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