4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 #include <linux/export.h>
9 #include <linux/types.h>
10 #include <sound/asoundef.h>
11 #include <sound/pcm.h>
12 #include <sound/pcm_iec958.h>
15 * snd_pcm_create_iec958_consumer - create consumer format IEC958 channel status
16 * @runtime: pcm runtime structure with ->rate filled in
17 * @cs: channel status buffer, at least four bytes
18 * @len: length of channel status buffer
20 * Create the consumer format channel status data in @cs of maximum size
21 * @len corresponding to the parameters of the PCM runtime @runtime.
23 * Drivers may wish to tweak the contents of the buffer after creation.
25 * Returns: length of buffer, or negative error code if something failed.
27 int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime
*runtime
, u8
*cs
,
35 switch (runtime
->rate
) {
37 fs
= IEC958_AES3_CON_FS_32000
;
40 fs
= IEC958_AES3_CON_FS_44100
;
43 fs
= IEC958_AES3_CON_FS_48000
;
46 fs
= IEC958_AES3_CON_FS_88200
;
49 fs
= IEC958_AES3_CON_FS_96000
;
52 fs
= IEC958_AES3_CON_FS_176400
;
55 fs
= IEC958_AES3_CON_FS_192000
;
62 switch (snd_pcm_format_width(runtime
->format
)) {
64 ws
= IEC958_AES4_CON_WORDLEN_20_16
;
67 ws
= IEC958_AES4_CON_WORDLEN_22_18
;
70 ws
= IEC958_AES4_CON_WORDLEN_20_16
|
71 IEC958_AES4_CON_MAX_WORDLEN_24
;
74 ws
= IEC958_AES4_CON_WORDLEN_24_20
|
75 IEC958_AES4_CON_MAX_WORDLEN_24
;
85 cs
[0] = IEC958_AES0_CON_NOT_COPYRIGHT
| IEC958_AES0_CON_EMPHASIS_NONE
;
86 cs
[1] = IEC958_AES1_CON_GENERAL
;
87 cs
[2] = IEC958_AES2_CON_SOURCE_UNSPEC
| IEC958_AES2_CON_CHANNEL_UNSPEC
;
88 cs
[3] = IEC958_AES3_CON_CLOCK_1000PPM
| fs
;
95 EXPORT_SYMBOL(snd_pcm_create_iec958_consumer
);