diff options
Diffstat (limited to 'Documentation/sound')
-rw-r--r-- | Documentation/sound/alsa/ALSA-Configuration.txt | 2 | ||||
-rw-r--r-- | Documentation/sound/alsa/Audiophile-Usb.txt | 2 | ||||
-rw-r--r-- | Documentation/sound/alsa/CMIPCI.txt | 2 | ||||
-rw-r--r-- | Documentation/sound/alsa/compress_offload.txt | 6 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/DPCM.txt | 380 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/codec.txt | 46 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/dapm.txt | 73 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/machine.txt | 6 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/platform.txt | 19 |
9 files changed, 463 insertions, 73 deletions
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 95731a08f257..b8dd0df76952 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt | |||
@@ -616,7 +616,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
616 | 616 | ||
617 | As default, snd-dummy drivers doesn't allocate the real buffers | 617 | As default, snd-dummy drivers doesn't allocate the real buffers |
618 | but either ignores read/write or mmap a single dummy page to all | 618 | but either ignores read/write or mmap a single dummy page to all |
619 | buffer pages, in order to save the resouces. If your apps need | 619 | buffer pages, in order to save the resources. If your apps need |
620 | the read/ written buffer data to be consistent, pass fake_buffer=0 | 620 | the read/ written buffer data to be consistent, pass fake_buffer=0 |
621 | option. | 621 | option. |
622 | 622 | ||
diff --git a/Documentation/sound/alsa/Audiophile-Usb.txt b/Documentation/sound/alsa/Audiophile-Usb.txt index 654dd3b694a8..e7a5ed4dcae8 100644 --- a/Documentation/sound/alsa/Audiophile-Usb.txt +++ b/Documentation/sound/alsa/Audiophile-Usb.txt | |||
@@ -232,7 +232,7 @@ The parameter can be given: | |||
232 | # modprobe snd-usb-audio index=1 device_setup=0x09 | 232 | # modprobe snd-usb-audio index=1 device_setup=0x09 |
233 | 233 | ||
234 | * Or while configuring the modules options in your modules configuration file | 234 | * Or while configuring the modules options in your modules configuration file |
235 | (tipically a .conf file in /etc/modprobe.d/ directory: | 235 | (typically a .conf file in /etc/modprobe.d/ directory: |
236 | alias snd-card-1 snd-usb-audio | 236 | alias snd-card-1 snd-usb-audio |
237 | options snd-usb-audio index=1 device_setup=0x09 | 237 | options snd-usb-audio index=1 device_setup=0x09 |
238 | 238 | ||
diff --git a/Documentation/sound/alsa/CMIPCI.txt b/Documentation/sound/alsa/CMIPCI.txt index 16935c8561f7..4e36e6e809ca 100644 --- a/Documentation/sound/alsa/CMIPCI.txt +++ b/Documentation/sound/alsa/CMIPCI.txt | |||
@@ -87,7 +87,7 @@ with 4 channels, | |||
87 | 87 | ||
88 | and use the interleaved 4 channel data. | 88 | and use the interleaved 4 channel data. |
89 | 89 | ||
90 | There are some control switchs affecting to the speaker connections: | 90 | There are some control switches affecting to the speaker connections: |
91 | 91 | ||
92 | "Line-In Mode" - an enum control to change the behavior of line-in | 92 | "Line-In Mode" - an enum control to change the behavior of line-in |
93 | jack. Either "Line-In", "Rear Output" or "Bass Output" can | 93 | jack. Either "Line-In", "Rear Output" or "Bass Output" can |
diff --git a/Documentation/sound/alsa/compress_offload.txt b/Documentation/sound/alsa/compress_offload.txt index fd74ff26376e..630c492c3dc2 100644 --- a/Documentation/sound/alsa/compress_offload.txt +++ b/Documentation/sound/alsa/compress_offload.txt | |||
@@ -217,12 +217,12 @@ Not supported: | |||
217 | would be enabled with ALSA kcontrols. | 217 | would be enabled with ALSA kcontrols. |
218 | 218 | ||
219 | - Audio policy/resource management. This API does not provide any | 219 | - Audio policy/resource management. This API does not provide any |
220 | hooks to query the utilization of the audio DSP, nor any premption | 220 | hooks to query the utilization of the audio DSP, nor any preemption |
221 | mechanisms. | 221 | mechanisms. |
222 | 222 | ||
223 | - No notion of underun/overrun. Since the bytes written are compressed | 223 | - No notion of underrun/overrun. Since the bytes written are compressed |
224 | in nature and data written/read doesn't translate directly to | 224 | in nature and data written/read doesn't translate directly to |
225 | rendered output in time, this does not deal with underrun/overun and | 225 | rendered output in time, this does not deal with underrun/overrun and |
226 | maybe dealt in user-library | 226 | maybe dealt in user-library |
227 | 227 | ||
228 | Credits: | 228 | Credits: |
diff --git a/Documentation/sound/alsa/soc/DPCM.txt b/Documentation/sound/alsa/soc/DPCM.txt new file mode 100644 index 000000000000..0110180b7ac6 --- /dev/null +++ b/Documentation/sound/alsa/soc/DPCM.txt | |||
@@ -0,0 +1,380 @@ | |||
1 | Dynamic PCM | ||
2 | =========== | ||
3 | |||
4 | 1. Description | ||
5 | ============== | ||
6 | |||
7 | Dynamic PCM allows an ALSA PCM device to digitally route its PCM audio to | ||
8 | various digital endpoints during the PCM stream runtime. e.g. PCM0 can route | ||
9 | digital audio to I2S DAI0, I2S DAI1 or PDM DAI2. This is useful for on SoC DSP | ||
10 | drivers that expose several ALSA PCMs and can route to multiple DAIs. | ||
11 | |||
12 | The DPCM runtime routing is determined by the ALSA mixer settings in the same | ||
13 | way as the analog signal is routed in an ASoC codec driver. DPCM uses a DAPM | ||
14 | graph representing the DSP internal audio paths and uses the mixer settings to | ||
15 | determine the patch used by each ALSA PCM. | ||
16 | |||
17 | DPCM re-uses all the existing component codec, platform and DAI drivers without | ||
18 | any modifications. | ||
19 | |||
20 | |||
21 | Phone Audio System with SoC based DSP | ||
22 | ------------------------------------- | ||
23 | |||
24 | Consider the following phone audio subsystem. This will be used in this | ||
25 | document for all examples :- | ||
26 | |||
27 | | Front End PCMs | SoC DSP | Back End DAIs | Audio devices | | ||
28 | |||
29 | ************* | ||
30 | PCM0 <------------> * * <----DAI0-----> Codec Headset | ||
31 | * * | ||
32 | PCM1 <------------> * * <----DAI1-----> Codec Speakers | ||
33 | * DSP * | ||
34 | PCM2 <------------> * * <----DAI2-----> MODEM | ||
35 | * * | ||
36 | PCM3 <------------> * * <----DAI3-----> BT | ||
37 | * * | ||
38 | * * <----DAI4-----> DMIC | ||
39 | * * | ||
40 | * * <----DAI5-----> FM | ||
41 | ************* | ||
42 | |||
43 | This diagram shows a simple smart phone audio subsystem. It supports Bluetooth, | ||
44 | FM digital radio, Speakers, Headset Jack, digital microphones and cellular | ||
45 | modem. This sound card exposes 4 DSP front end (FE) ALSA PCM devices and | ||
46 | supports 6 back end (BE) DAIs. Each FE PCM can digitally route audio data to any | ||
47 | of the BE DAIs. The FE PCM devices can also route audio to more than 1 BE DAI. | ||
48 | |||
49 | |||
50 | |||
51 | Example - DPCM Switching playback from DAI0 to DAI1 | ||
52 | --------------------------------------------------- | ||
53 | |||
54 | Audio is being played to the Headset. After a while the user removes the headset | ||
55 | and audio continues playing on the speakers. | ||
56 | |||
57 | Playback on PCM0 to Headset would look like :- | ||
58 | |||
59 | ************* | ||
60 | PCM0 <============> * * <====DAI0=====> Codec Headset | ||
61 | * * | ||
62 | PCM1 <------------> * * <----DAI1-----> Codec Speakers | ||
63 | * DSP * | ||
64 | PCM2 <------------> * * <----DAI2-----> MODEM | ||
65 | * * | ||
66 | PCM3 <------------> * * <----DAI3-----> BT | ||
67 | * * | ||
68 | * * <----DAI4-----> DMIC | ||
69 | * * | ||
70 | * * <----DAI5-----> FM | ||
71 | ************* | ||
72 | |||
73 | The headset is removed from the jack by user so the speakers must now be used :- | ||
74 | |||
75 | ************* | ||
76 | PCM0 <============> * * <----DAI0-----> Codec Headset | ||
77 | * * | ||
78 | PCM1 <------------> * * <====DAI1=====> Codec Speakers | ||
79 | * DSP * | ||
80 | PCM2 <------------> * * <----DAI2-----> MODEM | ||
81 | * * | ||
82 | PCM3 <------------> * * <----DAI3-----> BT | ||
83 | * * | ||
84 | * * <----DAI4-----> DMIC | ||
85 | * * | ||
86 | * * <----DAI5-----> FM | ||
87 | ************* | ||
88 | |||
89 | The audio driver processes this as follows :- | ||
90 | |||
91 | 1) Machine driver receives Jack removal event. | ||
92 | |||
93 | 2) Machine driver OR audio HAL disables the Headset path. | ||
94 | |||
95 | 3) DPCM runs the PCM trigger(stop), hw_free(), shutdown() operations on DAI0 | ||
96 | for headset since the path is now disabled. | ||
97 | |||
98 | 4) Machine driver or audio HAL enables the speaker path. | ||
99 | |||
100 | 5) DPCM runs the PCM ops for startup(), hw_params(), prepapre() and | ||
101 | trigger(start) for DAI1 Speakers since the path is enabled. | ||
102 | |||
103 | In this example, the machine driver or userspace audio HAL can alter the routing | ||
104 | and then DPCM will take care of managing the DAI PCM operations to either bring | ||
105 | the link up or down. Audio playback does not stop during this transition. | ||
106 | |||
107 | |||
108 | |||
109 | DPCM machine driver | ||
110 | =================== | ||
111 | |||
112 | The DPCM enabled ASoC machine driver is similar to normal machine drivers | ||
113 | except that we also have to :- | ||
114 | |||
115 | 1) Define the FE and BE DAI links. | ||
116 | |||
117 | 2) Define any FE/BE PCM operations. | ||
118 | |||
119 | 3) Define widget graph connections. | ||
120 | |||
121 | |||
122 | 1 FE and BE DAI links | ||
123 | --------------------- | ||
124 | |||
125 | | Front End PCMs | SoC DSP | Back End DAIs | Audio devices | | ||
126 | |||
127 | ************* | ||
128 | PCM0 <------------> * * <----DAI0-----> Codec Headset | ||
129 | * * | ||
130 | PCM1 <------------> * * <----DAI1-----> Codec Speakers | ||
131 | * DSP * | ||
132 | PCM2 <------------> * * <----DAI2-----> MODEM | ||
133 | * * | ||
134 | PCM3 <------------> * * <----DAI3-----> BT | ||
135 | * * | ||
136 | * * <----DAI4-----> DMIC | ||
137 | * * | ||
138 | * * <----DAI5-----> FM | ||
139 | ************* | ||
140 | |||
141 | For the example above we have to define 4 FE DAI links and 6 BE DAI links. The | ||
142 | FE DAI links are defined as follows :- | ||
143 | |||
144 | static struct snd_soc_dai_link machine_dais[] = { | ||
145 | { | ||
146 | .name = "PCM0 System", | ||
147 | .stream_name = "System Playback", | ||
148 | .cpu_dai_name = "System Pin", | ||
149 | .platform_name = "dsp-audio", | ||
150 | .codec_name = "snd-soc-dummy", | ||
151 | .codec_dai_name = "snd-soc-dummy-dai", | ||
152 | .dynamic = 1, | ||
153 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | ||
154 | .dpcm_playback = 1, | ||
155 | }, | ||
156 | .....< other FE and BE DAI links here > | ||
157 | }; | ||
158 | |||
159 | This FE DAI link is pretty similar to a regular DAI link except that we also | ||
160 | set the DAI link to a DPCM FE with the "dynamic = 1". The supported FE stream | ||
161 | directions should also be set with the "dpcm_playback" and "dpcm_capture" | ||
162 | flags. There is also an option to specify the ordering of the trigger call for | ||
163 | each FE. This allows the ASoC core to trigger the DSP before or after the other | ||
164 | components (as some DSPs have strong requirements for the ordering DAI/DSP | ||
165 | start and stop sequences). | ||
166 | |||
167 | The FE DAI above sets the codec and code DAIs to dummy devices since the BE is | ||
168 | dynamic and will change depending on runtime config. | ||
169 | |||
170 | The BE DAIs are configured as follows :- | ||
171 | |||
172 | static struct snd_soc_dai_link machine_dais[] = { | ||
173 | .....< FE DAI links here > | ||
174 | { | ||
175 | .name = "Codec Headset", | ||
176 | .cpu_dai_name = "ssp-dai.0", | ||
177 | .platform_name = "snd-soc-dummy", | ||
178 | .no_pcm = 1, | ||
179 | .codec_name = "rt5640.0-001c", | ||
180 | .codec_dai_name = "rt5640-aif1", | ||
181 | .ignore_suspend = 1, | ||
182 | .ignore_pmdown_time = 1, | ||
183 | .be_hw_params_fixup = hswult_ssp0_fixup, | ||
184 | .ops = &haswell_ops, | ||
185 | .dpcm_playback = 1, | ||
186 | .dpcm_capture = 1, | ||
187 | }, | ||
188 | .....< other BE DAI links here > | ||
189 | }; | ||
190 | |||
191 | This BE DAI link connects DAI0 to the codec (in this case RT5460 AIF1). It sets | ||
192 | the "no_pcm" flag to mark it has a BE and sets flags for supported stream | ||
193 | directions using "dpcm_playback" and "dpcm_capture" above. | ||
194 | |||
195 | The BE has also flags set for ignoring suspend and PM down time. This allows | ||
196 | the BE to work in a hostless mode where the host CPU is not transferring data | ||
197 | like a BT phone call :- | ||
198 | |||
199 | ************* | ||
200 | PCM0 <------------> * * <----DAI0-----> Codec Headset | ||
201 | * * | ||
202 | PCM1 <------------> * * <----DAI1-----> Codec Speakers | ||
203 | * DSP * | ||
204 | PCM2 <------------> * * <====DAI2=====> MODEM | ||
205 | * * | ||
206 | PCM3 <------------> * * <====DAI3=====> BT | ||
207 | * * | ||
208 | * * <----DAI4-----> DMIC | ||
209 | * * | ||
210 | * * <----DAI5-----> FM | ||
211 | ************* | ||
212 | |||
213 | This allows the host CPU to sleep whilst the DSP, MODEM DAI and the BT DAI are | ||
214 | still in operation. | ||
215 | |||
216 | A BE DAI link can also set the codec to a dummy device if the code is a device | ||
217 | that is managed externally. | ||
218 | |||
219 | Likewise a BE DAI can also set a dummy cpu DAI if the CPU DAI is managed by the | ||
220 | DSP firmware. | ||
221 | |||
222 | |||
223 | 2 FE/BE PCM operations | ||
224 | ---------------------- | ||
225 | |||
226 | The BE above also exports some PCM operations and a "fixup" callback. The fixup | ||
227 | callback is used by the machine driver to (re)configure the DAI based upon the | ||
228 | FE hw params. i.e. the DSP may perform SRC or ASRC from the FE to BE. | ||
229 | |||
230 | e.g. DSP converts all FE hw params to run at fixed rate of 48k, 16bit, stereo for | ||
231 | DAI0. This means all FE hw_params have to be fixed in the machine driver for | ||
232 | DAI0 so that the DAI is running at desired configuration regardless of the FE | ||
233 | configuration. | ||
234 | |||
235 | static int dai0_fixup(struct snd_soc_pcm_runtime *rtd, | ||
236 | struct snd_pcm_hw_params *params) | ||
237 | { | ||
238 | struct snd_interval *rate = hw_param_interval(params, | ||
239 | SNDRV_PCM_HW_PARAM_RATE); | ||
240 | struct snd_interval *channels = hw_param_interval(params, | ||
241 | SNDRV_PCM_HW_PARAM_CHANNELS); | ||
242 | |||
243 | /* The DSP will covert the FE rate to 48k, stereo */ | ||
244 | rate->min = rate->max = 48000; | ||
245 | channels->min = channels->max = 2; | ||
246 | |||
247 | /* set DAI0 to 16 bit */ | ||
248 | snd_mask_set(¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT - | ||
249 | SNDRV_PCM_HW_PARAM_FIRST_MASK], | ||
250 | SNDRV_PCM_FORMAT_S16_LE); | ||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | The other PCM operation are the same as for regular DAI links. Use as necessary. | ||
255 | |||
256 | |||
257 | 3 Widget graph connections | ||
258 | -------------------------- | ||
259 | |||
260 | The BE DAI links will normally be connected to the graph at initialisation time | ||
261 | by the ASoC DAPM core. However, if the BE codec or BE DAI is a dummy then this | ||
262 | has to be set explicitly in the driver :- | ||
263 | |||
264 | /* BE for codec Headset - DAI0 is dummy and managed by DSP FW */ | ||
265 | {"DAI0 CODEC IN", NULL, "AIF1 Capture"}, | ||
266 | {"AIF1 Playback", NULL, "DAI0 CODEC OUT"}, | ||
267 | |||
268 | |||
269 | Writing a DPCM DSP driver | ||
270 | ========================= | ||
271 | |||
272 | The DPCM DSP driver looks much like a standard platform class ASoC driver | ||
273 | combined with elements from a codec class driver. A DSP platform driver must | ||
274 | implement :- | ||
275 | |||
276 | 1) Front End PCM DAIs - i.e. struct snd_soc_dai_driver. | ||
277 | |||
278 | 2) DAPM graph showing DSP audio routing from FE DAIs to BEs. | ||
279 | |||
280 | 3) DAPM widgets from DSP graph. | ||
281 | |||
282 | 4) Mixers for gains, routing, etc. | ||
283 | |||
284 | 5) DMA configuration. | ||
285 | |||
286 | 6) BE AIF widgets. | ||
287 | |||
288 | Items 6 is important for routing the audio outside of the DSP. AIF need to be | ||
289 | defined for each BE and each stream direction. e.g for BE DAI0 above we would | ||
290 | have :- | ||
291 | |||
292 | SND_SOC_DAPM_AIF_IN("DAI0 RX", NULL, 0, SND_SOC_NOPM, 0, 0), | ||
293 | SND_SOC_DAPM_AIF_OUT("DAI0 TX", NULL, 0, SND_SOC_NOPM, 0, 0), | ||
294 | |||
295 | The BE AIF are used to connect the DSP graph to the graphs for the other | ||
296 | component drivers (e.g. codec graph). | ||
297 | |||
298 | |||
299 | Hostless PCM streams | ||
300 | ==================== | ||
301 | |||
302 | A hostless PCM stream is a stream that is not routed through the host CPU. An | ||
303 | example of this would be a phone call from handset to modem. | ||
304 | |||
305 | |||
306 | ************* | ||
307 | PCM0 <------------> * * <----DAI0-----> Codec Headset | ||
308 | * * | ||
309 | PCM1 <------------> * * <====DAI1=====> Codec Speakers/Mic | ||
310 | * DSP * | ||
311 | PCM2 <------------> * * <====DAI2=====> MODEM | ||
312 | * * | ||
313 | PCM3 <------------> * * <----DAI3-----> BT | ||
314 | * * | ||
315 | * * <----DAI4-----> DMIC | ||
316 | * * | ||
317 | * * <----DAI5-----> FM | ||
318 | ************* | ||
319 | |||
320 | In this case the PCM data is routed via the DSP. The host CPU in this use case | ||
321 | is only used for control and can sleep during the runtime of the stream. | ||
322 | |||
323 | The host can control the hostless link either by :- | ||
324 | |||
325 | 1) Configuring the link as a CODEC <-> CODEC style link. In this case the link | ||
326 | is enabled or disabled by the state of the DAPM graph. This usually means | ||
327 | there is a mixer control that can be used to connect or disconnect the path | ||
328 | between both DAIs. | ||
329 | |||
330 | 2) Hostless FE. This FE has a virtual connection to the BE DAI links on the DAPM | ||
331 | graph. Control is then carried out by the FE as regular PCM operations. | ||
332 | This method gives more control over the DAI links, but requires much more | ||
333 | userspace code to control the link. Its recommended to use CODEC<->CODEC | ||
334 | unless your HW needs more fine grained sequencing of the PCM ops. | ||
335 | |||
336 | |||
337 | CODEC <-> CODEC link | ||
338 | -------------------- | ||
339 | |||
340 | This DAI link is enabled when DAPM detects a valid path within the DAPM graph. | ||
341 | The machine driver sets some additional parameters to the DAI link i.e. | ||
342 | |||
343 | static const struct snd_soc_pcm_stream dai_params = { | ||
344 | .formats = SNDRV_PCM_FMTBIT_S32_LE, | ||
345 | .rate_min = 8000, | ||
346 | .rate_max = 8000, | ||
347 | .channels_min = 2, | ||
348 | .channels_max = 2, | ||
349 | }; | ||
350 | |||
351 | static struct snd_soc_dai_link dais[] = { | ||
352 | < ... more DAI links above ... > | ||
353 | { | ||
354 | .name = "MODEM", | ||
355 | .stream_name = "MODEM", | ||
356 | .cpu_dai_name = "dai2", | ||
357 | .codec_dai_name = "modem-aif1", | ||
358 | .codec_name = "modem", | ||
359 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | ||
360 | | SND_SOC_DAIFMT_CBM_CFM, | ||
361 | .params = &dai_params, | ||
362 | } | ||
363 | < ... more DAI links here ... > | ||
364 | |||
365 | These parameters are used to configure the DAI hw_params() when DAPM detects a | ||
366 | valid path and then calls the PCM operations to start the link. DAPM will also | ||
367 | call the appropriate PCM operations to disable the DAI when the path is no | ||
368 | longer valid. | ||
369 | |||
370 | |||
371 | Hostless FE | ||
372 | ----------- | ||
373 | |||
374 | The DAI link(s) are enabled by a FE that does not read or write any PCM data. | ||
375 | This means creating a new FE that is connected with a virtual path to both | ||
376 | DAI links. The DAI links will be started when the FE PCM is started and stopped | ||
377 | when the FE PCM is stopped. Note that the FE PCM cannot read or write data in | ||
378 | this configuration. | ||
379 | |||
380 | |||
diff --git a/Documentation/sound/alsa/soc/codec.txt b/Documentation/sound/alsa/soc/codec.txt index bce23a4a7875..db5f9c9ae149 100644 --- a/Documentation/sound/alsa/soc/codec.txt +++ b/Documentation/sound/alsa/soc/codec.txt | |||
@@ -1,22 +1,23 @@ | |||
1 | ASoC Codec Driver | 1 | ASoC Codec Class Driver |
2 | ================= | 2 | ======================= |
3 | 3 | ||
4 | The codec driver is generic and hardware independent code that configures the | 4 | The codec class driver is generic and hardware independent code that configures |
5 | codec to provide audio capture and playback. It should contain no code that is | 5 | the codec, FM, MODEM, BT or external DSP to provide audio capture and playback. |
6 | specific to the target platform or machine. All platform and machine specific | 6 | It should contain no code that is specific to the target platform or machine. |
7 | code should be added to the platform and machine drivers respectively. | 7 | All platform and machine specific code should be added to the platform and |
8 | machine drivers respectively. | ||
8 | 9 | ||
9 | Each codec driver *must* provide the following features:- | 10 | Each codec class driver *must* provide the following features:- |
10 | 11 | ||
11 | 1) Codec DAI and PCM configuration | 12 | 1) Codec DAI and PCM configuration |
12 | 2) Codec control IO - using I2C, 3 Wire(SPI) or both APIs | 13 | 2) Codec control IO - using RegMap API |
13 | 3) Mixers and audio controls | 14 | 3) Mixers and audio controls |
14 | 4) Codec audio operations | 15 | 4) Codec audio operations |
16 | 5) DAPM description. | ||
17 | 6) DAPM event handler. | ||
15 | 18 | ||
16 | Optionally, codec drivers can also provide:- | 19 | Optionally, codec drivers can also provide:- |
17 | 20 | ||
18 | 5) DAPM description. | ||
19 | 6) DAPM event handler. | ||
20 | 7) DAC Digital mute control. | 21 | 7) DAC Digital mute control. |
21 | 22 | ||
22 | Its probably best to use this guide in conjunction with the existing codec | 23 | Its probably best to use this guide in conjunction with the existing codec |
@@ -64,26 +65,9 @@ struct snd_soc_dai_driver wm8731_dai = { | |||
64 | 2 - Codec control IO | 65 | 2 - Codec control IO |
65 | -------------------- | 66 | -------------------- |
66 | The codec can usually be controlled via an I2C or SPI style interface | 67 | The codec can usually be controlled via an I2C or SPI style interface |
67 | (AC97 combines control with data in the DAI). The codec drivers provide | 68 | (AC97 combines control with data in the DAI). The codec driver should use the |
68 | functions to read and write the codec registers along with supplying a | 69 | Regmap API for all codec IO. Please see include/linux/regmap.h and existing |
69 | register cache:- | 70 | codec drivers for example regmap usage. |
70 | |||
71 | /* IO control data and register cache */ | ||
72 | void *control_data; /* codec control (i2c/3wire) data */ | ||
73 | void *reg_cache; | ||
74 | |||
75 | Codec read/write should do any data formatting and call the hardware | ||
76 | read write below to perform the IO. These functions are called by the | ||
77 | core and ALSA when performing DAPM or changing the mixer:- | ||
78 | |||
79 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | ||
80 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | ||
81 | |||
82 | Codec hardware IO functions - usually points to either the I2C, SPI or AC97 | ||
83 | read/write:- | ||
84 | |||
85 | hw_write_t hw_write; | ||
86 | hw_read_t hw_read; | ||
87 | 71 | ||
88 | 72 | ||
89 | 3 - Mixers and audio controls | 73 | 3 - Mixers and audio controls |
@@ -127,7 +111,7 @@ Defines a stereo enumerated control | |||
127 | 111 | ||
128 | 4 - Codec Audio Operations | 112 | 4 - Codec Audio Operations |
129 | -------------------------- | 113 | -------------------------- |
130 | The codec driver also supports the following ALSA operations:- | 114 | The codec driver also supports the following ALSA PCM operations:- |
131 | 115 | ||
132 | /* SoC audio ops */ | 116 | /* SoC audio ops */ |
133 | struct snd_soc_ops { | 117 | struct snd_soc_ops { |
diff --git a/Documentation/sound/alsa/soc/dapm.txt b/Documentation/sound/alsa/soc/dapm.txt index 05bf5a0eee41..6faab4880006 100644 --- a/Documentation/sound/alsa/soc/dapm.txt +++ b/Documentation/sound/alsa/soc/dapm.txt | |||
@@ -21,7 +21,7 @@ level power systems. | |||
21 | 21 | ||
22 | There are 4 power domains within DAPM | 22 | There are 4 power domains within DAPM |
23 | 23 | ||
24 | 1. Codec domain - VREF, VMID (core codec and audio power) | 24 | 1. Codec bias domain - VREF, VMID (core codec and audio power) |
25 | Usually controlled at codec probe/remove and suspend/resume, although | 25 | Usually controlled at codec probe/remove and suspend/resume, although |
26 | can be set at stream time if power is not needed for sidetone, etc. | 26 | can be set at stream time if power is not needed for sidetone, etc. |
27 | 27 | ||
@@ -30,7 +30,7 @@ There are 4 power domains within DAPM | |||
30 | machine driver and responds to asynchronous events e.g when HP | 30 | machine driver and responds to asynchronous events e.g when HP |
31 | are inserted | 31 | are inserted |
32 | 32 | ||
33 | 3. Path domain - audio susbsystem signal paths | 33 | 3. Path domain - audio subsystem signal paths |
34 | Automatically set when mixer and mux settings are changed by the user. | 34 | Automatically set when mixer and mux settings are changed by the user. |
35 | e.g. alsamixer, amixer. | 35 | e.g. alsamixer, amixer. |
36 | 36 | ||
@@ -63,14 +63,22 @@ Audio DAPM widgets fall into a number of types:- | |||
63 | o Line - Line Input/Output (and optional Jack) | 63 | o Line - Line Input/Output (and optional Jack) |
64 | o Speaker - Speaker | 64 | o Speaker - Speaker |
65 | o Supply - Power or clock supply widget used by other widgets. | 65 | o Supply - Power or clock supply widget used by other widgets. |
66 | o Regulator - External regulator that supplies power to audio components. | ||
67 | o Clock - External clock that supplies clock to audio components. | ||
68 | o AIF IN - Audio Interface Input (with TDM slot mask). | ||
69 | o AIF OUT - Audio Interface Output (with TDM slot mask). | ||
70 | o Siggen - Signal Generator. | ||
71 | o DAI IN - Digital Audio Interface Input. | ||
72 | o DAI OUT - Digital Audio Interface Output. | ||
73 | o DAI Link - DAI Link between two DAI structures */ | ||
66 | o Pre - Special PRE widget (exec before all others) | 74 | o Pre - Special PRE widget (exec before all others) |
67 | o Post - Special POST widget (exec after all others) | 75 | o Post - Special POST widget (exec after all others) |
68 | 76 | ||
69 | (Widgets are defined in include/sound/soc-dapm.h) | 77 | (Widgets are defined in include/sound/soc-dapm.h) |
70 | 78 | ||
71 | Widgets are usually added in the codec driver and the machine driver. There are | 79 | Widgets can be added to the sound card by any of the component driver types. |
72 | convenience macros defined in soc-dapm.h that can be used to quickly build a | 80 | There are convenience macros defined in soc-dapm.h that can be used to quickly |
73 | list of widgets of the codecs and machines DAPM widgets. | 81 | build a list of widgets of the codecs and machines DAPM widgets. |
74 | 82 | ||
75 | Most widgets have a name, register, shift and invert. Some widgets have extra | 83 | Most widgets have a name, register, shift and invert. Some widgets have extra |
76 | parameters for stream name and kcontrols. | 84 | parameters for stream name and kcontrols. |
@@ -80,11 +88,13 @@ parameters for stream name and kcontrols. | |||
80 | ------------------------- | 88 | ------------------------- |
81 | 89 | ||
82 | Stream Widgets relate to the stream power domain and only consist of ADCs | 90 | Stream Widgets relate to the stream power domain and only consist of ADCs |
83 | (analog to digital converters) and DACs (digital to analog converters). | 91 | (analog to digital converters), DACs (digital to analog converters), |
92 | AIF IN and AIF OUT. | ||
84 | 93 | ||
85 | Stream widgets have the following format:- | 94 | Stream widgets have the following format:- |
86 | 95 | ||
87 | SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert), | 96 | SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert), |
97 | SND_SOC_DAPM_AIF_IN(name, stream, slot, reg, shift, invert) | ||
88 | 98 | ||
89 | NOTE: the stream name must match the corresponding stream name in your codec | 99 | NOTE: the stream name must match the corresponding stream name in your codec |
90 | snd_soc_codec_dai. | 100 | snd_soc_codec_dai. |
@@ -94,6 +104,11 @@ e.g. stream widgets for HiFi playback and capture | |||
94 | SND_SOC_DAPM_DAC("HiFi DAC", "HiFi Playback", REG, 3, 1), | 104 | SND_SOC_DAPM_DAC("HiFi DAC", "HiFi Playback", REG, 3, 1), |
95 | SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1), | 105 | SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1), |
96 | 106 | ||
107 | e.g. stream widgets for AIF | ||
108 | |||
109 | SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), | ||
110 | SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0), | ||
111 | |||
97 | 112 | ||
98 | 2.2 Path Domain Widgets | 113 | 2.2 Path Domain Widgets |
99 | ----------------------- | 114 | ----------------------- |
@@ -121,12 +136,14 @@ If you dont want the mixer elements prefixed with the name of the mixer widget, | |||
121 | you can use SND_SOC_DAPM_MIXER_NAMED_CTL instead. the parameters are the same | 136 | you can use SND_SOC_DAPM_MIXER_NAMED_CTL instead. the parameters are the same |
122 | as for SND_SOC_DAPM_MIXER. | 137 | as for SND_SOC_DAPM_MIXER. |
123 | 138 | ||
124 | 2.3 Platform/Machine domain Widgets | 139 | |
125 | ----------------------------------- | 140 | 2.3 Machine domain Widgets |
141 | -------------------------- | ||
126 | 142 | ||
127 | Machine widgets are different from codec widgets in that they don't have a | 143 | Machine widgets are different from codec widgets in that they don't have a |
128 | codec register bit associated with them. A machine widget is assigned to each | 144 | codec register bit associated with them. A machine widget is assigned to each |
129 | machine audio component (non codec) that can be independently powered. e.g. | 145 | machine audio component (non codec or DSP) that can be independently |
146 | powered. e.g. | ||
130 | 147 | ||
131 | o Speaker Amp | 148 | o Speaker Amp |
132 | o Microphone Bias | 149 | o Microphone Bias |
@@ -146,12 +163,12 @@ static int spitz_mic_bias(struct snd_soc_dapm_widget* w, int event) | |||
146 | SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias), | 163 | SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias), |
147 | 164 | ||
148 | 165 | ||
149 | 2.4 Codec Domain | 166 | 2.4 Codec (BIAS) Domain |
150 | ---------------- | 167 | ----------------------- |
151 | 168 | ||
152 | The codec power domain has no widgets and is handled by the codecs DAPM event | 169 | The codec bias power domain has no widgets and is handled by the codecs DAPM |
153 | handler. This handler is called when the codec powerstate is changed wrt to any | 170 | event handler. This handler is called when the codec powerstate is changed wrt |
154 | stream event or by kernel PM events. | 171 | to any stream event or by kernel PM events. |
155 | 172 | ||
156 | 173 | ||
157 | 2.5 Virtual Widgets | 174 | 2.5 Virtual Widgets |
@@ -169,15 +186,16 @@ After all the widgets have been defined, they can then be added to the DAPM | |||
169 | subsystem individually with a call to snd_soc_dapm_new_control(). | 186 | subsystem individually with a call to snd_soc_dapm_new_control(). |
170 | 187 | ||
171 | 188 | ||
172 | 3. Codec Widget Interconnections | 189 | 3. Codec/DSP Widget Interconnections |
173 | ================================ | 190 | ==================================== |
174 | 191 | ||
175 | Widgets are connected to each other within the codec and machine by audio paths | 192 | Widgets are connected to each other within the codec, platform and machine by |
176 | (called interconnections). Each interconnection must be defined in order to | 193 | audio paths (called interconnections). Each interconnection must be defined in |
177 | create a map of all audio paths between widgets. | 194 | order to create a map of all audio paths between widgets. |
178 | 195 | ||
179 | This is easiest with a diagram of the codec (and schematic of the machine audio | 196 | This is easiest with a diagram of the codec or DSP (and schematic of the machine |
180 | system), as it requires joining widgets together via their audio signal paths. | 197 | audio system), as it requires joining widgets together via their audio signal |
198 | paths. | ||
181 | 199 | ||
182 | e.g., from the WM8731 output mixer (wm8731.c) | 200 | e.g., from the WM8731 output mixer (wm8731.c) |
183 | 201 | ||
@@ -247,16 +265,9 @@ machine and includes the codec. e.g. | |||
247 | o Mic Jack | 265 | o Mic Jack |
248 | o Codec Pins | 266 | o Codec Pins |
249 | 267 | ||
250 | When a codec pin is NC it can be marked as not used with a call to | 268 | Endpoints are added to the DAPM graph so that their usage can be determined in |
251 | 269 | order to save power. e.g. NC codecs pins will be switched OFF, unconnected | |
252 | snd_soc_dapm_set_endpoint(codec, "Widget Name", 0); | 270 | jacks can also be switched OFF. |
253 | |||
254 | The last argument is 0 for inactive and 1 for active. This way the pin and its | ||
255 | input widget will never be powered up and consume power. | ||
256 | |||
257 | This also applies to machine widgets. e.g. if a headphone is connected to a | ||
258 | jack then the jack can be marked active. If the headphone is removed, then | ||
259 | the headphone jack can be marked inactive. | ||
260 | 271 | ||
261 | 272 | ||
262 | 5 DAPM Widget Events | 273 | 5 DAPM Widget Events |
diff --git a/Documentation/sound/alsa/soc/machine.txt b/Documentation/sound/alsa/soc/machine.txt index d50c14df3411..74056dba52be 100644 --- a/Documentation/sound/alsa/soc/machine.txt +++ b/Documentation/sound/alsa/soc/machine.txt | |||
@@ -1,8 +1,10 @@ | |||
1 | ASoC Machine Driver | 1 | ASoC Machine Driver |
2 | =================== | 2 | =================== |
3 | 3 | ||
4 | The ASoC machine (or board) driver is the code that glues together the platform | 4 | The ASoC machine (or board) driver is the code that glues together all the |
5 | and codec drivers. | 5 | component drivers (e.g. codecs, platforms and DAIs). It also describes the |
6 | relationships between each componnent which include audio paths, GPIOs, | ||
7 | interrupts, clocking, jacks and voltage regulators. | ||
6 | 8 | ||
7 | The machine driver can contain codec and platform specific code. It registers | 9 | The machine driver can contain codec and platform specific code. It registers |
8 | the audio subsystem with the kernel as a platform device and is represented by | 10 | the audio subsystem with the kernel as a platform device and is represented by |
diff --git a/Documentation/sound/alsa/soc/platform.txt b/Documentation/sound/alsa/soc/platform.txt index d57efad37e0a..3a08a2c9150c 100644 --- a/Documentation/sound/alsa/soc/platform.txt +++ b/Documentation/sound/alsa/soc/platform.txt | |||
@@ -1,9 +1,9 @@ | |||
1 | ASoC Platform Driver | 1 | ASoC Platform Driver |
2 | ==================== | 2 | ==================== |
3 | 3 | ||
4 | An ASoC platform driver can be divided into audio DMA and SoC DAI configuration | 4 | An ASoC platform driver class can be divided into audio DMA drivers, SoC DAI |
5 | and control. The platform drivers only target the SoC CPU and must have no board | 5 | drivers and DSP drivers. The platform drivers only target the SoC CPU and must |
6 | specific code. | 6 | have no board specific code. |
7 | 7 | ||
8 | Audio DMA | 8 | Audio DMA |
9 | ========= | 9 | ========= |
@@ -64,3 +64,16 @@ Each SoC DAI driver must provide the following features:- | |||
64 | 5) Suspend and resume (optional) | 64 | 5) Suspend and resume (optional) |
65 | 65 | ||
66 | Please see codec.txt for a description of items 1 - 4. | 66 | Please see codec.txt for a description of items 1 - 4. |
67 | |||
68 | |||
69 | SoC DSP Drivers | ||
70 | =============== | ||
71 | |||
72 | Each SoC DSP driver usually supplies the following features :- | ||
73 | |||
74 | 1) DAPM graph | ||
75 | 2) Mixer controls | ||
76 | 3) DMA IO to/from DSP buffers (if applicable) | ||
77 | 4) Definition of DSP front end (FE) PCM devices. | ||
78 | |||
79 | Please see DPCM.txt for a description of item 4. | ||