| 1 | |
| 2 | *
|
| 3 | * linux/sound/soc.h -- ALSA SoC Layer
|
| 4 | *
|
| 5 | * Author: Liam Girdwood
|
| 6 | * Created: Aug 11th 2005
|
| 7 | * Copyright: Wolfson Microelectronics. PLC.
|
| 8 |
|
| 9 |
|
| 10 | #ifndef __LINUX_SND_SOC_H
|
| 11 | #define __LINUX_SND_SOC_H
|
| 12 |
|
| 13 | #include <linux/args.h>
|
| 14 | #include <linux/array_size.h>
|
| 15 | #include <linux/device.h>
|
| 16 | #include <linux/errno.h>
|
| 17 | #include <linux/interrupt.h>
|
| 18 | #include <linux/lockdep.h>
|
| 19 | #include <linux/log2.h>
|
| 20 | #include <linux/mutex.h>
|
| 21 | #include <linux/notifier.h>
|
| 22 | #include <linux/of.h>
|
| 23 | #include <linux/types.h>
|
| 24 | #include <linux/workqueue.h>
|
| 25 |
|
| 26 | #include <sound/ac97_codec.h>
|
| 27 | #include <sound/compress_driver.h>
|
| 28 | #include <sound/control.h>
|
| 29 | #include <sound/core.h>
|
| 30 | #include <sound/pcm.h>
|
| 31 |
|
| 32 | struct module;
|
| 33 | struct platform_device;
|
| 34 |
|
| 35 |
|
| 36 | #include <linux/platform_device.h>
|
| 37 | #include <linux/regmap.h>
|
| 38 |
|
| 39 | |
| 40 | * Convenience kcontrol builders
|
| 41 |
|
| 42 | #define SOC_DOUBLE_S_VALUE(xreg, shift_left, shift_right, xmin, xmax, xsign_bit, \
|
| 43 | xinvert, xautodisable) \
|
| 44 | ((unsigned long)&(struct soc_mixer_control) \
|
| 45 | {.reg = xreg, .rreg = xreg, .shift = shift_left, \
|
| 46 | .rshift = shift_right, .min = xmin, .max = xmax, \
|
| 47 | .sign_bit = xsign_bit, .invert = xinvert, .autodisable = xautodisable})
|
| 48 | #define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmin, xmax, xinvert, xautodisable) \
|
| 49 | SOC_DOUBLE_S_VALUE(xreg, shift_left, shift_right, xmin, xmax, 0, xinvert, \
|
| 50 | xautodisable)
|
| 51 | #define SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, xautodisable) \
|
| 52 | SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmin, xmax, xinvert, xautodisable)
|
| 53 | #define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
|
| 54 | ((unsigned long)&(struct soc_mixer_control) \
|
| 55 | {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
|
| 56 | .max = xmax, .min = xmin, .sign_bit = xsign_bit, \
|
| 57 | .invert = xinvert})
|
| 58 | #define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
|
| 59 | SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, 0, xinvert)
|
| 60 |
|
| 61 | #define SOC_SINGLE(xname, reg, shift, max, invert) \
|
| 62 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 63 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
|
| 64 | .put = snd_soc_put_volsw, \
|
| 65 | .private_value = SOC_SINGLE_VALUE(reg, shift, 0, max, invert, 0) }
|
| 66 | #define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
|
| 67 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
|
| 68 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
|
| 69 | .put = snd_soc_put_volsw, \
|
| 70 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, 0) }
|
| 71 | #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
|
| 72 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 73 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
|
| 74 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
|
| 75 | .tlv.p = (tlv_array), \
|
| 76 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
|
| 77 | .put = snd_soc_put_volsw, \
|
| 78 | .private_value = SOC_SINGLE_VALUE(reg, shift, 0, max, invert, 0) }
|
| 79 | #define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
|
| 80 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 81 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
|
| 82 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \
|
| 83 | .tlv.p = (tlv_array),\
|
| 84 | .info = snd_soc_info_volsw_sx, \
|
| 85 | .get = snd_soc_get_volsw_sx,\
|
| 86 | .put = snd_soc_put_volsw_sx, \
|
| 87 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, 0, 0) }
|
| 88 | #define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \
|
| 89 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
|
| 90 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
|
| 91 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
|
| 92 | .tlv.p = (tlv_array), \
|
| 93 | .info = snd_soc_info_volsw, \
|
| 94 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
|
| 95 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, 0) }
|
| 96 | #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
|
| 97 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
|
| 98 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
|
| 99 | .put = snd_soc_put_volsw, \
|
| 100 | .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
|
| 101 | 0, max, invert, 0) }
|
| 102 | #define SOC_DOUBLE_STS(xname, reg, shift_left, shift_right, max, invert) \
|
| 103 | { \
|
| 104 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
|
| 105 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
|
| 106 | .access = SNDRV_CTL_ELEM_ACCESS_READ | \
|
| 107 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
|
| 108 | .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
|
| 109 | 0, max, invert, 0) }
|
| 110 | #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
|
| 111 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
|
| 112 | .info = snd_soc_info_volsw, \
|
| 113 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
|
| 114 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
|
| 115 | 0, xmax, xinvert) }
|
| 116 | #define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \
|
| 117 | xmax, xinvert) \
|
| 118 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
|
| 119 | .info = snd_soc_info_volsw, \
|
| 120 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
|
| 121 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, \
|
| 122 | xshift, xmin, xmax, xinvert) }
|
| 123 | #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
|
| 124 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
|
| 125 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
|
| 126 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
|
| 127 | .tlv.p = (tlv_array), \
|
| 128 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
|
| 129 | .put = snd_soc_put_volsw, \
|
| 130 | .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
|
| 131 | 0, max, invert, 0) }
|
| 132 | #define SOC_DOUBLE_SX_TLV(xname, xreg, shift_left, shift_right, xmin, xmax, tlv_array) \
|
| 133 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
|
| 134 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
|
| 135 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \
|
| 136 | .tlv.p = (tlv_array), \
|
| 137 | .info = snd_soc_info_volsw_sx, \
|
| 138 | .get = snd_soc_get_volsw_sx, \
|
| 139 | .put = snd_soc_put_volsw_sx, \
|
| 140 | .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
|
| 141 | xmin, xmax, 0, 0) }
|
| 142 | #define SOC_DOUBLE_RANGE_TLV(xname, xreg, xshift_left, xshift_right, xmin, xmax, \
|
| 143 | xinvert, tlv_array) \
|
| 144 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
|
| 145 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
|
| 146 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
|
| 147 | .tlv.p = (tlv_array), \
|
| 148 | .info = snd_soc_info_volsw, \
|
| 149 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
|
| 150 | .private_value = SOC_DOUBLE_VALUE(xreg, xshift_left, xshift_right, \
|
| 151 | xmin, xmax, xinvert, 0) }
|
| 152 | #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
|
| 153 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
|
| 154 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
|
| 155 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
|
| 156 | .tlv.p = (tlv_array), \
|
| 157 | .info = snd_soc_info_volsw, \
|
| 158 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
|
| 159 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
|
| 160 | 0, xmax, xinvert) }
|
| 161 | #define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \
|
| 162 | xmax, xinvert, tlv_array) \
|
| 163 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
|
| 164 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
|
| 165 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
|
| 166 | .tlv.p = (tlv_array), \
|
| 167 | .info = snd_soc_info_volsw, \
|
| 168 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
|
| 169 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, \
|
| 170 | xshift, xmin, xmax, xinvert) }
|
| 171 | #define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
|
| 172 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
|
| 173 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
|
| 174 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \
|
| 175 | .tlv.p = (tlv_array), \
|
| 176 | .info = snd_soc_info_volsw_sx, \
|
| 177 | .get = snd_soc_get_volsw_sx, \
|
| 178 | .put = snd_soc_put_volsw_sx, \
|
| 179 | .private_value = SOC_DOUBLE_R_VALUE(xreg, xrreg, xshift, xmin, xmax, 0) }
|
| 180 | #define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
|
| 181 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
|
| 182 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
|
| 183 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
|
| 184 | .tlv.p = (tlv_array), \
|
| 185 | .info = snd_soc_info_volsw, \
|
| 186 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
|
| 187 | .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
|
| 188 | xmin, xmax, xsign_bit, xinvert) }
|
| 189 | #define SOC_SINGLE_S_TLV(xname, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
|
| 190 | SOC_DOUBLE_R_S_TLV(xname, xreg, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array)
|
| 191 | #define SOC_SINGLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
|
| 192 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
|
| 193 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
|
| 194 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \
|
| 195 | .tlv.p = (tlv_array), \
|
| 196 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
|
| 197 | .put = snd_soc_put_volsw, \
|
| 198 | .private_value = (unsigned long)&(struct soc_mixer_control) \
|
| 199 | {.reg = xreg, .rreg = xreg, \
|
| 200 | .min = xmin, .max = xmax, \
|
| 201 | .sign_bit = 7,} }
|
| 202 | #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
|
| 203 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
|
| 204 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
|
| 205 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \
|
| 206 | .tlv.p = (tlv_array), \
|
| 207 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
|
| 208 | .put = snd_soc_put_volsw, \
|
| 209 | .private_value = SOC_DOUBLE_S_VALUE(xreg, 0, 8, xmin, xmax, 7, 0, 0) }
|
| 210 | #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
|
| 211 | { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
|
| 212 | .items = xitems, .texts = xtexts, \
|
| 213 | .mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
|
| 214 | #define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
|
| 215 | SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
|
| 216 | #define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
|
| 217 | { .items = xitems, .texts = xtexts }
|
| 218 | #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
|
| 219 | { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
|
| 220 | .mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
|
| 221 | #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
|
| 222 | SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xitems, xtexts, xvalues)
|
| 223 | #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
|
| 224 | { .reg = xreg, .shift_l = xshift, .shift_r = xshift, \
|
| 225 | .mask = xmask, .items = xitems, .texts = xtexts, \
|
| 226 | .values = xvalues, .autodisable = 1}
|
| 227 | #define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
|
| 228 | SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
|
| 229 | #define SOC_ENUM(xname, xenum) \
|
| 230 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
|
| 231 | .info = snd_soc_info_enum_double, \
|
| 232 | .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
|
| 233 | .private_value = (unsigned long)&xenum }
|
| 234 | #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
|
| 235 | xhandler_get, xhandler_put) \
|
| 236 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 237 | .info = snd_soc_info_volsw, \
|
| 238 | .get = xhandler_get, .put = xhandler_put, \
|
| 239 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, 0, xmax, xinvert, 0) }
|
| 240 | #define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
|
| 241 | xhandler_get, xhandler_put) \
|
| 242 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
|
| 243 | .info = snd_soc_info_volsw, \
|
| 244 | .get = xhandler_get, .put = xhandler_put, \
|
| 245 | .private_value = \
|
| 246 | SOC_DOUBLE_VALUE(reg, shift_left, shift_right, 0, max, invert, 0) }
|
| 247 | #define SOC_DOUBLE_R_EXT(xname, reg_left, reg_right, xshift, xmax, xinvert,\
|
| 248 | xhandler_get, xhandler_put) \
|
| 249 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
|
| 250 | .info = snd_soc_info_volsw, \
|
| 251 | .get = xhandler_get, .put = xhandler_put, \
|
| 252 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
|
| 253 | 0, xmax, xinvert) }
|
| 254 | #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
|
| 255 | xhandler_get, xhandler_put, tlv_array) \
|
| 256 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 257 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
|
| 258 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
|
| 259 | .tlv.p = (tlv_array), \
|
| 260 | .info = snd_soc_info_volsw, \
|
| 261 | .get = xhandler_get, .put = xhandler_put, \
|
| 262 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, 0, xmax, xinvert, 0) }
|
| 263 | #define SOC_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
|
| 264 | xhandler_get, xhandler_put, tlv_array) \
|
| 265 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
|
| 266 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
|
| 267 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
|
| 268 | .tlv.p = (tlv_array), \
|
| 269 | .info = snd_soc_info_volsw, \
|
| 270 | .get = xhandler_get, .put = xhandler_put, \
|
| 271 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, 0) }
|
| 272 | #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
|
| 273 | xhandler_get, xhandler_put, tlv_array) \
|
| 274 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
|
| 275 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
|
| 276 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \
|
| 277 | .tlv.p = (tlv_array), \
|
| 278 | .info = snd_soc_info_volsw, \
|
| 279 | .get = xhandler_get, .put = xhandler_put, \
|
| 280 | .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
|
| 281 | 0, xmax, xinvert, 0) }
|
| 282 | #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
|
| 283 | xhandler_get, xhandler_put, tlv_array) \
|
| 284 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
|
| 285 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
|
| 286 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \
|
| 287 | .tlv.p = (tlv_array), \
|
| 288 | .info = snd_soc_info_volsw, \
|
| 289 | .get = xhandler_get, .put = xhandler_put, \
|
| 290 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
|
| 291 | 0, xmax, xinvert) }
|
| 292 | #define SOC_DOUBLE_R_S_EXT_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, \
|
| 293 | xsign_bit, xinvert, xhandler_get, xhandler_put, \
|
| 294 | tlv_array) \
|
| 295 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
|
| 296 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
|
| 297 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \
|
| 298 | .tlv.p = (tlv_array), \
|
| 299 | .info = snd_soc_info_volsw, \
|
| 300 | .get = xhandler_get, .put = xhandler_put, \
|
| 301 | .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
|
| 302 | xmin, xmax, xsign_bit, xinvert) }
|
| 303 | #define SOC_SINGLE_S_EXT_TLV(xname, xreg, xshift, xmin, xmax, \
|
| 304 | xsign_bit, xinvert, xhandler_get, xhandler_put, \
|
| 305 | tlv_array) \
|
| 306 | SOC_DOUBLE_R_S_EXT_TLV(xname, xreg, xreg, xshift, xmin, xmax, \
|
| 307 | xsign_bit, xinvert, xhandler_get, xhandler_put, \
|
| 308 | tlv_array)
|
| 309 | #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
|
| 310 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 311 | .info = snd_soc_info_bool_ext, \
|
| 312 | .get = xhandler_get, .put = xhandler_put, \
|
| 313 | .private_value = xdata }
|
| 314 | #define SOC_SINGLE_BOOL_EXT_ACC(xname, xdata, xhandler_get, xhandler_put, xaccess) \
|
| 315 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 316 | .access = xaccess, \
|
| 317 | .info = snd_soc_info_bool_ext, \
|
| 318 | .get = xhandler_get, .put = xhandler_put, \
|
| 319 | .private_value = xdata }
|
| 320 | #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
|
| 321 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 322 | .info = snd_soc_info_enum_double, \
|
| 323 | .get = xhandler_get, .put = xhandler_put, \
|
| 324 | .private_value = (unsigned long)&xenum }
|
| 325 | #define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
|
| 326 | SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put)
|
| 327 |
|
| 328 | #define SOC_ENUM_EXT_ACC(xname, xenum, xhandler_get, xhandler_put, xaccess) \
|
| 329 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 330 | .access = xaccess, \
|
| 331 | .info = snd_soc_info_enum_double, \
|
| 332 | .get = xhandler_get, .put = xhandler_put, \
|
| 333 | .private_value = (unsigned long)&xenum }
|
| 334 |
|
| 335 | #define SND_SOC_BYTES(xname, xbase, xregs) \
|
| 336 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 337 | .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
|
| 338 | .put = snd_soc_bytes_put, .private_value = \
|
| 339 | ((unsigned long)&(struct soc_bytes) \
|
| 340 | {.base = xbase, .num_regs = xregs }) }
|
| 341 | #define SND_SOC_BYTES_E(xname, xbase, xregs, xhandler_get, xhandler_put) \
|
| 342 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 343 | .info = snd_soc_bytes_info, .get = xhandler_get, \
|
| 344 | .put = xhandler_put, .private_value = \
|
| 345 | ((unsigned long)&(struct soc_bytes) \
|
| 346 | {.base = xbase, .num_regs = xregs }) }
|
| 347 | #define SND_SOC_BYTES_E_ACC(xname, xbase, xregs, xhandler_get, xhandler_put, xaccess) \
|
| 348 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 349 | .access = xaccess, \
|
| 350 | .info = snd_soc_bytes_info, .get = xhandler_get, \
|
| 351 | .put = xhandler_put, .private_value = \
|
| 352 | ((unsigned long)&(struct soc_bytes) \
|
| 353 | {.base = xbase, .num_regs = xregs }) }
|
| 354 |
|
| 355 | #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask) \
|
| 356 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 357 | .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
|
| 358 | .put = snd_soc_bytes_put, .private_value = \
|
| 359 | ((unsigned long)&(struct soc_bytes) \
|
| 360 | {.base = xbase, .num_regs = xregs, \
|
| 361 | .mask = xmask }) }
|
| 362 |
|
| 363 | |
| 364 | * SND_SOC_BYTES_EXT is deprecated, please USE SND_SOC_BYTES_TLV instead
|
| 365 |
|
| 366 | #define SND_SOC_BYTES_EXT(xname, xcount, xhandler_get, xhandler_put) \
|
| 367 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 368 | .info = snd_soc_bytes_info_ext, \
|
| 369 | .get = xhandler_get, .put = xhandler_put, \
|
| 370 | .private_value = (unsigned long)&(struct soc_bytes_ext) \
|
| 371 | {.max = xcount} }
|
| 372 | #define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \
|
| 373 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
|
| 374 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \
|
| 375 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
|
| 376 | .tlv.c = (snd_soc_bytes_tlv_callback), \
|
| 377 | .info = snd_soc_bytes_info_ext, \
|
| 378 | .private_value = (unsigned long)&(struct soc_bytes_ext) \
|
| 379 | {.max = xcount, .get = xhandler_get, .put = xhandler_put, } }
|
| 380 | #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
|
| 381 | xmin, xmax, xinvert) \
|
| 382 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
|
| 383 | .info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
|
| 384 | .put = snd_soc_put_xr_sx, \
|
| 385 | .private_value = (unsigned long)&(struct soc_mreg_control) \
|
| 386 | {.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
|
| 387 | .invert = xinvert, .min = xmin, .max = xmax} }
|
| 388 |
|
| 389 | #define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
|
| 390 | SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
|
| 391 | snd_soc_get_strobe, snd_soc_put_strobe)
|
| 392 |
|
| 393 | |
| 394 | * Simplified versions of above macros, declaring a struct and calculating
|
| 395 | * ARRAY_SIZE internally
|
| 396 |
|
| 397 | #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
|
| 398 | const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
|
| 399 | ARRAY_SIZE(xtexts), xtexts)
|
| 400 | #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
|
| 401 | SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
|
| 402 | #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
|
| 403 | const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
|
| 404 | #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
|
| 405 | const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
|
| 406 | ARRAY_SIZE(xtexts), xtexts, xvalues)
|
| 407 | #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
|
| 408 | SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
|
| 409 |
|
| 410 | #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
|
| 411 | const struct soc_enum name = SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, \
|
| 412 | xshift, xmask, ARRAY_SIZE(xtexts), xtexts, xvalues)
|
| 413 |
|
| 414 | #define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
|
| 415 | const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
|
| 416 |
|
| 417 | struct snd_soc_card;
|
| 418 | struct snd_soc_pcm_runtime;
|
| 419 | struct snd_soc_dai;
|
| 420 | struct snd_soc_dai_driver;
|
| 421 | struct snd_soc_dai_link;
|
| 422 | struct snd_soc_component;
|
| 423 | struct snd_soc_component_driver;
|
| 424 | struct snd_soc_jack;
|
| 425 | struct snd_soc_jack_pin;
|
| 426 |
|
| 427 | #include <sound/soc-dapm.h>
|
| 428 | #include <sound/soc-dpcm.h>
|
| 429 | #include <sound/soc-topology.h>
|
| 430 |
|
| 431 | int snd_soc_register_card(struct snd_soc_card *card);
|
| 432 | void snd_soc_unregister_card(struct snd_soc_card *card);
|
| 433 | int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
|
| 434 | #define devm_snd_soc_register_deferrable_card(d, c) devm_snd_soc_register_card(d, c)
|
| 435 | #ifdef CONFIG_PM_SLEEP
|
| 436 | int snd_soc_suspend(struct device *dev);
|
| 437 | int snd_soc_resume(struct device *dev);
|
| 438 | #else
|
| 439 | static inline int snd_soc_suspend(struct device *dev)
|
| 440 | {
|
| 441 | return 0;
|
| 442 | }
|
| 443 |
|
| 444 | static inline int snd_soc_resume(struct device *dev)
|
| 445 | {
|
| 446 | return 0;
|
| 447 | }
|
| 448 | #endif
|
| 449 | int snd_soc_poweroff(struct device *dev);
|
| 450 | int snd_soc_register_component_c(struct snd_soc_component *component,
|
| 451 | const struct snd_soc_component_driver *component_driver,
|
| 452 | struct snd_soc_dai_driver *dai_drv, int num_dai);
|
| 453 | int snd_soc_register_component_d(struct device *dev,
|
| 454 | const struct snd_soc_component_driver *component_driver,
|
| 455 | struct snd_soc_dai_driver *dai_drv, int num_dai);
|
| 456 | #define snd_soc_register_component(x, ...) _Generic((x), \
|
| 457 | struct device * : snd_soc_register_component_d, \
|
| 458 | struct snd_soc_component * : snd_soc_register_component_c)(x, __VA_ARGS__)
|
| 459 |
|
| 460 | int devm_snd_soc_register_component(struct device *dev,
|
| 461 | const struct snd_soc_component_driver *component_driver,
|
| 462 | struct snd_soc_dai_driver *dai_drv, int num_dai);
|
| 463 | #define snd_soc_unregister_component(dev) snd_soc_unregister_component_by_driver(dev, NULL)
|
| 464 | void snd_soc_unregister_component_by_driver(struct device *dev,
|
| 465 | const struct snd_soc_component_driver *component_driver);
|
| 466 | struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
|
| 467 | const char *driver_name);
|
| 468 | struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
|
| 469 | const char *driver_name);
|
| 470 | struct snd_soc_component *snd_soc_lookup_component_by_name(const char *component_name);
|
| 471 |
|
| 472 | int soc_new_pcm(struct snd_soc_pcm_runtime *rtd);
|
| 473 | #ifdef CONFIG_SND_SOC_COMPRESS
|
| 474 | int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd);
|
| 475 | #else
|
| 476 | static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd)
|
| 477 | {
|
| 478 | return 0;
|
| 479 | }
|
| 480 | #endif
|
| 481 |
|
| 482 | struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
|
| 483 | struct snd_soc_dai_link *dai_link);
|
| 484 |
|
| 485 | bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
|
| 486 |
|
| 487 | void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
|
| 488 | int stream, int action);
|
| 489 | static inline void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd,
|
| 490 | int stream)
|
| 491 | {
|
| 492 | snd_soc_runtime_action(rtd, stream, 1);
|
| 493 | }
|
| 494 | static inline void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd,
|
| 495 | int stream)
|
| 496 | {
|
| 497 | snd_soc_runtime_action(rtd, stream, -1);
|
| 498 | }
|
| 499 |
|
| 500 | int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
|
| 501 | struct snd_pcm_hardware *hw, int stream);
|
| 502 |
|
| 503 | int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
|
| 504 | unsigned int dai_fmt);
|
| 505 |
|
| 506 |
|
| 507 | int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
|
| 508 | int snd_soc_params_to_frame_size(const struct snd_pcm_hw_params *params);
|
| 509 | int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
|
| 510 | int snd_soc_params_to_bclk(const struct snd_pcm_hw_params *parms);
|
| 511 | int snd_soc_tdm_params_to_bclk(const struct snd_pcm_hw_params *params,
|
| 512 | int tdm_width, int tdm_slots, int slot_multiple);
|
| 513 | int snd_soc_ret(const struct device *dev, int ret, const char *fmt, ...);
|
| 514 |
|
| 515 |
|
| 516 | static inline int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
|
| 517 | const struct snd_pcm_hardware *hw)
|
| 518 | {
|
| 519 | substream->runtime->hw = *hw;
|
| 520 |
|
| 521 | return 0;
|
| 522 | }
|
| 523 |
|
| 524 | struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
|
| 525 | struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
|
| 526 | unsigned int id, unsigned int id_mask);
|
| 527 | void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
|
| 528 |
|
| 529 | #ifdef CONFIG_SND_SOC_AC97_BUS
|
| 530 | int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
|
| 531 | int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
|
| 532 | struct platform_device *pdev);
|
| 533 |
|
| 534 | extern struct snd_ac97_bus_ops *soc_ac97_ops;
|
| 535 | #else
|
| 536 | static inline int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
|
| 537 | struct platform_device *pdev)
|
| 538 | {
|
| 539 | return 0;
|
| 540 | }
|
| 541 |
|
| 542 | static inline int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
|
| 543 | {
|
| 544 | return 0;
|
| 545 | }
|
| 546 | #endif
|
| 547 |
|
| 548 | |
| 549 | *Controls
|
| 550 |
|
| 551 | struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
|
| 552 | void *data, const char *long_name,
|
| 553 | const char *prefix);
|
| 554 | int snd_soc_add_component_controls(struct snd_soc_component *component,
|
| 555 | const struct snd_kcontrol_new *controls, unsigned int num_controls);
|
| 556 | int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
|
| 557 | const struct snd_kcontrol_new *controls, int num_controls);
|
| 558 | int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
|
| 559 | const struct snd_kcontrol_new *controls, int num_controls);
|
| 560 | int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
|
| 561 | struct snd_ctl_elem_info *uinfo);
|
| 562 | int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
|
| 563 | struct snd_ctl_elem_value *ucontrol);
|
| 564 | int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
|
| 565 | struct snd_ctl_elem_value *ucontrol);
|
| 566 | int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
|
| 567 | struct snd_ctl_elem_info *uinfo);
|
| 568 | int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
|
| 569 | struct snd_ctl_elem_info *uinfo);
|
| 570 | #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
|
| 571 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
|
| 572 | struct snd_ctl_elem_value *ucontrol);
|
| 573 | int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
|
| 574 | struct snd_ctl_elem_value *ucontrol);
|
| 575 | #define snd_soc_get_volsw_2r snd_soc_get_volsw
|
| 576 | #define snd_soc_put_volsw_2r snd_soc_put_volsw
|
| 577 | int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
|
| 578 | struct snd_ctl_elem_value *ucontrol);
|
| 579 | int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
|
| 580 | struct snd_ctl_elem_value *ucontrol);
|
| 581 | int snd_soc_limit_volume(struct snd_soc_card *card,
|
| 582 | const char *name, int max);
|
| 583 | int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
|
| 584 | struct snd_ctl_elem_info *uinfo);
|
| 585 | int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
|
| 586 | struct snd_ctl_elem_value *ucontrol);
|
| 587 | int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
|
| 588 | struct snd_ctl_elem_value *ucontrol);
|
| 589 | int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
|
| 590 | struct snd_ctl_elem_info *ucontrol);
|
| 591 | int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
|
| 592 | unsigned int size, unsigned int __user *tlv);
|
| 593 | int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
|
| 594 | struct snd_ctl_elem_info *uinfo);
|
| 595 | int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
|
| 596 | struct snd_ctl_elem_value *ucontrol);
|
| 597 | int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
|
| 598 | struct snd_ctl_elem_value *ucontrol);
|
| 599 | int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
|
| 600 | struct snd_ctl_elem_value *ucontrol);
|
| 601 | int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
|
| 602 | struct snd_ctl_elem_value *ucontrol);
|
| 603 |
|
| 604 | enum snd_soc_trigger_order {
|
| 605 |
|
| 606 | SND_SOC_TRIGGER_ORDER_DEFAULT = 0,
|
| 607 | SND_SOC_TRIGGER_ORDER_LDC,
|
| 608 |
|
| 609 | SND_SOC_TRIGGER_ORDER_MAX,
|
| 610 | };
|
| 611 |
|
| 612 |
|
| 613 | struct snd_soc_pcm_stream {
|
| 614 | const char *stream_name;
|
| 615 | u64 formats;
|
| 616 | u32 subformats;
|
| 617 | unsigned int rates;
|
| 618 | unsigned int rate_min;
|
| 619 | unsigned int rate_max;
|
| 620 | unsigned int channels_min;
|
| 621 | unsigned int channels_max;
|
| 622 | unsigned int sig_bits;
|
| 623 | };
|
| 624 |
|
| 625 |
|
| 626 | struct snd_soc_ops {
|
| 627 | int (*startup)(struct snd_pcm_substream *);
|
| 628 | void (*shutdown)(struct snd_pcm_substream *);
|
| 629 | int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
|
| 630 | int (*hw_free)(struct snd_pcm_substream *);
|
| 631 | int (*prepare)(struct snd_pcm_substream *);
|
| 632 | int (*trigger)(struct snd_pcm_substream *, int);
|
| 633 | };
|
| 634 |
|
| 635 | struct snd_soc_compr_ops {
|
| 636 | int (*startup)(struct snd_compr_stream *);
|
| 637 | void (*shutdown)(struct snd_compr_stream *);
|
| 638 | int (*set_params)(struct snd_compr_stream *);
|
| 639 | };
|
| 640 |
|
| 641 | struct snd_soc_component*
|
| 642 | snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
|
| 643 | const char *driver_name);
|
| 644 |
|
| 645 | struct snd_soc_dai_link_component {
|
| 646 | const char *name;
|
| 647 | struct device_node *of_node;
|
| 648 | const char *dai_name;
|
| 649 | const struct of_phandle_args *dai_args;
|
| 650 |
|
| 651 | |
| 652 | * Extra format = SND_SOC_DAIFMT_Bx_Fx
|
| 653 | *
|
| 654 | * [Note] it is Bx_Fx base, not CBx_CFx
|
| 655 | *
|
| 656 | * It will be used with dai_link->dai_fmt
|
| 657 | * see
|
| 658 | * snd_soc_runtime_set_dai_fmt()
|
| 659 |
|
| 660 | unsigned int ext_fmt;
|
| 661 | };
|
| 662 |
|
| 663 | |
| 664 | * [dai_link->ch_maps Image sample]
|
| 665 | *
|
| 666 | *-------------------------
|
| 667 | * CPU0 <---> Codec0
|
| 668 | *
|
| 669 | * ch-map[0].cpu = 0 ch-map[0].codec = 0
|
| 670 | *
|
| 671 | *-------------------------
|
| 672 | * CPU0 <---> Codec0
|
| 673 | * CPU1 <---> Codec1
|
| 674 | * CPU2 <---> Codec2
|
| 675 | *
|
| 676 | * ch-map[0].cpu = 0 ch-map[0].codec = 0
|
| 677 | * ch-map[1].cpu = 1 ch-map[1].codec = 1
|
| 678 | * ch-map[2].cpu = 2 ch-map[2].codec = 2
|
| 679 | *
|
| 680 | *-------------------------
|
| 681 | * CPU0 <---> Codec0
|
| 682 | * CPU1 <-+-> Codec1
|
| 683 | * CPU2 <-/
|
| 684 | *
|
| 685 | * ch-map[0].cpu = 0 ch-map[0].codec = 0
|
| 686 | * ch-map[1].cpu = 1 ch-map[1].codec = 1
|
| 687 | * ch-map[2].cpu = 2 ch-map[2].codec = 1
|
| 688 | *
|
| 689 | *-------------------------
|
| 690 | * CPU0 <---> Codec0
|
| 691 | * CPU1 <-+-> Codec1
|
| 692 | * \-> Codec2
|
| 693 | *
|
| 694 | * ch-map[0].cpu = 0 ch-map[0].codec = 0
|
| 695 | * ch-map[1].cpu = 1 ch-map[1].codec = 1
|
| 696 | * ch-map[2].cpu = 1 ch-map[2].codec = 2
|
| 697 | *
|
| 698 |
|
| 699 | struct snd_soc_dai_link_ch_map {
|
| 700 | unsigned int cpu;
|
| 701 | unsigned int codec;
|
| 702 | unsigned int cpu_ch_mask;
|
| 703 | unsigned int codec_ch_mask;
|
| 704 | };
|
| 705 |
|
| 706 | struct snd_soc_dai_link {
|
| 707 |
|
| 708 | const char *name;
|
| 709 | const char *stream_name;
|
| 710 |
|
| 711 | |
| 712 | * You MAY specify the link's CPU-side device, either by device name,
|
| 713 | * or by DT/OF node, but not both. If this information is omitted,
|
| 714 | * the CPU-side DAI is matched using .cpu_dai_name only, which hence
|
| 715 | * must be globally unique. These fields are currently typically used
|
| 716 | * only for codec to codec links, or systems using device tree.
|
| 717 |
|
| 718 | |
| 719 | * You MAY specify the DAI name of the CPU DAI. If this information is
|
| 720 | * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
|
| 721 | * only, which only works well when that device exposes a single DAI.
|
| 722 |
|
| 723 | struct snd_soc_dai_link_component *cpus;
|
| 724 | unsigned int num_cpus;
|
| 725 |
|
| 726 | |
| 727 | * You MUST specify the link's codec, either by device name, or by
|
| 728 | * DT/OF node, but not both.
|
| 729 |
|
| 730 |
|
| 731 | struct snd_soc_dai_link_component *codecs;
|
| 732 | unsigned int num_codecs;
|
| 733 |
|
| 734 |
|
| 735 | struct snd_soc_dai_link_ch_map *ch_maps;
|
| 736 |
|
| 737 | |
| 738 | * You MAY specify the link's platform/PCM/DMA driver, either by
|
| 739 | * device name, or by DT/OF node, but not both. Some forms of link
|
| 740 | * do not need a platform. In such case, platforms are not mandatory.
|
| 741 |
|
| 742 | struct snd_soc_dai_link_component *platforms;
|
| 743 | unsigned int num_platforms;
|
| 744 |
|
| 745 | int id;
|
| 746 |
|
| 747 | |
| 748 | * for Codec2Codec
|
| 749 |
|
| 750 | const struct snd_soc_pcm_stream *c2c_params;
|
| 751 | unsigned int num_c2c_params;
|
| 752 |
|
| 753 | unsigned int dai_fmt;
|
| 754 |
|
| 755 | enum snd_soc_dpcm_trigger trigger[2];
|
| 756 |
|
| 757 |
|
| 758 | int (*init)(struct snd_soc_pcm_runtime *rtd);
|
| 759 |
|
| 760 |
|
| 761 | void (*exit)(struct snd_soc_pcm_runtime *rtd);
|
| 762 |
|
| 763 |
|
| 764 | int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
|
| 765 | struct snd_pcm_hw_params *params);
|
| 766 |
|
| 767 |
|
| 768 | const struct snd_soc_ops *ops;
|
| 769 | const struct snd_soc_compr_ops *compr_ops;
|
| 770 |
|
| 771 | |
| 772 | * soc_pcm_trigger() start/stop sequence.
|
| 773 | * see also
|
| 774 | * snd_soc_component_driver
|
| 775 | * soc_pcm_trigger()
|
| 776 |
|
| 777 | enum snd_soc_trigger_order trigger_start;
|
| 778 | enum snd_soc_trigger_order trigger_stop;
|
| 779 |
|
| 780 |
|
| 781 | unsigned int nonatomic:1;
|
| 782 |
|
| 783 |
|
| 784 | unsigned int playback_only:1;
|
| 785 | unsigned int capture_only:1;
|
| 786 |
|
| 787 |
|
| 788 | unsigned int ignore_suspend:1;
|
| 789 |
|
| 790 |
|
| 791 | unsigned int symmetric_rate:1;
|
| 792 | unsigned int symmetric_channels:1;
|
| 793 | unsigned int symmetric_sample_bits:1;
|
| 794 |
|
| 795 |
|
| 796 | unsigned int no_pcm:1;
|
| 797 |
|
| 798 |
|
| 799 | unsigned int dynamic:1;
|
| 800 |
|
| 801 |
|
| 802 | unsigned int dpcm_merged_format:1;
|
| 803 |
|
| 804 | unsigned int dpcm_merged_chan:1;
|
| 805 |
|
| 806 | unsigned int dpcm_merged_rate:1;
|
| 807 |
|
| 808 |
|
| 809 | unsigned int ignore_pmdown_time:1;
|
| 810 |
|
| 811 |
|
| 812 | unsigned int ignore:1;
|
| 813 |
|
| 814 | #ifdef CONFIG_SND_SOC_TOPOLOGY
|
| 815 | struct snd_soc_dobj dobj;
|
| 816 | #endif
|
| 817 | };
|
| 818 |
|
| 819 | static inline int snd_soc_link_num_ch_map(const struct snd_soc_dai_link *link)
|
| 820 | {
|
| 821 | return max(link->num_cpus, link->num_codecs);
|
| 822 | }
|
| 823 |
|
| 824 | static inline struct snd_soc_dai_link_component*
|
| 825 | snd_soc_link_to_cpu(struct snd_soc_dai_link *link, int n) {
|
| 826 | return &(link)->cpus[n];
|
| 827 | }
|
| 828 |
|
| 829 | static inline struct snd_soc_dai_link_component*
|
| 830 | snd_soc_link_to_codec(struct snd_soc_dai_link *link, int n) {
|
| 831 | return &(link)->codecs[n];
|
| 832 | }
|
| 833 |
|
| 834 | static inline struct snd_soc_dai_link_component*
|
| 835 | snd_soc_link_to_platform(struct snd_soc_dai_link *link, int n) {
|
| 836 | return &(link)->platforms[n];
|
| 837 | }
|
| 838 |
|
| 839 | #define for_each_link_codecs(link, i, codec) \
|
| 840 | for ((i) = 0; \
|
| 841 | ((i) < link->num_codecs) && \
|
| 842 | ((codec) = snd_soc_link_to_codec(link, i)); \
|
| 843 | (i)++)
|
| 844 |
|
| 845 | #define for_each_link_platforms(link, i, platform) \
|
| 846 | for ((i) = 0; \
|
| 847 | ((i) < link->num_platforms) && \
|
| 848 | ((platform) = snd_soc_link_to_platform(link, i)); \
|
| 849 | (i)++)
|
| 850 |
|
| 851 | #define for_each_link_cpus(link, i, cpu) \
|
| 852 | for ((i) = 0; \
|
| 853 | ((i) < link->num_cpus) && \
|
| 854 | ((cpu) = snd_soc_link_to_cpu(link, i)); \
|
| 855 | (i)++)
|
| 856 |
|
| 857 | #define for_each_link_ch_maps(link, i, ch_map) \
|
| 858 | for ((i) = 0; \
|
| 859 | ((i) < snd_soc_link_num_ch_map(link) && \
|
| 860 | ((ch_map) = link->ch_maps + i)); \
|
| 861 | (i)++)
|
| 862 |
|
| 863 | |
| 864 | * Sample 1 : Single CPU/Codec/Platform
|
| 865 | *
|
| 866 | * SND_SOC_DAILINK_DEFS(test,
|
| 867 | * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")),
|
| 868 | * DAILINK_COMP_ARRAY(COMP_CODEC("codec", "codec_dai")),
|
| 869 | * DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
|
| 870 | *
|
| 871 | * struct snd_soc_dai_link link = {
|
| 872 | * ...
|
| 873 | * SND_SOC_DAILINK_REG(test),
|
| 874 | * };
|
| 875 | *
|
| 876 | * Sample 2 : Multi CPU/Codec, no Platform
|
| 877 | *
|
| 878 | * SND_SOC_DAILINK_DEFS(test,
|
| 879 | * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
|
| 880 | * COMP_CPU("cpu_dai2")),
|
| 881 | * DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
|
| 882 | * COMP_CODEC("codec2", "codec_dai2")));
|
| 883 | *
|
| 884 | * struct snd_soc_dai_link link = {
|
| 885 | * ...
|
| 886 | * SND_SOC_DAILINK_REG(test),
|
| 887 | * };
|
| 888 | *
|
| 889 | * Sample 3 : Define each CPU/Codec/Platform manually
|
| 890 | *
|
| 891 | * SND_SOC_DAILINK_DEF(test_cpu,
|
| 892 | * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
|
| 893 | * COMP_CPU("cpu_dai2")));
|
| 894 | * SND_SOC_DAILINK_DEF(test_codec,
|
| 895 | * DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
|
| 896 | * COMP_CODEC("codec2", "codec_dai2")));
|
| 897 | * SND_SOC_DAILINK_DEF(test_platform,
|
| 898 | * DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
|
| 899 | *
|
| 900 | * struct snd_soc_dai_link link = {
|
| 901 | * ...
|
| 902 | * SND_SOC_DAILINK_REG(test_cpu,
|
| 903 | * test_codec,
|
| 904 | * test_platform),
|
| 905 | * };
|
| 906 | *
|
| 907 | * Sample 4 : Sample3 without platform
|
| 908 | *
|
| 909 | * struct snd_soc_dai_link link = {
|
| 910 | * ...
|
| 911 | * SND_SOC_DAILINK_REG(test_cpu,
|
| 912 | * test_codec);
|
| 913 | * };
|
| 914 |
|
| 915 |
|
| 916 | #define SND_SOC_DAILINK_REG1(name) SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms)
|
| 917 | #define SND_SOC_DAILINK_REG2(cpu, codec) SND_SOC_DAILINK_REG3(cpu, codec, null_dailink_component)
|
| 918 | #define SND_SOC_DAILINK_REG3(cpu, codec, platform) \
|
| 919 | .cpus = cpu, \
|
| 920 | .num_cpus = ARRAY_SIZE(cpu), \
|
| 921 | .codecs = codec, \
|
| 922 | .num_codecs = ARRAY_SIZE(codec), \
|
| 923 | .platforms = platform, \
|
| 924 | .num_platforms = ARRAY_SIZE(platform)
|
| 925 |
|
| 926 | #define SND_SOC_DAILINK_REG(...) \
|
| 927 | CONCATENATE(SND_SOC_DAILINK_REG, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__)
|
| 928 |
|
| 929 | #define SND_SOC_DAILINK_DEF(name, def...) \
|
| 930 | static struct snd_soc_dai_link_component name[] = { def }
|
| 931 |
|
| 932 | #define SND_SOC_DAILINK_DEFS(name, cpu, codec, platform...) \
|
| 933 | SND_SOC_DAILINK_DEF(name##_cpus, cpu); \
|
| 934 | SND_SOC_DAILINK_DEF(name##_codecs, codec); \
|
| 935 | SND_SOC_DAILINK_DEF(name##_platforms, platform)
|
| 936 |
|
| 937 | #define DAILINK_COMP_ARRAY(param...) param
|
| 938 | #define COMP_EMPTY() { }
|
| 939 | #define COMP_CPU(_dai) { .dai_name = _dai, }
|
| 940 | #define COMP_CODEC(_name, _dai) { .name = _name, .dai_name = _dai, }
|
| 941 | #define COMP_PLATFORM(_name) { .name = _name }
|
| 942 | #define COMP_AUX(_name) { .name = _name }
|
| 943 | #define COMP_CODEC_CONF(_name) { .name = _name }
|
| 944 | #define COMP_DUMMY()
|
| 945 |
|
| 946 | extern struct snd_soc_dai_link_component null_dailink_component[0];
|
| 947 | extern struct snd_soc_dai_link_component snd_soc_dummy_dlc;
|
| 948 | int snd_soc_dlc_is_dummy(struct snd_soc_dai_link_component *dlc);
|
| 949 |
|
| 950 | struct snd_soc_codec_conf {
|
| 951 | |
| 952 | * specify device either by device name, or by
|
| 953 | * DT/OF node, but not both.
|
| 954 |
|
| 955 | struct snd_soc_dai_link_component dlc;
|
| 956 |
|
| 957 | |
| 958 | * optional map of kcontrol, widget and path name prefixes that are
|
| 959 | * associated per device
|
| 960 |
|
| 961 | const char *name_prefix;
|
| 962 | };
|
| 963 |
|
| 964 | struct snd_soc_aux_dev {
|
| 965 | |
| 966 | * specify multi-codec either by device name, or by
|
| 967 | * DT/OF node, but not both.
|
| 968 |
|
| 969 | struct snd_soc_dai_link_component dlc;
|
| 970 |
|
| 971 |
|
| 972 | int (*init)(struct snd_soc_component *component);
|
| 973 | };
|
| 974 |
|
| 975 |
|
| 976 | struct snd_soc_card {
|
| 977 | const char *name;
|
| 978 | const char *long_name;
|
| 979 | const char *driver_name;
|
| 980 | const char *components;
|
| 981 |
|
| 982 | #ifdef CONFIG_PCI
|
| 983 | |
| 984 | * PCI does not define 0 as invalid, so pci_subsystem_set indicates
|
| 985 | * whether a value has been written to these fields.
|
| 986 |
|
| 987 | unsigned short pci_subsystem_vendor;
|
| 988 | unsigned short pci_subsystem_device;
|
| 989 | bool pci_subsystem_set;
|
| 990 | #endif
|
| 991 |
|
| 992 | char *topology_shortname;
|
| 993 |
|
| 994 | struct device *dev;
|
| 995 | struct snd_card *snd_card;
|
| 996 | struct module *owner;
|
| 997 |
|
| 998 | struct mutex mutex;
|
| 999 | struct mutex dapm_mutex;
|
| 1000 |
|
| 1001 |
|
| 1002 | struct mutex pcm_mutex;
|
| 1003 |
|
| 1004 | int (*probe)(struct snd_soc_card *card);
|
| 1005 | int (*late_probe)(struct snd_soc_card *card);
|
| 1006 | void (*fixup_controls)(struct snd_soc_card *card);
|
| 1007 | int (*remove)(struct snd_soc_card *card);
|
| 1008 |
|
| 1009 | |
| 1010 | * after the codec and DAI's do any PM work.
|
| 1011 | int (*suspend_pre)(struct snd_soc_card *card);
|
| 1012 | int (*suspend_post)(struct snd_soc_card *card);
|
| 1013 | int (*resume_pre)(struct snd_soc_card *card);
|
| 1014 | int (*resume_post)(struct snd_soc_card *card);
|
| 1015 |
|
| 1016 |
|
| 1017 | int (*set_bias_level)(struct snd_soc_card *,
|
| 1018 | struct snd_soc_dapm_context *dapm,
|
| 1019 | enum snd_soc_bias_level level);
|
| 1020 | int (*set_bias_level_post)(struct snd_soc_card *,
|
| 1021 | struct snd_soc_dapm_context *dapm,
|
| 1022 | enum snd_soc_bias_level level);
|
| 1023 |
|
| 1024 | int (*add_dai_link)(struct snd_soc_card *,
|
| 1025 | struct snd_soc_dai_link *link);
|
| 1026 | void (*remove_dai_link)(struct snd_soc_card *,
|
| 1027 | struct snd_soc_dai_link *link);
|
| 1028 |
|
| 1029 |
|
| 1030 | struct snd_soc_dai_link *dai_link;
|
| 1031 | int num_links;
|
| 1032 |
|
| 1033 | struct list_head rtd_list;
|
| 1034 | int num_rtd;
|
| 1035 |
|
| 1036 |
|
| 1037 | struct snd_soc_codec_conf *codec_conf;
|
| 1038 | int num_configs;
|
| 1039 |
|
| 1040 | |
| 1041 | * optional auxiliary devices such as amplifiers or codecs with DAI
|
| 1042 | * link unused
|
| 1043 |
|
| 1044 | struct snd_soc_aux_dev *aux_dev;
|
| 1045 | int num_aux_devs;
|
| 1046 | struct list_head aux_comp_list;
|
| 1047 |
|
| 1048 | const struct snd_kcontrol_new *controls;
|
| 1049 | int num_controls;
|
| 1050 |
|
| 1051 | |
| 1052 | * Card-specific routes and widgets.
|
| 1053 | * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
|
| 1054 |
|
| 1055 | const struct snd_soc_dapm_widget *dapm_widgets;
|
| 1056 | int num_dapm_widgets;
|
| 1057 | const struct snd_soc_dapm_route *dapm_routes;
|
| 1058 | int num_dapm_routes;
|
| 1059 | const char **ignore_suspend_widgets;
|
| 1060 | int num_ignore_suspend_widgets;
|
| 1061 | const struct snd_soc_dapm_widget *of_dapm_widgets;
|
| 1062 | int num_of_dapm_widgets;
|
| 1063 | const struct snd_soc_dapm_route *of_dapm_routes;
|
| 1064 | int num_of_dapm_routes;
|
| 1065 | const char **of_ignore_suspend_widgets;
|
| 1066 | int num_of_ignore_suspend_widgets;
|
| 1067 |
|
| 1068 |
|
| 1069 | struct list_head component_dev_list;
|
| 1070 | struct list_head list;
|
| 1071 |
|
| 1072 | struct list_head widgets;
|
| 1073 | struct list_head paths;
|
| 1074 | struct list_head dapm_list;
|
| 1075 | struct list_head dapm_dirty;
|
| 1076 |
|
| 1077 |
|
| 1078 | struct snd_soc_dapm_context *dapm;
|
| 1079 | struct snd_soc_dapm_stats dapm_stats;
|
| 1080 |
|
| 1081 | #ifdef CONFIG_DEBUG_FS
|
| 1082 | struct dentry *debugfs_card_root;
|
| 1083 | #endif
|
| 1084 | #ifdef CONFIG_PM_SLEEP
|
| 1085 | struct work_struct deferred_resume_work;
|
| 1086 | #endif
|
| 1087 |
|
| 1088 | unsigned int instantiated:1;
|
| 1089 | unsigned int fully_routed:1;
|
| 1090 | unsigned int probed:1;
|
| 1091 | unsigned int component_chaining:1;
|
| 1092 | struct device *devres_dev;
|
| 1093 |
|
| 1094 | void *drvdata;
|
| 1095 | };
|
| 1096 | #define for_each_card_prelinks(card, i, link) \
|
| 1097 | for ((i) = 0; \
|
| 1098 | ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
|
| 1099 | (i)++)
|
| 1100 | #define for_each_card_pre_auxs(card, i, aux) \
|
| 1101 | for ((i) = 0; \
|
| 1102 | ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \
|
| 1103 | (i)++)
|
| 1104 |
|
| 1105 | #define for_each_card_rtds(card, rtd) \
|
| 1106 | list_for_each_entry(rtd, &(card)->rtd_list, list)
|
| 1107 | #define for_each_card_rtds_safe(card, rtd, _rtd) \
|
| 1108 | list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list)
|
| 1109 |
|
| 1110 | #define for_each_card_auxs(card, component) \
|
| 1111 | list_for_each_entry(component, &card->aux_comp_list, card_aux_list)
|
| 1112 | #define for_each_card_auxs_safe(card, component, _comp) \
|
| 1113 | list_for_each_entry_safe(component, _comp, \
|
| 1114 | &card->aux_comp_list, card_aux_list)
|
| 1115 |
|
| 1116 | #define for_each_card_components(card, component) \
|
| 1117 | list_for_each_entry(component, &(card)->component_dev_list, card_list)
|
| 1118 |
|
| 1119 | #define for_each_card_dapms(card, dapm) \
|
| 1120 | list_for_each_entry(dapm, &card->dapm_list, list)
|
| 1121 |
|
| 1122 | #define for_each_card_widgets(card, w)\
|
| 1123 | list_for_each_entry(w, &card->widgets, list)
|
| 1124 | #define for_each_card_widgets_safe(card, w, _w) \
|
| 1125 | list_for_each_entry_safe(w, _w, &card->widgets, list)
|
| 1126 |
|
| 1127 |
|
| 1128 | static inline int snd_soc_card_is_instantiated(struct snd_soc_card *card)
|
| 1129 | {
|
| 1130 | return card && card->instantiated;
|
| 1131 | }
|
| 1132 |
|
| 1133 | static inline struct snd_soc_dapm_context *snd_soc_card_to_dapm(struct snd_soc_card *card)
|
| 1134 | {
|
| 1135 | return card->dapm;
|
| 1136 | }
|
| 1137 |
|
| 1138 |
|
| 1139 | struct snd_soc_pcm_runtime {
|
| 1140 | struct device *dev;
|
| 1141 | struct snd_soc_card *card;
|
| 1142 | struct snd_soc_dai_link *dai_link;
|
| 1143 | struct snd_pcm_ops ops;
|
| 1144 |
|
| 1145 | unsigned int c2c_params_select;
|
| 1146 |
|
| 1147 |
|
| 1148 | struct snd_soc_dpcm_runtime dpcm[SNDRV_PCM_STREAM_LAST + 1];
|
| 1149 | struct snd_soc_dapm_widget *c2c_widget[SNDRV_PCM_STREAM_LAST + 1];
|
| 1150 |
|
| 1151 | long pmdown_time;
|
| 1152 |
|
| 1153 |
|
| 1154 | struct snd_pcm *pcm;
|
| 1155 | struct snd_compr *compr;
|
| 1156 |
|
| 1157 | |
| 1158 | * dais = cpu_dai + codec_dai
|
| 1159 | * see
|
| 1160 | * soc_new_pcm_runtime()
|
| 1161 | * snd_soc_rtd_to_cpu()
|
| 1162 | * snd_soc_rtd_to_codec()
|
| 1163 |
|
| 1164 | struct snd_soc_dai **dais;
|
| 1165 |
|
| 1166 | struct delayed_work delayed_work;
|
| 1167 | void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
|
| 1168 | #ifdef CONFIG_DEBUG_FS
|
| 1169 | struct dentry *debugfs_dpcm_root;
|
| 1170 | #endif
|
| 1171 |
|
| 1172 | unsigned int id;
|
| 1173 | struct list_head list;
|
| 1174 |
|
| 1175 |
|
| 1176 | struct snd_pcm_substream *mark_startup;
|
| 1177 | struct snd_pcm_substream *mark_hw_params;
|
| 1178 | struct snd_pcm_substream *mark_trigger;
|
| 1179 | struct snd_compr_stream *mark_compr_startup;
|
| 1180 |
|
| 1181 |
|
| 1182 | unsigned int pop_wait:1;
|
| 1183 | unsigned int fe_compr:1;
|
| 1184 | unsigned int initialized:1;
|
| 1185 |
|
| 1186 |
|
| 1187 | int num_components;
|
| 1188 | struct snd_soc_component *components[] __counted_by(num_components);
|
| 1189 | };
|
| 1190 |
|
| 1191 |
|
| 1192 | #define snd_soc_rtd_to_cpu(rtd, n) (rtd)->dais[n]
|
| 1193 | #define snd_soc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->dai_link->num_cpus]
|
| 1194 |
|
| 1195 | static inline struct snd_soc_pcm_runtime *
|
| 1196 | snd_soc_substream_to_rtd(const struct snd_pcm_substream *substream)
|
| 1197 | {
|
| 1198 | return snd_pcm_substream_chip(substream);
|
| 1199 | }
|
| 1200 |
|
| 1201 | #define for_each_rtd_components(rtd, i, component) \
|
| 1202 | for ((i) = 0, component = NULL; \
|
| 1203 | ((i) < rtd->num_components) && ((component) = rtd->components[i]);\
|
| 1204 | (i)++)
|
| 1205 | #define for_each_rtd_cpu_dais(rtd, i, dai) \
|
| 1206 | for ((i) = 0; \
|
| 1207 | ((i) < rtd->dai_link->num_cpus) && ((dai) = snd_soc_rtd_to_cpu(rtd, i)); \
|
| 1208 | (i)++)
|
| 1209 | #define for_each_rtd_codec_dais(rtd, i, dai) \
|
| 1210 | for ((i) = 0; \
|
| 1211 | ((i) < rtd->dai_link->num_codecs) && ((dai) = snd_soc_rtd_to_codec(rtd, i)); \
|
| 1212 | (i)++)
|
| 1213 | #define for_each_rtd_dais(rtd, i, dai) \
|
| 1214 | for ((i) = 0; \
|
| 1215 | ((i) < (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs) && \
|
| 1216 | ((dai) = (rtd)->dais[i]); \
|
| 1217 | (i)++)
|
| 1218 | #define for_each_rtd_dais_reverse(rtd, i, dai) \
|
| 1219 | for ((i) = (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs - 1; \
|
| 1220 | (i) >= 0 && ((dai) = (rtd)->dais[i]); \
|
| 1221 | (i)--)
|
| 1222 | #define for_each_rtd_ch_maps(rtd, i, ch_maps) for_each_link_ch_maps(rtd->dai_link, i, ch_maps)
|
| 1223 |
|
| 1224 | void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);
|
| 1225 |
|
| 1226 |
|
| 1227 | struct soc_mixer_control {
|
| 1228 |
|
| 1229 | int min, max;
|
| 1230 |
|
| 1231 | int platform_max;
|
| 1232 | int reg, rreg;
|
| 1233 | unsigned int shift, rshift;
|
| 1234 | u32 num_channels;
|
| 1235 | unsigned int sign_bit;
|
| 1236 | unsigned int invert:1;
|
| 1237 | unsigned int autodisable:1;
|
| 1238 | #ifdef CONFIG_SND_SOC_TOPOLOGY
|
| 1239 | struct snd_soc_dobj dobj;
|
| 1240 | #endif
|
| 1241 | };
|
| 1242 |
|
| 1243 | struct soc_bytes {
|
| 1244 | int base;
|
| 1245 | int num_regs;
|
| 1246 | u32 mask;
|
| 1247 | };
|
| 1248 |
|
| 1249 | struct soc_bytes_ext {
|
| 1250 | int max;
|
| 1251 | #ifdef CONFIG_SND_SOC_TOPOLOGY
|
| 1252 | struct snd_soc_dobj dobj;
|
| 1253 | #endif
|
| 1254 |
|
| 1255 | int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
|
| 1256 | unsigned int size);
|
| 1257 | int (*put)(struct snd_kcontrol *kcontrol, const unsigned int __user *bytes,
|
| 1258 | unsigned int size);
|
| 1259 | };
|
| 1260 |
|
| 1261 |
|
| 1262 | struct soc_mreg_control {
|
| 1263 | long min, max;
|
| 1264 | unsigned int regbase, regcount, nbits, invert;
|
| 1265 | };
|
| 1266 |
|
| 1267 |
|
| 1268 | struct soc_enum {
|
| 1269 | int reg;
|
| 1270 | unsigned char shift_l;
|
| 1271 | unsigned char shift_r;
|
| 1272 | unsigned int items;
|
| 1273 | unsigned int mask;
|
| 1274 | const char * const *texts;
|
| 1275 | const unsigned int *values;
|
| 1276 | unsigned int autodisable:1;
|
| 1277 | #ifdef CONFIG_SND_SOC_TOPOLOGY
|
| 1278 | struct snd_soc_dobj dobj;
|
| 1279 | #endif
|
| 1280 | };
|
| 1281 |
|
| 1282 | static inline bool snd_soc_volsw_is_stereo(const struct soc_mixer_control *mc)
|
| 1283 | {
|
| 1284 | if (mc->reg == mc->rreg && mc->shift == mc->rshift)
|
| 1285 | return false;
|
| 1286 | |
| 1287 | * mc->reg == mc->rreg && mc->shift != mc->rshift, or
|
| 1288 | * mc->reg != mc->rreg means that the control is
|
| 1289 | * stereo (bits in one register or in two registers)
|
| 1290 |
|
| 1291 | return true;
|
| 1292 | }
|
| 1293 |
|
| 1294 | static inline unsigned int snd_soc_enum_val_to_item(const struct soc_enum *e,
|
| 1295 | unsigned int val)
|
| 1296 | {
|
| 1297 | unsigned int i;
|
| 1298 |
|
| 1299 | if (!e->values)
|
| 1300 | return val;
|
| 1301 |
|
| 1302 | for (i = 0; i < e->items; i++)
|
| 1303 | if (val == e->values[i])
|
| 1304 | return i;
|
| 1305 |
|
| 1306 | return 0;
|
| 1307 | }
|
| 1308 |
|
| 1309 | static inline unsigned int snd_soc_enum_item_to_val(const struct soc_enum *e,
|
| 1310 | unsigned int item)
|
| 1311 | {
|
| 1312 | if (!e->values)
|
| 1313 | return item;
|
| 1314 |
|
| 1315 | return e->values[item];
|
| 1316 | }
|
| 1317 |
|
| 1318 | int snd_soc_util_init(void);
|
| 1319 | void snd_soc_util_exit(void);
|
| 1320 |
|
| 1321 | int snd_soc_of_parse_card_name(struct snd_soc_card *card,
|
| 1322 | const char *propname);
|
| 1323 | int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
|
| 1324 | const char *propname);
|
| 1325 | int snd_soc_of_parse_pin_switches(struct snd_soc_card *card, const char *prop);
|
| 1326 | int snd_soc_of_get_slot_mask(struct device_node *np,
|
| 1327 | const char *prop_name,
|
| 1328 | unsigned int *mask);
|
| 1329 | int snd_soc_of_parse_tdm_slot(struct device_node *np,
|
| 1330 | unsigned int *tx_mask,
|
| 1331 | unsigned int *rx_mask,
|
| 1332 | unsigned int *slots,
|
| 1333 | unsigned int *slot_width);
|
| 1334 | void snd_soc_of_parse_node_prefix(struct device_node *np,
|
| 1335 | struct snd_soc_codec_conf *codec_conf,
|
| 1336 | struct device_node *of_node,
|
| 1337 | const char *propname);
|
| 1338 |
|
| 1339 | int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
|
| 1340 | const char *propname);
|
| 1341 | int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
|
| 1342 | int snd_soc_of_parse_ignore_suspend_widgets(struct snd_soc_card *card, const char *propname);
|
| 1343 |
|
| 1344 | unsigned int snd_soc_daifmt_clock_provider_flipped(unsigned int dai_fmt);
|
| 1345 | unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame);
|
| 1346 |
|
| 1347 | unsigned int snd_soc_daifmt_parse_format(struct device_node *np, const char *prefix);
|
| 1348 | unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
|
| 1349 | const char *prefix,
|
| 1350 | struct device_node **bitclkmaster,
|
| 1351 | struct device_node **framemaster);
|
| 1352 | #define snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix) \
|
| 1353 | snd_soc_daifmt_parse_clock_provider_raw(np, prefix, NULL, NULL)
|
| 1354 | #define snd_soc_daifmt_parse_clock_provider_as_phandle \
|
| 1355 | snd_soc_daifmt_parse_clock_provider_raw
|
| 1356 | #define snd_soc_daifmt_parse_clock_provider_as_flag(np, prefix) \
|
| 1357 | snd_soc_daifmt_clock_provider_from_bitmap( \
|
| 1358 | snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix))
|
| 1359 |
|
| 1360 | int snd_soc_get_stream_cpu(const struct snd_soc_dai_link *dai_link, int stream);
|
| 1361 | int snd_soc_get_dlc(const struct of_phandle_args *args,
|
| 1362 | struct snd_soc_dai_link_component *dlc);
|
| 1363 | int snd_soc_of_get_dlc(struct device_node *of_node,
|
| 1364 | struct of_phandle_args *args,
|
| 1365 | struct snd_soc_dai_link_component *dlc,
|
| 1366 | int index);
|
| 1367 | int snd_soc_get_dai_id(struct device_node *ep);
|
| 1368 | int snd_soc_get_dai_name(const struct of_phandle_args *args,
|
| 1369 | const char **dai_name);
|
| 1370 | int snd_soc_of_get_dai_name(struct device_node *of_node,
|
| 1371 | const char **dai_name, int index);
|
| 1372 | int snd_soc_of_get_dai_link_codecs(struct device *dev,
|
| 1373 | struct device_node *of_node,
|
| 1374 | struct snd_soc_dai_link *dai_link);
|
| 1375 | void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
|
| 1376 | int snd_soc_of_get_dai_link_cpus(struct device *dev,
|
| 1377 | struct device_node *of_node,
|
| 1378 | struct snd_soc_dai_link *dai_link);
|
| 1379 | void snd_soc_of_put_dai_link_cpus(struct snd_soc_dai_link *dai_link);
|
| 1380 |
|
| 1381 | int snd_soc_add_pcm_runtimes(struct snd_soc_card *card,
|
| 1382 | struct snd_soc_dai_link *dai_link,
|
| 1383 | int num_dai_link);
|
| 1384 | void snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
|
| 1385 | struct snd_soc_pcm_runtime *rtd);
|
| 1386 |
|
| 1387 | void snd_soc_dlc_use_cpu_as_platform(struct snd_soc_dai_link_component *platforms,
|
| 1388 | struct snd_soc_dai_link_component *cpus);
|
| 1389 | struct of_phandle_args *snd_soc_copy_dai_args(struct device *dev,
|
| 1390 | const struct of_phandle_args *args);
|
| 1391 | struct snd_soc_dai *snd_soc_get_dai_via_args(const struct of_phandle_args *dai_args);
|
| 1392 | struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
|
| 1393 | struct snd_soc_dai_driver *dai_drv,
|
| 1394 | bool legacy_dai_naming);
|
| 1395 | void snd_soc_unregister_dai(struct snd_soc_dai *dai);
|
| 1396 |
|
| 1397 | struct snd_soc_dai *snd_soc_find_dai(
|
| 1398 | const struct snd_soc_dai_link_component *dlc);
|
| 1399 | struct snd_soc_dai *snd_soc_find_dai_with_mutex(
|
| 1400 | const struct snd_soc_dai_link_component *dlc);
|
| 1401 |
|
| 1402 | void soc_pcm_set_dai_params(struct snd_soc_dai *dai,
|
| 1403 | struct snd_pcm_hw_params *params);
|
| 1404 |
|
| 1405 | #include <sound/soc-dai.h>
|
| 1406 |
|
| 1407 | static inline
|
| 1408 | int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
|
| 1409 | const char *platform_name)
|
| 1410 | {
|
| 1411 | struct snd_soc_dai_link *dai_link;
|
| 1412 | const char *name;
|
| 1413 | int i;
|
| 1414 |
|
| 1415 | if (!platform_name)
|
| 1416 | return 0;
|
| 1417 |
|
| 1418 |
|
| 1419 | for_each_card_prelinks(card, i, dai_link) {
|
| 1420 |
|
| 1421 | if (dai_link->num_platforms != 1)
|
| 1422 | return -EINVAL;
|
| 1423 |
|
| 1424 | if (!dai_link->platforms)
|
| 1425 | return -EINVAL;
|
| 1426 |
|
| 1427 | name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
|
| 1428 | if (!name)
|
| 1429 | return -ENOMEM;
|
| 1430 |
|
| 1431 |
|
| 1432 | dai_link->platforms->name = name;
|
| 1433 | }
|
| 1434 |
|
| 1435 | return 0;
|
| 1436 | }
|
| 1437 |
|
| 1438 | #ifdef CONFIG_DEBUG_FS
|
| 1439 | extern struct dentry *snd_soc_debugfs_root;
|
| 1440 | #endif
|
| 1441 |
|
| 1442 | extern const struct dev_pm_ops snd_soc_pm_ops;
|
| 1443 |
|
| 1444 | |
| 1445 | * DAPM helper functions
|
| 1446 |
|
| 1447 | enum snd_soc_dapm_subclass {
|
| 1448 | SND_SOC_DAPM_CLASS_ROOT = 0,
|
| 1449 | SND_SOC_DAPM_CLASS_RUNTIME = 1,
|
| 1450 | };
|
| 1451 |
|
| 1452 | static inline void _snd_soc_dapm_mutex_lock_root_c(struct snd_soc_card *card)
|
| 1453 | {
|
| 1454 | mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_ROOT);
|
| 1455 | }
|
| 1456 |
|
| 1457 | static inline void _snd_soc_dapm_mutex_lock_c(struct snd_soc_card *card)
|
| 1458 | {
|
| 1459 | mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
|
| 1460 | }
|
| 1461 |
|
| 1462 | static inline void _snd_soc_dapm_mutex_unlock_c(struct snd_soc_card *card)
|
| 1463 | {
|
| 1464 | mutex_unlock(&card->dapm_mutex);
|
| 1465 | }
|
| 1466 |
|
| 1467 | static inline void _snd_soc_dapm_mutex_assert_held_c(struct snd_soc_card *card)
|
| 1468 | {
|
| 1469 | lockdep_assert_held(&card->dapm_mutex);
|
| 1470 | }
|
| 1471 |
|
| 1472 | static inline void _snd_soc_dapm_mutex_lock_root_d(struct snd_soc_dapm_context *dapm)
|
| 1473 | {
|
| 1474 | _snd_soc_dapm_mutex_lock_root_c(snd_soc_dapm_to_card(dapm));
|
| 1475 | }
|
| 1476 |
|
| 1477 | static inline void _snd_soc_dapm_mutex_lock_d(struct snd_soc_dapm_context *dapm)
|
| 1478 | {
|
| 1479 | _snd_soc_dapm_mutex_lock_c(snd_soc_dapm_to_card(dapm));
|
| 1480 | }
|
| 1481 |
|
| 1482 | static inline void _snd_soc_dapm_mutex_unlock_d(struct snd_soc_dapm_context *dapm)
|
| 1483 | {
|
| 1484 | _snd_soc_dapm_mutex_unlock_c(snd_soc_dapm_to_card(dapm));
|
| 1485 | }
|
| 1486 |
|
| 1487 | static inline void _snd_soc_dapm_mutex_assert_held_d(struct snd_soc_dapm_context *dapm)
|
| 1488 | {
|
| 1489 | _snd_soc_dapm_mutex_assert_held_c(snd_soc_dapm_to_card(dapm));
|
| 1490 | }
|
| 1491 |
|
| 1492 | #define snd_soc_dapm_mutex_lock_root(x) _Generic((x), \
|
| 1493 | struct snd_soc_card * : _snd_soc_dapm_mutex_lock_root_c, \
|
| 1494 | struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_root_d)(x)
|
| 1495 | #define snd_soc_dapm_mutex_lock(x) _Generic((x), \
|
| 1496 | struct snd_soc_card * : _snd_soc_dapm_mutex_lock_c, \
|
| 1497 | struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_d)(x)
|
| 1498 | #define snd_soc_dapm_mutex_unlock(x) _Generic((x), \
|
| 1499 | struct snd_soc_card * : _snd_soc_dapm_mutex_unlock_c, \
|
| 1500 | struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_unlock_d)(x)
|
| 1501 | #define snd_soc_dapm_mutex_assert_held(x) _Generic((x), \
|
| 1502 | struct snd_soc_card * : _snd_soc_dapm_mutex_assert_held_c, \
|
| 1503 | struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_assert_held_d)(x)
|
| 1504 |
|
| 1505 | |
| 1506 | * PCM helper functions
|
| 1507 |
|
| 1508 | static inline void _snd_soc_dpcm_mutex_lock_c(struct snd_soc_card *card)
|
| 1509 | {
|
| 1510 | mutex_lock(&card->pcm_mutex);
|
| 1511 | }
|
| 1512 |
|
| 1513 | static inline void _snd_soc_dpcm_mutex_unlock_c(struct snd_soc_card *card)
|
| 1514 | {
|
| 1515 | mutex_unlock(&card->pcm_mutex);
|
| 1516 | }
|
| 1517 |
|
| 1518 | static inline void _snd_soc_dpcm_mutex_assert_held_c(struct snd_soc_card *card)
|
| 1519 | {
|
| 1520 | lockdep_assert_held(&card->pcm_mutex);
|
| 1521 | }
|
| 1522 |
|
| 1523 | static inline void _snd_soc_dpcm_mutex_lock_r(struct snd_soc_pcm_runtime *rtd)
|
| 1524 | {
|
| 1525 | _snd_soc_dpcm_mutex_lock_c(rtd->card);
|
| 1526 | }
|
| 1527 |
|
| 1528 | static inline void _snd_soc_dpcm_mutex_unlock_r(struct snd_soc_pcm_runtime *rtd)
|
| 1529 | {
|
| 1530 | _snd_soc_dpcm_mutex_unlock_c(rtd->card);
|
| 1531 | }
|
| 1532 |
|
| 1533 | static inline void _snd_soc_dpcm_mutex_assert_held_r(struct snd_soc_pcm_runtime *rtd)
|
| 1534 | {
|
| 1535 | _snd_soc_dpcm_mutex_assert_held_c(rtd->card);
|
| 1536 | }
|
| 1537 |
|
| 1538 | #define snd_soc_dpcm_mutex_lock(x) _Generic((x), \
|
| 1539 | struct snd_soc_card * : _snd_soc_dpcm_mutex_lock_c, \
|
| 1540 | struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_lock_r)(x)
|
| 1541 |
|
| 1542 | #define snd_soc_dpcm_mutex_unlock(x) _Generic((x), \
|
| 1543 | struct snd_soc_card * : _snd_soc_dpcm_mutex_unlock_c, \
|
| 1544 | struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_unlock_r)(x)
|
| 1545 |
|
| 1546 | #define snd_soc_dpcm_mutex_assert_held(x) _Generic((x), \
|
| 1547 | struct snd_soc_card * : _snd_soc_dpcm_mutex_assert_held_c, \
|
| 1548 | struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_assert_held_r)(x)
|
| 1549 |
|
| 1550 | #include <sound/soc-component.h>
|
| 1551 | #include <sound/soc-card.h>
|
| 1552 | #include <sound/soc-jack.h>
|
| 1553 |
|
| 1554 | #endif
|