]>
Commit | Line | Data |
---|---|---|
808db4a4 RP |
1 | /* |
2 | * linux/sound/soc-dapm.h -- ALSA SoC Dynamic Audio Power Management | |
3 | * | |
4 | * Author: Liam Girdwood | |
5 | * Created: Aug 11th 2005 | |
6 | * Copyright: Wolfson Microelectronics. PLC. | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License version 2 as | |
10 | * published by the Free Software Foundation. | |
11 | */ | |
12 | ||
13 | #ifndef __LINUX_SND_SOC_DAPM_H | |
14 | #define __LINUX_SND_SOC_DAPM_H | |
15 | ||
16 | #include <linux/device.h> | |
17 | #include <linux/types.h> | |
18 | #include <sound/control.h> | |
19 | #include <sound/soc.h> | |
20 | ||
21 | /* widget has no PM register bit */ | |
22 | #define SND_SOC_NOPM -1 | |
23 | ||
24 | /* | |
b7d2a803 | 25 | * SoC dynamic audio power management |
808db4a4 RP |
26 | * |
27 | * We can have upto 4 power domains | |
28 | * 1. Codec domain - VREF, VMID | |
29 | * Usually controlled at codec probe/remove, although can be set | |
30 | * at stream time if power is not needed for sidetone, etc. | |
31 | * 2. Platform/Machine domain - physically connected inputs and outputs | |
32 | * Is platform/machine and user action specific, is set in the machine | |
33 | * driver and by userspace e.g when HP are inserted | |
34 | * 3. Path domain - Internal codec path mixers | |
35 | * Are automatically set when mixer and mux settings are | |
36 | * changed by the user. | |
37 | * 4. Stream domain - DAC's and ADC's. | |
38 | * Enabled when stream playback/capture is started. | |
39 | */ | |
40 | ||
41 | /* codec domain */ | |
42 | #define SND_SOC_DAPM_VMID(wname) \ | |
43 | { .id = snd_soc_dapm_vmid, .name = wname, .kcontrols = NULL, \ | |
44 | .num_kcontrols = 0} | |
45 | ||
46 | /* platform domain */ | |
47 | #define SND_SOC_DAPM_INPUT(wname) \ | |
48 | { .id = snd_soc_dapm_input, .name = wname, .kcontrols = NULL, \ | |
49 | .num_kcontrols = 0} | |
50 | #define SND_SOC_DAPM_OUTPUT(wname) \ | |
51 | { .id = snd_soc_dapm_output, .name = wname, .kcontrols = NULL, \ | |
52 | .num_kcontrols = 0} | |
53 | #define SND_SOC_DAPM_MIC(wname, wevent) \ | |
54 | { .id = snd_soc_dapm_mic, .name = wname, .kcontrols = NULL, \ | |
55 | .num_kcontrols = 0, .event = wevent, \ | |
56 | .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD} | |
57 | #define SND_SOC_DAPM_HP(wname, wevent) \ | |
58 | { .id = snd_soc_dapm_hp, .name = wname, .kcontrols = NULL, \ | |
59 | .num_kcontrols = 0, .event = wevent, \ | |
60 | .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} | |
61 | #define SND_SOC_DAPM_SPK(wname, wevent) \ | |
62 | { .id = snd_soc_dapm_spk, .name = wname, .kcontrols = NULL, \ | |
63 | .num_kcontrols = 0, .event = wevent, \ | |
64 | .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} | |
65 | #define SND_SOC_DAPM_LINE(wname, wevent) \ | |
66 | { .id = snd_soc_dapm_line, .name = wname, .kcontrols = NULL, \ | |
67 | .num_kcontrols = 0, .event = wevent, \ | |
68 | .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} | |
69 | ||
70 | /* path domain */ | |
71 | #define SND_SOC_DAPM_PGA(wname, wreg, wshift, winvert,\ | |
72 | wcontrols, wncontrols) \ | |
73 | { .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ | |
74 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols} | |
75 | #define SND_SOC_DAPM_MIXER(wname, wreg, wshift, winvert, \ | |
76 | wcontrols, wncontrols)\ | |
77 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ | |
78 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols} | |
ca9c1aae IM |
79 | #define SND_SOC_DAPM_MIXER_NAMED_CTL(wname, wreg, wshift, winvert, \ |
80 | wcontrols, wncontrols)\ | |
81 | { .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \ | |
82 | .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \ | |
83 | .num_kcontrols = wncontrols} | |
808db4a4 RP |
84 | #define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \ |
85 | { .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ | |
86 | .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0} | |
87 | #define SND_SOC_DAPM_SWITCH(wname, wreg, wshift, winvert, wcontrols) \ | |
88 | { .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \ | |
89 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1} | |
90 | #define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \ | |
91 | { .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ | |
92 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1} | |
2e72f8e3 PU |
93 | #define SND_SOC_DAPM_VALUE_MUX(wname, wreg, wshift, winvert, wcontrols) \ |
94 | { .id = snd_soc_dapm_value_mux, .name = wname, .reg = wreg, \ | |
95 | .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \ | |
96 | .num_kcontrols = 1} | |
808db4a4 | 97 | |
8484c63f GL |
98 | /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */ |
99 | #define SOC_PGA_ARRAY(wname, wreg, wshift, winvert,\ | |
100 | wcontrols) \ | |
101 | { .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ | |
102 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)} | |
103 | #define SOC_MIXER_ARRAY(wname, wreg, wshift, winvert, \ | |
104 | wcontrols)\ | |
105 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ | |
106 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)} | |
107 | #define SOC_MIXER_NAMED_CTL_ARRAY(wname, wreg, wshift, winvert, \ | |
108 | wcontrols)\ | |
109 | { .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \ | |
110 | .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \ | |
111 | .num_kcontrols = ARRAY_SIZE(wcontrols)} | |
112 | ||
808db4a4 RP |
113 | /* path domain with event - event handler must return 0 for success */ |
114 | #define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \ | |
115 | wncontrols, wevent, wflags) \ | |
116 | { .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ | |
117 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ | |
118 | .event = wevent, .event_flags = wflags} | |
119 | #define SND_SOC_DAPM_MIXER_E(wname, wreg, wshift, winvert, wcontrols, \ | |
120 | wncontrols, wevent, wflags) \ | |
121 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ | |
122 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ | |
123 | .event = wevent, .event_flags = wflags} | |
ca9c1aae IM |
124 | #define SND_SOC_DAPM_MIXER_NAMED_CTL_E(wname, wreg, wshift, winvert, \ |
125 | wcontrols, wncontrols, wevent, wflags) \ | |
126 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ | |
127 | .invert = winvert, .kcontrols = wcontrols, \ | |
128 | .num_kcontrols = wncontrols, .event = wevent, .event_flags = wflags} | |
808db4a4 RP |
129 | #define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \ |
130 | { .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ | |
131 | .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0, \ | |
132 | .event = wevent, .event_flags = wflags} | |
133 | #define SND_SOC_DAPM_SWITCH_E(wname, wreg, wshift, winvert, wcontrols, \ | |
134 | wevent, wflags) \ | |
135 | { .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \ | |
43d50807 | 136 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ |
808db4a4 RP |
137 | .event = wevent, .event_flags = wflags} |
138 | #define SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, \ | |
139 | wevent, wflags) \ | |
140 | { .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ | |
141 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ | |
142 | .event = wevent, .event_flags = wflags} | |
143 | ||
8484c63f GL |
144 | /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */ |
145 | #define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \ | |
146 | wevent, wflags) \ | |
147 | { .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ | |
148 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \ | |
149 | .event = wevent, .event_flags = wflags} | |
150 | #define SOC_MIXER_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \ | |
151 | wevent, wflags) \ | |
152 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ | |
153 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \ | |
154 | .event = wevent, .event_flags = wflags} | |
155 | #define SOC_MIXER_NAMED_CTL_E_ARRAY(wname, wreg, wshift, winvert, \ | |
156 | wcontrols, wevent, wflags) \ | |
157 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ | |
158 | .invert = winvert, .kcontrols = wcontrols, \ | |
159 | .num_kcontrols = ARRAY_SIZE(wcontrols), .event = wevent, .event_flags = wflags} | |
160 | ||
808db4a4 RP |
161 | /* events that are pre and post DAPM */ |
162 | #define SND_SOC_DAPM_PRE(wname, wevent) \ | |
163 | { .id = snd_soc_dapm_pre, .name = wname, .kcontrols = NULL, \ | |
164 | .num_kcontrols = 0, .event = wevent, \ | |
165 | .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD} | |
166 | #define SND_SOC_DAPM_POST(wname, wevent) \ | |
167 | { .id = snd_soc_dapm_post, .name = wname, .kcontrols = NULL, \ | |
168 | .num_kcontrols = 0, .event = wevent, \ | |
169 | .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD} | |
170 | ||
171 | /* stream domain */ | |
010ff262 MB |
172 | #define SND_SOC_DAPM_AIF_IN(wname, stname, wslot, wreg, wshift, winvert) \ |
173 | { .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \ | |
174 | .reg = wreg, .shift = wshift, .invert = winvert } | |
ea0d09de MB |
175 | #define SND_SOC_DAPM_AIF_IN_E(wname, stname, wslot, wreg, wshift, winvert, \ |
176 | wevent, wflags) \ | |
177 | { .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \ | |
178 | .reg = wreg, .shift = wshift, .invert = winvert, \ | |
179 | .event = wevent, .event_flags = wflags } | |
010ff262 MB |
180 | #define SND_SOC_DAPM_AIF_OUT(wname, stname, wslot, wreg, wshift, winvert) \ |
181 | { .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \ | |
182 | .reg = wreg, .shift = wshift, .invert = winvert } | |
ea0d09de MB |
183 | #define SND_SOC_DAPM_AIF_OUT_E(wname, stname, wslot, wreg, wshift, winvert, \ |
184 | wevent, wflags) \ | |
185 | { .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \ | |
186 | .reg = wreg, .shift = wshift, .invert = winvert, \ | |
187 | .event = wevent, .event_flags = wflags } | |
808db4a4 RP |
188 | #define SND_SOC_DAPM_DAC(wname, stname, wreg, wshift, winvert) \ |
189 | { .id = snd_soc_dapm_dac, .name = wname, .sname = stname, .reg = wreg, \ | |
190 | .shift = wshift, .invert = winvert} | |
f6d655a6 MB |
191 | #define SND_SOC_DAPM_DAC_E(wname, stname, wreg, wshift, winvert, \ |
192 | wevent, wflags) \ | |
193 | { .id = snd_soc_dapm_dac, .name = wname, .sname = stname, .reg = wreg, \ | |
194 | .shift = wshift, .invert = winvert, \ | |
195 | .event = wevent, .event_flags = wflags} | |
808db4a4 RP |
196 | #define SND_SOC_DAPM_ADC(wname, stname, wreg, wshift, winvert) \ |
197 | { .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \ | |
198 | .shift = wshift, .invert = winvert} | |
f6d655a6 MB |
199 | #define SND_SOC_DAPM_ADC_E(wname, stname, wreg, wshift, winvert, \ |
200 | wevent, wflags) \ | |
201 | { .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \ | |
202 | .shift = wshift, .invert = winvert, \ | |
203 | .event = wevent, .event_flags = wflags} | |
808db4a4 | 204 | |
246d0a17 | 205 | /* generic widgets */ |
e2be2ccf JN |
206 | #define SND_SOC_DAPM_REG(wid, wname, wreg, wshift, wmask, won_val, woff_val) \ |
207 | { .id = wid, .name = wname, .kcontrols = NULL, .num_kcontrols = 0, \ | |
208 | .reg = -((wreg) + 1), .shift = wshift, .mask = wmask, \ | |
209 | .on_val = won_val, .off_val = woff_val, .event = dapm_reg_event, \ | |
210 | .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD} | |
246d0a17 MB |
211 | #define SND_SOC_DAPM_SUPPLY(wname, wreg, wshift, winvert, wevent, wflags) \ |
212 | { .id = snd_soc_dapm_supply, .name = wname, .reg = wreg, \ | |
213 | .shift = wshift, .invert = winvert, .event = wevent, \ | |
214 | .event_flags = wflags} | |
e2be2ccf | 215 | |
808db4a4 | 216 | /* dapm kcontrol types */ |
a7a4ac86 | 217 | #define SOC_DAPM_SINGLE(xname, reg, shift, max, invert) \ |
808db4a4 RP |
218 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
219 | .info = snd_soc_info_volsw, \ | |
220 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ | |
a7a4ac86 PZ |
221 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } |
222 | #define SOC_DAPM_DOUBLE(xname, reg, shift_left, shift_right, max, invert, \ | |
808db4a4 RP |
223 | power) \ |
224 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | |
225 | .info = snd_soc_info_volsw, \ | |
226 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ | |
227 | .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\ | |
a7a4ac86 PZ |
228 | ((max) << 16) | ((invert) << 24) } |
229 | #define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ | |
230 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
231 | .info = snd_soc_info_volsw, \ | |
232 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | |
233 | .tlv.p = (tlv_array), \ | |
234 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ | |
235 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } | |
236 | #define SOC_DAPM_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, \ | |
237 | power, tlv_array) \ | |
238 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | |
239 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | |
240 | .tlv.p = (tlv_array), \ | |
241 | .info = snd_soc_info_volsw, \ | |
242 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ | |
243 | .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\ | |
244 | ((max) << 16) | ((invert) << 24) } | |
808db4a4 RP |
245 | #define SOC_DAPM_ENUM(xname, xenum) \ |
246 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
247 | .info = snd_soc_info_enum_double, \ | |
248 | .get = snd_soc_dapm_get_enum_double, \ | |
249 | .put = snd_soc_dapm_put_enum_double, \ | |
250 | .private_value = (unsigned long)&xenum } | |
d2b247a8 MB |
251 | #define SOC_DAPM_ENUM_VIRT(xname, xenum) \ |
252 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
253 | .info = snd_soc_info_enum_double, \ | |
254 | .get = snd_soc_dapm_get_enum_virt, \ | |
255 | .put = snd_soc_dapm_put_enum_virt, \ | |
256 | .private_value = (unsigned long)&xenum } | |
2e72f8e3 PU |
257 | #define SOC_DAPM_VALUE_ENUM(xname, xenum) \ |
258 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
74155556 | 259 | .info = snd_soc_info_enum_double, \ |
2e72f8e3 PU |
260 | .get = snd_soc_dapm_get_value_enum_double, \ |
261 | .put = snd_soc_dapm_put_value_enum_double, \ | |
262 | .private_value = (unsigned long)&xenum } | |
8b37dbd2 MB |
263 | #define SOC_DAPM_PIN_SWITCH(xname) \ |
264 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname " Switch", \ | |
265 | .info = snd_soc_dapm_info_pin_switch, \ | |
266 | .get = snd_soc_dapm_get_pin_switch, \ | |
267 | .put = snd_soc_dapm_put_pin_switch, \ | |
268 | .private_value = (unsigned long)xname } | |
808db4a4 RP |
269 | |
270 | /* dapm stream operations */ | |
271 | #define SND_SOC_DAPM_STREAM_NOP 0x0 | |
272 | #define SND_SOC_DAPM_STREAM_START 0x1 | |
273 | #define SND_SOC_DAPM_STREAM_STOP 0x2 | |
274 | #define SND_SOC_DAPM_STREAM_SUSPEND 0x4 | |
275 | #define SND_SOC_DAPM_STREAM_RESUME 0x8 | |
276 | #define SND_SOC_DAPM_STREAM_PAUSE_PUSH 0x10 | |
277 | #define SND_SOC_DAPM_STREAM_PAUSE_RELEASE 0x20 | |
278 | ||
279 | /* dapm event types */ | |
280 | #define SND_SOC_DAPM_PRE_PMU 0x1 /* before widget power up */ | |
281 | #define SND_SOC_DAPM_POST_PMU 0x2 /* after widget power up */ | |
282 | #define SND_SOC_DAPM_PRE_PMD 0x4 /* before widget power down */ | |
283 | #define SND_SOC_DAPM_POST_PMD 0x8 /* after widget power down */ | |
284 | #define SND_SOC_DAPM_PRE_REG 0x10 /* before audio path setup */ | |
285 | #define SND_SOC_DAPM_POST_REG 0x20 /* after audio path setup */ | |
ea762b04 | 286 | #define SND_SOC_DAPM_PRE_POST_PMD \ |
287 | (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD) | |
808db4a4 RP |
288 | |
289 | /* convenience event type detection */ | |
290 | #define SND_SOC_DAPM_EVENT_ON(e) \ | |
291 | (e & (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU)) | |
292 | #define SND_SOC_DAPM_EVENT_OFF(e) \ | |
293 | (e & (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD)) | |
294 | ||
295 | struct snd_soc_dapm_widget; | |
296 | enum snd_soc_dapm_type; | |
297 | struct snd_soc_dapm_path; | |
298 | struct snd_soc_dapm_pin; | |
105f1c28 | 299 | struct snd_soc_dapm_route; |
ce6120cc | 300 | struct snd_soc_dapm_context; |
808db4a4 | 301 | |
11589418 MB |
302 | int dapm_reg_event(struct snd_soc_dapm_widget *w, |
303 | struct snd_kcontrol *kcontrol, int event); | |
304 | ||
808db4a4 RP |
305 | /* dapm controls */ |
306 | int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | |
307 | struct snd_ctl_elem_value *ucontrol); | |
308 | int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, | |
309 | struct snd_ctl_elem_value *ucontrol); | |
310 | int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, | |
311 | struct snd_ctl_elem_value *ucontrol); | |
312 | int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, | |
313 | struct snd_ctl_elem_value *ucontrol); | |
d2b247a8 MB |
314 | int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol, |
315 | struct snd_ctl_elem_value *ucontrol); | |
316 | int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol, | |
317 | struct snd_ctl_elem_value *ucontrol); | |
2e72f8e3 PU |
318 | int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol, |
319 | struct snd_ctl_elem_value *ucontrol); | |
320 | int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, | |
321 | struct snd_ctl_elem_value *ucontrol); | |
8b37dbd2 MB |
322 | int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol, |
323 | struct snd_ctl_elem_info *uinfo); | |
324 | int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, | |
325 | struct snd_ctl_elem_value *uncontrol); | |
326 | int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, | |
327 | struct snd_ctl_elem_value *uncontrol); | |
ce6120cc | 328 | int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, |
808db4a4 | 329 | const struct snd_soc_dapm_widget *widget); |
ce6120cc | 330 | int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, |
4ba1327a MB |
331 | const struct snd_soc_dapm_widget *widget, |
332 | int num); | |
808db4a4 RP |
333 | |
334 | /* dapm path setup */ | |
ce6120cc LG |
335 | int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm); |
336 | void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm); | |
337 | int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm, | |
105f1c28 | 338 | const struct snd_soc_dapm_route *route, int num); |
808db4a4 RP |
339 | |
340 | /* dapm events */ | |
f0fba2ad LG |
341 | int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, |
342 | const char *stream, int event); | |
343 | void snd_soc_dapm_shutdown(struct snd_soc_card *card); | |
808db4a4 RP |
344 | |
345 | /* dapm sys fs - used by the core */ | |
346 | int snd_soc_dapm_sys_add(struct device *dev); | |
ce6120cc | 347 | void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm); |
808db4a4 | 348 | |
a5302181 | 349 | /* dapm audio pin control and status */ |
ce6120cc LG |
350 | int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, |
351 | const char *pin); | |
352 | int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, | |
353 | const char *pin); | |
354 | int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin); | |
355 | int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, | |
356 | const char *pin); | |
357 | int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm); | |
358 | int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, | |
da34183e | 359 | const char *pin); |
ce6120cc LG |
360 | int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, |
361 | const char *pin); | |
808db4a4 RP |
362 | |
363 | /* dapm widget types */ | |
364 | enum snd_soc_dapm_type { | |
365 | snd_soc_dapm_input = 0, /* input pin */ | |
366 | snd_soc_dapm_output, /* output pin */ | |
367 | snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ | |
2e72f8e3 | 368 | snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */ |
808db4a4 | 369 | snd_soc_dapm_mixer, /* mixes several analog signals together */ |
ca9c1aae | 370 | snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */ |
808db4a4 RP |
371 | snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */ |
372 | snd_soc_dapm_adc, /* analog to digital converter */ | |
373 | snd_soc_dapm_dac, /* digital to analog converter */ | |
374 | snd_soc_dapm_micbias, /* microphone bias (power) */ | |
375 | snd_soc_dapm_mic, /* microphone */ | |
376 | snd_soc_dapm_hp, /* headphones */ | |
377 | snd_soc_dapm_spk, /* speaker */ | |
378 | snd_soc_dapm_line, /* line input/output */ | |
379 | snd_soc_dapm_switch, /* analog switch */ | |
380 | snd_soc_dapm_vmid, /* codec bias/vmid - to minimise pops */ | |
381 | snd_soc_dapm_pre, /* machine specific pre widget - exec first */ | |
382 | snd_soc_dapm_post, /* machine specific post widget - exec last */ | |
246d0a17 | 383 | snd_soc_dapm_supply, /* power/clock supply */ |
010ff262 MB |
384 | snd_soc_dapm_aif_in, /* audio interface input */ |
385 | snd_soc_dapm_aif_out, /* audio interface output */ | |
808db4a4 RP |
386 | }; |
387 | ||
105f1c28 MB |
388 | /* |
389 | * DAPM audio route definition. | |
390 | * | |
391 | * Defines an audio route originating at source via control and finishing | |
392 | * at sink. | |
393 | */ | |
394 | struct snd_soc_dapm_route { | |
395 | const char *sink; | |
396 | const char *control; | |
397 | const char *source; | |
215edda3 MB |
398 | |
399 | /* Note: currently only supported for links where source is a supply */ | |
400 | int (*connected)(struct snd_soc_dapm_widget *source, | |
401 | struct snd_soc_dapm_widget *sink); | |
105f1c28 MB |
402 | }; |
403 | ||
808db4a4 RP |
404 | /* dapm audio path between two widgets */ |
405 | struct snd_soc_dapm_path { | |
406 | char *name; | |
407 | char *long_name; | |
408 | ||
409 | /* source (input) and sink (output) widgets */ | |
410 | struct snd_soc_dapm_widget *source; | |
411 | struct snd_soc_dapm_widget *sink; | |
412 | struct snd_kcontrol *kcontrol; | |
413 | ||
414 | /* status */ | |
415 | u32 connect:1; /* source and sink widgets are connected */ | |
416 | u32 walked:1; /* path has been walked */ | |
417 | ||
215edda3 MB |
418 | int (*connected)(struct snd_soc_dapm_widget *source, |
419 | struct snd_soc_dapm_widget *sink); | |
420 | ||
808db4a4 RP |
421 | struct list_head list_source; |
422 | struct list_head list_sink; | |
423 | struct list_head list; | |
424 | }; | |
425 | ||
426 | /* dapm widget */ | |
427 | struct snd_soc_dapm_widget { | |
428 | enum snd_soc_dapm_type id; | |
429 | char *name; /* widget name */ | |
430 | char *sname; /* stream name */ | |
431 | struct snd_soc_codec *codec; | |
432 | struct list_head list; | |
ce6120cc | 433 | struct snd_soc_dapm_context *dapm; |
808db4a4 RP |
434 | |
435 | /* dapm control */ | |
436 | short reg; /* negative reg = no direct dapm */ | |
437 | unsigned char shift; /* bits to shift */ | |
438 | unsigned int saved_value; /* widget saved value */ | |
439 | unsigned int value; /* widget current value */ | |
e2be2ccf JN |
440 | unsigned int mask; /* non-shifted mask */ |
441 | unsigned int on_val; /* on state value */ | |
442 | unsigned int off_val; /* off state value */ | |
808db4a4 RP |
443 | unsigned char power:1; /* block power status */ |
444 | unsigned char invert:1; /* invert the power bit */ | |
445 | unsigned char active:1; /* active stream on DAC, ADC's */ | |
446 | unsigned char connected:1; /* connected codec pin */ | |
447 | unsigned char new:1; /* cnew complete */ | |
448 | unsigned char ext:1; /* has external widgets */ | |
da34183e | 449 | unsigned char force:1; /* force state */ |
1547aba9 | 450 | unsigned char ignore_suspend:1; /* kept enabled over suspend */ |
808db4a4 | 451 | |
b75576d7 MB |
452 | int (*power_check)(struct snd_soc_dapm_widget *w); |
453 | ||
808db4a4 RP |
454 | /* external events */ |
455 | unsigned short event_flags; /* flags to specify event types */ | |
9af6d956 | 456 | int (*event)(struct snd_soc_dapm_widget*, struct snd_kcontrol *, int); |
808db4a4 RP |
457 | |
458 | /* kcontrols that relate to this widget */ | |
459 | int num_kcontrols; | |
460 | const struct snd_kcontrol_new *kcontrols; | |
461 | ||
462 | /* widget input and outputs */ | |
463 | struct list_head sources; | |
464 | struct list_head sinks; | |
6d3ddc81 MB |
465 | |
466 | /* used during DAPM updates */ | |
467 | struct list_head power_list; | |
808db4a4 RP |
468 | }; |
469 | ||
ce6120cc LG |
470 | /* DAPM context */ |
471 | struct snd_soc_dapm_context { | |
472 | u32 pop_time; | |
473 | struct list_head widgets; | |
474 | struct list_head paths; | |
475 | enum snd_soc_bias_level bias_level; | |
476 | enum snd_soc_bias_level suspend_bias_level; | |
477 | struct delayed_work delayed_work; | |
478 | unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */ | |
479 | ||
480 | struct device *dev; /* from parent - for debug */ | |
481 | struct snd_soc_codec *codec; /* parent codec */ | |
482 | #ifdef CONFIG_DEBUG_FS | |
483 | struct dentry *debugfs_dapm; | |
484 | #endif | |
485 | }; | |
486 | ||
808db4a4 | 487 | #endif |