]>
Commit | Line | Data |
---|---|---|
808db4a4 RP |
1 | /* |
2 | * linux/sound/soc.h -- ALSA SoC Layer | |
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_H | |
14 | #define __LINUX_SND_SOC_H | |
15 | ||
cb470087 | 16 | #include <linux/of.h> |
808db4a4 RP |
17 | #include <linux/platform_device.h> |
18 | #include <linux/types.h> | |
d5021ec9 | 19 | #include <linux/notifier.h> |
4484bb2e | 20 | #include <linux/workqueue.h> |
ec67624d LCM |
21 | #include <linux/interrupt.h> |
22 | #include <linux/kernel.h> | |
be3ea3b9 | 23 | #include <linux/regmap.h> |
86767b7d | 24 | #include <linux/log2.h> |
808db4a4 RP |
25 | #include <sound/core.h> |
26 | #include <sound/pcm.h> | |
49681077 | 27 | #include <sound/compress_driver.h> |
808db4a4 RP |
28 | #include <sound/control.h> |
29 | #include <sound/ac97_codec.h> | |
30 | ||
808db4a4 RP |
31 | /* |
32 | * Convenience kcontrol builders | |
33 | */ | |
57295073 | 34 | #define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert, xautodisable) \ |
4eaa9819 | 35 | ((unsigned long)&(struct soc_mixer_control) \ |
30d86ba4 PU |
36 | {.reg = xreg, .rreg = xreg, .shift = shift_left, \ |
37 | .rshift = shift_right, .max = xmax, .platform_max = xmax, \ | |
57295073 LPC |
38 | .invert = xinvert, .autodisable = xautodisable}) |
39 | #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, xautodisable) \ | |
40 | SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert, xautodisable) | |
4eaa9819 JS |
41 | #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \ |
42 | ((unsigned long)&(struct soc_mixer_control) \ | |
d11bb4a9 | 43 | {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert}) |
cdffa775 PU |
44 | #define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \ |
45 | ((unsigned long)&(struct soc_mixer_control) \ | |
46 | {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \ | |
47 | .max = xmax, .platform_max = xmax, .invert = xinvert}) | |
cd21b123 MP |
48 | #define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \ |
49 | ((unsigned long)&(struct soc_mixer_control) \ | |
50 | {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \ | |
51 | .max = xmax, .min = xmin, .platform_max = xmax, .sign_bit = xsign_bit, \ | |
52 | .invert = xinvert}) | |
229e3fdc MB |
53 | #define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \ |
54 | ((unsigned long)&(struct soc_mixer_control) \ | |
55 | {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \ | |
56 | .min = xmin, .max = xmax, .platform_max = xmax, .invert = xinvert}) | |
a7a4ac86 | 57 | #define SOC_SINGLE(xname, reg, shift, max, invert) \ |
808db4a4 RP |
58 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
59 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ | |
60 | .put = snd_soc_put_volsw, \ | |
57295073 | 61 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) } |
6c9d8cf6 AT |
62 | #define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \ |
63 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ | |
64 | .info = snd_soc_info_volsw_range, .get = snd_soc_get_volsw_range, \ | |
65 | .put = snd_soc_put_volsw_range, \ | |
66 | .private_value = (unsigned long)&(struct soc_mixer_control) \ | |
9bde4f0b MB |
67 | {.reg = xreg, .rreg = xreg, .shift = xshift, \ |
68 | .rshift = xshift, .min = xmin, .max = xmax, \ | |
69 | .platform_max = xmax, .invert = xinvert} } | |
a7a4ac86 PZ |
70 | #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ |
71 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
72 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ | |
73 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | |
74 | .tlv.p = (tlv_array), \ | |
75 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ | |
76 | .put = snd_soc_put_volsw, \ | |
57295073 | 77 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) } |
1d99f243 BA |
78 | #define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \ |
79 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
80 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | |
81 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | |
82 | .tlv.p = (tlv_array),\ | |
83 | .info = snd_soc_info_volsw, \ | |
84 | .get = snd_soc_get_volsw_sx,\ | |
85 | .put = snd_soc_put_volsw_sx, \ | |
86 | .private_value = (unsigned long)&(struct soc_mixer_control) \ | |
87 | {.reg = xreg, .rreg = xreg, \ | |
88 | .shift = xshift, .rshift = xshift, \ | |
89 | .max = xmax, .min = xmin} } | |
6c9d8cf6 AT |
90 | #define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \ |
91 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ | |
92 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ | |
93 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | |
94 | .tlv.p = (tlv_array), \ | |
95 | .info = snd_soc_info_volsw_range, \ | |
96 | .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \ | |
97 | .private_value = (unsigned long)&(struct soc_mixer_control) \ | |
9bde4f0b MB |
98 | {.reg = xreg, .rreg = xreg, .shift = xshift, \ |
99 | .rshift = xshift, .min = xmin, .max = xmax, \ | |
100 | .platform_max = xmax, .invert = xinvert} } | |
460acbec | 101 | #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \ |
808db4a4 RP |
102 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ |
103 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ | |
104 | .put = snd_soc_put_volsw, \ | |
460acbec | 105 | .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \ |
57295073 | 106 | max, invert, 0) } |
4eaa9819 | 107 | #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \ |
808db4a4 | 108 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
e8f5a103 | 109 | .info = snd_soc_info_volsw, \ |
974815ba | 110 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ |
cdffa775 PU |
111 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ |
112 | xmax, xinvert) } | |
229e3fdc MB |
113 | #define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \ |
114 | xmax, xinvert) \ | |
115 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ | |
116 | .info = snd_soc_info_volsw_range, \ | |
117 | .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \ | |
118 | .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \ | |
119 | xshift, xmin, xmax, xinvert) } | |
460acbec | 120 | #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \ |
a7a4ac86 PZ |
121 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ |
122 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ | |
123 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | |
124 | .tlv.p = (tlv_array), \ | |
125 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ | |
126 | .put = snd_soc_put_volsw, \ | |
460acbec | 127 | .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \ |
57295073 | 128 | max, invert, 0) } |
4eaa9819 | 129 | #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \ |
a7a4ac86 PZ |
130 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ |
131 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ | |
132 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | |
133 | .tlv.p = (tlv_array), \ | |
e8f5a103 | 134 | .info = snd_soc_info_volsw, \ |
974815ba | 135 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ |
cdffa775 PU |
136 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ |
137 | xmax, xinvert) } | |
229e3fdc MB |
138 | #define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \ |
139 | xmax, xinvert, tlv_array) \ | |
140 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ | |
141 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ | |
142 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | |
143 | .tlv.p = (tlv_array), \ | |
144 | .info = snd_soc_info_volsw_range, \ | |
145 | .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \ | |
146 | .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \ | |
147 | xshift, xmin, xmax, xinvert) } | |
1d99f243 BA |
148 | #define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \ |
149 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | |
150 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | |
151 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | |
152 | .tlv.p = (tlv_array), \ | |
153 | .info = snd_soc_info_volsw, \ | |
154 | .get = snd_soc_get_volsw_sx, \ | |
155 | .put = snd_soc_put_volsw_sx, \ | |
156 | .private_value = (unsigned long)&(struct soc_mixer_control) \ | |
157 | {.reg = xreg, .rreg = xrreg, \ | |
158 | .shift = xshift, .rshift = xshift, \ | |
159 | .max = xmax, .min = xmin} } | |
cd21b123 MP |
160 | #define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \ |
161 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ | |
162 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ | |
163 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | |
164 | .tlv.p = (tlv_array), \ | |
165 | .info = snd_soc_info_volsw, \ | |
166 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ | |
167 | .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \ | |
168 | xmin, xmax, xsign_bit, xinvert) } | |
4eaa9819 | 169 | #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \ |
e13ac2e9 MB |
170 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
171 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | |
172 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | |
173 | .tlv.p = (tlv_array), \ | |
174 | .info = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \ | |
175 | .put = snd_soc_put_volsw_s8, \ | |
4eaa9819 | 176 | .private_value = (unsigned long)&(struct soc_mixer_control) \ |
d11bb4a9 PU |
177 | {.reg = xreg, .min = xmin, .max = xmax, \ |
178 | .platform_max = xmax} } | |
9a8d38db | 179 | #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \ |
808db4a4 | 180 | { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ |
9a8d38db TI |
181 | .items = xitems, .texts = xtexts, \ |
182 | .mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0} | |
183 | #define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \ | |
184 | SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts) | |
185 | #define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \ | |
186 | { .items = xitems, .texts = xtexts } | |
187 | #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \ | |
2e72f8e3 | 188 | { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ |
9a8d38db TI |
189 | .mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues} |
190 | #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xnitmes, xtexts, xvalues) \ | |
191 | SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xnitmes, xtexts, xvalues) | |
808db4a4 RP |
192 | #define SOC_ENUM(xname, xenum) \ |
193 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ | |
194 | .info = snd_soc_info_enum_double, \ | |
195 | .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \ | |
196 | .private_value = (unsigned long)&xenum } | |
2e72f8e3 | 197 | #define SOC_VALUE_ENUM(xname, xenum) \ |
29ae2fa5 | 198 | SOC_ENUM(xname, xenum) |
f8ba0b7b | 199 | #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\ |
808db4a4 RP |
200 | xhandler_get, xhandler_put) \ |
201 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
1c433fbd | 202 | .info = snd_soc_info_volsw, \ |
808db4a4 | 203 | .get = xhandler_get, .put = xhandler_put, \ |
57295073 | 204 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) } |
460acbec | 205 | #define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\ |
7629ad24 DM |
206 | xhandler_get, xhandler_put) \ |
207 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ | |
208 | .info = snd_soc_info_volsw, \ | |
209 | .get = xhandler_get, .put = xhandler_put, \ | |
460acbec | 210 | .private_value = \ |
57295073 | 211 | SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) } |
f8ba0b7b | 212 | #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\ |
10144c09 MM |
213 | xhandler_get, xhandler_put, tlv_array) \ |
214 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
215 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ | |
216 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | |
217 | .tlv.p = (tlv_array), \ | |
218 | .info = snd_soc_info_volsw, \ | |
219 | .get = xhandler_get, .put = xhandler_put, \ | |
57295073 | 220 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) } |
d0af93db JS |
221 | #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\ |
222 | xhandler_get, xhandler_put, tlv_array) \ | |
223 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | |
224 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | |
225 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | |
226 | .tlv.p = (tlv_array), \ | |
227 | .info = snd_soc_info_volsw, \ | |
228 | .get = xhandler_get, .put = xhandler_put, \ | |
460acbec | 229 | .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \ |
57295073 | 230 | xmax, xinvert, 0) } |
3ce91d5a JS |
231 | #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\ |
232 | xhandler_get, xhandler_put, tlv_array) \ | |
233 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | |
234 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | |
235 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | |
236 | .tlv.p = (tlv_array), \ | |
e8f5a103 | 237 | .info = snd_soc_info_volsw, \ |
3ce91d5a | 238 | .get = xhandler_get, .put = xhandler_put, \ |
cdffa775 PU |
239 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ |
240 | xmax, xinvert) } | |
808db4a4 RP |
241 | #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \ |
242 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
243 | .info = snd_soc_info_bool_ext, \ | |
244 | .get = xhandler_get, .put = xhandler_put, \ | |
245 | .private_value = xdata } | |
246 | #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \ | |
247 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
9a953e6f | 248 | .info = snd_soc_info_enum_double, \ |
808db4a4 RP |
249 | .get = xhandler_get, .put = xhandler_put, \ |
250 | .private_value = (unsigned long)&xenum } | |
251 | ||
71d08516 MB |
252 | #define SND_SOC_BYTES(xname, xbase, xregs) \ |
253 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
254 | .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \ | |
255 | .put = snd_soc_bytes_put, .private_value = \ | |
256 | ((unsigned long)&(struct soc_bytes) \ | |
257 | {.base = xbase, .num_regs = xregs }) } | |
b6f4bb38 | 258 | |
f831b055 MB |
259 | #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask) \ |
260 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
261 | .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \ | |
262 | .put = snd_soc_bytes_put, .private_value = \ | |
263 | ((unsigned long)&(struct soc_bytes) \ | |
264 | {.base = xbase, .num_regs = xregs, \ | |
265 | .mask = xmask }) } | |
266 | ||
4183eed2 KK |
267 | #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \ |
268 | xmin, xmax, xinvert) \ | |
269 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | |
270 | .info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \ | |
271 | .put = snd_soc_put_xr_sx, \ | |
272 | .private_value = (unsigned long)&(struct soc_mreg_control) \ | |
273 | {.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \ | |
274 | .invert = xinvert, .min = xmin, .max = xmax} } | |
275 | ||
dd7b10b3 KK |
276 | #define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \ |
277 | SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \ | |
278 | snd_soc_get_strobe, snd_soc_put_strobe) | |
279 | ||
6c2fb6a8 GL |
280 | /* |
281 | * Simplified versions of above macros, declaring a struct and calculating | |
282 | * ARRAY_SIZE internally | |
283 | */ | |
284 | #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \ | |
2e7e1993 | 285 | const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \ |
6c2fb6a8 GL |
286 | ARRAY_SIZE(xtexts), xtexts) |
287 | #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \ | |
288 | SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts) | |
289 | #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \ | |
2e7e1993 | 290 | const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts) |
6c2fb6a8 | 291 | #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \ |
2e7e1993 | 292 | const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \ |
6c2fb6a8 GL |
293 | ARRAY_SIZE(xtexts), xtexts, xvalues) |
294 | #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \ | |
295 | SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues) | |
296 | ||
0168bf0d LG |
297 | /* |
298 | * Component probe and remove ordering levels for components with runtime | |
299 | * dependencies. | |
300 | */ | |
301 | #define SND_SOC_COMP_ORDER_FIRST -2 | |
302 | #define SND_SOC_COMP_ORDER_EARLY -1 | |
303 | #define SND_SOC_COMP_ORDER_NORMAL 0 | |
304 | #define SND_SOC_COMP_ORDER_LATE 1 | |
305 | #define SND_SOC_COMP_ORDER_LAST 2 | |
306 | ||
0be9898a MB |
307 | /* |
308 | * Bias levels | |
309 | * | |
310 | * @ON: Bias is fully on for audio playback and capture operations. | |
311 | * @PREPARE: Prepare for audio operations. Called before DAPM switching for | |
312 | * stream start and stop operations. | |
313 | * @STANDBY: Low power standby state when no playback/capture operations are | |
314 | * in progress. NOTE: The transition time between STANDBY and ON | |
315 | * should be as fast as possible and no longer than 10ms. | |
316 | * @OFF: Power Off. No restrictions on transition times. | |
317 | */ | |
318 | enum snd_soc_bias_level { | |
56fba41f MB |
319 | SND_SOC_BIAS_OFF = 0, |
320 | SND_SOC_BIAS_STANDBY = 1, | |
321 | SND_SOC_BIAS_PREPARE = 2, | |
322 | SND_SOC_BIAS_ON = 3, | |
0be9898a MB |
323 | }; |
324 | ||
5a504963 | 325 | struct device_node; |
8a2cd618 MB |
326 | struct snd_jack; |
327 | struct snd_soc_card; | |
808db4a4 RP |
328 | struct snd_soc_pcm_stream; |
329 | struct snd_soc_ops; | |
808db4a4 | 330 | struct snd_soc_pcm_runtime; |
3c4b266f | 331 | struct snd_soc_dai; |
f0fba2ad | 332 | struct snd_soc_dai_driver; |
12a48a8c | 333 | struct snd_soc_platform; |
d273ebe7 | 334 | struct snd_soc_dai_link; |
f0fba2ad | 335 | struct snd_soc_platform_driver; |
808db4a4 | 336 | struct snd_soc_codec; |
f0fba2ad | 337 | struct snd_soc_codec_driver; |
030e79f6 KM |
338 | struct snd_soc_component; |
339 | struct snd_soc_component_driver; | |
808db4a4 | 340 | struct soc_enum; |
8a2cd618 | 341 | struct snd_soc_jack; |
fa9879ed | 342 | struct snd_soc_jack_zone; |
8a2cd618 | 343 | struct snd_soc_jack_pin; |
ce6120cc | 344 | #include <sound/soc-dapm.h> |
01d7584c | 345 | #include <sound/soc-dpcm.h> |
f0fba2ad | 346 | |
ec67624d | 347 | struct snd_soc_jack_gpio; |
808db4a4 RP |
348 | |
349 | typedef int (*hw_write_t)(void *,const char* ,int); | |
808db4a4 | 350 | |
b047e1cc | 351 | extern struct snd_ac97_bus_ops *soc_ac97_ops; |
808db4a4 | 352 | |
7084a42b | 353 | enum snd_soc_control_type { |
e9c03905 | 354 | SND_SOC_I2C = 1, |
7084a42b | 355 | SND_SOC_SPI, |
0671da18 | 356 | SND_SOC_REGMAP, |
7084a42b MB |
357 | }; |
358 | ||
b8c0dab9 LG |
359 | enum snd_soc_pcm_subclass { |
360 | SND_SOC_PCM_CLASS_PCM = 0, | |
361 | SND_SOC_PCM_CLASS_BE = 1, | |
362 | }; | |
363 | ||
01b9d99a | 364 | enum snd_soc_card_subclass { |
6874a918 LG |
365 | SND_SOC_CARD_CLASS_INIT = 0, |
366 | SND_SOC_CARD_CLASS_RUNTIME = 1, | |
01b9d99a LG |
367 | }; |
368 | ||
ec4ee52a | 369 | int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id, |
da1c6ea6 | 370 | int source, unsigned int freq, int dir); |
ec4ee52a MB |
371 | int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, |
372 | unsigned int freq_in, unsigned int freq_out); | |
373 | ||
70a7ca34 VK |
374 | int snd_soc_register_card(struct snd_soc_card *card); |
375 | int snd_soc_unregister_card(struct snd_soc_card *card); | |
0e4ff5c8 | 376 | int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card); |
6f8ab4ac MB |
377 | int snd_soc_suspend(struct device *dev); |
378 | int snd_soc_resume(struct device *dev); | |
379 | int snd_soc_poweroff(struct device *dev); | |
f0fba2ad | 380 | int snd_soc_register_platform(struct device *dev, |
d79e57db | 381 | const struct snd_soc_platform_driver *platform_drv); |
f0fba2ad | 382 | void snd_soc_unregister_platform(struct device *dev); |
71a45cda LPC |
383 | int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, |
384 | const struct snd_soc_platform_driver *platform_drv); | |
385 | void snd_soc_remove_platform(struct snd_soc_platform *platform); | |
386 | struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev); | |
f0fba2ad | 387 | int snd_soc_register_codec(struct device *dev, |
001ae4c0 | 388 | const struct snd_soc_codec_driver *codec_drv, |
f0fba2ad LG |
389 | struct snd_soc_dai_driver *dai_drv, int num_dai); |
390 | void snd_soc_unregister_codec(struct device *dev); | |
030e79f6 KM |
391 | int snd_soc_register_component(struct device *dev, |
392 | const struct snd_soc_component_driver *cmpnt_drv, | |
393 | struct snd_soc_dai_driver *dai_drv, int num_dai); | |
a0b03a61 MB |
394 | int devm_snd_soc_register_component(struct device *dev, |
395 | const struct snd_soc_component_driver *cmpnt_drv, | |
396 | struct snd_soc_dai_driver *dai_drv, int num_dai); | |
030e79f6 | 397 | void snd_soc_unregister_component(struct device *dev); |
181e055e MB |
398 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, |
399 | unsigned int reg); | |
239c9706 DP |
400 | int snd_soc_codec_readable_register(struct snd_soc_codec *codec, |
401 | unsigned int reg); | |
402 | int snd_soc_codec_writable_register(struct snd_soc_codec *codec, | |
403 | unsigned int reg); | |
17a52fd6 | 404 | int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, |
7084a42b MB |
405 | int addr_bits, int data_bits, |
406 | enum snd_soc_control_type control); | |
7a30a3db DP |
407 | int snd_soc_cache_sync(struct snd_soc_codec *codec); |
408 | int snd_soc_cache_init(struct snd_soc_codec *codec); | |
409 | int snd_soc_cache_exit(struct snd_soc_codec *codec); | |
410 | int snd_soc_cache_write(struct snd_soc_codec *codec, | |
411 | unsigned int reg, unsigned int value); | |
412 | int snd_soc_cache_read(struct snd_soc_codec *codec, | |
413 | unsigned int reg, unsigned int *value); | |
f1442bc1 LG |
414 | int snd_soc_platform_read(struct snd_soc_platform *platform, |
415 | unsigned int reg); | |
416 | int snd_soc_platform_write(struct snd_soc_platform *platform, | |
417 | unsigned int reg, unsigned int val); | |
354a2142 | 418 | int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num); |
49681077 | 419 | int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num); |
12a48a8c | 420 | |
47c88fff LG |
421 | struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, |
422 | const char *dai_link, int stream); | |
423 | struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, | |
424 | const char *dai_link); | |
425 | ||
7aae816d MB |
426 | /* Utility functions to get clock rates from various things */ |
427 | int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); | |
428 | int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params); | |
c0fa59df | 429 | int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots); |
7aae816d MB |
430 | int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms); |
431 | ||
808db4a4 RP |
432 | /* set runtime hw params */ |
433 | int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, | |
434 | const struct snd_pcm_hardware *hw); | |
808db4a4 | 435 | |
07bf84aa LG |
436 | int snd_soc_platform_trigger(struct snd_pcm_substream *substream, |
437 | int cmd, struct snd_soc_platform *platform); | |
438 | ||
8a2cd618 | 439 | /* Jack reporting */ |
f0fba2ad | 440 | int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, |
8a2cd618 MB |
441 | struct snd_soc_jack *jack); |
442 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); | |
443 | int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, | |
444 | struct snd_soc_jack_pin *pins); | |
d5021ec9 MB |
445 | void snd_soc_jack_notifier_register(struct snd_soc_jack *jack, |
446 | struct notifier_block *nb); | |
447 | void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack, | |
448 | struct notifier_block *nb); | |
fa9879ed VK |
449 | int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count, |
450 | struct snd_soc_jack_zone *zones); | |
451 | int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage); | |
ec67624d LCM |
452 | #ifdef CONFIG_GPIOLIB |
453 | int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |
454 | struct snd_soc_jack_gpio *gpios); | |
455 | void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, | |
456 | struct snd_soc_jack_gpio *gpios); | |
8778ac6b TI |
457 | #else |
458 | static inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |
459 | struct snd_soc_jack_gpio *gpios) | |
460 | { | |
461 | return 0; | |
462 | } | |
463 | ||
464 | static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, | |
465 | struct snd_soc_jack_gpio *gpios) | |
466 | { | |
467 | } | |
ec67624d | 468 | #endif |
8a2cd618 | 469 | |
808db4a4 RP |
470 | /* codec register bit access */ |
471 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, | |
46f5822f | 472 | unsigned int mask, unsigned int value); |
dd1b3d53 MB |
473 | int snd_soc_update_bits_locked(struct snd_soc_codec *codec, |
474 | unsigned short reg, unsigned int mask, | |
475 | unsigned int value); | |
808db4a4 | 476 | int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, |
46f5822f | 477 | unsigned int mask, unsigned int value); |
808db4a4 RP |
478 | |
479 | int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, | |
480 | struct snd_ac97_bus_ops *ops, int num); | |
481 | void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); | |
482 | ||
b047e1cc | 483 | int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops); |
741a509f MP |
484 | int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops, |
485 | struct platform_device *pdev); | |
b047e1cc | 486 | |
808db4a4 RP |
487 | /* |
488 | *Controls | |
489 | */ | |
490 | struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, | |
3056557f | 491 | void *data, const char *long_name, |
efb7ac3f | 492 | const char *prefix); |
4fefd698 DP |
493 | struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, |
494 | const char *name); | |
022658be | 495 | int snd_soc_add_codec_controls(struct snd_soc_codec *codec, |
3e8e1952 | 496 | const struct snd_kcontrol_new *controls, int num_controls); |
a491a5c8 LG |
497 | int snd_soc_add_platform_controls(struct snd_soc_platform *platform, |
498 | const struct snd_kcontrol_new *controls, int num_controls); | |
022658be LG |
499 | int snd_soc_add_card_controls(struct snd_soc_card *soc_card, |
500 | const struct snd_kcontrol_new *controls, int num_controls); | |
501 | int snd_soc_add_dai_controls(struct snd_soc_dai *dai, | |
502 | const struct snd_kcontrol_new *controls, int num_controls); | |
808db4a4 RP |
503 | int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, |
504 | struct snd_ctl_elem_info *uinfo); | |
808db4a4 RP |
505 | int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, |
506 | struct snd_ctl_elem_value *ucontrol); | |
507 | int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, | |
508 | struct snd_ctl_elem_value *ucontrol); | |
509 | int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, | |
808db4a4 | 510 | struct snd_ctl_elem_info *uinfo); |
392abe9c | 511 | #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info |
808db4a4 RP |
512 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, |
513 | struct snd_ctl_elem_value *ucontrol); | |
514 | int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, | |
515 | struct snd_ctl_elem_value *ucontrol); | |
a92f1394 PU |
516 | #define snd_soc_get_volsw_2r snd_soc_get_volsw |
517 | #define snd_soc_put_volsw_2r snd_soc_put_volsw | |
1d99f243 BA |
518 | int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol, |
519 | struct snd_ctl_elem_value *ucontrol); | |
520 | int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, | |
521 | struct snd_ctl_elem_value *ucontrol); | |
e13ac2e9 MB |
522 | int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, |
523 | struct snd_ctl_elem_info *uinfo); | |
524 | int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, | |
525 | struct snd_ctl_elem_value *ucontrol); | |
526 | int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol, | |
527 | struct snd_ctl_elem_value *ucontrol); | |
6c9d8cf6 AT |
528 | int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol, |
529 | struct snd_ctl_elem_info *uinfo); | |
530 | int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol, | |
531 | struct snd_ctl_elem_value *ucontrol); | |
532 | int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol, | |
533 | struct snd_ctl_elem_value *ucontrol); | |
637d3847 PU |
534 | int snd_soc_limit_volume(struct snd_soc_codec *codec, |
535 | const char *name, int max); | |
71d08516 MB |
536 | int snd_soc_bytes_info(struct snd_kcontrol *kcontrol, |
537 | struct snd_ctl_elem_info *uinfo); | |
538 | int snd_soc_bytes_get(struct snd_kcontrol *kcontrol, | |
539 | struct snd_ctl_elem_value *ucontrol); | |
540 | int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, | |
541 | struct snd_ctl_elem_value *ucontrol); | |
4183eed2 KK |
542 | int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol, |
543 | struct snd_ctl_elem_info *uinfo); | |
544 | int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol, | |
545 | struct snd_ctl_elem_value *ucontrol); | |
546 | int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol, | |
547 | struct snd_ctl_elem_value *ucontrol); | |
dd7b10b3 KK |
548 | int snd_soc_get_strobe(struct snd_kcontrol *kcontrol, |
549 | struct snd_ctl_elem_value *ucontrol); | |
550 | int snd_soc_put_strobe(struct snd_kcontrol *kcontrol, | |
551 | struct snd_ctl_elem_value *ucontrol); | |
808db4a4 | 552 | |
8a2cd618 MB |
553 | /** |
554 | * struct snd_soc_jack_pin - Describes a pin to update based on jack detection | |
555 | * | |
556 | * @pin: name of the pin to update | |
557 | * @mask: bits to check for in reported jack status | |
558 | * @invert: if non-zero then pin is enabled when status is not reported | |
559 | */ | |
560 | struct snd_soc_jack_pin { | |
561 | struct list_head list; | |
562 | const char *pin; | |
563 | int mask; | |
564 | bool invert; | |
565 | }; | |
566 | ||
fa9879ed VK |
567 | /** |
568 | * struct snd_soc_jack_zone - Describes voltage zones of jack detection | |
569 | * | |
570 | * @min_mv: start voltage in mv | |
571 | * @max_mv: end voltage in mv | |
572 | * @jack_type: type of jack that is expected for this voltage | |
573 | * @debounce_time: debounce_time for jack, codec driver should wait for this | |
574 | * duration before reading the adc for voltages | |
575 | * @:list: list container | |
576 | */ | |
577 | struct snd_soc_jack_zone { | |
578 | unsigned int min_mv; | |
579 | unsigned int max_mv; | |
580 | unsigned int jack_type; | |
581 | unsigned int debounce_time; | |
582 | struct list_head list; | |
583 | }; | |
584 | ||
ec67624d LCM |
585 | /** |
586 | * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection | |
587 | * | |
588 | * @gpio: gpio number | |
589 | * @name: gpio name | |
590 | * @report: value to report when jack detected | |
591 | * @invert: report presence in low state | |
592 | * @debouce_time: debouce time in ms | |
7887ab3a | 593 | * @wake: enable as wake source |
fadddc87 MB |
594 | * @jack_status_check: callback function which overrides the detection |
595 | * to provide more complex checks (eg, reading an | |
596 | * ADC). | |
ec67624d | 597 | */ |
ec67624d LCM |
598 | struct snd_soc_jack_gpio { |
599 | unsigned int gpio; | |
600 | const char *name; | |
601 | int report; | |
602 | int invert; | |
603 | int debounce_time; | |
7887ab3a MB |
604 | bool wake; |
605 | ||
ec67624d | 606 | struct snd_soc_jack *jack; |
4c14d78e | 607 | struct delayed_work work; |
c871a053 JS |
608 | |
609 | int (*jack_status_check)(void); | |
ec67624d | 610 | }; |
ec67624d | 611 | |
8a2cd618 | 612 | struct snd_soc_jack { |
2667b4b8 | 613 | struct mutex mutex; |
8a2cd618 | 614 | struct snd_jack *jack; |
f0fba2ad | 615 | struct snd_soc_codec *codec; |
8a2cd618 MB |
616 | struct list_head pins; |
617 | int status; | |
d5021ec9 | 618 | struct blocking_notifier_head notifier; |
fa9879ed | 619 | struct list_head jack_zones; |
8a2cd618 MB |
620 | }; |
621 | ||
808db4a4 RP |
622 | /* SoC PCM stream information */ |
623 | struct snd_soc_pcm_stream { | |
f0fba2ad | 624 | const char *stream_name; |
1c433fbd GG |
625 | u64 formats; /* SNDRV_PCM_FMTBIT_* */ |
626 | unsigned int rates; /* SNDRV_PCM_RATE_* */ | |
808db4a4 RP |
627 | unsigned int rate_min; /* min rate */ |
628 | unsigned int rate_max; /* max rate */ | |
629 | unsigned int channels_min; /* min channels */ | |
630 | unsigned int channels_max; /* max channels */ | |
58ba9b25 | 631 | unsigned int sig_bits; /* number of bits of content */ |
808db4a4 RP |
632 | }; |
633 | ||
634 | /* SoC audio ops */ | |
635 | struct snd_soc_ops { | |
636 | int (*startup)(struct snd_pcm_substream *); | |
637 | void (*shutdown)(struct snd_pcm_substream *); | |
638 | int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *); | |
639 | int (*hw_free)(struct snd_pcm_substream *); | |
640 | int (*prepare)(struct snd_pcm_substream *); | |
641 | int (*trigger)(struct snd_pcm_substream *, int); | |
642 | }; | |
643 | ||
49681077 VK |
644 | struct snd_soc_compr_ops { |
645 | int (*startup)(struct snd_compr_stream *); | |
646 | void (*shutdown)(struct snd_compr_stream *); | |
647 | int (*set_params)(struct snd_compr_stream *); | |
648 | int (*trigger)(struct snd_compr_stream *); | |
649 | }; | |
650 | ||
d191bd8d KM |
651 | /* component interface */ |
652 | struct snd_soc_component_driver { | |
653 | const char *name; | |
cb470087 KM |
654 | |
655 | /* DT */ | |
656 | int (*of_xlate_dai_name)(struct snd_soc_component *component, | |
657 | struct of_phandle_args *args, | |
658 | const char **dai_name); | |
d191bd8d KM |
659 | }; |
660 | ||
661 | struct snd_soc_component { | |
662 | const char *name; | |
663 | int id; | |
d191bd8d KM |
664 | struct device *dev; |
665 | struct list_head list; | |
666 | ||
6833c452 KM |
667 | struct snd_soc_dai_driver *dai_drv; |
668 | int num_dai; | |
669 | ||
d191bd8d KM |
670 | const struct snd_soc_component_driver *driver; |
671 | }; | |
672 | ||
f0fba2ad | 673 | /* SoC Audio Codec device */ |
808db4a4 | 674 | struct snd_soc_codec { |
f0fba2ad | 675 | const char *name; |
ead9b919 | 676 | const char *name_prefix; |
f0fba2ad | 677 | int id; |
0d0cf00a | 678 | struct device *dev; |
001ae4c0 | 679 | const struct snd_soc_codec_driver *driver; |
0d0cf00a | 680 | |
f0fba2ad LG |
681 | struct mutex mutex; |
682 | struct snd_soc_card *card; | |
0d0cf00a | 683 | struct list_head list; |
f0fba2ad LG |
684 | struct list_head card_list; |
685 | int num_dai; | |
1500b7b5 DP |
686 | int (*volatile_register)(struct snd_soc_codec *, unsigned int); |
687 | int (*readable_register)(struct snd_soc_codec *, unsigned int); | |
8020454c | 688 | int (*writable_register)(struct snd_soc_codec *, unsigned int); |
808db4a4 RP |
689 | |
690 | /* runtime */ | |
808db4a4 RP |
691 | struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ |
692 | unsigned int active; | |
dad8e7ae | 693 | unsigned int cache_bypass:1; /* Suppress access to the cache */ |
f0fba2ad LG |
694 | unsigned int suspended:1; /* Codec is in suspend PM state */ |
695 | unsigned int probed:1; /* Codec has been probed */ | |
696 | unsigned int ac97_registered:1; /* Codec has been AC97 registered */ | |
0562f788 | 697 | unsigned int ac97_created:1; /* Codec has been created by SoC */ |
fdf0f54d | 698 | unsigned int cache_init:1; /* codec cache has been initialized */ |
8a713da8 | 699 | unsigned int using_regmap:1; /* using regmap access */ |
aaee8ef1 MB |
700 | u32 cache_only; /* Suppress writes to hardware */ |
701 | u32 cache_sync; /* Cache needs to be synced to hardware */ | |
808db4a4 RP |
702 | |
703 | /* codec IO */ | |
704 | void *control_data; /* codec control (i2c/3wire) data */ | |
808db4a4 | 705 | hw_write_t hw_write; |
afa2f106 | 706 | unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); |
c3acec26 MB |
707 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); |
708 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | |
808db4a4 | 709 | void *reg_cache; |
7a30a3db | 710 | struct mutex cache_rw_mutex; |
be3ea3b9 | 711 | int val_bytes; |
a96ca338 | 712 | |
d191bd8d KM |
713 | /* component */ |
714 | struct snd_soc_component component; | |
715 | ||
808db4a4 | 716 | /* dapm */ |
ce6120cc | 717 | struct snd_soc_dapm_context dapm; |
1d69c5c5 | 718 | unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ |
808db4a4 | 719 | |
384c89e2 | 720 | #ifdef CONFIG_DEBUG_FS |
88439ac7 | 721 | struct dentry *debugfs_codec_root; |
384c89e2 | 722 | struct dentry *debugfs_reg; |
384c89e2 | 723 | #endif |
808db4a4 RP |
724 | }; |
725 | ||
f0fba2ad LG |
726 | /* codec driver */ |
727 | struct snd_soc_codec_driver { | |
728 | ||
729 | /* driver ops */ | |
730 | int (*probe)(struct snd_soc_codec *); | |
731 | int (*remove)(struct snd_soc_codec *); | |
84b315ee | 732 | int (*suspend)(struct snd_soc_codec *); |
f0fba2ad | 733 | int (*resume)(struct snd_soc_codec *); |
d191bd8d | 734 | struct snd_soc_component_driver component_driver; |
f0fba2ad | 735 | |
b7af1daf MB |
736 | /* Default control and setup, added after probe() is run */ |
737 | const struct snd_kcontrol_new *controls; | |
738 | int num_controls; | |
89b95ac0 MB |
739 | const struct snd_soc_dapm_widget *dapm_widgets; |
740 | int num_dapm_widgets; | |
741 | const struct snd_soc_dapm_route *dapm_routes; | |
742 | int num_dapm_routes; | |
743 | ||
ec4ee52a MB |
744 | /* codec wide operations */ |
745 | int (*set_sysclk)(struct snd_soc_codec *codec, | |
da1c6ea6 | 746 | int clk_id, int source, unsigned int freq, int dir); |
ec4ee52a MB |
747 | int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source, |
748 | unsigned int freq_in, unsigned int freq_out); | |
749 | ||
f0fba2ad LG |
750 | /* codec IO */ |
751 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | |
752 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | |
753 | int (*display_register)(struct snd_soc_codec *, char *, | |
754 | size_t, unsigned int); | |
d4754ec9 DP |
755 | int (*volatile_register)(struct snd_soc_codec *, unsigned int); |
756 | int (*readable_register)(struct snd_soc_codec *, unsigned int); | |
8020454c | 757 | int (*writable_register)(struct snd_soc_codec *, unsigned int); |
4a8923ba | 758 | unsigned int reg_cache_size; |
f0fba2ad LG |
759 | short reg_cache_step; |
760 | short reg_word_size; | |
761 | const void *reg_cache_default; | |
762 | ||
763 | /* codec bias level */ | |
764 | int (*set_bias_level)(struct snd_soc_codec *, | |
765 | enum snd_soc_bias_level level); | |
33c5f969 | 766 | bool idle_bias_off; |
474b62d6 MB |
767 | |
768 | void (*seq_notifier)(struct snd_soc_dapm_context *, | |
f85a9e0d | 769 | enum snd_soc_dapm_type, int); |
0168bf0d | 770 | |
64a648c2 LG |
771 | /* codec stream completion event */ |
772 | int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); | |
773 | ||
5124e69e MB |
774 | bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */ |
775 | ||
0168bf0d LG |
776 | /* probe ordering - for components with runtime dependencies */ |
777 | int probe_order; | |
778 | int remove_order; | |
808db4a4 RP |
779 | }; |
780 | ||
781 | /* SoC platform interface */ | |
f0fba2ad | 782 | struct snd_soc_platform_driver { |
808db4a4 | 783 | |
f0fba2ad LG |
784 | int (*probe)(struct snd_soc_platform *); |
785 | int (*remove)(struct snd_soc_platform *); | |
786 | int (*suspend)(struct snd_soc_dai *dai); | |
787 | int (*resume)(struct snd_soc_dai *dai); | |
808db4a4 RP |
788 | |
789 | /* pcm creation and destruction */ | |
552d1ef6 | 790 | int (*pcm_new)(struct snd_soc_pcm_runtime *); |
808db4a4 RP |
791 | void (*pcm_free)(struct snd_pcm *); |
792 | ||
cb2cf612 LG |
793 | /* Default control and setup, added after probe() is run */ |
794 | const struct snd_kcontrol_new *controls; | |
795 | int num_controls; | |
796 | const struct snd_soc_dapm_widget *dapm_widgets; | |
797 | int num_dapm_widgets; | |
798 | const struct snd_soc_dapm_route *dapm_routes; | |
799 | int num_dapm_routes; | |
800 | ||
258020d0 PU |
801 | /* |
802 | * For platform caused delay reporting. | |
803 | * Optional. | |
804 | */ | |
805 | snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *, | |
806 | struct snd_soc_dai *); | |
807 | ||
49681077 | 808 | /* platform stream pcm ops */ |
1f03f55b | 809 | const struct snd_pcm_ops *ops; |
0168bf0d | 810 | |
49681077 | 811 | /* platform stream compress ops */ |
ef03c9ae | 812 | const struct snd_compr_ops *compr_ops; |
49681077 | 813 | |
64a648c2 LG |
814 | /* platform stream completion event */ |
815 | int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); | |
816 | ||
0168bf0d LG |
817 | /* probe ordering - for components with runtime dependencies */ |
818 | int probe_order; | |
819 | int remove_order; | |
f1442bc1 LG |
820 | |
821 | /* platform IO - used for platform DAPM */ | |
822 | unsigned int (*read)(struct snd_soc_platform *, unsigned int); | |
823 | int (*write)(struct snd_soc_platform *, unsigned int, unsigned int); | |
07bf84aa | 824 | int (*bespoke_trigger)(struct snd_pcm_substream *, int); |
808db4a4 RP |
825 | }; |
826 | ||
f0fba2ad LG |
827 | struct snd_soc_platform { |
828 | const char *name; | |
829 | int id; | |
830 | struct device *dev; | |
d79e57db | 831 | const struct snd_soc_platform_driver *driver; |
cc22d37e | 832 | struct mutex mutex; |
808db4a4 | 833 | |
f0fba2ad LG |
834 | unsigned int suspended:1; /* platform is suspended */ |
835 | unsigned int probed:1; | |
1c433fbd | 836 | |
f0fba2ad LG |
837 | struct snd_soc_card *card; |
838 | struct list_head list; | |
839 | struct list_head card_list; | |
b7950641 LG |
840 | |
841 | struct snd_soc_dapm_context dapm; | |
731f1ab2 SG |
842 | |
843 | #ifdef CONFIG_DEBUG_FS | |
844 | struct dentry *debugfs_platform_root; | |
731f1ab2 | 845 | #endif |
f0fba2ad | 846 | }; |
808db4a4 | 847 | |
f0fba2ad LG |
848 | struct snd_soc_dai_link { |
849 | /* config - must be set by machine driver */ | |
850 | const char *name; /* Codec name */ | |
851 | const char *stream_name; /* Stream name */ | |
bc92657a SW |
852 | /* |
853 | * You MAY specify the link's CPU-side device, either by device name, | |
854 | * or by DT/OF node, but not both. If this information is omitted, | |
855 | * the CPU-side DAI is matched using .cpu_dai_name only, which hence | |
856 | * must be globally unique. These fields are currently typically used | |
857 | * only for codec to codec links, or systems using device tree. | |
858 | */ | |
859 | const char *cpu_name; | |
860 | const struct device_node *cpu_of_node; | |
861 | /* | |
862 | * You MAY specify the DAI name of the CPU DAI. If this information is | |
863 | * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node | |
864 | * only, which only works well when that device exposes a single DAI. | |
865 | */ | |
f0fba2ad | 866 | const char *cpu_dai_name; |
bc92657a SW |
867 | /* |
868 | * You MUST specify the link's codec, either by device name, or by | |
869 | * DT/OF node, but not both. | |
870 | */ | |
871 | const char *codec_name; | |
872 | const struct device_node *codec_of_node; | |
873 | /* You MUST specify the DAI name within the codec */ | |
f0fba2ad | 874 | const char *codec_dai_name; |
bc92657a SW |
875 | /* |
876 | * You MAY specify the link's platform/PCM/DMA driver, either by | |
877 | * device name, or by DT/OF node, but not both. Some forms of link | |
878 | * do not need a platform. | |
879 | */ | |
880 | const char *platform_name; | |
881 | const struct device_node *platform_of_node; | |
01d7584c | 882 | int be_id; /* optional ID for machine driver BE identification */ |
4ccab3e7 | 883 | |
c74184ed MB |
884 | const struct snd_soc_pcm_stream *params; |
885 | ||
75d9ac46 MB |
886 | unsigned int dai_fmt; /* format to set on init */ |
887 | ||
01d7584c LG |
888 | enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */ |
889 | ||
3efab7dc MB |
890 | /* Keep DAI active over suspend */ |
891 | unsigned int ignore_suspend:1; | |
892 | ||
06f409d7 MB |
893 | /* Symmetry requirements */ |
894 | unsigned int symmetric_rates:1; | |
3635bf09 NC |
895 | unsigned int symmetric_channels:1; |
896 | unsigned int symmetric_samplebits:1; | |
06f409d7 | 897 | |
01d7584c LG |
898 | /* Do not create a PCM for this DAI link (Backend link) */ |
899 | unsigned int no_pcm:1; | |
900 | ||
901 | /* This DAI link can route to other DAI links at runtime (Frontend)*/ | |
902 | unsigned int dynamic:1; | |
903 | ||
1e9de42f LG |
904 | /* DPCM capture and Playback support */ |
905 | unsigned int dpcm_capture:1; | |
906 | unsigned int dpcm_playback:1; | |
907 | ||
e50fad4f | 908 | /* pmdown_time is ignored at stop */ |
909 | unsigned int ignore_pmdown_time:1; | |
910 | ||
f0fba2ad LG |
911 | /* codec/machine specific init - e.g. add machine controls */ |
912 | int (*init)(struct snd_soc_pcm_runtime *rtd); | |
06f409d7 | 913 | |
01d7584c LG |
914 | /* optional hw_params re-writing for BE and FE sync */ |
915 | int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd, | |
916 | struct snd_pcm_hw_params *params); | |
917 | ||
f0fba2ad | 918 | /* machine stream operations */ |
13aec722 LPC |
919 | const struct snd_soc_ops *ops; |
920 | const struct snd_soc_compr_ops *compr_ops; | |
d6bead02 FE |
921 | |
922 | /* For unidirectional dai links */ | |
923 | bool playback_only; | |
924 | bool capture_only; | |
808db4a4 RP |
925 | }; |
926 | ||
ff819b83 | 927 | struct snd_soc_codec_conf { |
ead9b919 | 928 | const char *dev_name; |
ff819b83 DP |
929 | |
930 | /* | |
931 | * optional map of kcontrol, widget and path name prefixes that are | |
932 | * associated per device | |
933 | */ | |
ead9b919 JN |
934 | const char *name_prefix; |
935 | }; | |
936 | ||
2eea392d JN |
937 | struct snd_soc_aux_dev { |
938 | const char *name; /* Codec name */ | |
939 | const char *codec_name; /* for multi-codec */ | |
940 | ||
941 | /* codec/machine specific init - e.g. add machine controls */ | |
942 | int (*init)(struct snd_soc_dapm_context *dapm); | |
943 | }; | |
944 | ||
87506549 MB |
945 | /* SoC card */ |
946 | struct snd_soc_card { | |
f0fba2ad | 947 | const char *name; |
22de71ba LG |
948 | const char *long_name; |
949 | const char *driver_name; | |
c5af3a2e | 950 | struct device *dev; |
f0fba2ad LG |
951 | struct snd_card *snd_card; |
952 | struct module *owner; | |
c5af3a2e MB |
953 | |
954 | struct list_head list; | |
f0fba2ad | 955 | struct mutex mutex; |
a73fb2df | 956 | struct mutex dapm_mutex; |
c5af3a2e | 957 | |
f0fba2ad | 958 | bool instantiated; |
808db4a4 | 959 | |
e7361ec4 | 960 | int (*probe)(struct snd_soc_card *card); |
28e9ad92 | 961 | int (*late_probe)(struct snd_soc_card *card); |
e7361ec4 | 962 | int (*remove)(struct snd_soc_card *card); |
808db4a4 RP |
963 | |
964 | /* the pre and post PM functions are used to do any PM work before and | |
965 | * after the codec and DAI's do any PM work. */ | |
70b2ac12 MB |
966 | int (*suspend_pre)(struct snd_soc_card *card); |
967 | int (*suspend_post)(struct snd_soc_card *card); | |
968 | int (*resume_pre)(struct snd_soc_card *card); | |
969 | int (*resume_post)(struct snd_soc_card *card); | |
808db4a4 | 970 | |
0b4d221b | 971 | /* callbacks */ |
87506549 | 972 | int (*set_bias_level)(struct snd_soc_card *, |
d4c6005f | 973 | struct snd_soc_dapm_context *dapm, |
0be9898a | 974 | enum snd_soc_bias_level level); |
1badabd9 | 975 | int (*set_bias_level_post)(struct snd_soc_card *, |
d4c6005f | 976 | struct snd_soc_dapm_context *dapm, |
1badabd9 | 977 | enum snd_soc_bias_level level); |
0b4d221b | 978 | |
6c5f1fed | 979 | long pmdown_time; |
96dd3622 | 980 | |
808db4a4 RP |
981 | /* CPU <--> Codec DAI links */ |
982 | struct snd_soc_dai_link *dai_link; | |
983 | int num_links; | |
f0fba2ad LG |
984 | struct snd_soc_pcm_runtime *rtd; |
985 | int num_rtd; | |
6308419a | 986 | |
ff819b83 DP |
987 | /* optional codec specific configuration */ |
988 | struct snd_soc_codec_conf *codec_conf; | |
989 | int num_configs; | |
ead9b919 | 990 | |
2eea392d JN |
991 | /* |
992 | * optional auxiliary devices such as amplifiers or codecs with DAI | |
993 | * link unused | |
994 | */ | |
995 | struct snd_soc_aux_dev *aux_dev; | |
996 | int num_aux_devs; | |
997 | struct snd_soc_pcm_runtime *rtd_aux; | |
998 | int num_aux_rtd; | |
999 | ||
b7af1daf MB |
1000 | const struct snd_kcontrol_new *controls; |
1001 | int num_controls; | |
1002 | ||
b8ad29de MB |
1003 | /* |
1004 | * Card-specific routes and widgets. | |
1005 | */ | |
d06e48db | 1006 | const struct snd_soc_dapm_widget *dapm_widgets; |
b8ad29de | 1007 | int num_dapm_widgets; |
d06e48db | 1008 | const struct snd_soc_dapm_route *dapm_routes; |
b8ad29de | 1009 | int num_dapm_routes; |
1633281b | 1010 | bool fully_routed; |
b8ad29de | 1011 | |
6308419a | 1012 | struct work_struct deferred_resume_work; |
f0fba2ad LG |
1013 | |
1014 | /* lists of probed devices belonging to this card */ | |
1015 | struct list_head codec_dev_list; | |
1016 | struct list_head platform_dev_list; | |
1017 | struct list_head dai_dev_list; | |
a6052154 | 1018 | |
97c866de | 1019 | struct list_head widgets; |
8ddab3f5 | 1020 | struct list_head paths; |
7be31be8 | 1021 | struct list_head dapm_list; |
db432b41 | 1022 | struct list_head dapm_dirty; |
8ddab3f5 | 1023 | |
e37a4970 MB |
1024 | /* Generic DAPM context for the card */ |
1025 | struct snd_soc_dapm_context dapm; | |
de02d078 | 1026 | struct snd_soc_dapm_stats dapm_stats; |
564c6504 | 1027 | struct snd_soc_dapm_update *update; |
e37a4970 | 1028 | |
a6052154 JN |
1029 | #ifdef CONFIG_DEBUG_FS |
1030 | struct dentry *debugfs_card_root; | |
3a45b867 | 1031 | struct dentry *debugfs_pop_time; |
a6052154 | 1032 | #endif |
3a45b867 | 1033 | u32 pop_time; |
dddf3e4c MB |
1034 | |
1035 | void *drvdata; | |
808db4a4 RP |
1036 | }; |
1037 | ||
f0fba2ad | 1038 | /* SoC machine DAI configuration, glues a codec and cpu DAI together */ |
d66a327d | 1039 | struct snd_soc_pcm_runtime { |
36ae1a96 | 1040 | struct device *dev; |
87506549 | 1041 | struct snd_soc_card *card; |
f0fba2ad | 1042 | struct snd_soc_dai_link *dai_link; |
b8c0dab9 LG |
1043 | struct mutex pcm_mutex; |
1044 | enum snd_soc_pcm_subclass pcm_subclass; | |
1045 | struct snd_pcm_ops ops; | |
f0fba2ad | 1046 | |
f0fba2ad | 1047 | unsigned int dev_registered:1; |
808db4a4 | 1048 | |
01d7584c LG |
1049 | /* Dynamic PCM BE runtime data */ |
1050 | struct snd_soc_dpcm_runtime dpcm[2]; | |
2a99ef0f | 1051 | int fe_compr; |
01d7584c | 1052 | |
f0fba2ad | 1053 | long pmdown_time; |
9bffb1fb | 1054 | unsigned char pop_wait:1; |
f0fba2ad LG |
1055 | |
1056 | /* runtime devices */ | |
1057 | struct snd_pcm *pcm; | |
49681077 | 1058 | struct snd_compr *compr; |
f0fba2ad LG |
1059 | struct snd_soc_codec *codec; |
1060 | struct snd_soc_platform *platform; | |
1061 | struct snd_soc_dai *codec_dai; | |
1062 | struct snd_soc_dai *cpu_dai; | |
1063 | ||
1064 | struct delayed_work delayed_work; | |
f86dcef8 LG |
1065 | #ifdef CONFIG_DEBUG_FS |
1066 | struct dentry *debugfs_dpcm_root; | |
1067 | struct dentry *debugfs_dpcm_state; | |
1068 | #endif | |
808db4a4 RP |
1069 | }; |
1070 | ||
4eaa9819 JS |
1071 | /* mixer control */ |
1072 | struct soc_mixer_control { | |
d11bb4a9 | 1073 | int min, max, platform_max; |
249ce138 LPC |
1074 | int reg, rreg; |
1075 | unsigned int shift, rshift; | |
f227b88f | 1076 | unsigned int sign_bit; |
57295073 LPC |
1077 | unsigned int invert:1; |
1078 | unsigned int autodisable:1; | |
4eaa9819 JS |
1079 | }; |
1080 | ||
71d08516 MB |
1081 | struct soc_bytes { |
1082 | int base; | |
1083 | int num_regs; | |
f831b055 | 1084 | u32 mask; |
71d08516 MB |
1085 | }; |
1086 | ||
4183eed2 KK |
1087 | /* multi register control */ |
1088 | struct soc_mreg_control { | |
1089 | long min, max; | |
1090 | unsigned int regbase, regcount, nbits, invert; | |
1091 | }; | |
1092 | ||
808db4a4 RP |
1093 | /* enumerated kcontrol */ |
1094 | struct soc_enum { | |
2e72f8e3 | 1095 | unsigned short reg; |
2e72f8e3 PU |
1096 | unsigned char shift_l; |
1097 | unsigned char shift_r; | |
9a8d38db | 1098 | unsigned int items; |
2e72f8e3 | 1099 | unsigned int mask; |
87023ff7 | 1100 | const char * const *texts; |
2e72f8e3 | 1101 | const unsigned int *values; |
2e72f8e3 PU |
1102 | }; |
1103 | ||
5c82f567 | 1104 | /* codec IO */ |
c3753707 MB |
1105 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); |
1106 | unsigned int snd_soc_write(struct snd_soc_codec *codec, | |
1107 | unsigned int reg, unsigned int val); | |
5c82f567 | 1108 | |
f0fba2ad LG |
1109 | /* device driver data */ |
1110 | ||
dddf3e4c MB |
1111 | static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card, |
1112 | void *data) | |
1113 | { | |
1114 | card->drvdata = data; | |
1115 | } | |
1116 | ||
1117 | static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card) | |
1118 | { | |
1119 | return card->drvdata; | |
1120 | } | |
1121 | ||
b2c812e2 | 1122 | static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, |
f0fba2ad | 1123 | void *data) |
b2c812e2 | 1124 | { |
f0fba2ad | 1125 | dev_set_drvdata(codec->dev, data); |
b2c812e2 MB |
1126 | } |
1127 | ||
1128 | static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec) | |
1129 | { | |
f0fba2ad LG |
1130 | return dev_get_drvdata(codec->dev); |
1131 | } | |
1132 | ||
1133 | static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform, | |
1134 | void *data) | |
1135 | { | |
1136 | dev_set_drvdata(platform->dev, data); | |
1137 | } | |
1138 | ||
1139 | static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform) | |
1140 | { | |
1141 | return dev_get_drvdata(platform->dev); | |
1142 | } | |
1143 | ||
1144 | static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd, | |
1145 | void *data) | |
1146 | { | |
36ae1a96 | 1147 | dev_set_drvdata(rtd->dev, data); |
f0fba2ad LG |
1148 | } |
1149 | ||
1150 | static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd) | |
1151 | { | |
36ae1a96 | 1152 | return dev_get_drvdata(rtd->dev); |
b2c812e2 MB |
1153 | } |
1154 | ||
4e10bda0 VK |
1155 | static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) |
1156 | { | |
1157 | INIT_LIST_HEAD(&card->dai_dev_list); | |
1158 | INIT_LIST_HEAD(&card->codec_dev_list); | |
1159 | INIT_LIST_HEAD(&card->platform_dev_list); | |
1160 | INIT_LIST_HEAD(&card->widgets); | |
1161 | INIT_LIST_HEAD(&card->paths); | |
1162 | INIT_LIST_HEAD(&card->dapm_list); | |
1163 | } | |
1164 | ||
30d86ba4 PU |
1165 | static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc) |
1166 | { | |
1167 | if (mc->reg == mc->rreg && mc->shift == mc->rshift) | |
1168 | return 0; | |
1169 | /* | |
1170 | * mc->reg == mc->rreg && mc->shift != mc->rshift, or | |
1171 | * mc->reg != mc->rreg means that the control is | |
1172 | * stereo (bits in one register or in two registers) | |
1173 | */ | |
1174 | return 1; | |
1175 | } | |
1176 | ||
29ae2fa5 LPC |
1177 | static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e, |
1178 | unsigned int val) | |
1179 | { | |
1180 | unsigned int i; | |
1181 | ||
1182 | if (!e->values) | |
1183 | return val; | |
1184 | ||
1185 | for (i = 0; i < e->items; i++) | |
1186 | if (val == e->values[i]) | |
1187 | return i; | |
1188 | ||
1189 | return 0; | |
1190 | } | |
1191 | ||
1192 | static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e, | |
1193 | unsigned int item) | |
1194 | { | |
1195 | if (!e->values) | |
1196 | return item; | |
1197 | ||
1198 | return e->values[item]; | |
1199 | } | |
1200 | ||
fb257897 MB |
1201 | int snd_soc_util_init(void); |
1202 | void snd_soc_util_exit(void); | |
1203 | ||
bec4fa05 SW |
1204 | int snd_soc_of_parse_card_name(struct snd_soc_card *card, |
1205 | const char *propname); | |
a4a54dd5 SW |
1206 | int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, |
1207 | const char *propname); | |
a7930ed4 KM |
1208 | unsigned int snd_soc_of_parse_daifmt(struct device_node *np, |
1209 | const char *prefix); | |
cb470087 KM |
1210 | int snd_soc_of_get_dai_name(struct device_node *of_node, |
1211 | const char **dai_name); | |
bec4fa05 | 1212 | |
a47cbe72 MB |
1213 | #include <sound/soc-dai.h> |
1214 | ||
faff4bb0 | 1215 | #ifdef CONFIG_DEBUG_FS |
8a9dab1a | 1216 | extern struct dentry *snd_soc_debugfs_root; |
faff4bb0 SW |
1217 | #endif |
1218 | ||
6f8ab4ac MB |
1219 | extern const struct dev_pm_ops snd_soc_pm_ops; |
1220 | ||
f6d5e586 CK |
1221 | /* Helper functions */ |
1222 | static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm) | |
1223 | { | |
1224 | mutex_lock(&dapm->card->dapm_mutex); | |
1225 | } | |
1226 | ||
1227 | static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm) | |
1228 | { | |
1229 | mutex_unlock(&dapm->card->dapm_mutex); | |
1230 | } | |
1231 | ||
808db4a4 | 1232 | #endif |