aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/sound/alsa/soc/codec.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/sound/alsa/soc/codec.txt')
-rw-r--r--Documentation/sound/alsa/soc/codec.txt107
1 files changed, 36 insertions, 71 deletions
diff --git a/Documentation/sound/alsa/soc/codec.txt b/Documentation/sound/alsa/soc/codec.txt
index 274657a03e1c..48983c75aad9 100644
--- a/Documentation/sound/alsa/soc/codec.txt
+++ b/Documentation/sound/alsa/soc/codec.txt
@@ -6,21 +6,18 @@ codec to provide audio capture and playback. It should contain no code that is
6specific to the target platform or machine. All platform and machine specific 6specific to the target platform or machine. All platform and machine specific
7code should be added to the platform and machine drivers respectively. 7code should be added to the platform and machine drivers respectively.
8 8
9Each codec driver must provide the following features:- 9Each codec driver *must* provide the following features:-
10 10
11 1) Digital audio interface (DAI) description 11 1) Codec DAI and PCM configuration
12 2) Digital audio interface configuration 12 2) Codec control IO - using I2C, 3 Wire(SPI) or both API's
13 3) PCM's description 13 3) Mixers and audio controls
14 4) Codec control IO - using I2C, 3 Wire(SPI) or both API's 14 4) Codec audio operations
15 5) Mixers and audio controls
16 6) Sysclk configuration
17 7) Codec audio operations
18 15
19Optionally, codec drivers can also provide:- 16Optionally, codec drivers can also provide:-
20 17
21 8) DAPM description. 18 5) DAPM description.
22 9) DAPM event handler. 19 6) DAPM event handler.
2310) DAC Digital mute control. 20 7) DAC Digital mute control.
24 21
25It's probably best to use this guide in conjuction with the existing codec 22It's probably best to use this guide in conjuction with the existing codec
26driver code in sound/soc/codecs/ 23driver code in sound/soc/codecs/
@@ -28,58 +25,47 @@ driver code in sound/soc/codecs/
28ASoC Codec driver breakdown 25ASoC Codec driver breakdown
29=========================== 26===========================
30 27
311 - Digital Audio Interface (DAI) description 281 - Codec DAI and PCM configuration
32--------------------------------------------- 29-----------------------------------
33The DAI is a digital audio data transfer link between the codec and host SoC 30Each codec driver must have a struct snd_soc_codec_dai to define it's DAI and
34CPU. It typically has data transfer capabilities in both directions 31PCM's capablities and operations. This struct is exported so that it can be
35(playback and capture) and can run at a variety of different speeds. 32registered with the core by your machine driver.
36Supported interfaces currently include AC97, I2S and generic PCM style links.
37Please read DAI.txt for implementation information.
38
39
402 - Digital Audio Interface (DAI) configuration
41-----------------------------------------------
42DAI configuration is handled by the codec_pcm_prepare function and is
43responsible for configuring and starting the DAI on the codec. This can be
44called multiple times and is atomic. It can access the runtime parameters.
45
46This usually consists of a large function with numerous switch statements to
47set up each configuration option. These options are set by the core at runtime.
48
49
503 - Codec PCM's
51---------------
52Each codec must have it's PCM's defined. This defines the number of channels,
53stream names, callbacks and codec name. It is also used to register the DAI
54with the ASoC core. The PCM structure also associates the DAI capabilities with
55the ALSA PCM.
56 33
57e.g. 34e.g.
58 35
59static struct snd_soc_pcm_codec wm8731_pcm_client = { 36struct snd_soc_codec_dai wm8731_dai = {
60 .name = "WM8731", 37 .name = "WM8731",
38 /* playback capabilities */
61 .playback = { 39 .playback = {
62 .stream_name = "Playback", 40 .stream_name = "Playback",
63 .channels_min = 1, 41 .channels_min = 1,
64 .channels_max = 2, 42 .channels_max = 2,
65 }, 43 .rates = WM8731_RATES,
44 .formats = WM8731_FORMATS,},
45 /* capture capabilities */
66 .capture = { 46 .capture = {
67 .stream_name = "Capture", 47 .stream_name = "Capture",
68 .channels_min = 1, 48 .channels_min = 1,
69 .channels_max = 2, 49 .channels_max = 2,
70 }, 50 .rates = WM8731_RATES,
71 .config_sysclk = wm8731_config_sysclk, 51 .formats = WM8731_FORMATS,},
52 /* pcm operations - see section 4 below */
72 .ops = { 53 .ops = {
73 .prepare = wm8731_pcm_prepare, 54 .prepare = wm8731_pcm_prepare,
55 .hw_params = wm8731_hw_params,
56 .shutdown = wm8731_shutdown,
74 }, 57 },
75 .caps = { 58 /* DAI operations - see DAI.txt */
76 .num_modes = ARRAY_SIZE(wm8731_hwfmt), 59 .dai_ops = {
77 .modes = &wm8731_hwfmt[0], 60 .digital_mute = wm8731_mute,
78 }, 61 .set_sysclk = wm8731_set_dai_sysclk,
62 .set_fmt = wm8731_set_dai_fmt,
63 }
79}; 64};
65EXPORT_SYMBOL_GPL(wm8731_dai);
80 66
81 67
824 - Codec control IO 682 - Codec control IO
83-------------------- 69--------------------
84The codec can ususally be controlled via an I2C or SPI style interface (AC97 70The codec can ususally be controlled via an I2C or SPI style interface (AC97
85combines control with data in the DAI). The codec drivers will have to provide 71combines control with data in the DAI). The codec drivers will have to provide
@@ -104,7 +90,7 @@ read/write:-
104 hw_read_t hw_read; 90 hw_read_t hw_read;
105 91
106 92
1075 - Mixers and audio controls 933 - Mixers and audio controls
108----------------------------- 94-----------------------------
109All the codec mixers and audio controls can be defined using the convenience 95All the codec mixers and audio controls can be defined using the convenience
110macros defined in soc.h. 96macros defined in soc.h.
@@ -143,28 +129,7 @@ Defines an single enumerated control as follows:-
143Defines a stereo enumerated control 129Defines a stereo enumerated control
144 130
145 131
1466 - System clock configuration. 1324 - Codec Audio Operations
147-------------------------------
148The system clock that drives the audio subsystem can change depending on sample
149rate and the system power state. i.e.
150
151o Higher sample rates sometimes need a higher system clock.
152o Low system power states can sometimes limit the available clocks.
153
154This function is a callback that the machine driver can call to set and
155determine if the clock and sample rate combination is supported by the codec at
156the present time (and system state).
157
158NOTE: If the codec has a PLL then it has a lot more flexability wrt clock and
159sample rate combinations.
160
161Your config_sysclock function should return the MCLK if it's a valid
162combination for your codec else 0;
163
164Please read clocking.txt now.
165
166
1677 - Codec Audio Operations
168-------------------------- 133--------------------------
169The codec driver also supports the following alsa operations:- 134The codec driver also supports the following alsa operations:-
170 135
@@ -181,7 +146,7 @@ Please refer to the alsa driver PCM documentation for details.
181http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm 146http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm
182 147
183 148
1848 - DAPM description. 1495 - DAPM description.
185--------------------- 150---------------------
186The Dynamic Audio Power Management description describes the codec's power 151The Dynamic Audio Power Management description describes the codec's power
187components, their relationships and registers to the ASoC core. Please read 152components, their relationships and registers to the ASoC core. Please read
@@ -190,7 +155,7 @@ dapm.txt for details of building the description.
190Please also see the examples in other codec drivers. 155Please also see the examples in other codec drivers.
191 156
192 157
1939 - DAPM event handler 1586 - DAPM event handler
194---------------------- 159----------------------
195This function is a callback that handles codec domain PM calls and system 160This function is a callback that handles codec domain PM calls and system
196domain PM calls (e.g. suspend and resume). It's used to put the codec to sleep 161domain PM calls (e.g. suspend and resume). It's used to put the codec to sleep
@@ -210,7 +175,7 @@ Power states:-
210 SNDRV_CTL_POWER_D3cold: /* Everything Off, without power */ 175 SNDRV_CTL_POWER_D3cold: /* Everything Off, without power */
211 176
212 177
21310 - Codec DAC digital mute control. 1787 - Codec DAC digital mute control.
214------------------------------------ 179------------------------------------
215Most codecs have a digital mute before the DAC's that can be used to minimise 180Most codecs have a digital mute before the DAC's that can be used to minimise
216any system noise. The mute stops any digital data from entering the DAC. 181any system noise. The mute stops any digital data from entering the DAC.