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
13cb470087SKuninori Morimoto #include <linux/of.h>
14808db4a4SRichard Purdie #include <linux/platform_device.h>
15808db4a4SRichard Purdie #include <linux/types.h>
16d5021ec9SMark Brown #include <linux/notifier.h>
174484bb2eSAndrew Morton #include <linux/workqueue.h>
18ec67624dSLopez Cruz, Misael #include <linux/interrupt.h>
19ec67624dSLopez Cruz, Misael #include <linux/kernel.h>
20be3ea3b9SMark Brown #include <linux/regmap.h>
2186767b7dSLars-Peter Clausen #include <linux/log2.h>
22808db4a4SRichard Purdie #include <sound/core.h>
23808db4a4SRichard Purdie #include <sound/pcm.h>
2449681077SVinod Koul #include <sound/compress_driver.h>
25808db4a4SRichard Purdie #include <sound/control.h>
26808db4a4SRichard Purdie #include <sound/ac97_codec.h>
27808db4a4SRichard Purdie
28808db4a4SRichard Purdie /*
29808db4a4SRichard Purdie * Convenience kcontrol builders
30808db4a4SRichard Purdie */
3157295073SLars-Peter Clausen #define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert, xautodisable) \
324eaa9819SJon Smirl ((unsigned long)&(struct soc_mixer_control) \
3330d86ba4SPeter Ujfalusi {.reg = xreg, .rreg = xreg, .shift = shift_left, \
3426bdcc4bSSrinivas Kandagatla .rshift = shift_right, .max = xmax, \
3557295073SLars-Peter Clausen .invert = xinvert, .autodisable = xautodisable})
36c1b4d1c7SLars-Peter Clausen #define SOC_DOUBLE_S_VALUE(xreg, shift_left, shift_right, xmin, xmax, xsign_bit, xinvert, xautodisable) \
37c1b4d1c7SLars-Peter Clausen ((unsigned long)&(struct soc_mixer_control) \
38c1b4d1c7SLars-Peter Clausen {.reg = xreg, .rreg = xreg, .shift = shift_left, \
3926bdcc4bSSrinivas Kandagatla .rshift = shift_right, .min = xmin, .max = xmax, \
40c1b4d1c7SLars-Peter Clausen .sign_bit = xsign_bit, .invert = xinvert, .autodisable = xautodisable})
4157295073SLars-Peter Clausen #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, xautodisable) \
4257295073SLars-Peter Clausen SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert, xautodisable)
434eaa9819SJon Smirl #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
444eaa9819SJon Smirl ((unsigned long)&(struct soc_mixer_control) \
4526bdcc4bSSrinivas Kandagatla {.reg = xreg, .max = xmax, .invert = xinvert})
46cdffa775SPeter Ujfalusi #define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
47cdffa775SPeter Ujfalusi ((unsigned long)&(struct soc_mixer_control) \
48cdffa775SPeter Ujfalusi {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
4926bdcc4bSSrinivas Kandagatla .max = xmax, .invert = xinvert})
50cd21b123SMarkus Pargmann #define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
51cd21b123SMarkus Pargmann ((unsigned long)&(struct soc_mixer_control) \
52cd21b123SMarkus Pargmann {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
5326bdcc4bSSrinivas Kandagatla .max = xmax, .min = xmin, .sign_bit = xsign_bit, \
54cd21b123SMarkus Pargmann .invert = xinvert})
55229e3fdcSMark Brown #define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
56229e3fdcSMark Brown ((unsigned long)&(struct soc_mixer_control) \
57229e3fdcSMark Brown {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
5826bdcc4bSSrinivas Kandagatla .min = xmin, .max = xmax, .invert = xinvert})
59a7a4ac86SPhilipp Zabel #define SOC_SINGLE(xname, reg, shift, max, invert) \
60808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
61808db4a4SRichard Purdie .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
62808db4a4SRichard Purdie .put = snd_soc_put_volsw, \
6357295073SLars-Peter Clausen .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
646c9d8cf6SAdam Thomson #define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
656c9d8cf6SAdam Thomson { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
666c9d8cf6SAdam Thomson .info = snd_soc_info_volsw_range, .get = snd_soc_get_volsw_range, \
676c9d8cf6SAdam Thomson .put = snd_soc_put_volsw_range, \
686c9d8cf6SAdam Thomson .private_value = (unsigned long)&(struct soc_mixer_control) \
699bde4f0bSMark Brown {.reg = xreg, .rreg = xreg, .shift = xshift, \
709bde4f0bSMark Brown .rshift = xshift, .min = xmin, .max = xmax, \
7126bdcc4bSSrinivas Kandagatla .invert = xinvert} }
72a7a4ac86SPhilipp Zabel #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
73a7a4ac86SPhilipp Zabel { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
74a7a4ac86SPhilipp Zabel .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
75a7a4ac86SPhilipp Zabel SNDRV_CTL_ELEM_ACCESS_READWRITE,\
76a7a4ac86SPhilipp Zabel .tlv.p = (tlv_array), \
77a7a4ac86SPhilipp Zabel .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
78a7a4ac86SPhilipp Zabel .put = snd_soc_put_volsw, \
7957295073SLars-Peter Clausen .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
801d99f243SBrian Austin #define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
811d99f243SBrian Austin { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
821d99f243SBrian Austin .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
831d99f243SBrian Austin SNDRV_CTL_ELEM_ACCESS_READWRITE, \
841d99f243SBrian Austin .tlv.p = (tlv_array),\
8534198710SCharles Keepax .info = snd_soc_info_volsw_sx, \
861d99f243SBrian Austin .get = snd_soc_get_volsw_sx,\
871d99f243SBrian Austin .put = snd_soc_put_volsw_sx, \
881d99f243SBrian Austin .private_value = (unsigned long)&(struct soc_mixer_control) \
891d99f243SBrian Austin {.reg = xreg, .rreg = xreg, \
901d99f243SBrian Austin .shift = xshift, .rshift = xshift, \
911d99f243SBrian Austin .max = xmax, .min = xmin} }
926c9d8cf6SAdam Thomson #define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \
936c9d8cf6SAdam Thomson { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
946c9d8cf6SAdam Thomson .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
956c9d8cf6SAdam Thomson SNDRV_CTL_ELEM_ACCESS_READWRITE,\
966c9d8cf6SAdam Thomson .tlv.p = (tlv_array), \
976c9d8cf6SAdam Thomson .info = snd_soc_info_volsw_range, \
986c9d8cf6SAdam Thomson .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
996c9d8cf6SAdam Thomson .private_value = (unsigned long)&(struct soc_mixer_control) \
1009bde4f0bSMark Brown {.reg = xreg, .rreg = xreg, .shift = xshift, \
1019bde4f0bSMark Brown .rshift = xshift, .min = xmin, .max = xmax, \
10226bdcc4bSSrinivas Kandagatla .invert = xinvert} }
103460acbecSPeter Ujfalusi #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
104808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
105808db4a4SRichard Purdie .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
106808db4a4SRichard Purdie .put = snd_soc_put_volsw, \
107460acbecSPeter Ujfalusi .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
10857295073SLars-Peter Clausen max, invert, 0) }
109d13871b3SDamien.Horsley #define SOC_DOUBLE_STS(xname, reg, shift_left, shift_right, max, invert) \
110d13871b3SDamien.Horsley { \
111d13871b3SDamien.Horsley .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
112d13871b3SDamien.Horsley .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
113d13871b3SDamien.Horsley .access = SNDRV_CTL_ELEM_ACCESS_READ | \
114d13871b3SDamien.Horsley SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
115d13871b3SDamien.Horsley .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
116d13871b3SDamien.Horsley max, invert, 0) }
1174eaa9819SJon Smirl #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
118808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
119e8f5a103SPeter Ujfalusi .info = snd_soc_info_volsw, \
120974815baSPeter Ujfalusi .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
121cdffa775SPeter Ujfalusi .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
122cdffa775SPeter Ujfalusi xmax, xinvert) }
123229e3fdcSMark Brown #define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \
124229e3fdcSMark Brown xmax, xinvert) \
125229e3fdcSMark Brown { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
126229e3fdcSMark Brown .info = snd_soc_info_volsw_range, \
127229e3fdcSMark Brown .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
128229e3fdcSMark Brown .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
129229e3fdcSMark Brown xshift, xmin, xmax, xinvert) }
130460acbecSPeter Ujfalusi #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
131a7a4ac86SPhilipp Zabel { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
132a7a4ac86SPhilipp Zabel .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
133a7a4ac86SPhilipp Zabel SNDRV_CTL_ELEM_ACCESS_READWRITE,\
134a7a4ac86SPhilipp Zabel .tlv.p = (tlv_array), \
135a7a4ac86SPhilipp Zabel .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
136a7a4ac86SPhilipp Zabel .put = snd_soc_put_volsw, \
137460acbecSPeter Ujfalusi .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
13857295073SLars-Peter Clausen max, invert, 0) }
1396b183919SCharles Keepax #define SOC_DOUBLE_SX_TLV(xname, xreg, shift_left, shift_right, xmin, xmax, tlv_array) \
1406b183919SCharles Keepax { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
1416b183919SCharles Keepax .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1426b183919SCharles Keepax SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1436b183919SCharles Keepax .tlv.p = (tlv_array), \
1446b183919SCharles Keepax .info = snd_soc_info_volsw_sx, \
1456b183919SCharles Keepax .get = snd_soc_get_volsw_sx, \
1466b183919SCharles Keepax .put = snd_soc_put_volsw_sx, \
1476b183919SCharles Keepax .private_value = (unsigned long)&(struct soc_mixer_control) \
1486b183919SCharles Keepax {.reg = xreg, .rreg = xreg, \
1496b183919SCharles Keepax .shift = shift_left, .rshift = shift_right, \
1506b183919SCharles Keepax .max = xmax, .min = xmin} }
1514eaa9819SJon Smirl #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
152a7a4ac86SPhilipp Zabel { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
153a7a4ac86SPhilipp Zabel .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
154a7a4ac86SPhilipp Zabel SNDRV_CTL_ELEM_ACCESS_READWRITE,\
155a7a4ac86SPhilipp Zabel .tlv.p = (tlv_array), \
156e8f5a103SPeter Ujfalusi .info = snd_soc_info_volsw, \
157974815baSPeter Ujfalusi .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
158cdffa775SPeter Ujfalusi .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
159cdffa775SPeter Ujfalusi xmax, xinvert) }
160229e3fdcSMark Brown #define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \
161229e3fdcSMark Brown xmax, xinvert, tlv_array) \
162229e3fdcSMark Brown { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
163229e3fdcSMark Brown .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
164229e3fdcSMark Brown SNDRV_CTL_ELEM_ACCESS_READWRITE,\
165229e3fdcSMark Brown .tlv.p = (tlv_array), \
166229e3fdcSMark Brown .info = snd_soc_info_volsw_range, \
167229e3fdcSMark Brown .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
168229e3fdcSMark Brown .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
169229e3fdcSMark Brown xshift, xmin, xmax, xinvert) }
1701d99f243SBrian Austin #define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
1711d99f243SBrian Austin { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
1721d99f243SBrian Austin .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1731d99f243SBrian Austin SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1741d99f243SBrian Austin .tlv.p = (tlv_array), \
17534198710SCharles Keepax .info = snd_soc_info_volsw_sx, \
1761d99f243SBrian Austin .get = snd_soc_get_volsw_sx, \
1771d99f243SBrian Austin .put = snd_soc_put_volsw_sx, \
1781d99f243SBrian Austin .private_value = (unsigned long)&(struct soc_mixer_control) \
1791d99f243SBrian Austin {.reg = xreg, .rreg = xrreg, \
1801d99f243SBrian Austin .shift = xshift, .rshift = xshift, \
1811d99f243SBrian Austin .max = xmax, .min = xmin} }
182cd21b123SMarkus Pargmann #define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
183cd21b123SMarkus Pargmann { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
184cd21b123SMarkus Pargmann .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
185cd21b123SMarkus Pargmann SNDRV_CTL_ELEM_ACCESS_READWRITE,\
186cd21b123SMarkus Pargmann .tlv.p = (tlv_array), \
187cd21b123SMarkus Pargmann .info = snd_soc_info_volsw, \
188cd21b123SMarkus Pargmann .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
189cd21b123SMarkus Pargmann .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
190cd21b123SMarkus Pargmann xmin, xmax, xsign_bit, xinvert) }
191bc8cb029SRichard Fitzgerald #define SOC_SINGLE_S_TLV(xname, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
192bc8cb029SRichard Fitzgerald SOC_DOUBLE_R_S_TLV(xname, xreg, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array)
193dcc0799bSSrinivas Kandagatla #define SOC_SINGLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
194dcc0799bSSrinivas Kandagatla { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
195dcc0799bSSrinivas Kandagatla .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
196dcc0799bSSrinivas Kandagatla SNDRV_CTL_ELEM_ACCESS_READWRITE, \
197dcc0799bSSrinivas Kandagatla .tlv.p = (tlv_array), \
198dcc0799bSSrinivas Kandagatla .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
199dcc0799bSSrinivas Kandagatla .put = snd_soc_put_volsw, \
200dcc0799bSSrinivas Kandagatla .private_value = (unsigned long)&(struct soc_mixer_control) \
201dcc0799bSSrinivas Kandagatla {.reg = xreg, .rreg = xreg, \
20226bdcc4bSSrinivas Kandagatla .min = xmin, .max = xmax, \
203dcc0799bSSrinivas Kandagatla .sign_bit = 7,} }
2044eaa9819SJon Smirl #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
205e13ac2e9SMark Brown { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
206e13ac2e9SMark Brown .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
207e13ac2e9SMark Brown SNDRV_CTL_ELEM_ACCESS_READWRITE, \
208e13ac2e9SMark Brown .tlv.p = (tlv_array), \
209c1b4d1c7SLars-Peter Clausen .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
210c1b4d1c7SLars-Peter Clausen .put = snd_soc_put_volsw, \
211c1b4d1c7SLars-Peter Clausen .private_value = SOC_DOUBLE_S_VALUE(xreg, 0, 8, xmin, xmax, 7, 0, 0) }
2129a8d38dbSTakashi Iwai #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
213808db4a4SRichard Purdie { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
2149a8d38dbSTakashi Iwai .items = xitems, .texts = xtexts, \
2159a8d38dbSTakashi Iwai .mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
2169a8d38dbSTakashi Iwai #define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
2179a8d38dbSTakashi Iwai SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
2189a8d38dbSTakashi Iwai #define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
2199a8d38dbSTakashi Iwai { .items = xitems, .texts = xtexts }
2209a8d38dbSTakashi Iwai #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
2212e72f8e3SPeter Ujfalusi { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
2229a8d38dbSTakashi Iwai .mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
2235967cb3dSCharles Keepax #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
2245967cb3dSCharles Keepax SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xitems, xtexts, xvalues)
225561ed680SCharles Keepax #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
226561ed680SCharles Keepax { .reg = xreg, .shift_l = xshift, .shift_r = xshift, \
227561ed680SCharles Keepax .mask = xmask, .items = xitems, .texts = xtexts, \
228561ed680SCharles Keepax .values = xvalues, .autodisable = 1}
229b948837aSLars-Peter Clausen #define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
230b948837aSLars-Peter Clausen SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
231808db4a4SRichard Purdie #define SOC_ENUM(xname, xenum) \
232808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
233808db4a4SRichard Purdie .info = snd_soc_info_enum_double, \
234808db4a4SRichard Purdie .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
235808db4a4SRichard Purdie .private_value = (unsigned long)&xenum }
236f8ba0b7bSJon Smirl #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
237808db4a4SRichard Purdie xhandler_get, xhandler_put) \
238808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
2391c433fbdSGraeme Gregory .info = snd_soc_info_volsw, \
240808db4a4SRichard Purdie .get = xhandler_get, .put = xhandler_put, \
24157295073SLars-Peter Clausen .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
242460acbecSPeter Ujfalusi #define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
2437629ad24SDaniel Mack xhandler_get, xhandler_put) \
2447629ad24SDaniel Mack { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
2457629ad24SDaniel Mack .info = snd_soc_info_volsw, \
2467629ad24SDaniel Mack .get = xhandler_get, .put = xhandler_put, \
247460acbecSPeter Ujfalusi .private_value = \
24857295073SLars-Peter Clausen SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) }
249c25c79b4SAdam Thomson #define SOC_DOUBLE_R_EXT(xname, reg_left, reg_right, xshift, xmax, xinvert,\
250c25c79b4SAdam Thomson xhandler_get, xhandler_put) \
251c25c79b4SAdam Thomson { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
252c25c79b4SAdam Thomson .info = snd_soc_info_volsw, \
253c25c79b4SAdam Thomson .get = xhandler_get, .put = xhandler_put, \
254c25c79b4SAdam Thomson .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
255c25c79b4SAdam Thomson xmax, xinvert) }
256f8ba0b7bSJon Smirl #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
25710144c09SMike Montour xhandler_get, xhandler_put, tlv_array) \
25810144c09SMike Montour { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
25910144c09SMike Montour .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
26010144c09SMike Montour SNDRV_CTL_ELEM_ACCESS_READWRITE,\
26110144c09SMike Montour .tlv.p = (tlv_array), \
26210144c09SMike Montour .info = snd_soc_info_volsw, \
26310144c09SMike Montour .get = xhandler_get, .put = xhandler_put, \
26457295073SLars-Peter Clausen .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
265a54e22f4SCharles Keepax #define SOC_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
266a54e22f4SCharles Keepax xhandler_get, xhandler_put, tlv_array) \
267a54e22f4SCharles Keepax { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
268a54e22f4SCharles Keepax .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
269a54e22f4SCharles Keepax SNDRV_CTL_ELEM_ACCESS_READWRITE,\
270a54e22f4SCharles Keepax .tlv.p = (tlv_array), \
271a54e22f4SCharles Keepax .info = snd_soc_info_volsw_range, \
272a54e22f4SCharles Keepax .get = xhandler_get, .put = xhandler_put, \
273a54e22f4SCharles Keepax .private_value = (unsigned long)&(struct soc_mixer_control) \
274a54e22f4SCharles Keepax {.reg = xreg, .rreg = xreg, .shift = xshift, \
275a54e22f4SCharles Keepax .rshift = xshift, .min = xmin, .max = xmax, \
27626bdcc4bSSrinivas Kandagatla .invert = xinvert} }
277d0af93dbSJoonyoung Shim #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
278d0af93dbSJoonyoung Shim xhandler_get, xhandler_put, tlv_array) \
279d0af93dbSJoonyoung Shim { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
280d0af93dbSJoonyoung Shim .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
281d0af93dbSJoonyoung Shim SNDRV_CTL_ELEM_ACCESS_READWRITE, \
282d0af93dbSJoonyoung Shim .tlv.p = (tlv_array), \
283d0af93dbSJoonyoung Shim .info = snd_soc_info_volsw, \
284d0af93dbSJoonyoung Shim .get = xhandler_get, .put = xhandler_put, \
285460acbecSPeter Ujfalusi .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
28657295073SLars-Peter Clausen xmax, xinvert, 0) }
2873ce91d5aSJoonyoung Shim #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
2883ce91d5aSJoonyoung Shim xhandler_get, xhandler_put, tlv_array) \
2893ce91d5aSJoonyoung Shim { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
2903ce91d5aSJoonyoung Shim .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2913ce91d5aSJoonyoung Shim SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2923ce91d5aSJoonyoung Shim .tlv.p = (tlv_array), \
293e8f5a103SPeter Ujfalusi .info = snd_soc_info_volsw, \
2943ce91d5aSJoonyoung Shim .get = xhandler_get, .put = xhandler_put, \
295cdffa775SPeter Ujfalusi .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
296cdffa775SPeter Ujfalusi xmax, xinvert) }
297cf51406cSSimon Trimmer #define SOC_DOUBLE_R_S_EXT_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, \
298cf51406cSSimon Trimmer xsign_bit, xinvert, xhandler_get, xhandler_put, \
299cf51406cSSimon Trimmer tlv_array) \
300cf51406cSSimon Trimmer { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
301cf51406cSSimon Trimmer .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
302cf51406cSSimon Trimmer SNDRV_CTL_ELEM_ACCESS_READWRITE, \
303cf51406cSSimon Trimmer .tlv.p = (tlv_array), \
304cf51406cSSimon Trimmer .info = snd_soc_info_volsw, \
305cf51406cSSimon Trimmer .get = xhandler_get, .put = xhandler_put, \
306cf51406cSSimon Trimmer .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
307cf51406cSSimon Trimmer xmin, xmax, xsign_bit, xinvert) }
3085349c0c9SRichard Fitzgerald #define SOC_SINGLE_S_EXT_TLV(xname, xreg, xshift, xmin, xmax, \
3095349c0c9SRichard Fitzgerald xsign_bit, xinvert, xhandler_get, xhandler_put, \
3105349c0c9SRichard Fitzgerald tlv_array) \
3115349c0c9SRichard Fitzgerald SOC_DOUBLE_R_S_EXT_TLV(xname, xreg, xreg, xshift, xmin, xmax, \
3125349c0c9SRichard Fitzgerald xsign_bit, xinvert, xhandler_get, xhandler_put, \
3135349c0c9SRichard Fitzgerald tlv_array)
314808db4a4SRichard Purdie #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
315808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
316808db4a4SRichard Purdie .info = snd_soc_info_bool_ext, \
317808db4a4SRichard Purdie .get = xhandler_get, .put = xhandler_put, \
318808db4a4SRichard Purdie .private_value = xdata }
319808db4a4SRichard Purdie #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
320808db4a4SRichard Purdie { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
3219a953e6fSLars-Peter Clausen .info = snd_soc_info_enum_double, \
322808db4a4SRichard Purdie .get = xhandler_get, .put = xhandler_put, \
323808db4a4SRichard Purdie .private_value = (unsigned long)&xenum }
3241e4c0d7cSRichard Fitzgerald #define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
3251e4c0d7cSRichard Fitzgerald SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put)
326808db4a4SRichard Purdie
32771d08516SMark Brown #define SND_SOC_BYTES(xname, xbase, xregs) \
32871d08516SMark Brown { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
32971d08516SMark Brown .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
33071d08516SMark Brown .put = snd_soc_bytes_put, .private_value = \
33171d08516SMark Brown ((unsigned long)&(struct soc_bytes) \
33271d08516SMark Brown {.base = xbase, .num_regs = xregs }) }
333fb512677STzung-Bi Shih #define SND_SOC_BYTES_E(xname, xbase, xregs, xhandler_get, xhandler_put) \
334fb512677STzung-Bi Shih { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
335fb512677STzung-Bi Shih .info = snd_soc_bytes_info, .get = xhandler_get, \
336fb512677STzung-Bi Shih .put = xhandler_put, .private_value = \
337fb512677STzung-Bi Shih ((unsigned long)&(struct soc_bytes) \
338fb512677STzung-Bi Shih {.base = xbase, .num_regs = xregs }) }
339b6f4bb38Sapatard@mandriva.com
340f831b055SMark Brown #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask) \
341f831b055SMark Brown { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
342f831b055SMark Brown .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
343f831b055SMark Brown .put = snd_soc_bytes_put, .private_value = \
344f831b055SMark Brown ((unsigned long)&(struct soc_bytes) \
345f831b055SMark Brown {.base = xbase, .num_regs = xregs, \
346f831b055SMark Brown .mask = xmask }) }
347f831b055SMark Brown
34850a4f98dSVinod Koul /*
34950a4f98dSVinod Koul * SND_SOC_BYTES_EXT is deprecated, please USE SND_SOC_BYTES_TLV instead
35050a4f98dSVinod Koul */
351d9881208SVinod Koul #define SND_SOC_BYTES_EXT(xname, xcount, xhandler_get, xhandler_put) \
352d9881208SVinod Koul { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
353d9881208SVinod Koul .info = snd_soc_bytes_info_ext, \
354d9881208SVinod Koul .get = xhandler_get, .put = xhandler_put, \
355d9881208SVinod Koul .private_value = (unsigned long)&(struct soc_bytes_ext) \
356d9881208SVinod Koul {.max = xcount} }
3577523a271SOmair Mohammed Abdullah #define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \
3587523a271SOmair Mohammed Abdullah { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
3597523a271SOmair Mohammed Abdullah .access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \
3607523a271SOmair Mohammed Abdullah SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
3617523a271SOmair Mohammed Abdullah .tlv.c = (snd_soc_bytes_tlv_callback), \
3624d61b39bSSubhransu S. Prusty .info = snd_soc_bytes_info_ext, \
3637523a271SOmair Mohammed Abdullah .private_value = (unsigned long)&(struct soc_bytes_ext) \
3647523a271SOmair Mohammed Abdullah {.max = xcount, .get = xhandler_get, .put = xhandler_put, } }
3654183eed2SKristoffer KARLSSON #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
3664183eed2SKristoffer KARLSSON xmin, xmax, xinvert) \
3674183eed2SKristoffer KARLSSON { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
3684183eed2SKristoffer KARLSSON .info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
3694183eed2SKristoffer KARLSSON .put = snd_soc_put_xr_sx, \
3704183eed2SKristoffer KARLSSON .private_value = (unsigned long)&(struct soc_mreg_control) \
3714183eed2SKristoffer KARLSSON {.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
3724183eed2SKristoffer KARLSSON .invert = xinvert, .min = xmin, .max = xmax} }
3734183eed2SKristoffer KARLSSON
374dd7b10b3SKristoffer KARLSSON #define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
375dd7b10b3SKristoffer KARLSSON SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
376dd7b10b3SKristoffer KARLSSON snd_soc_get_strobe, snd_soc_put_strobe)
377dd7b10b3SKristoffer KARLSSON
378808db4a4SRichard Purdie /*
3796c2fb6a8SGuennadi Liakhovetski * Simplified versions of above macros, declaring a struct and calculating
3806c2fb6a8SGuennadi Liakhovetski * ARRAY_SIZE internally
3816c2fb6a8SGuennadi Liakhovetski */
3826c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
3832e7e1993STakashi Iwai const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
3846c2fb6a8SGuennadi Liakhovetski ARRAY_SIZE(xtexts), xtexts)
3856c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
3866c2fb6a8SGuennadi Liakhovetski SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
3876c2fb6a8SGuennadi Liakhovetski #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
3882e7e1993STakashi Iwai const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
3896c2fb6a8SGuennadi Liakhovetski #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
3902e7e1993STakashi Iwai const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
3916c2fb6a8SGuennadi Liakhovetski ARRAY_SIZE(xtexts), xtexts, xvalues)
3926c2fb6a8SGuennadi Liakhovetski #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
3936c2fb6a8SGuennadi Liakhovetski SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
394561ed680SCharles Keepax
395561ed680SCharles Keepax #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
396561ed680SCharles Keepax const struct soc_enum name = SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, \
397561ed680SCharles Keepax xshift, xmask, ARRAY_SIZE(xtexts), xtexts, xvalues)
398561ed680SCharles Keepax
399b948837aSLars-Peter Clausen #define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
400b948837aSLars-Peter Clausen const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
4016c2fb6a8SGuennadi Liakhovetski
4025a504963SStephen Warren struct device_node;
4038a2cd618SMark Brown struct snd_jack;
4048a2cd618SMark Brown struct snd_soc_card;
405808db4a4SRichard Purdie struct snd_soc_pcm_stream;
406808db4a4SRichard Purdie struct snd_soc_ops;
407808db4a4SRichard Purdie struct snd_soc_pcm_runtime;
4083c4b266fSLiam Girdwood struct snd_soc_dai;
409f0fba2adSLiam Girdwood struct snd_soc_dai_driver;
410d273ebe7Sjassi brar struct snd_soc_dai_link;
411030e79f6SKuninori Morimoto struct snd_soc_component;
412030e79f6SKuninori Morimoto struct snd_soc_component_driver;
413808db4a4SRichard Purdie struct soc_enum;
4148a2cd618SMark Brown struct snd_soc_jack;
415fa9879edSVinod Koul struct snd_soc_jack_zone;
4168a2cd618SMark Brown struct snd_soc_jack_pin;
417ce6120ccSLiam Girdwood #include <sound/soc-dapm.h>
41801d7584cSLiam Girdwood #include <sound/soc-dpcm.h>
41964527e8aSMengdong Lin #include <sound/soc-topology.h>
420f0fba2adSLiam Girdwood
421ec67624dSLopez Cruz, Misael struct snd_soc_jack_gpio;
422808db4a4SRichard Purdie
423b8c0dab9SLiam Girdwood enum snd_soc_pcm_subclass {
424b8c0dab9SLiam Girdwood SND_SOC_PCM_CLASS_PCM = 0,
425b8c0dab9SLiam Girdwood SND_SOC_PCM_CLASS_BE = 1,
426b8c0dab9SLiam Girdwood };
427b8c0dab9SLiam Girdwood
42870a7ca34SVinod Koul int snd_soc_register_card(struct snd_soc_card *card);
4291892a991SUwe Kleine-König void snd_soc_unregister_card(struct snd_soc_card *card);
4300e4ff5c8SMark Brown int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
431aae013d6SJie Yang #ifdef CONFIG_PM_SLEEP
4326f8ab4acSMark Brown int snd_soc_suspend(struct device *dev);
4336f8ab4acSMark Brown int snd_soc_resume(struct device *dev);
434aae013d6SJie Yang #else
snd_soc_suspend(struct device * dev)435aae013d6SJie Yang static inline int snd_soc_suspend(struct device *dev)
436aae013d6SJie Yang {
437aae013d6SJie Yang return 0;
438aae013d6SJie Yang }
439aae013d6SJie Yang
snd_soc_resume(struct device * dev)440aae013d6SJie Yang static inline int snd_soc_resume(struct device *dev)
441aae013d6SJie Yang {
442aae013d6SJie Yang return 0;
443aae013d6SJie Yang }
444aae013d6SJie Yang #endif
4456f8ab4acSMark Brown int snd_soc_poweroff(struct device *dev);
44608ff7209SCezary Rojewski int snd_soc_component_initialize(struct snd_soc_component *component,
44708ff7209SCezary Rojewski const struct snd_soc_component_driver *driver,
4487274d4cdSCezary Rojewski struct device *dev);
449ea029dd8SCezary Rojewski int snd_soc_add_component(struct snd_soc_component *component,
450e0dac41bSKuninori Morimoto struct snd_soc_dai_driver *dai_drv,
451e0dac41bSKuninori Morimoto int num_dai);
452030e79f6SKuninori Morimoto int snd_soc_register_component(struct device *dev,
453cf9e829eSKuninori Morimoto const struct snd_soc_component_driver *component_driver,
454030e79f6SKuninori Morimoto struct snd_soc_dai_driver *dai_drv, int num_dai);
455a0b03a61SMark Brown int devm_snd_soc_register_component(struct device *dev,
456cf9e829eSKuninori Morimoto const struct snd_soc_component_driver *component_driver,
457a0b03a61SMark Brown struct snd_soc_dai_driver *dai_drv, int num_dai);
458030e79f6SKuninori Morimoto void snd_soc_unregister_component(struct device *dev);
45958f30150SMaxime Ripard void snd_soc_unregister_component_by_driver(struct device *dev,
46058f30150SMaxime Ripard const struct snd_soc_component_driver *component_driver);
4616fbea6b6SShengjiu Wang struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
4626fbea6b6SShengjiu Wang const char *driver_name);
4637dd5d0d9SKuninori Morimoto struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
4647dd5d0d9SKuninori Morimoto const char *driver_name);
465427d204cSLars-Peter Clausen
466354a2142SMark Brown int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
4676f0c4226SJie Yang #ifdef CONFIG_SND_SOC_COMPRESS
4686f0c4226SJie Yang int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
4690b014d72SPierre-Louis Bossart #else
snd_soc_new_compress(struct snd_soc_pcm_runtime * rtd,int num)4700b014d72SPierre-Louis Bossart static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
4710b014d72SPierre-Louis Bossart {
4720b014d72SPierre-Louis Bossart return 0;
4730b014d72SPierre-Louis Bossart }
4746f0c4226SJie Yang #endif
47512a48a8cSMark Brown
476ef2e8175SKuninori Morimoto void snd_soc_disconnect_sync(struct device *dev);
477ef2e8175SKuninori Morimoto
47847c88fffSLiam Girdwood struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
4794468189fSKuninori Morimoto struct snd_soc_dai_link *dai_link);
48047c88fffSLiam Girdwood
481208a1589SLars-Peter Clausen bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
482d9051d86SKuninori Morimoto
483d9051d86SKuninori Morimoto void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
484d9051d86SKuninori Morimoto int stream, int action);
snd_soc_runtime_activate(struct snd_soc_pcm_runtime * rtd,int stream)485d9051d86SKuninori Morimoto static inline void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd,
486d9051d86SKuninori Morimoto int stream)
487d9051d86SKuninori Morimoto {
488d9051d86SKuninori Morimoto snd_soc_runtime_action(rtd, stream, 1);
489d9051d86SKuninori Morimoto }
snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime * rtd,int stream)490d9051d86SKuninori Morimoto static inline void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd,
491d9051d86SKuninori Morimoto int stream)
492d9051d86SKuninori Morimoto {
493d9051d86SKuninori Morimoto snd_soc_runtime_action(rtd, stream, -1);
494d9051d86SKuninori Morimoto }
495208a1589SLars-Peter Clausen
4965854a464SSamuel Holland int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
4975854a464SSamuel Holland struct snd_pcm_hardware *hw, int stream);
4985854a464SSamuel Holland
499ce64c8b9SLars-Peter Clausen int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
500ce64c8b9SLars-Peter Clausen unsigned int dai_fmt);
501ce64c8b9SLars-Peter Clausen
5021f5a4535STakashi Iwai #ifdef CONFIG_DMI
503345233d7SLiam Girdwood int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour);
5041f5a4535STakashi Iwai #else
snd_soc_set_dmi_name(struct snd_soc_card * card,const char * flavour)5051f5a4535STakashi Iwai static inline int snd_soc_set_dmi_name(struct snd_soc_card *card,
5061f5a4535STakashi Iwai const char *flavour)
5071f5a4535STakashi Iwai {
5081f5a4535STakashi Iwai return 0;
5091f5a4535STakashi Iwai }
5101f5a4535STakashi Iwai #endif
511345233d7SLiam Girdwood
5127aae816dSMark Brown /* Utility functions to get clock rates from various things */
5137aae816dSMark Brown int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
5147aae816dSMark Brown int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
515c0fa59dfSMark Brown int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
5167aae816dSMark Brown int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
5171ef34dd2SRichard Fitzgerald int snd_soc_tdm_params_to_bclk(struct snd_pcm_hw_params *params,
5181ef34dd2SRichard Fitzgerald int tdm_width, int tdm_slots, int slot_multiple);
5197aae816dSMark Brown
520808db4a4SRichard Purdie /* set runtime hw params */
521808db4a4SRichard Purdie int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
522808db4a4SRichard Purdie const struct snd_pcm_hardware *hw);
523808db4a4SRichard Purdie
524c95869e5SKuninori Morimoto struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
525c95869e5SKuninori Morimoto struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
5267361fbeaSLars-Peter Clausen unsigned int id, unsigned int id_mask);
527c95869e5SKuninori Morimoto void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
528808db4a4SRichard Purdie
529576ce407SArnd Bergmann #ifdef CONFIG_SND_SOC_AC97_BUS
530b047e1ccSMark Brown int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
531741a509fSMarkus Pargmann int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
532741a509fSMarkus Pargmann struct platform_device *pdev);
533b047e1ccSMark Brown
534336b8423SLars-Peter Clausen extern struct snd_ac97_bus_ops *soc_ac97_ops;
535336b8423SLars-Peter Clausen #else
snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops * ops,struct platform_device * pdev)536336b8423SLars-Peter Clausen static inline int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
537336b8423SLars-Peter Clausen struct platform_device *pdev)
538336b8423SLars-Peter Clausen {
539336b8423SLars-Peter Clausen return 0;
540336b8423SLars-Peter Clausen }
541336b8423SLars-Peter Clausen
snd_soc_set_ac97_ops(struct snd_ac97_bus_ops * ops)542336b8423SLars-Peter Clausen static inline int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
543336b8423SLars-Peter Clausen {
544336b8423SLars-Peter Clausen return 0;
545336b8423SLars-Peter Clausen }
546336b8423SLars-Peter Clausen #endif
547336b8423SLars-Peter Clausen
548808db4a4SRichard Purdie /*
549808db4a4SRichard Purdie *Controls
550808db4a4SRichard Purdie */
551808db4a4SRichard Purdie struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
5523056557fSMark Brown void *data, const char *long_name,
553efb7ac3fSMark Brown const char *prefix);
5540f2780adSLars-Peter Clausen int snd_soc_add_component_controls(struct snd_soc_component *component,
5550f2780adSLars-Peter Clausen const struct snd_kcontrol_new *controls, unsigned int num_controls);
556022658beSLiam Girdwood int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
557022658beSLiam Girdwood const struct snd_kcontrol_new *controls, int num_controls);
558022658beSLiam Girdwood int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
559022658beSLiam Girdwood const struct snd_kcontrol_new *controls, int num_controls);
560808db4a4SRichard Purdie int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
561808db4a4SRichard Purdie struct snd_ctl_elem_info *uinfo);
562808db4a4SRichard Purdie int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
563808db4a4SRichard Purdie struct snd_ctl_elem_value *ucontrol);
564808db4a4SRichard Purdie int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
565808db4a4SRichard Purdie struct snd_ctl_elem_value *ucontrol);
566808db4a4SRichard Purdie int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
567808db4a4SRichard Purdie struct snd_ctl_elem_info *uinfo);
56834198710SCharles Keepax int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
56934198710SCharles Keepax struct snd_ctl_elem_info *uinfo);
570392abe9cSPhilipp Zabel #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
571808db4a4SRichard Purdie int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
572808db4a4SRichard Purdie struct snd_ctl_elem_value *ucontrol);
573808db4a4SRichard Purdie int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
574808db4a4SRichard Purdie struct snd_ctl_elem_value *ucontrol);
575a92f1394SPeter Ujfalusi #define snd_soc_get_volsw_2r snd_soc_get_volsw
576a92f1394SPeter Ujfalusi #define snd_soc_put_volsw_2r snd_soc_put_volsw
5771d99f243SBrian Austin int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
5781d99f243SBrian Austin struct snd_ctl_elem_value *ucontrol);
5791d99f243SBrian Austin int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
5801d99f243SBrian Austin struct snd_ctl_elem_value *ucontrol);
5816c9d8cf6SAdam Thomson int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
5826c9d8cf6SAdam Thomson struct snd_ctl_elem_info *uinfo);
5836c9d8cf6SAdam Thomson int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
5846c9d8cf6SAdam Thomson struct snd_ctl_elem_value *ucontrol);
5856c9d8cf6SAdam Thomson int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
5866c9d8cf6SAdam Thomson struct snd_ctl_elem_value *ucontrol);
58726d9ca34SLars-Peter Clausen int snd_soc_limit_volume(struct snd_soc_card *card,
588637d3847SPeter Ujfalusi const char *name, int max);
58971d08516SMark Brown int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
59071d08516SMark Brown struct snd_ctl_elem_info *uinfo);
59171d08516SMark Brown int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
59271d08516SMark Brown struct snd_ctl_elem_value *ucontrol);
59371d08516SMark Brown int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
59471d08516SMark Brown struct snd_ctl_elem_value *ucontrol);
595d9881208SVinod Koul int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
596d9881208SVinod Koul struct snd_ctl_elem_info *ucontrol);
5977523a271SOmair Mohammed Abdullah int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
5987523a271SOmair Mohammed Abdullah unsigned int size, unsigned int __user *tlv);
5994183eed2SKristoffer KARLSSON int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
6004183eed2SKristoffer KARLSSON struct snd_ctl_elem_info *uinfo);
6014183eed2SKristoffer KARLSSON int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
6024183eed2SKristoffer KARLSSON struct snd_ctl_elem_value *ucontrol);
6034183eed2SKristoffer KARLSSON int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
6044183eed2SKristoffer KARLSSON struct snd_ctl_elem_value *ucontrol);
605dd7b10b3SKristoffer KARLSSON int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
606dd7b10b3SKristoffer KARLSSON struct snd_ctl_elem_value *ucontrol);
607dd7b10b3SKristoffer KARLSSON int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
608dd7b10b3SKristoffer KARLSSON struct snd_ctl_elem_value *ucontrol);
609808db4a4SRichard Purdie
610356caf66SKuninori Morimoto enum snd_soc_trigger_order {
611356caf66SKuninori Morimoto /* start stop */
612356caf66SKuninori Morimoto SND_SOC_TRIGGER_ORDER_DEFAULT = 0, /* Link->Component->DAI DAI->Component->Link */
613356caf66SKuninori Morimoto SND_SOC_TRIGGER_ORDER_LDC, /* Link->DAI->Component Component->DAI->Link */
614356caf66SKuninori Morimoto
615356caf66SKuninori Morimoto SND_SOC_TRIGGER_ORDER_MAX,
616356caf66SKuninori Morimoto };
617356caf66SKuninori Morimoto
618808db4a4SRichard Purdie /* SoC PCM stream information */
619808db4a4SRichard Purdie struct snd_soc_pcm_stream {
620f0fba2adSLiam Girdwood const char *stream_name;
6211c433fbdSGraeme Gregory u64 formats; /* SNDRV_PCM_FMTBIT_* */
6221c433fbdSGraeme Gregory unsigned int rates; /* SNDRV_PCM_RATE_* */
623808db4a4SRichard Purdie unsigned int rate_min; /* min rate */
624808db4a4SRichard Purdie unsigned int rate_max; /* max rate */
625808db4a4SRichard Purdie unsigned int channels_min; /* min channels */
626808db4a4SRichard Purdie unsigned int channels_max; /* max channels */
62758ba9b25SMark Brown unsigned int sig_bits; /* number of bits of content */
628808db4a4SRichard Purdie };
629808db4a4SRichard Purdie
630808db4a4SRichard Purdie /* SoC audio ops */
631808db4a4SRichard Purdie struct snd_soc_ops {
632808db4a4SRichard Purdie int (*startup)(struct snd_pcm_substream *);
633808db4a4SRichard Purdie void (*shutdown)(struct snd_pcm_substream *);
634808db4a4SRichard Purdie int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
635808db4a4SRichard Purdie int (*hw_free)(struct snd_pcm_substream *);
636808db4a4SRichard Purdie int (*prepare)(struct snd_pcm_substream *);
637808db4a4SRichard Purdie int (*trigger)(struct snd_pcm_substream *, int);
638808db4a4SRichard Purdie };
639808db4a4SRichard Purdie
64049681077SVinod Koul struct snd_soc_compr_ops {
64149681077SVinod Koul int (*startup)(struct snd_compr_stream *);
64249681077SVinod Koul void (*shutdown)(struct snd_compr_stream *);
64349681077SVinod Koul int (*set_params)(struct snd_compr_stream *);
64449681077SVinod Koul };
64549681077SVinod Koul
646a0ac4411SKuninori Morimoto struct snd_soc_component*
647a0ac4411SKuninori Morimoto snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
648a0ac4411SKuninori Morimoto const char *driver_name);
649a0ac4411SKuninori Morimoto
65088bd870fSBenoit Cousson struct snd_soc_dai_link_component {
65188bd870fSBenoit Cousson const char *name;
652c362effeSJean-Francois Moine struct device_node *of_node;
65388bd870fSBenoit Cousson const char *dai_name;
65445655ec6SKuninori Morimoto struct of_phandle_args *dai_args;
65588bd870fSBenoit Cousson };
65688bd870fSBenoit Cousson
657ac950278SBard Liao struct snd_soc_dai_link_codec_ch_map {
658ac950278SBard Liao unsigned int connected_cpu_id;
659ac950278SBard Liao unsigned int ch_mask;
660ac950278SBard Liao };
661ac950278SBard Liao
662808db4a4SRichard Purdie struct snd_soc_dai_link {
663f0fba2adSLiam Girdwood /* config - must be set by machine driver */
664f0fba2adSLiam Girdwood const char *name; /* Codec name */
665f0fba2adSLiam Girdwood const char *stream_name; /* Stream name */
66662bc79d3SKuninori Morimoto
66762bc79d3SKuninori Morimoto /*
668bc92657aSStephen Warren * You MAY specify the link's CPU-side device, either by device name,
669bc92657aSStephen Warren * or by DT/OF node, but not both. If this information is omitted,
670bc92657aSStephen Warren * the CPU-side DAI is matched using .cpu_dai_name only, which hence
671bc92657aSStephen Warren * must be globally unique. These fields are currently typically used
672bc92657aSStephen Warren * only for codec to codec links, or systems using device tree.
673bc92657aSStephen Warren */
674bc92657aSStephen Warren /*
675bc92657aSStephen Warren * You MAY specify the DAI name of the CPU DAI. If this information is
676bc92657aSStephen Warren * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
677bc92657aSStephen Warren * only, which only works well when that device exposes a single DAI.
678bc92657aSStephen Warren */
67908a5841eSKuninori Morimoto struct snd_soc_dai_link_component *cpus;
68008a5841eSKuninori Morimoto unsigned int num_cpus;
68108a5841eSKuninori Morimoto
68262bc79d3SKuninori Morimoto /*
683bc92657aSStephen Warren * You MUST specify the link's codec, either by device name, or by
684bc92657aSStephen Warren * DT/OF node, but not both.
685bc92657aSStephen Warren */
686bc92657aSStephen Warren /* You MUST specify the DAI name within the codec */
68788bd870fSBenoit Cousson struct snd_soc_dai_link_component *codecs;
68888bd870fSBenoit Cousson unsigned int num_codecs;
68988bd870fSBenoit Cousson
690ac950278SBard Liao struct snd_soc_dai_link_codec_ch_map *codec_ch_maps;
691bc92657aSStephen Warren /*
692bc92657aSStephen Warren * You MAY specify the link's platform/PCM/DMA driver, either by
693bc92657aSStephen Warren * device name, or by DT/OF node, but not both. Some forms of link
6941d768989SKuninori Morimoto * do not need a platform. In such case, platforms are not mandatory.
695bc92657aSStephen Warren */
696910fdcabSKuninori Morimoto struct snd_soc_dai_link_component *platforms;
697910fdcabSKuninori Morimoto unsigned int num_platforms;
698daecf46eSKuninori Morimoto
6992f0ad491SMengdong Lin int id; /* optional ID for machine driver link identification */
7004ccab3e7SLiam Girdwood
7017ddc7f91SKuninori Morimoto /*
7027ddc7f91SKuninori Morimoto * for Codec2Codec
7037ddc7f91SKuninori Morimoto */
7047ddc7f91SKuninori Morimoto const struct snd_soc_pcm_stream *c2c_params;
7057ddc7f91SKuninori Morimoto unsigned int num_c2c_params;
7067ddc7f91SKuninori Morimoto
70775d9ac46SMark Brown unsigned int dai_fmt; /* format to set on init */
70875d9ac46SMark Brown
70901d7584cSLiam Girdwood enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
71001d7584cSLiam Girdwood
711f0fba2adSLiam Girdwood /* codec/machine specific init - e.g. add machine controls */
712f0fba2adSLiam Girdwood int (*init)(struct snd_soc_pcm_runtime *rtd);
71306f409d7SMark Brown
71421a00fb3SPierre-Louis Bossart /* codec/machine specific exit - dual of init() */
71521a00fb3SPierre-Louis Bossart void (*exit)(struct snd_soc_pcm_runtime *rtd);
71621a00fb3SPierre-Louis Bossart
71701d7584cSLiam Girdwood /* optional hw_params re-writing for BE and FE sync */
71801d7584cSLiam Girdwood int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
71901d7584cSLiam Girdwood struct snd_pcm_hw_params *params);
72001d7584cSLiam Girdwood
721f0fba2adSLiam Girdwood /* machine stream operations */
72213aec722SLars-Peter Clausen const struct snd_soc_ops *ops;
72313aec722SLars-Peter Clausen const struct snd_soc_compr_ops *compr_ops;
724d6bead02SFabio Estevam
725356caf66SKuninori Morimoto /*
726356caf66SKuninori Morimoto * soc_pcm_trigger() start/stop sequence.
727356caf66SKuninori Morimoto * see also
728356caf66SKuninori Morimoto * snd_soc_component_driver
729356caf66SKuninori Morimoto * soc_pcm_trigger()
730356caf66SKuninori Morimoto */
731356caf66SKuninori Morimoto enum snd_soc_trigger_order trigger_start;
732356caf66SKuninori Morimoto enum snd_soc_trigger_order trigger_stop;
733356caf66SKuninori Morimoto
7342dc0f16bSKuninori Morimoto /* Mark this pcm with non atomic ops */
735317ec675SKuninori Morimoto unsigned int nonatomic:1;
7362dc0f16bSKuninori Morimoto
7371236fa1eSKuninori Morimoto /* For unidirectional dai links */
7381236fa1eSKuninori Morimoto unsigned int playback_only:1;
7391236fa1eSKuninori Morimoto unsigned int capture_only:1;
7401236fa1eSKuninori Morimoto
7412dc0f16bSKuninori Morimoto /* Keep DAI active over suspend */
7422dc0f16bSKuninori Morimoto unsigned int ignore_suspend:1;
7432dc0f16bSKuninori Morimoto
7442dc0f16bSKuninori Morimoto /* Symmetry requirements */
745f14654ddSKuninori Morimoto unsigned int symmetric_rate:1;
7462dc0f16bSKuninori Morimoto unsigned int symmetric_channels:1;
747f14654ddSKuninori Morimoto unsigned int symmetric_sample_bits:1;
7482dc0f16bSKuninori Morimoto
7492dc0f16bSKuninori Morimoto /* Do not create a PCM for this DAI link (Backend link) */
7502dc0f16bSKuninori Morimoto unsigned int no_pcm:1;
7512dc0f16bSKuninori Morimoto
7522dc0f16bSKuninori Morimoto /* This DAI link can route to other DAI links at runtime (Frontend)*/
7532dc0f16bSKuninori Morimoto unsigned int dynamic:1;
7542dc0f16bSKuninori Morimoto
7552dc0f16bSKuninori Morimoto /* DPCM capture and Playback support */
7562dc0f16bSKuninori Morimoto unsigned int dpcm_capture:1;
7572dc0f16bSKuninori Morimoto unsigned int dpcm_playback:1;
7582dc0f16bSKuninori Morimoto
759b073ed4eSKuninori Morimoto /* DPCM used FE & BE merged format */
760b073ed4eSKuninori Morimoto unsigned int dpcm_merged_format:1;
761f4c277b8SJiada Wang /* DPCM used FE & BE merged channel */
762f4c277b8SJiada Wang unsigned int dpcm_merged_chan:1;
763baacd8d1SJerome Brunet /* DPCM used FE & BE merged rate */
764baacd8d1SJerome Brunet unsigned int dpcm_merged_rate:1;
765b073ed4eSKuninori Morimoto
7662dc0f16bSKuninori Morimoto /* pmdown_time is ignored at stop */
7672dc0f16bSKuninori Morimoto unsigned int ignore_pmdown_time:1;
768f8f80361SMengdong Lin
769a655de80SLiam Girdwood /* Do not create a PCM for this DAI link (Backend link) */
770a655de80SLiam Girdwood unsigned int ignore:1;
771a655de80SLiam Girdwood
772509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY
773f8f80361SMengdong Lin struct snd_soc_dobj dobj; /* For topology */
774509ba54fSKuninori Morimoto #endif
775808db4a4SRichard Purdie };
7764da40cb9SKuninori Morimoto
777c92c96cdSKuninori Morimoto /* REMOVE ME */
778c92c96cdSKuninori Morimoto #define asoc_link_to_cpu snd_soc_link_to_cpu
779c92c96cdSKuninori Morimoto #define asoc_link_to_codec snd_soc_link_to_codec
780c92c96cdSKuninori Morimoto #define asoc_link_to_platform snd_soc_link_to_platform
781c92c96cdSKuninori Morimoto
7824da40cb9SKuninori Morimoto static inline struct snd_soc_dai_link_component*
snd_soc_link_to_cpu(struct snd_soc_dai_link * link,int n)783c92c96cdSKuninori Morimoto snd_soc_link_to_cpu(struct snd_soc_dai_link *link, int n) {
7844da40cb9SKuninori Morimoto return &(link)->cpus[n];
7854da40cb9SKuninori Morimoto }
7864da40cb9SKuninori Morimoto
7874da40cb9SKuninori Morimoto static inline struct snd_soc_dai_link_component*
snd_soc_link_to_codec(struct snd_soc_dai_link * link,int n)788c92c96cdSKuninori Morimoto snd_soc_link_to_codec(struct snd_soc_dai_link *link, int n) {
7894da40cb9SKuninori Morimoto return &(link)->codecs[n];
7904da40cb9SKuninori Morimoto }
7914da40cb9SKuninori Morimoto
7924da40cb9SKuninori Morimoto static inline struct snd_soc_dai_link_component*
snd_soc_link_to_platform(struct snd_soc_dai_link * link,int n)793c92c96cdSKuninori Morimoto snd_soc_link_to_platform(struct snd_soc_dai_link *link, int n) {
7944da40cb9SKuninori Morimoto return &(link)->platforms[n];
7954da40cb9SKuninori Morimoto }
7964da40cb9SKuninori Morimoto
7973db769f1SKuninori Morimoto #define for_each_link_codecs(link, i, codec) \
7983db769f1SKuninori Morimoto for ((i) = 0; \
7994da40cb9SKuninori Morimoto ((i) < link->num_codecs) && \
800c92c96cdSKuninori Morimoto ((codec) = snd_soc_link_to_codec(link, i)); \
8013db769f1SKuninori Morimoto (i)++)
802808db4a4SRichard Purdie
80334614739SJerome Brunet #define for_each_link_platforms(link, i, platform) \
80434614739SJerome Brunet for ((i) = 0; \
80534614739SJerome Brunet ((i) < link->num_platforms) && \
806c92c96cdSKuninori Morimoto ((platform) = snd_soc_link_to_platform(link, i)); \
80734614739SJerome Brunet (i)++)
80834614739SJerome Brunet
80976afa643SShreyas NC #define for_each_link_cpus(link, i, cpu) \
81076afa643SShreyas NC for ((i) = 0; \
8114da40cb9SKuninori Morimoto ((i) < link->num_cpus) && \
812c92c96cdSKuninori Morimoto ((cpu) = snd_soc_link_to_cpu(link, i)); \
81376afa643SShreyas NC (i)++)
81476afa643SShreyas NC
815587c9844SKuninori Morimoto /*
816587c9844SKuninori Morimoto * Sample 1 : Single CPU/Codec/Platform
817587c9844SKuninori Morimoto *
818587c9844SKuninori Morimoto * SND_SOC_DAILINK_DEFS(test,
819587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")),
820587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CODEC("codec", "codec_dai")),
821587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
822587c9844SKuninori Morimoto *
823587c9844SKuninori Morimoto * struct snd_soc_dai_link link = {
824587c9844SKuninori Morimoto * ...
825587c9844SKuninori Morimoto * SND_SOC_DAILINK_REG(test),
826587c9844SKuninori Morimoto * };
827587c9844SKuninori Morimoto *
828587c9844SKuninori Morimoto * Sample 2 : Multi CPU/Codec, no Platform
829587c9844SKuninori Morimoto *
830587c9844SKuninori Morimoto * SND_SOC_DAILINK_DEFS(test,
831587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
832587c9844SKuninori Morimoto * COMP_CPU("cpu_dai2")),
833587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
834587c9844SKuninori Morimoto * COMP_CODEC("codec2", "codec_dai2")));
835587c9844SKuninori Morimoto *
836587c9844SKuninori Morimoto * struct snd_soc_dai_link link = {
837587c9844SKuninori Morimoto * ...
838587c9844SKuninori Morimoto * SND_SOC_DAILINK_REG(test),
839587c9844SKuninori Morimoto * };
840587c9844SKuninori Morimoto *
841587c9844SKuninori Morimoto * Sample 3 : Define each CPU/Codec/Platform manually
842587c9844SKuninori Morimoto *
843587c9844SKuninori Morimoto * SND_SOC_DAILINK_DEF(test_cpu,
844587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
845587c9844SKuninori Morimoto * COMP_CPU("cpu_dai2")));
846587c9844SKuninori Morimoto * SND_SOC_DAILINK_DEF(test_codec,
847587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
848587c9844SKuninori Morimoto * COMP_CODEC("codec2", "codec_dai2")));
849587c9844SKuninori Morimoto * SND_SOC_DAILINK_DEF(test_platform,
850587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
851587c9844SKuninori Morimoto *
852587c9844SKuninori Morimoto * struct snd_soc_dai_link link = {
853587c9844SKuninori Morimoto * ...
854587c9844SKuninori Morimoto * SND_SOC_DAILINK_REG(test_cpu,
855587c9844SKuninori Morimoto * test_codec,
856587c9844SKuninori Morimoto * test_platform),
857587c9844SKuninori Morimoto * };
858587c9844SKuninori Morimoto *
859587c9844SKuninori Morimoto * Sample 4 : Sample3 without platform
860587c9844SKuninori Morimoto *
861587c9844SKuninori Morimoto * struct snd_soc_dai_link link = {
862587c9844SKuninori Morimoto * ...
863587c9844SKuninori Morimoto * SND_SOC_DAILINK_REG(test_cpu,
864587c9844SKuninori Morimoto * test_codec);
865587c9844SKuninori Morimoto * };
866587c9844SKuninori Morimoto */
867587c9844SKuninori Morimoto
868587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG1(name) SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms)
869587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG2(cpu, codec) SND_SOC_DAILINK_REG3(cpu, codec, null_dailink_component)
870587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG3(cpu, codec, platform) \
871587c9844SKuninori Morimoto .cpus = cpu, \
872587c9844SKuninori Morimoto .num_cpus = ARRAY_SIZE(cpu), \
873587c9844SKuninori Morimoto .codecs = codec, \
874587c9844SKuninori Morimoto .num_codecs = ARRAY_SIZE(codec), \
875587c9844SKuninori Morimoto .platforms = platform, \
876587c9844SKuninori Morimoto .num_platforms = ARRAY_SIZE(platform)
877587c9844SKuninori Morimoto
878587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func
879587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG(...) \
880587c9844SKuninori Morimoto SND_SOC_DAILINK_REGx(__VA_ARGS__, \
881587c9844SKuninori Morimoto SND_SOC_DAILINK_REG3, \
882587c9844SKuninori Morimoto SND_SOC_DAILINK_REG2, \
883587c9844SKuninori Morimoto SND_SOC_DAILINK_REG1)(__VA_ARGS__)
884587c9844SKuninori Morimoto
885587c9844SKuninori Morimoto #define SND_SOC_DAILINK_DEF(name, def...) \
886587c9844SKuninori Morimoto static struct snd_soc_dai_link_component name[] = { def }
887587c9844SKuninori Morimoto
888587c9844SKuninori Morimoto #define SND_SOC_DAILINK_DEFS(name, cpu, codec, platform...) \
889587c9844SKuninori Morimoto SND_SOC_DAILINK_DEF(name##_cpus, cpu); \
890587c9844SKuninori Morimoto SND_SOC_DAILINK_DEF(name##_codecs, codec); \
891587c9844SKuninori Morimoto SND_SOC_DAILINK_DEF(name##_platforms, platform)
892587c9844SKuninori Morimoto
893587c9844SKuninori Morimoto #define DAILINK_COMP_ARRAY(param...) param
894587c9844SKuninori Morimoto #define COMP_EMPTY() { }
895587c9844SKuninori Morimoto #define COMP_CPU(_dai) { .dai_name = _dai, }
896587c9844SKuninori Morimoto #define COMP_CODEC(_name, _dai) { .name = _name, .dai_name = _dai, }
897587c9844SKuninori Morimoto #define COMP_PLATFORM(_name) { .name = _name }
8983dc29b8bSKuninori Morimoto #define COMP_AUX(_name) { .name = _name }
899c13493a2SKuninori Morimoto #define COMP_CODEC_CONF(_name) { .name = _name }
900587c9844SKuninori Morimoto #define COMP_DUMMY() { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
901587c9844SKuninori Morimoto
902c92c96cdSKuninori Morimoto /* REMOVE ME */
903c92c96cdSKuninori Morimoto #define asoc_dummy_dlc snd_soc_dummy_dlc
904c92c96cdSKuninori Morimoto
905587c9844SKuninori Morimoto extern struct snd_soc_dai_link_component null_dailink_component[0];
906c92c96cdSKuninori Morimoto extern struct snd_soc_dai_link_component snd_soc_dummy_dlc;
907587c9844SKuninori Morimoto
908587c9844SKuninori Morimoto
909ff819b83SDimitris Papastamos struct snd_soc_codec_conf {
9103ca041edSSebastian Reichel /*
9113ca041edSSebastian Reichel * specify device either by device name, or by
9123ca041edSSebastian Reichel * DT/OF node, but not both.
9133ca041edSSebastian Reichel */
914c13493a2SKuninori Morimoto struct snd_soc_dai_link_component dlc;
915c13493a2SKuninori Morimoto
916ff819b83SDimitris Papastamos /*
917ff819b83SDimitris Papastamos * optional map of kcontrol, widget and path name prefixes that are
918ff819b83SDimitris Papastamos * associated per device
919ff819b83SDimitris Papastamos */
920ead9b919SJarkko Nikula const char *name_prefix;
921ead9b919SJarkko Nikula };
922ead9b919SJarkko Nikula
9232eea392dSJarkko Nikula struct snd_soc_aux_dev {
9243ca041edSSebastian Reichel /*
9253ca041edSSebastian Reichel * specify multi-codec either by device name, or by
9263ca041edSSebastian Reichel * DT/OF node, but not both.
9273ca041edSSebastian Reichel */
9283dc29b8bSKuninori Morimoto struct snd_soc_dai_link_component dlc;
9293dc29b8bSKuninori Morimoto
9302eea392dSJarkko Nikula /* codec/machine specific init - e.g. add machine controls */
93157bf7726SLars-Peter Clausen int (*init)(struct snd_soc_component *component);
9322eea392dSJarkko Nikula };
9332eea392dSJarkko Nikula
93487506549SMark Brown /* SoC card */
93587506549SMark Brown struct snd_soc_card {
936f0fba2adSLiam Girdwood const char *name;
93722de71baSLiam Girdwood const char *long_name;
93822de71baSLiam Girdwood const char *driver_name;
939dc73d73aSJaroslav Kysela const char *components;
9408a6a6a38SKuninori Morimoto #ifdef CONFIG_DMI
941345233d7SLiam Girdwood char dmi_longname[80];
9428a6a6a38SKuninori Morimoto #endif /* CONFIG_DMI */
943c766264eSRichard Fitzgerald
944c766264eSRichard Fitzgerald #ifdef CONFIG_PCI
945c766264eSRichard Fitzgerald /*
946c766264eSRichard Fitzgerald * PCI does not define 0 as invalid, so pci_subsystem_set indicates
947c766264eSRichard Fitzgerald * whether a value has been written to these fields.
948c766264eSRichard Fitzgerald */
949c766264eSRichard Fitzgerald unsigned short pci_subsystem_vendor;
950c766264eSRichard Fitzgerald unsigned short pci_subsystem_device;
951c766264eSRichard Fitzgerald bool pci_subsystem_set;
952c766264eSRichard Fitzgerald #endif /* CONFIG_PCI */
953c766264eSRichard Fitzgerald
954a655de80SLiam Girdwood char topology_shortname[32];
955345233d7SLiam Girdwood
956c5af3a2eSMark Brown struct device *dev;
957f0fba2adSLiam Girdwood struct snd_card *snd_card;
958f0fba2adSLiam Girdwood struct module *owner;
959c5af3a2eSMark Brown
960f0fba2adSLiam Girdwood struct mutex mutex;
961a73fb2dfSLiam Girdwood struct mutex dapm_mutex;
962c5af3a2eSMark Brown
96372b745e3SPeter Ujfalusi /* Mutex for PCM operations */
96472b745e3SPeter Ujfalusi struct mutex pcm_mutex;
96572b745e3SPeter Ujfalusi enum snd_soc_pcm_subclass pcm_subclass;
96672b745e3SPeter Ujfalusi
967e7361ec4SMark Brown int (*probe)(struct snd_soc_card *card);
96828e9ad92SMark Brown int (*late_probe)(struct snd_soc_card *card);
969df4d27b1SMartin Povišer void (*fixup_controls)(struct snd_soc_card *card);
970e7361ec4SMark Brown int (*remove)(struct snd_soc_card *card);
971808db4a4SRichard Purdie
972808db4a4SRichard Purdie /* the pre and post PM functions are used to do any PM work before and
973808db4a4SRichard Purdie * after the codec and DAI's do any PM work. */
97470b2ac12SMark Brown int (*suspend_pre)(struct snd_soc_card *card);
97570b2ac12SMark Brown int (*suspend_post)(struct snd_soc_card *card);
97670b2ac12SMark Brown int (*resume_pre)(struct snd_soc_card *card);
97770b2ac12SMark Brown int (*resume_post)(struct snd_soc_card *card);
978808db4a4SRichard Purdie
9790b4d221bSLiam Girdwood /* callbacks */
98087506549SMark Brown int (*set_bias_level)(struct snd_soc_card *,
981d4c6005fSMark Brown struct snd_soc_dapm_context *dapm,
9820be9898aSMark Brown enum snd_soc_bias_level level);
9831badabd9SMark Brown int (*set_bias_level_post)(struct snd_soc_card *,
984d4c6005fSMark Brown struct snd_soc_dapm_context *dapm,
9851badabd9SMark Brown enum snd_soc_bias_level level);
9860b4d221bSLiam Girdwood
987d6f220eaSMengdong Lin int (*add_dai_link)(struct snd_soc_card *,
988d6f220eaSMengdong Lin struct snd_soc_dai_link *link);
989d6f220eaSMengdong Lin void (*remove_dai_link)(struct snd_soc_card *,
990d6f220eaSMengdong Lin struct snd_soc_dai_link *link);
991d6f220eaSMengdong Lin
9926c5f1fedSMark Brown long pmdown_time;
99396dd3622SMark Brown
994808db4a4SRichard Purdie /* CPU <--> Codec DAI links */
995f8f80361SMengdong Lin struct snd_soc_dai_link *dai_link; /* predefined links only */
996f8f80361SMengdong Lin int num_links; /* predefined links only */
997f8f80361SMengdong Lin
9981a497983SMengdong Lin struct list_head rtd_list;
999f0fba2adSLiam Girdwood int num_rtd;
10006308419aSMark Brown
1001ff819b83SDimitris Papastamos /* optional codec specific configuration */
1002ff819b83SDimitris Papastamos struct snd_soc_codec_conf *codec_conf;
1003ff819b83SDimitris Papastamos int num_configs;
1004ead9b919SJarkko Nikula
10052eea392dSJarkko Nikula /*
10062eea392dSJarkko Nikula * optional auxiliary devices such as amplifiers or codecs with DAI
10072eea392dSJarkko Nikula * link unused
10082eea392dSJarkko Nikula */
10092eea392dSJarkko Nikula struct snd_soc_aux_dev *aux_dev;
10102eea392dSJarkko Nikula int num_aux_devs;
1011d2e3a135SSylwester Nawrocki struct list_head aux_comp_list;
10122eea392dSJarkko Nikula
1013b7af1dafSMark Brown const struct snd_kcontrol_new *controls;
1014b7af1dafSMark Brown int num_controls;
1015b7af1dafSMark Brown
1016b8ad29deSMark Brown /*
1017b8ad29deSMark Brown * Card-specific routes and widgets.
1018f23e860eSNicolin Chen * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
1019b8ad29deSMark Brown */
1020d06e48dbSLars-Peter Clausen const struct snd_soc_dapm_widget *dapm_widgets;
1021b8ad29deSMark Brown int num_dapm_widgets;
1022d06e48dbSLars-Peter Clausen const struct snd_soc_dapm_route *dapm_routes;
1023b8ad29deSMark Brown int num_dapm_routes;
1024f23e860eSNicolin Chen const struct snd_soc_dapm_widget *of_dapm_widgets;
1025f23e860eSNicolin Chen int num_of_dapm_widgets;
1026f23e860eSNicolin Chen const struct snd_soc_dapm_route *of_dapm_routes;
1027f23e860eSNicolin Chen int num_of_dapm_routes;
1028b8ad29deSMark Brown
1029f0fba2adSLiam Girdwood /* lists of probed devices belonging to this card */
1030d9fc4063SKuninori Morimoto struct list_head component_dev_list;
1031e894efefSSrinivas Kandagatla struct list_head list;
1032a6052154SJarkko Nikula
103397c866deSJarkko Nikula struct list_head widgets;
10348ddab3f5SJarkko Nikula struct list_head paths;
10357be31be8SJarkko Nikula struct list_head dapm_list;
1036db432b41SMark Brown struct list_head dapm_dirty;
10378ddab3f5SJarkko Nikula
10388a978234SLiam Girdwood /* attached dynamic objects */
10398a978234SLiam Girdwood struct list_head dobj_list;
10408a978234SLiam Girdwood
1041e37a4970SMark Brown /* Generic DAPM context for the card */
1042e37a4970SMark Brown struct snd_soc_dapm_context dapm;
1043de02d078SMark Brown struct snd_soc_dapm_stats dapm_stats;
1044564c6504SLars-Peter Clausen struct snd_soc_dapm_update *update;
1045e37a4970SMark Brown
1046a6052154SJarkko Nikula #ifdef CONFIG_DEBUG_FS
1047a6052154SJarkko Nikula struct dentry *debugfs_card_root;
1048a6052154SJarkko Nikula #endif
1049b3da4251SKuninori Morimoto #ifdef CONFIG_PM_SLEEP
1050b3da4251SKuninori Morimoto struct work_struct deferred_resume_work;
1051b3da4251SKuninori Morimoto #endif
10523a45b867SJarkko Nikula u32 pop_time;
1053dddf3e4cSMark Brown
1054317ec675SKuninori Morimoto /* bit field */
1055317ec675SKuninori Morimoto unsigned int instantiated:1;
1056317ec675SKuninori Morimoto unsigned int topology_shortname_created:1;
1057317ec675SKuninori Morimoto unsigned int fully_routed:1;
1058317ec675SKuninori Morimoto unsigned int disable_route_checks:1;
105927f07cacSKuninori Morimoto unsigned int probed:1;
1060aa293777SSameer Pujar unsigned int component_chaining:1;
1061317ec675SKuninori Morimoto
1062dddf3e4cSMark Brown void *drvdata;
1063808db4a4SRichard Purdie };
10647fe072b4SKuninori Morimoto #define for_each_card_prelinks(card, i, link) \
10657fe072b4SKuninori Morimoto for ((i) = 0; \
10667fe072b4SKuninori Morimoto ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
10677fe072b4SKuninori Morimoto (i)++)
1068c2b71c71SKuninori Morimoto #define for_each_card_pre_auxs(card, i, aux) \
1069c2b71c71SKuninori Morimoto for ((i) = 0; \
1070c2b71c71SKuninori Morimoto ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \
1071c2b71c71SKuninori Morimoto (i)++)
1072808db4a4SRichard Purdie
1073bcb1fd1fSKuninori Morimoto #define for_each_card_rtds(card, rtd) \
1074bcb1fd1fSKuninori Morimoto list_for_each_entry(rtd, &(card)->rtd_list, list)
1075bcb1fd1fSKuninori Morimoto #define for_each_card_rtds_safe(card, rtd, _rtd) \
1076bcb1fd1fSKuninori Morimoto list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list)
107798061fdbSKuninori Morimoto
1078c2b71c71SKuninori Morimoto #define for_each_card_auxs(card, component) \
1079c2b71c71SKuninori Morimoto list_for_each_entry(component, &card->aux_comp_list, card_aux_list)
1080c2b71c71SKuninori Morimoto #define for_each_card_auxs_safe(card, component, _comp) \
1081c2b71c71SKuninori Morimoto list_for_each_entry_safe(component, _comp, \
1082c2b71c71SKuninori Morimoto &card->aux_comp_list, card_aux_list)
1083c2b71c71SKuninori Morimoto
1084f70f18f7SKuninori Morimoto #define for_each_card_components(card, component) \
1085f70f18f7SKuninori Morimoto list_for_each_entry(component, &(card)->component_dev_list, card_list)
1086f70f18f7SKuninori Morimoto
1087df817f8eSKuninori Morimoto #define for_each_card_dapms(card, dapm) \
1088df817f8eSKuninori Morimoto list_for_each_entry(dapm, &card->dapm_list, list)
1089df817f8eSKuninori Morimoto
109014596692SKuninori Morimoto #define for_each_card_widgets(card, w)\
109114596692SKuninori Morimoto list_for_each_entry(w, &card->widgets, list)
109214596692SKuninori Morimoto #define for_each_card_widgets_safe(card, w, _w) \
109314596692SKuninori Morimoto list_for_each_entry_safe(w, _w, &card->widgets, list)
109414596692SKuninori Morimoto
10952e5f8617SKuninori Morimoto
snd_soc_card_is_instantiated(struct snd_soc_card * card)10962e5f8617SKuninori Morimoto static inline int snd_soc_card_is_instantiated(struct snd_soc_card *card)
10972e5f8617SKuninori Morimoto {
10982e5f8617SKuninori Morimoto return card && card->instantiated;
10992e5f8617SKuninori Morimoto }
11002e5f8617SKuninori Morimoto
1101f0fba2adSLiam Girdwood /* SoC machine DAI configuration, glues a codec and cpu DAI together */
1102808db4a4SRichard Purdie struct snd_soc_pcm_runtime {
110336ae1a96SMark Brown struct device *dev;
1104f0fba2adSLiam Girdwood struct snd_soc_card *card;
1105f0fba2adSLiam Girdwood struct snd_soc_dai_link *dai_link;
1106b8c0dab9SLiam Girdwood struct snd_pcm_ops ops;
1107f0fba2adSLiam Girdwood
11087ddc7f91SKuninori Morimoto unsigned int c2c_params_select; /* currently selected c2c_param for dai link */
1109243bcfafSCharles Keepax
111001d7584cSLiam Girdwood /* Dynamic PCM BE runtime data */
1111a26ec2acSKuninori Morimoto struct snd_soc_dpcm_runtime dpcm[SNDRV_PCM_STREAM_LAST + 1];
11123289dc02SKuninori Morimoto struct snd_soc_dapm_widget *c2c_widget[SNDRV_PCM_STREAM_LAST + 1];
111301d7584cSLiam Girdwood
1114f0fba2adSLiam Girdwood long pmdown_time;
1115f0fba2adSLiam Girdwood
1116f0fba2adSLiam Girdwood /* runtime devices */
1117f0fba2adSLiam Girdwood struct snd_pcm *pcm;
111849681077SVinod Koul struct snd_compr *compr;
11191729025bSKuninori Morimoto
11201729025bSKuninori Morimoto /*
11211729025bSKuninori Morimoto * dais = cpu_dai + codec_dai
11221729025bSKuninori Morimoto * see
11231729025bSKuninori Morimoto * soc_new_pcm_runtime()
1124c92c96cdSKuninori Morimoto * snd_soc_rtd_to_cpu()
1125c92c96cdSKuninori Morimoto * snd_soc_rtd_to_codec()
11261729025bSKuninori Morimoto */
112722a2fc81SKuninori Morimoto struct snd_soc_dai **dais;
112876afa643SShreyas NC
1129f0fba2adSLiam Girdwood struct delayed_work delayed_work;
11304bf2e385SCurtis Malainey void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
1131f86dcef8SLiam Girdwood #ifdef CONFIG_DEBUG_FS
1132f86dcef8SLiam Girdwood struct dentry *debugfs_dpcm_root;
1133f86dcef8SLiam Girdwood #endif
11341a497983SMengdong Lin
11351a497983SMengdong Lin unsigned int num; /* 0-based and monotonic increasing */
11361a497983SMengdong Lin struct list_head list; /* rtd list of the soc card */
1137a7df0d3bSKuninori Morimoto
11386064ed73SKuninori Morimoto /* function mark */
11396064ed73SKuninori Morimoto struct snd_pcm_substream *mark_startup;
1140918ad772SKuninori Morimoto struct snd_pcm_substream *mark_hw_params;
11416374f493SKuninori Morimoto struct snd_pcm_substream *mark_trigger;
1142cd7c7d10SKuninori Morimoto struct snd_compr_stream *mark_compr_startup;
11436064ed73SKuninori Morimoto
1144a7df0d3bSKuninori Morimoto /* bit field */
1145a7df0d3bSKuninori Morimoto unsigned int pop_wait:1;
11467426af50SKuninori Morimoto unsigned int fe_compr:1; /* for Dynamic PCM */
1147613fb500SKuninori Morimoto
1148dd9f9cc1SAmadeusz Sławiński bool initialized;
1149dd9f9cc1SAmadeusz Sławiński
1150613fb500SKuninori Morimoto int num_components;
11512d6201eeSGustavo A. R. Silva struct snd_soc_component *components[]; /* CPU/Codec/Platform */
1152808db4a4SRichard Purdie };
1153c92c96cdSKuninori Morimoto
1154c92c96cdSKuninori Morimoto /* REMOVE ME */
1155c92c96cdSKuninori Morimoto #define asoc_rtd_to_cpu snd_soc_rtd_to_cpu
1156c92c96cdSKuninori Morimoto #define asoc_rtd_to_codec snd_soc_rtd_to_codec
1157c92c96cdSKuninori Morimoto #define asoc_substream_to_rtd snd_soc_substream_to_rtd
1158c92c96cdSKuninori Morimoto
11592af69581SKuninori Morimoto /* see soc_new_pcm_runtime() */
1160c92c96cdSKuninori Morimoto #define snd_soc_rtd_to_cpu(rtd, n) (rtd)->dais[n]
1161c92c96cdSKuninori Morimoto #define snd_soc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->dai_link->num_cpus]
1162c92c96cdSKuninori Morimoto #define snd_soc_substream_to_rtd(substream) \
11630ceef681SKuninori Morimoto (struct snd_soc_pcm_runtime *)snd_pcm_substream_chip(substream)
11642af69581SKuninori Morimoto
1165613fb500SKuninori Morimoto #define for_each_rtd_components(rtd, i, component) \
1166be16a0f0SArnd Bergmann for ((i) = 0, component = NULL; \
1167613fb500SKuninori Morimoto ((i) < rtd->num_components) && ((component) = rtd->components[i]);\
1168613fb500SKuninori Morimoto (i)++)
1169995cbc3cSKuninori Morimoto #define for_each_rtd_cpu_dais(rtd, i, dai) \
1170995cbc3cSKuninori Morimoto for ((i) = 0; \
1171c92c96cdSKuninori Morimoto ((i) < rtd->dai_link->num_cpus) && ((dai) = snd_soc_rtd_to_cpu(rtd, i)); \
1172995cbc3cSKuninori Morimoto (i)++)
1173995cbc3cSKuninori Morimoto #define for_each_rtd_codec_dais(rtd, i, dai) \
1174995cbc3cSKuninori Morimoto for ((i) = 0; \
1175c92c96cdSKuninori Morimoto ((i) < rtd->dai_link->num_codecs) && ((dai) = snd_soc_rtd_to_codec(rtd, i)); \
1176995cbc3cSKuninori Morimoto (i)++)
117722a2fc81SKuninori Morimoto #define for_each_rtd_dais(rtd, i, dai) \
117822a2fc81SKuninori Morimoto for ((i) = 0; \
11793989ade2SKuninori Morimoto ((i) < (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs) && \
118022a2fc81SKuninori Morimoto ((dai) = (rtd)->dais[i]); \
118122a2fc81SKuninori Morimoto (i)++)
1182995cbc3cSKuninori Morimoto
118383f94a2eSKuninori Morimoto void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);
1184808db4a4SRichard Purdie
11854eaa9819SJon Smirl /* mixer control */
11864eaa9819SJon Smirl struct soc_mixer_control {
1187*54405532SCharles Keepax /* Minimum and maximum specified as written to the hardware */
1188*54405532SCharles Keepax int min, max;
1189*54405532SCharles Keepax /* Limited maximum value specified as presented through the control */
1190*54405532SCharles Keepax int platform_max;
1191249ce138SLars-Peter Clausen int reg, rreg;
1192249ce138SLars-Peter Clausen unsigned int shift, rshift;
1193f227b88fSMarkus Pargmann unsigned int sign_bit;
119457295073SLars-Peter Clausen unsigned int invert:1;
119557295073SLars-Peter Clausen unsigned int autodisable:1;
1196509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY
11978a978234SLiam Girdwood struct snd_soc_dobj dobj;
1198509ba54fSKuninori Morimoto #endif
11994eaa9819SJon Smirl };
12004eaa9819SJon Smirl
120171d08516SMark Brown struct soc_bytes {
120271d08516SMark Brown int base;
120371d08516SMark Brown int num_regs;
1204f831b055SMark Brown u32 mask;
120571d08516SMark Brown };
120671d08516SMark Brown
1207d9881208SVinod Koul struct soc_bytes_ext {
1208d9881208SVinod Koul int max;
1209509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY
12108a978234SLiam Girdwood struct snd_soc_dobj dobj;
1211509ba54fSKuninori Morimoto #endif
12127523a271SOmair Mohammed Abdullah /* used for TLV byte control */
1213a1e5e7e9SMythri P K int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
1214a1e5e7e9SMythri P K unsigned int size);
1215a1e5e7e9SMythri P K int (*put)(struct snd_kcontrol *kcontrol, const unsigned int __user *bytes,
1216a1e5e7e9SMythri P K unsigned int size);
1217d9881208SVinod Koul };
1218d9881208SVinod Koul
12194183eed2SKristoffer KARLSSON /* multi register control */
12204183eed2SKristoffer KARLSSON struct soc_mreg_control {
12214183eed2SKristoffer KARLSSON long min, max;
12224183eed2SKristoffer KARLSSON unsigned int regbase, regcount, nbits, invert;
12234183eed2SKristoffer KARLSSON };
12244183eed2SKristoffer KARLSSON
1225808db4a4SRichard Purdie /* enumerated kcontrol */
1226808db4a4SRichard Purdie struct soc_enum {
1227b948837aSLars-Peter Clausen int reg;
1228808db4a4SRichard Purdie unsigned char shift_l;
1229808db4a4SRichard Purdie unsigned char shift_r;
12309a8d38dbSTakashi Iwai unsigned int items;
12312e72f8e3SPeter Ujfalusi unsigned int mask;
123287023ff7STakashi Iwai const char * const *texts;
12332e72f8e3SPeter Ujfalusi const unsigned int *values;
1234561ed680SCharles Keepax unsigned int autodisable:1;
1235509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY
12368a978234SLiam Girdwood struct snd_soc_dobj dobj;
snd_soc_volsw_is_stereo(struct soc_mixer_control * mc)1237509ba54fSKuninori Morimoto #endif
12382e72f8e3SPeter Ujfalusi };
12392e72f8e3SPeter Ujfalusi
124030d86ba4SPeter Ujfalusi static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
124130d86ba4SPeter Ujfalusi {
124230d86ba4SPeter Ujfalusi if (mc->reg == mc->rreg && mc->shift == mc->rshift)
12434aa86e05SJason Yan return false;
124430d86ba4SPeter Ujfalusi /*
124530d86ba4SPeter Ujfalusi * mc->reg == mc->rreg && mc->shift != mc->rshift, or
124630d86ba4SPeter Ujfalusi * mc->reg != mc->rreg means that the control is
124730d86ba4SPeter Ujfalusi * stereo (bits in one register or in two registers)
124830d86ba4SPeter Ujfalusi */
snd_soc_enum_val_to_item(struct soc_enum * e,unsigned int val)12494aa86e05SJason Yan return true;
125030d86ba4SPeter Ujfalusi }
125130d86ba4SPeter Ujfalusi
125229ae2fa5SLars-Peter Clausen static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
125329ae2fa5SLars-Peter Clausen unsigned int val)
125429ae2fa5SLars-Peter Clausen {
125529ae2fa5SLars-Peter Clausen unsigned int i;
125629ae2fa5SLars-Peter Clausen
125729ae2fa5SLars-Peter Clausen if (!e->values)
125829ae2fa5SLars-Peter Clausen return val;
125929ae2fa5SLars-Peter Clausen
126029ae2fa5SLars-Peter Clausen for (i = 0; i < e->items; i++)
126129ae2fa5SLars-Peter Clausen if (val == e->values[i])
126229ae2fa5SLars-Peter Clausen return i;
126329ae2fa5SLars-Peter Clausen
snd_soc_enum_item_to_val(struct soc_enum * e,unsigned int item)126429ae2fa5SLars-Peter Clausen return 0;
126529ae2fa5SLars-Peter Clausen }
126629ae2fa5SLars-Peter Clausen
126729ae2fa5SLars-Peter Clausen static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
126829ae2fa5SLars-Peter Clausen unsigned int item)
126929ae2fa5SLars-Peter Clausen {
127029ae2fa5SLars-Peter Clausen if (!e->values)
127129ae2fa5SLars-Peter Clausen return item;
127229ae2fa5SLars-Peter Clausen
127329ae2fa5SLars-Peter Clausen return e->values[item];
127429ae2fa5SLars-Peter Clausen }
127529ae2fa5SLars-Peter Clausen
1276ea53bf77SLars-Peter Clausen /**
1277907fe36aSLars-Peter Clausen * snd_soc_kcontrol_component() - Returns the component that registered the
1278907fe36aSLars-Peter Clausen * control
1279907fe36aSLars-Peter Clausen * @kcontrol: The control for which to get the component
1280907fe36aSLars-Peter Clausen *
1281907fe36aSLars-Peter Clausen * Note: This function will work correctly if the control has been registered
1282ef050becSCharles Keepax * for a component. With snd_soc_add_codec_controls() or via table based
snd_soc_kcontrol_component(struct snd_kcontrol * kcontrol)1283ef050becSCharles Keepax * setup for either a CODEC or component driver. Otherwise the behavior is
1284ef050becSCharles Keepax * undefined.
1285907fe36aSLars-Peter Clausen */
1286907fe36aSLars-Peter Clausen static inline struct snd_soc_component *snd_soc_kcontrol_component(
1287907fe36aSLars-Peter Clausen struct snd_kcontrol *kcontrol)
1288907fe36aSLars-Peter Clausen {
1289907fe36aSLars-Peter Clausen return snd_kcontrol_chip(kcontrol);
1290907fe36aSLars-Peter Clausen }
1291907fe36aSLars-Peter Clausen
1292fb257897SMark Brown int snd_soc_util_init(void);
1293fb257897SMark Brown void snd_soc_util_exit(void);
1294fb257897SMark Brown
1295b07609ceSKuninori Morimoto int snd_soc_of_parse_card_name(struct snd_soc_card *card,
1296bec4fa05SStephen Warren const char *propname);
129721efde50SKuninori Morimoto int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
12989a6d4860SXiubo Li const char *propname);
12993d4641a4SStephan Gerhold int snd_soc_of_parse_pin_switches(struct snd_soc_card *card, const char *prop);
1300cbdfab3bSJerome Brunet int snd_soc_of_get_slot_mask(struct device_node *np,
1301cbdfab3bSJerome Brunet const char *prop_name,
1302cbdfab3bSJerome Brunet unsigned int *mask);
130389c67857SXiubo Li int snd_soc_of_parse_tdm_slot(struct device_node *np,
13046131084aSJyri Sarha unsigned int *tx_mask,
13056131084aSJyri Sarha unsigned int *rx_mask,
130689c67857SXiubo Li unsigned int *slots,
130789c67857SXiubo Li unsigned int *slot_width);
13083b710356SKuninori Morimoto void snd_soc_of_parse_node_prefix(struct device_node *np,
13095e3cdaa2SKuninori Morimoto struct snd_soc_codec_conf *codec_conf,
snd_soc_of_parse_audio_prefix(struct snd_soc_card * card,struct snd_soc_codec_conf * codec_conf,struct device_node * of_node,const char * propname)13105e3cdaa2SKuninori Morimoto struct device_node *of_node,
13115e3cdaa2SKuninori Morimoto const char *propname);
13122708bccfSKuninori Morimoto static inline
13132708bccfSKuninori Morimoto void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
13142708bccfSKuninori Morimoto struct snd_soc_codec_conf *codec_conf,
13152708bccfSKuninori Morimoto struct device_node *of_node,
13162708bccfSKuninori Morimoto const char *propname)
13172708bccfSKuninori Morimoto {
13182708bccfSKuninori Morimoto snd_soc_of_parse_node_prefix(card->dev->of_node,
13192708bccfSKuninori Morimoto codec_conf, of_node, propname);
13202708bccfSKuninori Morimoto }
13213b710356SKuninori Morimoto
13222bc644afSKuninori Morimoto int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
1323a4a54dd5SStephen Warren const char *propname);
13241ae0965dSStephan Gerhold int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
1325b44a67f8SKuninori Morimoto
132664c917d1SCharles Keepax unsigned int snd_soc_daifmt_clock_provider_flipped(unsigned int dai_fmt);
132791ae4477SKuninori Morimoto unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame);
13287766861dSKuninori Morimoto
13297766861dSKuninori Morimoto unsigned int snd_soc_daifmt_parse_format(struct device_node *np, const char *prefix);
13307766861dSKuninori Morimoto unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
13317766861dSKuninori Morimoto const char *prefix,
13327766861dSKuninori Morimoto struct device_node **bitclkmaster,
13337766861dSKuninori Morimoto struct device_node **framemaster);
13347766861dSKuninori Morimoto #define snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix) \
13357766861dSKuninori Morimoto snd_soc_daifmt_parse_clock_provider_raw(np, prefix, NULL, NULL)
13367766861dSKuninori Morimoto #define snd_soc_daifmt_parse_clock_provider_as_phandle \
13377766861dSKuninori Morimoto snd_soc_daifmt_parse_clock_provider_raw
13387766861dSKuninori Morimoto #define snd_soc_daifmt_parse_clock_provider_as_flag(np, prefix) \
13397766861dSKuninori Morimoto snd_soc_daifmt_clock_provider_from_bitmap( \
13407766861dSKuninori Morimoto snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix))
13417766861dSKuninori Morimoto
13421c943f60SKuninori Morimoto int snd_soc_get_stream_cpu(struct snd_soc_dai_link *dai_link, int stream);
134305722a0cSKuninori Morimoto int snd_soc_get_dlc(const struct of_phandle_args *args,
134405722a0cSKuninori Morimoto struct snd_soc_dai_link_component *dlc);
134505722a0cSKuninori Morimoto int snd_soc_of_get_dlc(struct device_node *of_node,
134605722a0cSKuninori Morimoto struct of_phandle_args *args,
134705722a0cSKuninori Morimoto struct snd_soc_dai_link_component *dlc,
134805722a0cSKuninori Morimoto int index);
1349a180e8b9SKuninori Morimoto int snd_soc_get_dai_id(struct device_node *ep);
1350933f98beSKrzysztof Kozlowski int snd_soc_get_dai_name(const struct of_phandle_args *args,
13511ad8ec53SKuninori Morimoto const char **dai_name);
1352cb470087SKuninori Morimoto int snd_soc_of_get_dai_name(struct device_node *of_node,
13533c8b5861SKuninori Morimoto const char **dai_name, int index);
135493b0f3eeSJean-Francois Moine int snd_soc_of_get_dai_link_codecs(struct device *dev,
135593b0f3eeSJean-Francois Moine struct device_node *of_node,
135693b0f3eeSJean-Francois Moine struct snd_soc_dai_link *dai_link);
135794685763SSylwester Nawrocki void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
1358900dedd7SMartin Povišer int snd_soc_of_get_dai_link_cpus(struct device *dev,
1359900dedd7SMartin Povišer struct device_node *of_node,
1360900dedd7SMartin Povišer struct snd_soc_dai_link *dai_link);
1361900dedd7SMartin Povišer void snd_soc_of_put_dai_link_cpus(struct snd_soc_dai_link *dai_link);
1362bec4fa05SStephen Warren
1363ffaf886eSKuninori Morimoto int snd_soc_add_pcm_runtimes(struct snd_soc_card *card,
1364ffaf886eSKuninori Morimoto struct snd_soc_dai_link *dai_link,
1365ffaf886eSKuninori Morimoto int num_dai_link);
136650cd9b53SKuninori Morimoto void snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
136750cd9b53SKuninori Morimoto struct snd_soc_pcm_runtime *rtd);
1368f8f80361SMengdong Lin
1369988bad5eSKuninori Morimoto void snd_soc_dlc_use_cpu_as_platform(struct snd_soc_dai_link_component *platforms,
1370988bad5eSKuninori Morimoto struct snd_soc_dai_link_component *cpus);
1371bbde4a30SKuninori Morimoto struct of_phandle_args *snd_soc_copy_dai_args(struct device *dev,
1372bbde4a30SKuninori Morimoto struct of_phandle_args *args);
1373442ae56cSKuninori Morimoto struct snd_soc_dai *snd_soc_get_dai_via_args(struct of_phandle_args *dai_args);
1374e443c205SKuninori Morimoto struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
13755d075197SKuninori Morimoto struct snd_soc_dai_driver *dai_drv,
13765d075197SKuninori Morimoto bool legacy_dai_naming);
13770fae253aSPierre-Louis Bossart struct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev,
13780fae253aSPierre-Louis Bossart struct snd_soc_component *component,
13790fae253aSPierre-Louis Bossart struct snd_soc_dai_driver *dai_drv,
13800fae253aSPierre-Louis Bossart bool legacy_dai_naming);
1381e11381f3SKuninori Morimoto void snd_soc_unregister_dai(struct snd_soc_dai *dai);
138268003e6cSMengdong Lin
1383305e9020SMengdong Lin struct snd_soc_dai *snd_soc_find_dai(
1384305e9020SMengdong Lin const struct snd_soc_dai_link_component *dlc);
1385c1c277b2SKuninori Morimoto struct snd_soc_dai *snd_soc_find_dai_with_mutex(
1386c1c277b2SKuninori Morimoto const struct snd_soc_dai_link_component *dlc);
1387305e9020SMengdong Lin
snd_soc_fixup_dai_links_platform_name(struct snd_soc_card * card,const char * platform_name)1388a47cbe72SMark Brown #include <sound/soc-dai.h>
1389a47cbe72SMark Brown
13907c761b59SPierre-Louis Bossart static inline
1391cb50358bSPierre-Louis Bossart int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
1392cb50358bSPierre-Louis Bossart const char *platform_name)
1393cb50358bSPierre-Louis Bossart {
1394cb50358bSPierre-Louis Bossart struct snd_soc_dai_link *dai_link;
1395cb50358bSPierre-Louis Bossart const char *name;
1396cb50358bSPierre-Louis Bossart int i;
1397cb50358bSPierre-Louis Bossart
1398cb50358bSPierre-Louis Bossart if (!platform_name) /* nothing to do */
1399cb50358bSPierre-Louis Bossart return 0;
1400cb50358bSPierre-Louis Bossart
1401cb50358bSPierre-Louis Bossart /* set platform name for each dailink */
1402cb50358bSPierre-Louis Bossart for_each_card_prelinks(card, i, dai_link) {
1403d908b922SKuninori Morimoto /* only single platform is supported for now */
1404d908b922SKuninori Morimoto if (dai_link->num_platforms != 1)
1405d908b922SKuninori Morimoto return -EINVAL;
1406d908b922SKuninori Morimoto
14074a50724eSKuninori Morimoto if (!dai_link->platforms)
14084a50724eSKuninori Morimoto return -EINVAL;
14094a50724eSKuninori Morimoto
1410cb50358bSPierre-Louis Bossart name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
1411cb50358bSPierre-Louis Bossart if (!name)
1412cb50358bSPierre-Louis Bossart return -ENOMEM;
1413cb50358bSPierre-Louis Bossart
1414cb50358bSPierre-Louis Bossart /* only single platform is supported for now */
1415cb50358bSPierre-Louis Bossart dai_link->platforms->name = name;
1416cb50358bSPierre-Louis Bossart }
1417cb50358bSPierre-Louis Bossart
1418cb50358bSPierre-Louis Bossart return 0;
1419cb50358bSPierre-Louis Bossart }
1420cb50358bSPierre-Louis Bossart
1421faff4bb0SStephen Warren #ifdef CONFIG_DEBUG_FS
14228a9dab1aSMark Brown extern struct dentry *snd_soc_debugfs_root;
1423faff4bb0SStephen Warren #endif
1424faff4bb0SStephen Warren
14256f8ab4acSMark Brown extern const struct dev_pm_ops snd_soc_pm_ops;
14266f8ab4acSMark Brown
14274a778bdcSKuninori Morimoto /*
14284a778bdcSKuninori Morimoto * DAPM helper functions
14294a778bdcSKuninori Morimoto */
14304a778bdcSKuninori Morimoto enum snd_soc_dapm_subclass {
14314a778bdcSKuninori Morimoto SND_SOC_DAPM_CLASS_ROOT = 0,
_snd_soc_dapm_mutex_lock_root_c(struct snd_soc_card * card)14324a778bdcSKuninori Morimoto SND_SOC_DAPM_CLASS_RUNTIME = 1,
14334a778bdcSKuninori Morimoto };
14344a778bdcSKuninori Morimoto
14354a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_root_c(struct snd_soc_card *card)
1436f6d5e586SCharles Keepax {
_snd_soc_dapm_mutex_lock_c(struct snd_soc_card * card)14374a778bdcSKuninori Morimoto mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_ROOT);
1438f6d5e586SCharles Keepax }
1439f6d5e586SCharles Keepax
14404a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_c(struct snd_soc_card *card)
1441f6d5e586SCharles Keepax {
_snd_soc_dapm_mutex_unlock_c(struct snd_soc_card * card)14424a778bdcSKuninori Morimoto mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
1443f6d5e586SCharles Keepax }
1444f6d5e586SCharles Keepax
14454a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_unlock_c(struct snd_soc_card *card)
14464a778bdcSKuninori Morimoto {
_snd_soc_dapm_mutex_assert_held_c(struct snd_soc_card * card)14474a778bdcSKuninori Morimoto mutex_unlock(&card->dapm_mutex);
14484a778bdcSKuninori Morimoto }
14494a778bdcSKuninori Morimoto
14504a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_assert_held_c(struct snd_soc_card *card)
14514a778bdcSKuninori Morimoto {
_snd_soc_dapm_mutex_lock_root_d(struct snd_soc_dapm_context * dapm)14524a778bdcSKuninori Morimoto lockdep_assert_held(&card->dapm_mutex);
14534a778bdcSKuninori Morimoto }
14544a778bdcSKuninori Morimoto
14554a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_root_d(struct snd_soc_dapm_context *dapm)
14564a778bdcSKuninori Morimoto {
_snd_soc_dapm_mutex_lock_d(struct snd_soc_dapm_context * dapm)14574a778bdcSKuninori Morimoto _snd_soc_dapm_mutex_lock_root_c(dapm->card);
14584a778bdcSKuninori Morimoto }
14594a778bdcSKuninori Morimoto
14604a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_d(struct snd_soc_dapm_context *dapm)
14614a778bdcSKuninori Morimoto {
_snd_soc_dapm_mutex_unlock_d(struct snd_soc_dapm_context * dapm)14624a778bdcSKuninori Morimoto _snd_soc_dapm_mutex_lock_c(dapm->card);
14634a778bdcSKuninori Morimoto }
14644a778bdcSKuninori Morimoto
14654a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_unlock_d(struct snd_soc_dapm_context *dapm)
14664a778bdcSKuninori Morimoto {
_snd_soc_dapm_mutex_assert_held_d(struct snd_soc_dapm_context * dapm)14674a778bdcSKuninori Morimoto _snd_soc_dapm_mutex_unlock_c(dapm->card);
14684a778bdcSKuninori Morimoto }
14694a778bdcSKuninori Morimoto
14704a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_assert_held_d(struct snd_soc_dapm_context *dapm)
14714a778bdcSKuninori Morimoto {
14724a778bdcSKuninori Morimoto _snd_soc_dapm_mutex_assert_held_c(dapm->card);
14734a778bdcSKuninori Morimoto }
14744a778bdcSKuninori Morimoto
14754a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_lock_root(x) _Generic((x), \
14764a778bdcSKuninori Morimoto struct snd_soc_card * : _snd_soc_dapm_mutex_lock_root_c, \
14774a778bdcSKuninori Morimoto struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_root_d)(x)
14784a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_lock(x) _Generic((x), \
14794a778bdcSKuninori Morimoto struct snd_soc_card * : _snd_soc_dapm_mutex_lock_c, \
14804a778bdcSKuninori Morimoto struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_d)(x)
14814a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_unlock(x) _Generic((x), \
14824a778bdcSKuninori Morimoto struct snd_soc_card * : _snd_soc_dapm_mutex_unlock_c, \
14834a778bdcSKuninori Morimoto struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_unlock_d)(x)
14844a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_assert_held(x) _Generic((x), \
14854a778bdcSKuninori Morimoto struct snd_soc_card * : _snd_soc_dapm_mutex_assert_held_c, \
14864a778bdcSKuninori Morimoto struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_assert_held_d)(x)
14874a778bdcSKuninori Morimoto
_snd_soc_dpcm_mutex_lock_c(struct snd_soc_card * card)148838e42f6dSKuninori Morimoto /*
148938e42f6dSKuninori Morimoto * PCM helper functions
149038e42f6dSKuninori Morimoto */
149138e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_lock_c(struct snd_soc_card *card)
149238e42f6dSKuninori Morimoto {
149338e42f6dSKuninori Morimoto mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass);
149438e42f6dSKuninori Morimoto }
149538e42f6dSKuninori Morimoto
149638e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_unlock_c(struct snd_soc_card *card)
149738e42f6dSKuninori Morimoto {
_snd_soc_dpcm_mutex_assert_held_c(struct snd_soc_card * card)149838e42f6dSKuninori Morimoto mutex_unlock(&card->pcm_mutex);
149938e42f6dSKuninori Morimoto }
150038e42f6dSKuninori Morimoto
150138e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_assert_held_c(struct snd_soc_card *card)
150238e42f6dSKuninori Morimoto {
_snd_soc_dpcm_mutex_lock_r(struct snd_soc_pcm_runtime * rtd)150338e42f6dSKuninori Morimoto lockdep_assert_held(&card->pcm_mutex);
150438e42f6dSKuninori Morimoto }
150538e42f6dSKuninori Morimoto
150638e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_lock_r(struct snd_soc_pcm_runtime *rtd)
150738e42f6dSKuninori Morimoto {
_snd_soc_dpcm_mutex_unlock_r(struct snd_soc_pcm_runtime * rtd)150838e42f6dSKuninori Morimoto _snd_soc_dpcm_mutex_lock_c(rtd->card);
150938e42f6dSKuninori Morimoto }
151038e42f6dSKuninori Morimoto
151138e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_unlock_r(struct snd_soc_pcm_runtime *rtd)
151238e42f6dSKuninori Morimoto {
_snd_soc_dpcm_mutex_assert_held_r(struct snd_soc_pcm_runtime * rtd)151338e42f6dSKuninori Morimoto _snd_soc_dpcm_mutex_unlock_c(rtd->card);
151438e42f6dSKuninori Morimoto }
151538e42f6dSKuninori Morimoto
151638e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_assert_held_r(struct snd_soc_pcm_runtime *rtd)
151738e42f6dSKuninori Morimoto {
151838e42f6dSKuninori Morimoto _snd_soc_dpcm_mutex_assert_held_c(rtd->card);
151938e42f6dSKuninori Morimoto }
152038e42f6dSKuninori Morimoto
152138e42f6dSKuninori Morimoto #define snd_soc_dpcm_mutex_lock(x) _Generic((x), \
152238e42f6dSKuninori Morimoto struct snd_soc_card * : _snd_soc_dpcm_mutex_lock_c, \
152338e42f6dSKuninori Morimoto struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_lock_r)(x)
152438e42f6dSKuninori Morimoto
152538e42f6dSKuninori Morimoto #define snd_soc_dpcm_mutex_unlock(x) _Generic((x), \
152638e42f6dSKuninori Morimoto struct snd_soc_card * : _snd_soc_dpcm_mutex_unlock_c, \
152738e42f6dSKuninori Morimoto struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_unlock_r)(x)
152838e42f6dSKuninori Morimoto
152938e42f6dSKuninori Morimoto #define snd_soc_dpcm_mutex_assert_held(x) _Generic((x), \
153038e42f6dSKuninori Morimoto struct snd_soc_card * : _snd_soc_dpcm_mutex_assert_held_c, \
153138e42f6dSKuninori Morimoto struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_assert_held_r)(x)
153238e42f6dSKuninori Morimoto
15334ff1fef1SKuninori Morimoto #include <sound/soc-component.h>
15341793936bSKuninori Morimoto #include <sound/soc-card.h>
1535ddfbe828SKuninori Morimoto #include <sound/soc-jack.h>
15361b4d9c22SRichard Fitzgerald
1537808db4a4SRichard Purdie #endif
1538