aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/sound/alsa/soc/DAI.txt
diff options
context:
space:
mode:
authorLiam Girdwood <liam.girdwood@wolfsonmicro.com>2006-10-06 12:34:51 -0400
committerJaroslav Kysela <perex@suse.cz>2007-02-09 03:00:20 -0500
commiteb1a6af39b70375d93ed25e7c916f64463e00614 (patch)
treea5cb9228ad4f5cad115d491a413a3ad0a0e7de29 /Documentation/sound/alsa/soc/DAI.txt
parenta3288176de3fdd439d9bca0a0b9ca749c12ac5ac (diff)
[ALSA] ASoC: documentation & maintainer
This patch adds documentation describing the ASoC architecture and a maintainer entry for ASoC. The documentation includes the following files:- codec.txt: Codec driver internals. DAI.txt: Description of Digital Audio Interface standards and how to configure a DAI within your codec and CPU DAI drivers. dapm.txt: Dynamic Audio Power Management. platform.txt: Platform audio DMA and DAI. machine.txt: Machine driver internals. pop_clicks.txt: How to minimise audio artifacts. clocking.txt: ASoC clocking for best power performance. Signed-off-by: Liam Girdwood <liam.girdwood@wolfsonmicro.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'Documentation/sound/alsa/soc/DAI.txt')
-rw-r--r--Documentation/sound/alsa/soc/DAI.txt380
1 files changed, 380 insertions, 0 deletions
diff --git a/Documentation/sound/alsa/soc/DAI.txt b/Documentation/sound/alsa/soc/DAI.txt
new file mode 100644
index 000000000000..919de76bab8d
--- /dev/null
+++ b/Documentation/sound/alsa/soc/DAI.txt
@@ -0,0 +1,380 @@
1ASoC currently supports the three main Digital Audio Interfaces (DAI) found on
2SoC controllers and portable audio CODECS today, namely AC97, I2S and PCM.
3
4
5AC97
6====
7
8 AC97 is a five wire interface commonly found on many PC sound cards. It is
9now also popular in many portable devices. This DAI has a reset line and time
10multiplexes its data on its SDATA_OUT (playback) and SDATA_IN (capture) lines.
11The bit clock (BCLK) is always driven by the CODEC (usually 12.288MHz) and the
12frame (FRAME) (usually 48kHz) is always driven by the controller. Each AC97
13frame is 21uS long and is divided into 13 time slots.
14
15The AC97 specification can be found at http://intel.com/
16
17
18I2S
19===
20
21 I2S is a common 4 wire DAI used in HiFi, STB and portable devices. The Tx and
22Rx lines are used for audio transmision, whilst the bit clock (BCLK) and
23left/right clock (LRC) synchronise the link. I2S is flexible in that either the
24controller or CODEC can drive (master) the BCLK and LRC clock lines. Bit clock
25usually varies depending on the sample rate and the master system clock
26(SYSCLK). LRCLK is the same as the sample rate. A few devices support separate
27ADC and DAC LRCLK's, this allows for similtanious capture and playback at
28different sample rates.
29
30I2S has several different operating modes:-
31
32 o I2S - MSB is transmitted on the falling edge of the first BCLK after LRC
33 transition.
34
35 o Left Justified - MSB is transmitted on transition of LRC.
36
37 o Right Justified - MSB is transmitted sample size BCLK's before LRC
38 transition.
39
40PCM
41===
42
43PCM is another 4 wire interface, very similar to I2S, that can support a more
44flexible protocol. It has bit clock (BCLK) and sync (SYNC) lines that are used
45to synchronise the link whilst the Tx and Rx lines are used to transmit and
46receive the audio data. Bit clock usually varies depending on sample rate
47whilst sync runs at the sample rate. PCM also supports Time Division
48Multiplexing (TDM) in that several devices can use the bus similtaniuosly (This
49is sometimes referred to as network mode).
50
51Common PCM operating modes:-
52
53 o Mode A - MSB is transmitted on falling edge of first BCLK after FRAME/SYNC.
54
55 o Mode B - MSB is transmitted on rising edge of FRAME/SYNC.
56
57
58ASoC DAI Configuration
59======================
60
61Every CODEC DAI and SoC DAI must have their capabilities defined in order to
62be configured together at runtime when the audio and clocking parameters are
63known. This is achieved by creating an array of struct snd_soc_hw_mode in the
64the CODEC and SoC interface drivers. Each element in the array describes a DAI
65mode and each mode is usually based upon the DAI system clock to sample rate
66ratio (FS).
67
68i.e. 48k sample rate @ 256 FS = sytem clock of 12.288 MHz
69 48000 * 256 = 12288000
70
71The CPU and Codec DAI modes are then ANDed together at runtime to determine the
72rutime DAI configuration for both the Codec and CPU.
73
74When creating a new codec or SoC DAI it's probably best to start of with a few
75sample rates first and then test your interface.
76
77struct snd_soc_dai_mode is defined (in soc.h) as:-
78
79/* SoC DAI mode */
80struct snd_soc_hw_mode {
81 unsigned int fmt:16; /* SND_SOC_DAIFMT_* */
82 unsigned int tdm:16; /* SND_SOC_DAITDM_* */
83 unsigned int pcmfmt:6; /* SNDRV_PCM_FORMAT_* */
84 unsigned int pcmrate:16; /* SND_SOC_DAIRATE_* */
85 unsigned int pcmdir:2; /* SND_SOC_DAIDIR_* */
86 unsigned int flags:8; /* hw flags */
87 unsigned int fs:32; /* mclk to rate dividers */
88 unsigned int bfs:16; /* mclk to bclk dividers */
89 unsigned long priv; /* private mode data */
90};
91
92fmt:
93----
94This field defines the DAI mode hardware format (e.g. I2S settings) and
95supports the following settings:-
96
97 1) hardware DAI formats
98
99#define SND_SOC_DAIFMT_I2S (1 << 0) /* I2S mode */
100#define SND_SOC_DAIFMT_RIGHT_J (1 << 1) /* Right justified mode */
101#define SND_SOC_DAIFMT_LEFT_J (1 << 2) /* Left Justified mode */
102#define SND_SOC_DAIFMT_DSP_A (1 << 3) /* L data msb after FRM */
103#define SND_SOC_DAIFMT_DSP_B (1 << 4) /* L data msb during FRM */
104#define SND_SOC_DAIFMT_AC97 (1 << 5) /* AC97 */
105
106 2) hw DAI signal inversions
107
108#define SND_SOC_DAIFMT_NB_NF (1 << 8) /* normal bit clock + frame */
109#define SND_SOC_DAIFMT_NB_IF (1 << 9) /* normal bclk + inv frm */
110#define SND_SOC_DAIFMT_IB_NF (1 << 10) /* invert bclk + nor frm */
111#define SND_SOC_DAIFMT_IB_IF (1 << 11) /* invert bclk + frm */
112
113 3) hw clock masters
114 This is wrt the codec, the inverse is true for the interface
115 i.e. if the codec is clk and frm master then the interface is
116 clk and frame slave.
117
118#define SND_SOC_DAIFMT_CBM_CFM (1 << 12) /* codec clk & frm master */
119#define SND_SOC_DAIFMT_CBS_CFM (1 << 13) /* codec clk slave & frm master */
120#define SND_SOC_DAIFMT_CBM_CFS (1 << 14) /* codec clk master & frame slave */
121#define SND_SOC_DAIFMT_CBS_CFS (1 << 15) /* codec clk & frm slave */
122
123At least one option from each section must be selected. Multiple selections are
124also supported e.g.
125
126 .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_RIGHT_J | \
127 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_NB_IF | SND_SOC_DAIFMT_IB_NF | \
128 SND_SOC_DAIFMT_IB_IF
129
130
131tdm:
132------
133This field defines the Time Division Multiplexing left and right word
134positions for the DAI mode if applicable. Set to SND_SOC_DAITDM_LRDW(0,0) for
135no TDM.
136
137
138pcmfmt:
139---------
140The hardware PCM format. This describes the PCM formats supported by the DAI
141mode e.g.
142
143 .hwpcmfmt = SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S20_3LE | \
144 SNDRV_PCM_FORMAT_S24_3LE
145
146pcmrate:
147----------
148The PCM sample rates supported by the DAI mode. e.g.
149
150 .hwpcmrate = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \
151 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
152 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000
153
154
155pcmdir:
156---------
157The stream directions supported by this mode. e.g. playback and capture
158
159
160flags:
161--------
162The DAI hardware flags supported by the mode.
163
164SND_SOC_DAI_BFS_DIV
165This flag states that bit clock is generated by dividing MCLK in this mode, if
166this flag is absent the bitclock generated by mulitiplying sample rate.
167
168NOTE: Bitclock division and mulitiplication modes can be safely matched by the
169core logic.
170
171
172fs:
173-----
174The FS supported by this DAI mode FS is the ratio between the system clock and
175the sample rate. See above
176
177bfs:
178------
179BFS is the ratio of BCLK to MCLK or the ratio of BCLK to sample rate (this
180depends on the codec or CPU DAI).
181
182The BFS supported by the DAI mode. This can either be the ratio between the
183bitclock (BCLK) and the sample rate OR the ratio between the system clock and
184the sample rate. Depends on the SND_SOC_DAI_BFS_DIV flag above.
185
186priv:
187-----
188private codec mode data.
189
190
191
192Examples
193========
194
195Note that Codec DAI and CPU DAI examples are interchangeable in these examples
196as long as the bus master is reversed. i.e.
197
198 SND_SOC_DAIFMT_CBM_CFM would become SND_SOC_DAIFMT_CBS_CFS
199 and vice versa.
200
201This applies to all SND_SOC_DAIFMT_CB*_CF*.
202
203Example 1
204---------
205
206Simple codec that only runs at 8k & 48k @ 256FS in master mode, can generate a
207BCLK of either MCLK/2 or MCLK/4.
208
209 /* codec master */
210 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, SND_SOC_DAITDM_LRDW(0,0),
211 SNDRV_PCM_FORMAT_S16_LE, SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
212 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, SND_SOC_DAI_BFS_DIV,
213 256, SND_SOC_FSBD(2) | SND_SOC_FSBD(4)},
214
215
216Example 2
217---------
218Simple codec that only runs at 8k & 48k @ 256FS in master mode, can generate a
219BCLK of either Rate * 32 or Rate * 64.
220
221 /* codec master */
222 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, SND_SOC_DAITDM_LRDW(0,0),
223 SNDRV_PCM_FORMAT_S16_LE, SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
224 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, 0,
225 256, SND_SOC_FSB(32) | SND_SOC_FSB(64)},
226
227
228Example 3
229---------
230Codec that only runs at 8k & 48k @ 256FS in master mode, can generate a
231BCLK of either Rate * 32 or Rate * 64. Codec can also run in slave mode as long
232as BCLK is rate * 32 or rate * 64.
233
234 /* codec master */
235 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, SND_SOC_DAITDM_LRDW(0,0),
236 SNDRV_PCM_FORMAT_S16_LE, SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
237 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, 0,
238 256, SND_SOC_FSB(32) | SND_SOC_FSB(64)},
239
240 /* codec slave */
241 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, SND_SOC_DAITDM_LRDW(0,0),
242 SNDRV_PCM_FORMAT_S16_LE, SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
243 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, 0,
244 SND_SOC_FS_ALL, SND_SOC_FSB(32) | SND_SOC_FSB(64)},
245
246
247Example 4
248---------
249Codec that only runs at 8k, 16k, 32k, 48k, 96k @ 128FS, 192FS & 256FS in master
250mode and can generate a BCLK of MCLK / (1,2,4,8,16). Codec can also run in slave
251mode as and does not care about FS or BCLK (as long as there is enough bandwidth).
252
253 #define CODEC_FSB \
254 (SND_SOC_FSBD(1) | SND_SOC_FSBD(2) | SND_SOC_FSBD(4) | \
255 SND_SOC_FSBD(8) | SND_SOC_FSBD(16))
256
257 #define CODEC_RATES \
258 (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_32000 |\
259 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000)
260
261 /* codec master @ 128, 192 & 256 FS */
262 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, SND_SOC_DAITDM_LRDW(0,0),
263 SNDRV_PCM_FORMAT_S16_LE, CODEC_RATES,
264 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, SND_SOC_DAI_BFS_DIV,
265 128, CODEC_FSB},
266
267 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, SND_SOC_DAITDM_LRDW(0,0),
268 SNDRV_PCM_FORMAT_S16_LE, CODEC_RATES,
269 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, SND_SOC_DAI_BFS_DIV,
270 192, CODEC_FSB},
271
272 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, SND_SOC_DAITDM_LRDW(0,0),
273 SNDRV_PCM_FORMAT_S16_LE, CODEC_RATES,
274 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, SND_SOC_DAI_BFS_DIV,
275 256, CODEC_FSB},
276
277 /* codec slave */
278 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, SND_SOC_DAITDM_LRDW(0,0),
279 SNDRV_PCM_FORMAT_S16_LE, CODEC_RATES,
280 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, 0,
281 SND_SOC_FS_ALL, SND_SOC_FSB_ALL},
282
283
284Example 5
285---------
286Codec that only runs at 8k, 44.1k, 48k @ different FS in master mode (for use
287with a fixed MCLK) and can generate a BCLK of MCLK / (1,2,4,8,16).
288Codec can also run in slave mode as and does not care about FS or BCLK (as long
289as there is enough bandwidth). Codec can support 16, 24 and 32 bit PCM sample
290sizes.
291
292 #define CODEC_FSB \
293 (SND_SOC_FSBD(1) | SND_SOC_FSBD(2) | SND_SOC_FSBD(4) | \
294 SND_SOC_FSBD(8) | SND_SOC_FSBD(16))
295
296 #define CODEC_PCM_FORMATS \
297 (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S20_3LE | \
298 SNDRV_PCM_FORMAT_S24_3LE | SNDRV_PCM_FORMAT_S24_LE | SNDRV_PCM_FORMAT_S32_LE)
299
300 /* codec master */
301 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, SND_SOC_DAITDM_LRDW(0,0),
302 SNDRV_PCM_FORMAT_S16_LE, SNDRV_PCM_RATE_8000,
303 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, SND_SOC_DAI_BFS_DIV,
304 1536, CODEC_FSB},
305
306 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, SND_SOC_DAITDM_LRDW(0,0),
307 SNDRV_PCM_FORMAT_S16_LE, SNDRV_PCM_RATE_44100,
308 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, SND_SOC_DAI_BFS_DIV,
309 272, CODEC_FSB},
310
311 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, SND_SOC_DAITDM_LRDW(0,0),
312 SNDRV_PCM_FORMAT_S16_LE, SNDRV_PCM_RATE_48000,
313 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, SND_SOC_DAI_BFS_DIV,
314 256, CODEC_FSB},
315
316 /* codec slave */
317 {SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, SND_SOC_DAITDM_LRDW(0,0),
318 SNDRV_PCM_FORMAT_S16_LE, CODEC_RATES,
319 SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, 0,
320 SND_SOC_FS_ALL, SND_SOC_FSB_ALL},
321
322
323Example 6
324---------
325AC97 Codec that does not support VRA (i.e only runs at 48k).
326
327 #define AC97_DIR \
328 (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE)
329
330
331 #define AC97_PCM_FORMATS \
332 (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S18_3LE | \
333 SNDRV_PCM_FORMAT_S20_3LE)
334
335 /* AC97 with no VRA */
336 {0, 0, AC97_PCM_FORMATS, SNDRV_PCM_RATE_48000},
337
338
339Example 7
340---------
341
342CPU DAI that supports 8k - 48k @ 256FS and BCLK = MCLK / 4 in master mode.
343Slave mode (CPU DAI is FRAME master) supports 8k - 96k at any FS as long as
344BCLK = 64 * rate. (Intel XScale I2S controller).
345
346 #define PXA_I2S_DAIFMT \
347 (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF)
348
349 #define PXA_I2S_DIR \
350 (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE)
351
352 #define PXA_I2S_RATES \
353 (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \
354 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
355 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
356
357 /* pxa2xx I2S frame and clock master modes */
358 {PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, SND_SOC_DAITDM_LRDW(0,0), SNDRV_PCM_FORMAT_S16_LE,
359 SNDRV_PCM_RATE_8000, PXA_I2S_DIR, SND_SOC_DAI_BFS_DIV, 256,
360 SND_SOC_FSBD(4), 0x48},
361 {PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, SND_SOC_DAITDM_LRDW(0,0), SNDRV_PCM_FORMAT_S16_LE,
362 SNDRV_PCM_RATE_11025, PXA_I2S_DIR, SND_SOC_DAI_BFS_DIV, 256,
363 SND_SOC_FSBD(4), 0x34},
364 {PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, SND_SOC_DAITDM_LRDW(0,0), SNDRV_PCM_FORMAT_S16_LE,
365 SNDRV_PCM_RATE_16000, PXA_I2S_DIR, SND_SOC_DAI_BFS_DIV, 256,
366 SND_SOC_FSBD(4), 0x24},
367 {PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, SND_SOC_DAITDM_LRDW(0,0), SNDRV_PCM_FORMAT_S16_LE,
368 SNDRV_PCM_RATE_22050, PXA_I2S_DIR, SND_SOC_DAI_BFS_DIV, 256,
369 SND_SOC_FSBD(4), 0x1a},
370 {PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, SND_SOC_DAITDM_LRDW(0,0), SNDRV_PCM_FORMAT_S16_LE,
371 SNDRV_PCM_RATE_44100, PXA_I2S_DIR, SND_SOC_DAI_BFS_DIV, 256,
372 SND_SOC_FSBD(4), 0xd},
373 {PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, SND_SOC_DAITDM_LRDW(0,0), SNDRV_PCM_FORMAT_S16_LE,
374 SNDRV_PCM_RATE_48000, PXA_I2S_DIR, SND_SOC_DAI_BFS_DIV, 256,
375 SND_SOC_FSBD(4), 0xc},
376
377 /* pxa2xx I2S frame master and clock slave mode */
378 {PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBM_CFS, SND_SOC_DAITDM_LRDW(0,0), SNDRV_PCM_FORMAT_S16_LE,
379 PXA_I2S_RATES, PXA_I2S_DIR, 0, SND_SOC_FS_ALL, SND_SOC_FSB(64)},
380