ASoC: topology: Add topology UAPI header
[deliverable/linux.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
808db4a4
RP
16#include <linux/types.h>
17#include <sound/control.h>
c147c0e1 18#include <sound/asoc.h>
808db4a4 19
313162d0
PG
20struct device;
21
808db4a4
RP
22/* widget has no PM register bit */
23#define SND_SOC_NOPM -1
24
25/*
b7d2a803 26 * SoC dynamic audio power management
808db4a4 27 *
25985edc 28 * We can have up to 4 power domains
28683e0f 29 * 1. Codec domain - VREF, VMID
808db4a4
RP
30 * Usually controlled at codec probe/remove, although can be set
31 * at stream time if power is not needed for sidetone, etc.
32 * 2. Platform/Machine domain - physically connected inputs and outputs
33 * Is platform/machine and user action specific, is set in the machine
34 * driver and by userspace e.g when HP are inserted
35 * 3. Path domain - Internal codec path mixers
36 * Are automatically set when mixer and mux settings are
37 * changed by the user.
38 * 4. Stream domain - DAC's and ADC's.
39 * Enabled when stream playback/capture is started.
40 */
41
42/* codec domain */
43#define SND_SOC_DAPM_VMID(wname) \
82cfecdc 44{ .id = snd_soc_dapm_vmid, .name = wname, .kcontrol_news = NULL, \
808db4a4
RP
45 .num_kcontrols = 0}
46
47/* platform domain */
1ab97c8c
MB
48#define SND_SOC_DAPM_SIGGEN(wname) \
49{ .id = snd_soc_dapm_siggen, .name = wname, .kcontrol_news = NULL, \
50 .num_kcontrols = 0, .reg = SND_SOC_NOPM }
808db4a4 51#define SND_SOC_DAPM_INPUT(wname) \
82cfecdc 52{ .id = snd_soc_dapm_input, .name = wname, .kcontrol_news = NULL, \
0ca03cd7 53 .num_kcontrols = 0, .reg = SND_SOC_NOPM }
808db4a4 54#define SND_SOC_DAPM_OUTPUT(wname) \
82cfecdc 55{ .id = snd_soc_dapm_output, .name = wname, .kcontrol_news = NULL, \
0ca03cd7 56 .num_kcontrols = 0, .reg = SND_SOC_NOPM }
808db4a4 57#define SND_SOC_DAPM_MIC(wname, wevent) \
82cfecdc 58{ .id = snd_soc_dapm_mic, .name = wname, .kcontrol_news = NULL, \
0ca03cd7 59 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
808db4a4
RP
60 .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD}
61#define SND_SOC_DAPM_HP(wname, wevent) \
82cfecdc 62{ .id = snd_soc_dapm_hp, .name = wname, .kcontrol_news = NULL, \
0ca03cd7 63 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
808db4a4
RP
64 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
65#define SND_SOC_DAPM_SPK(wname, wevent) \
82cfecdc 66{ .id = snd_soc_dapm_spk, .name = wname, .kcontrol_news = NULL, \
0ca03cd7 67 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
808db4a4
RP
68 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
69#define SND_SOC_DAPM_LINE(wname, wevent) \
82cfecdc 70{ .id = snd_soc_dapm_line, .name = wname, .kcontrol_news = NULL, \
0ca03cd7 71 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
808db4a4
RP
72 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
73
de9ba98b
LPC
74#define SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert) \
75 .reg = wreg, .mask = 1, .shift = wshift, \
76 .on_val = winvert ? 0 : 1, .off_val = winvert ? 1 : 0
77
808db4a4
RP
78/* path domain */
79#define SND_SOC_DAPM_PGA(wname, wreg, wshift, winvert,\
80 wcontrols, wncontrols) \
de9ba98b
LPC
81{ .id = snd_soc_dapm_pga, .name = wname, \
82 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
83 .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
d88429a6
OM
84#define SND_SOC_DAPM_OUT_DRV(wname, wreg, wshift, winvert,\
85 wcontrols, wncontrols) \
de9ba98b
LPC
86{ .id = snd_soc_dapm_out_drv, .name = wname, \
87 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
88 .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
808db4a4
RP
89#define SND_SOC_DAPM_MIXER(wname, wreg, wshift, winvert, \
90 wcontrols, wncontrols)\
de9ba98b
LPC
91{ .id = snd_soc_dapm_mixer, .name = wname, \
92 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
93 .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
ca9c1aae
IM
94#define SND_SOC_DAPM_MIXER_NAMED_CTL(wname, wreg, wshift, winvert, \
95 wcontrols, wncontrols)\
de9ba98b
LPC
96{ .id = snd_soc_dapm_mixer_named_ctl, .name = wname, \
97 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
98 .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
808db4a4 99#define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \
de9ba98b
LPC
100{ .id = snd_soc_dapm_micbias, .name = wname, \
101 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
102 .kcontrol_news = NULL, .num_kcontrols = 0}
808db4a4 103#define SND_SOC_DAPM_SWITCH(wname, wreg, wshift, winvert, wcontrols) \
de9ba98b
LPC
104{ .id = snd_soc_dapm_switch, .name = wname, \
105 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
106 .kcontrol_news = wcontrols, .num_kcontrols = 1}
808db4a4 107#define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \
faf6615b
SW
108{ .id = snd_soc_dapm_mux, .name = wname, \
109 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
de9ba98b 110 .kcontrol_news = wcontrols, .num_kcontrols = 1}
d714f97c
LPC
111#define SND_SOC_DAPM_DEMUX(wname, wreg, wshift, winvert, wcontrols) \
112{ .id = snd_soc_dapm_demux, .name = wname, \
113 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
114 .kcontrol_news = wcontrols, .num_kcontrols = 1}
808db4a4 115
8484c63f
GL
116/* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
117#define SOC_PGA_ARRAY(wname, wreg, wshift, winvert,\
118 wcontrols) \
de9ba98b
LPC
119{ .id = snd_soc_dapm_pga, .name = wname, \
120 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
121 .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
8484c63f
GL
122#define SOC_MIXER_ARRAY(wname, wreg, wshift, winvert, \
123 wcontrols)\
de9ba98b
LPC
124{ .id = snd_soc_dapm_mixer, .name = wname, \
125 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
126 .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
8484c63f
GL
127#define SOC_MIXER_NAMED_CTL_ARRAY(wname, wreg, wshift, winvert, \
128 wcontrols)\
de9ba98b
LPC
129{ .id = snd_soc_dapm_mixer_named_ctl, .name = wname, \
130 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
131 .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
8484c63f 132
808db4a4
RP
133/* path domain with event - event handler must return 0 for success */
134#define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \
135 wncontrols, wevent, wflags) \
de9ba98b
LPC
136{ .id = snd_soc_dapm_pga, .name = wname, \
137 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
138 .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
808db4a4 139 .event = wevent, .event_flags = wflags}
d88429a6
OM
140#define SND_SOC_DAPM_OUT_DRV_E(wname, wreg, wshift, winvert, wcontrols, \
141 wncontrols, wevent, wflags) \
de9ba98b
LPC
142{ .id = snd_soc_dapm_out_drv, .name = wname, \
143 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
144 .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
d88429a6 145 .event = wevent, .event_flags = wflags}
808db4a4
RP
146#define SND_SOC_DAPM_MIXER_E(wname, wreg, wshift, winvert, wcontrols, \
147 wncontrols, wevent, wflags) \
de9ba98b
LPC
148{ .id = snd_soc_dapm_mixer, .name = wname, \
149 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
150 .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
808db4a4 151 .event = wevent, .event_flags = wflags}
ca9c1aae
IM
152#define SND_SOC_DAPM_MIXER_NAMED_CTL_E(wname, wreg, wshift, winvert, \
153 wcontrols, wncontrols, wevent, wflags) \
de9ba98b
LPC
154{ .id = snd_soc_dapm_mixer, .name = wname, \
155 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
156 .kcontrol_news = wcontrols, \
ca9c1aae 157 .num_kcontrols = wncontrols, .event = wevent, .event_flags = wflags}
808db4a4
RP
158#define SND_SOC_DAPM_SWITCH_E(wname, wreg, wshift, winvert, wcontrols, \
159 wevent, wflags) \
de9ba98b
LPC
160{ .id = snd_soc_dapm_switch, .name = wname, \
161 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
162 .kcontrol_news = wcontrols, .num_kcontrols = 1, \
808db4a4
RP
163 .event = wevent, .event_flags = wflags}
164#define SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, \
165 wevent, wflags) \
de9ba98b
LPC
166{ .id = snd_soc_dapm_mux, .name = wname, \
167 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
168 .kcontrol_news = wcontrols, .num_kcontrols = 1, \
808db4a4
RP
169 .event = wevent, .event_flags = wflags}
170
20e4859d 171/* additional sequencing control within an event type */
3d23c73f
MB
172#define SND_SOC_DAPM_PGA_S(wname, wsubseq, wreg, wshift, winvert, \
173 wevent, wflags) \
de9ba98b
LPC
174{ .id = snd_soc_dapm_pga, .name = wname, \
175 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
176 .event = wevent, .event_flags = wflags, \
3d23c73f 177 .subseq = wsubseq}
20e4859d
MB
178#define SND_SOC_DAPM_SUPPLY_S(wname, wsubseq, wreg, wshift, winvert, wevent, \
179 wflags) \
de9ba98b
LPC
180{ .id = snd_soc_dapm_supply, .name = wname, \
181 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
182 .event = wevent, .event_flags = wflags, .subseq = wsubseq}
20e4859d 183
8484c63f
GL
184/* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
185#define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
186 wevent, wflags) \
de9ba98b
LPC
187{ .id = snd_soc_dapm_pga, .name = wname, \
188 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
189 .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
8484c63f
GL
190 .event = wevent, .event_flags = wflags}
191#define SOC_MIXER_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
192 wevent, wflags) \
de9ba98b
LPC
193{ .id = snd_soc_dapm_mixer, .name = wname, \
194 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
195 .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
8484c63f
GL
196 .event = wevent, .event_flags = wflags}
197#define SOC_MIXER_NAMED_CTL_E_ARRAY(wname, wreg, wshift, winvert, \
198 wcontrols, wevent, wflags) \
de9ba98b
LPC
199{ .id = snd_soc_dapm_mixer, .name = wname, \
200 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
201 .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
202 .event = wevent, .event_flags = wflags}
8484c63f 203
808db4a4
RP
204/* events that are pre and post DAPM */
205#define SND_SOC_DAPM_PRE(wname, wevent) \
82cfecdc 206{ .id = snd_soc_dapm_pre, .name = wname, .kcontrol_news = NULL, \
0ca03cd7 207 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
808db4a4
RP
208 .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD}
209#define SND_SOC_DAPM_POST(wname, wevent) \
82cfecdc 210{ .id = snd_soc_dapm_post, .name = wname, .kcontrol_news = NULL, \
0ca03cd7 211 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
808db4a4
RP
212 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD}
213
214/* stream domain */
010ff262
MB
215#define SND_SOC_DAPM_AIF_IN(wname, stname, wslot, wreg, wshift, winvert) \
216{ .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \
de9ba98b 217 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), }
ea0d09de
MB
218#define SND_SOC_DAPM_AIF_IN_E(wname, stname, wslot, wreg, wshift, winvert, \
219 wevent, wflags) \
220{ .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \
de9ba98b 221 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
ea0d09de 222 .event = wevent, .event_flags = wflags }
010ff262
MB
223#define SND_SOC_DAPM_AIF_OUT(wname, stname, wslot, wreg, wshift, winvert) \
224{ .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \
de9ba98b 225 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), }
ea0d09de
MB
226#define SND_SOC_DAPM_AIF_OUT_E(wname, stname, wslot, wreg, wshift, winvert, \
227 wevent, wflags) \
228{ .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \
de9ba98b 229 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
ea0d09de 230 .event = wevent, .event_flags = wflags }
808db4a4 231#define SND_SOC_DAPM_DAC(wname, stname, wreg, wshift, winvert) \
de9ba98b
LPC
232{ .id = snd_soc_dapm_dac, .name = wname, .sname = stname, \
233 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert) }
f6d655a6
MB
234#define SND_SOC_DAPM_DAC_E(wname, stname, wreg, wshift, winvert, \
235 wevent, wflags) \
de9ba98b
LPC
236{ .id = snd_soc_dapm_dac, .name = wname, .sname = stname, \
237 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
f6d655a6 238 .event = wevent, .event_flags = wflags}
de9ba98b 239
808db4a4 240#define SND_SOC_DAPM_ADC(wname, stname, wreg, wshift, winvert) \
de9ba98b
LPC
241{ .id = snd_soc_dapm_adc, .name = wname, .sname = stname, \
242 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), }
f6d655a6
MB
243#define SND_SOC_DAPM_ADC_E(wname, stname, wreg, wshift, winvert, \
244 wevent, wflags) \
de9ba98b
LPC
245{ .id = snd_soc_dapm_adc, .name = wname, .sname = stname, \
246 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
f6d655a6 247 .event = wevent, .event_flags = wflags}
d7e7eb91
OL
248#define SND_SOC_DAPM_CLOCK_SUPPLY(wname) \
249{ .id = snd_soc_dapm_clock_supply, .name = wname, \
250 .reg = SND_SOC_NOPM, .event = dapm_clock_event, \
251 .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD }
808db4a4 252
246d0a17 253/* generic widgets */
e2be2ccf 254#define SND_SOC_DAPM_REG(wid, wname, wreg, wshift, wmask, won_val, woff_val) \
82cfecdc 255{ .id = wid, .name = wname, .kcontrol_news = NULL, .num_kcontrols = 0, \
94986198
LPC
256 .reg = wreg, .shift = wshift, .mask = wmask, \
257 .on_val = won_val, .off_val = woff_val, }
246d0a17 258#define SND_SOC_DAPM_SUPPLY(wname, wreg, wshift, winvert, wevent, wflags) \
de9ba98b
LPC
259{ .id = snd_soc_dapm_supply, .name = wname, \
260 SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
261 .event = wevent, .event_flags = wflags}
822b4b8d 262#define SND_SOC_DAPM_REGULATOR_SUPPLY(wname, wdelay, wflags) \
62ea874a
MB
263{ .id = snd_soc_dapm_regulator_supply, .name = wname, \
264 .reg = SND_SOC_NOPM, .shift = wdelay, .event = dapm_regulator_event, \
822b4b8d 265 .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD, \
de9ba98b 266 .on_val = wflags}
e2be2ccf 267
d7e7eb91 268
808db4a4 269/* dapm kcontrol types */
a7a4ac86 270#define SOC_DAPM_SINGLE(xname, reg, shift, max, invert) \
808db4a4
RP
271{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
272 .info = snd_soc_info_volsw, \
273 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
57295073
LPC
274 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
275#define SOC_DAPM_SINGLE_AUTODISABLE(xname, reg, shift, max, invert) \
276{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
277 .info = snd_soc_info_volsw, \
278 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
279 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) }
249ce138
LPC
280#define SOC_DAPM_SINGLE_VIRT(xname, max) \
281 SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0)
a7a4ac86
PZ
282#define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
283{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
284 .info = snd_soc_info_volsw, \
285 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
286 .tlv.p = (tlv_array), \
287 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
57295073
LPC
288 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
289#define SOC_DAPM_SINGLE_TLV_AUTODISABLE(xname, reg, shift, max, invert, tlv_array) \
290{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
291 .info = snd_soc_info_volsw, \
292 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
293 .tlv.p = (tlv_array), \
294 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
295 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
249ce138
LPC
296#define SOC_DAPM_SINGLE_TLV_VIRT(xname, max, tlv_array) \
297 SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0, tlv_array)
808db4a4
RP
298#define SOC_DAPM_ENUM(xname, xenum) \
299{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
300 .info = snd_soc_info_enum_double, \
301 .get = snd_soc_dapm_get_enum_double, \
302 .put = snd_soc_dapm_put_enum_double, \
303 .private_value = (unsigned long)&xenum }
c219c809
LG
304#define SOC_DAPM_ENUM_EXT(xname, xenum, xget, xput) \
305{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
306 .info = snd_soc_info_enum_double, \
307 .get = xget, \
308 .put = xput, \
309 .private_value = (unsigned long)&xenum }
8b37dbd2
MB
310#define SOC_DAPM_PIN_SWITCH(xname) \
311{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname " Switch", \
312 .info = snd_soc_dapm_info_pin_switch, \
313 .get = snd_soc_dapm_get_pin_switch, \
314 .put = snd_soc_dapm_put_pin_switch, \
315 .private_value = (unsigned long)xname }
808db4a4
RP
316
317/* dapm stream operations */
318#define SND_SOC_DAPM_STREAM_NOP 0x0
319#define SND_SOC_DAPM_STREAM_START 0x1
320#define SND_SOC_DAPM_STREAM_STOP 0x2
321#define SND_SOC_DAPM_STREAM_SUSPEND 0x4
322#define SND_SOC_DAPM_STREAM_RESUME 0x8
323#define SND_SOC_DAPM_STREAM_PAUSE_PUSH 0x10
324#define SND_SOC_DAPM_STREAM_PAUSE_RELEASE 0x20
325
326/* dapm event types */
327#define SND_SOC_DAPM_PRE_PMU 0x1 /* before widget power up */
328#define SND_SOC_DAPM_POST_PMU 0x2 /* after widget power up */
329#define SND_SOC_DAPM_PRE_PMD 0x4 /* before widget power down */
330#define SND_SOC_DAPM_POST_PMD 0x8 /* after widget power down */
331#define SND_SOC_DAPM_PRE_REG 0x10 /* before audio path setup */
332#define SND_SOC_DAPM_POST_REG 0x20 /* after audio path setup */
80114129
MB
333#define SND_SOC_DAPM_WILL_PMU 0x40 /* called at start of sequence */
334#define SND_SOC_DAPM_WILL_PMD 0x80 /* called at start of sequence */
ea762b04 335#define SND_SOC_DAPM_PRE_POST_PMD \
336 (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD)
808db4a4
RP
337
338/* convenience event type detection */
339#define SND_SOC_DAPM_EVENT_ON(e) \
340 (e & (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU))
341#define SND_SOC_DAPM_EVENT_OFF(e) \
342 (e & (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD))
343
c05b84d1
MB
344/* regulator widget flags */
345#define SND_SOC_DAPM_REGULATOR_BYPASS 0x1 /* bypass when disabled */
346
808db4a4
RP
347struct snd_soc_dapm_widget;
348enum snd_soc_dapm_type;
349struct snd_soc_dapm_path;
350struct snd_soc_dapm_pin;
105f1c28 351struct snd_soc_dapm_route;
ce6120cc 352struct snd_soc_dapm_context;
a3cc056b 353struct regulator;
ec2e3031 354struct snd_soc_dapm_widget_list;
6b3fc03b 355struct snd_soc_dapm_update;
808db4a4 356
62ea874a
MB
357int dapm_regulator_event(struct snd_soc_dapm_widget *w,
358 struct snd_kcontrol *kcontrol, int event);
d7e7eb91
OL
359int dapm_clock_event(struct snd_soc_dapm_widget *w,
360 struct snd_kcontrol *kcontrol, int event);
11589418 361
808db4a4
RP
362/* dapm controls */
363int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_value *ucontrol);
365int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
366 struct snd_ctl_elem_value *ucontrol);
367int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
368 struct snd_ctl_elem_value *ucontrol);
369int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
370 struct snd_ctl_elem_value *ucontrol);
8b37dbd2
MB
371int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol,
372 struct snd_ctl_elem_info *uinfo);
373int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
374 struct snd_ctl_elem_value *uncontrol);
375int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
376 struct snd_ctl_elem_value *uncontrol);
ce6120cc 377int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
4ba1327a
MB
378 const struct snd_soc_dapm_widget *widget,
379 int num);
888df395
MB
380int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
381 struct snd_soc_dai *dai);
382int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card);
b893ea5f 383void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
c74184ed
MB
384int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
385 const struct snd_soc_pcm_stream *params,
c6615082 386 unsigned int num_params,
c74184ed
MB
387 struct snd_soc_dapm_widget *source,
388 struct snd_soc_dapm_widget *sink);
808db4a4
RP
389
390/* dapm path setup */
824ef826 391int snd_soc_dapm_new_widgets(struct snd_soc_card *card);
ce6120cc
LG
392void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm);
393int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
105f1c28 394 const struct snd_soc_dapm_route *route, int num);
efcc3c61
MB
395int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm,
396 const struct snd_soc_dapm_route *route, int num);
bf3a9e13
MB
397int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm,
398 const struct snd_soc_dapm_route *route, int num);
808db4a4
RP
399
400/* dapm events */
d9b0951b
LG
401void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
402 int event);
f0fba2ad 403void snd_soc_dapm_shutdown(struct snd_soc_card *card);
808db4a4 404
40f02cd9 405/* external DAPM widget events */
ce6cfaf1 406int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
6b3fc03b
LPC
407 struct snd_kcontrol *kcontrol, int connect,
408 struct snd_soc_dapm_update *update);
ce6cfaf1 409int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm,
6b3fc03b
LPC
410 struct snd_kcontrol *kcontrol, int mux, struct soc_enum *e,
411 struct snd_soc_dapm_update *update);
40f02cd9 412
808db4a4 413/* dapm sys fs - used by the core */
d29697dc 414extern struct attribute *soc_dapm_dev_attrs[];
8eecaf62
LPC
415void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
416 struct dentry *parent);
808db4a4 417
a5302181 418/* dapm audio pin control and status */
ce6120cc
LG
419int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm,
420 const char *pin);
11391100
CK
421int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
422 const char *pin);
ce6120cc
LG
423int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
424 const char *pin);
11391100
CK
425int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm,
426 const char *pin);
ce6120cc 427int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin);
11391100
CK
428int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm,
429 const char *pin);
ce6120cc
LG
430int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm,
431 const char *pin);
432int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm);
3eb29dfb 433int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context *dapm);
ce6120cc 434int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
da34183e 435 const char *pin);
11391100
CK
436int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
437 const char *pin);
ce6120cc
LG
438int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
439 const char *pin);
5dc0158a 440unsigned int dapm_kcontrol_get_value(const struct snd_kcontrol *kcontrol);
808db4a4 441
25c77c5f 442/* Mostly internal - should not normally be used */
8be4da29 443void dapm_mark_endpoints_dirty(struct snd_soc_card *card);
25c77c5f 444
ec2e3031
LG
445/* dapm path query */
446int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream,
447 struct snd_soc_dapm_widget_list **list);
448
ce0fc93a
LPC
449struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm(
450 struct snd_kcontrol *kcontrol);
eee5d7f9 451
fa880775
LPC
452int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm,
453 enum snd_soc_bias_level level);
454
808db4a4
RP
455/* dapm widget types */
456enum snd_soc_dapm_type {
457 snd_soc_dapm_input = 0, /* input pin */
458 snd_soc_dapm_output, /* output pin */
459 snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */
d714f97c 460 snd_soc_dapm_demux, /* connects the input to one of multiple outputs */
808db4a4 461 snd_soc_dapm_mixer, /* mixes several analog signals together */
ca9c1aae 462 snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */
808db4a4 463 snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */
d88429a6 464 snd_soc_dapm_out_drv, /* output driver */
808db4a4
RP
465 snd_soc_dapm_adc, /* analog to digital converter */
466 snd_soc_dapm_dac, /* digital to analog converter */
467 snd_soc_dapm_micbias, /* microphone bias (power) */
468 snd_soc_dapm_mic, /* microphone */
469 snd_soc_dapm_hp, /* headphones */
470 snd_soc_dapm_spk, /* speaker */
471 snd_soc_dapm_line, /* line input/output */
472 snd_soc_dapm_switch, /* analog switch */
473 snd_soc_dapm_vmid, /* codec bias/vmid - to minimise pops */
474 snd_soc_dapm_pre, /* machine specific pre widget - exec first */
475 snd_soc_dapm_post, /* machine specific post widget - exec last */
246d0a17 476 snd_soc_dapm_supply, /* power/clock supply */
62ea874a 477 snd_soc_dapm_regulator_supply, /* external regulator */
d7e7eb91 478 snd_soc_dapm_clock_supply, /* external clock */
010ff262
MB
479 snd_soc_dapm_aif_in, /* audio interface input */
480 snd_soc_dapm_aif_out, /* audio interface output */
1ab97c8c 481 snd_soc_dapm_siggen, /* signal generator */
4616274d
MB
482 snd_soc_dapm_dai_in, /* link to DAI structure */
483 snd_soc_dapm_dai_out,
c74184ed 484 snd_soc_dapm_dai_link, /* link between two DAI structures */
57295073 485 snd_soc_dapm_kcontrol, /* Auto-disabled kcontrol */
808db4a4
RP
486};
487
a73fb2df 488enum snd_soc_dapm_subclass {
3cd04343
LG
489 SND_SOC_DAPM_CLASS_INIT = 0,
490 SND_SOC_DAPM_CLASS_RUNTIME = 1,
a73fb2df
LG
491};
492
105f1c28
MB
493/*
494 * DAPM audio route definition.
495 *
496 * Defines an audio route originating at source via control and finishing
497 * at sink.
498 */
499struct snd_soc_dapm_route {
500 const char *sink;
501 const char *control;
502 const char *source;
215edda3
MB
503
504 /* Note: currently only supported for links where source is a supply */
505 int (*connected)(struct snd_soc_dapm_widget *source,
506 struct snd_soc_dapm_widget *sink);
105f1c28
MB
507};
508
808db4a4
RP
509/* dapm audio path between two widgets */
510struct snd_soc_dapm_path {
3056557f 511 const char *name;
808db4a4
RP
512
513 /* source (input) and sink (output) widgets */
514 struct snd_soc_dapm_widget *source;
515 struct snd_soc_dapm_widget *sink;
808db4a4
RP
516
517 /* status */
518 u32 connect:1; /* source and sink widgets are connected */
8af294b4 519 u32 walking:1; /* path is in the process of being walked */
169d5a83 520 u32 weak:1; /* path ignored for power management */
c1862c8b 521 u32 is_supply:1; /* At least one of the connected widgets is a supply */
808db4a4 522
215edda3
MB
523 int (*connected)(struct snd_soc_dapm_widget *source,
524 struct snd_soc_dapm_widget *sink);
525
808db4a4
RP
526 struct list_head list_source;
527 struct list_head list_sink;
5106b92f 528 struct list_head list_kcontrol;
808db4a4
RP
529 struct list_head list;
530};
531
532/* dapm widget */
533struct snd_soc_dapm_widget {
534 enum snd_soc_dapm_type id;
3056557f
MB
535 const char *name; /* widget name */
536 const char *sname; /* stream name */
808db4a4 537 struct list_head list;
ce6120cc 538 struct snd_soc_dapm_context *dapm;
808db4a4 539
62ea874a 540 void *priv; /* widget specific data */
a3cc056b 541 struct regulator *regulator; /* attached regulator */
c74184ed 542 const struct snd_soc_pcm_stream *params; /* params for dai links */
c6615082
NO
543 unsigned int num_params; /* number of params for dai links */
544 unsigned int params_select; /* currently selected param for dai link */
62ea874a 545
808db4a4 546 /* dapm control */
41b5b3bd 547 int reg; /* negative reg = no direct dapm */
808db4a4 548 unsigned char shift; /* bits to shift */
e2be2ccf
JN
549 unsigned int mask; /* non-shifted mask */
550 unsigned int on_val; /* on state value */
551 unsigned int off_val; /* off state value */
808db4a4 552 unsigned char power:1; /* block power status */
808db4a4
RP
553 unsigned char active:1; /* active stream on DAC, ADC's */
554 unsigned char connected:1; /* connected codec pin */
555 unsigned char new:1; /* cnew complete */
da34183e 556 unsigned char force:1; /* force state */
1547aba9 557 unsigned char ignore_suspend:1; /* kept enabled over suspend */
9b8a83b2
MB
558 unsigned char new_power:1; /* power from this run */
559 unsigned char power_checked:1; /* power checked this run */
6dd98b0a
LPC
560 unsigned char is_supply:1; /* Widget is a supply type widget */
561 unsigned char is_sink:1; /* Widget is a sink type widget */
562 unsigned char is_source:1; /* Widget is a source type widget */
20e4859d 563 int subseq; /* sort within widget type */
808db4a4 564
b75576d7
MB
565 int (*power_check)(struct snd_soc_dapm_widget *w);
566
808db4a4
RP
567 /* external events */
568 unsigned short event_flags; /* flags to specify event types */
9af6d956 569 int (*event)(struct snd_soc_dapm_widget*, struct snd_kcontrol *, int);
808db4a4
RP
570
571 /* kcontrols that relate to this widget */
572 int num_kcontrols;
82cfecdc 573 const struct snd_kcontrol_new *kcontrol_news;
fad59888 574 struct snd_kcontrol **kcontrols;
808db4a4
RP
575
576 /* widget input and outputs */
577 struct list_head sources;
578 struct list_head sinks;
6d3ddc81
MB
579
580 /* used during DAPM updates */
92a99ea4 581 struct list_head work_list;
6d3ddc81 582 struct list_head power_list;
db432b41 583 struct list_head dirty;
024dc078
MB
584 int inputs;
585 int outputs;
d7e7eb91
OL
586
587 struct clk *clk;
808db4a4
RP
588};
589
97404f2e 590struct snd_soc_dapm_update {
97404f2e
MB
591 struct snd_kcontrol *kcontrol;
592 int reg;
593 int mask;
594 int val;
595};
596
45a110a1
CK
597struct snd_soc_dapm_wcache {
598 struct snd_soc_dapm_widget *widget;
599};
600
ce6120cc
LG
601/* DAPM context */
602struct snd_soc_dapm_context {
ce6120cc 603 enum snd_soc_bias_level bias_level;
ce6120cc 604 unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */
86dbf2ac
LPC
605 /* Go to BIAS_OFF in suspend if the DAPM context is idle */
606 unsigned int suspend_bias_off:1;
474b62d6 607 void (*seq_notifier)(struct snd_soc_dapm_context *,
f85a9e0d 608 enum snd_soc_dapm_type, int);
474b62d6 609
ce6120cc 610 struct device *dev; /* from parent - for debug */
e2c330b9 611 struct snd_soc_component *component; /* parent component */
3a45b867 612 struct snd_soc_card *card; /* parent card */
7be31be8
JN
613
614 /* used during DAPM updates */
56fba41f 615 enum snd_soc_bias_level target_bias_level;
7be31be8
JN
616 struct list_head list;
617
64a648c2 618 int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
68f831c2
LPC
619 int (*set_bias_level)(struct snd_soc_dapm_context *dapm,
620 enum snd_soc_bias_level level);
64a648c2 621
45a110a1
CK
622 struct snd_soc_dapm_wcache path_sink_cache;
623 struct snd_soc_dapm_wcache path_source_cache;
624
ce6120cc
LG
625#ifdef CONFIG_DEBUG_FS
626 struct dentry *debugfs_dapm;
627#endif
628};
629
fafd2176
SW
630/* A list of widgets associated with an object, typically a snd_kcontrol */
631struct snd_soc_dapm_widget_list {
632 int num_widgets;
633 struct snd_soc_dapm_widget *widgets[0];
634};
635
de02d078
MB
636struct snd_soc_dapm_stats {
637 int power_checks;
638 int path_checks;
e56235e0 639 int neighbour_checks;
de02d078
MB
640};
641
fa880775
LPC
642/**
643 * snd_soc_dapm_init_bias_level() - Initialize DAPM bias level
644 * @dapm: The DAPM context to initialize
645 * @level: The DAPM level to initialize to
646 *
647 * This function only sets the driver internal state of the DAPM level and will
648 * not modify the state of the device. Hence it should not be used during normal
649 * operation, but only to synchronize the internal state to the device state.
650 * E.g. during driver probe to set the DAPM level to the one corresponding with
651 * the power-on reset state of the device.
652 *
653 * To change the DAPM state of the device use snd_soc_dapm_set_bias_level().
654 */
655static inline void snd_soc_dapm_init_bias_level(
656 struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level)
657{
658 dapm->bias_level = level;
659}
660
661/**
662 * snd_soc_dapm_get_bias_level() - Get current DAPM bias level
663 * @dapm: The context for which to get the bias level
664 *
665 * Returns: The current bias level of the passed DAPM context.
666 */
667static inline enum snd_soc_bias_level snd_soc_dapm_get_bias_level(
668 struct snd_soc_dapm_context *dapm)
669{
670 return dapm->bias_level;
671}
672
808db4a4 673#endif
This page took 0.416533 seconds and 5 git commands to generate.