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