xref: /linux/include/sound/soc.h (revision 36ec807b627b4c0a0a382f0ae48eac7187d14b2b)
1873486edSKuninori Morimoto /* SPDX-License-Identifier: GPL-2.0
2873486edSKuninori Morimoto  *
3808db4a4SRichard Purdie  * linux/sound/soc.h -- ALSA SoC Layer
4808db4a4SRichard Purdie  *
5808db4a4SRichard Purdie  * Author:	Liam Girdwood
6808db4a4SRichard Purdie  * Created:	Aug 11th 2005
7808db4a4SRichard Purdie  * Copyright:	Wolfson Microelectronics. PLC.
8808db4a4SRichard Purdie  */
9808db4a4SRichard Purdie 
10808db4a4SRichard Purdie #ifndef __LINUX_SND_SOC_H
11808db4a4SRichard Purdie #define __LINUX_SND_SOC_H
12808db4a4SRichard Purdie 
13428cc410SAndy Shevchenko #include <linux/args.h>
143249c68eSAndy Shevchenko #include <linux/array_size.h>
153249c68eSAndy Shevchenko #include <linux/device.h>
163249c68eSAndy Shevchenko #include <linux/errno.h>
17ec67624dSLopez Cruz, Misael #include <linux/interrupt.h>
183249c68eSAndy Shevchenko #include <linux/lockdep.h>
1986767b7dSLars-Peter Clausen #include <linux/log2.h>
203249c68eSAndy Shevchenko #include <linux/mutex.h>
213249c68eSAndy Shevchenko #include <linux/notifier.h>
223249c68eSAndy Shevchenko #include <linux/of.h>
233249c68eSAndy Shevchenko #include <linux/types.h>
243249c68eSAndy Shevchenko #include <linux/workqueue.h>
253249c68eSAndy Shevchenko 
263249c68eSAndy Shevchenko #include <sound/ac97_codec.h>
2749681077SVinod Koul #include <sound/compress_driver.h>
28808db4a4SRichard Purdie #include <sound/control.h>
293249c68eSAndy Shevchenko #include <sound/core.h>
303249c68eSAndy Shevchenko #include <sound/pcm.h>
313249c68eSAndy Shevchenko 
323249c68eSAndy Shevchenko struct module;
333249c68eSAndy Shevchenko struct platform_device;
343249c68eSAndy Shevchenko 
353249c68eSAndy Shevchenko /* For the current users of sound/soc.h to avoid build issues */
363249c68eSAndy Shevchenko #include <linux/platform_device.h>
373249c68eSAndy Shevchenko #include <linux/regmap.h>
38808db4a4SRichard Purdie 
39808db4a4SRichard Purdie /*
40808db4a4SRichard Purdie  * Convenience kcontrol builders
41808db4a4SRichard Purdie  */
4257295073SLars-Peter Clausen #define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert, xautodisable) \
434eaa9819SJon Smirl 	((unsigned long)&(struct soc_mixer_control) \
4430d86ba4SPeter Ujfalusi 	{.reg = xreg, .rreg = xreg, .shift = shift_left, \
4526bdcc4bSSrinivas Kandagatla 	.rshift = shift_right, .max = xmax, \
4657295073SLars-Peter Clausen 	.invert = xinvert, .autodisable = xautodisable})
47c1b4d1c7SLars-Peter Clausen #define SOC_DOUBLE_S_VALUE(xreg, shift_left, shift_right, xmin, xmax, xsign_bit, xinvert, xautodisable) \
48c1b4d1c7SLars-Peter Clausen 	((unsigned long)&(struct soc_mixer_control) \
49c1b4d1c7SLars-Peter Clausen 	{.reg = xreg, .rreg = xreg, .shift = shift_left, \
5026bdcc4bSSrinivas Kandagatla 	.rshift = shift_right, .min = xmin, .max = xmax, \
51c1b4d1c7SLars-Peter Clausen 	.sign_bit = xsign_bit, .invert = xinvert, .autodisable = xautodisable})
5257295073SLars-Peter Clausen #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, xautodisable) \
5357295073SLars-Peter Clausen 	SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert, xautodisable)
544eaa9819SJon Smirl #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
554eaa9819SJon Smirl 	((unsigned long)&(struct soc_mixer_control) \
5626bdcc4bSSrinivas Kandagatla 	{.reg = xreg, .max = xmax, .invert = xinvert})
57cdffa775SPeter Ujfalusi #define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
58cdffa775SPeter Ujfalusi 	((unsigned long)&(struct soc_mixer_control) \
59cdffa775SPeter Ujfalusi 	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
6026bdcc4bSSrinivas Kandagatla 	.max = xmax, .invert = xinvert})
61cd21b123SMarkus Pargmann #define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
62cd21b123SMarkus Pargmann 	((unsigned long)&(struct soc_mixer_control) \
63cd21b123SMarkus Pargmann 	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
6426bdcc4bSSrinivas Kandagatla 	.max = xmax, .min = xmin, .sign_bit = xsign_bit, \
65cd21b123SMarkus Pargmann 	.invert = xinvert})
66229e3fdcSMark Brown #define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
67229e3fdcSMark Brown 	((unsigned long)&(struct soc_mixer_control) \
68229e3fdcSMark Brown 	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
6926bdcc4bSSrinivas Kandagatla 	.min = xmin, .max = xmax, .invert = xinvert})
70a7a4ac86SPhilipp Zabel #define SOC_SINGLE(xname, reg, shift, max, invert) \
71808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
72808db4a4SRichard Purdie 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
73808db4a4SRichard Purdie 	.put = snd_soc_put_volsw, \
7457295073SLars-Peter Clausen 	.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
756c9d8cf6SAdam Thomson #define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
766c9d8cf6SAdam Thomson {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
776c9d8cf6SAdam Thomson 	.info = snd_soc_info_volsw_range, .get = snd_soc_get_volsw_range, \
786c9d8cf6SAdam Thomson 	.put = snd_soc_put_volsw_range, \
796c9d8cf6SAdam Thomson 	.private_value = (unsigned long)&(struct soc_mixer_control) \
809bde4f0bSMark Brown 		{.reg = xreg, .rreg = xreg, .shift = xshift, \
819bde4f0bSMark Brown 		 .rshift = xshift,  .min = xmin, .max = xmax, \
8226bdcc4bSSrinivas Kandagatla 		 .invert = xinvert} }
83a7a4ac86SPhilipp Zabel #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
84a7a4ac86SPhilipp Zabel {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
85a7a4ac86SPhilipp Zabel 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
86a7a4ac86SPhilipp Zabel 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
87a7a4ac86SPhilipp Zabel 	.tlv.p = (tlv_array), \
88a7a4ac86SPhilipp Zabel 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
89a7a4ac86SPhilipp Zabel 	.put = snd_soc_put_volsw, \
9057295073SLars-Peter Clausen 	.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
911d99f243SBrian Austin #define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
921d99f243SBrian Austin {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
931d99f243SBrian Austin 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
941d99f243SBrian Austin 	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
951d99f243SBrian Austin 	.tlv.p  = (tlv_array),\
9634198710SCharles Keepax 	.info = snd_soc_info_volsw_sx, \
971d99f243SBrian Austin 	.get = snd_soc_get_volsw_sx,\
981d99f243SBrian Austin 	.put = snd_soc_put_volsw_sx, \
991d99f243SBrian Austin 	.private_value = (unsigned long)&(struct soc_mixer_control) \
1001d99f243SBrian Austin 		{.reg = xreg, .rreg = xreg, \
1011d99f243SBrian Austin 		.shift = xshift, .rshift = xshift, \
1021d99f243SBrian Austin 		.max = xmax, .min = xmin} }
1036c9d8cf6SAdam Thomson #define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \
1046c9d8cf6SAdam Thomson {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
1056c9d8cf6SAdam Thomson 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
1066c9d8cf6SAdam Thomson 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
1076c9d8cf6SAdam Thomson 	.tlv.p = (tlv_array), \
1086c9d8cf6SAdam Thomson 	.info = snd_soc_info_volsw_range, \
1096c9d8cf6SAdam Thomson 	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
1106c9d8cf6SAdam Thomson 	.private_value = (unsigned long)&(struct soc_mixer_control) \
1119bde4f0bSMark Brown 		{.reg = xreg, .rreg = xreg, .shift = xshift, \
1129bde4f0bSMark Brown 		 .rshift = xshift, .min = xmin, .max = xmax, \
11326bdcc4bSSrinivas Kandagatla 		 .invert = xinvert} }
114460acbecSPeter Ujfalusi #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
115808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
116808db4a4SRichard Purdie 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
117808db4a4SRichard Purdie 	.put = snd_soc_put_volsw, \
118460acbecSPeter Ujfalusi 	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
11957295073SLars-Peter Clausen 					  max, invert, 0) }
120d13871b3SDamien.Horsley #define SOC_DOUBLE_STS(xname, reg, shift_left, shift_right, max, invert) \
121d13871b3SDamien.Horsley {									\
122d13871b3SDamien.Horsley 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),		\
123d13871b3SDamien.Horsley 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,		\
124d13871b3SDamien.Horsley 	.access = SNDRV_CTL_ELEM_ACCESS_READ |				\
125d13871b3SDamien.Horsley 		SNDRV_CTL_ELEM_ACCESS_VOLATILE,				\
126d13871b3SDamien.Horsley 	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right,	\
127d13871b3SDamien.Horsley 					  max, invert, 0) }
1284eaa9819SJon Smirl #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
129808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
130e8f5a103SPeter Ujfalusi 	.info = snd_soc_info_volsw, \
131974815baSPeter Ujfalusi 	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
132cdffa775SPeter Ujfalusi 	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
133cdffa775SPeter Ujfalusi 					    xmax, xinvert) }
134229e3fdcSMark Brown #define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \
135229e3fdcSMark Brown 			   xmax, xinvert)		\
136229e3fdcSMark Brown {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
137229e3fdcSMark Brown 	.info = snd_soc_info_volsw_range, \
138229e3fdcSMark Brown 	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
139229e3fdcSMark Brown 	.private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
140229e3fdcSMark Brown 					    xshift, xmin, xmax, xinvert) }
141460acbecSPeter Ujfalusi #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
142a7a4ac86SPhilipp Zabel {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
143a7a4ac86SPhilipp Zabel 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
144a7a4ac86SPhilipp Zabel 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
145a7a4ac86SPhilipp Zabel 	.tlv.p = (tlv_array), \
146a7a4ac86SPhilipp Zabel 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
147a7a4ac86SPhilipp Zabel 	.put = snd_soc_put_volsw, \
148460acbecSPeter Ujfalusi 	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
14957295073SLars-Peter Clausen 					  max, invert, 0) }
1506b183919SCharles Keepax #define SOC_DOUBLE_SX_TLV(xname, xreg, shift_left, shift_right, xmin, xmax, tlv_array) \
1516b183919SCharles Keepax {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
1526b183919SCharles Keepax 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1536b183919SCharles Keepax 	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1546b183919SCharles Keepax 	.tlv.p  = (tlv_array), \
1556b183919SCharles Keepax 	.info = snd_soc_info_volsw_sx, \
1566b183919SCharles Keepax 	.get = snd_soc_get_volsw_sx, \
1576b183919SCharles Keepax 	.put = snd_soc_put_volsw_sx, \
1586b183919SCharles Keepax 	.private_value = (unsigned long)&(struct soc_mixer_control) \
1596b183919SCharles Keepax 		{.reg = xreg, .rreg = xreg, \
1606b183919SCharles Keepax 		.shift = shift_left, .rshift = shift_right, \
1616b183919SCharles Keepax 		.max = xmax, .min = xmin} }
162d75a2161SLuca Ceresoli #define SOC_DOUBLE_RANGE_TLV(xname, xreg, xshift_left, xshift_right, xmin, xmax, \
163d75a2161SLuca Ceresoli 			     xinvert, tlv_array) \
164d75a2161SLuca Ceresoli {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
165d75a2161SLuca Ceresoli 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
166d75a2161SLuca Ceresoli 		  SNDRV_CTL_ELEM_ACCESS_READWRITE,\
167d75a2161SLuca Ceresoli 	.tlv.p = (tlv_array), \
168d75a2161SLuca Ceresoli 	.info = snd_soc_info_volsw, \
169d75a2161SLuca Ceresoli 	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
170d75a2161SLuca Ceresoli 	.private_value = (unsigned long)&(struct soc_mixer_control) \
171d75a2161SLuca Ceresoli 		{.reg = xreg, .rreg = xreg, \
172d75a2161SLuca Ceresoli 		 .shift = xshift_left, .rshift = xshift_right, \
173d75a2161SLuca Ceresoli 		 .min = xmin, .max = xmax, .invert = xinvert} }
1744eaa9819SJon Smirl #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
175a7a4ac86SPhilipp Zabel {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
176a7a4ac86SPhilipp Zabel 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
177a7a4ac86SPhilipp Zabel 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
178a7a4ac86SPhilipp Zabel 	.tlv.p = (tlv_array), \
179e8f5a103SPeter Ujfalusi 	.info = snd_soc_info_volsw, \
180974815baSPeter Ujfalusi 	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
181cdffa775SPeter Ujfalusi 	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
182cdffa775SPeter Ujfalusi 					    xmax, xinvert) }
183229e3fdcSMark Brown #define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \
184229e3fdcSMark Brown 			       xmax, xinvert, tlv_array)		\
185229e3fdcSMark Brown {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
186229e3fdcSMark Brown 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
187229e3fdcSMark Brown 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
188229e3fdcSMark Brown 	.tlv.p = (tlv_array), \
189229e3fdcSMark Brown 	.info = snd_soc_info_volsw_range, \
190229e3fdcSMark Brown 	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
191229e3fdcSMark Brown 	.private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
192229e3fdcSMark Brown 					    xshift, xmin, xmax, xinvert) }
1931d99f243SBrian Austin #define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
1941d99f243SBrian Austin {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
1951d99f243SBrian Austin 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1961d99f243SBrian Austin 	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1971d99f243SBrian Austin 	.tlv.p  = (tlv_array), \
19834198710SCharles Keepax 	.info = snd_soc_info_volsw_sx, \
1991d99f243SBrian Austin 	.get = snd_soc_get_volsw_sx, \
2001d99f243SBrian Austin 	.put = snd_soc_put_volsw_sx, \
2011d99f243SBrian Austin 	.private_value = (unsigned long)&(struct soc_mixer_control) \
2021d99f243SBrian Austin 		{.reg = xreg, .rreg = xrreg, \
2031d99f243SBrian Austin 		.shift = xshift, .rshift = xshift, \
2041d99f243SBrian Austin 		.max = xmax, .min = xmin} }
205cd21b123SMarkus Pargmann #define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
206cd21b123SMarkus Pargmann {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
207cd21b123SMarkus Pargmann 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
208cd21b123SMarkus Pargmann 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
209cd21b123SMarkus Pargmann 	.tlv.p = (tlv_array), \
210cd21b123SMarkus Pargmann 	.info = snd_soc_info_volsw, \
211cd21b123SMarkus Pargmann 	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
212cd21b123SMarkus Pargmann 	.private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
213cd21b123SMarkus Pargmann 					    xmin, xmax, xsign_bit, xinvert) }
214bc8cb029SRichard Fitzgerald #define SOC_SINGLE_S_TLV(xname, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
215bc8cb029SRichard Fitzgerald 	SOC_DOUBLE_R_S_TLV(xname, xreg, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array)
216dcc0799bSSrinivas Kandagatla #define SOC_SINGLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
217dcc0799bSSrinivas Kandagatla {	.iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
218dcc0799bSSrinivas Kandagatla 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
219dcc0799bSSrinivas Kandagatla 		  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
220dcc0799bSSrinivas Kandagatla 	.tlv.p  = (tlv_array), \
221dcc0799bSSrinivas Kandagatla 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
222dcc0799bSSrinivas Kandagatla 	.put = snd_soc_put_volsw, \
223dcc0799bSSrinivas Kandagatla 	.private_value = (unsigned long)&(struct soc_mixer_control) \
224dcc0799bSSrinivas Kandagatla 	{.reg = xreg, .rreg = xreg,  \
22526bdcc4bSSrinivas Kandagatla 	 .min = xmin, .max = xmax, \
226dcc0799bSSrinivas Kandagatla 	.sign_bit = 7,} }
2274eaa9819SJon Smirl #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
228e13ac2e9SMark Brown {	.iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
229e13ac2e9SMark Brown 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
230e13ac2e9SMark Brown 		  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
231e13ac2e9SMark Brown 	.tlv.p  = (tlv_array), \
232c1b4d1c7SLars-Peter Clausen 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
233c1b4d1c7SLars-Peter Clausen 	.put = snd_soc_put_volsw, \
234c1b4d1c7SLars-Peter Clausen 	.private_value = SOC_DOUBLE_S_VALUE(xreg, 0, 8, xmin, xmax, 7, 0, 0) }
2359a8d38dbSTakashi Iwai #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
236808db4a4SRichard Purdie {	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
2379a8d38dbSTakashi Iwai 	.items = xitems, .texts = xtexts, \
2389a8d38dbSTakashi Iwai 	.mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
2399a8d38dbSTakashi Iwai #define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
2409a8d38dbSTakashi Iwai 	SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
2419a8d38dbSTakashi Iwai #define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
2429a8d38dbSTakashi Iwai {	.items = xitems, .texts = xtexts }
2439a8d38dbSTakashi Iwai #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
2442e72f8e3SPeter Ujfalusi {	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
2459a8d38dbSTakashi Iwai 	.mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
2465967cb3dSCharles Keepax #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
2475967cb3dSCharles Keepax 	SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xitems, xtexts, xvalues)
248561ed680SCharles Keepax #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
249561ed680SCharles Keepax {	.reg = xreg, .shift_l = xshift, .shift_r = xshift, \
250561ed680SCharles Keepax 	.mask = xmask, .items = xitems, .texts = xtexts, \
251561ed680SCharles Keepax 	.values = xvalues, .autodisable = 1}
252b948837aSLars-Peter Clausen #define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
253b948837aSLars-Peter Clausen 	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
254808db4a4SRichard Purdie #define SOC_ENUM(xname, xenum) \
255808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
256808db4a4SRichard Purdie 	.info = snd_soc_info_enum_double, \
257808db4a4SRichard Purdie 	.get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
258808db4a4SRichard Purdie 	.private_value = (unsigned long)&xenum }
259f8ba0b7bSJon Smirl #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
260808db4a4SRichard Purdie 	 xhandler_get, xhandler_put) \
261808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
2621c433fbdSGraeme Gregory 	.info = snd_soc_info_volsw, \
263808db4a4SRichard Purdie 	.get = xhandler_get, .put = xhandler_put, \
26457295073SLars-Peter Clausen 	.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
265460acbecSPeter Ujfalusi #define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
2667629ad24SDaniel Mack 	 xhandler_get, xhandler_put) \
2677629ad24SDaniel Mack {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
2687629ad24SDaniel Mack 	.info = snd_soc_info_volsw, \
2697629ad24SDaniel Mack 	.get = xhandler_get, .put = xhandler_put, \
270460acbecSPeter Ujfalusi 	.private_value = \
27157295073SLars-Peter Clausen 		SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) }
272c25c79b4SAdam Thomson #define SOC_DOUBLE_R_EXT(xname, reg_left, reg_right, xshift, xmax, xinvert,\
273c25c79b4SAdam Thomson 	 xhandler_get, xhandler_put) \
274c25c79b4SAdam Thomson {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
275c25c79b4SAdam Thomson 	.info = snd_soc_info_volsw, \
276c25c79b4SAdam Thomson 	.get = xhandler_get, .put = xhandler_put, \
277c25c79b4SAdam Thomson 	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
278c25c79b4SAdam Thomson 					    xmax, xinvert) }
279f8ba0b7bSJon Smirl #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
28010144c09SMike Montour 	 xhandler_get, xhandler_put, tlv_array) \
28110144c09SMike Montour {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
28210144c09SMike Montour 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
28310144c09SMike Montour 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
28410144c09SMike Montour 	.tlv.p = (tlv_array), \
28510144c09SMike Montour 	.info = snd_soc_info_volsw, \
28610144c09SMike Montour 	.get = xhandler_get, .put = xhandler_put, \
28757295073SLars-Peter Clausen 	.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
288a54e22f4SCharles Keepax #define SOC_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
289a54e22f4SCharles Keepax 				 xhandler_get, xhandler_put, tlv_array) \
290a54e22f4SCharles Keepax {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
291a54e22f4SCharles Keepax 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
292a54e22f4SCharles Keepax 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
293a54e22f4SCharles Keepax 	.tlv.p = (tlv_array), \
294a54e22f4SCharles Keepax 	.info = snd_soc_info_volsw_range, \
295a54e22f4SCharles Keepax 	.get = xhandler_get, .put = xhandler_put, \
296a54e22f4SCharles Keepax 	.private_value = (unsigned long)&(struct soc_mixer_control) \
297a54e22f4SCharles Keepax 		{.reg = xreg, .rreg = xreg, .shift = xshift, \
298a54e22f4SCharles Keepax 		 .rshift = xshift, .min = xmin, .max = xmax, \
29926bdcc4bSSrinivas Kandagatla 		 .invert = xinvert} }
300d0af93dbSJoonyoung Shim #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
301d0af93dbSJoonyoung Shim 	 xhandler_get, xhandler_put, tlv_array) \
302d0af93dbSJoonyoung Shim {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
303d0af93dbSJoonyoung Shim 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
304d0af93dbSJoonyoung Shim 		 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
305d0af93dbSJoonyoung Shim 	.tlv.p = (tlv_array), \
306d0af93dbSJoonyoung Shim 	.info = snd_soc_info_volsw, \
307d0af93dbSJoonyoung Shim 	.get = xhandler_get, .put = xhandler_put, \
308460acbecSPeter Ujfalusi 	.private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
30957295073SLars-Peter Clausen 					  xmax, xinvert, 0) }
3103ce91d5aSJoonyoung Shim #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
3113ce91d5aSJoonyoung Shim 	 xhandler_get, xhandler_put, tlv_array) \
3123ce91d5aSJoonyoung Shim {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
3133ce91d5aSJoonyoung Shim 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
3143ce91d5aSJoonyoung Shim 		 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
3153ce91d5aSJoonyoung Shim 	.tlv.p = (tlv_array), \
316e8f5a103SPeter Ujfalusi 	.info = snd_soc_info_volsw, \
3173ce91d5aSJoonyoung Shim 	.get = xhandler_get, .put = xhandler_put, \
318cdffa775SPeter Ujfalusi 	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
319cdffa775SPeter Ujfalusi 					    xmax, xinvert) }
320cf51406cSSimon Trimmer #define SOC_DOUBLE_R_S_EXT_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, \
321cf51406cSSimon Trimmer 			       xsign_bit, xinvert, xhandler_get, xhandler_put, \
322cf51406cSSimon Trimmer 			       tlv_array) \
323cf51406cSSimon Trimmer {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
324cf51406cSSimon Trimmer 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
325cf51406cSSimon Trimmer 		  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
326cf51406cSSimon Trimmer 	.tlv.p = (tlv_array), \
327cf51406cSSimon Trimmer 	.info = snd_soc_info_volsw, \
328cf51406cSSimon Trimmer 	.get = xhandler_get, .put = xhandler_put, \
329cf51406cSSimon Trimmer 	.private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
330cf51406cSSimon Trimmer 					      xmin, xmax, xsign_bit, xinvert) }
3315349c0c9SRichard Fitzgerald #define SOC_SINGLE_S_EXT_TLV(xname, xreg, xshift, xmin, xmax, \
3325349c0c9SRichard Fitzgerald 			     xsign_bit, xinvert, xhandler_get, xhandler_put, \
3335349c0c9SRichard Fitzgerald 			     tlv_array) \
3345349c0c9SRichard Fitzgerald 	SOC_DOUBLE_R_S_EXT_TLV(xname, xreg, xreg, xshift, xmin, xmax, \
3355349c0c9SRichard Fitzgerald 			       xsign_bit, xinvert, xhandler_get, xhandler_put, \
3365349c0c9SRichard Fitzgerald 			       tlv_array)
337808db4a4SRichard Purdie #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
338808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
339808db4a4SRichard Purdie 	.info = snd_soc_info_bool_ext, \
340808db4a4SRichard Purdie 	.get = xhandler_get, .put = xhandler_put, \
341808db4a4SRichard Purdie 	.private_value = xdata }
342808db4a4SRichard Purdie #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
343808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
3449a953e6fSLars-Peter Clausen 	.info = snd_soc_info_enum_double, \
345808db4a4SRichard Purdie 	.get = xhandler_get, .put = xhandler_put, \
346808db4a4SRichard Purdie 	.private_value = (unsigned long)&xenum }
3471e4c0d7cSRichard Fitzgerald #define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
3481e4c0d7cSRichard Fitzgerald 	SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put)
349808db4a4SRichard Purdie 
35071d08516SMark Brown #define SND_SOC_BYTES(xname, xbase, xregs)		      \
35171d08516SMark Brown {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
35271d08516SMark Brown 	.info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
35371d08516SMark Brown 	.put = snd_soc_bytes_put, .private_value =	      \
35471d08516SMark Brown 		((unsigned long)&(struct soc_bytes)           \
35571d08516SMark Brown 		{.base = xbase, .num_regs = xregs }) }
356fb512677STzung-Bi Shih #define SND_SOC_BYTES_E(xname, xbase, xregs, xhandler_get, xhandler_put) \
357fb512677STzung-Bi Shih {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
358fb512677STzung-Bi Shih 	.info = snd_soc_bytes_info, .get = xhandler_get, \
359fb512677STzung-Bi Shih 	.put = xhandler_put, .private_value = \
360fb512677STzung-Bi Shih 		((unsigned long)&(struct soc_bytes) \
361fb512677STzung-Bi Shih 		{.base = xbase, .num_regs = xregs }) }
362b6f4bb38Sapatard@mandriva.com 
363f831b055SMark Brown #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask)	      \
364f831b055SMark Brown {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
365f831b055SMark Brown 	.info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
366f831b055SMark Brown 	.put = snd_soc_bytes_put, .private_value =	      \
367f831b055SMark Brown 		((unsigned long)&(struct soc_bytes)           \
368f831b055SMark Brown 		{.base = xbase, .num_regs = xregs,	      \
369f831b055SMark Brown 		 .mask = xmask }) }
370f831b055SMark Brown 
37150a4f98dSVinod Koul /*
37250a4f98dSVinod Koul  * SND_SOC_BYTES_EXT is deprecated, please USE SND_SOC_BYTES_TLV instead
37350a4f98dSVinod Koul  */
374d9881208SVinod Koul #define SND_SOC_BYTES_EXT(xname, xcount, xhandler_get, xhandler_put) \
375d9881208SVinod Koul {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
376d9881208SVinod Koul 	.info = snd_soc_bytes_info_ext, \
377d9881208SVinod Koul 	.get = xhandler_get, .put = xhandler_put, \
378d9881208SVinod Koul 	.private_value = (unsigned long)&(struct soc_bytes_ext) \
379d9881208SVinod Koul 		{.max = xcount} }
3807523a271SOmair Mohammed Abdullah #define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \
3817523a271SOmair Mohammed Abdullah {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
3827523a271SOmair Mohammed Abdullah 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \
3837523a271SOmair Mohammed Abdullah 		  SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
3847523a271SOmair Mohammed Abdullah 	.tlv.c = (snd_soc_bytes_tlv_callback), \
3854d61b39bSSubhransu S. Prusty 	.info = snd_soc_bytes_info_ext, \
3867523a271SOmair Mohammed Abdullah 	.private_value = (unsigned long)&(struct soc_bytes_ext) \
3877523a271SOmair Mohammed Abdullah 		{.max = xcount, .get = xhandler_get, .put = xhandler_put, } }
3884183eed2SKristoffer KARLSSON #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
3894183eed2SKristoffer KARLSSON 		xmin, xmax, xinvert) \
3904183eed2SKristoffer KARLSSON {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
3914183eed2SKristoffer KARLSSON 	.info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
3924183eed2SKristoffer KARLSSON 	.put = snd_soc_put_xr_sx, \
3934183eed2SKristoffer KARLSSON 	.private_value = (unsigned long)&(struct soc_mreg_control) \
3944183eed2SKristoffer KARLSSON 		{.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
3954183eed2SKristoffer KARLSSON 		.invert = xinvert, .min = xmin, .max = xmax} }
3964183eed2SKristoffer KARLSSON 
397dd7b10b3SKristoffer KARLSSON #define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
398dd7b10b3SKristoffer KARLSSON 	SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
399dd7b10b3SKristoffer KARLSSON 		snd_soc_get_strobe, snd_soc_put_strobe)
400dd7b10b3SKristoffer KARLSSON 
401808db4a4SRichard Purdie /*
4026c2fb6a8SGuennadi Liakhovetski  * Simplified versions of above macros, declaring a struct and calculating
4036c2fb6a8SGuennadi Liakhovetski  * ARRAY_SIZE internally
4046c2fb6a8SGuennadi Liakhovetski  */
4056c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
4062e7e1993STakashi Iwai 	const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
4076c2fb6a8SGuennadi Liakhovetski 						ARRAY_SIZE(xtexts), xtexts)
4086c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
4096c2fb6a8SGuennadi Liakhovetski 	SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
4106c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
4112e7e1993STakashi Iwai 	const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
4126c2fb6a8SGuennadi Liakhovetski #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
4132e7e1993STakashi Iwai 	const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
4146c2fb6a8SGuennadi Liakhovetski 							ARRAY_SIZE(xtexts), xtexts, xvalues)
4156c2fb6a8SGuennadi Liakhovetski #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
4166c2fb6a8SGuennadi Liakhovetski 	SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
417561ed680SCharles Keepax 
418561ed680SCharles Keepax #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
419561ed680SCharles Keepax 	const struct soc_enum name = SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, \
420561ed680SCharles Keepax 		xshift, xmask, ARRAY_SIZE(xtexts), xtexts, xvalues)
421561ed680SCharles Keepax 
422b948837aSLars-Peter Clausen #define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
423b948837aSLars-Peter Clausen 	const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
4246c2fb6a8SGuennadi Liakhovetski 
4258a2cd618SMark Brown struct snd_jack;
4268a2cd618SMark Brown struct snd_soc_card;
427808db4a4SRichard Purdie struct snd_soc_pcm_stream;
428808db4a4SRichard Purdie struct snd_soc_ops;
429808db4a4SRichard Purdie struct snd_soc_pcm_runtime;
4303c4b266fSLiam Girdwood struct snd_soc_dai;
431f0fba2adSLiam Girdwood struct snd_soc_dai_driver;
432d273ebe7Sjassi brar struct snd_soc_dai_link;
433030e79f6SKuninori Morimoto struct snd_soc_component;
434030e79f6SKuninori Morimoto struct snd_soc_component_driver;
435808db4a4SRichard Purdie struct soc_enum;
4368a2cd618SMark Brown struct snd_soc_jack;
437fa9879edSVinod Koul struct snd_soc_jack_zone;
4388a2cd618SMark Brown struct snd_soc_jack_pin;
4393249c68eSAndy Shevchenko 
440ce6120ccSLiam Girdwood #include <sound/soc-dapm.h>
44101d7584cSLiam Girdwood #include <sound/soc-dpcm.h>
44264527e8aSMengdong Lin #include <sound/soc-topology.h>
443f0fba2adSLiam Girdwood 
444ec67624dSLopez Cruz, Misael struct snd_soc_jack_gpio;
445808db4a4SRichard Purdie 
446b8c0dab9SLiam Girdwood enum snd_soc_pcm_subclass {
447b8c0dab9SLiam Girdwood 	SND_SOC_PCM_CLASS_PCM	= 0,
448b8c0dab9SLiam Girdwood 	SND_SOC_PCM_CLASS_BE	= 1,
449b8c0dab9SLiam Girdwood };
450b8c0dab9SLiam Girdwood 
45170a7ca34SVinod Koul int snd_soc_register_card(struct snd_soc_card *card);
4521892a991SUwe Kleine-König void snd_soc_unregister_card(struct snd_soc_card *card);
4530e4ff5c8SMark Brown int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
454aae013d6SJie Yang #ifdef CONFIG_PM_SLEEP
4556f8ab4acSMark Brown int snd_soc_suspend(struct device *dev);
4566f8ab4acSMark Brown int snd_soc_resume(struct device *dev);
457aae013d6SJie Yang #else
458aae013d6SJie Yang static inline int snd_soc_suspend(struct device *dev)
459aae013d6SJie Yang {
460aae013d6SJie Yang 	return 0;
461aae013d6SJie Yang }
462aae013d6SJie Yang 
463aae013d6SJie Yang static inline int snd_soc_resume(struct device *dev)
464aae013d6SJie Yang {
465aae013d6SJie Yang 	return 0;
466aae013d6SJie Yang }
467aae013d6SJie Yang #endif
4686f8ab4acSMark Brown int snd_soc_poweroff(struct device *dev);
46908ff7209SCezary Rojewski int snd_soc_component_initialize(struct snd_soc_component *component,
47008ff7209SCezary Rojewski 				 const struct snd_soc_component_driver *driver,
4717274d4cdSCezary Rojewski 				 struct device *dev);
472ea029dd8SCezary Rojewski int snd_soc_add_component(struct snd_soc_component *component,
473e0dac41bSKuninori Morimoto 			  struct snd_soc_dai_driver *dai_drv,
474e0dac41bSKuninori Morimoto 			  int num_dai);
475030e79f6SKuninori Morimoto int snd_soc_register_component(struct device *dev,
476cf9e829eSKuninori Morimoto 			 const struct snd_soc_component_driver *component_driver,
477030e79f6SKuninori Morimoto 			 struct snd_soc_dai_driver *dai_drv, int num_dai);
478a0b03a61SMark Brown int devm_snd_soc_register_component(struct device *dev,
479cf9e829eSKuninori Morimoto 			 const struct snd_soc_component_driver *component_driver,
480a0b03a61SMark Brown 			 struct snd_soc_dai_driver *dai_drv, int num_dai);
481030e79f6SKuninori Morimoto void snd_soc_unregister_component(struct device *dev);
48258f30150SMaxime Ripard void snd_soc_unregister_component_by_driver(struct device *dev,
48358f30150SMaxime Ripard 			 const struct snd_soc_component_driver *component_driver);
4846fbea6b6SShengjiu Wang struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
4856fbea6b6SShengjiu Wang 							    const char *driver_name);
4867dd5d0d9SKuninori Morimoto struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
4877dd5d0d9SKuninori Morimoto 						   const char *driver_name);
488427d204cSLars-Peter Clausen 
489354a2142SMark Brown int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
4906f0c4226SJie Yang #ifdef CONFIG_SND_SOC_COMPRESS
4916f0c4226SJie Yang int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
4920b014d72SPierre-Louis Bossart #else
4930b014d72SPierre-Louis Bossart static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
4940b014d72SPierre-Louis Bossart {
4950b014d72SPierre-Louis Bossart 	return 0;
4960b014d72SPierre-Louis Bossart }
4976f0c4226SJie Yang #endif
49812a48a8cSMark Brown 
499ef2e8175SKuninori Morimoto void snd_soc_disconnect_sync(struct device *dev);
500ef2e8175SKuninori Morimoto 
50147c88fffSLiam Girdwood struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
5024468189fSKuninori Morimoto 				struct snd_soc_dai_link *dai_link);
50347c88fffSLiam Girdwood 
504208a1589SLars-Peter Clausen bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
505d9051d86SKuninori Morimoto 
506d9051d86SKuninori Morimoto void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
507d9051d86SKuninori Morimoto 			    int stream, int action);
508d9051d86SKuninori Morimoto static inline void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd,
509d9051d86SKuninori Morimoto 				     int stream)
510d9051d86SKuninori Morimoto {
511d9051d86SKuninori Morimoto 	snd_soc_runtime_action(rtd, stream, 1);
512d9051d86SKuninori Morimoto }
513d9051d86SKuninori Morimoto static inline void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd,
514d9051d86SKuninori Morimoto 				       int stream)
515d9051d86SKuninori Morimoto {
516d9051d86SKuninori Morimoto 	snd_soc_runtime_action(rtd, stream, -1);
517d9051d86SKuninori Morimoto }
518208a1589SLars-Peter Clausen 
5195854a464SSamuel Holland int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
5205854a464SSamuel Holland 			    struct snd_pcm_hardware *hw, int stream);
5215854a464SSamuel Holland 
522ce64c8b9SLars-Peter Clausen int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
523ce64c8b9SLars-Peter Clausen 	unsigned int dai_fmt);
524ce64c8b9SLars-Peter Clausen 
5251f5a4535STakashi Iwai #ifdef CONFIG_DMI
526345233d7SLiam Girdwood int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour);
5271f5a4535STakashi Iwai #else
5281f5a4535STakashi Iwai static inline int snd_soc_set_dmi_name(struct snd_soc_card *card,
5291f5a4535STakashi Iwai 				       const char *flavour)
5301f5a4535STakashi Iwai {
5311f5a4535STakashi Iwai 	return 0;
5321f5a4535STakashi Iwai }
5331f5a4535STakashi Iwai #endif
534345233d7SLiam Girdwood 
5357aae816dSMark Brown /* Utility functions to get clock rates from various things */
5367aae816dSMark Brown int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
537*f3ac3da7SKrzysztof Kozlowski int snd_soc_params_to_frame_size(const struct snd_pcm_hw_params *params);
538c0fa59dfSMark Brown int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
539*f3ac3da7SKrzysztof Kozlowski int snd_soc_params_to_bclk(const struct snd_pcm_hw_params *parms);
540*f3ac3da7SKrzysztof Kozlowski int snd_soc_tdm_params_to_bclk(const struct snd_pcm_hw_params *params,
5411ef34dd2SRichard Fitzgerald 			       int tdm_width, int tdm_slots, int slot_multiple);
5427aae816dSMark Brown 
543808db4a4SRichard Purdie /* set runtime hw params */
544808db4a4SRichard Purdie int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
545808db4a4SRichard Purdie 	const struct snd_pcm_hardware *hw);
546808db4a4SRichard Purdie 
547c95869e5SKuninori Morimoto struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
548c95869e5SKuninori Morimoto struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
5497361fbeaSLars-Peter Clausen 	unsigned int id, unsigned int id_mask);
550c95869e5SKuninori Morimoto void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
551808db4a4SRichard Purdie 
552576ce407SArnd Bergmann #ifdef CONFIG_SND_SOC_AC97_BUS
553b047e1ccSMark Brown int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
554741a509fSMarkus Pargmann int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
555741a509fSMarkus Pargmann 		struct platform_device *pdev);
556b047e1ccSMark Brown 
557336b8423SLars-Peter Clausen extern struct snd_ac97_bus_ops *soc_ac97_ops;
558336b8423SLars-Peter Clausen #else
559336b8423SLars-Peter Clausen static inline int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
560336b8423SLars-Peter Clausen 	struct platform_device *pdev)
561336b8423SLars-Peter Clausen {
562336b8423SLars-Peter Clausen 	return 0;
563336b8423SLars-Peter Clausen }
564336b8423SLars-Peter Clausen 
565336b8423SLars-Peter Clausen static inline int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
566336b8423SLars-Peter Clausen {
567336b8423SLars-Peter Clausen 	return 0;
568336b8423SLars-Peter Clausen }
569336b8423SLars-Peter Clausen #endif
570336b8423SLars-Peter Clausen 
571808db4a4SRichard Purdie /*
572808db4a4SRichard Purdie  *Controls
573808db4a4SRichard Purdie  */
574808db4a4SRichard Purdie struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
5753056557fSMark Brown 				  void *data, const char *long_name,
576efb7ac3fSMark Brown 				  const char *prefix);
5770f2780adSLars-Peter Clausen int snd_soc_add_component_controls(struct snd_soc_component *component,
5780f2780adSLars-Peter Clausen 	const struct snd_kcontrol_new *controls, unsigned int num_controls);
579022658beSLiam Girdwood int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
580022658beSLiam Girdwood 	const struct snd_kcontrol_new *controls, int num_controls);
581022658beSLiam Girdwood int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
582022658beSLiam Girdwood 	const struct snd_kcontrol_new *controls, int num_controls);
583808db4a4SRichard Purdie int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
584808db4a4SRichard Purdie 	struct snd_ctl_elem_info *uinfo);
585808db4a4SRichard Purdie int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
586808db4a4SRichard Purdie 	struct snd_ctl_elem_value *ucontrol);
587808db4a4SRichard Purdie int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
588808db4a4SRichard Purdie 	struct snd_ctl_elem_value *ucontrol);
589808db4a4SRichard Purdie int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
590808db4a4SRichard Purdie 	struct snd_ctl_elem_info *uinfo);
59134198710SCharles Keepax int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
59234198710SCharles Keepax 			  struct snd_ctl_elem_info *uinfo);
593392abe9cSPhilipp Zabel #define snd_soc_info_bool_ext		snd_ctl_boolean_mono_info
594808db4a4SRichard Purdie int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
595808db4a4SRichard Purdie 	struct snd_ctl_elem_value *ucontrol);
596808db4a4SRichard Purdie int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
597808db4a4SRichard Purdie 	struct snd_ctl_elem_value *ucontrol);
598a92f1394SPeter Ujfalusi #define snd_soc_get_volsw_2r snd_soc_get_volsw
599a92f1394SPeter Ujfalusi #define snd_soc_put_volsw_2r snd_soc_put_volsw
6001d99f243SBrian Austin int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
6011d99f243SBrian Austin 	struct snd_ctl_elem_value *ucontrol);
6021d99f243SBrian Austin int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
6031d99f243SBrian Austin 	struct snd_ctl_elem_value *ucontrol);
6046c9d8cf6SAdam Thomson int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
6056c9d8cf6SAdam Thomson 	struct snd_ctl_elem_info *uinfo);
6066c9d8cf6SAdam Thomson int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
6076c9d8cf6SAdam Thomson 	struct snd_ctl_elem_value *ucontrol);
6086c9d8cf6SAdam Thomson int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
6096c9d8cf6SAdam Thomson 	struct snd_ctl_elem_value *ucontrol);
61026d9ca34SLars-Peter Clausen int snd_soc_limit_volume(struct snd_soc_card *card,
611637d3847SPeter Ujfalusi 	const char *name, int max);
61271d08516SMark Brown int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
61371d08516SMark Brown 		       struct snd_ctl_elem_info *uinfo);
61471d08516SMark Brown int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
61571d08516SMark Brown 		      struct snd_ctl_elem_value *ucontrol);
61671d08516SMark Brown int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
61771d08516SMark Brown 		      struct snd_ctl_elem_value *ucontrol);
618d9881208SVinod Koul int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
619d9881208SVinod Koul 	struct snd_ctl_elem_info *ucontrol);
6207523a271SOmair Mohammed Abdullah int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
6217523a271SOmair Mohammed Abdullah 	unsigned int size, unsigned int __user *tlv);
6224183eed2SKristoffer KARLSSON int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
6234183eed2SKristoffer KARLSSON 	struct snd_ctl_elem_info *uinfo);
6244183eed2SKristoffer KARLSSON int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
6254183eed2SKristoffer KARLSSON 	struct snd_ctl_elem_value *ucontrol);
6264183eed2SKristoffer KARLSSON int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
6274183eed2SKristoffer KARLSSON 	struct snd_ctl_elem_value *ucontrol);
628dd7b10b3SKristoffer KARLSSON int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
629dd7b10b3SKristoffer KARLSSON 	struct snd_ctl_elem_value *ucontrol);
630dd7b10b3SKristoffer KARLSSON int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
631dd7b10b3SKristoffer KARLSSON 	struct snd_ctl_elem_value *ucontrol);
632808db4a4SRichard Purdie 
633356caf66SKuninori Morimoto enum snd_soc_trigger_order {
634356caf66SKuninori Morimoto 						/* start			stop		     */
635356caf66SKuninori Morimoto 	SND_SOC_TRIGGER_ORDER_DEFAULT	= 0,	/* Link->Component->DAI		DAI->Component->Link */
636356caf66SKuninori Morimoto 	SND_SOC_TRIGGER_ORDER_LDC,		/* Link->DAI->Component		Component->DAI->Link */
637356caf66SKuninori Morimoto 
638356caf66SKuninori Morimoto 	SND_SOC_TRIGGER_ORDER_MAX,
639356caf66SKuninori Morimoto };
640356caf66SKuninori Morimoto 
641808db4a4SRichard Purdie /* SoC PCM stream information */
642808db4a4SRichard Purdie struct snd_soc_pcm_stream {
643f0fba2adSLiam Girdwood 	const char *stream_name;
6441c433fbdSGraeme Gregory 	u64 formats;			/* SNDRV_PCM_FMTBIT_* */
6454a6ba09eSCezary Rojewski 	u32 subformats;			/* for S32_LE format, SNDRV_PCM_SUBFMTBIT_* */
6461c433fbdSGraeme Gregory 	unsigned int rates;		/* SNDRV_PCM_RATE_* */
647808db4a4SRichard Purdie 	unsigned int rate_min;		/* min rate */
648808db4a4SRichard Purdie 	unsigned int rate_max;		/* max rate */
649808db4a4SRichard Purdie 	unsigned int channels_min;	/* min channels */
650808db4a4SRichard Purdie 	unsigned int channels_max;	/* max channels */
65158ba9b25SMark Brown 	unsigned int sig_bits;		/* number of bits of content */
652808db4a4SRichard Purdie };
653808db4a4SRichard Purdie 
654808db4a4SRichard Purdie /* SoC audio ops */
655808db4a4SRichard Purdie struct snd_soc_ops {
656808db4a4SRichard Purdie 	int (*startup)(struct snd_pcm_substream *);
657808db4a4SRichard Purdie 	void (*shutdown)(struct snd_pcm_substream *);
658808db4a4SRichard Purdie 	int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
659808db4a4SRichard Purdie 	int (*hw_free)(struct snd_pcm_substream *);
660808db4a4SRichard Purdie 	int (*prepare)(struct snd_pcm_substream *);
661808db4a4SRichard Purdie 	int (*trigger)(struct snd_pcm_substream *, int);
662808db4a4SRichard Purdie };
663808db4a4SRichard Purdie 
66449681077SVinod Koul struct snd_soc_compr_ops {
66549681077SVinod Koul 	int (*startup)(struct snd_compr_stream *);
66649681077SVinod Koul 	void (*shutdown)(struct snd_compr_stream *);
66749681077SVinod Koul 	int (*set_params)(struct snd_compr_stream *);
66849681077SVinod Koul };
66949681077SVinod Koul 
670a0ac4411SKuninori Morimoto struct snd_soc_component*
671a0ac4411SKuninori Morimoto snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
672a0ac4411SKuninori Morimoto 		       const char *driver_name);
673a0ac4411SKuninori Morimoto 
67488bd870fSBenoit Cousson struct snd_soc_dai_link_component {
67588bd870fSBenoit Cousson 	const char *name;
676c362effeSJean-Francois Moine 	struct device_node *of_node;
67788bd870fSBenoit Cousson 	const char *dai_name;
678020b37d0SKrzysztof Kozlowski 	const struct of_phandle_args *dai_args;
67988bd870fSBenoit Cousson };
68088bd870fSBenoit Cousson 
68145cc50d1SKuninori Morimoto /*
68245cc50d1SKuninori Morimoto  * [dai_link->ch_maps Image sample]
68345cc50d1SKuninori Morimoto  *
68445cc50d1SKuninori Morimoto  *-------------------------
68545cc50d1SKuninori Morimoto  * CPU0 <---> Codec0
68645cc50d1SKuninori Morimoto  *
68745cc50d1SKuninori Morimoto  * ch-map[0].cpu = 0	ch-map[0].codec = 0
68845cc50d1SKuninori Morimoto  *
68945cc50d1SKuninori Morimoto  *-------------------------
69045cc50d1SKuninori Morimoto  * CPU0 <---> Codec0
69145cc50d1SKuninori Morimoto  * CPU1 <---> Codec1
69245cc50d1SKuninori Morimoto  * CPU2 <---> Codec2
69345cc50d1SKuninori Morimoto  *
69445cc50d1SKuninori Morimoto  * ch-map[0].cpu = 0	ch-map[0].codec = 0
69545cc50d1SKuninori Morimoto  * ch-map[1].cpu = 1	ch-map[1].codec = 1
69645cc50d1SKuninori Morimoto  * ch-map[2].cpu = 2	ch-map[2].codec = 2
69745cc50d1SKuninori Morimoto  *
69845cc50d1SKuninori Morimoto  *-------------------------
69945cc50d1SKuninori Morimoto  * CPU0 <---> Codec0
70045cc50d1SKuninori Morimoto  * CPU1 <-+-> Codec1
70145cc50d1SKuninori Morimoto  * CPU2 <-/
70245cc50d1SKuninori Morimoto  *
70345cc50d1SKuninori Morimoto  * ch-map[0].cpu = 0	ch-map[0].codec = 0
70445cc50d1SKuninori Morimoto  * ch-map[1].cpu = 1	ch-map[1].codec = 1
70545cc50d1SKuninori Morimoto  * ch-map[2].cpu = 2	ch-map[2].codec = 1
70645cc50d1SKuninori Morimoto  *
70745cc50d1SKuninori Morimoto  *-------------------------
70845cc50d1SKuninori Morimoto  * CPU0 <---> Codec0
70945cc50d1SKuninori Morimoto  * CPU1 <-+-> Codec1
71045cc50d1SKuninori Morimoto  *	  \-> Codec2
71145cc50d1SKuninori Morimoto  *
71245cc50d1SKuninori Morimoto  * ch-map[0].cpu = 0	ch-map[0].codec = 0
71345cc50d1SKuninori Morimoto  * ch-map[1].cpu = 1	ch-map[1].codec = 1
71445cc50d1SKuninori Morimoto  * ch-map[2].cpu = 1	ch-map[2].codec = 2
71545cc50d1SKuninori Morimoto  *
71645cc50d1SKuninori Morimoto  */
71745cc50d1SKuninori Morimoto struct snd_soc_dai_link_ch_map {
71845cc50d1SKuninori Morimoto 	unsigned int cpu;
71945cc50d1SKuninori Morimoto 	unsigned int codec;
720ac950278SBard Liao 	unsigned int ch_mask;
721ac950278SBard Liao };
722ac950278SBard Liao 
723808db4a4SRichard Purdie struct snd_soc_dai_link {
724f0fba2adSLiam Girdwood 	/* config - must be set by machine driver */
725f0fba2adSLiam Girdwood 	const char *name;			/* Codec name */
726f0fba2adSLiam Girdwood 	const char *stream_name;		/* Stream name */
72762bc79d3SKuninori Morimoto 
72862bc79d3SKuninori Morimoto 	/*
729bc92657aSStephen Warren 	 * You MAY specify the link's CPU-side device, either by device name,
730bc92657aSStephen Warren 	 * or by DT/OF node, but not both. If this information is omitted,
731bc92657aSStephen Warren 	 * the CPU-side DAI is matched using .cpu_dai_name only, which hence
732bc92657aSStephen Warren 	 * must be globally unique. These fields are currently typically used
733bc92657aSStephen Warren 	 * only for codec to codec links, or systems using device tree.
734bc92657aSStephen Warren 	 */
735bc92657aSStephen Warren 	/*
736bc92657aSStephen Warren 	 * You MAY specify the DAI name of the CPU DAI. If this information is
737bc92657aSStephen Warren 	 * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
738bc92657aSStephen Warren 	 * only, which only works well when that device exposes a single DAI.
739bc92657aSStephen Warren 	 */
74008a5841eSKuninori Morimoto 	struct snd_soc_dai_link_component *cpus;
74108a5841eSKuninori Morimoto 	unsigned int num_cpus;
74208a5841eSKuninori Morimoto 
74362bc79d3SKuninori Morimoto 	/*
744bc92657aSStephen Warren 	 * You MUST specify the link's codec, either by device name, or by
745bc92657aSStephen Warren 	 * DT/OF node, but not both.
746bc92657aSStephen Warren 	 */
747bc92657aSStephen Warren 	/* You MUST specify the DAI name within the codec */
74888bd870fSBenoit Cousson 	struct snd_soc_dai_link_component *codecs;
74988bd870fSBenoit Cousson 	unsigned int num_codecs;
75088bd870fSBenoit Cousson 
75145cc50d1SKuninori Morimoto 	/* num_ch_maps = max(num_cpu, num_codecs) */
75245cc50d1SKuninori Morimoto 	struct snd_soc_dai_link_ch_map *ch_maps;
75345cc50d1SKuninori Morimoto 
754bc92657aSStephen Warren 	/*
755bc92657aSStephen Warren 	 * You MAY specify the link's platform/PCM/DMA driver, either by
756bc92657aSStephen Warren 	 * device name, or by DT/OF node, but not both. Some forms of link
7571d768989SKuninori Morimoto 	 * do not need a platform. In such case, platforms are not mandatory.
758bc92657aSStephen Warren 	 */
759910fdcabSKuninori Morimoto 	struct snd_soc_dai_link_component *platforms;
760910fdcabSKuninori Morimoto 	unsigned int num_platforms;
761daecf46eSKuninori Morimoto 
7622f0ad491SMengdong Lin 	int id;	/* optional ID for machine driver link identification */
7634ccab3e7SLiam Girdwood 
7647ddc7f91SKuninori Morimoto 	/*
7657ddc7f91SKuninori Morimoto 	 * for Codec2Codec
7667ddc7f91SKuninori Morimoto 	 */
7677ddc7f91SKuninori Morimoto 	const struct snd_soc_pcm_stream *c2c_params;
7687ddc7f91SKuninori Morimoto 	unsigned int num_c2c_params;
7697ddc7f91SKuninori Morimoto 
77075d9ac46SMark Brown 	unsigned int dai_fmt;           /* format to set on init */
77175d9ac46SMark Brown 
77201d7584cSLiam Girdwood 	enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
77301d7584cSLiam Girdwood 
774f0fba2adSLiam Girdwood 	/* codec/machine specific init - e.g. add machine controls */
775f0fba2adSLiam Girdwood 	int (*init)(struct snd_soc_pcm_runtime *rtd);
77606f409d7SMark Brown 
77721a00fb3SPierre-Louis Bossart 	/* codec/machine specific exit - dual of init() */
77821a00fb3SPierre-Louis Bossart 	void (*exit)(struct snd_soc_pcm_runtime *rtd);
77921a00fb3SPierre-Louis Bossart 
78001d7584cSLiam Girdwood 	/* optional hw_params re-writing for BE and FE sync */
78101d7584cSLiam Girdwood 	int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
78201d7584cSLiam Girdwood 			struct snd_pcm_hw_params *params);
78301d7584cSLiam Girdwood 
784f0fba2adSLiam Girdwood 	/* machine stream operations */
78513aec722SLars-Peter Clausen 	const struct snd_soc_ops *ops;
78613aec722SLars-Peter Clausen 	const struct snd_soc_compr_ops *compr_ops;
787d6bead02SFabio Estevam 
788356caf66SKuninori Morimoto 	/*
789356caf66SKuninori Morimoto 	 * soc_pcm_trigger() start/stop sequence.
790356caf66SKuninori Morimoto 	 * see also
791356caf66SKuninori Morimoto 	 *	snd_soc_component_driver
792356caf66SKuninori Morimoto 	 *	soc_pcm_trigger()
793356caf66SKuninori Morimoto 	 */
794356caf66SKuninori Morimoto 	enum snd_soc_trigger_order trigger_start;
795356caf66SKuninori Morimoto 	enum snd_soc_trigger_order trigger_stop;
796356caf66SKuninori Morimoto 
7972dc0f16bSKuninori Morimoto 	/* Mark this pcm with non atomic ops */
798317ec675SKuninori Morimoto 	unsigned int nonatomic:1;
7992dc0f16bSKuninori Morimoto 
8001236fa1eSKuninori Morimoto 	/* For unidirectional dai links */
8011236fa1eSKuninori Morimoto 	unsigned int playback_only:1;
8021236fa1eSKuninori Morimoto 	unsigned int capture_only:1;
8031236fa1eSKuninori Morimoto 
8042dc0f16bSKuninori Morimoto 	/* Keep DAI active over suspend */
8052dc0f16bSKuninori Morimoto 	unsigned int ignore_suspend:1;
8062dc0f16bSKuninori Morimoto 
8072dc0f16bSKuninori Morimoto 	/* Symmetry requirements */
808f14654ddSKuninori Morimoto 	unsigned int symmetric_rate:1;
8092dc0f16bSKuninori Morimoto 	unsigned int symmetric_channels:1;
810f14654ddSKuninori Morimoto 	unsigned int symmetric_sample_bits:1;
8112dc0f16bSKuninori Morimoto 
8122dc0f16bSKuninori Morimoto 	/* Do not create a PCM for this DAI link (Backend link) */
8132dc0f16bSKuninori Morimoto 	unsigned int no_pcm:1;
8142dc0f16bSKuninori Morimoto 
8152dc0f16bSKuninori Morimoto 	/* This DAI link can route to other DAI links at runtime (Frontend)*/
8162dc0f16bSKuninori Morimoto 	unsigned int dynamic:1;
8172dc0f16bSKuninori Morimoto 
8182dc0f16bSKuninori Morimoto 	/* DPCM capture and Playback support */
8192dc0f16bSKuninori Morimoto 	unsigned int dpcm_capture:1;
8202dc0f16bSKuninori Morimoto 	unsigned int dpcm_playback:1;
8212dc0f16bSKuninori Morimoto 
822b073ed4eSKuninori Morimoto 	/* DPCM used FE & BE merged format */
823b073ed4eSKuninori Morimoto 	unsigned int dpcm_merged_format:1;
824f4c277b8SJiada Wang 	/* DPCM used FE & BE merged channel */
825f4c277b8SJiada Wang 	unsigned int dpcm_merged_chan:1;
826baacd8d1SJerome Brunet 	/* DPCM used FE & BE merged rate */
827baacd8d1SJerome Brunet 	unsigned int dpcm_merged_rate:1;
828b073ed4eSKuninori Morimoto 
8292dc0f16bSKuninori Morimoto 	/* pmdown_time is ignored at stop */
8302dc0f16bSKuninori Morimoto 	unsigned int ignore_pmdown_time:1;
831f8f80361SMengdong Lin 
832a655de80SLiam Girdwood 	/* Do not create a PCM for this DAI link (Backend link) */
833a655de80SLiam Girdwood 	unsigned int ignore:1;
834a655de80SLiam Girdwood 
835509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY
836f8f80361SMengdong Lin 	struct snd_soc_dobj dobj; /* For topology */
837509ba54fSKuninori Morimoto #endif
838808db4a4SRichard Purdie };
8394da40cb9SKuninori Morimoto 
840*f3ac3da7SKrzysztof Kozlowski static inline int snd_soc_link_num_ch_map(const struct snd_soc_dai_link *link)
841*f3ac3da7SKrzysztof Kozlowski {
84245cc50d1SKuninori Morimoto 	return max(link->num_cpus, link->num_codecs);
84345cc50d1SKuninori Morimoto }
84445cc50d1SKuninori Morimoto 
8454da40cb9SKuninori Morimoto static inline struct snd_soc_dai_link_component*
8461d5a2b5dSKuninori Morimoto snd_soc_link_to_cpu(struct snd_soc_dai_link *link, int n) {
8474da40cb9SKuninori Morimoto 	return &(link)->cpus[n];
8484da40cb9SKuninori Morimoto }
8494da40cb9SKuninori Morimoto 
8504da40cb9SKuninori Morimoto static inline struct snd_soc_dai_link_component*
8511d5a2b5dSKuninori Morimoto snd_soc_link_to_codec(struct snd_soc_dai_link *link, int n) {
8524da40cb9SKuninori Morimoto 	return &(link)->codecs[n];
8534da40cb9SKuninori Morimoto }
8544da40cb9SKuninori Morimoto 
8554da40cb9SKuninori Morimoto static inline struct snd_soc_dai_link_component*
8561d5a2b5dSKuninori Morimoto snd_soc_link_to_platform(struct snd_soc_dai_link *link, int n) {
8574da40cb9SKuninori Morimoto 	return &(link)->platforms[n];
8584da40cb9SKuninori Morimoto }
8594da40cb9SKuninori Morimoto 
8603db769f1SKuninori Morimoto #define for_each_link_codecs(link, i, codec)				\
8613db769f1SKuninori Morimoto 	for ((i) = 0;							\
8624da40cb9SKuninori Morimoto 	     ((i) < link->num_codecs) &&				\
8631d5a2b5dSKuninori Morimoto 		     ((codec) = snd_soc_link_to_codec(link, i));		\
8643db769f1SKuninori Morimoto 	     (i)++)
865808db4a4SRichard Purdie 
86634614739SJerome Brunet #define for_each_link_platforms(link, i, platform)			\
86734614739SJerome Brunet 	for ((i) = 0;							\
86834614739SJerome Brunet 	     ((i) < link->num_platforms) &&				\
8691d5a2b5dSKuninori Morimoto 		     ((platform) = snd_soc_link_to_platform(link, i));	\
87034614739SJerome Brunet 	     (i)++)
87134614739SJerome Brunet 
87276afa643SShreyas NC #define for_each_link_cpus(link, i, cpu)				\
87376afa643SShreyas NC 	for ((i) = 0;							\
8744da40cb9SKuninori Morimoto 	     ((i) < link->num_cpus) &&					\
8751d5a2b5dSKuninori Morimoto 		     ((cpu) = snd_soc_link_to_cpu(link, i));		\
87676afa643SShreyas NC 	     (i)++)
87776afa643SShreyas NC 
87845cc50d1SKuninori Morimoto #define for_each_link_ch_maps(link, i, ch_map)			\
87945cc50d1SKuninori Morimoto 	for ((i) = 0;						\
88045cc50d1SKuninori Morimoto 	     ((i) < snd_soc_link_num_ch_map(link) &&		\
88145cc50d1SKuninori Morimoto 		      ((ch_map) = link->ch_maps + i));		\
88245cc50d1SKuninori Morimoto 	     (i)++)
88345cc50d1SKuninori Morimoto 
884587c9844SKuninori Morimoto /*
885587c9844SKuninori Morimoto  * Sample 1 : Single CPU/Codec/Platform
886587c9844SKuninori Morimoto  *
887587c9844SKuninori Morimoto  * SND_SOC_DAILINK_DEFS(test,
888587c9844SKuninori Morimoto  *	DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")),
889587c9844SKuninori Morimoto  *	DAILINK_COMP_ARRAY(COMP_CODEC("codec", "codec_dai")),
890587c9844SKuninori Morimoto  *	DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
891587c9844SKuninori Morimoto  *
892587c9844SKuninori Morimoto  * struct snd_soc_dai_link link = {
893587c9844SKuninori Morimoto  *	...
894587c9844SKuninori Morimoto  *	SND_SOC_DAILINK_REG(test),
895587c9844SKuninori Morimoto  * };
896587c9844SKuninori Morimoto  *
897587c9844SKuninori Morimoto  * Sample 2 : Multi CPU/Codec, no Platform
898587c9844SKuninori Morimoto  *
899587c9844SKuninori Morimoto  * SND_SOC_DAILINK_DEFS(test,
900587c9844SKuninori Morimoto  *	DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
901587c9844SKuninori Morimoto  *			   COMP_CPU("cpu_dai2")),
902587c9844SKuninori Morimoto  *	DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
903587c9844SKuninori Morimoto  *			   COMP_CODEC("codec2", "codec_dai2")));
904587c9844SKuninori Morimoto  *
905587c9844SKuninori Morimoto  * struct snd_soc_dai_link link = {
906587c9844SKuninori Morimoto  *	...
907587c9844SKuninori Morimoto  *	SND_SOC_DAILINK_REG(test),
908587c9844SKuninori Morimoto  * };
909587c9844SKuninori Morimoto  *
910587c9844SKuninori Morimoto  * Sample 3 : Define each CPU/Codec/Platform manually
911587c9844SKuninori Morimoto  *
912587c9844SKuninori Morimoto  * SND_SOC_DAILINK_DEF(test_cpu,
913587c9844SKuninori Morimoto  *		DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
914587c9844SKuninori Morimoto  *				   COMP_CPU("cpu_dai2")));
915587c9844SKuninori Morimoto  * SND_SOC_DAILINK_DEF(test_codec,
916587c9844SKuninori Morimoto  *		DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
917587c9844SKuninori Morimoto  *				   COMP_CODEC("codec2", "codec_dai2")));
918587c9844SKuninori Morimoto  * SND_SOC_DAILINK_DEF(test_platform,
919587c9844SKuninori Morimoto  *		DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
920587c9844SKuninori Morimoto  *
921587c9844SKuninori Morimoto  * struct snd_soc_dai_link link = {
922587c9844SKuninori Morimoto  *	...
923587c9844SKuninori Morimoto  *	SND_SOC_DAILINK_REG(test_cpu,
924587c9844SKuninori Morimoto  *			    test_codec,
925587c9844SKuninori Morimoto  *			    test_platform),
926587c9844SKuninori Morimoto  * };
927587c9844SKuninori Morimoto  *
928587c9844SKuninori Morimoto  * Sample 4 : Sample3 without platform
929587c9844SKuninori Morimoto  *
930587c9844SKuninori Morimoto  * struct snd_soc_dai_link link = {
931587c9844SKuninori Morimoto  *	...
932587c9844SKuninori Morimoto  *	SND_SOC_DAILINK_REG(test_cpu,
933587c9844SKuninori Morimoto  *			    test_codec);
934587c9844SKuninori Morimoto  * };
935587c9844SKuninori Morimoto  */
936587c9844SKuninori Morimoto 
937587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG1(name)	 SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms)
938587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG2(cpu, codec) SND_SOC_DAILINK_REG3(cpu, codec, null_dailink_component)
939587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG3(cpu, codec, platform)	\
940587c9844SKuninori Morimoto 	.cpus		= cpu,				\
941587c9844SKuninori Morimoto 	.num_cpus	= ARRAY_SIZE(cpu),		\
942587c9844SKuninori Morimoto 	.codecs		= codec,			\
943587c9844SKuninori Morimoto 	.num_codecs	= ARRAY_SIZE(codec),		\
944587c9844SKuninori Morimoto 	.platforms	= platform,			\
945587c9844SKuninori Morimoto 	.num_platforms	= ARRAY_SIZE(platform)
946587c9844SKuninori Morimoto 
947587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG(...) \
948428cc410SAndy Shevchenko 	CONCATENATE(SND_SOC_DAILINK_REG, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__)
949587c9844SKuninori Morimoto 
950587c9844SKuninori Morimoto #define SND_SOC_DAILINK_DEF(name, def...)		\
951587c9844SKuninori Morimoto 	static struct snd_soc_dai_link_component name[]	= { def }
952587c9844SKuninori Morimoto 
953587c9844SKuninori Morimoto #define SND_SOC_DAILINK_DEFS(name, cpu, codec, platform...)	\
954587c9844SKuninori Morimoto 	SND_SOC_DAILINK_DEF(name##_cpus, cpu);			\
955587c9844SKuninori Morimoto 	SND_SOC_DAILINK_DEF(name##_codecs, codec);		\
956587c9844SKuninori Morimoto 	SND_SOC_DAILINK_DEF(name##_platforms, platform)
957587c9844SKuninori Morimoto 
958587c9844SKuninori Morimoto #define DAILINK_COMP_ARRAY(param...)	param
959587c9844SKuninori Morimoto #define COMP_EMPTY()			{ }
960587c9844SKuninori Morimoto #define COMP_CPU(_dai)			{ .dai_name = _dai, }
961587c9844SKuninori Morimoto #define COMP_CODEC(_name, _dai)		{ .name = _name, .dai_name = _dai, }
962587c9844SKuninori Morimoto #define COMP_PLATFORM(_name)		{ .name = _name }
9633dc29b8bSKuninori Morimoto #define COMP_AUX(_name)			{ .name = _name }
964c13493a2SKuninori Morimoto #define COMP_CODEC_CONF(_name)		{ .name = _name }
96513f58267SKuninori Morimoto #define COMP_DUMMY()			/* see snd_soc_fill_dummy_dai() */
966587c9844SKuninori Morimoto 
967587c9844SKuninori Morimoto extern struct snd_soc_dai_link_component null_dailink_component[0];
9681d5a2b5dSKuninori Morimoto extern struct snd_soc_dai_link_component snd_soc_dummy_dlc;
969587c9844SKuninori Morimoto 
970587c9844SKuninori Morimoto 
971ff819b83SDimitris Papastamos struct snd_soc_codec_conf {
9723ca041edSSebastian Reichel 	/*
9733ca041edSSebastian Reichel 	 * specify device either by device name, or by
9743ca041edSSebastian Reichel 	 * DT/OF node, but not both.
9753ca041edSSebastian Reichel 	 */
976c13493a2SKuninori Morimoto 	struct snd_soc_dai_link_component dlc;
977c13493a2SKuninori Morimoto 
978ff819b83SDimitris Papastamos 	/*
979ff819b83SDimitris Papastamos 	 * optional map of kcontrol, widget and path name prefixes that are
980ff819b83SDimitris Papastamos 	 * associated per device
981ff819b83SDimitris Papastamos 	 */
982ead9b919SJarkko Nikula 	const char *name_prefix;
983ead9b919SJarkko Nikula };
984ead9b919SJarkko Nikula 
9852eea392dSJarkko Nikula struct snd_soc_aux_dev {
9863ca041edSSebastian Reichel 	/*
9873ca041edSSebastian Reichel 	 * specify multi-codec either by device name, or by
9883ca041edSSebastian Reichel 	 * DT/OF node, but not both.
9893ca041edSSebastian Reichel 	 */
9903dc29b8bSKuninori Morimoto 	struct snd_soc_dai_link_component dlc;
9913dc29b8bSKuninori Morimoto 
9922eea392dSJarkko Nikula 	/* codec/machine specific init - e.g. add machine controls */
99357bf7726SLars-Peter Clausen 	int (*init)(struct snd_soc_component *component);
9942eea392dSJarkko Nikula };
9952eea392dSJarkko Nikula 
99687506549SMark Brown /* SoC card */
99787506549SMark Brown struct snd_soc_card {
998f0fba2adSLiam Girdwood 	const char *name;
99922de71baSLiam Girdwood 	const char *long_name;
100022de71baSLiam Girdwood 	const char *driver_name;
1001dc73d73aSJaroslav Kysela 	const char *components;
10028a6a6a38SKuninori Morimoto #ifdef CONFIG_DMI
1003345233d7SLiam Girdwood 	char dmi_longname[80];
10048a6a6a38SKuninori Morimoto #endif /* CONFIG_DMI */
100547f56e38SRichard Fitzgerald 
100647f56e38SRichard Fitzgerald #ifdef CONFIG_PCI
100747f56e38SRichard Fitzgerald 	/*
100847f56e38SRichard Fitzgerald 	 * PCI does not define 0 as invalid, so pci_subsystem_set indicates
100947f56e38SRichard Fitzgerald 	 * whether a value has been written to these fields.
101047f56e38SRichard Fitzgerald 	 */
101147f56e38SRichard Fitzgerald 	unsigned short pci_subsystem_vendor;
101247f56e38SRichard Fitzgerald 	unsigned short pci_subsystem_device;
101347f56e38SRichard Fitzgerald 	bool pci_subsystem_set;
101447f56e38SRichard Fitzgerald #endif /* CONFIG_PCI */
101547f56e38SRichard Fitzgerald 
1016a655de80SLiam Girdwood 	char topology_shortname[32];
1017345233d7SLiam Girdwood 
1018c5af3a2eSMark Brown 	struct device *dev;
1019f0fba2adSLiam Girdwood 	struct snd_card *snd_card;
1020f0fba2adSLiam Girdwood 	struct module *owner;
1021c5af3a2eSMark Brown 
1022f0fba2adSLiam Girdwood 	struct mutex mutex;
1023a73fb2dfSLiam Girdwood 	struct mutex dapm_mutex;
1024c5af3a2eSMark Brown 
102572b745e3SPeter Ujfalusi 	/* Mutex for PCM operations */
102672b745e3SPeter Ujfalusi 	struct mutex pcm_mutex;
102772b745e3SPeter Ujfalusi 	enum snd_soc_pcm_subclass pcm_subclass;
102872b745e3SPeter Ujfalusi 
1029e7361ec4SMark Brown 	int (*probe)(struct snd_soc_card *card);
103028e9ad92SMark Brown 	int (*late_probe)(struct snd_soc_card *card);
1031df4d27b1SMartin Povišer 	void (*fixup_controls)(struct snd_soc_card *card);
1032e7361ec4SMark Brown 	int (*remove)(struct snd_soc_card *card);
1033808db4a4SRichard Purdie 
1034808db4a4SRichard Purdie 	/* the pre and post PM functions are used to do any PM work before and
1035808db4a4SRichard Purdie 	 * after the codec and DAI's do any PM work. */
103670b2ac12SMark Brown 	int (*suspend_pre)(struct snd_soc_card *card);
103770b2ac12SMark Brown 	int (*suspend_post)(struct snd_soc_card *card);
103870b2ac12SMark Brown 	int (*resume_pre)(struct snd_soc_card *card);
103970b2ac12SMark Brown 	int (*resume_post)(struct snd_soc_card *card);
1040808db4a4SRichard Purdie 
10410b4d221bSLiam Girdwood 	/* callbacks */
104287506549SMark Brown 	int (*set_bias_level)(struct snd_soc_card *,
1043d4c6005fSMark Brown 			      struct snd_soc_dapm_context *dapm,
10440be9898aSMark Brown 			      enum snd_soc_bias_level level);
10451badabd9SMark Brown 	int (*set_bias_level_post)(struct snd_soc_card *,
1046d4c6005fSMark Brown 				   struct snd_soc_dapm_context *dapm,
10471badabd9SMark Brown 				   enum snd_soc_bias_level level);
10480b4d221bSLiam Girdwood 
1049d6f220eaSMengdong Lin 	int (*add_dai_link)(struct snd_soc_card *,
1050d6f220eaSMengdong Lin 			    struct snd_soc_dai_link *link);
1051d6f220eaSMengdong Lin 	void (*remove_dai_link)(struct snd_soc_card *,
1052d6f220eaSMengdong Lin 			    struct snd_soc_dai_link *link);
1053d6f220eaSMengdong Lin 
10546c5f1fedSMark Brown 	long pmdown_time;
105596dd3622SMark Brown 
1056808db4a4SRichard Purdie 	/* CPU <--> Codec DAI links  */
1057f8f80361SMengdong Lin 	struct snd_soc_dai_link *dai_link;  /* predefined links only */
1058f8f80361SMengdong Lin 	int num_links;  /* predefined links only */
1059f8f80361SMengdong Lin 
10601a497983SMengdong Lin 	struct list_head rtd_list;
1061f0fba2adSLiam Girdwood 	int num_rtd;
10626308419aSMark Brown 
1063ff819b83SDimitris Papastamos 	/* optional codec specific configuration */
1064ff819b83SDimitris Papastamos 	struct snd_soc_codec_conf *codec_conf;
1065ff819b83SDimitris Papastamos 	int num_configs;
1066ead9b919SJarkko Nikula 
10672eea392dSJarkko Nikula 	/*
10682eea392dSJarkko Nikula 	 * optional auxiliary devices such as amplifiers or codecs with DAI
10692eea392dSJarkko Nikula 	 * link unused
10702eea392dSJarkko Nikula 	 */
10712eea392dSJarkko Nikula 	struct snd_soc_aux_dev *aux_dev;
10722eea392dSJarkko Nikula 	int num_aux_devs;
1073d2e3a135SSylwester Nawrocki 	struct list_head aux_comp_list;
10742eea392dSJarkko Nikula 
1075b7af1dafSMark Brown 	const struct snd_kcontrol_new *controls;
1076b7af1dafSMark Brown 	int num_controls;
1077b7af1dafSMark Brown 
1078b8ad29deSMark Brown 	/*
1079b8ad29deSMark Brown 	 * Card-specific routes and widgets.
1080f23e860eSNicolin Chen 	 * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
1081b8ad29deSMark Brown 	 */
1082d06e48dbSLars-Peter Clausen 	const struct snd_soc_dapm_widget *dapm_widgets;
1083b8ad29deSMark Brown 	int num_dapm_widgets;
1084d06e48dbSLars-Peter Clausen 	const struct snd_soc_dapm_route *dapm_routes;
1085b8ad29deSMark Brown 	int num_dapm_routes;
1086f23e860eSNicolin Chen 	const struct snd_soc_dapm_widget *of_dapm_widgets;
1087f23e860eSNicolin Chen 	int num_of_dapm_widgets;
1088f23e860eSNicolin Chen 	const struct snd_soc_dapm_route *of_dapm_routes;
1089f23e860eSNicolin Chen 	int num_of_dapm_routes;
1090b8ad29deSMark Brown 
1091f0fba2adSLiam Girdwood 	/* lists of probed devices belonging to this card */
1092d9fc4063SKuninori Morimoto 	struct list_head component_dev_list;
1093e894efefSSrinivas Kandagatla 	struct list_head list;
1094a6052154SJarkko Nikula 
109597c866deSJarkko Nikula 	struct list_head widgets;
10968ddab3f5SJarkko Nikula 	struct list_head paths;
10977be31be8SJarkko Nikula 	struct list_head dapm_list;
1098db432b41SMark Brown 	struct list_head dapm_dirty;
10998ddab3f5SJarkko Nikula 
11008a978234SLiam Girdwood 	/* attached dynamic objects */
11018a978234SLiam Girdwood 	struct list_head dobj_list;
11028a978234SLiam Girdwood 
1103e37a4970SMark Brown 	/* Generic DAPM context for the card */
1104e37a4970SMark Brown 	struct snd_soc_dapm_context dapm;
1105de02d078SMark Brown 	struct snd_soc_dapm_stats dapm_stats;
1106564c6504SLars-Peter Clausen 	struct snd_soc_dapm_update *update;
1107e37a4970SMark Brown 
1108a6052154SJarkko Nikula #ifdef CONFIG_DEBUG_FS
1109a6052154SJarkko Nikula 	struct dentry *debugfs_card_root;
1110a6052154SJarkko Nikula #endif
1111b3da4251SKuninori Morimoto #ifdef CONFIG_PM_SLEEP
1112b3da4251SKuninori Morimoto 	struct work_struct deferred_resume_work;
1113b3da4251SKuninori Morimoto #endif
11143a45b867SJarkko Nikula 	u32 pop_time;
1115dddf3e4cSMark Brown 
1116317ec675SKuninori Morimoto 	/* bit field */
1117317ec675SKuninori Morimoto 	unsigned int instantiated:1;
1118317ec675SKuninori Morimoto 	unsigned int topology_shortname_created:1;
1119317ec675SKuninori Morimoto 	unsigned int fully_routed:1;
1120317ec675SKuninori Morimoto 	unsigned int disable_route_checks:1;
112127f07cacSKuninori Morimoto 	unsigned int probed:1;
1122aa293777SSameer Pujar 	unsigned int component_chaining:1;
1123317ec675SKuninori Morimoto 
1124dddf3e4cSMark Brown 	void *drvdata;
1125808db4a4SRichard Purdie };
11267fe072b4SKuninori Morimoto #define for_each_card_prelinks(card, i, link)				\
11277fe072b4SKuninori Morimoto 	for ((i) = 0;							\
11287fe072b4SKuninori Morimoto 	     ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
11297fe072b4SKuninori Morimoto 	     (i)++)
1130c2b71c71SKuninori Morimoto #define for_each_card_pre_auxs(card, i, aux)				\
1131c2b71c71SKuninori Morimoto 	for ((i) = 0;							\
1132c2b71c71SKuninori Morimoto 	     ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \
1133c2b71c71SKuninori Morimoto 	     (i)++)
1134808db4a4SRichard Purdie 
1135bcb1fd1fSKuninori Morimoto #define for_each_card_rtds(card, rtd)			\
1136bcb1fd1fSKuninori Morimoto 	list_for_each_entry(rtd, &(card)->rtd_list, list)
1137bcb1fd1fSKuninori Morimoto #define for_each_card_rtds_safe(card, rtd, _rtd)	\
1138bcb1fd1fSKuninori Morimoto 	list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list)
113998061fdbSKuninori Morimoto 
1140c2b71c71SKuninori Morimoto #define for_each_card_auxs(card, component)			\
1141c2b71c71SKuninori Morimoto 	list_for_each_entry(component, &card->aux_comp_list, card_aux_list)
1142c2b71c71SKuninori Morimoto #define for_each_card_auxs_safe(card, component, _comp)	\
1143c2b71c71SKuninori Morimoto 	list_for_each_entry_safe(component, _comp,	\
1144c2b71c71SKuninori Morimoto 				 &card->aux_comp_list, card_aux_list)
1145c2b71c71SKuninori Morimoto 
1146f70f18f7SKuninori Morimoto #define for_each_card_components(card, component)			\
1147f70f18f7SKuninori Morimoto 	list_for_each_entry(component, &(card)->component_dev_list, card_list)
1148f70f18f7SKuninori Morimoto 
1149df817f8eSKuninori Morimoto #define for_each_card_dapms(card, dapm)					\
1150df817f8eSKuninori Morimoto 	list_for_each_entry(dapm, &card->dapm_list, list)
1151df817f8eSKuninori Morimoto 
115214596692SKuninori Morimoto #define for_each_card_widgets(card, w)\
115314596692SKuninori Morimoto 	list_for_each_entry(w, &card->widgets, list)
115414596692SKuninori Morimoto #define for_each_card_widgets_safe(card, w, _w)	\
115514596692SKuninori Morimoto 	list_for_each_entry_safe(w, _w, &card->widgets, list)
115614596692SKuninori Morimoto 
11572e5f8617SKuninori Morimoto 
11582e5f8617SKuninori Morimoto static inline int snd_soc_card_is_instantiated(struct snd_soc_card *card)
11592e5f8617SKuninori Morimoto {
11602e5f8617SKuninori Morimoto 	return card && card->instantiated;
11612e5f8617SKuninori Morimoto }
11622e5f8617SKuninori Morimoto 
1163f0fba2adSLiam Girdwood /* SoC machine DAI configuration, glues a codec and cpu DAI together */
1164808db4a4SRichard Purdie struct snd_soc_pcm_runtime {
116536ae1a96SMark Brown 	struct device *dev;
1166f0fba2adSLiam Girdwood 	struct snd_soc_card *card;
1167f0fba2adSLiam Girdwood 	struct snd_soc_dai_link *dai_link;
1168b8c0dab9SLiam Girdwood 	struct snd_pcm_ops ops;
1169f0fba2adSLiam Girdwood 
11707ddc7f91SKuninori Morimoto 	unsigned int c2c_params_select; /* currently selected c2c_param for dai link */
1171243bcfafSCharles Keepax 
117201d7584cSLiam Girdwood 	/* Dynamic PCM BE runtime data */
1173a26ec2acSKuninori Morimoto 	struct snd_soc_dpcm_runtime dpcm[SNDRV_PCM_STREAM_LAST + 1];
11743289dc02SKuninori Morimoto 	struct snd_soc_dapm_widget *c2c_widget[SNDRV_PCM_STREAM_LAST + 1];
117501d7584cSLiam Girdwood 
1176f0fba2adSLiam Girdwood 	long pmdown_time;
1177f0fba2adSLiam Girdwood 
1178f0fba2adSLiam Girdwood 	/* runtime devices */
1179f0fba2adSLiam Girdwood 	struct snd_pcm *pcm;
118049681077SVinod Koul 	struct snd_compr *compr;
11811729025bSKuninori Morimoto 
11821729025bSKuninori Morimoto 	/*
11831729025bSKuninori Morimoto 	 * dais = cpu_dai + codec_dai
11841729025bSKuninori Morimoto 	 * see
11851729025bSKuninori Morimoto 	 *	soc_new_pcm_runtime()
11861d5a2b5dSKuninori Morimoto 	 *	snd_soc_rtd_to_cpu()
11871d5a2b5dSKuninori Morimoto 	 *	snd_soc_rtd_to_codec()
11881729025bSKuninori Morimoto 	 */
118922a2fc81SKuninori Morimoto 	struct snd_soc_dai **dais;
119076afa643SShreyas NC 
1191f0fba2adSLiam Girdwood 	struct delayed_work delayed_work;
11924bf2e385SCurtis Malainey 	void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
1193f86dcef8SLiam Girdwood #ifdef CONFIG_DEBUG_FS
1194f86dcef8SLiam Girdwood 	struct dentry *debugfs_dpcm_root;
1195f86dcef8SLiam Girdwood #endif
11961a497983SMengdong Lin 
11971a497983SMengdong Lin 	unsigned int num; /* 0-based and monotonic increasing */
11981a497983SMengdong Lin 	struct list_head list; /* rtd list of the soc card */
1199a7df0d3bSKuninori Morimoto 
12006064ed73SKuninori Morimoto 	/* function mark */
12016064ed73SKuninori Morimoto 	struct snd_pcm_substream *mark_startup;
1202918ad772SKuninori Morimoto 	struct snd_pcm_substream *mark_hw_params;
12036374f493SKuninori Morimoto 	struct snd_pcm_substream *mark_trigger;
1204cd7c7d10SKuninori Morimoto 	struct snd_compr_stream  *mark_compr_startup;
12056064ed73SKuninori Morimoto 
1206a7df0d3bSKuninori Morimoto 	/* bit field */
1207a7df0d3bSKuninori Morimoto 	unsigned int pop_wait:1;
12087426af50SKuninori Morimoto 	unsigned int fe_compr:1; /* for Dynamic PCM */
1209613fb500SKuninori Morimoto 
1210dd9f9cc1SAmadeusz Sławiński 	bool initialized;
1211dd9f9cc1SAmadeusz Sławiński 
1212613fb500SKuninori Morimoto 	int num_components;
12132d6201eeSGustavo A. R. Silva 	struct snd_soc_component *components[]; /* CPU/Codec/Platform */
1214808db4a4SRichard Purdie };
12151d5a2b5dSKuninori Morimoto 
12162af69581SKuninori Morimoto /* see soc_new_pcm_runtime()  */
12171d5a2b5dSKuninori Morimoto #define snd_soc_rtd_to_cpu(rtd, n)   (rtd)->dais[n]
12181d5a2b5dSKuninori Morimoto #define snd_soc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->dai_link->num_cpus]
12199723cab0SKrzysztof Kozlowski 
12209723cab0SKrzysztof Kozlowski static inline struct snd_soc_pcm_runtime *
12219723cab0SKrzysztof Kozlowski snd_soc_substream_to_rtd(const struct snd_pcm_substream *substream)
12229723cab0SKrzysztof Kozlowski {
12239723cab0SKrzysztof Kozlowski 	return snd_pcm_substream_chip(substream);
12249723cab0SKrzysztof Kozlowski }
12252af69581SKuninori Morimoto 
1226613fb500SKuninori Morimoto #define for_each_rtd_components(rtd, i, component)			\
1227be16a0f0SArnd Bergmann 	for ((i) = 0, component = NULL;					\
1228613fb500SKuninori Morimoto 	     ((i) < rtd->num_components) && ((component) = rtd->components[i]);\
1229613fb500SKuninori Morimoto 	     (i)++)
1230995cbc3cSKuninori Morimoto #define for_each_rtd_cpu_dais(rtd, i, dai)				\
1231995cbc3cSKuninori Morimoto 	for ((i) = 0;							\
12321d5a2b5dSKuninori Morimoto 	     ((i) < rtd->dai_link->num_cpus) && ((dai) = snd_soc_rtd_to_cpu(rtd, i)); \
1233995cbc3cSKuninori Morimoto 	     (i)++)
1234995cbc3cSKuninori Morimoto #define for_each_rtd_codec_dais(rtd, i, dai)				\
1235995cbc3cSKuninori Morimoto 	for ((i) = 0;							\
12361d5a2b5dSKuninori Morimoto 	     ((i) < rtd->dai_link->num_codecs) && ((dai) = snd_soc_rtd_to_codec(rtd, i)); \
1237995cbc3cSKuninori Morimoto 	     (i)++)
123822a2fc81SKuninori Morimoto #define for_each_rtd_dais(rtd, i, dai)					\
123922a2fc81SKuninori Morimoto 	for ((i) = 0;							\
12403989ade2SKuninori Morimoto 	     ((i) < (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs) &&	\
124122a2fc81SKuninori Morimoto 		     ((dai) = (rtd)->dais[i]);				\
124222a2fc81SKuninori Morimoto 	     (i)++)
124331a70a71SCezary Rojewski #define for_each_rtd_dais_reverse(rtd, i, dai)					\
124431a70a71SCezary Rojewski 	for ((i) = (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs - 1;	\
124531a70a71SCezary Rojewski 	     (i) >= 0 && ((dai) = (rtd)->dais[i]);				\
124631a70a71SCezary Rojewski 	     (i)--)
124745cc50d1SKuninori Morimoto #define for_each_rtd_ch_maps(rtd, i, ch_maps) for_each_link_ch_maps(rtd->dai_link, i, ch_maps)
1248995cbc3cSKuninori Morimoto 
124983f94a2eSKuninori Morimoto void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);
1250808db4a4SRichard Purdie 
12514eaa9819SJon Smirl /* mixer control */
12524eaa9819SJon Smirl struct soc_mixer_control {
1253d11bb4a9SPeter Ujfalusi 	int min, max, platform_max;
1254249ce138SLars-Peter Clausen 	int reg, rreg;
1255249ce138SLars-Peter Clausen 	unsigned int shift, rshift;
1256f227b88fSMarkus Pargmann 	unsigned int sign_bit;
125757295073SLars-Peter Clausen 	unsigned int invert:1;
125857295073SLars-Peter Clausen 	unsigned int autodisable:1;
1259509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY
12608a978234SLiam Girdwood 	struct snd_soc_dobj dobj;
1261509ba54fSKuninori Morimoto #endif
12624eaa9819SJon Smirl };
12634eaa9819SJon Smirl 
126471d08516SMark Brown struct soc_bytes {
126571d08516SMark Brown 	int base;
126671d08516SMark Brown 	int num_regs;
1267f831b055SMark Brown 	u32 mask;
126871d08516SMark Brown };
126971d08516SMark Brown 
1270d9881208SVinod Koul struct soc_bytes_ext {
1271d9881208SVinod Koul 	int max;
1272509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY
12738a978234SLiam Girdwood 	struct snd_soc_dobj dobj;
1274509ba54fSKuninori Morimoto #endif
12757523a271SOmair Mohammed Abdullah 	/* used for TLV byte control */
1276a1e5e7e9SMythri P K 	int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
1277a1e5e7e9SMythri P K 			unsigned int size);
1278a1e5e7e9SMythri P K 	int (*put)(struct snd_kcontrol *kcontrol, const unsigned int __user *bytes,
1279a1e5e7e9SMythri P K 			unsigned int size);
1280d9881208SVinod Koul };
1281d9881208SVinod Koul 
12824183eed2SKristoffer KARLSSON /* multi register control */
12834183eed2SKristoffer KARLSSON struct soc_mreg_control {
12844183eed2SKristoffer KARLSSON 	long min, max;
12854183eed2SKristoffer KARLSSON 	unsigned int regbase, regcount, nbits, invert;
12864183eed2SKristoffer KARLSSON };
12874183eed2SKristoffer KARLSSON 
1288808db4a4SRichard Purdie /* enumerated kcontrol */
1289808db4a4SRichard Purdie struct soc_enum {
1290b948837aSLars-Peter Clausen 	int reg;
1291808db4a4SRichard Purdie 	unsigned char shift_l;
1292808db4a4SRichard Purdie 	unsigned char shift_r;
12939a8d38dbSTakashi Iwai 	unsigned int items;
12942e72f8e3SPeter Ujfalusi 	unsigned int mask;
129587023ff7STakashi Iwai 	const char * const *texts;
12962e72f8e3SPeter Ujfalusi 	const unsigned int *values;
1297561ed680SCharles Keepax 	unsigned int autodisable:1;
1298509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY
12998a978234SLiam Girdwood 	struct snd_soc_dobj dobj;
1300509ba54fSKuninori Morimoto #endif
13012e72f8e3SPeter Ujfalusi };
13022e72f8e3SPeter Ujfalusi 
1303*f3ac3da7SKrzysztof Kozlowski static inline bool snd_soc_volsw_is_stereo(const struct soc_mixer_control *mc)
130430d86ba4SPeter Ujfalusi {
130530d86ba4SPeter Ujfalusi 	if (mc->reg == mc->rreg && mc->shift == mc->rshift)
13064aa86e05SJason Yan 		return false;
130730d86ba4SPeter Ujfalusi 	/*
130830d86ba4SPeter Ujfalusi 	 * mc->reg == mc->rreg && mc->shift != mc->rshift, or
130930d86ba4SPeter Ujfalusi 	 * mc->reg != mc->rreg means that the control is
131030d86ba4SPeter Ujfalusi 	 * stereo (bits in one register or in two registers)
131130d86ba4SPeter Ujfalusi 	 */
13124aa86e05SJason Yan 	return true;
131330d86ba4SPeter Ujfalusi }
131430d86ba4SPeter Ujfalusi 
1315*f3ac3da7SKrzysztof Kozlowski static inline unsigned int snd_soc_enum_val_to_item(const struct soc_enum *e,
131629ae2fa5SLars-Peter Clausen 	unsigned int val)
131729ae2fa5SLars-Peter Clausen {
131829ae2fa5SLars-Peter Clausen 	unsigned int i;
131929ae2fa5SLars-Peter Clausen 
132029ae2fa5SLars-Peter Clausen 	if (!e->values)
132129ae2fa5SLars-Peter Clausen 		return val;
132229ae2fa5SLars-Peter Clausen 
132329ae2fa5SLars-Peter Clausen 	for (i = 0; i < e->items; i++)
132429ae2fa5SLars-Peter Clausen 		if (val == e->values[i])
132529ae2fa5SLars-Peter Clausen 			return i;
132629ae2fa5SLars-Peter Clausen 
132729ae2fa5SLars-Peter Clausen 	return 0;
132829ae2fa5SLars-Peter Clausen }
132929ae2fa5SLars-Peter Clausen 
1330*f3ac3da7SKrzysztof Kozlowski static inline unsigned int snd_soc_enum_item_to_val(const struct soc_enum *e,
133129ae2fa5SLars-Peter Clausen 	unsigned int item)
133229ae2fa5SLars-Peter Clausen {
133329ae2fa5SLars-Peter Clausen 	if (!e->values)
133429ae2fa5SLars-Peter Clausen 		return item;
133529ae2fa5SLars-Peter Clausen 
133629ae2fa5SLars-Peter Clausen 	return e->values[item];
133729ae2fa5SLars-Peter Clausen }
133829ae2fa5SLars-Peter Clausen 
1339ea53bf77SLars-Peter Clausen /**
1340907fe36aSLars-Peter Clausen  * snd_soc_kcontrol_component() - Returns the component that registered the
1341907fe36aSLars-Peter Clausen  *  control
1342907fe36aSLars-Peter Clausen  * @kcontrol: The control for which to get the component
1343907fe36aSLars-Peter Clausen  *
1344907fe36aSLars-Peter Clausen  * Note: This function will work correctly if the control has been registered
1345ef050becSCharles Keepax  * for a component. With snd_soc_add_codec_controls() or via table based
1346ef050becSCharles Keepax  * setup for either a CODEC or component driver. Otherwise the behavior is
1347ef050becSCharles Keepax  * undefined.
1348907fe36aSLars-Peter Clausen  */
1349907fe36aSLars-Peter Clausen static inline struct snd_soc_component *snd_soc_kcontrol_component(
1350907fe36aSLars-Peter Clausen 	struct snd_kcontrol *kcontrol)
1351907fe36aSLars-Peter Clausen {
1352907fe36aSLars-Peter Clausen 	return snd_kcontrol_chip(kcontrol);
1353907fe36aSLars-Peter Clausen }
1354907fe36aSLars-Peter Clausen 
1355fb257897SMark Brown int snd_soc_util_init(void);
1356fb257897SMark Brown void snd_soc_util_exit(void);
1357fb257897SMark Brown 
1358b07609ceSKuninori Morimoto int snd_soc_of_parse_card_name(struct snd_soc_card *card,
1359bec4fa05SStephen Warren 			       const char *propname);
136021efde50SKuninori Morimoto int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
13619a6d4860SXiubo Li 					  const char *propname);
13623d4641a4SStephan Gerhold int snd_soc_of_parse_pin_switches(struct snd_soc_card *card, const char *prop);
1363cbdfab3bSJerome Brunet int snd_soc_of_get_slot_mask(struct device_node *np,
1364cbdfab3bSJerome Brunet 			     const char *prop_name,
1365cbdfab3bSJerome Brunet 			     unsigned int *mask);
136689c67857SXiubo Li int snd_soc_of_parse_tdm_slot(struct device_node *np,
13676131084aSJyri Sarha 			      unsigned int *tx_mask,
13686131084aSJyri Sarha 			      unsigned int *rx_mask,
136989c67857SXiubo Li 			      unsigned int *slots,
137089c67857SXiubo Li 			      unsigned int *slot_width);
13713b710356SKuninori Morimoto void snd_soc_of_parse_node_prefix(struct device_node *np,
13725e3cdaa2SKuninori Morimoto 				   struct snd_soc_codec_conf *codec_conf,
13735e3cdaa2SKuninori Morimoto 				   struct device_node *of_node,
13745e3cdaa2SKuninori Morimoto 				   const char *propname);
13752708bccfSKuninori Morimoto static inline
13762708bccfSKuninori Morimoto void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
13772708bccfSKuninori Morimoto 				   struct snd_soc_codec_conf *codec_conf,
13782708bccfSKuninori Morimoto 				   struct device_node *of_node,
13792708bccfSKuninori Morimoto 				   const char *propname)
13802708bccfSKuninori Morimoto {
13812708bccfSKuninori Morimoto 	snd_soc_of_parse_node_prefix(card->dev->of_node,
13822708bccfSKuninori Morimoto 				     codec_conf, of_node, propname);
13832708bccfSKuninori Morimoto }
13843b710356SKuninori Morimoto 
13852bc644afSKuninori Morimoto int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
1386a4a54dd5SStephen Warren 				   const char *propname);
13871ae0965dSStephan Gerhold int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
1388b44a67f8SKuninori Morimoto 
138964c917d1SCharles Keepax unsigned int snd_soc_daifmt_clock_provider_flipped(unsigned int dai_fmt);
139091ae4477SKuninori Morimoto unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame);
13917766861dSKuninori Morimoto 
13927766861dSKuninori Morimoto unsigned int snd_soc_daifmt_parse_format(struct device_node *np, const char *prefix);
13937766861dSKuninori Morimoto unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
13947766861dSKuninori Morimoto 						     const char *prefix,
13957766861dSKuninori Morimoto 						     struct device_node **bitclkmaster,
13967766861dSKuninori Morimoto 						     struct device_node **framemaster);
13977766861dSKuninori Morimoto #define snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix)	\
13987766861dSKuninori Morimoto 	snd_soc_daifmt_parse_clock_provider_raw(np, prefix, NULL, NULL)
13997766861dSKuninori Morimoto #define snd_soc_daifmt_parse_clock_provider_as_phandle			\
14007766861dSKuninori Morimoto 	snd_soc_daifmt_parse_clock_provider_raw
14017766861dSKuninori Morimoto #define snd_soc_daifmt_parse_clock_provider_as_flag(np, prefix)		\
14027766861dSKuninori Morimoto 	snd_soc_daifmt_clock_provider_from_bitmap(			\
14037766861dSKuninori Morimoto 		snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix))
14047766861dSKuninori Morimoto 
1405*f3ac3da7SKrzysztof Kozlowski int snd_soc_get_stream_cpu(const struct snd_soc_dai_link *dai_link, int stream);
140605722a0cSKuninori Morimoto int snd_soc_get_dlc(const struct of_phandle_args *args,
140705722a0cSKuninori Morimoto 		    struct snd_soc_dai_link_component *dlc);
140805722a0cSKuninori Morimoto int snd_soc_of_get_dlc(struct device_node *of_node,
140905722a0cSKuninori Morimoto 		       struct of_phandle_args *args,
141005722a0cSKuninori Morimoto 		       struct snd_soc_dai_link_component *dlc,
141105722a0cSKuninori Morimoto 		       int index);
1412a180e8b9SKuninori Morimoto int snd_soc_get_dai_id(struct device_node *ep);
1413933f98beSKrzysztof Kozlowski int snd_soc_get_dai_name(const struct of_phandle_args *args,
14141ad8ec53SKuninori Morimoto 			 const char **dai_name);
1415cb470087SKuninori Morimoto int snd_soc_of_get_dai_name(struct device_node *of_node,
14163c8b5861SKuninori Morimoto 			    const char **dai_name, int index);
141793b0f3eeSJean-Francois Moine int snd_soc_of_get_dai_link_codecs(struct device *dev,
141893b0f3eeSJean-Francois Moine 				   struct device_node *of_node,
141993b0f3eeSJean-Francois Moine 				   struct snd_soc_dai_link *dai_link);
142094685763SSylwester Nawrocki void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
1421900dedd7SMartin Povišer int snd_soc_of_get_dai_link_cpus(struct device *dev,
1422900dedd7SMartin Povišer 				 struct device_node *of_node,
1423900dedd7SMartin Povišer 				 struct snd_soc_dai_link *dai_link);
1424900dedd7SMartin Povišer void snd_soc_of_put_dai_link_cpus(struct snd_soc_dai_link *dai_link);
1425bec4fa05SStephen Warren 
1426ffaf886eSKuninori Morimoto int snd_soc_add_pcm_runtimes(struct snd_soc_card *card,
1427ffaf886eSKuninori Morimoto 			     struct snd_soc_dai_link *dai_link,
1428ffaf886eSKuninori Morimoto 			     int num_dai_link);
142950cd9b53SKuninori Morimoto void snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
143050cd9b53SKuninori Morimoto 				struct snd_soc_pcm_runtime *rtd);
1431f8f80361SMengdong Lin 
1432988bad5eSKuninori Morimoto void snd_soc_dlc_use_cpu_as_platform(struct snd_soc_dai_link_component *platforms,
1433988bad5eSKuninori Morimoto 				     struct snd_soc_dai_link_component *cpus);
1434bbde4a30SKuninori Morimoto struct of_phandle_args *snd_soc_copy_dai_args(struct device *dev,
1435cf88ab48SKrzysztof Kozlowski 					      const struct of_phandle_args *args);
1436cf88ab48SKrzysztof Kozlowski struct snd_soc_dai *snd_soc_get_dai_via_args(const struct of_phandle_args *dai_args);
1437e443c205SKuninori Morimoto struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
14385d075197SKuninori Morimoto 					 struct snd_soc_dai_driver *dai_drv,
14395d075197SKuninori Morimoto 					 bool legacy_dai_naming);
14400fae253aSPierre-Louis Bossart struct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev,
14410fae253aSPierre-Louis Bossart 					      struct snd_soc_component *component,
14420fae253aSPierre-Louis Bossart 					      struct snd_soc_dai_driver *dai_drv,
14430fae253aSPierre-Louis Bossart 					      bool legacy_dai_naming);
1444e11381f3SKuninori Morimoto void snd_soc_unregister_dai(struct snd_soc_dai *dai);
144568003e6cSMengdong Lin 
1446305e9020SMengdong Lin struct snd_soc_dai *snd_soc_find_dai(
1447305e9020SMengdong Lin 	const struct snd_soc_dai_link_component *dlc);
1448c1c277b2SKuninori Morimoto struct snd_soc_dai *snd_soc_find_dai_with_mutex(
1449c1c277b2SKuninori Morimoto 	const struct snd_soc_dai_link_component *dlc);
1450305e9020SMengdong Lin 
1451a47cbe72SMark Brown #include <sound/soc-dai.h>
1452a47cbe72SMark Brown 
14537c761b59SPierre-Louis Bossart static inline
1454cb50358bSPierre-Louis Bossart int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
1455cb50358bSPierre-Louis Bossart 					  const char *platform_name)
1456cb50358bSPierre-Louis Bossart {
1457cb50358bSPierre-Louis Bossart 	struct snd_soc_dai_link *dai_link;
1458cb50358bSPierre-Louis Bossart 	const char *name;
1459cb50358bSPierre-Louis Bossart 	int i;
1460cb50358bSPierre-Louis Bossart 
1461cb50358bSPierre-Louis Bossart 	if (!platform_name) /* nothing to do */
1462cb50358bSPierre-Louis Bossart 		return 0;
1463cb50358bSPierre-Louis Bossart 
1464cb50358bSPierre-Louis Bossart 	/* set platform name for each dailink */
1465cb50358bSPierre-Louis Bossart 	for_each_card_prelinks(card, i, dai_link) {
1466d908b922SKuninori Morimoto 		/* only single platform is supported for now */
1467d908b922SKuninori Morimoto 		if (dai_link->num_platforms != 1)
1468d908b922SKuninori Morimoto 			return -EINVAL;
1469d908b922SKuninori Morimoto 
14704a50724eSKuninori Morimoto 		if (!dai_link->platforms)
14714a50724eSKuninori Morimoto 			return -EINVAL;
14724a50724eSKuninori Morimoto 
1473cb50358bSPierre-Louis Bossart 		name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
1474cb50358bSPierre-Louis Bossart 		if (!name)
1475cb50358bSPierre-Louis Bossart 			return -ENOMEM;
1476cb50358bSPierre-Louis Bossart 
1477cb50358bSPierre-Louis Bossart 		/* only single platform is supported for now */
1478cb50358bSPierre-Louis Bossart 		dai_link->platforms->name = name;
1479cb50358bSPierre-Louis Bossart 	}
1480cb50358bSPierre-Louis Bossart 
1481cb50358bSPierre-Louis Bossart 	return 0;
1482cb50358bSPierre-Louis Bossart }
1483cb50358bSPierre-Louis Bossart 
1484faff4bb0SStephen Warren #ifdef CONFIG_DEBUG_FS
14858a9dab1aSMark Brown extern struct dentry *snd_soc_debugfs_root;
1486faff4bb0SStephen Warren #endif
1487faff4bb0SStephen Warren 
14886f8ab4acSMark Brown extern const struct dev_pm_ops snd_soc_pm_ops;
14896f8ab4acSMark Brown 
14904a778bdcSKuninori Morimoto /*
14914a778bdcSKuninori Morimoto  *	DAPM helper functions
14924a778bdcSKuninori Morimoto  */
14934a778bdcSKuninori Morimoto enum snd_soc_dapm_subclass {
14944a778bdcSKuninori Morimoto 	SND_SOC_DAPM_CLASS_ROOT		= 0,
14954a778bdcSKuninori Morimoto 	SND_SOC_DAPM_CLASS_RUNTIME	= 1,
14964a778bdcSKuninori Morimoto };
14974a778bdcSKuninori Morimoto 
14984a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_root_c(struct snd_soc_card *card)
1499f6d5e586SCharles Keepax {
15004a778bdcSKuninori Morimoto 	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_ROOT);
1501f6d5e586SCharles Keepax }
1502f6d5e586SCharles Keepax 
15034a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_c(struct snd_soc_card *card)
1504f6d5e586SCharles Keepax {
15054a778bdcSKuninori Morimoto 	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
1506f6d5e586SCharles Keepax }
1507f6d5e586SCharles Keepax 
15084a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_unlock_c(struct snd_soc_card *card)
15094a778bdcSKuninori Morimoto {
15104a778bdcSKuninori Morimoto 	mutex_unlock(&card->dapm_mutex);
15114a778bdcSKuninori Morimoto }
15124a778bdcSKuninori Morimoto 
15134a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_assert_held_c(struct snd_soc_card *card)
15144a778bdcSKuninori Morimoto {
15154a778bdcSKuninori Morimoto 	lockdep_assert_held(&card->dapm_mutex);
15164a778bdcSKuninori Morimoto }
15174a778bdcSKuninori Morimoto 
15184a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_root_d(struct snd_soc_dapm_context *dapm)
15194a778bdcSKuninori Morimoto {
15204a778bdcSKuninori Morimoto 	_snd_soc_dapm_mutex_lock_root_c(dapm->card);
15214a778bdcSKuninori Morimoto }
15224a778bdcSKuninori Morimoto 
15234a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_d(struct snd_soc_dapm_context *dapm)
15244a778bdcSKuninori Morimoto {
15254a778bdcSKuninori Morimoto 	_snd_soc_dapm_mutex_lock_c(dapm->card);
15264a778bdcSKuninori Morimoto }
15274a778bdcSKuninori Morimoto 
15284a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_unlock_d(struct snd_soc_dapm_context *dapm)
15294a778bdcSKuninori Morimoto {
15304a778bdcSKuninori Morimoto 	_snd_soc_dapm_mutex_unlock_c(dapm->card);
15314a778bdcSKuninori Morimoto }
15324a778bdcSKuninori Morimoto 
15334a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_assert_held_d(struct snd_soc_dapm_context *dapm)
15344a778bdcSKuninori Morimoto {
15354a778bdcSKuninori Morimoto 	_snd_soc_dapm_mutex_assert_held_c(dapm->card);
15364a778bdcSKuninori Morimoto }
15374a778bdcSKuninori Morimoto 
15384a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_lock_root(x) _Generic((x),			\
15394a778bdcSKuninori Morimoto 	struct snd_soc_card * :		_snd_soc_dapm_mutex_lock_root_c, \
15404a778bdcSKuninori Morimoto 	struct snd_soc_dapm_context * :	_snd_soc_dapm_mutex_lock_root_d)(x)
15414a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_lock(x) _Generic((x),			\
15424a778bdcSKuninori Morimoto 	struct snd_soc_card * :		_snd_soc_dapm_mutex_lock_c,	\
15434a778bdcSKuninori Morimoto 	struct snd_soc_dapm_context * :	_snd_soc_dapm_mutex_lock_d)(x)
15444a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_unlock(x) _Generic((x),			\
15454a778bdcSKuninori Morimoto 	struct snd_soc_card * :		_snd_soc_dapm_mutex_unlock_c,	\
15464a778bdcSKuninori Morimoto 	struct snd_soc_dapm_context * :	_snd_soc_dapm_mutex_unlock_d)(x)
15474a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_assert_held(x) _Generic((x),			\
15484a778bdcSKuninori Morimoto 	struct snd_soc_card * :		_snd_soc_dapm_mutex_assert_held_c, \
15494a778bdcSKuninori Morimoto 	struct snd_soc_dapm_context * :	_snd_soc_dapm_mutex_assert_held_d)(x)
15504a778bdcSKuninori Morimoto 
155138e42f6dSKuninori Morimoto /*
155238e42f6dSKuninori Morimoto  *	PCM helper functions
155338e42f6dSKuninori Morimoto  */
155438e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_lock_c(struct snd_soc_card *card)
155538e42f6dSKuninori Morimoto {
155638e42f6dSKuninori Morimoto 	mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass);
155738e42f6dSKuninori Morimoto }
155838e42f6dSKuninori Morimoto 
155938e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_unlock_c(struct snd_soc_card *card)
156038e42f6dSKuninori Morimoto {
156138e42f6dSKuninori Morimoto 	mutex_unlock(&card->pcm_mutex);
156238e42f6dSKuninori Morimoto }
156338e42f6dSKuninori Morimoto 
156438e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_assert_held_c(struct snd_soc_card *card)
156538e42f6dSKuninori Morimoto {
156638e42f6dSKuninori Morimoto 	lockdep_assert_held(&card->pcm_mutex);
156738e42f6dSKuninori Morimoto }
156838e42f6dSKuninori Morimoto 
156938e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_lock_r(struct snd_soc_pcm_runtime *rtd)
157038e42f6dSKuninori Morimoto {
157138e42f6dSKuninori Morimoto 	_snd_soc_dpcm_mutex_lock_c(rtd->card);
157238e42f6dSKuninori Morimoto }
157338e42f6dSKuninori Morimoto 
157438e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_unlock_r(struct snd_soc_pcm_runtime *rtd)
157538e42f6dSKuninori Morimoto {
157638e42f6dSKuninori Morimoto 	_snd_soc_dpcm_mutex_unlock_c(rtd->card);
157738e42f6dSKuninori Morimoto }
157838e42f6dSKuninori Morimoto 
157938e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_assert_held_r(struct snd_soc_pcm_runtime *rtd)
158038e42f6dSKuninori Morimoto {
158138e42f6dSKuninori Morimoto 	_snd_soc_dpcm_mutex_assert_held_c(rtd->card);
158238e42f6dSKuninori Morimoto }
158338e42f6dSKuninori Morimoto 
158438e42f6dSKuninori Morimoto #define snd_soc_dpcm_mutex_lock(x) _Generic((x),			\
158538e42f6dSKuninori Morimoto 	 struct snd_soc_card * :	_snd_soc_dpcm_mutex_lock_c,	\
158638e42f6dSKuninori Morimoto 	 struct snd_soc_pcm_runtime * :	_snd_soc_dpcm_mutex_lock_r)(x)
158738e42f6dSKuninori Morimoto 
158838e42f6dSKuninori Morimoto #define snd_soc_dpcm_mutex_unlock(x) _Generic((x),			\
158938e42f6dSKuninori Morimoto 	 struct snd_soc_card * :	_snd_soc_dpcm_mutex_unlock_c,	\
159038e42f6dSKuninori Morimoto 	 struct snd_soc_pcm_runtime * :	_snd_soc_dpcm_mutex_unlock_r)(x)
159138e42f6dSKuninori Morimoto 
159238e42f6dSKuninori Morimoto #define snd_soc_dpcm_mutex_assert_held(x) _Generic((x),		\
159338e42f6dSKuninori Morimoto 	struct snd_soc_card * :		_snd_soc_dpcm_mutex_assert_held_c, \
159438e42f6dSKuninori Morimoto 	struct snd_soc_pcm_runtime * :	_snd_soc_dpcm_mutex_assert_held_r)(x)
159538e42f6dSKuninori Morimoto 
15964ff1fef1SKuninori Morimoto #include <sound/soc-component.h>
15971793936bSKuninori Morimoto #include <sound/soc-card.h>
1598ddfbe828SKuninori Morimoto #include <sound/soc-jack.h>
15991b4d9c22SRichard Fitzgerald 
1600808db4a4SRichard Purdie #endif
1601