0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __LINUX_SND_SOC_H
0011 #define __LINUX_SND_SOC_H
0012
0013 #include <linux/of.h>
0014 #include <linux/platform_device.h>
0015 #include <linux/types.h>
0016 #include <linux/notifier.h>
0017 #include <linux/workqueue.h>
0018 #include <linux/interrupt.h>
0019 #include <linux/kernel.h>
0020 #include <linux/regmap.h>
0021 #include <linux/log2.h>
0022 #include <sound/core.h>
0023 #include <sound/pcm.h>
0024 #include <sound/compress_driver.h>
0025 #include <sound/control.h>
0026 #include <sound/ac97_codec.h>
0027
0028
0029
0030
0031 #define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert, xautodisable) \
0032 ((unsigned long)&(struct soc_mixer_control) \
0033 {.reg = xreg, .rreg = xreg, .shift = shift_left, \
0034 .rshift = shift_right, .max = xmax, .platform_max = xmax, \
0035 .invert = xinvert, .autodisable = xautodisable})
0036 #define SOC_DOUBLE_S_VALUE(xreg, shift_left, shift_right, xmin, xmax, xsign_bit, xinvert, xautodisable) \
0037 ((unsigned long)&(struct soc_mixer_control) \
0038 {.reg = xreg, .rreg = xreg, .shift = shift_left, \
0039 .rshift = shift_right, .min = xmin, .max = xmax, .platform_max = xmax, \
0040 .sign_bit = xsign_bit, .invert = xinvert, .autodisable = xautodisable})
0041 #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, xautodisable) \
0042 SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert, xautodisable)
0043 #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
0044 ((unsigned long)&(struct soc_mixer_control) \
0045 {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert})
0046 #define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
0047 ((unsigned long)&(struct soc_mixer_control) \
0048 {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
0049 .max = xmax, .platform_max = xmax, .invert = xinvert})
0050 #define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
0051 ((unsigned long)&(struct soc_mixer_control) \
0052 {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
0053 .max = xmax, .min = xmin, .platform_max = xmax, .sign_bit = xsign_bit, \
0054 .invert = xinvert})
0055 #define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
0056 ((unsigned long)&(struct soc_mixer_control) \
0057 {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
0058 .min = xmin, .max = xmax, .platform_max = xmax, .invert = xinvert})
0059 #define SOC_SINGLE(xname, reg, shift, max, invert) \
0060 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0061 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
0062 .put = snd_soc_put_volsw, \
0063 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
0064 #define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
0065 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
0066 .info = snd_soc_info_volsw_range, .get = snd_soc_get_volsw_range, \
0067 .put = snd_soc_put_volsw_range, \
0068 .private_value = (unsigned long)&(struct soc_mixer_control) \
0069 {.reg = xreg, .rreg = xreg, .shift = xshift, \
0070 .rshift = xshift, .min = xmin, .max = xmax, \
0071 .platform_max = xmax, .invert = xinvert} }
0072 #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
0073 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0074 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
0075 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
0076 .tlv.p = (tlv_array), \
0077 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
0078 .put = snd_soc_put_volsw, \
0079 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
0080 #define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
0081 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0082 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
0083 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
0084 .tlv.p = (tlv_array),\
0085 .info = snd_soc_info_volsw_sx, \
0086 .get = snd_soc_get_volsw_sx,\
0087 .put = snd_soc_put_volsw_sx, \
0088 .private_value = (unsigned long)&(struct soc_mixer_control) \
0089 {.reg = xreg, .rreg = xreg, \
0090 .shift = xshift, .rshift = xshift, \
0091 .max = xmax, .min = xmin} }
0092 #define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \
0093 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
0094 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
0095 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
0096 .tlv.p = (tlv_array), \
0097 .info = snd_soc_info_volsw_range, \
0098 .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
0099 .private_value = (unsigned long)&(struct soc_mixer_control) \
0100 {.reg = xreg, .rreg = xreg, .shift = xshift, \
0101 .rshift = xshift, .min = xmin, .max = xmax, \
0102 .platform_max = xmax, .invert = xinvert} }
0103 #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
0104 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
0105 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
0106 .put = snd_soc_put_volsw, \
0107 .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
0108 max, invert, 0) }
0109 #define SOC_DOUBLE_STS(xname, reg, shift_left, shift_right, max, invert) \
0110 { \
0111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0112 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
0113 .access = SNDRV_CTL_ELEM_ACCESS_READ | \
0114 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
0115 .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
0116 max, invert, 0) }
0117 #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
0118 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0119 .info = snd_soc_info_volsw, \
0120 .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
0121 .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
0122 xmax, xinvert) }
0123 #define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \
0124 xmax, xinvert) \
0125 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
0126 .info = snd_soc_info_volsw_range, \
0127 .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
0128 .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
0129 xshift, xmin, xmax, xinvert) }
0130 #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
0131 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
0132 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
0133 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
0134 .tlv.p = (tlv_array), \
0135 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
0136 .put = snd_soc_put_volsw, \
0137 .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
0138 max, invert, 0) }
0139 #define SOC_DOUBLE_SX_TLV(xname, xreg, shift_left, shift_right, xmin, xmax, tlv_array) \
0140 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0141 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
0142 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
0143 .tlv.p = (tlv_array), \
0144 .info = snd_soc_info_volsw_sx, \
0145 .get = snd_soc_get_volsw_sx, \
0146 .put = snd_soc_put_volsw_sx, \
0147 .private_value = (unsigned long)&(struct soc_mixer_control) \
0148 {.reg = xreg, .rreg = xreg, \
0149 .shift = shift_left, .rshift = shift_right, \
0150 .max = xmax, .min = xmin} }
0151 #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
0152 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
0153 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
0154 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
0155 .tlv.p = (tlv_array), \
0156 .info = snd_soc_info_volsw, \
0157 .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
0158 .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
0159 xmax, xinvert) }
0160 #define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \
0161 xmax, xinvert, tlv_array) \
0162 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
0163 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
0164 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
0165 .tlv.p = (tlv_array), \
0166 .info = snd_soc_info_volsw_range, \
0167 .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
0168 .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
0169 xshift, xmin, xmax, xinvert) }
0170 #define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
0171 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0172 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
0173 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
0174 .tlv.p = (tlv_array), \
0175 .info = snd_soc_info_volsw_sx, \
0176 .get = snd_soc_get_volsw_sx, \
0177 .put = snd_soc_put_volsw_sx, \
0178 .private_value = (unsigned long)&(struct soc_mixer_control) \
0179 {.reg = xreg, .rreg = xrreg, \
0180 .shift = xshift, .rshift = xshift, \
0181 .max = xmax, .min = xmin} }
0182 #define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
0183 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
0184 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
0185 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
0186 .tlv.p = (tlv_array), \
0187 .info = snd_soc_info_volsw, \
0188 .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
0189 .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
0190 xmin, xmax, xsign_bit, xinvert) }
0191 #define SOC_SINGLE_S_TLV(xname, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
0192 SOC_DOUBLE_R_S_TLV(xname, xreg, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array)
0193 #define SOC_SINGLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
0194 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0195 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
0196 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
0197 .tlv.p = (tlv_array), \
0198 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
0199 .put = snd_soc_put_volsw, \
0200 .private_value = (unsigned long)&(struct soc_mixer_control) \
0201 {.reg = xreg, .rreg = xreg, \
0202 .min = xmin, .max = xmax, .platform_max = xmax, \
0203 .sign_bit = 7,} }
0204 #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
0205 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0206 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
0207 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
0208 .tlv.p = (tlv_array), \
0209 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
0210 .put = snd_soc_put_volsw, \
0211 .private_value = SOC_DOUBLE_S_VALUE(xreg, 0, 8, xmin, xmax, 7, 0, 0) }
0212 #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
0213 { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
0214 .items = xitems, .texts = xtexts, \
0215 .mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
0216 #define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
0217 SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
0218 #define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
0219 { .items = xitems, .texts = xtexts }
0220 #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
0221 { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
0222 .mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
0223 #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
0224 SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xitems, xtexts, xvalues)
0225 #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
0226 { .reg = xreg, .shift_l = xshift, .shift_r = xshift, \
0227 .mask = xmask, .items = xitems, .texts = xtexts, \
0228 .values = xvalues, .autodisable = 1}
0229 #define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
0230 SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
0231 #define SOC_ENUM(xname, xenum) \
0232 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
0233 .info = snd_soc_info_enum_double, \
0234 .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
0235 .private_value = (unsigned long)&xenum }
0236 #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
0237 xhandler_get, xhandler_put) \
0238 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0239 .info = snd_soc_info_volsw, \
0240 .get = xhandler_get, .put = xhandler_put, \
0241 .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
0242 #define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
0243 xhandler_get, xhandler_put) \
0244 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
0245 .info = snd_soc_info_volsw, \
0246 .get = xhandler_get, .put = xhandler_put, \
0247 .private_value = \
0248 SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) }
0249 #define SOC_DOUBLE_R_EXT(xname, reg_left, reg_right, xshift, xmax, xinvert,\
0250 xhandler_get, xhandler_put) \
0251 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0252 .info = snd_soc_info_volsw, \
0253 .get = xhandler_get, .put = xhandler_put, \
0254 .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
0255 xmax, xinvert) }
0256 #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
0257 xhandler_get, xhandler_put, tlv_array) \
0258 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0259 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
0260 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
0261 .tlv.p = (tlv_array), \
0262 .info = snd_soc_info_volsw, \
0263 .get = xhandler_get, .put = xhandler_put, \
0264 .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
0265 #define SOC_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
0266 xhandler_get, xhandler_put, tlv_array) \
0267 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
0268 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
0269 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
0270 .tlv.p = (tlv_array), \
0271 .info = snd_soc_info_volsw_range, \
0272 .get = xhandler_get, .put = xhandler_put, \
0273 .private_value = (unsigned long)&(struct soc_mixer_control) \
0274 {.reg = xreg, .rreg = xreg, .shift = xshift, \
0275 .rshift = xshift, .min = xmin, .max = xmax, \
0276 .platform_max = xmax, .invert = xinvert} }
0277 #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
0278 xhandler_get, xhandler_put, tlv_array) \
0279 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0280 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
0281 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
0282 .tlv.p = (tlv_array), \
0283 .info = snd_soc_info_volsw, \
0284 .get = xhandler_get, .put = xhandler_put, \
0285 .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
0286 xmax, xinvert, 0) }
0287 #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
0288 xhandler_get, xhandler_put, tlv_array) \
0289 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0290 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
0291 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
0292 .tlv.p = (tlv_array), \
0293 .info = snd_soc_info_volsw, \
0294 .get = xhandler_get, .put = xhandler_put, \
0295 .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
0296 xmax, xinvert) }
0297 #define SOC_DOUBLE_R_S_EXT_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, \
0298 xsign_bit, xinvert, xhandler_get, xhandler_put, \
0299 tlv_array) \
0300 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0301 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
0302 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
0303 .tlv.p = (tlv_array), \
0304 .info = snd_soc_info_volsw, \
0305 .get = xhandler_get, .put = xhandler_put, \
0306 .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
0307 xmin, xmax, xsign_bit, xinvert) }
0308 #define SOC_SINGLE_S_EXT_TLV(xname, xreg, xshift, xmin, xmax, \
0309 xsign_bit, xinvert, xhandler_get, xhandler_put, \
0310 tlv_array) \
0311 SOC_DOUBLE_R_S_EXT_TLV(xname, xreg, xreg, xshift, xmin, xmax, \
0312 xsign_bit, xinvert, xhandler_get, xhandler_put, \
0313 tlv_array)
0314 #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
0315 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0316 .info = snd_soc_info_bool_ext, \
0317 .get = xhandler_get, .put = xhandler_put, \
0318 .private_value = xdata }
0319 #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
0320 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0321 .info = snd_soc_info_enum_double, \
0322 .get = xhandler_get, .put = xhandler_put, \
0323 .private_value = (unsigned long)&xenum }
0324 #define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
0325 SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put)
0326
0327 #define SND_SOC_BYTES(xname, xbase, xregs) \
0328 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0329 .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
0330 .put = snd_soc_bytes_put, .private_value = \
0331 ((unsigned long)&(struct soc_bytes) \
0332 {.base = xbase, .num_regs = xregs }) }
0333 #define SND_SOC_BYTES_E(xname, xbase, xregs, xhandler_get, xhandler_put) \
0334 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0335 .info = snd_soc_bytes_info, .get = xhandler_get, \
0336 .put = xhandler_put, .private_value = \
0337 ((unsigned long)&(struct soc_bytes) \
0338 {.base = xbase, .num_regs = xregs }) }
0339
0340 #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask) \
0341 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0342 .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
0343 .put = snd_soc_bytes_put, .private_value = \
0344 ((unsigned long)&(struct soc_bytes) \
0345 {.base = xbase, .num_regs = xregs, \
0346 .mask = xmask }) }
0347
0348
0349
0350
0351 #define SND_SOC_BYTES_EXT(xname, xcount, xhandler_get, xhandler_put) \
0352 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0353 .info = snd_soc_bytes_info_ext, \
0354 .get = xhandler_get, .put = xhandler_put, \
0355 .private_value = (unsigned long)&(struct soc_bytes_ext) \
0356 {.max = xcount} }
0357 #define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \
0358 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0359 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \
0360 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
0361 .tlv.c = (snd_soc_bytes_tlv_callback), \
0362 .info = snd_soc_bytes_info_ext, \
0363 .private_value = (unsigned long)&(struct soc_bytes_ext) \
0364 {.max = xcount, .get = xhandler_get, .put = xhandler_put, } }
0365 #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
0366 xmin, xmax, xinvert) \
0367 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0368 .info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
0369 .put = snd_soc_put_xr_sx, \
0370 .private_value = (unsigned long)&(struct soc_mreg_control) \
0371 {.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
0372 .invert = xinvert, .min = xmin, .max = xmax} }
0373
0374 #define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
0375 SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
0376 snd_soc_get_strobe, snd_soc_put_strobe)
0377
0378
0379
0380
0381
0382 #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
0383 const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
0384 ARRAY_SIZE(xtexts), xtexts)
0385 #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
0386 SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
0387 #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
0388 const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
0389 #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
0390 const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
0391 ARRAY_SIZE(xtexts), xtexts, xvalues)
0392 #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
0393 SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
0394
0395 #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
0396 const struct soc_enum name = SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, \
0397 xshift, xmask, ARRAY_SIZE(xtexts), xtexts, xvalues)
0398
0399 #define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
0400 const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
0401
0402 struct device_node;
0403 struct snd_jack;
0404 struct snd_soc_card;
0405 struct snd_soc_pcm_stream;
0406 struct snd_soc_ops;
0407 struct snd_soc_pcm_runtime;
0408 struct snd_soc_dai;
0409 struct snd_soc_dai_driver;
0410 struct snd_soc_dai_link;
0411 struct snd_soc_component;
0412 struct snd_soc_component_driver;
0413 struct soc_enum;
0414 struct snd_soc_jack;
0415 struct snd_soc_jack_zone;
0416 struct snd_soc_jack_pin;
0417 #include <sound/soc-dapm.h>
0418 #include <sound/soc-dpcm.h>
0419 #include <sound/soc-topology.h>
0420
0421 struct snd_soc_jack_gpio;
0422
0423 enum snd_soc_pcm_subclass {
0424 SND_SOC_PCM_CLASS_PCM = 0,
0425 SND_SOC_PCM_CLASS_BE = 1,
0426 };
0427
0428 int snd_soc_register_card(struct snd_soc_card *card);
0429 void snd_soc_unregister_card(struct snd_soc_card *card);
0430 int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
0431 #ifdef CONFIG_PM_SLEEP
0432 int snd_soc_suspend(struct device *dev);
0433 int snd_soc_resume(struct device *dev);
0434 #else
0435 static inline int snd_soc_suspend(struct device *dev)
0436 {
0437 return 0;
0438 }
0439
0440 static inline int snd_soc_resume(struct device *dev)
0441 {
0442 return 0;
0443 }
0444 #endif
0445 int snd_soc_poweroff(struct device *dev);
0446 int snd_soc_component_initialize(struct snd_soc_component *component,
0447 const struct snd_soc_component_driver *driver,
0448 struct device *dev);
0449 int snd_soc_add_component(struct snd_soc_component *component,
0450 struct snd_soc_dai_driver *dai_drv,
0451 int num_dai);
0452 int snd_soc_register_component(struct device *dev,
0453 const struct snd_soc_component_driver *component_driver,
0454 struct snd_soc_dai_driver *dai_drv, int num_dai);
0455 int devm_snd_soc_register_component(struct device *dev,
0456 const struct snd_soc_component_driver *component_driver,
0457 struct snd_soc_dai_driver *dai_drv, int num_dai);
0458 void snd_soc_unregister_component(struct device *dev);
0459 void snd_soc_unregister_component_by_driver(struct device *dev,
0460 const struct snd_soc_component_driver *component_driver);
0461 struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
0462 const char *driver_name);
0463 struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
0464 const char *driver_name);
0465
0466 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
0467 #ifdef CONFIG_SND_SOC_COMPRESS
0468 int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
0469 #else
0470 static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
0471 {
0472 return 0;
0473 }
0474 #endif
0475
0476 void snd_soc_disconnect_sync(struct device *dev);
0477
0478 struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
0479 struct snd_soc_dai_link *dai_link);
0480
0481 bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
0482
0483 void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
0484 int stream, int action);
0485 static inline void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd,
0486 int stream)
0487 {
0488 snd_soc_runtime_action(rtd, stream, 1);
0489 }
0490 static inline void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd,
0491 int stream)
0492 {
0493 snd_soc_runtime_action(rtd, stream, -1);
0494 }
0495
0496 int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
0497 struct snd_pcm_hardware *hw, int stream);
0498
0499 int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
0500 unsigned int dai_fmt);
0501
0502 #ifdef CONFIG_DMI
0503 int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour);
0504 #else
0505 static inline int snd_soc_set_dmi_name(struct snd_soc_card *card,
0506 const char *flavour)
0507 {
0508 return 0;
0509 }
0510 #endif
0511
0512
0513 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
0514 int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
0515 int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
0516 int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
0517 int snd_soc_tdm_params_to_bclk(struct snd_pcm_hw_params *params,
0518 int tdm_width, int tdm_slots, int slot_multiple);
0519
0520
0521 int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
0522 const struct snd_pcm_hardware *hw);
0523
0524 struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
0525 struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
0526 unsigned int id, unsigned int id_mask);
0527 void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
0528
0529 #ifdef CONFIG_SND_SOC_AC97_BUS
0530 int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
0531 int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
0532 struct platform_device *pdev);
0533
0534 extern struct snd_ac97_bus_ops *soc_ac97_ops;
0535 #else
0536 static inline int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
0537 struct platform_device *pdev)
0538 {
0539 return 0;
0540 }
0541
0542 static inline int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
0543 {
0544 return 0;
0545 }
0546 #endif
0547
0548
0549
0550
0551 struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
0552 void *data, const char *long_name,
0553 const char *prefix);
0554 int snd_soc_add_component_controls(struct snd_soc_component *component,
0555 const struct snd_kcontrol_new *controls, unsigned int num_controls);
0556 int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
0557 const struct snd_kcontrol_new *controls, int num_controls);
0558 int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
0559 const struct snd_kcontrol_new *controls, int num_controls);
0560 int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
0561 struct snd_ctl_elem_info *uinfo);
0562 int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
0563 struct snd_ctl_elem_value *ucontrol);
0564 int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
0565 struct snd_ctl_elem_value *ucontrol);
0566 int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
0567 struct snd_ctl_elem_info *uinfo);
0568 int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
0569 struct snd_ctl_elem_info *uinfo);
0570 #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
0571 int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
0572 struct snd_ctl_elem_value *ucontrol);
0573 int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
0574 struct snd_ctl_elem_value *ucontrol);
0575 #define snd_soc_get_volsw_2r snd_soc_get_volsw
0576 #define snd_soc_put_volsw_2r snd_soc_put_volsw
0577 int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
0578 struct snd_ctl_elem_value *ucontrol);
0579 int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
0580 struct snd_ctl_elem_value *ucontrol);
0581 int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
0582 struct snd_ctl_elem_info *uinfo);
0583 int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
0584 struct snd_ctl_elem_value *ucontrol);
0585 int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
0586 struct snd_ctl_elem_value *ucontrol);
0587 int snd_soc_limit_volume(struct snd_soc_card *card,
0588 const char *name, int max);
0589 int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
0590 struct snd_ctl_elem_info *uinfo);
0591 int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
0592 struct snd_ctl_elem_value *ucontrol);
0593 int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
0594 struct snd_ctl_elem_value *ucontrol);
0595 int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
0596 struct snd_ctl_elem_info *ucontrol);
0597 int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
0598 unsigned int size, unsigned int __user *tlv);
0599 int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
0600 struct snd_ctl_elem_info *uinfo);
0601 int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
0602 struct snd_ctl_elem_value *ucontrol);
0603 int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
0604 struct snd_ctl_elem_value *ucontrol);
0605 int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
0606 struct snd_ctl_elem_value *ucontrol);
0607 int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
0608 struct snd_ctl_elem_value *ucontrol);
0609
0610
0611 struct snd_soc_pcm_stream {
0612 const char *stream_name;
0613 u64 formats;
0614 unsigned int rates;
0615 unsigned int rate_min;
0616 unsigned int rate_max;
0617 unsigned int channels_min;
0618 unsigned int channels_max;
0619 unsigned int sig_bits;
0620 };
0621
0622
0623 struct snd_soc_ops {
0624 int (*startup)(struct snd_pcm_substream *);
0625 void (*shutdown)(struct snd_pcm_substream *);
0626 int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
0627 int (*hw_free)(struct snd_pcm_substream *);
0628 int (*prepare)(struct snd_pcm_substream *);
0629 int (*trigger)(struct snd_pcm_substream *, int);
0630 };
0631
0632 struct snd_soc_compr_ops {
0633 int (*startup)(struct snd_compr_stream *);
0634 void (*shutdown)(struct snd_compr_stream *);
0635 int (*set_params)(struct snd_compr_stream *);
0636 int (*trigger)(struct snd_compr_stream *);
0637 };
0638
0639 struct snd_soc_component*
0640 snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
0641 const char *driver_name);
0642
0643 struct snd_soc_dai_link_component {
0644 const char *name;
0645 struct device_node *of_node;
0646 const char *dai_name;
0647 };
0648
0649 struct snd_soc_dai_link {
0650
0651 const char *name;
0652 const char *stream_name;
0653
0654
0655
0656
0657
0658
0659
0660
0661
0662
0663
0664
0665
0666 struct snd_soc_dai_link_component *cpus;
0667 unsigned int num_cpus;
0668
0669
0670
0671
0672
0673
0674 struct snd_soc_dai_link_component *codecs;
0675 unsigned int num_codecs;
0676
0677
0678
0679
0680
0681
0682 struct snd_soc_dai_link_component *platforms;
0683 unsigned int num_platforms;
0684
0685 int id;
0686
0687 const struct snd_soc_pcm_stream *params;
0688 unsigned int num_params;
0689
0690 unsigned int dai_fmt;
0691
0692 enum snd_soc_dpcm_trigger trigger[2];
0693
0694
0695 int (*init)(struct snd_soc_pcm_runtime *rtd);
0696
0697
0698 void (*exit)(struct snd_soc_pcm_runtime *rtd);
0699
0700
0701 int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
0702 struct snd_pcm_hw_params *params);
0703
0704
0705 const struct snd_soc_ops *ops;
0706 const struct snd_soc_compr_ops *compr_ops;
0707
0708
0709 unsigned int nonatomic:1;
0710
0711
0712 unsigned int playback_only:1;
0713 unsigned int capture_only:1;
0714
0715
0716 unsigned int ignore_suspend:1;
0717
0718
0719 unsigned int symmetric_rate:1;
0720 unsigned int symmetric_channels:1;
0721 unsigned int symmetric_sample_bits:1;
0722
0723
0724 unsigned int no_pcm:1;
0725
0726
0727 unsigned int dynamic:1;
0728
0729
0730 unsigned int dpcm_capture:1;
0731 unsigned int dpcm_playback:1;
0732
0733
0734 unsigned int dpcm_merged_format:1;
0735
0736 unsigned int dpcm_merged_chan:1;
0737
0738 unsigned int dpcm_merged_rate:1;
0739
0740
0741 unsigned int ignore_pmdown_time:1;
0742
0743
0744 unsigned int ignore:1;
0745
0746
0747
0748
0749
0750 unsigned int stop_dma_first:1;
0751
0752 #ifdef CONFIG_SND_SOC_TOPOLOGY
0753 struct snd_soc_dobj dobj;
0754 #endif
0755 };
0756
0757 static inline struct snd_soc_dai_link_component*
0758 asoc_link_to_cpu(struct snd_soc_dai_link *link, int n) {
0759 return &(link)->cpus[n];
0760 }
0761
0762 static inline struct snd_soc_dai_link_component*
0763 asoc_link_to_codec(struct snd_soc_dai_link *link, int n) {
0764 return &(link)->codecs[n];
0765 }
0766
0767 static inline struct snd_soc_dai_link_component*
0768 asoc_link_to_platform(struct snd_soc_dai_link *link, int n) {
0769 return &(link)->platforms[n];
0770 }
0771
0772 #define for_each_link_codecs(link, i, codec) \
0773 for ((i) = 0; \
0774 ((i) < link->num_codecs) && \
0775 ((codec) = asoc_link_to_codec(link, i)); \
0776 (i)++)
0777
0778 #define for_each_link_platforms(link, i, platform) \
0779 for ((i) = 0; \
0780 ((i) < link->num_platforms) && \
0781 ((platform) = asoc_link_to_platform(link, i)); \
0782 (i)++)
0783
0784 #define for_each_link_cpus(link, i, cpu) \
0785 for ((i) = 0; \
0786 ((i) < link->num_cpus) && \
0787 ((cpu) = asoc_link_to_cpu(link, i)); \
0788 (i)++)
0789
0790
0791
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834
0835
0836
0837
0838
0839
0840
0841
0842
0843 #define SND_SOC_DAILINK_REG1(name) SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms)
0844 #define SND_SOC_DAILINK_REG2(cpu, codec) SND_SOC_DAILINK_REG3(cpu, codec, null_dailink_component)
0845 #define SND_SOC_DAILINK_REG3(cpu, codec, platform) \
0846 .cpus = cpu, \
0847 .num_cpus = ARRAY_SIZE(cpu), \
0848 .codecs = codec, \
0849 .num_codecs = ARRAY_SIZE(codec), \
0850 .platforms = platform, \
0851 .num_platforms = ARRAY_SIZE(platform)
0852
0853 #define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func
0854 #define SND_SOC_DAILINK_REG(...) \
0855 SND_SOC_DAILINK_REGx(__VA_ARGS__, \
0856 SND_SOC_DAILINK_REG3, \
0857 SND_SOC_DAILINK_REG2, \
0858 SND_SOC_DAILINK_REG1)(__VA_ARGS__)
0859
0860 #define SND_SOC_DAILINK_DEF(name, def...) \
0861 static struct snd_soc_dai_link_component name[] = { def }
0862
0863 #define SND_SOC_DAILINK_DEFS(name, cpu, codec, platform...) \
0864 SND_SOC_DAILINK_DEF(name##_cpus, cpu); \
0865 SND_SOC_DAILINK_DEF(name##_codecs, codec); \
0866 SND_SOC_DAILINK_DEF(name##_platforms, platform)
0867
0868 #define DAILINK_COMP_ARRAY(param...) param
0869 #define COMP_EMPTY() { }
0870 #define COMP_CPU(_dai) { .dai_name = _dai, }
0871 #define COMP_CODEC(_name, _dai) { .name = _name, .dai_name = _dai, }
0872 #define COMP_PLATFORM(_name) { .name = _name }
0873 #define COMP_AUX(_name) { .name = _name }
0874 #define COMP_CODEC_CONF(_name) { .name = _name }
0875 #define COMP_DUMMY() { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
0876
0877 extern struct snd_soc_dai_link_component null_dailink_component[0];
0878
0879
0880 struct snd_soc_codec_conf {
0881
0882
0883
0884
0885 struct snd_soc_dai_link_component dlc;
0886
0887
0888
0889
0890
0891 const char *name_prefix;
0892 };
0893
0894 struct snd_soc_aux_dev {
0895
0896
0897
0898
0899 struct snd_soc_dai_link_component dlc;
0900
0901
0902 int (*init)(struct snd_soc_component *component);
0903 };
0904
0905
0906 struct snd_soc_card {
0907 const char *name;
0908 const char *long_name;
0909 const char *driver_name;
0910 const char *components;
0911 #ifdef CONFIG_DMI
0912 char dmi_longname[80];
0913 #endif
0914 char topology_shortname[32];
0915
0916 struct device *dev;
0917 struct snd_card *snd_card;
0918 struct module *owner;
0919
0920 struct mutex mutex;
0921 struct mutex dapm_mutex;
0922
0923
0924 struct mutex pcm_mutex;
0925 enum snd_soc_pcm_subclass pcm_subclass;
0926
0927 int (*probe)(struct snd_soc_card *card);
0928 int (*late_probe)(struct snd_soc_card *card);
0929 void (*fixup_controls)(struct snd_soc_card *card);
0930 int (*remove)(struct snd_soc_card *card);
0931
0932
0933
0934 int (*suspend_pre)(struct snd_soc_card *card);
0935 int (*suspend_post)(struct snd_soc_card *card);
0936 int (*resume_pre)(struct snd_soc_card *card);
0937 int (*resume_post)(struct snd_soc_card *card);
0938
0939
0940 int (*set_bias_level)(struct snd_soc_card *,
0941 struct snd_soc_dapm_context *dapm,
0942 enum snd_soc_bias_level level);
0943 int (*set_bias_level_post)(struct snd_soc_card *,
0944 struct snd_soc_dapm_context *dapm,
0945 enum snd_soc_bias_level level);
0946
0947 int (*add_dai_link)(struct snd_soc_card *,
0948 struct snd_soc_dai_link *link);
0949 void (*remove_dai_link)(struct snd_soc_card *,
0950 struct snd_soc_dai_link *link);
0951
0952 long pmdown_time;
0953
0954
0955 struct snd_soc_dai_link *dai_link;
0956 int num_links;
0957
0958 struct list_head rtd_list;
0959 int num_rtd;
0960
0961
0962 struct snd_soc_codec_conf *codec_conf;
0963 int num_configs;
0964
0965
0966
0967
0968
0969 struct snd_soc_aux_dev *aux_dev;
0970 int num_aux_devs;
0971 struct list_head aux_comp_list;
0972
0973 const struct snd_kcontrol_new *controls;
0974 int num_controls;
0975
0976
0977
0978
0979
0980 const struct snd_soc_dapm_widget *dapm_widgets;
0981 int num_dapm_widgets;
0982 const struct snd_soc_dapm_route *dapm_routes;
0983 int num_dapm_routes;
0984 const struct snd_soc_dapm_widget *of_dapm_widgets;
0985 int num_of_dapm_widgets;
0986 const struct snd_soc_dapm_route *of_dapm_routes;
0987 int num_of_dapm_routes;
0988
0989
0990 struct list_head component_dev_list;
0991 struct list_head list;
0992
0993 struct list_head widgets;
0994 struct list_head paths;
0995 struct list_head dapm_list;
0996 struct list_head dapm_dirty;
0997
0998
0999 struct list_head dobj_list;
1000
1001
1002 struct snd_soc_dapm_context dapm;
1003 struct snd_soc_dapm_stats dapm_stats;
1004 struct snd_soc_dapm_update *update;
1005
1006 #ifdef CONFIG_DEBUG_FS
1007 struct dentry *debugfs_card_root;
1008 #endif
1009 #ifdef CONFIG_PM_SLEEP
1010 struct work_struct deferred_resume_work;
1011 #endif
1012 u32 pop_time;
1013
1014
1015 unsigned int instantiated:1;
1016 unsigned int topology_shortname_created:1;
1017 unsigned int fully_routed:1;
1018 unsigned int disable_route_checks:1;
1019 unsigned int probed:1;
1020 unsigned int component_chaining:1;
1021
1022 void *drvdata;
1023 };
1024 #define for_each_card_prelinks(card, i, link) \
1025 for ((i) = 0; \
1026 ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
1027 (i)++)
1028 #define for_each_card_pre_auxs(card, i, aux) \
1029 for ((i) = 0; \
1030 ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \
1031 (i)++)
1032
1033 #define for_each_card_rtds(card, rtd) \
1034 list_for_each_entry(rtd, &(card)->rtd_list, list)
1035 #define for_each_card_rtds_safe(card, rtd, _rtd) \
1036 list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list)
1037
1038 #define for_each_card_auxs(card, component) \
1039 list_for_each_entry(component, &card->aux_comp_list, card_aux_list)
1040 #define for_each_card_auxs_safe(card, component, _comp) \
1041 list_for_each_entry_safe(component, _comp, \
1042 &card->aux_comp_list, card_aux_list)
1043
1044 #define for_each_card_components(card, component) \
1045 list_for_each_entry(component, &(card)->component_dev_list, card_list)
1046
1047 #define for_each_card_dapms(card, dapm) \
1048 list_for_each_entry(dapm, &card->dapm_list, list)
1049
1050 #define for_each_card_widgets(card, w)\
1051 list_for_each_entry(w, &card->widgets, list)
1052 #define for_each_card_widgets_safe(card, w, _w) \
1053 list_for_each_entry_safe(w, _w, &card->widgets, list)
1054
1055
1056 struct snd_soc_pcm_runtime {
1057 struct device *dev;
1058 struct snd_soc_card *card;
1059 struct snd_soc_dai_link *dai_link;
1060 struct snd_pcm_ops ops;
1061
1062 unsigned int params_select;
1063
1064
1065 struct snd_soc_dpcm_runtime dpcm[2];
1066
1067 long pmdown_time;
1068
1069
1070 struct snd_pcm *pcm;
1071 struct snd_compr *compr;
1072
1073
1074
1075
1076
1077
1078
1079
1080 struct snd_soc_dai **dais;
1081 unsigned int num_codecs;
1082 unsigned int num_cpus;
1083
1084 struct snd_soc_dapm_widget *playback_widget;
1085 struct snd_soc_dapm_widget *capture_widget;
1086
1087 struct delayed_work delayed_work;
1088 void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
1089 #ifdef CONFIG_DEBUG_FS
1090 struct dentry *debugfs_dpcm_root;
1091 #endif
1092
1093 unsigned int num;
1094 struct list_head list;
1095
1096
1097 struct snd_pcm_substream *mark_startup;
1098 struct snd_pcm_substream *mark_hw_params;
1099 struct snd_pcm_substream *mark_trigger;
1100 struct snd_compr_stream *mark_compr_startup;
1101
1102
1103 unsigned int pop_wait:1;
1104 unsigned int fe_compr:1;
1105
1106 int num_components;
1107 struct snd_soc_component *components[];
1108 };
1109
1110 #define asoc_rtd_to_cpu(rtd, n) (rtd)->dais[n]
1111 #define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->num_cpus]
1112 #define asoc_substream_to_rtd(substream) \
1113 (struct snd_soc_pcm_runtime *)snd_pcm_substream_chip(substream)
1114
1115 #define for_each_rtd_components(rtd, i, component) \
1116 for ((i) = 0, component = NULL; \
1117 ((i) < rtd->num_components) && ((component) = rtd->components[i]);\
1118 (i)++)
1119 #define for_each_rtd_cpu_dais(rtd, i, dai) \
1120 for ((i) = 0; \
1121 ((i) < rtd->num_cpus) && ((dai) = asoc_rtd_to_cpu(rtd, i)); \
1122 (i)++)
1123 #define for_each_rtd_codec_dais(rtd, i, dai) \
1124 for ((i) = 0; \
1125 ((i) < rtd->num_codecs) && ((dai) = asoc_rtd_to_codec(rtd, i)); \
1126 (i)++)
1127 #define for_each_rtd_dais(rtd, i, dai) \
1128 for ((i) = 0; \
1129 ((i) < (rtd)->num_cpus + (rtd)->num_codecs) && \
1130 ((dai) = (rtd)->dais[i]); \
1131 (i)++)
1132
1133 void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);
1134
1135
1136 struct soc_mixer_control {
1137 int min, max, platform_max;
1138 int reg, rreg;
1139 unsigned int shift, rshift;
1140 unsigned int sign_bit;
1141 unsigned int invert:1;
1142 unsigned int autodisable:1;
1143 #ifdef CONFIG_SND_SOC_TOPOLOGY
1144 struct snd_soc_dobj dobj;
1145 #endif
1146 };
1147
1148 struct soc_bytes {
1149 int base;
1150 int num_regs;
1151 u32 mask;
1152 };
1153
1154 struct soc_bytes_ext {
1155 int max;
1156 #ifdef CONFIG_SND_SOC_TOPOLOGY
1157 struct snd_soc_dobj dobj;
1158 #endif
1159
1160 int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
1161 unsigned int size);
1162 int (*put)(struct snd_kcontrol *kcontrol, const unsigned int __user *bytes,
1163 unsigned int size);
1164 };
1165
1166
1167 struct soc_mreg_control {
1168 long min, max;
1169 unsigned int regbase, regcount, nbits, invert;
1170 };
1171
1172
1173 struct soc_enum {
1174 int reg;
1175 unsigned char shift_l;
1176 unsigned char shift_r;
1177 unsigned int items;
1178 unsigned int mask;
1179 const char * const *texts;
1180 const unsigned int *values;
1181 unsigned int autodisable:1;
1182 #ifdef CONFIG_SND_SOC_TOPOLOGY
1183 struct snd_soc_dobj dobj;
1184 #endif
1185 };
1186
1187 static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
1188 {
1189 if (mc->reg == mc->rreg && mc->shift == mc->rshift)
1190 return false;
1191
1192
1193
1194
1195
1196 return true;
1197 }
1198
1199 static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
1200 unsigned int val)
1201 {
1202 unsigned int i;
1203
1204 if (!e->values)
1205 return val;
1206
1207 for (i = 0; i < e->items; i++)
1208 if (val == e->values[i])
1209 return i;
1210
1211 return 0;
1212 }
1213
1214 static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
1215 unsigned int item)
1216 {
1217 if (!e->values)
1218 return item;
1219
1220 return e->values[item];
1221 }
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233 static inline struct snd_soc_component *snd_soc_kcontrol_component(
1234 struct snd_kcontrol *kcontrol)
1235 {
1236 return snd_kcontrol_chip(kcontrol);
1237 }
1238
1239 int snd_soc_util_init(void);
1240 void snd_soc_util_exit(void);
1241
1242 int snd_soc_of_parse_card_name(struct snd_soc_card *card,
1243 const char *propname);
1244 int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
1245 const char *propname);
1246 int snd_soc_of_parse_pin_switches(struct snd_soc_card *card, const char *prop);
1247 int snd_soc_of_get_slot_mask(struct device_node *np,
1248 const char *prop_name,
1249 unsigned int *mask);
1250 int snd_soc_of_parse_tdm_slot(struct device_node *np,
1251 unsigned int *tx_mask,
1252 unsigned int *rx_mask,
1253 unsigned int *slots,
1254 unsigned int *slot_width);
1255 void snd_soc_of_parse_node_prefix(struct device_node *np,
1256 struct snd_soc_codec_conf *codec_conf,
1257 struct device_node *of_node,
1258 const char *propname);
1259 static inline
1260 void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
1261 struct snd_soc_codec_conf *codec_conf,
1262 struct device_node *of_node,
1263 const char *propname)
1264 {
1265 snd_soc_of_parse_node_prefix(card->dev->of_node,
1266 codec_conf, of_node, propname);
1267 }
1268
1269 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
1270 const char *propname);
1271 int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
1272
1273 unsigned int snd_soc_daifmt_clock_provider_flipped(unsigned int dai_fmt);
1274 unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame);
1275
1276 unsigned int snd_soc_daifmt_parse_format(struct device_node *np, const char *prefix);
1277 unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
1278 const char *prefix,
1279 struct device_node **bitclkmaster,
1280 struct device_node **framemaster);
1281 #define snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix) \
1282 snd_soc_daifmt_parse_clock_provider_raw(np, prefix, NULL, NULL)
1283 #define snd_soc_daifmt_parse_clock_provider_as_phandle \
1284 snd_soc_daifmt_parse_clock_provider_raw
1285 #define snd_soc_daifmt_parse_clock_provider_as_flag(np, prefix) \
1286 snd_soc_daifmt_clock_provider_from_bitmap( \
1287 snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix))
1288
1289 int snd_soc_get_dai_id(struct device_node *ep);
1290 int snd_soc_get_dai_name(const struct of_phandle_args *args,
1291 const char **dai_name);
1292 int snd_soc_of_get_dai_name(struct device_node *of_node,
1293 const char **dai_name);
1294 int snd_soc_of_get_dai_link_codecs(struct device *dev,
1295 struct device_node *of_node,
1296 struct snd_soc_dai_link *dai_link);
1297 void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
1298 int snd_soc_of_get_dai_link_cpus(struct device *dev,
1299 struct device_node *of_node,
1300 struct snd_soc_dai_link *dai_link);
1301 void snd_soc_of_put_dai_link_cpus(struct snd_soc_dai_link *dai_link);
1302
1303 int snd_soc_add_pcm_runtime(struct snd_soc_card *card,
1304 struct snd_soc_dai_link *dai_link);
1305 void snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
1306 struct snd_soc_pcm_runtime *rtd);
1307
1308 struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
1309 struct snd_soc_dai_driver *dai_drv,
1310 bool legacy_dai_naming);
1311 struct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev,
1312 struct snd_soc_component *component,
1313 struct snd_soc_dai_driver *dai_drv,
1314 bool legacy_dai_naming);
1315 void snd_soc_unregister_dai(struct snd_soc_dai *dai);
1316
1317 struct snd_soc_dai *snd_soc_find_dai(
1318 const struct snd_soc_dai_link_component *dlc);
1319 struct snd_soc_dai *snd_soc_find_dai_with_mutex(
1320 const struct snd_soc_dai_link_component *dlc);
1321
1322 #include <sound/soc-dai.h>
1323
1324 static inline
1325 int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
1326 const char *platform_name)
1327 {
1328 struct snd_soc_dai_link *dai_link;
1329 const char *name;
1330 int i;
1331
1332 if (!platform_name)
1333 return 0;
1334
1335
1336 for_each_card_prelinks(card, i, dai_link) {
1337
1338 if (dai_link->num_platforms != 1)
1339 return -EINVAL;
1340
1341 if (!dai_link->platforms)
1342 return -EINVAL;
1343
1344 name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
1345 if (!name)
1346 return -ENOMEM;
1347
1348
1349 dai_link->platforms->name = name;
1350 }
1351
1352 return 0;
1353 }
1354
1355 #ifdef CONFIG_DEBUG_FS
1356 extern struct dentry *snd_soc_debugfs_root;
1357 #endif
1358
1359 extern const struct dev_pm_ops snd_soc_pm_ops;
1360
1361
1362 static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm)
1363 {
1364 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
1365 }
1366
1367 static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
1368 {
1369 mutex_unlock(&dapm->card->dapm_mutex);
1370 }
1371
1372 #include <sound/soc-component.h>
1373 #include <sound/soc-card.h>
1374 #include <sound/soc-jack.h>
1375
1376 #endif