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