904d69429087c6b6ae88bb2f17607d18ffed48ab
[sfrench/cifs-2.6.git] / include / sound / soc.h
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/of.h>
17 #include <linux/platform_device.h>
18 #include <linux/types.h>
19 #include <linux/notifier.h>
20 #include <linux/workqueue.h>
21 #include <linux/interrupt.h>
22 #include <linux/kernel.h>
23 #include <linux/regmap.h>
24 #include <linux/log2.h>
25 #include <sound/core.h>
26 #include <sound/pcm.h>
27 #include <sound/compress_driver.h>
28 #include <sound/control.h>
29 #include <sound/ac97_codec.h>
30 #include <sound/soc-topology.h>
31
32 /*
33  * Convenience kcontrol builders
34  */
35 #define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert, xautodisable) \
36         ((unsigned long)&(struct soc_mixer_control) \
37         {.reg = xreg, .rreg = xreg, .shift = shift_left, \
38         .rshift = shift_right, .max = xmax, .platform_max = xmax, \
39         .invert = xinvert, .autodisable = xautodisable})
40 #define SOC_DOUBLE_S_VALUE(xreg, shift_left, shift_right, xmin, xmax, xsign_bit, xinvert, xautodisable) \
41         ((unsigned long)&(struct soc_mixer_control) \
42         {.reg = xreg, .rreg = xreg, .shift = shift_left, \
43         .rshift = shift_right, .min = xmin, .max = xmax, .platform_max = xmax, \
44         .sign_bit = xsign_bit, .invert = xinvert, .autodisable = xautodisable})
45 #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, xautodisable) \
46         SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert, xautodisable)
47 #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
48         ((unsigned long)&(struct soc_mixer_control) \
49         {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert})
50 #define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
51         ((unsigned long)&(struct soc_mixer_control) \
52         {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
53         .max = xmax, .platform_max = xmax, .invert = xinvert})
54 #define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
55         ((unsigned long)&(struct soc_mixer_control) \
56         {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
57         .max = xmax, .min = xmin, .platform_max = xmax, .sign_bit = xsign_bit, \
58         .invert = xinvert})
59 #define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
60         ((unsigned long)&(struct soc_mixer_control) \
61         {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
62         .min = xmin, .max = xmax, .platform_max = xmax, .invert = xinvert})
63 #define SOC_SINGLE(xname, reg, shift, max, invert) \
64 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
65         .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
66         .put = snd_soc_put_volsw, \
67         .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
68 #define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
69 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
70         .info = snd_soc_info_volsw_range, .get = snd_soc_get_volsw_range, \
71         .put = snd_soc_put_volsw_range, \
72         .private_value = (unsigned long)&(struct soc_mixer_control) \
73                 {.reg = xreg, .rreg = xreg, .shift = xshift, \
74                  .rshift = xshift,  .min = xmin, .max = xmax, \
75                  .platform_max = xmax, .invert = xinvert} }
76 #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
77 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
78         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
79                  SNDRV_CTL_ELEM_ACCESS_READWRITE,\
80         .tlv.p = (tlv_array), \
81         .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
82         .put = snd_soc_put_volsw, \
83         .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
84 #define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
85 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
86         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
87         SNDRV_CTL_ELEM_ACCESS_READWRITE, \
88         .tlv.p  = (tlv_array),\
89         .info = snd_soc_info_volsw_sx, \
90         .get = snd_soc_get_volsw_sx,\
91         .put = snd_soc_put_volsw_sx, \
92         .private_value = (unsigned long)&(struct soc_mixer_control) \
93                 {.reg = xreg, .rreg = xreg, \
94                 .shift = xshift, .rshift = xshift, \
95                 .max = xmax, .min = xmin} }
96 #define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \
97 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
98         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
99                  SNDRV_CTL_ELEM_ACCESS_READWRITE,\
100         .tlv.p = (tlv_array), \
101         .info = snd_soc_info_volsw_range, \
102         .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
103         .private_value = (unsigned long)&(struct soc_mixer_control) \
104                 {.reg = xreg, .rreg = xreg, .shift = xshift, \
105                  .rshift = xshift, .min = xmin, .max = xmax, \
106                  .platform_max = xmax, .invert = xinvert} }
107 #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
108 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
109         .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
110         .put = snd_soc_put_volsw, \
111         .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
112                                           max, invert, 0) }
113 #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
114 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
115         .info = snd_soc_info_volsw, \
116         .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
117         .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
118                                             xmax, xinvert) }
119 #define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \
120                            xmax, xinvert)               \
121 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
122         .info = snd_soc_info_volsw_range, \
123         .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
124         .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
125                                             xshift, xmin, xmax, xinvert) }
126 #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
127 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
128         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
129                  SNDRV_CTL_ELEM_ACCESS_READWRITE,\
130         .tlv.p = (tlv_array), \
131         .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
132         .put = snd_soc_put_volsw, \
133         .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
134                                           max, invert, 0) }
135 #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
136 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
137         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
138                  SNDRV_CTL_ELEM_ACCESS_READWRITE,\
139         .tlv.p = (tlv_array), \
140         .info = snd_soc_info_volsw, \
141         .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
142         .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
143                                             xmax, xinvert) }
144 #define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \
145                                xmax, xinvert, tlv_array)                \
146 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
147         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
148                  SNDRV_CTL_ELEM_ACCESS_READWRITE,\
149         .tlv.p = (tlv_array), \
150         .info = snd_soc_info_volsw_range, \
151         .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
152         .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
153                                             xshift, xmin, xmax, xinvert) }
154 #define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
155 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
156         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
157         SNDRV_CTL_ELEM_ACCESS_READWRITE, \
158         .tlv.p  = (tlv_array), \
159         .info = snd_soc_info_volsw_sx, \
160         .get = snd_soc_get_volsw_sx, \
161         .put = snd_soc_put_volsw_sx, \
162         .private_value = (unsigned long)&(struct soc_mixer_control) \
163                 {.reg = xreg, .rreg = xrreg, \
164                 .shift = xshift, .rshift = xshift, \
165                 .max = xmax, .min = xmin} }
166 #define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
167 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
168         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
169                  SNDRV_CTL_ELEM_ACCESS_READWRITE,\
170         .tlv.p = (tlv_array), \
171         .info = snd_soc_info_volsw, \
172         .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
173         .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
174                                             xmin, xmax, xsign_bit, xinvert) }
175 #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
176 {       .iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
177         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
178                   SNDRV_CTL_ELEM_ACCESS_READWRITE, \
179         .tlv.p  = (tlv_array), \
180         .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
181         .put = snd_soc_put_volsw, \
182         .private_value = SOC_DOUBLE_S_VALUE(xreg, 0, 8, xmin, xmax, 7, 0, 0) }
183 #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
184 {       .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
185         .items = xitems, .texts = xtexts, \
186         .mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
187 #define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
188         SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
189 #define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
190 {       .items = xitems, .texts = xtexts }
191 #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
192 {       .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
193         .mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
194 #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
195         SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xitems, xtexts, xvalues)
196 #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
197 {       .reg = xreg, .shift_l = xshift, .shift_r = xshift, \
198         .mask = xmask, .items = xitems, .texts = xtexts, \
199         .values = xvalues, .autodisable = 1}
200 #define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
201         SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
202 #define SOC_ENUM(xname, xenum) \
203 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
204         .info = snd_soc_info_enum_double, \
205         .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
206         .private_value = (unsigned long)&xenum }
207 #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
208          xhandler_get, xhandler_put) \
209 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
210         .info = snd_soc_info_volsw, \
211         .get = xhandler_get, .put = xhandler_put, \
212         .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
213 #define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
214          xhandler_get, xhandler_put) \
215 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
216         .info = snd_soc_info_volsw, \
217         .get = xhandler_get, .put = xhandler_put, \
218         .private_value = \
219                 SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) }
220 #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
221          xhandler_get, xhandler_put, tlv_array) \
222 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
223         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
224                  SNDRV_CTL_ELEM_ACCESS_READWRITE,\
225         .tlv.p = (tlv_array), \
226         .info = snd_soc_info_volsw, \
227         .get = xhandler_get, .put = xhandler_put, \
228         .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
229 #define SOC_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
230                                  xhandler_get, xhandler_put, tlv_array) \
231 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
232         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
233                  SNDRV_CTL_ELEM_ACCESS_READWRITE,\
234         .tlv.p = (tlv_array), \
235         .info = snd_soc_info_volsw_range, \
236         .get = xhandler_get, .put = xhandler_put, \
237         .private_value = (unsigned long)&(struct soc_mixer_control) \
238                 {.reg = xreg, .rreg = xreg, .shift = xshift, \
239                  .rshift = xshift, .min = xmin, .max = xmax, \
240                  .platform_max = xmax, .invert = xinvert} }
241 #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
242          xhandler_get, xhandler_put, tlv_array) \
243 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
244         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
245                  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
246         .tlv.p = (tlv_array), \
247         .info = snd_soc_info_volsw, \
248         .get = xhandler_get, .put = xhandler_put, \
249         .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
250                                           xmax, xinvert, 0) }
251 #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
252          xhandler_get, xhandler_put, tlv_array) \
253 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
254         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
255                  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
256         .tlv.p = (tlv_array), \
257         .info = snd_soc_info_volsw, \
258         .get = xhandler_get, .put = xhandler_put, \
259         .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
260                                             xmax, xinvert) }
261 #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
262 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
263         .info = snd_soc_info_bool_ext, \
264         .get = xhandler_get, .put = xhandler_put, \
265         .private_value = xdata }
266 #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
267 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
268         .info = snd_soc_info_enum_double, \
269         .get = xhandler_get, .put = xhandler_put, \
270         .private_value = (unsigned long)&xenum }
271 #define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
272         SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put)
273
274 #define SND_SOC_BYTES(xname, xbase, xregs)                    \
275 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
276         .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
277         .put = snd_soc_bytes_put, .private_value =            \
278                 ((unsigned long)&(struct soc_bytes)           \
279                 {.base = xbase, .num_regs = xregs }) }
280
281 #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask)        \
282 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
283         .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
284         .put = snd_soc_bytes_put, .private_value =            \
285                 ((unsigned long)&(struct soc_bytes)           \
286                 {.base = xbase, .num_regs = xregs,            \
287                  .mask = xmask }) }
288
289 #define SND_SOC_BYTES_EXT(xname, xcount, xhandler_get, xhandler_put) \
290 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
291         .info = snd_soc_bytes_info_ext, \
292         .get = xhandler_get, .put = xhandler_put, \
293         .private_value = (unsigned long)&(struct soc_bytes_ext) \
294                 {.max = xcount} }
295 #define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \
296 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
297         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \
298                   SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
299         .tlv.c = (snd_soc_bytes_tlv_callback), \
300         .info = snd_soc_bytes_info_ext, \
301         .private_value = (unsigned long)&(struct soc_bytes_ext) \
302                 {.max = xcount, .get = xhandler_get, .put = xhandler_put, } }
303 #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
304                 xmin, xmax, xinvert) \
305 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
306         .info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
307         .put = snd_soc_put_xr_sx, \
308         .private_value = (unsigned long)&(struct soc_mreg_control) \
309                 {.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
310                 .invert = xinvert, .min = xmin, .max = xmax} }
311
312 #define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
313         SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
314                 snd_soc_get_strobe, snd_soc_put_strobe)
315
316 /*
317  * Simplified versions of above macros, declaring a struct and calculating
318  * ARRAY_SIZE internally
319  */
320 #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
321         const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
322                                                 ARRAY_SIZE(xtexts), xtexts)
323 #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
324         SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
325 #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
326         const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
327 #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
328         const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
329                                                         ARRAY_SIZE(xtexts), xtexts, xvalues)
330 #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
331         SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
332
333 #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
334         const struct soc_enum name = SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, \
335                 xshift, xmask, ARRAY_SIZE(xtexts), xtexts, xvalues)
336
337 #define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
338         const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
339
340 /*
341  * Component probe and remove ordering levels for components with runtime
342  * dependencies.
343  */
344 #define SND_SOC_COMP_ORDER_FIRST                -2
345 #define SND_SOC_COMP_ORDER_EARLY                -1
346 #define SND_SOC_COMP_ORDER_NORMAL               0
347 #define SND_SOC_COMP_ORDER_LATE         1
348 #define SND_SOC_COMP_ORDER_LAST         2
349
350 /*
351  * Bias levels
352  *
353  * @ON:      Bias is fully on for audio playback and capture operations.
354  * @PREPARE: Prepare for audio operations. Called before DAPM switching for
355  *           stream start and stop operations.
356  * @STANDBY: Low power standby state when no playback/capture operations are
357  *           in progress. NOTE: The transition time between STANDBY and ON
358  *           should be as fast as possible and no longer than 10ms.
359  * @OFF:     Power Off. No restrictions on transition times.
360  */
361 enum snd_soc_bias_level {
362         SND_SOC_BIAS_OFF = 0,
363         SND_SOC_BIAS_STANDBY = 1,
364         SND_SOC_BIAS_PREPARE = 2,
365         SND_SOC_BIAS_ON = 3,
366 };
367
368 struct device_node;
369 struct snd_jack;
370 struct snd_soc_card;
371 struct snd_soc_pcm_stream;
372 struct snd_soc_ops;
373 struct snd_soc_pcm_runtime;
374 struct snd_soc_dai;
375 struct snd_soc_dai_driver;
376 struct snd_soc_platform;
377 struct snd_soc_dai_link;
378 struct snd_soc_platform_driver;
379 struct snd_soc_codec;
380 struct snd_soc_codec_driver;
381 struct snd_soc_component;
382 struct snd_soc_component_driver;
383 struct soc_enum;
384 struct snd_soc_jack;
385 struct snd_soc_jack_zone;
386 struct snd_soc_jack_pin;
387 #include <sound/soc-dapm.h>
388 #include <sound/soc-dpcm.h>
389
390 struct snd_soc_jack_gpio;
391
392 typedef int (*hw_write_t)(void *,const char* ,int);
393
394 enum snd_soc_pcm_subclass {
395         SND_SOC_PCM_CLASS_PCM   = 0,
396         SND_SOC_PCM_CLASS_BE    = 1,
397 };
398
399 enum snd_soc_card_subclass {
400         SND_SOC_CARD_CLASS_INIT         = 0,
401         SND_SOC_CARD_CLASS_RUNTIME      = 1,
402 };
403
404 int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
405                              int source, unsigned int freq, int dir);
406 int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
407                           unsigned int freq_in, unsigned int freq_out);
408
409 int snd_soc_register_card(struct snd_soc_card *card);
410 int snd_soc_unregister_card(struct snd_soc_card *card);
411 int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
412 #ifdef CONFIG_PM_SLEEP
413 int snd_soc_suspend(struct device *dev);
414 int snd_soc_resume(struct device *dev);
415 #else
416 static inline int snd_soc_suspend(struct device *dev)
417 {
418         return 0;
419 }
420
421 static inline int snd_soc_resume(struct device *dev)
422 {
423         return 0;
424 }
425 #endif
426 int snd_soc_poweroff(struct device *dev);
427 int snd_soc_register_platform(struct device *dev,
428                 const struct snd_soc_platform_driver *platform_drv);
429 int devm_snd_soc_register_platform(struct device *dev,
430                 const struct snd_soc_platform_driver *platform_drv);
431 void snd_soc_unregister_platform(struct device *dev);
432 int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
433                 const struct snd_soc_platform_driver *platform_drv);
434 void snd_soc_remove_platform(struct snd_soc_platform *platform);
435 struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev);
436 int snd_soc_register_codec(struct device *dev,
437                 const struct snd_soc_codec_driver *codec_drv,
438                 struct snd_soc_dai_driver *dai_drv, int num_dai);
439 void snd_soc_unregister_codec(struct device *dev);
440 int snd_soc_register_component(struct device *dev,
441                          const struct snd_soc_component_driver *cmpnt_drv,
442                          struct snd_soc_dai_driver *dai_drv, int num_dai);
443 int devm_snd_soc_register_component(struct device *dev,
444                          const struct snd_soc_component_driver *cmpnt_drv,
445                          struct snd_soc_dai_driver *dai_drv, int num_dai);
446 void snd_soc_unregister_component(struct device *dev);
447 int snd_soc_cache_init(struct snd_soc_codec *codec);
448 int snd_soc_cache_exit(struct snd_soc_codec *codec);
449
450 int snd_soc_platform_read(struct snd_soc_platform *platform,
451                                         unsigned int reg);
452 int snd_soc_platform_write(struct snd_soc_platform *platform,
453                                         unsigned int reg, unsigned int val);
454 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
455 #ifdef CONFIG_SND_SOC_COMPRESS
456 int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
457 #endif
458
459 struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
460                 const char *dai_link, int stream);
461 struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
462                 const char *dai_link);
463
464 bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
465 void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream);
466 void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream);
467
468 int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
469         unsigned int dai_fmt);
470
471 /* Utility functions to get clock rates from various things */
472 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
473 int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
474 int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
475 int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
476
477 /* set runtime hw params */
478 int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
479         const struct snd_pcm_hardware *hw);
480
481 int snd_soc_platform_trigger(struct snd_pcm_substream *substream,
482                 int cmd, struct snd_soc_platform *platform);
483
484 int soc_dai_hw_params(struct snd_pcm_substream *substream,
485                       struct snd_pcm_hw_params *params,
486                       struct snd_soc_dai *dai);
487
488 /* Jack reporting */
489 int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
490         struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins,
491         unsigned int num_pins);
492
493 void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
494 int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
495                           struct snd_soc_jack_pin *pins);
496 void snd_soc_jack_notifier_register(struct snd_soc_jack *jack,
497                                     struct notifier_block *nb);
498 void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
499                                       struct notifier_block *nb);
500 int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count,
501                           struct snd_soc_jack_zone *zones);
502 int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage);
503 #ifdef CONFIG_GPIOLIB
504 int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
505                         struct snd_soc_jack_gpio *gpios);
506 int snd_soc_jack_add_gpiods(struct device *gpiod_dev,
507                             struct snd_soc_jack *jack,
508                             int count, struct snd_soc_jack_gpio *gpios);
509 void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
510                         struct snd_soc_jack_gpio *gpios);
511 #else
512 static inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
513                                          struct snd_soc_jack_gpio *gpios)
514 {
515         return 0;
516 }
517
518 static inline int snd_soc_jack_add_gpiods(struct device *gpiod_dev,
519                                           struct snd_soc_jack *jack,
520                                           int count,
521                                           struct snd_soc_jack_gpio *gpios)
522 {
523         return 0;
524 }
525
526 static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
527                                            struct snd_soc_jack_gpio *gpios)
528 {
529 }
530 #endif
531
532 /* codec register bit access */
533 int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg,
534                                 unsigned int mask, unsigned int value);
535 int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
536                                unsigned int reg, unsigned int mask,
537                                unsigned int value);
538 int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg,
539                                 unsigned int mask, unsigned int value);
540
541 #ifdef CONFIG_SND_SOC_AC97_BUS
542 struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec);
543 struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
544         unsigned int id, unsigned int id_mask);
545 void snd_soc_free_ac97_codec(struct snd_ac97 *ac97);
546
547 int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
548 int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
549                 struct platform_device *pdev);
550
551 extern struct snd_ac97_bus_ops *soc_ac97_ops;
552 #else
553 static inline int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
554         struct platform_device *pdev)
555 {
556         return 0;
557 }
558
559 static inline int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
560 {
561         return 0;
562 }
563 #endif
564
565 /*
566  *Controls
567  */
568 struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
569                                   void *data, const char *long_name,
570                                   const char *prefix);
571 struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
572                                                const char *name);
573 int snd_soc_add_component_controls(struct snd_soc_component *component,
574         const struct snd_kcontrol_new *controls, unsigned int num_controls);
575 int snd_soc_add_codec_controls(struct snd_soc_codec *codec,
576         const struct snd_kcontrol_new *controls, unsigned int num_controls);
577 int snd_soc_add_platform_controls(struct snd_soc_platform *platform,
578         const struct snd_kcontrol_new *controls, unsigned int num_controls);
579 int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
580         const struct snd_kcontrol_new *controls, int num_controls);
581 int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
582         const struct snd_kcontrol_new *controls, int num_controls);
583 int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
584         struct snd_ctl_elem_info *uinfo);
585 int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
586         struct snd_ctl_elem_value *ucontrol);
587 int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
588         struct snd_ctl_elem_value *ucontrol);
589 int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
590         struct snd_ctl_elem_info *uinfo);
591 int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
592                           struct snd_ctl_elem_info *uinfo);
593 #define snd_soc_info_bool_ext           snd_ctl_boolean_mono_info
594 int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
595         struct snd_ctl_elem_value *ucontrol);
596 int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
597         struct snd_ctl_elem_value *ucontrol);
598 #define snd_soc_get_volsw_2r snd_soc_get_volsw
599 #define snd_soc_put_volsw_2r snd_soc_put_volsw
600 int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
601         struct snd_ctl_elem_value *ucontrol);
602 int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
603         struct snd_ctl_elem_value *ucontrol);
604 int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
605         struct snd_ctl_elem_info *uinfo);
606 int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
607         struct snd_ctl_elem_value *ucontrol);
608 int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
609         struct snd_ctl_elem_value *ucontrol);
610 int snd_soc_limit_volume(struct snd_soc_card *card,
611         const char *name, int max);
612 int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
613                        struct snd_ctl_elem_info *uinfo);
614 int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
615                       struct snd_ctl_elem_value *ucontrol);
616 int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
617                       struct snd_ctl_elem_value *ucontrol);
618 int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
619         struct snd_ctl_elem_info *ucontrol);
620 int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
621         unsigned int size, unsigned int __user *tlv);
622 int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
623         struct snd_ctl_elem_info *uinfo);
624 int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
625         struct snd_ctl_elem_value *ucontrol);
626 int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
627         struct snd_ctl_elem_value *ucontrol);
628 int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
629         struct snd_ctl_elem_value *ucontrol);
630 int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
631         struct snd_ctl_elem_value *ucontrol);
632
633 /**
634  * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
635  *
636  * @pin:    name of the pin to update
637  * @mask:   bits to check for in reported jack status
638  * @invert: if non-zero then pin is enabled when status is not reported
639  * @list:   internal list entry
640  */
641 struct snd_soc_jack_pin {
642         struct list_head list;
643         const char *pin;
644         int mask;
645         bool invert;
646 };
647
648 /**
649  * struct snd_soc_jack_zone - Describes voltage zones of jack detection
650  *
651  * @min_mv: start voltage in mv
652  * @max_mv: end voltage in mv
653  * @jack_type: type of jack that is expected for this voltage
654  * @debounce_time: debounce_time for jack, codec driver should wait for this
655  *              duration before reading the adc for voltages
656  * @list:   internal list entry
657  */
658 struct snd_soc_jack_zone {
659         unsigned int min_mv;
660         unsigned int max_mv;
661         unsigned int jack_type;
662         unsigned int debounce_time;
663         struct list_head list;
664 };
665
666 /**
667  * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection
668  *
669  * @gpio:         legacy gpio number
670  * @idx:          gpio descriptor index within the function of the GPIO
671  *                consumer device
672  * @gpiod_dev:    GPIO consumer device
673  * @name:         gpio name. Also as connection ID for the GPIO consumer
674  *                device function name lookup
675  * @report:       value to report when jack detected
676  * @invert:       report presence in low state
677  * @debounce_time: debounce time in ms
678  * @wake:         enable as wake source
679  * @jack_status_check: callback function which overrides the detection
680  *                     to provide more complex checks (eg, reading an
681  *                     ADC).
682  */
683 struct snd_soc_jack_gpio {
684         unsigned int gpio;
685         unsigned int idx;
686         struct device *gpiod_dev;
687         const char *name;
688         int report;
689         int invert;
690         int debounce_time;
691         bool wake;
692
693         /* private: */
694         struct snd_soc_jack *jack;
695         struct delayed_work work;
696         struct gpio_desc *desc;
697
698         void *data;
699         /* public: */
700         int (*jack_status_check)(void *data);
701 };
702
703 struct snd_soc_jack {
704         struct mutex mutex;
705         struct snd_jack *jack;
706         struct snd_soc_card *card;
707         struct list_head pins;
708         int status;
709         struct blocking_notifier_head notifier;
710         struct list_head jack_zones;
711 };
712
713 /* SoC PCM stream information */
714 struct snd_soc_pcm_stream {
715         const char *stream_name;
716         u64 formats;                    /* SNDRV_PCM_FMTBIT_* */
717         unsigned int rates;             /* SNDRV_PCM_RATE_* */
718         unsigned int rate_min;          /* min rate */
719         unsigned int rate_max;          /* max rate */
720         unsigned int channels_min;      /* min channels */
721         unsigned int channels_max;      /* max channels */
722         unsigned int sig_bits;          /* number of bits of content */
723 };
724
725 /* SoC audio ops */
726 struct snd_soc_ops {
727         int (*startup)(struct snd_pcm_substream *);
728         void (*shutdown)(struct snd_pcm_substream *);
729         int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
730         int (*hw_free)(struct snd_pcm_substream *);
731         int (*prepare)(struct snd_pcm_substream *);
732         int (*trigger)(struct snd_pcm_substream *, int);
733 };
734
735 struct snd_soc_compr_ops {
736         int (*startup)(struct snd_compr_stream *);
737         void (*shutdown)(struct snd_compr_stream *);
738         int (*set_params)(struct snd_compr_stream *);
739         int (*trigger)(struct snd_compr_stream *);
740 };
741
742 /* component interface */
743 struct snd_soc_component_driver {
744         const char *name;
745
746         /* Default control and setup, added after probe() is run */
747         const struct snd_kcontrol_new *controls;
748         unsigned int num_controls;
749         const struct snd_soc_dapm_widget *dapm_widgets;
750         unsigned int num_dapm_widgets;
751         const struct snd_soc_dapm_route *dapm_routes;
752         unsigned int num_dapm_routes;
753
754         int (*probe)(struct snd_soc_component *);
755         void (*remove)(struct snd_soc_component *);
756
757         /* DT */
758         int (*of_xlate_dai_name)(struct snd_soc_component *component,
759                                  struct of_phandle_args *args,
760                                  const char **dai_name);
761         void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type,
762                 int subseq);
763         int (*stream_event)(struct snd_soc_component *, int event);
764
765         /* probe ordering - for components with runtime dependencies */
766         int probe_order;
767         int remove_order;
768 };
769
770 struct snd_soc_component {
771         const char *name;
772         int id;
773         const char *name_prefix;
774         struct device *dev;
775         struct snd_soc_card *card;
776
777         unsigned int active;
778
779         unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
780         unsigned int registered_as_component:1;
781
782         struct list_head list;
783
784         struct snd_soc_dai_driver *dai_drv;
785         int num_dai;
786
787         const struct snd_soc_component_driver *driver;
788
789         struct list_head dai_list;
790
791         int (*read)(struct snd_soc_component *, unsigned int, unsigned int *);
792         int (*write)(struct snd_soc_component *, unsigned int, unsigned int);
793
794         struct regmap *regmap;
795         int val_bytes;
796
797         struct mutex io_mutex;
798
799         /* attached dynamic objects */
800         struct list_head dobj_list;
801
802 #ifdef CONFIG_DEBUG_FS
803         struct dentry *debugfs_root;
804 #endif
805
806         /*
807         * DO NOT use any of the fields below in drivers, they are temporary and
808         * are going to be removed again soon. If you use them in driver code the
809         * driver will be marked as BROKEN when these fields are removed.
810         */
811
812         /* Don't use these, use snd_soc_component_get_dapm() */
813         struct snd_soc_dapm_context dapm;
814
815         const struct snd_kcontrol_new *controls;
816         unsigned int num_controls;
817         const struct snd_soc_dapm_widget *dapm_widgets;
818         unsigned int num_dapm_widgets;
819         const struct snd_soc_dapm_route *dapm_routes;
820         unsigned int num_dapm_routes;
821         struct snd_soc_codec *codec;
822
823         int (*probe)(struct snd_soc_component *);
824         void (*remove)(struct snd_soc_component *);
825
826 #ifdef CONFIG_DEBUG_FS
827         void (*init_debugfs)(struct snd_soc_component *component);
828         const char *debugfs_prefix;
829 #endif
830 };
831
832 /* SoC Audio Codec device */
833 struct snd_soc_codec {
834         struct device *dev;
835         const struct snd_soc_codec_driver *driver;
836
837         struct list_head list;
838         struct list_head card_list;
839
840         /* runtime */
841         unsigned int cache_bypass:1; /* Suppress access to the cache */
842         unsigned int suspended:1; /* Codec is in suspend PM state */
843         unsigned int cache_init:1; /* codec cache has been initialized */
844
845         /* codec IO */
846         void *control_data; /* codec control (i2c/3wire) data */
847         hw_write_t hw_write;
848         void *reg_cache;
849
850         /* component */
851         struct snd_soc_component component;
852
853 #ifdef CONFIG_DEBUG_FS
854         struct dentry *debugfs_reg;
855 #endif
856 };
857
858 /* codec driver */
859 struct snd_soc_codec_driver {
860
861         /* driver ops */
862         int (*probe)(struct snd_soc_codec *);
863         int (*remove)(struct snd_soc_codec *);
864         int (*suspend)(struct snd_soc_codec *);
865         int (*resume)(struct snd_soc_codec *);
866         struct snd_soc_component_driver component_driver;
867
868         /* Default control and setup, added after probe() is run */
869         const struct snd_kcontrol_new *controls;
870         int num_controls;
871         const struct snd_soc_dapm_widget *dapm_widgets;
872         int num_dapm_widgets;
873         const struct snd_soc_dapm_route *dapm_routes;
874         int num_dapm_routes;
875
876         /* codec wide operations */
877         int (*set_sysclk)(struct snd_soc_codec *codec,
878                           int clk_id, int source, unsigned int freq, int dir);
879         int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source,
880                 unsigned int freq_in, unsigned int freq_out);
881
882         /* codec IO */
883         struct regmap *(*get_regmap)(struct device *);
884         unsigned int (*read)(struct snd_soc_codec *, unsigned int);
885         int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
886         unsigned int reg_cache_size;
887         short reg_cache_step;
888         short reg_word_size;
889         const void *reg_cache_default;
890
891         /* codec bias level */
892         int (*set_bias_level)(struct snd_soc_codec *,
893                               enum snd_soc_bias_level level);
894         bool idle_bias_off;
895         bool suspend_bias_off;
896
897         void (*seq_notifier)(struct snd_soc_dapm_context *,
898                              enum snd_soc_dapm_type, int);
899
900         bool ignore_pmdown_time;  /* Doesn't benefit from pmdown delay */
901 };
902
903 /* SoC platform interface */
904 struct snd_soc_platform_driver {
905
906         int (*probe)(struct snd_soc_platform *);
907         int (*remove)(struct snd_soc_platform *);
908         struct snd_soc_component_driver component_driver;
909
910         /* pcm creation and destruction */
911         int (*pcm_new)(struct snd_soc_pcm_runtime *);
912         void (*pcm_free)(struct snd_pcm *);
913
914         /*
915          * For platform caused delay reporting.
916          * Optional.
917          */
918         snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
919                 struct snd_soc_dai *);
920
921         /* platform stream pcm ops */
922         const struct snd_pcm_ops *ops;
923
924         /* platform stream compress ops */
925         const struct snd_compr_ops *compr_ops;
926
927         int (*bespoke_trigger)(struct snd_pcm_substream *, int);
928 };
929
930 struct snd_soc_dai_link_component {
931         const char *name;
932         struct device_node *of_node;
933         const char *dai_name;
934 };
935
936 struct snd_soc_platform {
937         struct device *dev;
938         const struct snd_soc_platform_driver *driver;
939
940         struct list_head list;
941
942         struct snd_soc_component component;
943 };
944
945 struct snd_soc_dai_link {
946         /* config - must be set by machine driver */
947         const char *name;                       /* Codec name */
948         const char *stream_name;                /* Stream name */
949         /*
950          * You MAY specify the link's CPU-side device, either by device name,
951          * or by DT/OF node, but not both. If this information is omitted,
952          * the CPU-side DAI is matched using .cpu_dai_name only, which hence
953          * must be globally unique. These fields are currently typically used
954          * only for codec to codec links, or systems using device tree.
955          */
956         const char *cpu_name;
957         struct device_node *cpu_of_node;
958         /*
959          * You MAY specify the DAI name of the CPU DAI. If this information is
960          * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
961          * only, which only works well when that device exposes a single DAI.
962          */
963         const char *cpu_dai_name;
964         /*
965          * You MUST specify the link's codec, either by device name, or by
966          * DT/OF node, but not both.
967          */
968         const char *codec_name;
969         struct device_node *codec_of_node;
970         /* You MUST specify the DAI name within the codec */
971         const char *codec_dai_name;
972
973         struct snd_soc_dai_link_component *codecs;
974         unsigned int num_codecs;
975
976         /*
977          * You MAY specify the link's platform/PCM/DMA driver, either by
978          * device name, or by DT/OF node, but not both. Some forms of link
979          * do not need a platform.
980          */
981         const char *platform_name;
982         struct device_node *platform_of_node;
983         int be_id;      /* optional ID for machine driver BE identification */
984
985         const struct snd_soc_pcm_stream *params;
986         unsigned int num_params;
987
988         unsigned int dai_fmt;           /* format to set on init */
989
990         enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
991
992         /* codec/machine specific init - e.g. add machine controls */
993         int (*init)(struct snd_soc_pcm_runtime *rtd);
994
995         /* optional hw_params re-writing for BE and FE sync */
996         int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
997                         struct snd_pcm_hw_params *params);
998
999         /* machine stream operations */
1000         const struct snd_soc_ops *ops;
1001         const struct snd_soc_compr_ops *compr_ops;
1002
1003         /* For unidirectional dai links */
1004         bool playback_only;
1005         bool capture_only;
1006
1007         /* Mark this pcm with non atomic ops */
1008         bool nonatomic;
1009
1010         /* Keep DAI active over suspend */
1011         unsigned int ignore_suspend:1;
1012
1013         /* Symmetry requirements */
1014         unsigned int symmetric_rates:1;
1015         unsigned int symmetric_channels:1;
1016         unsigned int symmetric_samplebits:1;
1017
1018         /* Do not create a PCM for this DAI link (Backend link) */
1019         unsigned int no_pcm:1;
1020
1021         /* This DAI link can route to other DAI links at runtime (Frontend)*/
1022         unsigned int dynamic:1;
1023
1024         /* DPCM capture and Playback support */
1025         unsigned int dpcm_capture:1;
1026         unsigned int dpcm_playback:1;
1027
1028         /* DPCM used FE & BE merged format */
1029         unsigned int dpcm_merged_format:1;
1030
1031         /* pmdown_time is ignored at stop */
1032         unsigned int ignore_pmdown_time:1;
1033 };
1034
1035 struct snd_soc_codec_conf {
1036         /*
1037          * specify device either by device name, or by
1038          * DT/OF node, but not both.
1039          */
1040         const char *dev_name;
1041         struct device_node *of_node;
1042
1043         /*
1044          * optional map of kcontrol, widget and path name prefixes that are
1045          * associated per device
1046          */
1047         const char *name_prefix;
1048 };
1049
1050 struct snd_soc_aux_dev {
1051         const char *name;               /* Codec name */
1052
1053         /*
1054          * specify multi-codec either by device name, or by
1055          * DT/OF node, but not both.
1056          */
1057         const char *codec_name;
1058         struct device_node *codec_of_node;
1059
1060         /* codec/machine specific init - e.g. add machine controls */
1061         int (*init)(struct snd_soc_component *component);
1062 };
1063
1064 /* SoC card */
1065 struct snd_soc_card {
1066         const char *name;
1067         const char *long_name;
1068         const char *driver_name;
1069         struct device *dev;
1070         struct snd_card *snd_card;
1071         struct module *owner;
1072
1073         struct mutex mutex;
1074         struct mutex dapm_mutex;
1075
1076         bool instantiated;
1077
1078         int (*probe)(struct snd_soc_card *card);
1079         int (*late_probe)(struct snd_soc_card *card);
1080         int (*remove)(struct snd_soc_card *card);
1081
1082         /* the pre and post PM functions are used to do any PM work before and
1083          * after the codec and DAI's do any PM work. */
1084         int (*suspend_pre)(struct snd_soc_card *card);
1085         int (*suspend_post)(struct snd_soc_card *card);
1086         int (*resume_pre)(struct snd_soc_card *card);
1087         int (*resume_post)(struct snd_soc_card *card);
1088
1089         /* callbacks */
1090         int (*set_bias_level)(struct snd_soc_card *,
1091                               struct snd_soc_dapm_context *dapm,
1092                               enum snd_soc_bias_level level);
1093         int (*set_bias_level_post)(struct snd_soc_card *,
1094                                    struct snd_soc_dapm_context *dapm,
1095                                    enum snd_soc_bias_level level);
1096
1097         long pmdown_time;
1098
1099         /* CPU <--> Codec DAI links  */
1100         struct snd_soc_dai_link *dai_link;
1101         int num_links;
1102         struct snd_soc_pcm_runtime *rtd;
1103         int num_rtd;
1104
1105         /* optional codec specific configuration */
1106         struct snd_soc_codec_conf *codec_conf;
1107         int num_configs;
1108
1109         /*
1110          * optional auxiliary devices such as amplifiers or codecs with DAI
1111          * link unused
1112          */
1113         struct snd_soc_aux_dev *aux_dev;
1114         int num_aux_devs;
1115         struct snd_soc_pcm_runtime *rtd_aux;
1116         int num_aux_rtd;
1117
1118         const struct snd_kcontrol_new *controls;
1119         int num_controls;
1120
1121         /*
1122          * Card-specific routes and widgets.
1123          * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
1124          */
1125         const struct snd_soc_dapm_widget *dapm_widgets;
1126         int num_dapm_widgets;
1127         const struct snd_soc_dapm_route *dapm_routes;
1128         int num_dapm_routes;
1129         const struct snd_soc_dapm_widget *of_dapm_widgets;
1130         int num_of_dapm_widgets;
1131         const struct snd_soc_dapm_route *of_dapm_routes;
1132         int num_of_dapm_routes;
1133         bool fully_routed;
1134
1135         struct work_struct deferred_resume_work;
1136
1137         /* lists of probed devices belonging to this card */
1138         struct list_head codec_dev_list;
1139
1140         struct list_head widgets;
1141         struct list_head paths;
1142         struct list_head dapm_list;
1143         struct list_head dapm_dirty;
1144
1145         /* attached dynamic objects */
1146         struct list_head dobj_list;
1147
1148         /* Generic DAPM context for the card */
1149         struct snd_soc_dapm_context dapm;
1150         struct snd_soc_dapm_stats dapm_stats;
1151         struct snd_soc_dapm_update *update;
1152
1153 #ifdef CONFIG_DEBUG_FS
1154         struct dentry *debugfs_card_root;
1155         struct dentry *debugfs_pop_time;
1156 #endif
1157         u32 pop_time;
1158
1159         void *drvdata;
1160 };
1161
1162 /* SoC machine DAI configuration, glues a codec and cpu DAI together */
1163 struct snd_soc_pcm_runtime {
1164         struct device *dev;
1165         struct snd_soc_card *card;
1166         struct snd_soc_dai_link *dai_link;
1167         struct mutex pcm_mutex;
1168         enum snd_soc_pcm_subclass pcm_subclass;
1169         struct snd_pcm_ops ops;
1170
1171         unsigned int dev_registered:1;
1172
1173         /* Dynamic PCM BE runtime data */
1174         struct snd_soc_dpcm_runtime dpcm[2];
1175         int fe_compr;
1176
1177         long pmdown_time;
1178         unsigned char pop_wait:1;
1179
1180         /* runtime devices */
1181         struct snd_pcm *pcm;
1182         struct snd_compr *compr;
1183         struct snd_soc_codec *codec;
1184         struct snd_soc_platform *platform;
1185         struct snd_soc_dai *codec_dai;
1186         struct snd_soc_dai *cpu_dai;
1187         struct snd_soc_component *component; /* Only valid for AUX dev rtds */
1188
1189         struct snd_soc_dai **codec_dais;
1190         unsigned int num_codecs;
1191
1192         struct delayed_work delayed_work;
1193 #ifdef CONFIG_DEBUG_FS
1194         struct dentry *debugfs_dpcm_root;
1195         struct dentry *debugfs_dpcm_state;
1196 #endif
1197 };
1198
1199 /* mixer control */
1200 struct soc_mixer_control {
1201         int min, max, platform_max;
1202         int reg, rreg;
1203         unsigned int shift, rshift;
1204         unsigned int sign_bit;
1205         unsigned int invert:1;
1206         unsigned int autodisable:1;
1207         struct snd_soc_dobj dobj;
1208 };
1209
1210 struct soc_bytes {
1211         int base;
1212         int num_regs;
1213         u32 mask;
1214 };
1215
1216 struct soc_bytes_ext {
1217         int max;
1218         struct snd_soc_dobj dobj;
1219
1220         /* used for TLV byte control */
1221         int (*get)(unsigned int __user *bytes, unsigned int size);
1222         int (*put)(const unsigned int __user *bytes, unsigned int size);
1223 };
1224
1225 /* multi register control */
1226 struct soc_mreg_control {
1227         long min, max;
1228         unsigned int regbase, regcount, nbits, invert;
1229 };
1230
1231 /* enumerated kcontrol */
1232 struct soc_enum {
1233         int reg;
1234         unsigned char shift_l;
1235         unsigned char shift_r;
1236         unsigned int items;
1237         unsigned int mask;
1238         const char * const *texts;
1239         const unsigned int *values;
1240         unsigned int autodisable:1;
1241         struct snd_soc_dobj dobj;
1242 };
1243
1244 /**
1245  * snd_soc_component_to_codec() - Casts a component to the CODEC it is embedded in
1246  * @component: The component to cast to a CODEC
1247  *
1248  * This function must only be used on components that are known to be CODECs.
1249  * Otherwise the behavior is undefined.
1250  */
1251 static inline struct snd_soc_codec *snd_soc_component_to_codec(
1252         struct snd_soc_component *component)
1253 {
1254         return container_of(component, struct snd_soc_codec, component);
1255 }
1256
1257 /**
1258  * snd_soc_component_to_platform() - Casts a component to the platform it is embedded in
1259  * @component: The component to cast to a platform
1260  *
1261  * This function must only be used on components that are known to be platforms.
1262  * Otherwise the behavior is undefined.
1263  */
1264 static inline struct snd_soc_platform *snd_soc_component_to_platform(
1265         struct snd_soc_component *component)
1266 {
1267         return container_of(component, struct snd_soc_platform, component);
1268 }
1269
1270 /**
1271  * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
1272  *  embedded in
1273  * @dapm: The DAPM context to cast to the component
1274  *
1275  * This function must only be used on DAPM contexts that are known to be part of
1276  * a component (e.g. in a component driver). Otherwise the behavior is
1277  * undefined.
1278  */
1279 static inline struct snd_soc_component *snd_soc_dapm_to_component(
1280         struct snd_soc_dapm_context *dapm)
1281 {
1282         return container_of(dapm, struct snd_soc_component, dapm);
1283 }
1284
1285 /**
1286  * snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in
1287  * @dapm: The DAPM context to cast to the CODEC
1288  *
1289  * This function must only be used on DAPM contexts that are known to be part of
1290  * a CODEC (e.g. in a CODEC driver). Otherwise the behavior is undefined.
1291  */
1292 static inline struct snd_soc_codec *snd_soc_dapm_to_codec(
1293         struct snd_soc_dapm_context *dapm)
1294 {
1295         return snd_soc_component_to_codec(snd_soc_dapm_to_component(dapm));
1296 }
1297
1298 /**
1299  * snd_soc_dapm_to_platform() - Casts a DAPM context to the platform it is
1300  *  embedded in
1301  * @dapm: The DAPM context to cast to the platform.
1302  *
1303  * This function must only be used on DAPM contexts that are known to be part of
1304  * a platform (e.g. in a platform driver). Otherwise the behavior is undefined.
1305  */
1306 static inline struct snd_soc_platform *snd_soc_dapm_to_platform(
1307         struct snd_soc_dapm_context *dapm)
1308 {
1309         return snd_soc_component_to_platform(snd_soc_dapm_to_component(dapm));
1310 }
1311
1312 /**
1313  * snd_soc_component_get_dapm() - Returns the DAPM context associated with a
1314  *  component
1315  * @component: The component for which to get the DAPM context
1316  */
1317 static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
1318         struct snd_soc_component *component)
1319 {
1320         return &component->dapm;
1321 }
1322
1323 /**
1324  * snd_soc_codec_get_dapm() - Returns the DAPM context for the CODEC
1325  * @codec: The CODEC for which to get the DAPM context
1326  *
1327  * Note: Use this function instead of directly accessing the CODEC's dapm field
1328  */
1329 static inline struct snd_soc_dapm_context *snd_soc_codec_get_dapm(
1330         struct snd_soc_codec *codec)
1331 {
1332         return snd_soc_component_get_dapm(&codec->component);
1333 }
1334
1335 /**
1336  * snd_soc_dapm_init_bias_level() - Initialize CODEC DAPM bias level
1337  * @codec: The CODEC for which to initialize the DAPM bias level
1338  * @level: The DAPM level to initialize to
1339  *
1340  * Initializes the CODEC DAPM bias level. See snd_soc_dapm_init_bias_level().
1341  */
1342 static inline void snd_soc_codec_init_bias_level(struct snd_soc_codec *codec,
1343         enum snd_soc_bias_level level)
1344 {
1345         snd_soc_dapm_init_bias_level(snd_soc_codec_get_dapm(codec), level);
1346 }
1347
1348 /**
1349  * snd_soc_dapm_get_bias_level() - Get current CODEC DAPM bias level
1350  * @codec: The CODEC for which to get the DAPM bias level
1351  *
1352  * Returns: The current DAPM bias level of the CODEC.
1353  */
1354 static inline enum snd_soc_bias_level snd_soc_codec_get_bias_level(
1355         struct snd_soc_codec *codec)
1356 {
1357         return snd_soc_dapm_get_bias_level(snd_soc_codec_get_dapm(codec));
1358 }
1359
1360 /**
1361  * snd_soc_codec_force_bias_level() - Set the CODEC DAPM bias level
1362  * @codec: The CODEC for which to set the level
1363  * @level: The level to set to
1364  *
1365  * Forces the CODEC bias level to a specific state. See
1366  * snd_soc_dapm_force_bias_level().
1367  */
1368 static inline int snd_soc_codec_force_bias_level(struct snd_soc_codec *codec,
1369         enum snd_soc_bias_level level)
1370 {
1371         return snd_soc_dapm_force_bias_level(snd_soc_codec_get_dapm(codec),
1372                 level);
1373 }
1374
1375 /**
1376  * snd_soc_dapm_kcontrol_codec() - Returns the codec associated to a kcontrol
1377  * @kcontrol: The kcontrol
1378  *
1379  * This function must only be used on DAPM contexts that are known to be part of
1380  * a CODEC (e.g. in a CODEC driver). Otherwise the behavior is undefined.
1381  */
1382 static inline struct snd_soc_codec *snd_soc_dapm_kcontrol_codec(
1383         struct snd_kcontrol *kcontrol)
1384 {
1385         return snd_soc_dapm_to_codec(snd_soc_dapm_kcontrol_dapm(kcontrol));
1386 }
1387
1388 /* codec IO */
1389 unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
1390 int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
1391         unsigned int val);
1392
1393 /**
1394  * snd_soc_cache_sync() - Sync the register cache with the hardware
1395  * @codec: CODEC to sync
1396  *
1397  * Note: This function will call regcache_sync()
1398  */
1399 static inline int snd_soc_cache_sync(struct snd_soc_codec *codec)
1400 {
1401         return regcache_sync(codec->component.regmap);
1402 }
1403
1404 /* component IO */
1405 int snd_soc_component_read(struct snd_soc_component *component,
1406         unsigned int reg, unsigned int *val);
1407 int snd_soc_component_write(struct snd_soc_component *component,
1408         unsigned int reg, unsigned int val);
1409 int snd_soc_component_update_bits(struct snd_soc_component *component,
1410         unsigned int reg, unsigned int mask, unsigned int val);
1411 int snd_soc_component_update_bits_async(struct snd_soc_component *component,
1412         unsigned int reg, unsigned int mask, unsigned int val);
1413 void snd_soc_component_async_complete(struct snd_soc_component *component);
1414 int snd_soc_component_test_bits(struct snd_soc_component *component,
1415         unsigned int reg, unsigned int mask, unsigned int value);
1416
1417 #ifdef CONFIG_REGMAP
1418
1419 void snd_soc_component_init_regmap(struct snd_soc_component *component,
1420         struct regmap *regmap);
1421 void snd_soc_component_exit_regmap(struct snd_soc_component *component);
1422
1423 /**
1424  * snd_soc_codec_init_regmap() - Initialize regmap instance for the CODEC
1425  * @codec: The CODEC for which to initialize the regmap instance
1426  * @regmap: The regmap instance that should be used by the CODEC
1427  *
1428  * This function allows deferred assignment of the regmap instance that is
1429  * associated with the CODEC. Only use this if the regmap instance is not yet
1430  * ready when the CODEC is registered. The function must also be called before
1431  * the first IO attempt of the CODEC.
1432  */
1433 static inline void snd_soc_codec_init_regmap(struct snd_soc_codec *codec,
1434         struct regmap *regmap)
1435 {
1436         snd_soc_component_init_regmap(&codec->component, regmap);
1437 }
1438
1439 /**
1440  * snd_soc_codec_exit_regmap() - De-initialize regmap instance for the CODEC
1441  * @codec: The CODEC for which to de-initialize the regmap instance
1442  *
1443  * Calls regmap_exit() on the regmap instance associated to the CODEC and
1444  * removes the regmap instance from the CODEC.
1445  *
1446  * This function should only be used if snd_soc_codec_init_regmap() was used to
1447  * initialize the regmap instance.
1448  */
1449 static inline void snd_soc_codec_exit_regmap(struct snd_soc_codec *codec)
1450 {
1451         snd_soc_component_exit_regmap(&codec->component);
1452 }
1453
1454 #endif
1455
1456 /* device driver data */
1457
1458 static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
1459                 void *data)
1460 {
1461         card->drvdata = data;
1462 }
1463
1464 static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
1465 {
1466         return card->drvdata;
1467 }
1468
1469 static inline void snd_soc_component_set_drvdata(struct snd_soc_component *c,
1470                 void *data)
1471 {
1472         dev_set_drvdata(c->dev, data);
1473 }
1474
1475 static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c)
1476 {
1477         return dev_get_drvdata(c->dev);
1478 }
1479
1480 static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
1481                 void *data)
1482 {
1483         snd_soc_component_set_drvdata(&codec->component, data);
1484 }
1485
1486 static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec)
1487 {
1488         return snd_soc_component_get_drvdata(&codec->component);
1489 }
1490
1491 static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform,
1492                 void *data)
1493 {
1494         snd_soc_component_set_drvdata(&platform->component, data);
1495 }
1496
1497 static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform)
1498 {
1499         return snd_soc_component_get_drvdata(&platform->component);
1500 }
1501
1502 static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd,
1503                 void *data)
1504 {
1505         dev_set_drvdata(rtd->dev, data);
1506 }
1507
1508 static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd)
1509 {
1510         return dev_get_drvdata(rtd->dev);
1511 }
1512
1513 static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
1514 {
1515         INIT_LIST_HEAD(&card->codec_dev_list);
1516         INIT_LIST_HEAD(&card->widgets);
1517         INIT_LIST_HEAD(&card->paths);
1518         INIT_LIST_HEAD(&card->dapm_list);
1519 }
1520
1521 static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
1522 {
1523         if (mc->reg == mc->rreg && mc->shift == mc->rshift)
1524                 return 0;
1525         /*
1526          * mc->reg == mc->rreg && mc->shift != mc->rshift, or
1527          * mc->reg != mc->rreg means that the control is
1528          * stereo (bits in one register or in two registers)
1529          */
1530         return 1;
1531 }
1532
1533 static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
1534         unsigned int val)
1535 {
1536         unsigned int i;
1537
1538         if (!e->values)
1539                 return val;
1540
1541         for (i = 0; i < e->items; i++)
1542                 if (val == e->values[i])
1543                         return i;
1544
1545         return 0;
1546 }
1547
1548 static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
1549         unsigned int item)
1550 {
1551         if (!e->values)
1552                 return item;
1553
1554         return e->values[item];
1555 }
1556
1557 static inline bool snd_soc_component_is_active(
1558         struct snd_soc_component *component)
1559 {
1560         return component->active != 0;
1561 }
1562
1563 static inline bool snd_soc_codec_is_active(struct snd_soc_codec *codec)
1564 {
1565         return snd_soc_component_is_active(&codec->component);
1566 }
1567
1568 /**
1569  * snd_soc_kcontrol_component() - Returns the component that registered the
1570  *  control
1571  * @kcontrol: The control for which to get the component
1572  *
1573  * Note: This function will work correctly if the control has been registered
1574  * for a component. Either with snd_soc_add_codec_controls() or
1575  * snd_soc_add_platform_controls() or via  table based setup for either a
1576  * CODEC, a platform or component driver. Otherwise the behavior is undefined.
1577  */
1578 static inline struct snd_soc_component *snd_soc_kcontrol_component(
1579         struct snd_kcontrol *kcontrol)
1580 {
1581         return snd_kcontrol_chip(kcontrol);
1582 }
1583
1584 /**
1585  * snd_soc_kcontrol_codec() - Returns the CODEC that registered the control
1586  * @kcontrol: The control for which to get the CODEC
1587  *
1588  * Note: This function will only work correctly if the control has been
1589  * registered with snd_soc_add_codec_controls() or via table based setup of
1590  * snd_soc_codec_driver. Otherwise the behavior is undefined.
1591  */
1592 static inline struct snd_soc_codec *snd_soc_kcontrol_codec(
1593         struct snd_kcontrol *kcontrol)
1594 {
1595         return snd_soc_component_to_codec(snd_soc_kcontrol_component(kcontrol));
1596 }
1597
1598 /**
1599  * snd_soc_kcontrol_platform() - Returns the platform that registered the control
1600  * @kcontrol: The control for which to get the platform
1601  *
1602  * Note: This function will only work correctly if the control has been
1603  * registered with snd_soc_add_platform_controls() or via table based setup of
1604  * a snd_soc_platform_driver. Otherwise the behavior is undefined.
1605  */
1606 static inline struct snd_soc_platform *snd_soc_kcontrol_platform(
1607         struct snd_kcontrol *kcontrol)
1608 {
1609         return snd_soc_component_to_platform(snd_soc_kcontrol_component(kcontrol));
1610 }
1611
1612 int snd_soc_util_init(void);
1613 void snd_soc_util_exit(void);
1614
1615 int snd_soc_of_parse_card_name(struct snd_soc_card *card,
1616                                const char *propname);
1617 int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
1618                                           const char *propname);
1619 int snd_soc_of_parse_tdm_slot(struct device_node *np,
1620                               unsigned int *tx_mask,
1621                               unsigned int *rx_mask,
1622                               unsigned int *slots,
1623                               unsigned int *slot_width);
1624 void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
1625                                    struct snd_soc_codec_conf *codec_conf,
1626                                    struct device_node *of_node,
1627                                    const char *propname);
1628 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
1629                                    const char *propname);
1630 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
1631                                      const char *prefix,
1632                                      struct device_node **bitclkmaster,
1633                                      struct device_node **framemaster);
1634 int snd_soc_of_get_dai_name(struct device_node *of_node,
1635                             const char **dai_name);
1636 int snd_soc_of_get_dai_link_codecs(struct device *dev,
1637                                    struct device_node *of_node,
1638                                    struct snd_soc_dai_link *dai_link);
1639
1640 #include <sound/soc-dai.h>
1641
1642 #ifdef CONFIG_DEBUG_FS
1643 extern struct dentry *snd_soc_debugfs_root;
1644 #endif
1645
1646 extern const struct dev_pm_ops snd_soc_pm_ops;
1647
1648 /* Helper functions */
1649 static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm)
1650 {
1651         mutex_lock(&dapm->card->dapm_mutex);
1652 }
1653
1654 static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
1655 {
1656         mutex_unlock(&dapm->card->dapm_mutex);
1657 }
1658
1659 #endif