• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0
2  *
3  * linux/sound/soc.h -- ALSA SoC Layer
4  *
5  * Author:	Liam Girdwood
6  * Created:	Aug 11th 2005
7  * Copyright:	Wolfson Microelectronics. PLC.
8  */
9 
10 #ifndef __LINUX_SND_SOC_H
11 #define __LINUX_SND_SOC_H
12 
13 #include <linux/of.h>
14 #include <linux/platform_device.h>
15 #include <linux/types.h>
16 #include <linux/notifier.h>
17 #include <linux/workqueue.h>
18 #include <linux/interrupt.h>
19 #include <linux/kernel.h>
20 #include <linux/regmap.h>
21 #include <linux/log2.h>
22 #include <linux/android_kabi.h>
23 #include <sound/core.h>
24 #include <sound/pcm.h>
25 #include <sound/compress_driver.h>
26 #include <sound/control.h>
27 #include <sound/ac97_codec.h>
28 
29 /*
30  * Convenience kcontrol builders
31  */
32 #define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert, xautodisable) \
33 	((unsigned long)&(struct soc_mixer_control) \
34 	{.reg = xreg, .rreg = xreg, .shift = shift_left, \
35 	.rshift = shift_right, .max = xmax, .platform_max = xmax, \
36 	.invert = xinvert, .autodisable = xautodisable})
37 #define SOC_DOUBLE_S_VALUE(xreg, shift_left, shift_right, xmin, xmax, xsign_bit, xinvert, xautodisable) \
38 	((unsigned long)&(struct soc_mixer_control) \
39 	{.reg = xreg, .rreg = xreg, .shift = shift_left, \
40 	.rshift = shift_right, .min = xmin, .max = xmax, .platform_max = xmax, \
41 	.sign_bit = xsign_bit, .invert = xinvert, .autodisable = xautodisable})
42 #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, xautodisable) \
43 	SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert, xautodisable)
44 #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
45 	((unsigned long)&(struct soc_mixer_control) \
46 	{.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert})
47 #define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
48 	((unsigned long)&(struct soc_mixer_control) \
49 	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
50 	.max = xmax, .platform_max = xmax, .invert = xinvert})
51 #define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
52 	((unsigned long)&(struct soc_mixer_control) \
53 	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
54 	.max = xmax, .min = xmin, .platform_max = xmax, .sign_bit = xsign_bit, \
55 	.invert = xinvert})
56 #define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
57 	((unsigned long)&(struct soc_mixer_control) \
58 	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
59 	.min = xmin, .max = xmax, .platform_max = xmax, .invert = xinvert})
60 #define SOC_SINGLE(xname, reg, shift, max, invert) \
61 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
62 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
63 	.put = snd_soc_put_volsw, \
64 	.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
65 #define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
66 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
67 	.info = snd_soc_info_volsw_range, .get = snd_soc_get_volsw_range, \
68 	.put = snd_soc_put_volsw_range, \
69 	.private_value = (unsigned long)&(struct soc_mixer_control) \
70 		{.reg = xreg, .rreg = xreg, .shift = xshift, \
71 		 .rshift = xshift,  .min = xmin, .max = xmax, \
72 		 .platform_max = xmax, .invert = xinvert} }
73 #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
74 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
75 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
76 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
77 	.tlv.p = (tlv_array), \
78 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
79 	.put = snd_soc_put_volsw, \
80 	.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
81 #define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
82 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
83 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
84 	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
85 	.tlv.p  = (tlv_array),\
86 	.info = snd_soc_info_volsw_sx, \
87 	.get = snd_soc_get_volsw_sx,\
88 	.put = snd_soc_put_volsw_sx, \
89 	.private_value = (unsigned long)&(struct soc_mixer_control) \
90 		{.reg = xreg, .rreg = xreg, \
91 		.shift = xshift, .rshift = xshift, \
92 		.max = xmax, .min = xmin} }
93 #define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \
94 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
95 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
96 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
97 	.tlv.p = (tlv_array), \
98 	.info = snd_soc_info_volsw_range, \
99 	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
100 	.private_value = (unsigned long)&(struct soc_mixer_control) \
101 		{.reg = xreg, .rreg = xreg, .shift = xshift, \
102 		 .rshift = xshift, .min = xmin, .max = xmax, \
103 		 .platform_max = xmax, .invert = xinvert} }
104 #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
105 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
106 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
107 	.put = snd_soc_put_volsw, \
108 	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
109 					  max, invert, 0) }
110 #define SOC_DOUBLE_STS(xname, reg, shift_left, shift_right, max, invert) \
111 {									\
112 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),		\
113 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,		\
114 	.access = SNDRV_CTL_ELEM_ACCESS_READ |				\
115 		SNDRV_CTL_ELEM_ACCESS_VOLATILE,				\
116 	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right,	\
117 					  max, invert, 0) }
118 #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
119 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
120 	.info = snd_soc_info_volsw, \
121 	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
122 	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
123 					    xmax, xinvert) }
124 #define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \
125 			   xmax, xinvert)		\
126 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
127 	.info = snd_soc_info_volsw_range, \
128 	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
129 	.private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
130 					    xshift, xmin, xmax, xinvert) }
131 #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
132 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
133 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
134 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
135 	.tlv.p = (tlv_array), \
136 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
137 	.put = snd_soc_put_volsw, \
138 	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
139 					  max, invert, 0) }
140 #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
141 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
142 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
143 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
144 	.tlv.p = (tlv_array), \
145 	.info = snd_soc_info_volsw, \
146 	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
147 	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
148 					    xmax, xinvert) }
149 #define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \
150 			       xmax, xinvert, tlv_array)		\
151 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
152 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
153 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
154 	.tlv.p = (tlv_array), \
155 	.info = snd_soc_info_volsw_range, \
156 	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
157 	.private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
158 					    xshift, xmin, xmax, xinvert) }
159 #define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
160 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
161 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
162 	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
163 	.tlv.p  = (tlv_array), \
164 	.info = snd_soc_info_volsw_sx, \
165 	.get = snd_soc_get_volsw_sx, \
166 	.put = snd_soc_put_volsw_sx, \
167 	.private_value = (unsigned long)&(struct soc_mixer_control) \
168 		{.reg = xreg, .rreg = xrreg, \
169 		.shift = xshift, .rshift = xshift, \
170 		.max = xmax, .min = xmin} }
171 #define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
172 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
173 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
174 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
175 	.tlv.p = (tlv_array), \
176 	.info = snd_soc_info_volsw, \
177 	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
178 	.private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
179 					    xmin, xmax, xsign_bit, xinvert) }
180 #define SOC_SINGLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
181 {	.iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
182 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
183 		  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
184 	.tlv.p  = (tlv_array), \
185 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
186 	.put = snd_soc_put_volsw, \
187 	.private_value = (unsigned long)&(struct soc_mixer_control) \
188 	{.reg = xreg, .rreg = xreg,  \
189 	 .min = xmin, .max = xmax, .platform_max = xmax, \
190 	.sign_bit = 7,} }
191 #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
192 {	.iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
193 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
194 		  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
195 	.tlv.p  = (tlv_array), \
196 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
197 	.put = snd_soc_put_volsw, \
198 	.private_value = SOC_DOUBLE_S_VALUE(xreg, 0, 8, xmin, xmax, 7, 0, 0) }
199 #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
200 {	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
201 	.items = xitems, .texts = xtexts, \
202 	.mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
203 #define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
204 	SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
205 #define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
206 {	.items = xitems, .texts = xtexts }
207 #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
208 {	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
209 	.mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
210 #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
211 	SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xitems, xtexts, xvalues)
212 #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
213 {	.reg = xreg, .shift_l = xshift, .shift_r = xshift, \
214 	.mask = xmask, .items = xitems, .texts = xtexts, \
215 	.values = xvalues, .autodisable = 1}
216 #define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
217 	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
218 #define SOC_ENUM(xname, xenum) \
219 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
220 	.info = snd_soc_info_enum_double, \
221 	.get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
222 	.private_value = (unsigned long)&xenum }
223 #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
224 	 xhandler_get, xhandler_put) \
225 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
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_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
230 	 xhandler_get, xhandler_put) \
231 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
232 	.info = snd_soc_info_volsw, \
233 	.get = xhandler_get, .put = xhandler_put, \
234 	.private_value = \
235 		SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) }
236 #define SOC_DOUBLE_R_EXT(xname, reg_left, reg_right, xshift, xmax, xinvert,\
237 	 xhandler_get, xhandler_put) \
238 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
239 	.info = snd_soc_info_volsw, \
240 	.get = xhandler_get, .put = xhandler_put, \
241 	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
242 					    xmax, xinvert) }
243 #define SOC_SINGLE_MULTI_EXT(xname, xreg, xshift, xmax, xinvert, xcount,\
244 	xhandler_get, xhandler_put) \
245 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
246 	.info = snd_soc_info_multi_ext, \
247 	.get = xhandler_get, .put = xhandler_put, \
248 	.private_value = (unsigned long)&(struct soc_multi_mixer_control) \
249 		{.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \
250 		.count = xcount, .platform_max = xmax, .invert = xinvert} }
251 #define SOC_SINGLE_EXT_TLV(xname, xreg, 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_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
260 #define SOC_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
261 				 xhandler_get, xhandler_put, tlv_array) \
262 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
263 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
264 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
265 	.tlv.p = (tlv_array), \
266 	.info = snd_soc_info_volsw_range, \
267 	.get = xhandler_get, .put = xhandler_put, \
268 	.private_value = (unsigned long)&(struct soc_mixer_control) \
269 		{.reg = xreg, .rreg = xreg, .shift = xshift, \
270 		 .rshift = xshift, .min = xmin, .max = xmax, \
271 		 .platform_max = xmax, .invert = xinvert} }
272 #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
273 	 xhandler_get, xhandler_put, tlv_array) \
274 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
275 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
276 		 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
277 	.tlv.p = (tlv_array), \
278 	.info = snd_soc_info_volsw, \
279 	.get = xhandler_get, .put = xhandler_put, \
280 	.private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
281 					  xmax, xinvert, 0) }
282 #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
283 	 xhandler_get, xhandler_put, tlv_array) \
284 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
285 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
286 		 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
287 	.tlv.p = (tlv_array), \
288 	.info = snd_soc_info_volsw, \
289 	.get = xhandler_get, .put = xhandler_put, \
290 	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
291 					    xmax, xinvert) }
292 #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
293 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
294 	.info = snd_soc_info_bool_ext, \
295 	.get = xhandler_get, .put = xhandler_put, \
296 	.private_value = xdata }
297 #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
298 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
299 	.info = snd_soc_info_enum_double, \
300 	.get = xhandler_get, .put = xhandler_put, \
301 	.private_value = (unsigned long)&xenum }
302 #define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
303 	SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put)
304 
305 #define SND_SOC_BYTES(xname, xbase, xregs)		      \
306 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
307 	.info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
308 	.put = snd_soc_bytes_put, .private_value =	      \
309 		((unsigned long)&(struct soc_bytes)           \
310 		{.base = xbase, .num_regs = xregs }) }
311 #define SND_SOC_BYTES_E(xname, xbase, xregs, xhandler_get, xhandler_put) \
312 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
313 	.info = snd_soc_bytes_info, .get = xhandler_get, \
314 	.put = xhandler_put, .private_value = \
315 		((unsigned long)&(struct soc_bytes) \
316 		{.base = xbase, .num_regs = xregs }) }
317 
318 #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask)	      \
319 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
320 	.info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
321 	.put = snd_soc_bytes_put, .private_value =	      \
322 		((unsigned long)&(struct soc_bytes)           \
323 		{.base = xbase, .num_regs = xregs,	      \
324 		 .mask = xmask }) }
325 
326 /*
327  * SND_SOC_BYTES_EXT is deprecated, please USE SND_SOC_BYTES_TLV instead
328  */
329 #define SND_SOC_BYTES_EXT(xname, xcount, xhandler_get, xhandler_put) \
330 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
331 	.info = snd_soc_bytes_info_ext, \
332 	.get = xhandler_get, .put = xhandler_put, \
333 	.private_value = (unsigned long)&(struct soc_bytes_ext) \
334 		{.max = xcount} }
335 #define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \
336 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
337 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \
338 		  SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
339 	.tlv.c = (snd_soc_bytes_tlv_callback), \
340 	.info = snd_soc_bytes_info_ext, \
341 	.private_value = (unsigned long)&(struct soc_bytes_ext) \
342 		{.max = xcount, .get = xhandler_get, .put = xhandler_put, } }
343 #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
344 		xmin, xmax, xinvert) \
345 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
346 	.info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
347 	.put = snd_soc_put_xr_sx, \
348 	.private_value = (unsigned long)&(struct soc_mreg_control) \
349 		{.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
350 		.invert = xinvert, .min = xmin, .max = xmax} }
351 
352 #define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
353 	SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
354 		snd_soc_get_strobe, snd_soc_put_strobe)
355 
356 /*
357  * Simplified versions of above macros, declaring a struct and calculating
358  * ARRAY_SIZE internally
359  */
360 #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
361 	const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
362 						ARRAY_SIZE(xtexts), xtexts)
363 #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
364 	SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
365 #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
366 	const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
367 #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
368 	const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
369 							ARRAY_SIZE(xtexts), xtexts, xvalues)
370 #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
371 	SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
372 
373 #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
374 	const struct soc_enum name = SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, \
375 		xshift, xmask, ARRAY_SIZE(xtexts), xtexts, xvalues)
376 
377 #define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
378 	const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
379 
380 struct device_node;
381 struct snd_jack;
382 struct snd_soc_card;
383 struct snd_soc_pcm_stream;
384 struct snd_soc_ops;
385 struct snd_soc_pcm_runtime;
386 struct snd_soc_dai;
387 struct snd_soc_dai_driver;
388 struct snd_soc_dai_link;
389 struct snd_soc_component;
390 struct snd_soc_component_driver;
391 struct soc_enum;
392 struct snd_soc_jack;
393 struct snd_soc_jack_zone;
394 struct snd_soc_jack_pin;
395 #include <sound/soc-dapm.h>
396 #include <sound/soc-dpcm.h>
397 #include <sound/soc-topology.h>
398 
399 struct snd_soc_jack_gpio;
400 
401 typedef int (*hw_write_t)(void *,const char* ,int);
402 
403 enum snd_soc_pcm_subclass {
404 	SND_SOC_PCM_CLASS_PCM	= 0,
405 	SND_SOC_PCM_CLASS_BE	= 1,
406 };
407 
408 int snd_soc_register_card(struct snd_soc_card *card);
409 int snd_soc_unregister_card(struct snd_soc_card *card);
410 int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
411 #ifdef CONFIG_PM_SLEEP
412 int snd_soc_suspend(struct device *dev);
413 int snd_soc_resume(struct device *dev);
414 #else
snd_soc_suspend(struct device * dev)415 static inline int snd_soc_suspend(struct device *dev)
416 {
417 	return 0;
418 }
419 
snd_soc_resume(struct device * dev)420 static inline int snd_soc_resume(struct device *dev)
421 {
422 	return 0;
423 }
424 #endif
425 int snd_soc_poweroff(struct device *dev);
426 int snd_soc_component_initialize(struct snd_soc_component *component,
427 				 const struct snd_soc_component_driver *driver,
428 				 struct device *dev);
429 int snd_soc_add_component(struct snd_soc_component *component,
430 			  struct snd_soc_dai_driver *dai_drv,
431 			  int num_dai);
432 int snd_soc_register_component(struct device *dev,
433 			 const struct snd_soc_component_driver *component_driver,
434 			 struct snd_soc_dai_driver *dai_drv, int num_dai);
435 int devm_snd_soc_register_component(struct device *dev,
436 			 const struct snd_soc_component_driver *component_driver,
437 			 struct snd_soc_dai_driver *dai_drv, int num_dai);
438 void snd_soc_unregister_component(struct device *dev);
439 void snd_soc_unregister_component_by_driver(struct device *dev,
440 			 const struct snd_soc_component_driver *component_driver);
441 struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
442 							    const char *driver_name);
443 struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
444 						   const char *driver_name);
445 
446 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
447 #ifdef CONFIG_SND_SOC_COMPRESS
448 int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
449 #else
snd_soc_new_compress(struct snd_soc_pcm_runtime * rtd,int num)450 static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
451 {
452 	return 0;
453 }
454 #endif
455 
456 void snd_soc_disconnect_sync(struct device *dev);
457 
458 struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
459 				struct snd_soc_dai_link *dai_link);
460 
461 bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
462 
463 void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
464 			    int stream, int action);
snd_soc_runtime_activate(struct snd_soc_pcm_runtime * rtd,int stream)465 static inline void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd,
466 				     int stream)
467 {
468 	snd_soc_runtime_action(rtd, stream, 1);
469 }
snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime * rtd,int stream)470 static inline void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd,
471 				       int stream)
472 {
473 	snd_soc_runtime_action(rtd, stream, -1);
474 }
475 
476 int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
477 			    struct snd_pcm_hardware *hw, int stream);
478 
479 int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
480 	unsigned int dai_fmt);
481 
482 #ifdef CONFIG_DMI
483 int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour);
484 #else
snd_soc_set_dmi_name(struct snd_soc_card * card,const char * flavour)485 static inline int snd_soc_set_dmi_name(struct snd_soc_card *card,
486 				       const char *flavour)
487 {
488 	return 0;
489 }
490 #endif
491 
492 /* Utility functions to get clock rates from various things */
493 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
494 int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
495 int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
496 int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
497 
498 /* set runtime hw params */
499 int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
500 	const struct snd_pcm_hardware *hw);
501 
502 /* Jack reporting */
503 void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
504 int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
505 			  struct snd_soc_jack_pin *pins);
506 void snd_soc_jack_notifier_register(struct snd_soc_jack *jack,
507 				    struct notifier_block *nb);
508 void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
509 				      struct notifier_block *nb);
510 int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count,
511 			  struct snd_soc_jack_zone *zones);
512 int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage);
513 #ifdef CONFIG_GPIOLIB
514 int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
515 			struct snd_soc_jack_gpio *gpios);
516 int snd_soc_jack_add_gpiods(struct device *gpiod_dev,
517 			    struct snd_soc_jack *jack,
518 			    int count, struct snd_soc_jack_gpio *gpios);
519 void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
520 			struct snd_soc_jack_gpio *gpios);
521 #else
snd_soc_jack_add_gpios(struct snd_soc_jack * jack,int count,struct snd_soc_jack_gpio * gpios)522 static inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
523 					 struct snd_soc_jack_gpio *gpios)
524 {
525 	return 0;
526 }
527 
snd_soc_jack_add_gpiods(struct device * gpiod_dev,struct snd_soc_jack * jack,int count,struct snd_soc_jack_gpio * gpios)528 static inline int snd_soc_jack_add_gpiods(struct device *gpiod_dev,
529 					  struct snd_soc_jack *jack,
530 					  int count,
531 					  struct snd_soc_jack_gpio *gpios)
532 {
533 	return 0;
534 }
535 
snd_soc_jack_free_gpios(struct snd_soc_jack * jack,int count,struct snd_soc_jack_gpio * gpios)536 static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
537 					   struct snd_soc_jack_gpio *gpios)
538 {
539 }
540 #endif
541 
542 struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
543 struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
544 	unsigned int id, unsigned int id_mask);
545 void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
546 
547 #ifdef CONFIG_SND_SOC_AC97_BUS
548 int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
549 int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
550 		struct platform_device *pdev);
551 
552 extern struct snd_ac97_bus_ops *soc_ac97_ops;
553 #else
snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops * ops,struct platform_device * pdev)554 static inline int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
555 	struct platform_device *pdev)
556 {
557 	return 0;
558 }
559 
snd_soc_set_ac97_ops(struct snd_ac97_bus_ops * ops)560 static inline int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
561 {
562 	return 0;
563 }
564 #endif
565 
566 /*
567  *Controls
568  */
569 struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
570 				  void *data, const char *long_name,
571 				  const char *prefix);
572 int snd_soc_add_component_controls(struct snd_soc_component *component,
573 	const struct snd_kcontrol_new *controls, unsigned int num_controls);
574 int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
575 	const struct snd_kcontrol_new *controls, int num_controls);
576 int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
577 	const struct snd_kcontrol_new *controls, int num_controls);
578 int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
579 	struct snd_ctl_elem_info *uinfo);
580 int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
581 	struct snd_ctl_elem_value *ucontrol);
582 int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
583 	struct snd_ctl_elem_value *ucontrol);
584 int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
585 	struct snd_ctl_elem_info *uinfo);
586 int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
587 			  struct snd_ctl_elem_info *uinfo);
588 #define snd_soc_info_bool_ext		snd_ctl_boolean_mono_info
589 int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
590 	struct snd_ctl_elem_value *ucontrol);
591 int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
592 	struct snd_ctl_elem_value *ucontrol);
593 #define snd_soc_get_volsw_2r snd_soc_get_volsw
594 #define snd_soc_put_volsw_2r snd_soc_put_volsw
595 int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
596 	struct snd_ctl_elem_value *ucontrol);
597 int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
598 	struct snd_ctl_elem_value *ucontrol);
599 int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
600 	struct snd_ctl_elem_info *uinfo);
601 int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
602 	struct snd_ctl_elem_value *ucontrol);
603 int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
604 	struct snd_ctl_elem_value *ucontrol);
605 int snd_soc_limit_volume(struct snd_soc_card *card,
606 	const char *name, int max);
607 int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
608 		       struct snd_ctl_elem_info *uinfo);
609 int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
610 		      struct snd_ctl_elem_value *ucontrol);
611 int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
612 		      struct snd_ctl_elem_value *ucontrol);
613 int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
614 	struct snd_ctl_elem_info *ucontrol);
615 int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
616 	unsigned int size, unsigned int __user *tlv);
617 int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
618 	struct snd_ctl_elem_info *uinfo);
619 int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
620 	struct snd_ctl_elem_value *ucontrol);
621 int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
622 	struct snd_ctl_elem_value *ucontrol);
623 int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
624 	struct snd_ctl_elem_value *ucontrol);
625 int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
626 	struct snd_ctl_elem_value *ucontrol);
627 int snd_soc_info_multi_ext(struct snd_kcontrol *kcontrol,
628 	struct snd_ctl_elem_info *uinfo);
629 
630 /**
631  * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
632  *
633  * @pin:    name of the pin to update
634  * @mask:   bits to check for in reported jack status
635  * @invert: if non-zero then pin is enabled when status is not reported
636  * @list:   internal list entry
637  */
638 struct snd_soc_jack_pin {
639 	struct list_head list;
640 	const char *pin;
641 	int mask;
642 	bool invert;
643 };
644 
645 /**
646  * struct snd_soc_jack_zone - Describes voltage zones of jack detection
647  *
648  * @min_mv: start voltage in mv
649  * @max_mv: end voltage in mv
650  * @jack_type: type of jack that is expected for this voltage
651  * @debounce_time: debounce_time for jack, codec driver should wait for this
652  *		duration before reading the adc for voltages
653  * @list:   internal list entry
654  */
655 struct snd_soc_jack_zone {
656 	unsigned int min_mv;
657 	unsigned int max_mv;
658 	unsigned int jack_type;
659 	unsigned int debounce_time;
660 	struct list_head list;
661 };
662 
663 /**
664  * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection
665  *
666  * @gpio:         legacy gpio number
667  * @idx:          gpio descriptor index within the function of the GPIO
668  *                consumer device
669  * @gpiod_dev:    GPIO consumer device
670  * @name:         gpio name. Also as connection ID for the GPIO consumer
671  *                device function name lookup
672  * @report:       value to report when jack detected
673  * @invert:       report presence in low state
674  * @debounce_time: debounce time in ms
675  * @wake:	  enable as wake source
676  * @jack_status_check: callback function which overrides the detection
677  *		       to provide more complex checks (eg, reading an
678  *		       ADC).
679  */
680 struct snd_soc_jack_gpio {
681 	unsigned int gpio;
682 	unsigned int idx;
683 	struct device *gpiod_dev;
684 	const char *name;
685 	int report;
686 	int invert;
687 	int debounce_time;
688 	bool wake;
689 
690 	/* private: */
691 	struct snd_soc_jack *jack;
692 	struct delayed_work work;
693 	struct notifier_block pm_notifier;
694 	struct gpio_desc *desc;
695 
696 	void *data;
697 	/* public: */
698 	int (*jack_status_check)(void *data);
699 };
700 
701 struct snd_soc_jack {
702 	struct mutex mutex;
703 	struct snd_jack *jack;
704 	struct snd_soc_card *card;
705 	struct list_head pins;
706 	int status;
707 	struct blocking_notifier_head notifier;
708 	struct list_head jack_zones;
709 };
710 
711 /* SoC PCM stream information */
712 struct snd_soc_pcm_stream {
713 	const char *stream_name;
714 	u64 formats;			/* SNDRV_PCM_FMTBIT_* */
715 	unsigned int rates;		/* SNDRV_PCM_RATE_* */
716 	unsigned int rate_min;		/* min rate */
717 	unsigned int rate_max;		/* max rate */
718 	unsigned int channels_min;	/* min channels */
719 	unsigned int channels_max;	/* max channels */
720 	unsigned int sig_bits;		/* number of bits of content */
721 };
722 
723 /* SoC audio ops */
724 struct snd_soc_ops {
725 	int (*startup)(struct snd_pcm_substream *);
726 	void (*shutdown)(struct snd_pcm_substream *);
727 	int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
728 	int (*hw_free)(struct snd_pcm_substream *);
729 	int (*prepare)(struct snd_pcm_substream *);
730 	int (*trigger)(struct snd_pcm_substream *, int);
731 };
732 
733 struct snd_soc_compr_ops {
734 	int (*startup)(struct snd_compr_stream *);
735 	void (*shutdown)(struct snd_compr_stream *);
736 	int (*set_params)(struct snd_compr_stream *);
737 	int (*trigger)(struct snd_compr_stream *);
738 };
739 
740 struct snd_soc_component*
741 snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
742 		       const char *driver_name);
743 
744 struct snd_soc_dai_link_component {
745 	const char *name;
746 	struct device_node *of_node;
747 	const char *dai_name;
748 };
749 
750 struct snd_soc_dai_link {
751 	/* config - must be set by machine driver */
752 	const char *name;			/* Codec name */
753 	const char *stream_name;		/* Stream name */
754 
755 	/*
756 	 * You MAY specify the link's CPU-side device, either by device name,
757 	 * or by DT/OF node, but not both. If this information is omitted,
758 	 * the CPU-side DAI is matched using .cpu_dai_name only, which hence
759 	 * must be globally unique. These fields are currently typically used
760 	 * only for codec to codec links, or systems using device tree.
761 	 */
762 	/*
763 	 * You MAY specify the DAI name of the CPU DAI. If this information is
764 	 * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
765 	 * only, which only works well when that device exposes a single DAI.
766 	 */
767 	struct snd_soc_dai_link_component *cpus;
768 	unsigned int num_cpus;
769 
770 	/*
771 	 * You MUST specify the link's codec, either by device name, or by
772 	 * DT/OF node, but not both.
773 	 */
774 	/* You MUST specify the DAI name within the codec */
775 	struct snd_soc_dai_link_component *codecs;
776 	unsigned int num_codecs;
777 
778 	/*
779 	 * You MAY specify the link's platform/PCM/DMA driver, either by
780 	 * device name, or by DT/OF node, but not both. Some forms of link
781 	 * do not need a platform. In such case, platforms are not mandatory.
782 	 */
783 	struct snd_soc_dai_link_component *platforms;
784 	unsigned int num_platforms;
785 
786 	int id;	/* optional ID for machine driver link identification */
787 
788 	const struct snd_soc_pcm_stream *params;
789 	unsigned int num_params;
790 
791 	unsigned int dai_fmt;           /* format to set on init */
792 
793 	enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
794 
795 	/* codec/machine specific init - e.g. add machine controls */
796 	int (*init)(struct snd_soc_pcm_runtime *rtd);
797 
798 	/* codec/machine specific exit - dual of init() */
799 	void (*exit)(struct snd_soc_pcm_runtime *rtd);
800 
801 	/* optional hw_params re-writing for BE and FE sync */
802 	int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
803 			struct snd_pcm_hw_params *params);
804 
805 	/* machine stream operations */
806 	const struct snd_soc_ops *ops;
807 	const struct snd_soc_compr_ops *compr_ops;
808 
809 	/* Mark this pcm with non atomic ops */
810 	unsigned int nonatomic:1;
811 
812 	/* For unidirectional dai links */
813 	unsigned int playback_only:1;
814 	unsigned int capture_only:1;
815 
816 	/* Keep DAI active over suspend */
817 	unsigned int ignore_suspend:1;
818 
819 	/* Symmetry requirements */
820 	unsigned int symmetric_rates:1;
821 	unsigned int symmetric_channels:1;
822 	unsigned int symmetric_samplebits:1;
823 
824 	/* Do not create a PCM for this DAI link (Backend link) */
825 	unsigned int no_pcm:1;
826 
827 	/* This DAI link can route to other DAI links at runtime (Frontend)*/
828 	unsigned int dynamic:1;
829 
830 	/* DPCM capture and Playback support */
831 	unsigned int dpcm_capture:1;
832 	unsigned int dpcm_playback:1;
833 
834 	/* DPCM used FE & BE merged format */
835 	unsigned int dpcm_merged_format:1;
836 	/* DPCM used FE & BE merged channel */
837 	unsigned int dpcm_merged_chan:1;
838 	/* DPCM used FE & BE merged rate */
839 	unsigned int dpcm_merged_rate:1;
840 
841 	/* pmdown_time is ignored at stop */
842 	unsigned int ignore_pmdown_time:1;
843 
844 	/* Do not create a PCM for this DAI link (Backend link) */
845 	unsigned int ignore:1;
846 
847 #ifdef CONFIG_SND_SOC_TOPOLOGY
848 	struct snd_soc_dobj dobj; /* For topology */
849 #endif
850 
851 	ANDROID_KABI_RESERVE(1);
852 };
853 #define for_each_link_codecs(link, i, codec)				\
854 	for ((i) = 0;							\
855 	     ((i) < link->num_codecs) && ((codec) = &link->codecs[i]);	\
856 	     (i)++)
857 
858 #define for_each_link_platforms(link, i, platform)			\
859 	for ((i) = 0;							\
860 	     ((i) < link->num_platforms) &&				\
861 	     ((platform) = &link->platforms[i]);			\
862 	     (i)++)
863 
864 #define for_each_link_cpus(link, i, cpu)				\
865 	for ((i) = 0;							\
866 	     ((i) < link->num_cpus) && ((cpu) = &link->cpus[i]);	\
867 	     (i)++)
868 
869 /*
870  * Sample 1 : Single CPU/Codec/Platform
871  *
872  * SND_SOC_DAILINK_DEFS(test,
873  *	DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")),
874  *	DAILINK_COMP_ARRAY(COMP_CODEC("codec", "codec_dai")),
875  *	DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
876  *
877  * struct snd_soc_dai_link link = {
878  *	...
879  *	SND_SOC_DAILINK_REG(test),
880  * };
881  *
882  * Sample 2 : Multi CPU/Codec, no Platform
883  *
884  * SND_SOC_DAILINK_DEFS(test,
885  *	DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
886  *			   COMP_CPU("cpu_dai2")),
887  *	DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
888  *			   COMP_CODEC("codec2", "codec_dai2")));
889  *
890  * struct snd_soc_dai_link link = {
891  *	...
892  *	SND_SOC_DAILINK_REG(test),
893  * };
894  *
895  * Sample 3 : Define each CPU/Codec/Platform manually
896  *
897  * SND_SOC_DAILINK_DEF(test_cpu,
898  *		DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
899  *				   COMP_CPU("cpu_dai2")));
900  * SND_SOC_DAILINK_DEF(test_codec,
901  *		DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
902  *				   COMP_CODEC("codec2", "codec_dai2")));
903  * SND_SOC_DAILINK_DEF(test_platform,
904  *		DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
905  *
906  * struct snd_soc_dai_link link = {
907  *	...
908  *	SND_SOC_DAILINK_REG(test_cpu,
909  *			    test_codec,
910  *			    test_platform),
911  * };
912  *
913  * Sample 4 : Sample3 without platform
914  *
915  * struct snd_soc_dai_link link = {
916  *	...
917  *	SND_SOC_DAILINK_REG(test_cpu,
918  *			    test_codec);
919  * };
920  */
921 
922 #define SND_SOC_DAILINK_REG1(name)	 SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms)
923 #define SND_SOC_DAILINK_REG2(cpu, codec) SND_SOC_DAILINK_REG3(cpu, codec, null_dailink_component)
924 #define SND_SOC_DAILINK_REG3(cpu, codec, platform)	\
925 	.cpus		= cpu,				\
926 	.num_cpus	= ARRAY_SIZE(cpu),		\
927 	.codecs		= codec,			\
928 	.num_codecs	= ARRAY_SIZE(codec),		\
929 	.platforms	= platform,			\
930 	.num_platforms	= ARRAY_SIZE(platform)
931 
932 #define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func
933 #define SND_SOC_DAILINK_REG(...) \
934 	SND_SOC_DAILINK_REGx(__VA_ARGS__,		\
935 			SND_SOC_DAILINK_REG3,	\
936 			SND_SOC_DAILINK_REG2,	\
937 			SND_SOC_DAILINK_REG1)(__VA_ARGS__)
938 
939 #define SND_SOC_DAILINK_DEF(name, def...)		\
940 	static struct snd_soc_dai_link_component name[]	= { def }
941 
942 #define SND_SOC_DAILINK_DEFS(name, cpu, codec, platform...)	\
943 	SND_SOC_DAILINK_DEF(name##_cpus, cpu);			\
944 	SND_SOC_DAILINK_DEF(name##_codecs, codec);		\
945 	SND_SOC_DAILINK_DEF(name##_platforms, platform)
946 
947 #define DAILINK_COMP_ARRAY(param...)	param
948 #define COMP_EMPTY()			{ }
949 #define COMP_CPU(_dai)			{ .dai_name = _dai, }
950 #define COMP_CODEC(_name, _dai)		{ .name = _name, .dai_name = _dai, }
951 #define COMP_PLATFORM(_name)		{ .name = _name }
952 #define COMP_AUX(_name)			{ .name = _name }
953 #define COMP_CODEC_CONF(_name)		{ .name = _name }
954 #define COMP_DUMMY()			{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
955 
956 extern struct snd_soc_dai_link_component null_dailink_component[0];
957 
958 
959 struct snd_soc_codec_conf {
960 	/*
961 	 * specify device either by device name, or by
962 	 * DT/OF node, but not both.
963 	 */
964 	struct snd_soc_dai_link_component dlc;
965 
966 	/*
967 	 * optional map of kcontrol, widget and path name prefixes that are
968 	 * associated per device
969 	 */
970 	const char *name_prefix;
971 };
972 
973 struct snd_soc_aux_dev {
974 	/*
975 	 * specify multi-codec either by device name, or by
976 	 * DT/OF node, but not both.
977 	 */
978 	struct snd_soc_dai_link_component dlc;
979 
980 	/* codec/machine specific init - e.g. add machine controls */
981 	int (*init)(struct snd_soc_component *component);
982 };
983 
984 /* SoC card */
985 struct snd_soc_card {
986 	const char *name;
987 	const char *long_name;
988 	const char *driver_name;
989 	const char *components;
990 #ifdef CONFIG_DMI
991 	char dmi_longname[80];
992 #endif /* CONFIG_DMI */
993 	char topology_shortname[32];
994 
995 	struct device *dev;
996 	struct snd_card *snd_card;
997 	struct module *owner;
998 
999 	struct mutex mutex;
1000 	struct mutex dapm_mutex;
1001 
1002 	/* Mutex for PCM operations */
1003 	struct mutex pcm_mutex;
1004 	enum snd_soc_pcm_subclass pcm_subclass;
1005 
1006 	spinlock_t dpcm_lock;
1007 
1008 	int (*probe)(struct snd_soc_card *card);
1009 	int (*late_probe)(struct snd_soc_card *card);
1010 	int (*remove)(struct snd_soc_card *card);
1011 
1012 	/* the pre and post PM functions are used to do any PM work before and
1013 	 * after the codec and DAI's do any PM work. */
1014 	int (*suspend_pre)(struct snd_soc_card *card);
1015 	int (*suspend_post)(struct snd_soc_card *card);
1016 	int (*resume_pre)(struct snd_soc_card *card);
1017 	int (*resume_post)(struct snd_soc_card *card);
1018 
1019 	/* callbacks */
1020 	int (*set_bias_level)(struct snd_soc_card *,
1021 			      struct snd_soc_dapm_context *dapm,
1022 			      enum snd_soc_bias_level level);
1023 	int (*set_bias_level_post)(struct snd_soc_card *,
1024 				   struct snd_soc_dapm_context *dapm,
1025 				   enum snd_soc_bias_level level);
1026 
1027 	int (*add_dai_link)(struct snd_soc_card *,
1028 			    struct snd_soc_dai_link *link);
1029 	void (*remove_dai_link)(struct snd_soc_card *,
1030 			    struct snd_soc_dai_link *link);
1031 
1032 	long pmdown_time;
1033 
1034 	/* CPU <--> Codec DAI links  */
1035 	struct snd_soc_dai_link *dai_link;  /* predefined links only */
1036 	int num_links;  /* predefined links only */
1037 
1038 	struct list_head rtd_list;
1039 	int num_rtd;
1040 
1041 	/* optional codec specific configuration */
1042 	struct snd_soc_codec_conf *codec_conf;
1043 	int num_configs;
1044 
1045 	/*
1046 	 * optional auxiliary devices such as amplifiers or codecs with DAI
1047 	 * link unused
1048 	 */
1049 	struct snd_soc_aux_dev *aux_dev;
1050 	int num_aux_devs;
1051 	struct list_head aux_comp_list;
1052 
1053 	const struct snd_kcontrol_new *controls;
1054 	int num_controls;
1055 
1056 	/*
1057 	 * Card-specific routes and widgets.
1058 	 * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
1059 	 */
1060 	const struct snd_soc_dapm_widget *dapm_widgets;
1061 	int num_dapm_widgets;
1062 	const struct snd_soc_dapm_route *dapm_routes;
1063 	int num_dapm_routes;
1064 	const struct snd_soc_dapm_widget *of_dapm_widgets;
1065 	int num_of_dapm_widgets;
1066 	const struct snd_soc_dapm_route *of_dapm_routes;
1067 	int num_of_dapm_routes;
1068 
1069 	/* lists of probed devices belonging to this card */
1070 	struct list_head component_dev_list;
1071 	struct list_head list;
1072 
1073 	struct list_head widgets;
1074 	struct list_head paths;
1075 	struct list_head dapm_list;
1076 	struct list_head dapm_dirty;
1077 
1078 	/* attached dynamic objects */
1079 	struct list_head dobj_list;
1080 
1081 	/* Generic DAPM context for the card */
1082 	struct snd_soc_dapm_context dapm;
1083 	struct snd_soc_dapm_stats dapm_stats;
1084 	struct snd_soc_dapm_update *update;
1085 
1086 #ifdef CONFIG_DEBUG_FS
1087 	struct dentry *debugfs_card_root;
1088 #endif
1089 #ifdef CONFIG_PM_SLEEP
1090 	struct work_struct deferred_resume_work;
1091 #endif
1092 	u32 pop_time;
1093 
1094 	/* bit field */
1095 	unsigned int instantiated:1;
1096 	unsigned int topology_shortname_created:1;
1097 	unsigned int fully_routed:1;
1098 	unsigned int disable_route_checks:1;
1099 	unsigned int probed:1;
1100 
1101 	void *drvdata;
1102 
1103 	ANDROID_KABI_RESERVE(1);
1104 	ANDROID_KABI_RESERVE(2);
1105 	ANDROID_KABI_RESERVE(3);
1106 	ANDROID_KABI_RESERVE(4);
1107 };
1108 #define for_each_card_prelinks(card, i, link)				\
1109 	for ((i) = 0;							\
1110 	     ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
1111 	     (i)++)
1112 #define for_each_card_pre_auxs(card, i, aux)				\
1113 	for ((i) = 0;							\
1114 	     ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \
1115 	     (i)++)
1116 
1117 #define for_each_card_rtds(card, rtd)			\
1118 	list_for_each_entry(rtd, &(card)->rtd_list, list)
1119 #define for_each_card_rtds_safe(card, rtd, _rtd)	\
1120 	list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list)
1121 
1122 #define for_each_card_auxs(card, component)			\
1123 	list_for_each_entry(component, &card->aux_comp_list, card_aux_list)
1124 #define for_each_card_auxs_safe(card, component, _comp)	\
1125 	list_for_each_entry_safe(component, _comp,	\
1126 				 &card->aux_comp_list, card_aux_list)
1127 
1128 #define for_each_card_components(card, component)			\
1129 	list_for_each_entry(component, &(card)->component_dev_list, card_list)
1130 
1131 #define for_each_card_dapms(card, dapm)					\
1132 	list_for_each_entry(dapm, &card->dapm_list, list)
1133 
1134 #define for_each_card_widgets(card, w)\
1135 	list_for_each_entry(w, &card->widgets, list)
1136 #define for_each_card_widgets_safe(card, w, _w)	\
1137 	list_for_each_entry_safe(w, _w, &card->widgets, list)
1138 
1139 /* SoC machine DAI configuration, glues a codec and cpu DAI together */
1140 struct snd_soc_pcm_runtime {
1141 	struct device *dev;
1142 	struct snd_soc_card *card;
1143 	struct snd_soc_dai_link *dai_link;
1144 	struct snd_pcm_ops ops;
1145 
1146 	unsigned int params_select; /* currently selected param for dai link */
1147 
1148 	/* Dynamic PCM BE runtime data */
1149 	struct snd_soc_dpcm_runtime dpcm[2];
1150 
1151 	long pmdown_time;
1152 
1153 	/* runtime devices */
1154 	struct snd_pcm *pcm;
1155 	struct snd_compr *compr;
1156 
1157 	/*
1158 	 * dais = cpu_dai + codec_dai
1159 	 * see
1160 	 *	soc_new_pcm_runtime()
1161 	 *	asoc_rtd_to_cpu()
1162 	 *	asoc_rtd_to_codec()
1163 	 */
1164 	struct snd_soc_dai **dais;
1165 	unsigned int num_codecs;
1166 	unsigned int num_cpus;
1167 
1168 	struct snd_soc_dapm_widget *playback_widget;
1169 	struct snd_soc_dapm_widget *capture_widget;
1170 
1171 	struct delayed_work delayed_work;
1172 	void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
1173 #ifdef CONFIG_DEBUG_FS
1174 	struct dentry *debugfs_dpcm_root;
1175 #endif
1176 
1177 	unsigned int num; /* 0-based and monotonic increasing */
1178 	struct list_head list; /* rtd list of the soc card */
1179 
1180 	/* function mark */
1181 	struct snd_pcm_substream *mark_startup;
1182 
1183 	/* bit field */
1184 	unsigned int pop_wait:1;
1185 	unsigned int fe_compr:1; /* for Dynamic PCM */
1186 
1187 	int num_components;
1188 
1189 	ANDROID_KABI_RESERVE(1);
1190 
1191 	struct snd_soc_component *components[]; /* CPU/Codec/Platform */
1192 };
1193 /* see soc_new_pcm_runtime()  */
1194 #define asoc_rtd_to_cpu(rtd, n)   (rtd)->dais[n]
1195 #define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->num_cpus]
1196 #define asoc_substream_to_rtd(substream) \
1197 	(struct snd_soc_pcm_runtime *)snd_pcm_substream_chip(substream)
1198 
1199 #define for_each_rtd_components(rtd, i, component)			\
1200 	for ((i) = 0, component = NULL;					\
1201 	     ((i) < rtd->num_components) && ((component) = rtd->components[i]);\
1202 	     (i)++)
1203 #define for_each_rtd_cpu_dais(rtd, i, dai)				\
1204 	for ((i) = 0;							\
1205 	     ((i) < rtd->num_cpus) && ((dai) = asoc_rtd_to_cpu(rtd, i)); \
1206 	     (i)++)
1207 #define for_each_rtd_cpu_dais_rollback(rtd, i, dai)		\
1208 	for (; (--(i) >= 0) && ((dai) = asoc_rtd_to_cpu(rtd, i));)
1209 #define for_each_rtd_codec_dais(rtd, i, dai)				\
1210 	for ((i) = 0;							\
1211 	     ((i) < rtd->num_codecs) && ((dai) = asoc_rtd_to_codec(rtd, i)); \
1212 	     (i)++)
1213 #define for_each_rtd_codec_dais_rollback(rtd, i, dai)		\
1214 	for (; (--(i) >= 0) && ((dai) = asoc_rtd_to_codec(rtd, i));)
1215 #define for_each_rtd_dais(rtd, i, dai)					\
1216 	for ((i) = 0;							\
1217 	     ((i) < (rtd)->num_cpus + (rtd)->num_codecs) &&		\
1218 		     ((dai) = (rtd)->dais[i]);				\
1219 	     (i)++)
1220 #define for_each_rtd_dais_rollback(rtd, i, dai)		\
1221 	for (; (--(i) >= 0) && ((dai) = (rtd)->dais[i]);)
1222 
1223 void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);
1224 
1225 /* mixer control */
1226 struct soc_mixer_control {
1227 	int min, max, platform_max;
1228 	int reg, rreg;
1229 	unsigned int shift, rshift;
1230 	unsigned int sign_bit;
1231 	unsigned int invert:1;
1232 	unsigned int autodisable:1;
1233 #ifdef CONFIG_SND_SOC_TOPOLOGY
1234 	struct snd_soc_dobj dobj;
1235 #endif
1236 
1237 	ANDROID_KABI_RESERVE(1);
1238 };
1239 
1240 struct soc_bytes {
1241 	int base;
1242 	int num_regs;
1243 	u32 mask;
1244 };
1245 
1246 struct soc_bytes_ext {
1247 	int max;
1248 #ifdef CONFIG_SND_SOC_TOPOLOGY
1249 	struct snd_soc_dobj dobj;
1250 #endif
1251 	/* used for TLV byte control */
1252 	int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
1253 			unsigned int size);
1254 	int (*put)(struct snd_kcontrol *kcontrol, const unsigned int __user *bytes,
1255 			unsigned int size);
1256 };
1257 
1258 /* multi register control */
1259 struct soc_mreg_control {
1260 	long min, max;
1261 	unsigned int regbase, regcount, nbits, invert;
1262 };
1263 
1264 struct soc_multi_mixer_control {
1265 	int min, max, platform_max, count;
1266 	unsigned int reg, rreg, shift, rshift, invert;
1267 };
1268 
1269 /* enumerated kcontrol */
1270 struct soc_enum {
1271 	int reg;
1272 	unsigned char shift_l;
1273 	unsigned char shift_r;
1274 	unsigned int items;
1275 	unsigned int mask;
1276 	const char * const *texts;
1277 	const unsigned int *values;
1278 	unsigned int autodisable:1;
1279 #ifdef CONFIG_SND_SOC_TOPOLOGY
1280 	struct snd_soc_dobj dobj;
1281 #endif
1282 
1283 	ANDROID_KABI_RESERVE(1);
1284 };
1285 
snd_soc_volsw_is_stereo(struct soc_mixer_control * mc)1286 static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
1287 {
1288 	if (mc->reg == mc->rreg && mc->shift == mc->rshift)
1289 		return false;
1290 	/*
1291 	 * mc->reg == mc->rreg && mc->shift != mc->rshift, or
1292 	 * mc->reg != mc->rreg means that the control is
1293 	 * stereo (bits in one register or in two registers)
1294 	 */
1295 	return true;
1296 }
1297 
snd_soc_enum_val_to_item(struct soc_enum * e,unsigned int val)1298 static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
1299 	unsigned int val)
1300 {
1301 	unsigned int i;
1302 
1303 	if (!e->values)
1304 		return val;
1305 
1306 	for (i = 0; i < e->items; i++)
1307 		if (val == e->values[i])
1308 			return i;
1309 
1310 	return 0;
1311 }
1312 
snd_soc_enum_item_to_val(struct soc_enum * e,unsigned int item)1313 static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
1314 	unsigned int item)
1315 {
1316 	if (!e->values)
1317 		return item;
1318 
1319 	return e->values[item];
1320 }
1321 
1322 /**
1323  * snd_soc_kcontrol_component() - Returns the component that registered the
1324  *  control
1325  * @kcontrol: The control for which to get the component
1326  *
1327  * Note: This function will work correctly if the control has been registered
1328  * for a component. With snd_soc_add_codec_controls() or via table based
1329  * setup for either a CODEC or component driver. Otherwise the behavior is
1330  * undefined.
1331  */
snd_soc_kcontrol_component(struct snd_kcontrol * kcontrol)1332 static inline struct snd_soc_component *snd_soc_kcontrol_component(
1333 	struct snd_kcontrol *kcontrol)
1334 {
1335 	return snd_kcontrol_chip(kcontrol);
1336 }
1337 
1338 int snd_soc_util_init(void);
1339 void snd_soc_util_exit(void);
1340 
1341 int snd_soc_of_parse_card_name(struct snd_soc_card *card,
1342 			       const char *propname);
1343 int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
1344 					  const char *propname);
1345 int snd_soc_of_get_slot_mask(struct device_node *np,
1346 			     const char *prop_name,
1347 			     unsigned int *mask);
1348 int snd_soc_of_parse_tdm_slot(struct device_node *np,
1349 			      unsigned int *tx_mask,
1350 			      unsigned int *rx_mask,
1351 			      unsigned int *slots,
1352 			      unsigned int *slot_width);
1353 void snd_soc_of_parse_node_prefix(struct device_node *np,
1354 				   struct snd_soc_codec_conf *codec_conf,
1355 				   struct device_node *of_node,
1356 				   const char *propname);
1357 static inline
snd_soc_of_parse_audio_prefix(struct snd_soc_card * card,struct snd_soc_codec_conf * codec_conf,struct device_node * of_node,const char * propname)1358 void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
1359 				   struct snd_soc_codec_conf *codec_conf,
1360 				   struct device_node *of_node,
1361 				   const char *propname)
1362 {
1363 	snd_soc_of_parse_node_prefix(card->dev->of_node,
1364 				     codec_conf, of_node, propname);
1365 }
1366 
1367 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
1368 				   const char *propname);
1369 int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
1370 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
1371 				     const char *prefix,
1372 				     struct device_node **bitclkmaster,
1373 				     struct device_node **framemaster);
1374 int snd_soc_get_dai_id(struct device_node *ep);
1375 int snd_soc_get_dai_name(struct of_phandle_args *args,
1376 			 const char **dai_name);
1377 int snd_soc_of_get_dai_name(struct device_node *of_node,
1378 			    const char **dai_name);
1379 int snd_soc_of_get_dai_link_codecs(struct device *dev,
1380 				   struct device_node *of_node,
1381 				   struct snd_soc_dai_link *dai_link);
1382 void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
1383 
1384 int snd_soc_add_pcm_runtime(struct snd_soc_card *card,
1385 			    struct snd_soc_dai_link *dai_link);
1386 void snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
1387 				struct snd_soc_pcm_runtime *rtd);
1388 
1389 struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
1390 					 struct snd_soc_dai_driver *dai_drv,
1391 					 bool legacy_dai_naming);
1392 struct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev,
1393 					      struct snd_soc_component *component,
1394 					      struct snd_soc_dai_driver *dai_drv,
1395 					      bool legacy_dai_naming);
1396 void snd_soc_unregister_dai(struct snd_soc_dai *dai);
1397 
1398 struct snd_soc_dai *snd_soc_find_dai(
1399 	const struct snd_soc_dai_link_component *dlc);
1400 struct snd_soc_dai *snd_soc_find_dai_with_mutex(
1401 	const struct snd_soc_dai_link_component *dlc);
1402 
1403 #include <sound/soc-dai.h>
1404 
1405 static inline
snd_soc_fixup_dai_links_platform_name(struct snd_soc_card * card,const char * platform_name)1406 int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
1407 					  const char *platform_name)
1408 {
1409 	struct snd_soc_dai_link *dai_link;
1410 	const char *name;
1411 	int i;
1412 
1413 	if (!platform_name) /* nothing to do */
1414 		return 0;
1415 
1416 	/* set platform name for each dailink */
1417 	for_each_card_prelinks(card, i, dai_link) {
1418 		name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
1419 		if (!name)
1420 			return -ENOMEM;
1421 
1422 		if (!dai_link->platforms)
1423 			return -EINVAL;
1424 
1425 		/* only single platform is supported for now */
1426 		dai_link->platforms->name = name;
1427 	}
1428 
1429 	return 0;
1430 }
1431 
1432 #ifdef CONFIG_DEBUG_FS
1433 extern struct dentry *snd_soc_debugfs_root;
1434 #endif
1435 
1436 extern const struct dev_pm_ops snd_soc_pm_ops;
1437 
1438 /* Helper functions */
snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context * dapm)1439 static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm)
1440 {
1441 	mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
1442 }
1443 
snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context * dapm)1444 static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
1445 {
1446 	mutex_unlock(&dapm->card->dapm_mutex);
1447 }
1448 
1449 #include <sound/soc-component.h>
1450 #include <sound/soc-card.h>
1451 
1452 #endif
1453