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 435aae013d6SJie Yang static inline int snd_soc_suspend(struct device *dev) 436aae013d6SJie Yang { 437aae013d6SJie Yang return 0; 438aae013d6SJie Yang } 439aae013d6SJie Yang 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 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); 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 } 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 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 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 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; 65488bd870fSBenoit Cousson }; 65588bd870fSBenoit Cousson 656ac950278SBard Liao struct snd_soc_dai_link_codec_ch_map { 657ac950278SBard Liao unsigned int connected_cpu_id; 658ac950278SBard Liao unsigned int ch_mask; 659ac950278SBard Liao }; 660ac950278SBard Liao 661808db4a4SRichard Purdie struct snd_soc_dai_link { 662f0fba2adSLiam Girdwood /* config - must be set by machine driver */ 663f0fba2adSLiam Girdwood const char *name; /* Codec name */ 664f0fba2adSLiam Girdwood const char *stream_name; /* Stream name */ 66562bc79d3SKuninori Morimoto 66662bc79d3SKuninori Morimoto /* 667bc92657aSStephen Warren * You MAY specify the link's CPU-side device, either by device name, 668bc92657aSStephen Warren * or by DT/OF node, but not both. If this information is omitted, 669bc92657aSStephen Warren * the CPU-side DAI is matched using .cpu_dai_name only, which hence 670bc92657aSStephen Warren * must be globally unique. These fields are currently typically used 671bc92657aSStephen Warren * only for codec to codec links, or systems using device tree. 672bc92657aSStephen Warren */ 673bc92657aSStephen Warren /* 674bc92657aSStephen Warren * You MAY specify the DAI name of the CPU DAI. If this information is 675bc92657aSStephen Warren * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node 676bc92657aSStephen Warren * only, which only works well when that device exposes a single DAI. 677bc92657aSStephen Warren */ 67808a5841eSKuninori Morimoto struct snd_soc_dai_link_component *cpus; 67908a5841eSKuninori Morimoto unsigned int num_cpus; 68008a5841eSKuninori Morimoto 68162bc79d3SKuninori Morimoto /* 682bc92657aSStephen Warren * You MUST specify the link's codec, either by device name, or by 683bc92657aSStephen Warren * DT/OF node, but not both. 684bc92657aSStephen Warren */ 685bc92657aSStephen Warren /* You MUST specify the DAI name within the codec */ 68688bd870fSBenoit Cousson struct snd_soc_dai_link_component *codecs; 68788bd870fSBenoit Cousson unsigned int num_codecs; 68888bd870fSBenoit Cousson 689ac950278SBard Liao struct snd_soc_dai_link_codec_ch_map *codec_ch_maps; 690bc92657aSStephen Warren /* 691bc92657aSStephen Warren * You MAY specify the link's platform/PCM/DMA driver, either by 692bc92657aSStephen Warren * device name, or by DT/OF node, but not both. Some forms of link 6931d768989SKuninori Morimoto * do not need a platform. In such case, platforms are not mandatory. 694bc92657aSStephen Warren */ 695910fdcabSKuninori Morimoto struct snd_soc_dai_link_component *platforms; 696910fdcabSKuninori Morimoto unsigned int num_platforms; 697daecf46eSKuninori Morimoto 6982f0ad491SMengdong Lin int id; /* optional ID for machine driver link identification */ 6994ccab3e7SLiam Girdwood 7007ddc7f91SKuninori Morimoto /* 7017ddc7f91SKuninori Morimoto * for Codec2Codec 7027ddc7f91SKuninori Morimoto */ 7037ddc7f91SKuninori Morimoto const struct snd_soc_pcm_stream *c2c_params; 7047ddc7f91SKuninori Morimoto unsigned int num_c2c_params; 7057ddc7f91SKuninori Morimoto 70675d9ac46SMark Brown unsigned int dai_fmt; /* format to set on init */ 70775d9ac46SMark Brown 70801d7584cSLiam Girdwood enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */ 70901d7584cSLiam Girdwood 710f0fba2adSLiam Girdwood /* codec/machine specific init - e.g. add machine controls */ 711f0fba2adSLiam Girdwood int (*init)(struct snd_soc_pcm_runtime *rtd); 71206f409d7SMark Brown 71321a00fb3SPierre-Louis Bossart /* codec/machine specific exit - dual of init() */ 71421a00fb3SPierre-Louis Bossart void (*exit)(struct snd_soc_pcm_runtime *rtd); 71521a00fb3SPierre-Louis Bossart 71601d7584cSLiam Girdwood /* optional hw_params re-writing for BE and FE sync */ 71701d7584cSLiam Girdwood int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd, 71801d7584cSLiam Girdwood struct snd_pcm_hw_params *params); 71901d7584cSLiam Girdwood 720f0fba2adSLiam Girdwood /* machine stream operations */ 72113aec722SLars-Peter Clausen const struct snd_soc_ops *ops; 72213aec722SLars-Peter Clausen const struct snd_soc_compr_ops *compr_ops; 723d6bead02SFabio Estevam 724356caf66SKuninori Morimoto /* 725356caf66SKuninori Morimoto * soc_pcm_trigger() start/stop sequence. 726356caf66SKuninori Morimoto * see also 727356caf66SKuninori Morimoto * snd_soc_component_driver 728356caf66SKuninori Morimoto * soc_pcm_trigger() 729356caf66SKuninori Morimoto */ 730356caf66SKuninori Morimoto enum snd_soc_trigger_order trigger_start; 731356caf66SKuninori Morimoto enum snd_soc_trigger_order trigger_stop; 732356caf66SKuninori Morimoto 7332dc0f16bSKuninori Morimoto /* Mark this pcm with non atomic ops */ 734317ec675SKuninori Morimoto unsigned int nonatomic:1; 7352dc0f16bSKuninori Morimoto 7361236fa1eSKuninori Morimoto /* For unidirectional dai links */ 7371236fa1eSKuninori Morimoto unsigned int playback_only:1; 7381236fa1eSKuninori Morimoto unsigned int capture_only:1; 7391236fa1eSKuninori Morimoto 7402dc0f16bSKuninori Morimoto /* Keep DAI active over suspend */ 7412dc0f16bSKuninori Morimoto unsigned int ignore_suspend:1; 7422dc0f16bSKuninori Morimoto 7432dc0f16bSKuninori Morimoto /* Symmetry requirements */ 744f14654ddSKuninori Morimoto unsigned int symmetric_rate:1; 7452dc0f16bSKuninori Morimoto unsigned int symmetric_channels:1; 746f14654ddSKuninori Morimoto unsigned int symmetric_sample_bits:1; 7472dc0f16bSKuninori Morimoto 7482dc0f16bSKuninori Morimoto /* Do not create a PCM for this DAI link (Backend link) */ 7492dc0f16bSKuninori Morimoto unsigned int no_pcm:1; 7502dc0f16bSKuninori Morimoto 7512dc0f16bSKuninori Morimoto /* This DAI link can route to other DAI links at runtime (Frontend)*/ 7522dc0f16bSKuninori Morimoto unsigned int dynamic:1; 7532dc0f16bSKuninori Morimoto 7542dc0f16bSKuninori Morimoto /* DPCM capture and Playback support */ 7552dc0f16bSKuninori Morimoto unsigned int dpcm_capture:1; 7562dc0f16bSKuninori Morimoto unsigned int dpcm_playback:1; 7572dc0f16bSKuninori Morimoto 758b073ed4eSKuninori Morimoto /* DPCM used FE & BE merged format */ 759b073ed4eSKuninori Morimoto unsigned int dpcm_merged_format:1; 760f4c277b8SJiada Wang /* DPCM used FE & BE merged channel */ 761f4c277b8SJiada Wang unsigned int dpcm_merged_chan:1; 762baacd8d1SJerome Brunet /* DPCM used FE & BE merged rate */ 763baacd8d1SJerome Brunet unsigned int dpcm_merged_rate:1; 764b073ed4eSKuninori Morimoto 7652dc0f16bSKuninori Morimoto /* pmdown_time is ignored at stop */ 7662dc0f16bSKuninori Morimoto unsigned int ignore_pmdown_time:1; 767f8f80361SMengdong Lin 768a655de80SLiam Girdwood /* Do not create a PCM for this DAI link (Backend link) */ 769a655de80SLiam Girdwood unsigned int ignore:1; 770a655de80SLiam Girdwood 771509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY 772f8f80361SMengdong Lin struct snd_soc_dobj dobj; /* For topology */ 773509ba54fSKuninori Morimoto #endif 774808db4a4SRichard Purdie }; 7754da40cb9SKuninori Morimoto 7764da40cb9SKuninori Morimoto static inline struct snd_soc_dai_link_component* 7774da40cb9SKuninori Morimoto asoc_link_to_cpu(struct snd_soc_dai_link *link, int n) { 7784da40cb9SKuninori Morimoto return &(link)->cpus[n]; 7794da40cb9SKuninori Morimoto } 7804da40cb9SKuninori Morimoto 7814da40cb9SKuninori Morimoto static inline struct snd_soc_dai_link_component* 7824da40cb9SKuninori Morimoto asoc_link_to_codec(struct snd_soc_dai_link *link, int n) { 7834da40cb9SKuninori Morimoto return &(link)->codecs[n]; 7844da40cb9SKuninori Morimoto } 7854da40cb9SKuninori Morimoto 7864da40cb9SKuninori Morimoto static inline struct snd_soc_dai_link_component* 7874da40cb9SKuninori Morimoto asoc_link_to_platform(struct snd_soc_dai_link *link, int n) { 7884da40cb9SKuninori Morimoto return &(link)->platforms[n]; 7894da40cb9SKuninori Morimoto } 7904da40cb9SKuninori Morimoto 7913db769f1SKuninori Morimoto #define for_each_link_codecs(link, i, codec) \ 7923db769f1SKuninori Morimoto for ((i) = 0; \ 7934da40cb9SKuninori Morimoto ((i) < link->num_codecs) && \ 7944da40cb9SKuninori Morimoto ((codec) = asoc_link_to_codec(link, i)); \ 7953db769f1SKuninori Morimoto (i)++) 796808db4a4SRichard Purdie 79734614739SJerome Brunet #define for_each_link_platforms(link, i, platform) \ 79834614739SJerome Brunet for ((i) = 0; \ 79934614739SJerome Brunet ((i) < link->num_platforms) && \ 8004da40cb9SKuninori Morimoto ((platform) = asoc_link_to_platform(link, i)); \ 80134614739SJerome Brunet (i)++) 80234614739SJerome Brunet 80376afa643SShreyas NC #define for_each_link_cpus(link, i, cpu) \ 80476afa643SShreyas NC for ((i) = 0; \ 8054da40cb9SKuninori Morimoto ((i) < link->num_cpus) && \ 8064da40cb9SKuninori Morimoto ((cpu) = asoc_link_to_cpu(link, i)); \ 80776afa643SShreyas NC (i)++) 80876afa643SShreyas NC 809587c9844SKuninori Morimoto /* 810587c9844SKuninori Morimoto * Sample 1 : Single CPU/Codec/Platform 811587c9844SKuninori Morimoto * 812587c9844SKuninori Morimoto * SND_SOC_DAILINK_DEFS(test, 813587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")), 814587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CODEC("codec", "codec_dai")), 815587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_PLATFORM("platform"))); 816587c9844SKuninori Morimoto * 817587c9844SKuninori Morimoto * struct snd_soc_dai_link link = { 818587c9844SKuninori Morimoto * ... 819587c9844SKuninori Morimoto * SND_SOC_DAILINK_REG(test), 820587c9844SKuninori Morimoto * }; 821587c9844SKuninori Morimoto * 822587c9844SKuninori Morimoto * Sample 2 : Multi CPU/Codec, no Platform 823587c9844SKuninori Morimoto * 824587c9844SKuninori Morimoto * SND_SOC_DAILINK_DEFS(test, 825587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"), 826587c9844SKuninori Morimoto * COMP_CPU("cpu_dai2")), 827587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"), 828587c9844SKuninori Morimoto * COMP_CODEC("codec2", "codec_dai2"))); 829587c9844SKuninori Morimoto * 830587c9844SKuninori Morimoto * struct snd_soc_dai_link link = { 831587c9844SKuninori Morimoto * ... 832587c9844SKuninori Morimoto * SND_SOC_DAILINK_REG(test), 833587c9844SKuninori Morimoto * }; 834587c9844SKuninori Morimoto * 835587c9844SKuninori Morimoto * Sample 3 : Define each CPU/Codec/Platform manually 836587c9844SKuninori Morimoto * 837587c9844SKuninori Morimoto * SND_SOC_DAILINK_DEF(test_cpu, 838587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"), 839587c9844SKuninori Morimoto * COMP_CPU("cpu_dai2"))); 840587c9844SKuninori Morimoto * SND_SOC_DAILINK_DEF(test_codec, 841587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"), 842587c9844SKuninori Morimoto * COMP_CODEC("codec2", "codec_dai2"))); 843587c9844SKuninori Morimoto * SND_SOC_DAILINK_DEF(test_platform, 844587c9844SKuninori Morimoto * DAILINK_COMP_ARRAY(COMP_PLATFORM("platform"))); 845587c9844SKuninori Morimoto * 846587c9844SKuninori Morimoto * struct snd_soc_dai_link link = { 847587c9844SKuninori Morimoto * ... 848587c9844SKuninori Morimoto * SND_SOC_DAILINK_REG(test_cpu, 849587c9844SKuninori Morimoto * test_codec, 850587c9844SKuninori Morimoto * test_platform), 851587c9844SKuninori Morimoto * }; 852587c9844SKuninori Morimoto * 853587c9844SKuninori Morimoto * Sample 4 : Sample3 without platform 854587c9844SKuninori Morimoto * 855587c9844SKuninori Morimoto * struct snd_soc_dai_link link = { 856587c9844SKuninori Morimoto * ... 857587c9844SKuninori Morimoto * SND_SOC_DAILINK_REG(test_cpu, 858587c9844SKuninori Morimoto * test_codec); 859587c9844SKuninori Morimoto * }; 860587c9844SKuninori Morimoto */ 861587c9844SKuninori Morimoto 862587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG1(name) SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms) 863587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG2(cpu, codec) SND_SOC_DAILINK_REG3(cpu, codec, null_dailink_component) 864587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG3(cpu, codec, platform) \ 865587c9844SKuninori Morimoto .cpus = cpu, \ 866587c9844SKuninori Morimoto .num_cpus = ARRAY_SIZE(cpu), \ 867587c9844SKuninori Morimoto .codecs = codec, \ 868587c9844SKuninori Morimoto .num_codecs = ARRAY_SIZE(codec), \ 869587c9844SKuninori Morimoto .platforms = platform, \ 870587c9844SKuninori Morimoto .num_platforms = ARRAY_SIZE(platform) 871587c9844SKuninori Morimoto 872587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func 873587c9844SKuninori Morimoto #define SND_SOC_DAILINK_REG(...) \ 874587c9844SKuninori Morimoto SND_SOC_DAILINK_REGx(__VA_ARGS__, \ 875587c9844SKuninori Morimoto SND_SOC_DAILINK_REG3, \ 876587c9844SKuninori Morimoto SND_SOC_DAILINK_REG2, \ 877587c9844SKuninori Morimoto SND_SOC_DAILINK_REG1)(__VA_ARGS__) 878587c9844SKuninori Morimoto 879587c9844SKuninori Morimoto #define SND_SOC_DAILINK_DEF(name, def...) \ 880587c9844SKuninori Morimoto static struct snd_soc_dai_link_component name[] = { def } 881587c9844SKuninori Morimoto 882587c9844SKuninori Morimoto #define SND_SOC_DAILINK_DEFS(name, cpu, codec, platform...) \ 883587c9844SKuninori Morimoto SND_SOC_DAILINK_DEF(name##_cpus, cpu); \ 884587c9844SKuninori Morimoto SND_SOC_DAILINK_DEF(name##_codecs, codec); \ 885587c9844SKuninori Morimoto SND_SOC_DAILINK_DEF(name##_platforms, platform) 886587c9844SKuninori Morimoto 887587c9844SKuninori Morimoto #define DAILINK_COMP_ARRAY(param...) param 888587c9844SKuninori Morimoto #define COMP_EMPTY() { } 889587c9844SKuninori Morimoto #define COMP_CPU(_dai) { .dai_name = _dai, } 890587c9844SKuninori Morimoto #define COMP_CODEC(_name, _dai) { .name = _name, .dai_name = _dai, } 891587c9844SKuninori Morimoto #define COMP_PLATFORM(_name) { .name = _name } 8923dc29b8bSKuninori Morimoto #define COMP_AUX(_name) { .name = _name } 893c13493a2SKuninori Morimoto #define COMP_CODEC_CONF(_name) { .name = _name } 894587c9844SKuninori Morimoto #define COMP_DUMMY() { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", } 895587c9844SKuninori Morimoto 896587c9844SKuninori Morimoto extern struct snd_soc_dai_link_component null_dailink_component[0]; 897d2a4e0d7SKuninori Morimoto extern struct snd_soc_dai_link_component asoc_dummy_dlc; 898587c9844SKuninori Morimoto 899587c9844SKuninori Morimoto 900ff819b83SDimitris Papastamos struct snd_soc_codec_conf { 9013ca041edSSebastian Reichel /* 9023ca041edSSebastian Reichel * specify device either by device name, or by 9033ca041edSSebastian Reichel * DT/OF node, but not both. 9043ca041edSSebastian Reichel */ 905c13493a2SKuninori Morimoto struct snd_soc_dai_link_component dlc; 906c13493a2SKuninori Morimoto 907ff819b83SDimitris Papastamos /* 908ff819b83SDimitris Papastamos * optional map of kcontrol, widget and path name prefixes that are 909ff819b83SDimitris Papastamos * associated per device 910ff819b83SDimitris Papastamos */ 911ead9b919SJarkko Nikula const char *name_prefix; 912ead9b919SJarkko Nikula }; 913ead9b919SJarkko Nikula 9142eea392dSJarkko Nikula struct snd_soc_aux_dev { 9153ca041edSSebastian Reichel /* 9163ca041edSSebastian Reichel * specify multi-codec either by device name, or by 9173ca041edSSebastian Reichel * DT/OF node, but not both. 9183ca041edSSebastian Reichel */ 9193dc29b8bSKuninori Morimoto struct snd_soc_dai_link_component dlc; 9203dc29b8bSKuninori Morimoto 9212eea392dSJarkko Nikula /* codec/machine specific init - e.g. add machine controls */ 92257bf7726SLars-Peter Clausen int (*init)(struct snd_soc_component *component); 9232eea392dSJarkko Nikula }; 9242eea392dSJarkko Nikula 92587506549SMark Brown /* SoC card */ 92687506549SMark Brown struct snd_soc_card { 927f0fba2adSLiam Girdwood const char *name; 92822de71baSLiam Girdwood const char *long_name; 92922de71baSLiam Girdwood const char *driver_name; 930dc73d73aSJaroslav Kysela const char *components; 9318a6a6a38SKuninori Morimoto #ifdef CONFIG_DMI 932345233d7SLiam Girdwood char dmi_longname[80]; 9338a6a6a38SKuninori Morimoto #endif /* CONFIG_DMI */ 934a655de80SLiam Girdwood char topology_shortname[32]; 935345233d7SLiam Girdwood 936c5af3a2eSMark Brown struct device *dev; 937f0fba2adSLiam Girdwood struct snd_card *snd_card; 938f0fba2adSLiam Girdwood struct module *owner; 939c5af3a2eSMark Brown 940f0fba2adSLiam Girdwood struct mutex mutex; 941a73fb2dfSLiam Girdwood struct mutex dapm_mutex; 942c5af3a2eSMark Brown 94372b745e3SPeter Ujfalusi /* Mutex for PCM operations */ 94472b745e3SPeter Ujfalusi struct mutex pcm_mutex; 94572b745e3SPeter Ujfalusi enum snd_soc_pcm_subclass pcm_subclass; 94672b745e3SPeter Ujfalusi 947e7361ec4SMark Brown int (*probe)(struct snd_soc_card *card); 94828e9ad92SMark Brown int (*late_probe)(struct snd_soc_card *card); 949df4d27b1SMartin Povišer void (*fixup_controls)(struct snd_soc_card *card); 950e7361ec4SMark Brown int (*remove)(struct snd_soc_card *card); 951808db4a4SRichard Purdie 952808db4a4SRichard Purdie /* the pre and post PM functions are used to do any PM work before and 953808db4a4SRichard Purdie * after the codec and DAI's do any PM work. */ 95470b2ac12SMark Brown int (*suspend_pre)(struct snd_soc_card *card); 95570b2ac12SMark Brown int (*suspend_post)(struct snd_soc_card *card); 95670b2ac12SMark Brown int (*resume_pre)(struct snd_soc_card *card); 95770b2ac12SMark Brown int (*resume_post)(struct snd_soc_card *card); 958808db4a4SRichard Purdie 9590b4d221bSLiam Girdwood /* callbacks */ 96087506549SMark Brown int (*set_bias_level)(struct snd_soc_card *, 961d4c6005fSMark Brown struct snd_soc_dapm_context *dapm, 9620be9898aSMark Brown enum snd_soc_bias_level level); 9631badabd9SMark Brown int (*set_bias_level_post)(struct snd_soc_card *, 964d4c6005fSMark Brown struct snd_soc_dapm_context *dapm, 9651badabd9SMark Brown enum snd_soc_bias_level level); 9660b4d221bSLiam Girdwood 967d6f220eaSMengdong Lin int (*add_dai_link)(struct snd_soc_card *, 968d6f220eaSMengdong Lin struct snd_soc_dai_link *link); 969d6f220eaSMengdong Lin void (*remove_dai_link)(struct snd_soc_card *, 970d6f220eaSMengdong Lin struct snd_soc_dai_link *link); 971d6f220eaSMengdong Lin 9726c5f1fedSMark Brown long pmdown_time; 97396dd3622SMark Brown 974808db4a4SRichard Purdie /* CPU <--> Codec DAI links */ 975f8f80361SMengdong Lin struct snd_soc_dai_link *dai_link; /* predefined links only */ 976f8f80361SMengdong Lin int num_links; /* predefined links only */ 977f8f80361SMengdong Lin 9781a497983SMengdong Lin struct list_head rtd_list; 979f0fba2adSLiam Girdwood int num_rtd; 9806308419aSMark Brown 981ff819b83SDimitris Papastamos /* optional codec specific configuration */ 982ff819b83SDimitris Papastamos struct snd_soc_codec_conf *codec_conf; 983ff819b83SDimitris Papastamos int num_configs; 984ead9b919SJarkko Nikula 9852eea392dSJarkko Nikula /* 9862eea392dSJarkko Nikula * optional auxiliary devices such as amplifiers or codecs with DAI 9872eea392dSJarkko Nikula * link unused 9882eea392dSJarkko Nikula */ 9892eea392dSJarkko Nikula struct snd_soc_aux_dev *aux_dev; 9902eea392dSJarkko Nikula int num_aux_devs; 991d2e3a135SSylwester Nawrocki struct list_head aux_comp_list; 9922eea392dSJarkko Nikula 993b7af1dafSMark Brown const struct snd_kcontrol_new *controls; 994b7af1dafSMark Brown int num_controls; 995b7af1dafSMark Brown 996b8ad29deSMark Brown /* 997b8ad29deSMark Brown * Card-specific routes and widgets. 998f23e860eSNicolin Chen * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in. 999b8ad29deSMark Brown */ 1000d06e48dbSLars-Peter Clausen const struct snd_soc_dapm_widget *dapm_widgets; 1001b8ad29deSMark Brown int num_dapm_widgets; 1002d06e48dbSLars-Peter Clausen const struct snd_soc_dapm_route *dapm_routes; 1003b8ad29deSMark Brown int num_dapm_routes; 1004f23e860eSNicolin Chen const struct snd_soc_dapm_widget *of_dapm_widgets; 1005f23e860eSNicolin Chen int num_of_dapm_widgets; 1006f23e860eSNicolin Chen const struct snd_soc_dapm_route *of_dapm_routes; 1007f23e860eSNicolin Chen int num_of_dapm_routes; 1008b8ad29deSMark Brown 1009f0fba2adSLiam Girdwood /* lists of probed devices belonging to this card */ 1010d9fc4063SKuninori Morimoto struct list_head component_dev_list; 1011e894efefSSrinivas Kandagatla struct list_head list; 1012a6052154SJarkko Nikula 101397c866deSJarkko Nikula struct list_head widgets; 10148ddab3f5SJarkko Nikula struct list_head paths; 10157be31be8SJarkko Nikula struct list_head dapm_list; 1016db432b41SMark Brown struct list_head dapm_dirty; 10178ddab3f5SJarkko Nikula 10188a978234SLiam Girdwood /* attached dynamic objects */ 10198a978234SLiam Girdwood struct list_head dobj_list; 10208a978234SLiam Girdwood 1021e37a4970SMark Brown /* Generic DAPM context for the card */ 1022e37a4970SMark Brown struct snd_soc_dapm_context dapm; 1023de02d078SMark Brown struct snd_soc_dapm_stats dapm_stats; 1024564c6504SLars-Peter Clausen struct snd_soc_dapm_update *update; 1025e37a4970SMark Brown 1026a6052154SJarkko Nikula #ifdef CONFIG_DEBUG_FS 1027a6052154SJarkko Nikula struct dentry *debugfs_card_root; 1028a6052154SJarkko Nikula #endif 1029b3da4251SKuninori Morimoto #ifdef CONFIG_PM_SLEEP 1030b3da4251SKuninori Morimoto struct work_struct deferred_resume_work; 1031b3da4251SKuninori Morimoto #endif 10323a45b867SJarkko Nikula u32 pop_time; 1033dddf3e4cSMark Brown 1034317ec675SKuninori Morimoto /* bit field */ 1035317ec675SKuninori Morimoto unsigned int instantiated:1; 1036317ec675SKuninori Morimoto unsigned int topology_shortname_created:1; 1037317ec675SKuninori Morimoto unsigned int fully_routed:1; 1038317ec675SKuninori Morimoto unsigned int disable_route_checks:1; 103927f07cacSKuninori Morimoto unsigned int probed:1; 1040aa293777SSameer Pujar unsigned int component_chaining:1; 1041317ec675SKuninori Morimoto 1042dddf3e4cSMark Brown void *drvdata; 1043808db4a4SRichard Purdie }; 10447fe072b4SKuninori Morimoto #define for_each_card_prelinks(card, i, link) \ 10457fe072b4SKuninori Morimoto for ((i) = 0; \ 10467fe072b4SKuninori Morimoto ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \ 10477fe072b4SKuninori Morimoto (i)++) 1048c2b71c71SKuninori Morimoto #define for_each_card_pre_auxs(card, i, aux) \ 1049c2b71c71SKuninori Morimoto for ((i) = 0; \ 1050c2b71c71SKuninori Morimoto ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \ 1051c2b71c71SKuninori Morimoto (i)++) 1052808db4a4SRichard Purdie 1053bcb1fd1fSKuninori Morimoto #define for_each_card_rtds(card, rtd) \ 1054bcb1fd1fSKuninori Morimoto list_for_each_entry(rtd, &(card)->rtd_list, list) 1055bcb1fd1fSKuninori Morimoto #define for_each_card_rtds_safe(card, rtd, _rtd) \ 1056bcb1fd1fSKuninori Morimoto list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list) 105798061fdbSKuninori Morimoto 1058c2b71c71SKuninori Morimoto #define for_each_card_auxs(card, component) \ 1059c2b71c71SKuninori Morimoto list_for_each_entry(component, &card->aux_comp_list, card_aux_list) 1060c2b71c71SKuninori Morimoto #define for_each_card_auxs_safe(card, component, _comp) \ 1061c2b71c71SKuninori Morimoto list_for_each_entry_safe(component, _comp, \ 1062c2b71c71SKuninori Morimoto &card->aux_comp_list, card_aux_list) 1063c2b71c71SKuninori Morimoto 1064f70f18f7SKuninori Morimoto #define for_each_card_components(card, component) \ 1065f70f18f7SKuninori Morimoto list_for_each_entry(component, &(card)->component_dev_list, card_list) 1066f70f18f7SKuninori Morimoto 1067df817f8eSKuninori Morimoto #define for_each_card_dapms(card, dapm) \ 1068df817f8eSKuninori Morimoto list_for_each_entry(dapm, &card->dapm_list, list) 1069df817f8eSKuninori Morimoto 107014596692SKuninori Morimoto #define for_each_card_widgets(card, w)\ 107114596692SKuninori Morimoto list_for_each_entry(w, &card->widgets, list) 107214596692SKuninori Morimoto #define for_each_card_widgets_safe(card, w, _w) \ 107314596692SKuninori Morimoto list_for_each_entry_safe(w, _w, &card->widgets, list) 107414596692SKuninori Morimoto 10752e5f8617SKuninori Morimoto 10762e5f8617SKuninori Morimoto static inline int snd_soc_card_is_instantiated(struct snd_soc_card *card) 10772e5f8617SKuninori Morimoto { 10782e5f8617SKuninori Morimoto return card && card->instantiated; 10792e5f8617SKuninori Morimoto } 10802e5f8617SKuninori Morimoto 1081f0fba2adSLiam Girdwood /* SoC machine DAI configuration, glues a codec and cpu DAI together */ 1082808db4a4SRichard Purdie struct snd_soc_pcm_runtime { 108336ae1a96SMark Brown struct device *dev; 1084f0fba2adSLiam Girdwood struct snd_soc_card *card; 1085f0fba2adSLiam Girdwood struct snd_soc_dai_link *dai_link; 1086b8c0dab9SLiam Girdwood struct snd_pcm_ops ops; 1087f0fba2adSLiam Girdwood 10887ddc7f91SKuninori Morimoto unsigned int c2c_params_select; /* currently selected c2c_param for dai link */ 1089243bcfafSCharles Keepax 109001d7584cSLiam Girdwood /* Dynamic PCM BE runtime data */ 1091a26ec2acSKuninori Morimoto struct snd_soc_dpcm_runtime dpcm[SNDRV_PCM_STREAM_LAST + 1]; 10923289dc02SKuninori Morimoto struct snd_soc_dapm_widget *c2c_widget[SNDRV_PCM_STREAM_LAST + 1]; 109301d7584cSLiam Girdwood 1094f0fba2adSLiam Girdwood long pmdown_time; 1095f0fba2adSLiam Girdwood 1096f0fba2adSLiam Girdwood /* runtime devices */ 1097f0fba2adSLiam Girdwood struct snd_pcm *pcm; 109849681077SVinod Koul struct snd_compr *compr; 10991729025bSKuninori Morimoto 11001729025bSKuninori Morimoto /* 11011729025bSKuninori Morimoto * dais = cpu_dai + codec_dai 11021729025bSKuninori Morimoto * see 11031729025bSKuninori Morimoto * soc_new_pcm_runtime() 11041729025bSKuninori Morimoto * asoc_rtd_to_cpu() 11051729025bSKuninori Morimoto * asoc_rtd_to_codec() 11061729025bSKuninori Morimoto */ 110722a2fc81SKuninori Morimoto struct snd_soc_dai **dais; 110876afa643SShreyas NC 1109f0fba2adSLiam Girdwood struct delayed_work delayed_work; 11104bf2e385SCurtis Malainey void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd); 1111f86dcef8SLiam Girdwood #ifdef CONFIG_DEBUG_FS 1112f86dcef8SLiam Girdwood struct dentry *debugfs_dpcm_root; 1113f86dcef8SLiam Girdwood #endif 11141a497983SMengdong Lin 11151a497983SMengdong Lin unsigned int num; /* 0-based and monotonic increasing */ 11161a497983SMengdong Lin struct list_head list; /* rtd list of the soc card */ 1117a7df0d3bSKuninori Morimoto 11186064ed73SKuninori Morimoto /* function mark */ 11196064ed73SKuninori Morimoto struct snd_pcm_substream *mark_startup; 1120918ad772SKuninori Morimoto struct snd_pcm_substream *mark_hw_params; 11216374f493SKuninori Morimoto struct snd_pcm_substream *mark_trigger; 1122cd7c7d10SKuninori Morimoto struct snd_compr_stream *mark_compr_startup; 11236064ed73SKuninori Morimoto 1124a7df0d3bSKuninori Morimoto /* bit field */ 1125a7df0d3bSKuninori Morimoto unsigned int pop_wait:1; 11267426af50SKuninori Morimoto unsigned int fe_compr:1; /* for Dynamic PCM */ 1127613fb500SKuninori Morimoto 1128613fb500SKuninori Morimoto int num_components; 11292d6201eeSGustavo A. R. Silva struct snd_soc_component *components[]; /* CPU/Codec/Platform */ 1130808db4a4SRichard Purdie }; 11312af69581SKuninori Morimoto /* see soc_new_pcm_runtime() */ 11322af69581SKuninori Morimoto #define asoc_rtd_to_cpu(rtd, n) (rtd)->dais[n] 11333989ade2SKuninori Morimoto #define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->dai_link->num_cpus] 11340ceef681SKuninori Morimoto #define asoc_substream_to_rtd(substream) \ 11350ceef681SKuninori Morimoto (struct snd_soc_pcm_runtime *)snd_pcm_substream_chip(substream) 11362af69581SKuninori Morimoto 1137613fb500SKuninori Morimoto #define for_each_rtd_components(rtd, i, component) \ 1138be16a0f0SArnd Bergmann for ((i) = 0, component = NULL; \ 1139613fb500SKuninori Morimoto ((i) < rtd->num_components) && ((component) = rtd->components[i]);\ 1140613fb500SKuninori Morimoto (i)++) 1141995cbc3cSKuninori Morimoto #define for_each_rtd_cpu_dais(rtd, i, dai) \ 1142995cbc3cSKuninori Morimoto for ((i) = 0; \ 11433989ade2SKuninori Morimoto ((i) < rtd->dai_link->num_cpus) && ((dai) = asoc_rtd_to_cpu(rtd, i)); \ 1144995cbc3cSKuninori Morimoto (i)++) 1145995cbc3cSKuninori Morimoto #define for_each_rtd_codec_dais(rtd, i, dai) \ 1146995cbc3cSKuninori Morimoto for ((i) = 0; \ 11473989ade2SKuninori Morimoto ((i) < rtd->dai_link->num_codecs) && ((dai) = asoc_rtd_to_codec(rtd, i)); \ 1148995cbc3cSKuninori Morimoto (i)++) 114922a2fc81SKuninori Morimoto #define for_each_rtd_dais(rtd, i, dai) \ 115022a2fc81SKuninori Morimoto for ((i) = 0; \ 11513989ade2SKuninori Morimoto ((i) < (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs) && \ 115222a2fc81SKuninori Morimoto ((dai) = (rtd)->dais[i]); \ 115322a2fc81SKuninori Morimoto (i)++) 1154995cbc3cSKuninori Morimoto 115583f94a2eSKuninori Morimoto void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd); 1156808db4a4SRichard Purdie 11574eaa9819SJon Smirl /* mixer control */ 11584eaa9819SJon Smirl struct soc_mixer_control { 1159d11bb4a9SPeter Ujfalusi int min, max, platform_max; 1160249ce138SLars-Peter Clausen int reg, rreg; 1161249ce138SLars-Peter Clausen unsigned int shift, rshift; 1162f227b88fSMarkus Pargmann unsigned int sign_bit; 116357295073SLars-Peter Clausen unsigned int invert:1; 116457295073SLars-Peter Clausen unsigned int autodisable:1; 1165509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY 11668a978234SLiam Girdwood struct snd_soc_dobj dobj; 1167509ba54fSKuninori Morimoto #endif 11684eaa9819SJon Smirl }; 11694eaa9819SJon Smirl 117071d08516SMark Brown struct soc_bytes { 117171d08516SMark Brown int base; 117271d08516SMark Brown int num_regs; 1173f831b055SMark Brown u32 mask; 117471d08516SMark Brown }; 117571d08516SMark Brown 1176d9881208SVinod Koul struct soc_bytes_ext { 1177d9881208SVinod Koul int max; 1178509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY 11798a978234SLiam Girdwood struct snd_soc_dobj dobj; 1180509ba54fSKuninori Morimoto #endif 11817523a271SOmair Mohammed Abdullah /* used for TLV byte control */ 1182a1e5e7e9SMythri P K int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes, 1183a1e5e7e9SMythri P K unsigned int size); 1184a1e5e7e9SMythri P K int (*put)(struct snd_kcontrol *kcontrol, const unsigned int __user *bytes, 1185a1e5e7e9SMythri P K unsigned int size); 1186d9881208SVinod Koul }; 1187d9881208SVinod Koul 11884183eed2SKristoffer KARLSSON /* multi register control */ 11894183eed2SKristoffer KARLSSON struct soc_mreg_control { 11904183eed2SKristoffer KARLSSON long min, max; 11914183eed2SKristoffer KARLSSON unsigned int regbase, regcount, nbits, invert; 11924183eed2SKristoffer KARLSSON }; 11934183eed2SKristoffer KARLSSON 1194808db4a4SRichard Purdie /* enumerated kcontrol */ 1195808db4a4SRichard Purdie struct soc_enum { 1196b948837aSLars-Peter Clausen int reg; 1197808db4a4SRichard Purdie unsigned char shift_l; 1198808db4a4SRichard Purdie unsigned char shift_r; 11999a8d38dbSTakashi Iwai unsigned int items; 12002e72f8e3SPeter Ujfalusi unsigned int mask; 120187023ff7STakashi Iwai const char * const *texts; 12022e72f8e3SPeter Ujfalusi const unsigned int *values; 1203561ed680SCharles Keepax unsigned int autodisable:1; 1204509ba54fSKuninori Morimoto #ifdef CONFIG_SND_SOC_TOPOLOGY 12058a978234SLiam Girdwood struct snd_soc_dobj dobj; 1206509ba54fSKuninori Morimoto #endif 12072e72f8e3SPeter Ujfalusi }; 12082e72f8e3SPeter Ujfalusi 120930d86ba4SPeter Ujfalusi static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc) 121030d86ba4SPeter Ujfalusi { 121130d86ba4SPeter Ujfalusi if (mc->reg == mc->rreg && mc->shift == mc->rshift) 12124aa86e05SJason Yan return false; 121330d86ba4SPeter Ujfalusi /* 121430d86ba4SPeter Ujfalusi * mc->reg == mc->rreg && mc->shift != mc->rshift, or 121530d86ba4SPeter Ujfalusi * mc->reg != mc->rreg means that the control is 121630d86ba4SPeter Ujfalusi * stereo (bits in one register or in two registers) 121730d86ba4SPeter Ujfalusi */ 12184aa86e05SJason Yan return true; 121930d86ba4SPeter Ujfalusi } 122030d86ba4SPeter Ujfalusi 122129ae2fa5SLars-Peter Clausen static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e, 122229ae2fa5SLars-Peter Clausen unsigned int val) 122329ae2fa5SLars-Peter Clausen { 122429ae2fa5SLars-Peter Clausen unsigned int i; 122529ae2fa5SLars-Peter Clausen 122629ae2fa5SLars-Peter Clausen if (!e->values) 122729ae2fa5SLars-Peter Clausen return val; 122829ae2fa5SLars-Peter Clausen 122929ae2fa5SLars-Peter Clausen for (i = 0; i < e->items; i++) 123029ae2fa5SLars-Peter Clausen if (val == e->values[i]) 123129ae2fa5SLars-Peter Clausen return i; 123229ae2fa5SLars-Peter Clausen 123329ae2fa5SLars-Peter Clausen return 0; 123429ae2fa5SLars-Peter Clausen } 123529ae2fa5SLars-Peter Clausen 123629ae2fa5SLars-Peter Clausen static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e, 123729ae2fa5SLars-Peter Clausen unsigned int item) 123829ae2fa5SLars-Peter Clausen { 123929ae2fa5SLars-Peter Clausen if (!e->values) 124029ae2fa5SLars-Peter Clausen return item; 124129ae2fa5SLars-Peter Clausen 124229ae2fa5SLars-Peter Clausen return e->values[item]; 124329ae2fa5SLars-Peter Clausen } 124429ae2fa5SLars-Peter Clausen 1245ea53bf77SLars-Peter Clausen /** 1246907fe36aSLars-Peter Clausen * snd_soc_kcontrol_component() - Returns the component that registered the 1247907fe36aSLars-Peter Clausen * control 1248907fe36aSLars-Peter Clausen * @kcontrol: The control for which to get the component 1249907fe36aSLars-Peter Clausen * 1250907fe36aSLars-Peter Clausen * Note: This function will work correctly if the control has been registered 1251ef050becSCharles Keepax * for a component. With snd_soc_add_codec_controls() or via table based 1252ef050becSCharles Keepax * setup for either a CODEC or component driver. Otherwise the behavior is 1253ef050becSCharles Keepax * undefined. 1254907fe36aSLars-Peter Clausen */ 1255907fe36aSLars-Peter Clausen static inline struct snd_soc_component *snd_soc_kcontrol_component( 1256907fe36aSLars-Peter Clausen struct snd_kcontrol *kcontrol) 1257907fe36aSLars-Peter Clausen { 1258907fe36aSLars-Peter Clausen return snd_kcontrol_chip(kcontrol); 1259907fe36aSLars-Peter Clausen } 1260907fe36aSLars-Peter Clausen 1261fb257897SMark Brown int snd_soc_util_init(void); 1262fb257897SMark Brown void snd_soc_util_exit(void); 1263fb257897SMark Brown 1264b07609ceSKuninori Morimoto int snd_soc_of_parse_card_name(struct snd_soc_card *card, 1265bec4fa05SStephen Warren const char *propname); 126621efde50SKuninori Morimoto int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card, 12679a6d4860SXiubo Li const char *propname); 12683d4641a4SStephan Gerhold int snd_soc_of_parse_pin_switches(struct snd_soc_card *card, const char *prop); 1269cbdfab3bSJerome Brunet int snd_soc_of_get_slot_mask(struct device_node *np, 1270cbdfab3bSJerome Brunet const char *prop_name, 1271cbdfab3bSJerome Brunet unsigned int *mask); 127289c67857SXiubo Li int snd_soc_of_parse_tdm_slot(struct device_node *np, 12736131084aSJyri Sarha unsigned int *tx_mask, 12746131084aSJyri Sarha unsigned int *rx_mask, 127589c67857SXiubo Li unsigned int *slots, 127689c67857SXiubo Li unsigned int *slot_width); 12773b710356SKuninori Morimoto void snd_soc_of_parse_node_prefix(struct device_node *np, 12785e3cdaa2SKuninori Morimoto struct snd_soc_codec_conf *codec_conf, 12795e3cdaa2SKuninori Morimoto struct device_node *of_node, 12805e3cdaa2SKuninori Morimoto const char *propname); 12812708bccfSKuninori Morimoto static inline 12822708bccfSKuninori Morimoto void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card, 12832708bccfSKuninori Morimoto struct snd_soc_codec_conf *codec_conf, 12842708bccfSKuninori Morimoto struct device_node *of_node, 12852708bccfSKuninori Morimoto const char *propname) 12862708bccfSKuninori Morimoto { 12872708bccfSKuninori Morimoto snd_soc_of_parse_node_prefix(card->dev->of_node, 12882708bccfSKuninori Morimoto codec_conf, of_node, propname); 12892708bccfSKuninori Morimoto } 12903b710356SKuninori Morimoto 12912bc644afSKuninori Morimoto int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, 1292a4a54dd5SStephen Warren const char *propname); 12931ae0965dSStephan Gerhold int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname); 1294b44a67f8SKuninori Morimoto 129564c917d1SCharles Keepax unsigned int snd_soc_daifmt_clock_provider_flipped(unsigned int dai_fmt); 129691ae4477SKuninori Morimoto unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame); 12977766861dSKuninori Morimoto 12987766861dSKuninori Morimoto unsigned int snd_soc_daifmt_parse_format(struct device_node *np, const char *prefix); 12997766861dSKuninori Morimoto unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np, 13007766861dSKuninori Morimoto const char *prefix, 13017766861dSKuninori Morimoto struct device_node **bitclkmaster, 13027766861dSKuninori Morimoto struct device_node **framemaster); 13037766861dSKuninori Morimoto #define snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix) \ 13047766861dSKuninori Morimoto snd_soc_daifmt_parse_clock_provider_raw(np, prefix, NULL, NULL) 13057766861dSKuninori Morimoto #define snd_soc_daifmt_parse_clock_provider_as_phandle \ 13067766861dSKuninori Morimoto snd_soc_daifmt_parse_clock_provider_raw 13077766861dSKuninori Morimoto #define snd_soc_daifmt_parse_clock_provider_as_flag(np, prefix) \ 13087766861dSKuninori Morimoto snd_soc_daifmt_clock_provider_from_bitmap( \ 13097766861dSKuninori Morimoto snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix)) 13107766861dSKuninori Morimoto 13111c943f60SKuninori Morimoto int snd_soc_get_stream_cpu(struct snd_soc_dai_link *dai_link, int stream); 131205722a0cSKuninori Morimoto int snd_soc_get_dlc(const struct of_phandle_args *args, 131305722a0cSKuninori Morimoto struct snd_soc_dai_link_component *dlc); 131405722a0cSKuninori Morimoto int snd_soc_of_get_dlc(struct device_node *of_node, 131505722a0cSKuninori Morimoto struct of_phandle_args *args, 131605722a0cSKuninori Morimoto struct snd_soc_dai_link_component *dlc, 131705722a0cSKuninori Morimoto int index); 1318a180e8b9SKuninori Morimoto int snd_soc_get_dai_id(struct device_node *ep); 1319933f98beSKrzysztof Kozlowski int snd_soc_get_dai_name(const struct of_phandle_args *args, 13201ad8ec53SKuninori Morimoto const char **dai_name); 1321cb470087SKuninori Morimoto int snd_soc_of_get_dai_name(struct device_node *of_node, 1322*3c8b5861SKuninori Morimoto const char **dai_name, int index); 132393b0f3eeSJean-Francois Moine int snd_soc_of_get_dai_link_codecs(struct device *dev, 132493b0f3eeSJean-Francois Moine struct device_node *of_node, 132593b0f3eeSJean-Francois Moine struct snd_soc_dai_link *dai_link); 132694685763SSylwester Nawrocki void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link); 1327900dedd7SMartin Povišer int snd_soc_of_get_dai_link_cpus(struct device *dev, 1328900dedd7SMartin Povišer struct device_node *of_node, 1329900dedd7SMartin Povišer struct snd_soc_dai_link *dai_link); 1330900dedd7SMartin Povišer void snd_soc_of_put_dai_link_cpus(struct snd_soc_dai_link *dai_link); 1331bec4fa05SStephen Warren 1332ffaf886eSKuninori Morimoto int snd_soc_add_pcm_runtimes(struct snd_soc_card *card, 1333ffaf886eSKuninori Morimoto struct snd_soc_dai_link *dai_link, 1334ffaf886eSKuninori Morimoto int num_dai_link); 133550cd9b53SKuninori Morimoto void snd_soc_remove_pcm_runtime(struct snd_soc_card *card, 133650cd9b53SKuninori Morimoto struct snd_soc_pcm_runtime *rtd); 1337f8f80361SMengdong Lin 1338e443c205SKuninori Morimoto struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, 13395d075197SKuninori Morimoto struct snd_soc_dai_driver *dai_drv, 13405d075197SKuninori Morimoto bool legacy_dai_naming); 13410fae253aSPierre-Louis Bossart struct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev, 13420fae253aSPierre-Louis Bossart struct snd_soc_component *component, 13430fae253aSPierre-Louis Bossart struct snd_soc_dai_driver *dai_drv, 13440fae253aSPierre-Louis Bossart bool legacy_dai_naming); 1345e11381f3SKuninori Morimoto void snd_soc_unregister_dai(struct snd_soc_dai *dai); 134668003e6cSMengdong Lin 1347305e9020SMengdong Lin struct snd_soc_dai *snd_soc_find_dai( 1348305e9020SMengdong Lin const struct snd_soc_dai_link_component *dlc); 1349c1c277b2SKuninori Morimoto struct snd_soc_dai *snd_soc_find_dai_with_mutex( 1350c1c277b2SKuninori Morimoto const struct snd_soc_dai_link_component *dlc); 1351305e9020SMengdong Lin 1352a47cbe72SMark Brown #include <sound/soc-dai.h> 1353a47cbe72SMark Brown 13547c761b59SPierre-Louis Bossart static inline 1355cb50358bSPierre-Louis Bossart int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card, 1356cb50358bSPierre-Louis Bossart const char *platform_name) 1357cb50358bSPierre-Louis Bossart { 1358cb50358bSPierre-Louis Bossart struct snd_soc_dai_link *dai_link; 1359cb50358bSPierre-Louis Bossart const char *name; 1360cb50358bSPierre-Louis Bossart int i; 1361cb50358bSPierre-Louis Bossart 1362cb50358bSPierre-Louis Bossart if (!platform_name) /* nothing to do */ 1363cb50358bSPierre-Louis Bossart return 0; 1364cb50358bSPierre-Louis Bossart 1365cb50358bSPierre-Louis Bossart /* set platform name for each dailink */ 1366cb50358bSPierre-Louis Bossart for_each_card_prelinks(card, i, dai_link) { 1367d908b922SKuninori Morimoto /* only single platform is supported for now */ 1368d908b922SKuninori Morimoto if (dai_link->num_platforms != 1) 1369d908b922SKuninori Morimoto return -EINVAL; 1370d908b922SKuninori Morimoto 13714a50724eSKuninori Morimoto if (!dai_link->platforms) 13724a50724eSKuninori Morimoto return -EINVAL; 13734a50724eSKuninori Morimoto 1374cb50358bSPierre-Louis Bossart name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL); 1375cb50358bSPierre-Louis Bossart if (!name) 1376cb50358bSPierre-Louis Bossart return -ENOMEM; 1377cb50358bSPierre-Louis Bossart 1378cb50358bSPierre-Louis Bossart /* only single platform is supported for now */ 1379cb50358bSPierre-Louis Bossart dai_link->platforms->name = name; 1380cb50358bSPierre-Louis Bossart } 1381cb50358bSPierre-Louis Bossart 1382cb50358bSPierre-Louis Bossart return 0; 1383cb50358bSPierre-Louis Bossart } 1384cb50358bSPierre-Louis Bossart 1385faff4bb0SStephen Warren #ifdef CONFIG_DEBUG_FS 13868a9dab1aSMark Brown extern struct dentry *snd_soc_debugfs_root; 1387faff4bb0SStephen Warren #endif 1388faff4bb0SStephen Warren 13896f8ab4acSMark Brown extern const struct dev_pm_ops snd_soc_pm_ops; 13906f8ab4acSMark Brown 13914a778bdcSKuninori Morimoto /* 13924a778bdcSKuninori Morimoto * DAPM helper functions 13934a778bdcSKuninori Morimoto */ 13944a778bdcSKuninori Morimoto enum snd_soc_dapm_subclass { 13954a778bdcSKuninori Morimoto SND_SOC_DAPM_CLASS_ROOT = 0, 13964a778bdcSKuninori Morimoto SND_SOC_DAPM_CLASS_RUNTIME = 1, 13974a778bdcSKuninori Morimoto }; 13984a778bdcSKuninori Morimoto 13994a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_root_c(struct snd_soc_card *card) 1400f6d5e586SCharles Keepax { 14014a778bdcSKuninori Morimoto mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_ROOT); 1402f6d5e586SCharles Keepax } 1403f6d5e586SCharles Keepax 14044a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_c(struct snd_soc_card *card) 1405f6d5e586SCharles Keepax { 14064a778bdcSKuninori Morimoto mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 1407f6d5e586SCharles Keepax } 1408f6d5e586SCharles Keepax 14094a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_unlock_c(struct snd_soc_card *card) 14104a778bdcSKuninori Morimoto { 14114a778bdcSKuninori Morimoto mutex_unlock(&card->dapm_mutex); 14124a778bdcSKuninori Morimoto } 14134a778bdcSKuninori Morimoto 14144a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_assert_held_c(struct snd_soc_card *card) 14154a778bdcSKuninori Morimoto { 14164a778bdcSKuninori Morimoto lockdep_assert_held(&card->dapm_mutex); 14174a778bdcSKuninori Morimoto } 14184a778bdcSKuninori Morimoto 14194a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_root_d(struct snd_soc_dapm_context *dapm) 14204a778bdcSKuninori Morimoto { 14214a778bdcSKuninori Morimoto _snd_soc_dapm_mutex_lock_root_c(dapm->card); 14224a778bdcSKuninori Morimoto } 14234a778bdcSKuninori Morimoto 14244a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_lock_d(struct snd_soc_dapm_context *dapm) 14254a778bdcSKuninori Morimoto { 14264a778bdcSKuninori Morimoto _snd_soc_dapm_mutex_lock_c(dapm->card); 14274a778bdcSKuninori Morimoto } 14284a778bdcSKuninori Morimoto 14294a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_unlock_d(struct snd_soc_dapm_context *dapm) 14304a778bdcSKuninori Morimoto { 14314a778bdcSKuninori Morimoto _snd_soc_dapm_mutex_unlock_c(dapm->card); 14324a778bdcSKuninori Morimoto } 14334a778bdcSKuninori Morimoto 14344a778bdcSKuninori Morimoto static inline void _snd_soc_dapm_mutex_assert_held_d(struct snd_soc_dapm_context *dapm) 14354a778bdcSKuninori Morimoto { 14364a778bdcSKuninori Morimoto _snd_soc_dapm_mutex_assert_held_c(dapm->card); 14374a778bdcSKuninori Morimoto } 14384a778bdcSKuninori Morimoto 14394a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_lock_root(x) _Generic((x), \ 14404a778bdcSKuninori Morimoto struct snd_soc_card * : _snd_soc_dapm_mutex_lock_root_c, \ 14414a778bdcSKuninori Morimoto struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_root_d)(x) 14424a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_lock(x) _Generic((x), \ 14434a778bdcSKuninori Morimoto struct snd_soc_card * : _snd_soc_dapm_mutex_lock_c, \ 14444a778bdcSKuninori Morimoto struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_d)(x) 14454a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_unlock(x) _Generic((x), \ 14464a778bdcSKuninori Morimoto struct snd_soc_card * : _snd_soc_dapm_mutex_unlock_c, \ 14474a778bdcSKuninori Morimoto struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_unlock_d)(x) 14484a778bdcSKuninori Morimoto #define snd_soc_dapm_mutex_assert_held(x) _Generic((x), \ 14494a778bdcSKuninori Morimoto struct snd_soc_card * : _snd_soc_dapm_mutex_assert_held_c, \ 14504a778bdcSKuninori Morimoto struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_assert_held_d)(x) 14514a778bdcSKuninori Morimoto 145238e42f6dSKuninori Morimoto /* 145338e42f6dSKuninori Morimoto * PCM helper functions 145438e42f6dSKuninori Morimoto */ 145538e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_lock_c(struct snd_soc_card *card) 145638e42f6dSKuninori Morimoto { 145738e42f6dSKuninori Morimoto mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass); 145838e42f6dSKuninori Morimoto } 145938e42f6dSKuninori Morimoto 146038e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_unlock_c(struct snd_soc_card *card) 146138e42f6dSKuninori Morimoto { 146238e42f6dSKuninori Morimoto mutex_unlock(&card->pcm_mutex); 146338e42f6dSKuninori Morimoto } 146438e42f6dSKuninori Morimoto 146538e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_assert_held_c(struct snd_soc_card *card) 146638e42f6dSKuninori Morimoto { 146738e42f6dSKuninori Morimoto lockdep_assert_held(&card->pcm_mutex); 146838e42f6dSKuninori Morimoto } 146938e42f6dSKuninori Morimoto 147038e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_lock_r(struct snd_soc_pcm_runtime *rtd) 147138e42f6dSKuninori Morimoto { 147238e42f6dSKuninori Morimoto _snd_soc_dpcm_mutex_lock_c(rtd->card); 147338e42f6dSKuninori Morimoto } 147438e42f6dSKuninori Morimoto 147538e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_unlock_r(struct snd_soc_pcm_runtime *rtd) 147638e42f6dSKuninori Morimoto { 147738e42f6dSKuninori Morimoto _snd_soc_dpcm_mutex_unlock_c(rtd->card); 147838e42f6dSKuninori Morimoto } 147938e42f6dSKuninori Morimoto 148038e42f6dSKuninori Morimoto static inline void _snd_soc_dpcm_mutex_assert_held_r(struct snd_soc_pcm_runtime *rtd) 148138e42f6dSKuninori Morimoto { 148238e42f6dSKuninori Morimoto _snd_soc_dpcm_mutex_assert_held_c(rtd->card); 148338e42f6dSKuninori Morimoto } 148438e42f6dSKuninori Morimoto 148538e42f6dSKuninori Morimoto #define snd_soc_dpcm_mutex_lock(x) _Generic((x), \ 148638e42f6dSKuninori Morimoto struct snd_soc_card * : _snd_soc_dpcm_mutex_lock_c, \ 148738e42f6dSKuninori Morimoto struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_lock_r)(x) 148838e42f6dSKuninori Morimoto 148938e42f6dSKuninori Morimoto #define snd_soc_dpcm_mutex_unlock(x) _Generic((x), \ 149038e42f6dSKuninori Morimoto struct snd_soc_card * : _snd_soc_dpcm_mutex_unlock_c, \ 149138e42f6dSKuninori Morimoto struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_unlock_r)(x) 149238e42f6dSKuninori Morimoto 149338e42f6dSKuninori Morimoto #define snd_soc_dpcm_mutex_assert_held(x) _Generic((x), \ 149438e42f6dSKuninori Morimoto struct snd_soc_card * : _snd_soc_dpcm_mutex_assert_held_c, \ 149538e42f6dSKuninori Morimoto struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_assert_held_r)(x) 149638e42f6dSKuninori Morimoto 14974ff1fef1SKuninori Morimoto #include <sound/soc-component.h> 14981793936bSKuninori Morimoto #include <sound/soc-card.h> 1499ddfbe828SKuninori Morimoto #include <sound/soc-jack.h> 15001b4d9c22SRichard Fitzgerald 1501808db4a4SRichard Purdie #endif 1502