xref: /linux/include/sound/soc.h (revision 389cb8348cf5ac4a702c71bf13673c4c8bf01e34)
1808db4a4SRichard Purdie /*
2808db4a4SRichard Purdie  * linux/sound/soc.h -- ALSA SoC Layer
3808db4a4SRichard Purdie  *
4808db4a4SRichard Purdie  * Author:		Liam Girdwood
5808db4a4SRichard Purdie  * Created:		Aug 11th 2005
6808db4a4SRichard Purdie  * Copyright:	Wolfson Microelectronics. PLC.
7808db4a4SRichard Purdie  *
8808db4a4SRichard Purdie  * This program is free software; you can redistribute it and/or modify
9808db4a4SRichard Purdie  * it under the terms of the GNU General Public License version 2 as
10808db4a4SRichard Purdie  * published by the Free Software Foundation.
11808db4a4SRichard Purdie  */
12808db4a4SRichard Purdie 
13808db4a4SRichard Purdie #ifndef __LINUX_SND_SOC_H
14808db4a4SRichard Purdie #define __LINUX_SND_SOC_H
15808db4a4SRichard Purdie 
16cb470087SKuninori Morimoto #include <linux/of.h>
17808db4a4SRichard Purdie #include <linux/platform_device.h>
18808db4a4SRichard Purdie #include <linux/types.h>
19d5021ec9SMark Brown #include <linux/notifier.h>
204484bb2eSAndrew Morton #include <linux/workqueue.h>
21ec67624dSLopez Cruz, Misael #include <linux/interrupt.h>
22ec67624dSLopez Cruz, Misael #include <linux/kernel.h>
23be3ea3b9SMark Brown #include <linux/regmap.h>
2486767b7dSLars-Peter Clausen #include <linux/log2.h>
25808db4a4SRichard Purdie #include <sound/core.h>
26808db4a4SRichard Purdie #include <sound/pcm.h>
2749681077SVinod Koul #include <sound/compress_driver.h>
28808db4a4SRichard Purdie #include <sound/control.h>
29808db4a4SRichard Purdie #include <sound/ac97_codec.h>
30808db4a4SRichard Purdie 
31808db4a4SRichard Purdie /*
32808db4a4SRichard Purdie  * Convenience kcontrol builders
33808db4a4SRichard Purdie  */
3457295073SLars-Peter Clausen #define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert, xautodisable) \
354eaa9819SJon Smirl 	((unsigned long)&(struct soc_mixer_control) \
3630d86ba4SPeter Ujfalusi 	{.reg = xreg, .rreg = xreg, .shift = shift_left, \
3730d86ba4SPeter Ujfalusi 	.rshift = shift_right, .max = xmax, .platform_max = xmax, \
3857295073SLars-Peter Clausen 	.invert = xinvert, .autodisable = xautodisable})
3957295073SLars-Peter Clausen #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, xautodisable) \
4057295073SLars-Peter Clausen 	SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert, xautodisable)
414eaa9819SJon Smirl #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
424eaa9819SJon Smirl 	((unsigned long)&(struct soc_mixer_control) \
43d11bb4a9SPeter Ujfalusi 	{.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert})
44cdffa775SPeter Ujfalusi #define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
45cdffa775SPeter Ujfalusi 	((unsigned long)&(struct soc_mixer_control) \
46cdffa775SPeter Ujfalusi 	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
47cdffa775SPeter Ujfalusi 	.max = xmax, .platform_max = xmax, .invert = xinvert})
48cd21b123SMarkus Pargmann #define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
49cd21b123SMarkus Pargmann 	((unsigned long)&(struct soc_mixer_control) \
50cd21b123SMarkus Pargmann 	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
51cd21b123SMarkus Pargmann 	.max = xmax, .min = xmin, .platform_max = xmax, .sign_bit = xsign_bit, \
52cd21b123SMarkus Pargmann 	.invert = xinvert})
53229e3fdcSMark Brown #define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
54229e3fdcSMark Brown 	((unsigned long)&(struct soc_mixer_control) \
55229e3fdcSMark Brown 	{.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
56229e3fdcSMark Brown 	.min = xmin, .max = xmax, .platform_max = xmax, .invert = xinvert})
57a7a4ac86SPhilipp Zabel #define SOC_SINGLE(xname, reg, shift, max, invert) \
58808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
59808db4a4SRichard Purdie 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
60808db4a4SRichard Purdie 	.put = snd_soc_put_volsw, \
6157295073SLars-Peter Clausen 	.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
626c9d8cf6SAdam Thomson #define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
636c9d8cf6SAdam Thomson {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
646c9d8cf6SAdam Thomson 	.info = snd_soc_info_volsw_range, .get = snd_soc_get_volsw_range, \
656c9d8cf6SAdam Thomson 	.put = snd_soc_put_volsw_range, \
666c9d8cf6SAdam Thomson 	.private_value = (unsigned long)&(struct soc_mixer_control) \
679bde4f0bSMark Brown 		{.reg = xreg, .rreg = xreg, .shift = xshift, \
689bde4f0bSMark Brown 		 .rshift = xshift,  .min = xmin, .max = xmax, \
699bde4f0bSMark Brown 		 .platform_max = xmax, .invert = xinvert} }
70a7a4ac86SPhilipp Zabel #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
71a7a4ac86SPhilipp Zabel {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
72a7a4ac86SPhilipp Zabel 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
73a7a4ac86SPhilipp Zabel 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
74a7a4ac86SPhilipp Zabel 	.tlv.p = (tlv_array), \
75a7a4ac86SPhilipp Zabel 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
76a7a4ac86SPhilipp Zabel 	.put = snd_soc_put_volsw, \
7757295073SLars-Peter Clausen 	.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
781d99f243SBrian Austin #define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
791d99f243SBrian Austin {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
801d99f243SBrian Austin 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
811d99f243SBrian Austin 	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
821d99f243SBrian Austin 	.tlv.p  = (tlv_array),\
831d99f243SBrian Austin 	.info = snd_soc_info_volsw, \
841d99f243SBrian Austin 	.get = snd_soc_get_volsw_sx,\
851d99f243SBrian Austin 	.put = snd_soc_put_volsw_sx, \
861d99f243SBrian Austin 	.private_value = (unsigned long)&(struct soc_mixer_control) \
871d99f243SBrian Austin 		{.reg = xreg, .rreg = xreg, \
881d99f243SBrian Austin 		.shift = xshift, .rshift = xshift, \
891d99f243SBrian Austin 		.max = xmax, .min = xmin} }
906c9d8cf6SAdam Thomson #define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \
916c9d8cf6SAdam Thomson {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
926c9d8cf6SAdam Thomson 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
936c9d8cf6SAdam Thomson 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
946c9d8cf6SAdam Thomson 	.tlv.p = (tlv_array), \
956c9d8cf6SAdam Thomson 	.info = snd_soc_info_volsw_range, \
966c9d8cf6SAdam Thomson 	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
976c9d8cf6SAdam Thomson 	.private_value = (unsigned long)&(struct soc_mixer_control) \
989bde4f0bSMark Brown 		{.reg = xreg, .rreg = xreg, .shift = xshift, \
999bde4f0bSMark Brown 		 .rshift = xshift, .min = xmin, .max = xmax, \
1009bde4f0bSMark Brown 		 .platform_max = xmax, .invert = xinvert} }
101460acbecSPeter Ujfalusi #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
102808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
103808db4a4SRichard Purdie 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
104808db4a4SRichard Purdie 	.put = snd_soc_put_volsw, \
105460acbecSPeter Ujfalusi 	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
10657295073SLars-Peter Clausen 					  max, invert, 0) }
1074eaa9819SJon Smirl #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
108808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
109e8f5a103SPeter Ujfalusi 	.info = snd_soc_info_volsw, \
110974815baSPeter Ujfalusi 	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
111cdffa775SPeter Ujfalusi 	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
112cdffa775SPeter Ujfalusi 					    xmax, xinvert) }
113229e3fdcSMark Brown #define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \
114229e3fdcSMark Brown 			   xmax, xinvert)		\
115229e3fdcSMark Brown {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
116229e3fdcSMark Brown 	.info = snd_soc_info_volsw_range, \
117229e3fdcSMark Brown 	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
118229e3fdcSMark Brown 	.private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
119229e3fdcSMark Brown 					    xshift, xmin, xmax, xinvert) }
120460acbecSPeter Ujfalusi #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
121a7a4ac86SPhilipp Zabel {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
122a7a4ac86SPhilipp Zabel 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
123a7a4ac86SPhilipp Zabel 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
124a7a4ac86SPhilipp Zabel 	.tlv.p = (tlv_array), \
125a7a4ac86SPhilipp Zabel 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
126a7a4ac86SPhilipp Zabel 	.put = snd_soc_put_volsw, \
127460acbecSPeter Ujfalusi 	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
12857295073SLars-Peter Clausen 					  max, invert, 0) }
1294eaa9819SJon Smirl #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
130a7a4ac86SPhilipp Zabel {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
131a7a4ac86SPhilipp Zabel 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
132a7a4ac86SPhilipp Zabel 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
133a7a4ac86SPhilipp Zabel 	.tlv.p = (tlv_array), \
134e8f5a103SPeter Ujfalusi 	.info = snd_soc_info_volsw, \
135974815baSPeter Ujfalusi 	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
136cdffa775SPeter Ujfalusi 	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
137cdffa775SPeter Ujfalusi 					    xmax, xinvert) }
138229e3fdcSMark Brown #define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \
139229e3fdcSMark Brown 			       xmax, xinvert, tlv_array)		\
140229e3fdcSMark Brown {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
141229e3fdcSMark Brown 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
142229e3fdcSMark Brown 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
143229e3fdcSMark Brown 	.tlv.p = (tlv_array), \
144229e3fdcSMark Brown 	.info = snd_soc_info_volsw_range, \
145229e3fdcSMark Brown 	.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
146229e3fdcSMark Brown 	.private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
147229e3fdcSMark Brown 					    xshift, xmin, xmax, xinvert) }
1481d99f243SBrian Austin #define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
1491d99f243SBrian Austin {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
1501d99f243SBrian Austin 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1511d99f243SBrian Austin 	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1521d99f243SBrian Austin 	.tlv.p  = (tlv_array), \
1531d99f243SBrian Austin 	.info = snd_soc_info_volsw, \
1541d99f243SBrian Austin 	.get = snd_soc_get_volsw_sx, \
1551d99f243SBrian Austin 	.put = snd_soc_put_volsw_sx, \
1561d99f243SBrian Austin 	.private_value = (unsigned long)&(struct soc_mixer_control) \
1571d99f243SBrian Austin 		{.reg = xreg, .rreg = xrreg, \
1581d99f243SBrian Austin 		.shift = xshift, .rshift = xshift, \
1591d99f243SBrian Austin 		.max = xmax, .min = xmin} }
160cd21b123SMarkus Pargmann #define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
161cd21b123SMarkus Pargmann {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
162cd21b123SMarkus Pargmann 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
163cd21b123SMarkus Pargmann 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
164cd21b123SMarkus Pargmann 	.tlv.p = (tlv_array), \
165cd21b123SMarkus Pargmann 	.info = snd_soc_info_volsw, \
166cd21b123SMarkus Pargmann 	.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
167cd21b123SMarkus Pargmann 	.private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
168cd21b123SMarkus Pargmann 					    xmin, xmax, xsign_bit, xinvert) }
1694eaa9819SJon Smirl #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
170e13ac2e9SMark Brown {	.iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
171e13ac2e9SMark Brown 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
172e13ac2e9SMark Brown 		  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
173e13ac2e9SMark Brown 	.tlv.p  = (tlv_array), \
174e13ac2e9SMark Brown 	.info   = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \
175e13ac2e9SMark Brown 	.put    = snd_soc_put_volsw_s8, \
1764eaa9819SJon Smirl 	.private_value = (unsigned long)&(struct soc_mixer_control) \
177d11bb4a9SPeter Ujfalusi 		{.reg = xreg, .min = xmin, .max = xmax, \
178d11bb4a9SPeter Ujfalusi 		 .platform_max = xmax} }
1799a8d38dbSTakashi Iwai #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
180808db4a4SRichard Purdie {	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
1819a8d38dbSTakashi Iwai 	.items = xitems, .texts = xtexts, \
1829a8d38dbSTakashi Iwai 	.mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
1839a8d38dbSTakashi Iwai #define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
1849a8d38dbSTakashi Iwai 	SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
1859a8d38dbSTakashi Iwai #define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
1869a8d38dbSTakashi Iwai {	.items = xitems, .texts = xtexts }
1879a8d38dbSTakashi Iwai #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
1882e72f8e3SPeter Ujfalusi {	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
1899a8d38dbSTakashi Iwai 	.mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
1909a8d38dbSTakashi Iwai #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xnitmes, xtexts, xvalues) \
1919a8d38dbSTakashi Iwai 	SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xnitmes, xtexts, xvalues)
192b948837aSLars-Peter Clausen #define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
193b948837aSLars-Peter Clausen 	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
194808db4a4SRichard Purdie #define SOC_ENUM(xname, xenum) \
195808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
196808db4a4SRichard Purdie 	.info = snd_soc_info_enum_double, \
197808db4a4SRichard Purdie 	.get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
198808db4a4SRichard Purdie 	.private_value = (unsigned long)&xenum }
1992e72f8e3SPeter Ujfalusi #define SOC_VALUE_ENUM(xname, xenum) \
20029ae2fa5SLars-Peter Clausen 	SOC_ENUM(xname, xenum)
201f8ba0b7bSJon Smirl #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
202808db4a4SRichard Purdie 	 xhandler_get, xhandler_put) \
203808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
2041c433fbdSGraeme Gregory 	.info = snd_soc_info_volsw, \
205808db4a4SRichard Purdie 	.get = xhandler_get, .put = xhandler_put, \
20657295073SLars-Peter Clausen 	.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
207460acbecSPeter Ujfalusi #define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
2087629ad24SDaniel Mack 	 xhandler_get, xhandler_put) \
2097629ad24SDaniel Mack {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
2107629ad24SDaniel Mack 	.info = snd_soc_info_volsw, \
2117629ad24SDaniel Mack 	.get = xhandler_get, .put = xhandler_put, \
212460acbecSPeter Ujfalusi 	.private_value = \
21357295073SLars-Peter Clausen 		SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) }
214f8ba0b7bSJon Smirl #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
21510144c09SMike Montour 	 xhandler_get, xhandler_put, tlv_array) \
21610144c09SMike Montour {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
21710144c09SMike Montour 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
21810144c09SMike Montour 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
21910144c09SMike Montour 	.tlv.p = (tlv_array), \
22010144c09SMike Montour 	.info = snd_soc_info_volsw, \
22110144c09SMike Montour 	.get = xhandler_get, .put = xhandler_put, \
22257295073SLars-Peter Clausen 	.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
223d0af93dbSJoonyoung Shim #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
224d0af93dbSJoonyoung Shim 	 xhandler_get, xhandler_put, tlv_array) \
225d0af93dbSJoonyoung Shim {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
226d0af93dbSJoonyoung Shim 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
227d0af93dbSJoonyoung Shim 		 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
228d0af93dbSJoonyoung Shim 	.tlv.p = (tlv_array), \
229d0af93dbSJoonyoung Shim 	.info = snd_soc_info_volsw, \
230d0af93dbSJoonyoung Shim 	.get = xhandler_get, .put = xhandler_put, \
231460acbecSPeter Ujfalusi 	.private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
23257295073SLars-Peter Clausen 					  xmax, xinvert, 0) }
2333ce91d5aSJoonyoung Shim #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
2343ce91d5aSJoonyoung Shim 	 xhandler_get, xhandler_put, tlv_array) \
2353ce91d5aSJoonyoung Shim {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
2363ce91d5aSJoonyoung Shim 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2373ce91d5aSJoonyoung Shim 		 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2383ce91d5aSJoonyoung Shim 	.tlv.p = (tlv_array), \
239e8f5a103SPeter Ujfalusi 	.info = snd_soc_info_volsw, \
2403ce91d5aSJoonyoung Shim 	.get = xhandler_get, .put = xhandler_put, \
241cdffa775SPeter Ujfalusi 	.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
242cdffa775SPeter Ujfalusi 					    xmax, xinvert) }
243808db4a4SRichard Purdie #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
244808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
245808db4a4SRichard Purdie 	.info = snd_soc_info_bool_ext, \
246808db4a4SRichard Purdie 	.get = xhandler_get, .put = xhandler_put, \
247808db4a4SRichard Purdie 	.private_value = xdata }
248808db4a4SRichard Purdie #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
249808db4a4SRichard Purdie {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
2509a953e6fSLars-Peter Clausen 	.info = snd_soc_info_enum_double, \
251808db4a4SRichard Purdie 	.get = xhandler_get, .put = xhandler_put, \
252808db4a4SRichard Purdie 	.private_value = (unsigned long)&xenum }
253808db4a4SRichard Purdie 
25471d08516SMark Brown #define SND_SOC_BYTES(xname, xbase, xregs)		      \
25571d08516SMark Brown {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
25671d08516SMark Brown 	.info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
25771d08516SMark Brown 	.put = snd_soc_bytes_put, .private_value =	      \
25871d08516SMark Brown 		((unsigned long)&(struct soc_bytes)           \
25971d08516SMark Brown 		{.base = xbase, .num_regs = xregs }) }
260b6f4bb38Sapatard@mandriva.com 
261f831b055SMark Brown #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask)	      \
262f831b055SMark Brown {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
263f831b055SMark Brown 	.info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
264f831b055SMark Brown 	.put = snd_soc_bytes_put, .private_value =	      \
265f831b055SMark Brown 		((unsigned long)&(struct soc_bytes)           \
266f831b055SMark Brown 		{.base = xbase, .num_regs = xregs,	      \
267f831b055SMark Brown 		 .mask = xmask }) }
268f831b055SMark Brown 
2694183eed2SKristoffer KARLSSON #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
2704183eed2SKristoffer KARLSSON 		xmin, xmax, xinvert) \
2714183eed2SKristoffer KARLSSON {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
2724183eed2SKristoffer KARLSSON 	.info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
2734183eed2SKristoffer KARLSSON 	.put = snd_soc_put_xr_sx, \
2744183eed2SKristoffer KARLSSON 	.private_value = (unsigned long)&(struct soc_mreg_control) \
2754183eed2SKristoffer KARLSSON 		{.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
2764183eed2SKristoffer KARLSSON 		.invert = xinvert, .min = xmin, .max = xmax} }
2774183eed2SKristoffer KARLSSON 
278dd7b10b3SKristoffer KARLSSON #define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
279dd7b10b3SKristoffer KARLSSON 	SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
280dd7b10b3SKristoffer KARLSSON 		snd_soc_get_strobe, snd_soc_put_strobe)
281dd7b10b3SKristoffer KARLSSON 
282808db4a4SRichard Purdie /*
2836c2fb6a8SGuennadi Liakhovetski  * Simplified versions of above macros, declaring a struct and calculating
2846c2fb6a8SGuennadi Liakhovetski  * ARRAY_SIZE internally
2856c2fb6a8SGuennadi Liakhovetski  */
2866c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
2872e7e1993STakashi Iwai 	const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
2886c2fb6a8SGuennadi Liakhovetski 						ARRAY_SIZE(xtexts), xtexts)
2896c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
2906c2fb6a8SGuennadi Liakhovetski 	SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
2916c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
2922e7e1993STakashi Iwai 	const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
2936c2fb6a8SGuennadi Liakhovetski #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
2942e7e1993STakashi Iwai 	const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
2956c2fb6a8SGuennadi Liakhovetski 							ARRAY_SIZE(xtexts), xtexts, xvalues)
2966c2fb6a8SGuennadi Liakhovetski #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
2976c2fb6a8SGuennadi Liakhovetski 	SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
298b948837aSLars-Peter Clausen #define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
299b948837aSLars-Peter Clausen 	const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
3006c2fb6a8SGuennadi Liakhovetski 
3016c2fb6a8SGuennadi Liakhovetski /*
3020168bf0dSLiam Girdwood  * Component probe and remove ordering levels for components with runtime
3030168bf0dSLiam Girdwood  * dependencies.
3040168bf0dSLiam Girdwood  */
3050168bf0dSLiam Girdwood #define SND_SOC_COMP_ORDER_FIRST		-2
3060168bf0dSLiam Girdwood #define SND_SOC_COMP_ORDER_EARLY		-1
3070168bf0dSLiam Girdwood #define SND_SOC_COMP_ORDER_NORMAL		0
3080168bf0dSLiam Girdwood #define SND_SOC_COMP_ORDER_LATE		1
3090168bf0dSLiam Girdwood #define SND_SOC_COMP_ORDER_LAST		2
3100168bf0dSLiam Girdwood 
3110168bf0dSLiam Girdwood /*
3120be9898aSMark Brown  * Bias levels
3130be9898aSMark Brown  *
3140be9898aSMark Brown  * @ON:      Bias is fully on for audio playback and capture operations.
3150be9898aSMark Brown  * @PREPARE: Prepare for audio operations. Called before DAPM switching for
3160be9898aSMark Brown  *           stream start and stop operations.
3170be9898aSMark Brown  * @STANDBY: Low power standby state when no playback/capture operations are
3180be9898aSMark Brown  *           in progress. NOTE: The transition time between STANDBY and ON
3190be9898aSMark Brown  *           should be as fast as possible and no longer than 10ms.
3200be9898aSMark Brown  * @OFF:     Power Off. No restrictions on transition times.
3210be9898aSMark Brown  */
3220be9898aSMark Brown enum snd_soc_bias_level {
32356fba41fSMark Brown 	SND_SOC_BIAS_OFF = 0,
32456fba41fSMark Brown 	SND_SOC_BIAS_STANDBY = 1,
32556fba41fSMark Brown 	SND_SOC_BIAS_PREPARE = 2,
32656fba41fSMark Brown 	SND_SOC_BIAS_ON = 3,
3270be9898aSMark Brown };
3280be9898aSMark Brown 
3295a504963SStephen Warren struct device_node;
3308a2cd618SMark Brown struct snd_jack;
3318a2cd618SMark Brown struct snd_soc_card;
332808db4a4SRichard Purdie struct snd_soc_pcm_stream;
333808db4a4SRichard Purdie struct snd_soc_ops;
334808db4a4SRichard Purdie struct snd_soc_pcm_runtime;
3353c4b266fSLiam Girdwood struct snd_soc_dai;
336f0fba2adSLiam Girdwood struct snd_soc_dai_driver;
33712a48a8cSMark Brown struct snd_soc_platform;
338d273ebe7Sjassi brar struct snd_soc_dai_link;
339f0fba2adSLiam Girdwood struct snd_soc_platform_driver;
340808db4a4SRichard Purdie struct snd_soc_codec;
341f0fba2adSLiam Girdwood struct snd_soc_codec_driver;
342030e79f6SKuninori Morimoto struct snd_soc_component;
343030e79f6SKuninori Morimoto struct snd_soc_component_driver;
344808db4a4SRichard Purdie struct soc_enum;
3458a2cd618SMark Brown struct snd_soc_jack;
346fa9879edSVinod Koul struct snd_soc_jack_zone;
3478a2cd618SMark Brown struct snd_soc_jack_pin;
348ce6120ccSLiam Girdwood #include <sound/soc-dapm.h>
34901d7584cSLiam Girdwood #include <sound/soc-dpcm.h>
350f0fba2adSLiam Girdwood 
351ec67624dSLopez Cruz, Misael struct snd_soc_jack_gpio;
352808db4a4SRichard Purdie 
353808db4a4SRichard Purdie typedef int (*hw_write_t)(void *,const char* ,int);
354808db4a4SRichard Purdie 
355b047e1ccSMark Brown extern struct snd_ac97_bus_ops *soc_ac97_ops;
356808db4a4SRichard Purdie 
357b8c0dab9SLiam Girdwood enum snd_soc_pcm_subclass {
358b8c0dab9SLiam Girdwood 	SND_SOC_PCM_CLASS_PCM	= 0,
359b8c0dab9SLiam Girdwood 	SND_SOC_PCM_CLASS_BE	= 1,
360b8c0dab9SLiam Girdwood };
361b8c0dab9SLiam Girdwood 
36201b9d99aSLiam Girdwood enum snd_soc_card_subclass {
36301b9d99aSLiam Girdwood 	SND_SOC_CARD_CLASS_INIT		= 0,
3646874a918SLiam Girdwood 	SND_SOC_CARD_CLASS_RUNTIME	= 1,
36501b9d99aSLiam Girdwood };
36601b9d99aSLiam Girdwood 
367ec4ee52aSMark Brown int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
368da1c6ea6SMark Brown 			     int source, unsigned int freq, int dir);
369ec4ee52aSMark Brown int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
370ec4ee52aSMark Brown 			  unsigned int freq_in, unsigned int freq_out);
371ec4ee52aSMark Brown 
37270a7ca34SVinod Koul int snd_soc_register_card(struct snd_soc_card *card);
37370a7ca34SVinod Koul int snd_soc_unregister_card(struct snd_soc_card *card);
3740e4ff5c8SMark Brown int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
3756f8ab4acSMark Brown int snd_soc_suspend(struct device *dev);
3766f8ab4acSMark Brown int snd_soc_resume(struct device *dev);
3776f8ab4acSMark Brown int snd_soc_poweroff(struct device *dev);
378f0fba2adSLiam Girdwood int snd_soc_register_platform(struct device *dev,
379d79e57dbSLars-Peter Clausen 		const struct snd_soc_platform_driver *platform_drv);
380f0fba2adSLiam Girdwood void snd_soc_unregister_platform(struct device *dev);
38171a45cdaSLars-Peter Clausen int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
38271a45cdaSLars-Peter Clausen 		const struct snd_soc_platform_driver *platform_drv);
38371a45cdaSLars-Peter Clausen void snd_soc_remove_platform(struct snd_soc_platform *platform);
38471a45cdaSLars-Peter Clausen struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev);
385f0fba2adSLiam Girdwood int snd_soc_register_codec(struct device *dev,
386001ae4c0SMark Brown 		const struct snd_soc_codec_driver *codec_drv,
387f0fba2adSLiam Girdwood 		struct snd_soc_dai_driver *dai_drv, int num_dai);
388f0fba2adSLiam Girdwood void snd_soc_unregister_codec(struct device *dev);
389030e79f6SKuninori Morimoto int snd_soc_register_component(struct device *dev,
390030e79f6SKuninori Morimoto 			 const struct snd_soc_component_driver *cmpnt_drv,
391030e79f6SKuninori Morimoto 			 struct snd_soc_dai_driver *dai_drv, int num_dai);
392a0b03a61SMark Brown int devm_snd_soc_register_component(struct device *dev,
393a0b03a61SMark Brown 			 const struct snd_soc_component_driver *cmpnt_drv,
394a0b03a61SMark Brown 			 struct snd_soc_dai_driver *dai_drv, int num_dai);
395030e79f6SKuninori Morimoto void snd_soc_unregister_component(struct device *dev);
396181e055eSMark Brown int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
397181e055eSMark Brown 				    unsigned int reg);
398239c9706SDimitris Papastamos int snd_soc_codec_readable_register(struct snd_soc_codec *codec,
399239c9706SDimitris Papastamos 				    unsigned int reg);
400239c9706SDimitris Papastamos int snd_soc_codec_writable_register(struct snd_soc_codec *codec,
401239c9706SDimitris Papastamos 				    unsigned int reg);
40217a52fd6SMark Brown int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
403092eba93SXiubo Li 			       struct regmap *regmap);
4047a30a3dbSDimitris Papastamos int snd_soc_cache_sync(struct snd_soc_codec *codec);
4057a30a3dbSDimitris Papastamos int snd_soc_cache_init(struct snd_soc_codec *codec);
4067a30a3dbSDimitris Papastamos int snd_soc_cache_exit(struct snd_soc_codec *codec);
4077a30a3dbSDimitris Papastamos int snd_soc_cache_write(struct snd_soc_codec *codec,
4087a30a3dbSDimitris Papastamos 			unsigned int reg, unsigned int value);
4097a30a3dbSDimitris Papastamos int snd_soc_cache_read(struct snd_soc_codec *codec,
4107a30a3dbSDimitris Papastamos 		       unsigned int reg, unsigned int *value);
411f1442bc1SLiam Girdwood int snd_soc_platform_read(struct snd_soc_platform *platform,
412f1442bc1SLiam Girdwood 					unsigned int reg);
413f1442bc1SLiam Girdwood int snd_soc_platform_write(struct snd_soc_platform *platform,
414f1442bc1SLiam Girdwood 					unsigned int reg, unsigned int val);
415354a2142SMark Brown int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
41649681077SVinod Koul int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
41712a48a8cSMark Brown 
41847c88fffSLiam Girdwood struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
41947c88fffSLiam Girdwood 		const char *dai_link, int stream);
42047c88fffSLiam Girdwood struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
42147c88fffSLiam Girdwood 		const char *dai_link);
42247c88fffSLiam Girdwood 
423208a1589SLars-Peter Clausen bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
42424894b76SLars-Peter Clausen void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream);
42524894b76SLars-Peter Clausen void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream);
426208a1589SLars-Peter Clausen 
4277aae816dSMark Brown /* Utility functions to get clock rates from various things */
4287aae816dSMark Brown int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
4297aae816dSMark Brown int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
430c0fa59dfSMark Brown int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
4317aae816dSMark Brown int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
4327aae816dSMark Brown 
433808db4a4SRichard Purdie /* set runtime hw params */
434808db4a4SRichard Purdie int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
435808db4a4SRichard Purdie 	const struct snd_pcm_hardware *hw);
436808db4a4SRichard Purdie 
43707bf84aaSLiam Girdwood int snd_soc_platform_trigger(struct snd_pcm_substream *substream,
43807bf84aaSLiam Girdwood 		int cmd, struct snd_soc_platform *platform);
43907bf84aaSLiam Girdwood 
4408a2cd618SMark Brown /* Jack reporting */
441f0fba2adSLiam Girdwood int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
4428a2cd618SMark Brown 		     struct snd_soc_jack *jack);
4438a2cd618SMark Brown void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
4448a2cd618SMark Brown int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
4458a2cd618SMark Brown 			  struct snd_soc_jack_pin *pins);
446d5021ec9SMark Brown void snd_soc_jack_notifier_register(struct snd_soc_jack *jack,
447d5021ec9SMark Brown 				    struct notifier_block *nb);
448d5021ec9SMark Brown void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
449d5021ec9SMark Brown 				      struct notifier_block *nb);
450fa9879edSVinod Koul int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count,
451fa9879edSVinod Koul 			  struct snd_soc_jack_zone *zones);
452fa9879edSVinod Koul int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage);
453ec67624dSLopez Cruz, Misael #ifdef CONFIG_GPIOLIB
454ec67624dSLopez Cruz, Misael int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
455ec67624dSLopez Cruz, Misael 			struct snd_soc_jack_gpio *gpios);
456ec67624dSLopez Cruz, Misael void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
457ec67624dSLopez Cruz, Misael 			struct snd_soc_jack_gpio *gpios);
4588778ac6bSTakashi Iwai #else
4598778ac6bSTakashi Iwai static inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
4608778ac6bSTakashi Iwai 					 struct snd_soc_jack_gpio *gpios)
4618778ac6bSTakashi Iwai {
4628778ac6bSTakashi Iwai 	return 0;
4638778ac6bSTakashi Iwai }
4648778ac6bSTakashi Iwai 
4658778ac6bSTakashi Iwai static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
4668778ac6bSTakashi Iwai 					   struct snd_soc_jack_gpio *gpios)
4678778ac6bSTakashi Iwai {
4688778ac6bSTakashi Iwai }
469ec67624dSLopez Cruz, Misael #endif
4708a2cd618SMark Brown 
471808db4a4SRichard Purdie /* codec register bit access */
472808db4a4SRichard Purdie int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
47346f5822fSDaniel Ribeiro 				unsigned int mask, unsigned int value);
474dd1b3d53SMark Brown int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
475dd1b3d53SMark Brown 			       unsigned short reg, unsigned int mask,
476dd1b3d53SMark Brown 			       unsigned int value);
477808db4a4SRichard Purdie int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
47846f5822fSDaniel Ribeiro 				unsigned int mask, unsigned int value);
479808db4a4SRichard Purdie 
480808db4a4SRichard Purdie int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
481808db4a4SRichard Purdie 	struct snd_ac97_bus_ops *ops, int num);
482808db4a4SRichard Purdie void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
483808db4a4SRichard Purdie 
484b047e1ccSMark Brown int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
485741a509fSMarkus Pargmann int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
486741a509fSMarkus Pargmann 		struct platform_device *pdev);
487b047e1ccSMark Brown 
488808db4a4SRichard Purdie /*
489808db4a4SRichard Purdie  *Controls
490808db4a4SRichard Purdie  */
491808db4a4SRichard Purdie struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
4923056557fSMark Brown 				  void *data, const char *long_name,
493efb7ac3fSMark Brown 				  const char *prefix);
4944fefd698SDimitris Papastamos struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
4954fefd698SDimitris Papastamos 					       const char *name);
496022658beSLiam Girdwood int snd_soc_add_codec_controls(struct snd_soc_codec *codec,
4973e8e1952SIan Molton 	const struct snd_kcontrol_new *controls, int num_controls);
498a491a5c8SLiam Girdwood int snd_soc_add_platform_controls(struct snd_soc_platform *platform,
499a491a5c8SLiam Girdwood 	const struct snd_kcontrol_new *controls, int num_controls);
500022658beSLiam Girdwood int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
501022658beSLiam Girdwood 	const struct snd_kcontrol_new *controls, int num_controls);
502022658beSLiam Girdwood int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
503022658beSLiam Girdwood 	const struct snd_kcontrol_new *controls, int num_controls);
504808db4a4SRichard Purdie int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
505808db4a4SRichard Purdie 	struct snd_ctl_elem_info *uinfo);
506808db4a4SRichard Purdie int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
507808db4a4SRichard Purdie 	struct snd_ctl_elem_value *ucontrol);
508808db4a4SRichard Purdie int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
509808db4a4SRichard Purdie 	struct snd_ctl_elem_value *ucontrol);
510808db4a4SRichard Purdie int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
511808db4a4SRichard Purdie 	struct snd_ctl_elem_info *uinfo);
512392abe9cSPhilipp Zabel #define snd_soc_info_bool_ext		snd_ctl_boolean_mono_info
513808db4a4SRichard Purdie int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
514808db4a4SRichard Purdie 	struct snd_ctl_elem_value *ucontrol);
515808db4a4SRichard Purdie int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
516808db4a4SRichard Purdie 	struct snd_ctl_elem_value *ucontrol);
517a92f1394SPeter Ujfalusi #define snd_soc_get_volsw_2r snd_soc_get_volsw
518a92f1394SPeter Ujfalusi #define snd_soc_put_volsw_2r snd_soc_put_volsw
5191d99f243SBrian Austin int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
5201d99f243SBrian Austin 	struct snd_ctl_elem_value *ucontrol);
5211d99f243SBrian Austin int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
5221d99f243SBrian Austin 	struct snd_ctl_elem_value *ucontrol);
523e13ac2e9SMark Brown int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
524e13ac2e9SMark Brown 	struct snd_ctl_elem_info *uinfo);
525e13ac2e9SMark Brown int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
526e13ac2e9SMark Brown 	struct snd_ctl_elem_value *ucontrol);
527e13ac2e9SMark Brown int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
528e13ac2e9SMark Brown 	struct snd_ctl_elem_value *ucontrol);
5296c9d8cf6SAdam Thomson int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
5306c9d8cf6SAdam Thomson 	struct snd_ctl_elem_info *uinfo);
5316c9d8cf6SAdam Thomson int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
5326c9d8cf6SAdam Thomson 	struct snd_ctl_elem_value *ucontrol);
5336c9d8cf6SAdam Thomson int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
5346c9d8cf6SAdam Thomson 	struct snd_ctl_elem_value *ucontrol);
535637d3847SPeter Ujfalusi int snd_soc_limit_volume(struct snd_soc_codec *codec,
536637d3847SPeter Ujfalusi 	const char *name, int max);
53771d08516SMark Brown int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
53871d08516SMark Brown 		       struct snd_ctl_elem_info *uinfo);
53971d08516SMark Brown int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
54071d08516SMark Brown 		      struct snd_ctl_elem_value *ucontrol);
54171d08516SMark Brown int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
54271d08516SMark Brown 		      struct snd_ctl_elem_value *ucontrol);
5434183eed2SKristoffer KARLSSON int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
5444183eed2SKristoffer KARLSSON 	struct snd_ctl_elem_info *uinfo);
5454183eed2SKristoffer KARLSSON int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
5464183eed2SKristoffer KARLSSON 	struct snd_ctl_elem_value *ucontrol);
5474183eed2SKristoffer KARLSSON int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
5484183eed2SKristoffer KARLSSON 	struct snd_ctl_elem_value *ucontrol);
549dd7b10b3SKristoffer KARLSSON int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
550dd7b10b3SKristoffer KARLSSON 	struct snd_ctl_elem_value *ucontrol);
551dd7b10b3SKristoffer KARLSSON int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
552dd7b10b3SKristoffer KARLSSON 	struct snd_ctl_elem_value *ucontrol);
553808db4a4SRichard Purdie 
5548a2cd618SMark Brown /**
5558a2cd618SMark Brown  * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
5568a2cd618SMark Brown  *
5578a2cd618SMark Brown  * @pin:    name of the pin to update
5588a2cd618SMark Brown  * @mask:   bits to check for in reported jack status
5598a2cd618SMark Brown  * @invert: if non-zero then pin is enabled when status is not reported
5608a2cd618SMark Brown  */
5618a2cd618SMark Brown struct snd_soc_jack_pin {
5628a2cd618SMark Brown 	struct list_head list;
5638a2cd618SMark Brown 	const char *pin;
5648a2cd618SMark Brown 	int mask;
5658a2cd618SMark Brown 	bool invert;
5668a2cd618SMark Brown };
5678a2cd618SMark Brown 
568ec67624dSLopez Cruz, Misael /**
569fa9879edSVinod Koul  * struct snd_soc_jack_zone - Describes voltage zones of jack detection
570fa9879edSVinod Koul  *
571fa9879edSVinod Koul  * @min_mv: start voltage in mv
572fa9879edSVinod Koul  * @max_mv: end voltage in mv
573fa9879edSVinod Koul  * @jack_type: type of jack that is expected for this voltage
574fa9879edSVinod Koul  * @debounce_time: debounce_time for jack, codec driver should wait for this
575fa9879edSVinod Koul  *		duration before reading the adc for voltages
576fa9879edSVinod Koul  * @:list: list container
577fa9879edSVinod Koul  */
578fa9879edSVinod Koul struct snd_soc_jack_zone {
579fa9879edSVinod Koul 	unsigned int min_mv;
580fa9879edSVinod Koul 	unsigned int max_mv;
581fa9879edSVinod Koul 	unsigned int jack_type;
582fa9879edSVinod Koul 	unsigned int debounce_time;
583fa9879edSVinod Koul 	struct list_head list;
584fa9879edSVinod Koul };
585fa9879edSVinod Koul 
586fa9879edSVinod Koul /**
587ec67624dSLopez Cruz, Misael  * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection
588ec67624dSLopez Cruz, Misael  *
589ec67624dSLopez Cruz, Misael  * @gpio:         gpio number
590ec67624dSLopez Cruz, Misael  * @name:         gpio name
591ec67624dSLopez Cruz, Misael  * @report:       value to report when jack detected
592ec67624dSLopez Cruz, Misael  * @invert:       report presence in low state
593ec67624dSLopez Cruz, Misael  * @debouce_time: debouce time in ms
5947887ab3aSMark Brown  * @wake:	  enable as wake source
595fadddc87SMark Brown  * @jack_status_check: callback function which overrides the detection
596fadddc87SMark Brown  *		       to provide more complex checks (eg, reading an
597fadddc87SMark Brown  *		       ADC).
598ec67624dSLopez Cruz, Misael  */
599ec67624dSLopez Cruz, Misael struct snd_soc_jack_gpio {
600ec67624dSLopez Cruz, Misael 	unsigned int gpio;
601ec67624dSLopez Cruz, Misael 	const char *name;
602ec67624dSLopez Cruz, Misael 	int report;
603ec67624dSLopez Cruz, Misael 	int invert;
604ec67624dSLopez Cruz, Misael 	int debounce_time;
6057887ab3aSMark Brown 	bool wake;
6067887ab3aSMark Brown 
607ec67624dSLopez Cruz, Misael 	struct snd_soc_jack *jack;
6084c14d78eSMark Brown 	struct delayed_work work;
609c871a053SJoonyoung Shim 
610cb29d7b9Sxiangxiao 	void *data;
611cb29d7b9Sxiangxiao 	int (*jack_status_check)(void *data);
612ec67624dSLopez Cruz, Misael };
613ec67624dSLopez Cruz, Misael 
6148a2cd618SMark Brown struct snd_soc_jack {
6152667b4b8SMark Brown 	struct mutex mutex;
6168a2cd618SMark Brown 	struct snd_jack *jack;
617f0fba2adSLiam Girdwood 	struct snd_soc_codec *codec;
6188a2cd618SMark Brown 	struct list_head pins;
6198a2cd618SMark Brown 	int status;
620d5021ec9SMark Brown 	struct blocking_notifier_head notifier;
621fa9879edSVinod Koul 	struct list_head jack_zones;
6228a2cd618SMark Brown };
6238a2cd618SMark Brown 
624808db4a4SRichard Purdie /* SoC PCM stream information */
625808db4a4SRichard Purdie struct snd_soc_pcm_stream {
626f0fba2adSLiam Girdwood 	const char *stream_name;
6271c433fbdSGraeme Gregory 	u64 formats;			/* SNDRV_PCM_FMTBIT_* */
6281c433fbdSGraeme Gregory 	unsigned int rates;		/* SNDRV_PCM_RATE_* */
629808db4a4SRichard Purdie 	unsigned int rate_min;		/* min rate */
630808db4a4SRichard Purdie 	unsigned int rate_max;		/* max rate */
631808db4a4SRichard Purdie 	unsigned int channels_min;	/* min channels */
632808db4a4SRichard Purdie 	unsigned int channels_max;	/* max channels */
63358ba9b25SMark Brown 	unsigned int sig_bits;		/* number of bits of content */
634808db4a4SRichard Purdie };
635808db4a4SRichard Purdie 
636808db4a4SRichard Purdie /* SoC audio ops */
637808db4a4SRichard Purdie struct snd_soc_ops {
638808db4a4SRichard Purdie 	int (*startup)(struct snd_pcm_substream *);
639808db4a4SRichard Purdie 	void (*shutdown)(struct snd_pcm_substream *);
640808db4a4SRichard Purdie 	int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
641808db4a4SRichard Purdie 	int (*hw_free)(struct snd_pcm_substream *);
642808db4a4SRichard Purdie 	int (*prepare)(struct snd_pcm_substream *);
643808db4a4SRichard Purdie 	int (*trigger)(struct snd_pcm_substream *, int);
644808db4a4SRichard Purdie };
645808db4a4SRichard Purdie 
64649681077SVinod Koul struct snd_soc_compr_ops {
64749681077SVinod Koul 	int (*startup)(struct snd_compr_stream *);
64849681077SVinod Koul 	void (*shutdown)(struct snd_compr_stream *);
64949681077SVinod Koul 	int (*set_params)(struct snd_compr_stream *);
65049681077SVinod Koul 	int (*trigger)(struct snd_compr_stream *);
65149681077SVinod Koul };
65249681077SVinod Koul 
653d191bd8dSKuninori Morimoto /* component interface */
654d191bd8dSKuninori Morimoto struct snd_soc_component_driver {
655d191bd8dSKuninori Morimoto 	const char *name;
656cb470087SKuninori Morimoto 
657cb470087SKuninori Morimoto 	/* DT */
658cb470087SKuninori Morimoto 	int (*of_xlate_dai_name)(struct snd_soc_component *component,
659cb470087SKuninori Morimoto 				 struct of_phandle_args *args,
660cb470087SKuninori Morimoto 				 const char **dai_name);
661d191bd8dSKuninori Morimoto };
662d191bd8dSKuninori Morimoto 
663d191bd8dSKuninori Morimoto struct snd_soc_component {
664d191bd8dSKuninori Morimoto 	const char *name;
665d191bd8dSKuninori Morimoto 	int id;
666d191bd8dSKuninori Morimoto 	struct device *dev;
667cdde4ccbSLars-Peter Clausen 
668cdde4ccbSLars-Peter Clausen 	unsigned int active;
669cdde4ccbSLars-Peter Clausen 
6703d59400fSLars-Peter Clausen 	unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
6713d59400fSLars-Peter Clausen 
672d191bd8dSKuninori Morimoto 	struct list_head list;
673d191bd8dSKuninori Morimoto 
6746833c452SKuninori Morimoto 	struct snd_soc_dai_driver *dai_drv;
6756833c452SKuninori Morimoto 	int num_dai;
6766833c452SKuninori Morimoto 
677d191bd8dSKuninori Morimoto 	const struct snd_soc_component_driver *driver;
6781438c2f6SLars-Peter Clausen 
6791438c2f6SLars-Peter Clausen 	struct list_head dai_list;
680d191bd8dSKuninori Morimoto };
681d191bd8dSKuninori Morimoto 
682f0fba2adSLiam Girdwood /* SoC Audio Codec device */
683808db4a4SRichard Purdie struct snd_soc_codec {
684f0fba2adSLiam Girdwood 	const char *name;
685ead9b919SJarkko Nikula 	const char *name_prefix;
686f0fba2adSLiam Girdwood 	int id;
6870d0cf00aSMark Brown 	struct device *dev;
688001ae4c0SMark Brown 	const struct snd_soc_codec_driver *driver;
6890d0cf00aSMark Brown 
690f0fba2adSLiam Girdwood 	struct mutex mutex;
691f0fba2adSLiam Girdwood 	struct snd_soc_card *card;
6920d0cf00aSMark Brown 	struct list_head list;
693f0fba2adSLiam Girdwood 	struct list_head card_list;
694f0fba2adSLiam Girdwood 	int num_dai;
6951500b7b5SDimitris Papastamos 	int (*volatile_register)(struct snd_soc_codec *, unsigned int);
6961500b7b5SDimitris Papastamos 	int (*readable_register)(struct snd_soc_codec *, unsigned int);
6978020454cSDimitris Papastamos 	int (*writable_register)(struct snd_soc_codec *, unsigned int);
698808db4a4SRichard Purdie 
699808db4a4SRichard Purdie 	/* runtime */
700808db4a4SRichard Purdie 	struct snd_ac97 *ac97;  /* for ad-hoc ac97 devices */
701dad8e7aeSDimitris Papastamos 	unsigned int cache_bypass:1; /* Suppress access to the cache */
702f0fba2adSLiam Girdwood 	unsigned int suspended:1; /* Codec is in suspend PM state */
703f0fba2adSLiam Girdwood 	unsigned int probed:1; /* Codec has been probed */
704f0fba2adSLiam Girdwood 	unsigned int ac97_registered:1; /* Codec has been AC97 registered */
7050562f788SMika Westerberg 	unsigned int ac97_created:1; /* Codec has been created by SoC */
706fdf0f54dSDimitris Papastamos 	unsigned int cache_init:1; /* codec cache has been initialized */
7078a713da8SMark Brown 	unsigned int using_regmap:1; /* using regmap access */
708aaee8ef1SMark Brown 	u32 cache_only;  /* Suppress writes to hardware */
709aaee8ef1SMark Brown 	u32 cache_sync; /* Cache needs to be synced to hardware */
710f0fba2adSLiam Girdwood 
711f0fba2adSLiam Girdwood 	/* codec IO */
712f0fba2adSLiam Girdwood 	void *control_data; /* codec control (i2c/3wire) data */
713f0fba2adSLiam Girdwood 	hw_write_t hw_write;
714c3acec26SMark Brown 	unsigned int (*read)(struct snd_soc_codec *, unsigned int);
715c3acec26SMark Brown 	int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
716f0fba2adSLiam Girdwood 	void *reg_cache;
7177a30a3dbSDimitris Papastamos 	struct mutex cache_rw_mutex;
718be3ea3b9SMark Brown 	int val_bytes;
719a96ca338SMark Brown 
720d191bd8dSKuninori Morimoto 	/* component */
721d191bd8dSKuninori Morimoto 	struct snd_soc_component component;
722d191bd8dSKuninori Morimoto 
723808db4a4SRichard Purdie 	/* dapm */
724ce6120ccSLiam Girdwood 	struct snd_soc_dapm_context dapm;
725808db4a4SRichard Purdie 
726384c89e2SMark Brown #ifdef CONFIG_DEBUG_FS
72788439ac7SPeter Ujfalusi 	struct dentry *debugfs_codec_root;
728384c89e2SMark Brown 	struct dentry *debugfs_reg;
729384c89e2SMark Brown #endif
730808db4a4SRichard Purdie };
731808db4a4SRichard Purdie 
732f0fba2adSLiam Girdwood /* codec driver */
733f0fba2adSLiam Girdwood struct snd_soc_codec_driver {
734f0fba2adSLiam Girdwood 
735f0fba2adSLiam Girdwood 	/* driver ops */
736f0fba2adSLiam Girdwood 	int (*probe)(struct snd_soc_codec *);
737f0fba2adSLiam Girdwood 	int (*remove)(struct snd_soc_codec *);
73884b315eeSLars-Peter Clausen 	int (*suspend)(struct snd_soc_codec *);
739f0fba2adSLiam Girdwood 	int (*resume)(struct snd_soc_codec *);
740d191bd8dSKuninori Morimoto 	struct snd_soc_component_driver component_driver;
741f0fba2adSLiam Girdwood 
742b7af1dafSMark Brown 	/* Default control and setup, added after probe() is run */
743b7af1dafSMark Brown 	const struct snd_kcontrol_new *controls;
744b7af1dafSMark Brown 	int num_controls;
74589b95ac0SMark Brown 	const struct snd_soc_dapm_widget *dapm_widgets;
74689b95ac0SMark Brown 	int num_dapm_widgets;
74789b95ac0SMark Brown 	const struct snd_soc_dapm_route *dapm_routes;
74889b95ac0SMark Brown 	int num_dapm_routes;
74989b95ac0SMark Brown 
750ec4ee52aSMark Brown 	/* codec wide operations */
751ec4ee52aSMark Brown 	int (*set_sysclk)(struct snd_soc_codec *codec,
752da1c6ea6SMark Brown 			  int clk_id, int source, unsigned int freq, int dir);
753ec4ee52aSMark Brown 	int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source,
754ec4ee52aSMark Brown 		unsigned int freq_in, unsigned int freq_out);
755ec4ee52aSMark Brown 
756f0fba2adSLiam Girdwood 	/* codec IO */
757f0fba2adSLiam Girdwood 	unsigned int (*read)(struct snd_soc_codec *, unsigned int);
758f0fba2adSLiam Girdwood 	int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
759f0fba2adSLiam Girdwood 	int (*display_register)(struct snd_soc_codec *, char *,
760f0fba2adSLiam Girdwood 				size_t, unsigned int);
761d4754ec9SDimitris Papastamos 	int (*volatile_register)(struct snd_soc_codec *, unsigned int);
762d4754ec9SDimitris Papastamos 	int (*readable_register)(struct snd_soc_codec *, unsigned int);
7638020454cSDimitris Papastamos 	int (*writable_register)(struct snd_soc_codec *, unsigned int);
7644a8923baSMark Brown 	unsigned int reg_cache_size;
765f0fba2adSLiam Girdwood 	short reg_cache_step;
766f0fba2adSLiam Girdwood 	short reg_word_size;
767f0fba2adSLiam Girdwood 	const void *reg_cache_default;
768f0fba2adSLiam Girdwood 
769f0fba2adSLiam Girdwood 	/* codec bias level */
770f0fba2adSLiam Girdwood 	int (*set_bias_level)(struct snd_soc_codec *,
771f0fba2adSLiam Girdwood 			      enum snd_soc_bias_level level);
77233c5f969SMark Brown 	bool idle_bias_off;
773474b62d6SMark Brown 
774474b62d6SMark Brown 	void (*seq_notifier)(struct snd_soc_dapm_context *,
775f85a9e0dSMark Brown 			     enum snd_soc_dapm_type, int);
7760168bf0dSLiam Girdwood 
77764a648c2SLiam Girdwood 	/* codec stream completion event */
77864a648c2SLiam Girdwood 	int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
77964a648c2SLiam Girdwood 
7805124e69eSMark Brown 	bool ignore_pmdown_time;  /* Doesn't benefit from pmdown delay */
7815124e69eSMark Brown 
7820168bf0dSLiam Girdwood 	/* probe ordering - for components with runtime dependencies */
7830168bf0dSLiam Girdwood 	int probe_order;
7840168bf0dSLiam Girdwood 	int remove_order;
785808db4a4SRichard Purdie };
786808db4a4SRichard Purdie 
787808db4a4SRichard Purdie /* SoC platform interface */
788f0fba2adSLiam Girdwood struct snd_soc_platform_driver {
789808db4a4SRichard Purdie 
790f0fba2adSLiam Girdwood 	int (*probe)(struct snd_soc_platform *);
791f0fba2adSLiam Girdwood 	int (*remove)(struct snd_soc_platform *);
792f0fba2adSLiam Girdwood 	int (*suspend)(struct snd_soc_dai *dai);
793f0fba2adSLiam Girdwood 	int (*resume)(struct snd_soc_dai *dai);
794808db4a4SRichard Purdie 
795808db4a4SRichard Purdie 	/* pcm creation and destruction */
796552d1ef6SLiam Girdwood 	int (*pcm_new)(struct snd_soc_pcm_runtime *);
797808db4a4SRichard Purdie 	void (*pcm_free)(struct snd_pcm *);
798808db4a4SRichard Purdie 
799cb2cf612SLiam Girdwood 	/* Default control and setup, added after probe() is run */
800cb2cf612SLiam Girdwood 	const struct snd_kcontrol_new *controls;
801cb2cf612SLiam Girdwood 	int num_controls;
802cb2cf612SLiam Girdwood 	const struct snd_soc_dapm_widget *dapm_widgets;
803cb2cf612SLiam Girdwood 	int num_dapm_widgets;
804cb2cf612SLiam Girdwood 	const struct snd_soc_dapm_route *dapm_routes;
805cb2cf612SLiam Girdwood 	int num_dapm_routes;
806cb2cf612SLiam Girdwood 
807258020d0SPeter Ujfalusi 	/*
808258020d0SPeter Ujfalusi 	 * For platform caused delay reporting.
809258020d0SPeter Ujfalusi 	 * Optional.
810258020d0SPeter Ujfalusi 	 */
811258020d0SPeter Ujfalusi 	snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
812258020d0SPeter Ujfalusi 		struct snd_soc_dai *);
813258020d0SPeter Ujfalusi 
81449681077SVinod Koul 	/* platform stream pcm ops */
8151f03f55bSLars-Peter Clausen 	const struct snd_pcm_ops *ops;
8160168bf0dSLiam Girdwood 
81749681077SVinod Koul 	/* platform stream compress ops */
818ef03c9aeSLars-Peter Clausen 	const struct snd_compr_ops *compr_ops;
81949681077SVinod Koul 
82064a648c2SLiam Girdwood 	/* platform stream completion event */
82164a648c2SLiam Girdwood 	int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
82264a648c2SLiam Girdwood 
8230168bf0dSLiam Girdwood 	/* probe ordering - for components with runtime dependencies */
8240168bf0dSLiam Girdwood 	int probe_order;
8250168bf0dSLiam Girdwood 	int remove_order;
826f1442bc1SLiam Girdwood 
827f1442bc1SLiam Girdwood 	/* platform IO - used for platform DAPM */
828f1442bc1SLiam Girdwood 	unsigned int (*read)(struct snd_soc_platform *, unsigned int);
829f1442bc1SLiam Girdwood 	int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
83007bf84aaSLiam Girdwood 	int (*bespoke_trigger)(struct snd_pcm_substream *, int);
831808db4a4SRichard Purdie };
832808db4a4SRichard Purdie 
833f0fba2adSLiam Girdwood struct snd_soc_platform {
834f0fba2adSLiam Girdwood 	const char *name;
835f0fba2adSLiam Girdwood 	int id;
836f0fba2adSLiam Girdwood 	struct device *dev;
837d79e57dbSLars-Peter Clausen 	const struct snd_soc_platform_driver *driver;
838cc22d37eSLiam Girdwood 	struct mutex mutex;
839f0fba2adSLiam Girdwood 
840f0fba2adSLiam Girdwood 	unsigned int suspended:1; /* platform is suspended */
841f0fba2adSLiam Girdwood 	unsigned int probed:1;
842f0fba2adSLiam Girdwood 
843f0fba2adSLiam Girdwood 	struct snd_soc_card *card;
844f0fba2adSLiam Girdwood 	struct list_head list;
845f0fba2adSLiam Girdwood 	struct list_head card_list;
846b7950641SLiam Girdwood 
847b7950641SLiam Girdwood 	struct snd_soc_dapm_context dapm;
848731f1ab2SSebastien Guiriec 
849731f1ab2SSebastien Guiriec #ifdef CONFIG_DEBUG_FS
850731f1ab2SSebastien Guiriec 	struct dentry *debugfs_platform_root;
851731f1ab2SSebastien Guiriec #endif
852f0fba2adSLiam Girdwood };
853f0fba2adSLiam Girdwood 
854808db4a4SRichard Purdie struct snd_soc_dai_link {
855f0fba2adSLiam Girdwood 	/* config - must be set by machine driver */
856f0fba2adSLiam Girdwood 	const char *name;			/* Codec name */
857f0fba2adSLiam Girdwood 	const char *stream_name;		/* Stream name */
858bc92657aSStephen Warren 	/*
859bc92657aSStephen Warren 	 * You MAY specify the link's CPU-side device, either by device name,
860bc92657aSStephen Warren 	 * or by DT/OF node, but not both. If this information is omitted,
861bc92657aSStephen Warren 	 * the CPU-side DAI is matched using .cpu_dai_name only, which hence
862bc92657aSStephen Warren 	 * must be globally unique. These fields are currently typically used
863bc92657aSStephen Warren 	 * only for codec to codec links, or systems using device tree.
864bc92657aSStephen Warren 	 */
865bc92657aSStephen Warren 	const char *cpu_name;
866bc92657aSStephen Warren 	const struct device_node *cpu_of_node;
867bc92657aSStephen Warren 	/*
868bc92657aSStephen Warren 	 * You MAY specify the DAI name of the CPU DAI. If this information is
869bc92657aSStephen Warren 	 * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
870bc92657aSStephen Warren 	 * only, which only works well when that device exposes a single DAI.
871bc92657aSStephen Warren 	 */
872f0fba2adSLiam Girdwood 	const char *cpu_dai_name;
873bc92657aSStephen Warren 	/*
874bc92657aSStephen Warren 	 * You MUST specify the link's codec, either by device name, or by
875bc92657aSStephen Warren 	 * DT/OF node, but not both.
876bc92657aSStephen Warren 	 */
877bc92657aSStephen Warren 	const char *codec_name;
878bc92657aSStephen Warren 	const struct device_node *codec_of_node;
879bc92657aSStephen Warren 	/* You MUST specify the DAI name within the codec */
880f0fba2adSLiam Girdwood 	const char *codec_dai_name;
881bc92657aSStephen Warren 	/*
882bc92657aSStephen Warren 	 * You MAY specify the link's platform/PCM/DMA driver, either by
883bc92657aSStephen Warren 	 * device name, or by DT/OF node, but not both. Some forms of link
884bc92657aSStephen Warren 	 * do not need a platform.
885bc92657aSStephen Warren 	 */
886bc92657aSStephen Warren 	const char *platform_name;
887bc92657aSStephen Warren 	const struct device_node *platform_of_node;
88801d7584cSLiam Girdwood 	int be_id;	/* optional ID for machine driver BE identification */
8894ccab3e7SLiam Girdwood 
890c74184edSMark Brown 	const struct snd_soc_pcm_stream *params;
891c74184edSMark Brown 
89275d9ac46SMark Brown 	unsigned int dai_fmt;           /* format to set on init */
89375d9ac46SMark Brown 
89401d7584cSLiam Girdwood 	enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
89501d7584cSLiam Girdwood 
8963efab7dcSMark Brown 	/* Keep DAI active over suspend */
8973efab7dcSMark Brown 	unsigned int ignore_suspend:1;
8983efab7dcSMark Brown 
89906f409d7SMark Brown 	/* Symmetry requirements */
90006f409d7SMark Brown 	unsigned int symmetric_rates:1;
9013635bf09SNicolin Chen 	unsigned int symmetric_channels:1;
9023635bf09SNicolin Chen 	unsigned int symmetric_samplebits:1;
90306f409d7SMark Brown 
90401d7584cSLiam Girdwood 	/* Do not create a PCM for this DAI link (Backend link) */
90501d7584cSLiam Girdwood 	unsigned int no_pcm:1;
90601d7584cSLiam Girdwood 
90701d7584cSLiam Girdwood 	/* This DAI link can route to other DAI links at runtime (Frontend)*/
90801d7584cSLiam Girdwood 	unsigned int dynamic:1;
90901d7584cSLiam Girdwood 
9101e9de42fSLiam Girdwood 	/* DPCM capture and Playback support */
9111e9de42fSLiam Girdwood 	unsigned int dpcm_capture:1;
9121e9de42fSLiam Girdwood 	unsigned int dpcm_playback:1;
9131e9de42fSLiam Girdwood 
914e50fad4fSramesh.babu@linux.intel.com 	/* pmdown_time is ignored at stop */
915e50fad4fSramesh.babu@linux.intel.com 	unsigned int ignore_pmdown_time:1;
916e50fad4fSramesh.babu@linux.intel.com 
917f0fba2adSLiam Girdwood 	/* codec/machine specific init - e.g. add machine controls */
918f0fba2adSLiam Girdwood 	int (*init)(struct snd_soc_pcm_runtime *rtd);
91906f409d7SMark Brown 
92001d7584cSLiam Girdwood 	/* optional hw_params re-writing for BE and FE sync */
92101d7584cSLiam Girdwood 	int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
92201d7584cSLiam Girdwood 			struct snd_pcm_hw_params *params);
92301d7584cSLiam Girdwood 
924f0fba2adSLiam Girdwood 	/* machine stream operations */
92513aec722SLars-Peter Clausen 	const struct snd_soc_ops *ops;
92613aec722SLars-Peter Clausen 	const struct snd_soc_compr_ops *compr_ops;
927d6bead02SFabio Estevam 
928d6bead02SFabio Estevam 	/* For unidirectional dai links */
929d6bead02SFabio Estevam 	bool playback_only;
930d6bead02SFabio Estevam 	bool capture_only;
931808db4a4SRichard Purdie };
932808db4a4SRichard Purdie 
933ff819b83SDimitris Papastamos struct snd_soc_codec_conf {
934ead9b919SJarkko Nikula 	const char *dev_name;
935ff819b83SDimitris Papastamos 
936ff819b83SDimitris Papastamos 	/*
937ff819b83SDimitris Papastamos 	 * optional map of kcontrol, widget and path name prefixes that are
938ff819b83SDimitris Papastamos 	 * associated per device
939ff819b83SDimitris Papastamos 	 */
940ead9b919SJarkko Nikula 	const char *name_prefix;
941ead9b919SJarkko Nikula };
942ead9b919SJarkko Nikula 
9432eea392dSJarkko Nikula struct snd_soc_aux_dev {
9442eea392dSJarkko Nikula 	const char *name;		/* Codec name */
9452eea392dSJarkko Nikula 	const char *codec_name;		/* for multi-codec */
9462eea392dSJarkko Nikula 
9472eea392dSJarkko Nikula 	/* codec/machine specific init - e.g. add machine controls */
9482eea392dSJarkko Nikula 	int (*init)(struct snd_soc_dapm_context *dapm);
9492eea392dSJarkko Nikula };
9502eea392dSJarkko Nikula 
95187506549SMark Brown /* SoC card */
95287506549SMark Brown struct snd_soc_card {
953f0fba2adSLiam Girdwood 	const char *name;
95422de71baSLiam Girdwood 	const char *long_name;
95522de71baSLiam Girdwood 	const char *driver_name;
956c5af3a2eSMark Brown 	struct device *dev;
957f0fba2adSLiam Girdwood 	struct snd_card *snd_card;
958f0fba2adSLiam Girdwood 	struct module *owner;
959c5af3a2eSMark Brown 
960c5af3a2eSMark Brown 	struct list_head list;
961f0fba2adSLiam Girdwood 	struct mutex mutex;
962a73fb2dfSLiam Girdwood 	struct mutex dapm_mutex;
963c5af3a2eSMark Brown 
964f0fba2adSLiam Girdwood 	bool instantiated;
965808db4a4SRichard Purdie 
966e7361ec4SMark Brown 	int (*probe)(struct snd_soc_card *card);
96728e9ad92SMark Brown 	int (*late_probe)(struct snd_soc_card *card);
968e7361ec4SMark Brown 	int (*remove)(struct snd_soc_card *card);
969808db4a4SRichard Purdie 
970808db4a4SRichard Purdie 	/* the pre and post PM functions are used to do any PM work before and
971808db4a4SRichard Purdie 	 * after the codec and DAI's do any PM work. */
97270b2ac12SMark Brown 	int (*suspend_pre)(struct snd_soc_card *card);
97370b2ac12SMark Brown 	int (*suspend_post)(struct snd_soc_card *card);
97470b2ac12SMark Brown 	int (*resume_pre)(struct snd_soc_card *card);
97570b2ac12SMark Brown 	int (*resume_post)(struct snd_soc_card *card);
976808db4a4SRichard Purdie 
9770b4d221bSLiam Girdwood 	/* callbacks */
97887506549SMark Brown 	int (*set_bias_level)(struct snd_soc_card *,
979d4c6005fSMark Brown 			      struct snd_soc_dapm_context *dapm,
9800be9898aSMark Brown 			      enum snd_soc_bias_level level);
9811badabd9SMark Brown 	int (*set_bias_level_post)(struct snd_soc_card *,
982d4c6005fSMark Brown 				   struct snd_soc_dapm_context *dapm,
9831badabd9SMark Brown 				   enum snd_soc_bias_level level);
9840b4d221bSLiam Girdwood 
9856c5f1fedSMark Brown 	long pmdown_time;
98696dd3622SMark Brown 
987808db4a4SRichard Purdie 	/* CPU <--> Codec DAI links  */
988808db4a4SRichard Purdie 	struct snd_soc_dai_link *dai_link;
989808db4a4SRichard Purdie 	int num_links;
990f0fba2adSLiam Girdwood 	struct snd_soc_pcm_runtime *rtd;
991f0fba2adSLiam Girdwood 	int num_rtd;
9926308419aSMark Brown 
993ff819b83SDimitris Papastamos 	/* optional codec specific configuration */
994ff819b83SDimitris Papastamos 	struct snd_soc_codec_conf *codec_conf;
995ff819b83SDimitris Papastamos 	int num_configs;
996ead9b919SJarkko Nikula 
9972eea392dSJarkko Nikula 	/*
9982eea392dSJarkko Nikula 	 * optional auxiliary devices such as amplifiers or codecs with DAI
9992eea392dSJarkko Nikula 	 * link unused
10002eea392dSJarkko Nikula 	 */
10012eea392dSJarkko Nikula 	struct snd_soc_aux_dev *aux_dev;
10022eea392dSJarkko Nikula 	int num_aux_devs;
10032eea392dSJarkko Nikula 	struct snd_soc_pcm_runtime *rtd_aux;
10042eea392dSJarkko Nikula 	int num_aux_rtd;
10052eea392dSJarkko Nikula 
1006b7af1dafSMark Brown 	const struct snd_kcontrol_new *controls;
1007b7af1dafSMark Brown 	int num_controls;
1008b7af1dafSMark Brown 
1009b8ad29deSMark Brown 	/*
1010b8ad29deSMark Brown 	 * Card-specific routes and widgets.
1011b8ad29deSMark Brown 	 */
1012d06e48dbSLars-Peter Clausen 	const struct snd_soc_dapm_widget *dapm_widgets;
1013b8ad29deSMark Brown 	int num_dapm_widgets;
1014d06e48dbSLars-Peter Clausen 	const struct snd_soc_dapm_route *dapm_routes;
1015b8ad29deSMark Brown 	int num_dapm_routes;
10161633281bSStephen Warren 	bool fully_routed;
1017b8ad29deSMark Brown 
10186308419aSMark Brown 	struct work_struct deferred_resume_work;
1019f0fba2adSLiam Girdwood 
1020f0fba2adSLiam Girdwood 	/* lists of probed devices belonging to this card */
1021f0fba2adSLiam Girdwood 	struct list_head codec_dev_list;
1022f0fba2adSLiam Girdwood 	struct list_head platform_dev_list;
1023f0fba2adSLiam Girdwood 	struct list_head dai_dev_list;
1024a6052154SJarkko Nikula 
102597c866deSJarkko Nikula 	struct list_head widgets;
10268ddab3f5SJarkko Nikula 	struct list_head paths;
10277be31be8SJarkko Nikula 	struct list_head dapm_list;
1028db432b41SMark Brown 	struct list_head dapm_dirty;
10298ddab3f5SJarkko Nikula 
1030e37a4970SMark Brown 	/* Generic DAPM context for the card */
1031e37a4970SMark Brown 	struct snd_soc_dapm_context dapm;
1032de02d078SMark Brown 	struct snd_soc_dapm_stats dapm_stats;
1033564c6504SLars-Peter Clausen 	struct snd_soc_dapm_update *update;
1034e37a4970SMark Brown 
1035a6052154SJarkko Nikula #ifdef CONFIG_DEBUG_FS
1036a6052154SJarkko Nikula 	struct dentry *debugfs_card_root;
10373a45b867SJarkko Nikula 	struct dentry *debugfs_pop_time;
1038a6052154SJarkko Nikula #endif
10393a45b867SJarkko Nikula 	u32 pop_time;
1040dddf3e4cSMark Brown 
1041dddf3e4cSMark Brown 	void *drvdata;
1042808db4a4SRichard Purdie };
1043808db4a4SRichard Purdie 
1044f0fba2adSLiam Girdwood /* SoC machine DAI configuration, glues a codec and cpu DAI together */
1045808db4a4SRichard Purdie struct snd_soc_pcm_runtime {
104636ae1a96SMark Brown 	struct device *dev;
1047f0fba2adSLiam Girdwood 	struct snd_soc_card *card;
1048f0fba2adSLiam Girdwood 	struct snd_soc_dai_link *dai_link;
1049b8c0dab9SLiam Girdwood 	struct mutex pcm_mutex;
1050b8c0dab9SLiam Girdwood 	enum snd_soc_pcm_subclass pcm_subclass;
1051b8c0dab9SLiam Girdwood 	struct snd_pcm_ops ops;
1052f0fba2adSLiam Girdwood 
1053f0fba2adSLiam Girdwood 	unsigned int dev_registered:1;
1054f0fba2adSLiam Girdwood 
105501d7584cSLiam Girdwood 	/* Dynamic PCM BE runtime data */
105601d7584cSLiam Girdwood 	struct snd_soc_dpcm_runtime dpcm[2];
10572a99ef0fSLiam Girdwood 	int fe_compr;
105801d7584cSLiam Girdwood 
1059f0fba2adSLiam Girdwood 	long pmdown_time;
10609bffb1fbSMisael Lopez Cruz 	unsigned char pop_wait:1;
1061f0fba2adSLiam Girdwood 
1062f0fba2adSLiam Girdwood 	/* runtime devices */
1063f0fba2adSLiam Girdwood 	struct snd_pcm *pcm;
106449681077SVinod Koul 	struct snd_compr *compr;
1065f0fba2adSLiam Girdwood 	struct snd_soc_codec *codec;
1066f0fba2adSLiam Girdwood 	struct snd_soc_platform *platform;
1067f0fba2adSLiam Girdwood 	struct snd_soc_dai *codec_dai;
1068f0fba2adSLiam Girdwood 	struct snd_soc_dai *cpu_dai;
1069f0fba2adSLiam Girdwood 
1070f0fba2adSLiam Girdwood 	struct delayed_work delayed_work;
1071f86dcef8SLiam Girdwood #ifdef CONFIG_DEBUG_FS
1072f86dcef8SLiam Girdwood 	struct dentry *debugfs_dpcm_root;
1073f86dcef8SLiam Girdwood 	struct dentry *debugfs_dpcm_state;
1074f86dcef8SLiam Girdwood #endif
1075808db4a4SRichard Purdie };
1076808db4a4SRichard Purdie 
10774eaa9819SJon Smirl /* mixer control */
10784eaa9819SJon Smirl struct soc_mixer_control {
1079d11bb4a9SPeter Ujfalusi 	int min, max, platform_max;
1080249ce138SLars-Peter Clausen 	int reg, rreg;
1081249ce138SLars-Peter Clausen 	unsigned int shift, rshift;
1082f227b88fSMarkus Pargmann 	unsigned int sign_bit;
108357295073SLars-Peter Clausen 	unsigned int invert:1;
108457295073SLars-Peter Clausen 	unsigned int autodisable:1;
10854eaa9819SJon Smirl };
10864eaa9819SJon Smirl 
108771d08516SMark Brown struct soc_bytes {
108871d08516SMark Brown 	int base;
108971d08516SMark Brown 	int num_regs;
1090f831b055SMark Brown 	u32 mask;
109171d08516SMark Brown };
109271d08516SMark Brown 
10934183eed2SKristoffer KARLSSON /* multi register control */
10944183eed2SKristoffer KARLSSON struct soc_mreg_control {
10954183eed2SKristoffer KARLSSON 	long min, max;
10964183eed2SKristoffer KARLSSON 	unsigned int regbase, regcount, nbits, invert;
10974183eed2SKristoffer KARLSSON };
10984183eed2SKristoffer KARLSSON 
1099808db4a4SRichard Purdie /* enumerated kcontrol */
1100808db4a4SRichard Purdie struct soc_enum {
1101b948837aSLars-Peter Clausen 	int reg;
1102808db4a4SRichard Purdie 	unsigned char shift_l;
1103808db4a4SRichard Purdie 	unsigned char shift_r;
11049a8d38dbSTakashi Iwai 	unsigned int items;
11052e72f8e3SPeter Ujfalusi 	unsigned int mask;
110687023ff7STakashi Iwai 	const char * const *texts;
11072e72f8e3SPeter Ujfalusi 	const unsigned int *values;
11082e72f8e3SPeter Ujfalusi };
11092e72f8e3SPeter Ujfalusi 
111028d6d175SLars-Peter Clausen /**
111128d6d175SLars-Peter Clausen  * snd_soc_component_to_codec() - Casts a component to the CODEC it is embedded in
111228d6d175SLars-Peter Clausen  * @component: The component to cast to a CODEC
111328d6d175SLars-Peter Clausen  *
111428d6d175SLars-Peter Clausen  * This function must only be used on components that are known to be CODECs.
111528d6d175SLars-Peter Clausen  * Otherwise the behavior is undefined.
111628d6d175SLars-Peter Clausen  */
111728d6d175SLars-Peter Clausen static inline struct snd_soc_codec *snd_soc_component_to_codec(
111828d6d175SLars-Peter Clausen 	struct snd_soc_component *component)
111928d6d175SLars-Peter Clausen {
112028d6d175SLars-Peter Clausen 	return container_of(component, struct snd_soc_codec, component);
112128d6d175SLars-Peter Clausen }
112228d6d175SLars-Peter Clausen 
11235c82f567SMark Brown /* codec IO */
1124c3753707SMark Brown unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
1125c3753707SMark Brown unsigned int snd_soc_write(struct snd_soc_codec *codec,
1126c3753707SMark Brown 			   unsigned int reg, unsigned int val);
11275c82f567SMark Brown 
1128f0fba2adSLiam Girdwood /* device driver data */
1129f0fba2adSLiam Girdwood 
1130dddf3e4cSMark Brown static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
1131dddf3e4cSMark Brown 		void *data)
1132dddf3e4cSMark Brown {
1133dddf3e4cSMark Brown 	card->drvdata = data;
1134dddf3e4cSMark Brown }
1135dddf3e4cSMark Brown 
1136dddf3e4cSMark Brown static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
1137dddf3e4cSMark Brown {
1138dddf3e4cSMark Brown 	return card->drvdata;
1139dddf3e4cSMark Brown }
1140dddf3e4cSMark Brown 
1141b2c812e2SMark Brown static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
1142b2c812e2SMark Brown 		void *data)
1143b2c812e2SMark Brown {
1144f0fba2adSLiam Girdwood 	dev_set_drvdata(codec->dev, data);
1145b2c812e2SMark Brown }
1146b2c812e2SMark Brown 
1147b2c812e2SMark Brown static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec)
1148b2c812e2SMark Brown {
1149f0fba2adSLiam Girdwood 	return dev_get_drvdata(codec->dev);
1150f0fba2adSLiam Girdwood }
1151f0fba2adSLiam Girdwood 
1152f0fba2adSLiam Girdwood static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform,
1153f0fba2adSLiam Girdwood 		void *data)
1154f0fba2adSLiam Girdwood {
1155f0fba2adSLiam Girdwood 	dev_set_drvdata(platform->dev, data);
1156f0fba2adSLiam Girdwood }
1157f0fba2adSLiam Girdwood 
1158f0fba2adSLiam Girdwood static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform)
1159f0fba2adSLiam Girdwood {
1160f0fba2adSLiam Girdwood 	return dev_get_drvdata(platform->dev);
1161f0fba2adSLiam Girdwood }
1162f0fba2adSLiam Girdwood 
1163f0fba2adSLiam Girdwood static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd,
1164f0fba2adSLiam Girdwood 		void *data)
1165f0fba2adSLiam Girdwood {
116636ae1a96SMark Brown 	dev_set_drvdata(rtd->dev, data);
1167f0fba2adSLiam Girdwood }
1168f0fba2adSLiam Girdwood 
1169f0fba2adSLiam Girdwood static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd)
1170f0fba2adSLiam Girdwood {
117136ae1a96SMark Brown 	return dev_get_drvdata(rtd->dev);
1172b2c812e2SMark Brown }
1173b2c812e2SMark Brown 
11744e10bda0SVinod Koul static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
11754e10bda0SVinod Koul {
11764e10bda0SVinod Koul 	INIT_LIST_HEAD(&card->dai_dev_list);
11774e10bda0SVinod Koul 	INIT_LIST_HEAD(&card->codec_dev_list);
11784e10bda0SVinod Koul 	INIT_LIST_HEAD(&card->platform_dev_list);
11794e10bda0SVinod Koul 	INIT_LIST_HEAD(&card->widgets);
11804e10bda0SVinod Koul 	INIT_LIST_HEAD(&card->paths);
11814e10bda0SVinod Koul 	INIT_LIST_HEAD(&card->dapm_list);
11824e10bda0SVinod Koul }
11834e10bda0SVinod Koul 
118430d86ba4SPeter Ujfalusi static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
118530d86ba4SPeter Ujfalusi {
118630d86ba4SPeter Ujfalusi 	if (mc->reg == mc->rreg && mc->shift == mc->rshift)
118730d86ba4SPeter Ujfalusi 		return 0;
118830d86ba4SPeter Ujfalusi 	/*
118930d86ba4SPeter Ujfalusi 	 * mc->reg == mc->rreg && mc->shift != mc->rshift, or
119030d86ba4SPeter Ujfalusi 	 * mc->reg != mc->rreg means that the control is
119130d86ba4SPeter Ujfalusi 	 * stereo (bits in one register or in two registers)
119230d86ba4SPeter Ujfalusi 	 */
119330d86ba4SPeter Ujfalusi 	return 1;
119430d86ba4SPeter Ujfalusi }
119530d86ba4SPeter Ujfalusi 
119629ae2fa5SLars-Peter Clausen static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
119729ae2fa5SLars-Peter Clausen 	unsigned int val)
119829ae2fa5SLars-Peter Clausen {
119929ae2fa5SLars-Peter Clausen 	unsigned int i;
120029ae2fa5SLars-Peter Clausen 
120129ae2fa5SLars-Peter Clausen 	if (!e->values)
120229ae2fa5SLars-Peter Clausen 		return val;
120329ae2fa5SLars-Peter Clausen 
120429ae2fa5SLars-Peter Clausen 	for (i = 0; i < e->items; i++)
120529ae2fa5SLars-Peter Clausen 		if (val == e->values[i])
120629ae2fa5SLars-Peter Clausen 			return i;
120729ae2fa5SLars-Peter Clausen 
120829ae2fa5SLars-Peter Clausen 	return 0;
120929ae2fa5SLars-Peter Clausen }
121029ae2fa5SLars-Peter Clausen 
121129ae2fa5SLars-Peter Clausen static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
121229ae2fa5SLars-Peter Clausen 	unsigned int item)
121329ae2fa5SLars-Peter Clausen {
121429ae2fa5SLars-Peter Clausen 	if (!e->values)
121529ae2fa5SLars-Peter Clausen 		return item;
121629ae2fa5SLars-Peter Clausen 
121729ae2fa5SLars-Peter Clausen 	return e->values[item];
121829ae2fa5SLars-Peter Clausen }
121929ae2fa5SLars-Peter Clausen 
1220cdde4ccbSLars-Peter Clausen static inline bool snd_soc_component_is_active(
1221cdde4ccbSLars-Peter Clausen 	struct snd_soc_component *component)
1222cdde4ccbSLars-Peter Clausen {
1223cdde4ccbSLars-Peter Clausen 	return component->active != 0;
1224cdde4ccbSLars-Peter Clausen }
1225cdde4ccbSLars-Peter Clausen 
12265c898e74SLars-Peter Clausen static inline bool snd_soc_codec_is_active(struct snd_soc_codec *codec)
12275c898e74SLars-Peter Clausen {
1228cdde4ccbSLars-Peter Clausen 	return snd_soc_component_is_active(&codec->component);
12295c898e74SLars-Peter Clausen }
12305c898e74SLars-Peter Clausen 
1231fb257897SMark Brown int snd_soc_util_init(void);
1232fb257897SMark Brown void snd_soc_util_exit(void);
1233fb257897SMark Brown 
1234bec4fa05SStephen Warren int snd_soc_of_parse_card_name(struct snd_soc_card *card,
1235bec4fa05SStephen Warren 			       const char *propname);
12369a6d4860SXiubo Li int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
12379a6d4860SXiubo Li 					  const char *propname);
123889c67857SXiubo Li int snd_soc_of_parse_tdm_slot(struct device_node *np,
123989c67857SXiubo Li 			      unsigned int *slots,
124089c67857SXiubo Li 			      unsigned int *slot_width);
1241a4a54dd5SStephen Warren int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
1242a4a54dd5SStephen Warren 				   const char *propname);
1243a7930ed4SKuninori Morimoto unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
1244*389cb834SJyri Sarha 				     const char *prefix,
1245*389cb834SJyri Sarha 				     struct device_node **bitclkmaster,
1246*389cb834SJyri Sarha 				     struct device_node **framemaster);
1247cb470087SKuninori Morimoto int snd_soc_of_get_dai_name(struct device_node *of_node,
1248cb470087SKuninori Morimoto 			    const char **dai_name);
1249bec4fa05SStephen Warren 
1250a47cbe72SMark Brown #include <sound/soc-dai.h>
1251a47cbe72SMark Brown 
1252faff4bb0SStephen Warren #ifdef CONFIG_DEBUG_FS
12538a9dab1aSMark Brown extern struct dentry *snd_soc_debugfs_root;
1254faff4bb0SStephen Warren #endif
1255faff4bb0SStephen Warren 
12566f8ab4acSMark Brown extern const struct dev_pm_ops snd_soc_pm_ops;
12576f8ab4acSMark Brown 
1258f6d5e586SCharles Keepax /* Helper functions */
1259f6d5e586SCharles Keepax static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm)
1260f6d5e586SCharles Keepax {
1261f6d5e586SCharles Keepax 	mutex_lock(&dapm->card->dapm_mutex);
1262f6d5e586SCharles Keepax }
1263f6d5e586SCharles Keepax 
1264f6d5e586SCharles Keepax static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
1265f6d5e586SCharles Keepax {
1266f6d5e586SCharles Keepax 	mutex_unlock(&dapm->card->dapm_mutex);
1267f6d5e586SCharles Keepax }
1268f6d5e586SCharles Keepax 
1269808db4a4SRichard Purdie #endif
1270