| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * linux/sound/soc.h -- ALSA SoC Layer | 
|  | 3 | * | 
|  | 4 | * Author:		Liam Girdwood | 
|  | 5 | * Created:		Aug 11th 2005 | 
|  | 6 | * Copyright:	Wolfson Microelectronics. PLC. | 
|  | 7 | * | 
|  | 8 | * This program is free software; you can redistribute it and/or modify | 
|  | 9 | * it under the terms of the GNU General Public License version 2 as | 
|  | 10 | * published by the Free Software Foundation. | 
|  | 11 | */ | 
|  | 12 |  | 
|  | 13 | #ifndef __LINUX_SND_SOC_H | 
|  | 14 | #define __LINUX_SND_SOC_H | 
|  | 15 |  | 
|  | 16 | #include <linux/platform_device.h> | 
|  | 17 | #include <linux/types.h> | 
|  | 18 | #include <linux/notifier.h> | 
|  | 19 | #include <linux/workqueue.h> | 
|  | 20 | #include <linux/interrupt.h> | 
|  | 21 | #include <linux/kernel.h> | 
|  | 22 | #include <linux/regmap.h> | 
|  | 23 | #include <sound/core.h> | 
|  | 24 | #include <sound/pcm.h> | 
|  | 25 | #include <sound/control.h> | 
|  | 26 | #include <sound/ac97_codec.h> | 
|  | 27 |  | 
|  | 28 | /* | 
|  | 29 | * Convenience kcontrol builders | 
|  | 30 | */ | 
|  | 31 | #define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert) \ | 
|  | 32 | ((unsigned long)&(struct soc_mixer_control) \ | 
|  | 33 | {.reg = xreg, .rreg = xreg, .shift = shift_left, \ | 
|  | 34 | .rshift = shift_right, .max = xmax, .platform_max = xmax, \ | 
|  | 35 | .invert = xinvert}) | 
|  | 36 | #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \ | 
|  | 37 | SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert) | 
|  | 38 | #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \ | 
|  | 39 | ((unsigned long)&(struct soc_mixer_control) \ | 
|  | 40 | {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert}) | 
|  | 41 | #define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \ | 
|  | 42 | ((unsigned long)&(struct soc_mixer_control) \ | 
|  | 43 | {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \ | 
|  | 44 | .max = xmax, .platform_max = xmax, .invert = xinvert}) | 
|  | 45 | #define SOC_SINGLE(xname, reg, shift, max, invert) \ | 
|  | 46 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 
|  | 47 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ | 
|  | 48 | .put = snd_soc_put_volsw, \ | 
|  | 49 | .private_value =  SOC_SINGLE_VALUE(reg, shift, max, invert) } | 
|  | 50 | #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ | 
|  | 51 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 
|  | 52 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ | 
|  | 53 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | 
|  | 54 | .tlv.p = (tlv_array), \ | 
|  | 55 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ | 
|  | 56 | .put = snd_soc_put_volsw, \ | 
|  | 57 | .private_value =  SOC_SINGLE_VALUE(reg, shift, max, invert) } | 
|  | 58 | #define SOC_SINGLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \ | 
|  | 59 | {	.iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | 
|  | 60 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | 
|  | 61 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | 
|  | 62 | .tlv.p  = (tlv_array), \ | 
|  | 63 | .info   = snd_soc_info_volsw_s8_single, .get = snd_soc_get_volsw_s8_single, \ | 
|  | 64 | .put    = snd_soc_put_volsw_s8_single, \ | 
|  | 65 | .private_value = (unsigned long)&(struct soc_mixer_control) \ | 
|  | 66 | {.reg = xreg, .min = xmin, .max = xmax, \ | 
|  | 67 | .platform_max = xmax} } | 
|  | 68 | #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \ | 
|  | 69 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ | 
|  | 70 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ | 
|  | 71 | .put = snd_soc_put_volsw, \ | 
|  | 72 | .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \ | 
|  | 73 | max, invert) } | 
|  | 74 | #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \ | 
|  | 75 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | 
|  | 76 | .info = snd_soc_info_volsw, \ | 
|  | 77 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ | 
|  | 78 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ | 
|  | 79 | xmax, xinvert) } | 
|  | 80 | #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \ | 
|  | 81 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ | 
|  | 82 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ | 
|  | 83 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | 
|  | 84 | .tlv.p = (tlv_array), \ | 
|  | 85 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ | 
|  | 86 | .put = snd_soc_put_volsw, \ | 
|  | 87 | .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \ | 
|  | 88 | max, invert) } | 
|  | 89 | #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \ | 
|  | 90 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ | 
|  | 91 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ | 
|  | 92 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | 
|  | 93 | .tlv.p = (tlv_array), \ | 
|  | 94 | .info = snd_soc_info_volsw, \ | 
|  | 95 | .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ | 
|  | 96 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ | 
|  | 97 | xmax, xinvert) } | 
|  | 98 | #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \ | 
|  | 99 | {	.iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | 
|  | 100 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | 
|  | 101 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | 
|  | 102 | .tlv.p  = (tlv_array), \ | 
|  | 103 | .info   = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \ | 
|  | 104 | .put    = snd_soc_put_volsw_s8, \ | 
|  | 105 | .private_value = (unsigned long)&(struct soc_mixer_control) \ | 
|  | 106 | {.reg = xreg, .min = xmin, .max = xmax, \ | 
|  | 107 | .platform_max = xmax} } | 
|  | 108 | #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \ | 
|  | 109 | {	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ | 
|  | 110 | .max = xmax, .texts = xtexts } | 
|  | 111 | #define SOC_ENUM_SINGLE(xreg, xshift, xmax, xtexts) \ | 
|  | 112 | SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmax, xtexts) | 
|  | 113 | #define SOC_ENUM_SINGLE_EXT(xmax, xtexts) \ | 
|  | 114 | {	.max = xmax, .texts = xtexts } | 
|  | 115 | #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xmax, xtexts, xvalues) \ | 
|  | 116 | {	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ | 
|  | 117 | .mask = xmask, .max = xmax, .texts = xtexts, .values = xvalues} | 
|  | 118 | #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xmax, xtexts, xvalues) \ | 
|  | 119 | SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xmax, xtexts, xvalues) | 
|  | 120 | #define SOC_ENUM(xname, xenum) \ | 
|  | 121 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ | 
|  | 122 | .info = snd_soc_info_enum_double, \ | 
|  | 123 | .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \ | 
|  | 124 | .private_value = (unsigned long)&xenum } | 
|  | 125 | #define SOC_VALUE_ENUM(xname, xenum) \ | 
|  | 126 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ | 
|  | 127 | .info = snd_soc_info_enum_double, \ | 
|  | 128 | .get = snd_soc_get_value_enum_double, \ | 
|  | 129 | .put = snd_soc_put_value_enum_double, \ | 
|  | 130 | .private_value = (unsigned long)&xenum } | 
|  | 131 | #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\ | 
|  | 132 | xhandler_get, xhandler_put) \ | 
|  | 133 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 
|  | 134 | .info = snd_soc_info_volsw, \ | 
|  | 135 | .get = xhandler_get, .put = xhandler_put, \ | 
|  | 136 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) } | 
|  | 137 | #define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\ | 
|  | 138 | xhandler_get, xhandler_put) \ | 
|  | 139 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ | 
|  | 140 | .info = snd_soc_info_volsw, \ | 
|  | 141 | .get = xhandler_get, .put = xhandler_put, \ | 
|  | 142 | .private_value = \ | 
|  | 143 | SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert) } | 
|  | 144 | #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\ | 
|  | 145 | xhandler_get, xhandler_put, tlv_array) \ | 
|  | 146 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 
|  | 147 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ | 
|  | 148 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ | 
|  | 149 | .tlv.p = (tlv_array), \ | 
|  | 150 | .info = snd_soc_info_volsw, \ | 
|  | 151 | .get = xhandler_get, .put = xhandler_put, \ | 
|  | 152 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) } | 
|  | 153 | #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\ | 
|  | 154 | xhandler_get, xhandler_put, tlv_array) \ | 
|  | 155 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | 
|  | 156 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | 
|  | 157 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | 
|  | 158 | .tlv.p = (tlv_array), \ | 
|  | 159 | .info = snd_soc_info_volsw, \ | 
|  | 160 | .get = xhandler_get, .put = xhandler_put, \ | 
|  | 161 | .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \ | 
|  | 162 | xmax, xinvert) } | 
|  | 163 | #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\ | 
|  | 164 | xhandler_get, xhandler_put, tlv_array) \ | 
|  | 165 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | 
|  | 166 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | 
|  | 167 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | 
|  | 168 | .tlv.p = (tlv_array), \ | 
|  | 169 | .info = snd_soc_info_volsw, \ | 
|  | 170 | .get = xhandler_get, .put = xhandler_put, \ | 
|  | 171 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ | 
|  | 172 | xmax, xinvert) } | 
|  | 173 | #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \ | 
|  | 174 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 
|  | 175 | .info = snd_soc_info_bool_ext, \ | 
|  | 176 | .get = xhandler_get, .put = xhandler_put, \ | 
|  | 177 | .private_value = xdata } | 
|  | 178 | #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \ | 
|  | 179 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 
|  | 180 | .info = snd_soc_info_enum_ext, \ | 
|  | 181 | .get = xhandler_get, .put = xhandler_put, \ | 
|  | 182 | .private_value = (unsigned long)&xenum } | 
|  | 183 |  | 
|  | 184 | #define SOC_DOUBLE_R_SX_TLV(xname, xreg_left, xreg_right, xshift,\ | 
|  | 185 | xmin, xmax, tlv_array) \ | 
|  | 186 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | 
|  | 187 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | 
|  | 188 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | 
|  | 189 | .tlv.p = (tlv_array), \ | 
|  | 190 | .info = snd_soc_info_volsw_2r_sx, \ | 
|  | 191 | .get = snd_soc_get_volsw_2r_sx, \ | 
|  | 192 | .put = snd_soc_put_volsw_2r_sx, \ | 
|  | 193 | .private_value = (unsigned long)&(struct soc_mixer_control) \ | 
|  | 194 | {.reg = xreg_left, \ | 
|  | 195 | .rreg = xreg_right, .shift = xshift, \ | 
|  | 196 | .min = xmin, .max = xmax} } | 
|  | 197 |  | 
|  | 198 | #define SND_SOC_BYTES(xname, xbase, xregs)		      \ | 
|  | 199 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \ | 
|  | 200 | .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \ | 
|  | 201 | .put = snd_soc_bytes_put, .private_value =	      \ | 
|  | 202 | ((unsigned long)&(struct soc_bytes)           \ | 
|  | 203 | {.base = xbase, .num_regs = xregs }) } | 
|  | 204 |  | 
|  | 205 | #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask)	      \ | 
|  | 206 | {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \ | 
|  | 207 | .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \ | 
|  | 208 | .put = snd_soc_bytes_put, .private_value =	      \ | 
|  | 209 | ((unsigned long)&(struct soc_bytes)           \ | 
|  | 210 | {.base = xbase, .num_regs = xregs,	      \ | 
|  | 211 | .mask = xmask }) } | 
|  | 212 |  | 
|  | 213 | /* | 
|  | 214 | * Simplified versions of above macros, declaring a struct and calculating | 
|  | 215 | * ARRAY_SIZE internally | 
|  | 216 | */ | 
|  | 217 | #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \ | 
|  | 218 | struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \ | 
|  | 219 | ARRAY_SIZE(xtexts), xtexts) | 
|  | 220 | #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \ | 
|  | 221 | SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts) | 
|  | 222 | #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \ | 
|  | 223 | struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts) | 
|  | 224 | #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \ | 
|  | 225 | struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \ | 
|  | 226 | ARRAY_SIZE(xtexts), xtexts, xvalues) | 
|  | 227 | #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \ | 
|  | 228 | SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues) | 
|  | 229 |  | 
|  | 230 | /* | 
|  | 231 | * Component probe and remove ordering levels for components with runtime | 
|  | 232 | * dependencies. | 
|  | 233 | */ | 
|  | 234 | #define SND_SOC_COMP_ORDER_FIRST		-2 | 
|  | 235 | #define SND_SOC_COMP_ORDER_EARLY		-1 | 
|  | 236 | #define SND_SOC_COMP_ORDER_NORMAL		0 | 
|  | 237 | #define SND_SOC_COMP_ORDER_LATE		1 | 
|  | 238 | #define SND_SOC_COMP_ORDER_LAST		2 | 
|  | 239 |  | 
|  | 240 | /* | 
|  | 241 | * Bias levels | 
|  | 242 | * | 
|  | 243 | * @ON:      Bias is fully on for audio playback and capture operations. | 
|  | 244 | * @PREPARE: Prepare for audio operations. Called before DAPM switching for | 
|  | 245 | *           stream start and stop operations. | 
|  | 246 | * @STANDBY: Low power standby state when no playback/capture operations are | 
|  | 247 | *           in progress. NOTE: The transition time between STANDBY and ON | 
|  | 248 | *           should be as fast as possible and no longer than 10ms. | 
|  | 249 | * @OFF:     Power Off. No restrictions on transition times. | 
|  | 250 | */ | 
|  | 251 | enum snd_soc_bias_level { | 
|  | 252 | SND_SOC_BIAS_OFF = 0, | 
|  | 253 | SND_SOC_BIAS_STANDBY = 1, | 
|  | 254 | SND_SOC_BIAS_PREPARE = 2, | 
|  | 255 | SND_SOC_BIAS_ON = 3, | 
|  | 256 | }; | 
|  | 257 |  | 
|  | 258 | struct device_node; | 
|  | 259 | struct snd_jack; | 
|  | 260 | struct snd_soc_card; | 
|  | 261 | struct snd_soc_pcm_stream; | 
|  | 262 | struct snd_soc_ops; | 
|  | 263 | struct snd_soc_pcm_runtime; | 
|  | 264 | struct snd_soc_dai; | 
|  | 265 | struct snd_soc_dai_driver; | 
|  | 266 | struct snd_soc_platform; | 
|  | 267 | struct snd_soc_dai_link; | 
|  | 268 | struct snd_soc_platform_driver; | 
|  | 269 | struct snd_soc_codec; | 
|  | 270 | struct snd_soc_codec_driver; | 
|  | 271 | struct soc_enum; | 
|  | 272 | struct snd_soc_jack; | 
|  | 273 | struct snd_soc_jack_zone; | 
|  | 274 | struct snd_soc_jack_pin; | 
|  | 275 | struct snd_soc_cache_ops; | 
|  | 276 | #include <sound/soc-dapm.h> | 
|  | 277 |  | 
|  | 278 | #ifdef CONFIG_GPIOLIB | 
|  | 279 | struct snd_soc_jack_gpio; | 
|  | 280 | #endif | 
|  | 281 |  | 
|  | 282 | typedef int (*hw_write_t)(void *,const char* ,int); | 
|  | 283 |  | 
|  | 284 | extern struct snd_ac97_bus_ops soc_ac97_ops; | 
|  | 285 |  | 
|  | 286 | enum snd_soc_control_type { | 
|  | 287 | SND_SOC_I2C = 1, | 
|  | 288 | SND_SOC_SPI, | 
|  | 289 | SND_SOC_REGMAP, | 
|  | 290 | }; | 
|  | 291 |  | 
|  | 292 | enum snd_soc_compress_type { | 
|  | 293 | SND_SOC_FLAT_COMPRESSION = 1, | 
|  | 294 | }; | 
|  | 295 |  | 
|  | 296 | enum snd_soc_pcm_subclass { | 
|  | 297 | SND_SOC_PCM_CLASS_PCM	= 0, | 
|  | 298 | SND_SOC_PCM_CLASS_BE	= 1, | 
|  | 299 | }; | 
|  | 300 |  | 
|  | 301 | enum snd_soc_card_subclass { | 
|  | 302 | SND_SOC_CARD_CLASS_INIT	= 0, | 
|  | 303 | SND_SOC_CARD_CLASS_PCM	= 1, | 
|  | 304 | }; | 
|  | 305 |  | 
|  | 306 | int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id, | 
|  | 307 | int source, unsigned int freq, int dir); | 
|  | 308 | int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, | 
|  | 309 | unsigned int freq_in, unsigned int freq_out); | 
|  | 310 |  | 
|  | 311 | int snd_soc_register_card(struct snd_soc_card *card); | 
|  | 312 | int snd_soc_unregister_card(struct snd_soc_card *card); | 
|  | 313 | int snd_soc_suspend(struct device *dev); | 
|  | 314 | int snd_soc_resume(struct device *dev); | 
|  | 315 | int snd_soc_poweroff(struct device *dev); | 
|  | 316 | int snd_soc_register_platform(struct device *dev, | 
|  | 317 | struct snd_soc_platform_driver *platform_drv); | 
|  | 318 | void snd_soc_unregister_platform(struct device *dev); | 
|  | 319 | int snd_soc_register_codec(struct device *dev, | 
|  | 320 | const struct snd_soc_codec_driver *codec_drv, | 
|  | 321 | struct snd_soc_dai_driver *dai_drv, int num_dai); | 
|  | 322 | void snd_soc_unregister_codec(struct device *dev); | 
|  | 323 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, | 
|  | 324 | unsigned int reg); | 
|  | 325 | int snd_soc_codec_readable_register(struct snd_soc_codec *codec, | 
|  | 326 | unsigned int reg); | 
|  | 327 | int snd_soc_codec_writable_register(struct snd_soc_codec *codec, | 
|  | 328 | unsigned int reg); | 
|  | 329 | int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, | 
|  | 330 | int addr_bits, int data_bits, | 
|  | 331 | enum snd_soc_control_type control); | 
|  | 332 | int snd_soc_cache_sync(struct snd_soc_codec *codec); | 
|  | 333 | int snd_soc_cache_init(struct snd_soc_codec *codec); | 
|  | 334 | int snd_soc_cache_exit(struct snd_soc_codec *codec); | 
|  | 335 | int snd_soc_cache_write(struct snd_soc_codec *codec, | 
|  | 336 | unsigned int reg, unsigned int value); | 
|  | 337 | int snd_soc_cache_read(struct snd_soc_codec *codec, | 
|  | 338 | unsigned int reg, unsigned int *value); | 
|  | 339 | int snd_soc_default_volatile_register(struct snd_soc_codec *codec, | 
|  | 340 | unsigned int reg); | 
|  | 341 | int snd_soc_default_readable_register(struct snd_soc_codec *codec, | 
|  | 342 | unsigned int reg); | 
|  | 343 | int snd_soc_default_writable_register(struct snd_soc_codec *codec, | 
|  | 344 | unsigned int reg); | 
|  | 345 | int snd_soc_platform_read(struct snd_soc_platform *platform, | 
|  | 346 | unsigned int reg); | 
|  | 347 | int snd_soc_platform_write(struct snd_soc_platform *platform, | 
|  | 348 | unsigned int reg, unsigned int val); | 
|  | 349 | int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num); | 
|  | 350 |  | 
|  | 351 | /* Utility functions to get clock rates from various things */ | 
|  | 352 | int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); | 
|  | 353 | int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params); | 
|  | 354 | int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots); | 
|  | 355 | int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms); | 
|  | 356 |  | 
|  | 357 | /* set runtime hw params */ | 
|  | 358 | int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, | 
|  | 359 | const struct snd_pcm_hardware *hw); | 
|  | 360 |  | 
|  | 361 | /* Jack reporting */ | 
|  | 362 | int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, | 
|  | 363 | struct snd_soc_jack *jack); | 
|  | 364 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); | 
|  | 365 | int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, | 
|  | 366 | struct snd_soc_jack_pin *pins); | 
|  | 367 | void snd_soc_jack_notifier_register(struct snd_soc_jack *jack, | 
|  | 368 | struct notifier_block *nb); | 
|  | 369 | void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack, | 
|  | 370 | struct notifier_block *nb); | 
|  | 371 | int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count, | 
|  | 372 | struct snd_soc_jack_zone *zones); | 
|  | 373 | int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage); | 
|  | 374 | #ifdef CONFIG_GPIOLIB | 
|  | 375 | int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | 
|  | 376 | struct snd_soc_jack_gpio *gpios); | 
|  | 377 | void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, | 
|  | 378 | struct snd_soc_jack_gpio *gpios); | 
|  | 379 | #endif | 
|  | 380 |  | 
|  | 381 | /* codec register bit access */ | 
|  | 382 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, | 
|  | 383 | unsigned int mask, unsigned int value); | 
|  | 384 | int snd_soc_update_bits_locked(struct snd_soc_codec *codec, | 
|  | 385 | unsigned short reg, unsigned int mask, | 
|  | 386 | unsigned int value); | 
|  | 387 | int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, | 
|  | 388 | unsigned int mask, unsigned int value); | 
|  | 389 |  | 
|  | 390 | int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, | 
|  | 391 | struct snd_ac97_bus_ops *ops, int num); | 
|  | 392 | void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); | 
|  | 393 |  | 
|  | 394 | /* | 
|  | 395 | *Controls | 
|  | 396 | */ | 
|  | 397 | struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, | 
|  | 398 | void *data, const char *long_name, | 
|  | 399 | const char *prefix); | 
|  | 400 | int snd_soc_add_codec_controls(struct snd_soc_codec *codec, | 
|  | 401 | const struct snd_kcontrol_new *controls, int num_controls); | 
|  | 402 | int snd_soc_add_platform_controls(struct snd_soc_platform *platform, | 
|  | 403 | const struct snd_kcontrol_new *controls, int num_controls); | 
|  | 404 | int snd_soc_add_card_controls(struct snd_soc_card *soc_card, | 
|  | 405 | const struct snd_kcontrol_new *controls, int num_controls); | 
|  | 406 | int snd_soc_add_dai_controls(struct snd_soc_dai *dai, | 
|  | 407 | const struct snd_kcontrol_new *controls, int num_controls); | 
|  | 408 | int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, | 
|  | 409 | struct snd_ctl_elem_info *uinfo); | 
|  | 410 | int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol, | 
|  | 411 | struct snd_ctl_elem_info *uinfo); | 
|  | 412 | int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, | 
|  | 413 | struct snd_ctl_elem_value *ucontrol); | 
|  | 414 | int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, | 
|  | 415 | struct snd_ctl_elem_value *ucontrol); | 
|  | 416 | int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol, | 
|  | 417 | struct snd_ctl_elem_value *ucontrol); | 
|  | 418 | int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol, | 
|  | 419 | struct snd_ctl_elem_value *ucontrol); | 
|  | 420 | int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, | 
|  | 421 | struct snd_ctl_elem_info *uinfo); | 
|  | 422 | int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, | 
|  | 423 | struct snd_ctl_elem_info *uinfo); | 
|  | 424 | #define snd_soc_info_bool_ext		snd_ctl_boolean_mono_info | 
|  | 425 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, | 
|  | 426 | struct snd_ctl_elem_value *ucontrol); | 
|  | 427 | int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, | 
|  | 428 | struct snd_ctl_elem_value *ucontrol); | 
|  | 429 | #define snd_soc_get_volsw_2r snd_soc_get_volsw | 
|  | 430 | #define snd_soc_put_volsw_2r snd_soc_put_volsw | 
|  | 431 | int snd_soc_info_volsw_s8_single(struct snd_kcontrol *kcontrol, | 
|  | 432 | struct snd_ctl_elem_info *uinfo); | 
|  | 433 | int snd_soc_get_volsw_s8_single(struct snd_kcontrol *kcontrol, | 
|  | 434 | struct snd_ctl_elem_value *ucontrol); | 
|  | 435 | int snd_soc_put_volsw_s8_single(struct snd_kcontrol *kcontrol, | 
|  | 436 | struct snd_ctl_elem_value *ucontrol); | 
|  | 437 | int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, | 
|  | 438 | struct snd_ctl_elem_info *uinfo); | 
|  | 439 | int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, | 
|  | 440 | struct snd_ctl_elem_value *ucontrol); | 
|  | 441 | int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol, | 
|  | 442 | struct snd_ctl_elem_value *ucontrol); | 
|  | 443 | int snd_soc_limit_volume(struct snd_soc_codec *codec, | 
|  | 444 | const char *name, int max); | 
|  | 445 | int snd_soc_info_volsw_2r_sx(struct snd_kcontrol *kcontrol, | 
|  | 446 | struct snd_ctl_elem_info *uinfo); | 
|  | 447 | int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol, | 
|  | 448 | struct snd_ctl_elem_value *ucontrol); | 
|  | 449 | int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol, | 
|  | 450 | struct snd_ctl_elem_value *ucontrol); | 
|  | 451 | int snd_soc_bytes_info(struct snd_kcontrol *kcontrol, | 
|  | 452 | struct snd_ctl_elem_info *uinfo); | 
|  | 453 | int snd_soc_bytes_get(struct snd_kcontrol *kcontrol, | 
|  | 454 | struct snd_ctl_elem_value *ucontrol); | 
|  | 455 | int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, | 
|  | 456 | struct snd_ctl_elem_value *ucontrol); | 
|  | 457 |  | 
|  | 458 |  | 
|  | 459 | /** | 
|  | 460 | * struct snd_soc_reg_access - Describes whether a given register is | 
|  | 461 | * readable, writable or volatile. | 
|  | 462 | * | 
|  | 463 | * @reg: the register number | 
|  | 464 | * @read: whether this register is readable | 
|  | 465 | * @write: whether this register is writable | 
|  | 466 | * @vol: whether this register is volatile | 
|  | 467 | */ | 
|  | 468 | struct snd_soc_reg_access { | 
|  | 469 | u16 reg; | 
|  | 470 | u16 read; | 
|  | 471 | u16 write; | 
|  | 472 | u16 vol; | 
|  | 473 | }; | 
|  | 474 |  | 
|  | 475 | /** | 
|  | 476 | * struct snd_soc_jack_pin - Describes a pin to update based on jack detection | 
|  | 477 | * | 
|  | 478 | * @pin:    name of the pin to update | 
|  | 479 | * @mask:   bits to check for in reported jack status | 
|  | 480 | * @invert: if non-zero then pin is enabled when status is not reported | 
|  | 481 | */ | 
|  | 482 | struct snd_soc_jack_pin { | 
|  | 483 | struct list_head list; | 
|  | 484 | const char *pin; | 
|  | 485 | int mask; | 
|  | 486 | bool invert; | 
|  | 487 | }; | 
|  | 488 |  | 
|  | 489 | /** | 
|  | 490 | * struct snd_soc_jack_zone - Describes voltage zones of jack detection | 
|  | 491 | * | 
|  | 492 | * @min_mv: start voltage in mv | 
|  | 493 | * @max_mv: end voltage in mv | 
|  | 494 | * @jack_type: type of jack that is expected for this voltage | 
|  | 495 | * @debounce_time: debounce_time for jack, codec driver should wait for this | 
|  | 496 | *		duration before reading the adc for voltages | 
|  | 497 | * @:list: list container | 
|  | 498 | */ | 
|  | 499 | struct snd_soc_jack_zone { | 
|  | 500 | unsigned int min_mv; | 
|  | 501 | unsigned int max_mv; | 
|  | 502 | unsigned int jack_type; | 
|  | 503 | unsigned int debounce_time; | 
|  | 504 | struct list_head list; | 
|  | 505 | }; | 
|  | 506 |  | 
|  | 507 | /** | 
|  | 508 | * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection | 
|  | 509 | * | 
|  | 510 | * @gpio:         gpio number | 
|  | 511 | * @name:         gpio name | 
|  | 512 | * @report:       value to report when jack detected | 
|  | 513 | * @invert:       report presence in low state | 
|  | 514 | * @debouce_time: debouce time in ms | 
|  | 515 | * @wake:	  enable as wake source | 
|  | 516 | * @jack_status_check: callback function which overrides the detection | 
|  | 517 | *		       to provide more complex checks (eg, reading an | 
|  | 518 | *		       ADC). | 
|  | 519 | */ | 
|  | 520 | #ifdef CONFIG_GPIOLIB | 
|  | 521 | struct snd_soc_jack_gpio { | 
|  | 522 | unsigned int gpio; | 
|  | 523 | const char *name; | 
|  | 524 | int report; | 
|  | 525 | int invert; | 
|  | 526 | int debounce_time; | 
|  | 527 | bool wake; | 
|  | 528 |  | 
|  | 529 | struct snd_soc_jack *jack; | 
|  | 530 | struct delayed_work work; | 
|  | 531 |  | 
|  | 532 | int (*jack_status_check)(void); | 
|  | 533 | }; | 
|  | 534 | #endif | 
|  | 535 |  | 
|  | 536 | struct snd_soc_jack { | 
|  | 537 | struct snd_jack *jack; | 
|  | 538 | struct snd_soc_codec *codec; | 
|  | 539 | struct list_head pins; | 
|  | 540 | int status; | 
|  | 541 | struct blocking_notifier_head notifier; | 
|  | 542 | struct list_head jack_zones; | 
|  | 543 | }; | 
|  | 544 |  | 
|  | 545 | /* SoC PCM stream information */ | 
|  | 546 | struct snd_soc_pcm_stream { | 
|  | 547 | const char *stream_name; | 
|  | 548 | u64 formats;			/* SNDRV_PCM_FMTBIT_* */ | 
|  | 549 | unsigned int rates;		/* SNDRV_PCM_RATE_* */ | 
|  | 550 | unsigned int rate_min;		/* min rate */ | 
|  | 551 | unsigned int rate_max;		/* max rate */ | 
|  | 552 | unsigned int channels_min;	/* min channels */ | 
|  | 553 | unsigned int channels_max;	/* max channels */ | 
|  | 554 | unsigned int sig_bits;		/* number of bits of content */ | 
|  | 555 | }; | 
|  | 556 |  | 
|  | 557 | /* SoC audio ops */ | 
|  | 558 | struct snd_soc_ops { | 
|  | 559 | int (*startup)(struct snd_pcm_substream *); | 
|  | 560 | void (*shutdown)(struct snd_pcm_substream *); | 
|  | 561 | int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *); | 
|  | 562 | int (*hw_free)(struct snd_pcm_substream *); | 
|  | 563 | int (*prepare)(struct snd_pcm_substream *); | 
|  | 564 | int (*trigger)(struct snd_pcm_substream *, int); | 
|  | 565 | }; | 
|  | 566 |  | 
|  | 567 | /* SoC cache ops */ | 
|  | 568 | struct snd_soc_cache_ops { | 
|  | 569 | const char *name; | 
|  | 570 | enum snd_soc_compress_type id; | 
|  | 571 | int (*init)(struct snd_soc_codec *codec); | 
|  | 572 | int (*exit)(struct snd_soc_codec *codec); | 
|  | 573 | int (*read)(struct snd_soc_codec *codec, unsigned int reg, | 
|  | 574 | unsigned int *value); | 
|  | 575 | int (*write)(struct snd_soc_codec *codec, unsigned int reg, | 
|  | 576 | unsigned int value); | 
|  | 577 | int (*sync)(struct snd_soc_codec *codec); | 
|  | 578 | }; | 
|  | 579 |  | 
|  | 580 | /* SoC Audio Codec device */ | 
|  | 581 | struct snd_soc_codec { | 
|  | 582 | const char *name; | 
|  | 583 | const char *name_prefix; | 
|  | 584 | int id; | 
|  | 585 | struct device *dev; | 
|  | 586 | const struct snd_soc_codec_driver *driver; | 
|  | 587 |  | 
|  | 588 | struct mutex mutex; | 
|  | 589 | struct snd_soc_card *card; | 
|  | 590 | struct list_head list; | 
|  | 591 | struct list_head card_list; | 
|  | 592 | int num_dai; | 
|  | 593 | enum snd_soc_compress_type compress_type; | 
|  | 594 | size_t reg_size;	/* reg_cache_size * reg_word_size */ | 
|  | 595 | int (*volatile_register)(struct snd_soc_codec *, unsigned int); | 
|  | 596 | int (*readable_register)(struct snd_soc_codec *, unsigned int); | 
|  | 597 | int (*writable_register)(struct snd_soc_codec *, unsigned int); | 
|  | 598 |  | 
|  | 599 | /* runtime */ | 
|  | 600 | struct snd_ac97 *ac97;  /* for ad-hoc ac97 devices */ | 
|  | 601 | unsigned int active; | 
|  | 602 | unsigned int cache_bypass:1; /* Suppress access to the cache */ | 
|  | 603 | unsigned int suspended:1; /* Codec is in suspend PM state */ | 
|  | 604 | unsigned int probed:1; /* Codec has been probed */ | 
|  | 605 | unsigned int ac97_registered:1; /* Codec has been AC97 registered */ | 
|  | 606 | unsigned int ac97_created:1; /* Codec has been created by SoC */ | 
|  | 607 | unsigned int sysfs_registered:1; /* codec has been sysfs registered */ | 
|  | 608 | unsigned int cache_init:1; /* codec cache has been initialized */ | 
|  | 609 | unsigned int using_regmap:1; /* using regmap access */ | 
|  | 610 | u32 cache_only;  /* Suppress writes to hardware */ | 
|  | 611 | u32 cache_sync; /* Cache needs to be synced to hardware */ | 
|  | 612 |  | 
|  | 613 | /* codec IO */ | 
|  | 614 | void *control_data; /* codec control (i2c/3wire) data */ | 
|  | 615 | enum snd_soc_control_type control_type; | 
|  | 616 | hw_write_t hw_write; | 
|  | 617 | unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); | 
|  | 618 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | 
|  | 619 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | 
|  | 620 | int (*bulk_write_raw)(struct snd_soc_codec *, unsigned int, const void *, size_t); | 
|  | 621 | void *reg_cache; | 
|  | 622 | const void *reg_def_copy; | 
|  | 623 | const struct snd_soc_cache_ops *cache_ops; | 
|  | 624 | struct mutex cache_rw_mutex; | 
|  | 625 | int val_bytes; | 
|  | 626 |  | 
|  | 627 | /* dapm */ | 
|  | 628 | struct snd_soc_dapm_context dapm; | 
|  | 629 | unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ | 
|  | 630 |  | 
|  | 631 | #ifdef CONFIG_DEBUG_FS | 
|  | 632 | struct dentry *debugfs_codec_root; | 
|  | 633 | struct dentry *debugfs_reg; | 
|  | 634 | struct dentry *debugfs_dapm; | 
|  | 635 | #endif | 
|  | 636 | }; | 
|  | 637 |  | 
|  | 638 | /* codec driver */ | 
|  | 639 | struct snd_soc_codec_driver { | 
|  | 640 |  | 
|  | 641 | /* driver ops */ | 
|  | 642 | int (*probe)(struct snd_soc_codec *); | 
|  | 643 | int (*remove)(struct snd_soc_codec *); | 
|  | 644 | int (*suspend)(struct snd_soc_codec *); | 
|  | 645 | int (*resume)(struct snd_soc_codec *); | 
|  | 646 |  | 
|  | 647 | /* Default control and setup, added after probe() is run */ | 
|  | 648 | const struct snd_kcontrol_new *controls; | 
|  | 649 | int num_controls; | 
|  | 650 | const struct snd_soc_dapm_widget *dapm_widgets; | 
|  | 651 | int num_dapm_widgets; | 
|  | 652 | const struct snd_soc_dapm_route *dapm_routes; | 
|  | 653 | int num_dapm_routes; | 
|  | 654 |  | 
|  | 655 | /* codec wide operations */ | 
|  | 656 | int (*set_sysclk)(struct snd_soc_codec *codec, | 
|  | 657 | int clk_id, int source, unsigned int freq, int dir); | 
|  | 658 | int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source, | 
|  | 659 | unsigned int freq_in, unsigned int freq_out); | 
|  | 660 |  | 
|  | 661 | /* codec IO */ | 
|  | 662 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | 
|  | 663 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | 
|  | 664 | int (*display_register)(struct snd_soc_codec *, char *, | 
|  | 665 | size_t, unsigned int); | 
|  | 666 | int (*volatile_register)(struct snd_soc_codec *, unsigned int); | 
|  | 667 | int (*readable_register)(struct snd_soc_codec *, unsigned int); | 
|  | 668 | int (*writable_register)(struct snd_soc_codec *, unsigned int); | 
|  | 669 | unsigned int reg_cache_size; | 
|  | 670 | short reg_cache_step; | 
|  | 671 | short reg_word_size; | 
|  | 672 | const void *reg_cache_default; | 
|  | 673 | short reg_access_size; | 
|  | 674 | const struct snd_soc_reg_access *reg_access_default; | 
|  | 675 | enum snd_soc_compress_type compress_type; | 
|  | 676 |  | 
|  | 677 | /* codec bias level */ | 
|  | 678 | int (*set_bias_level)(struct snd_soc_codec *, | 
|  | 679 | enum snd_soc_bias_level level); | 
|  | 680 | bool idle_bias_off; | 
|  | 681 |  | 
|  | 682 | void (*seq_notifier)(struct snd_soc_dapm_context *, | 
|  | 683 | enum snd_soc_dapm_type, int); | 
|  | 684 |  | 
|  | 685 | /* codec stream completion event */ | 
|  | 686 | int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); | 
|  | 687 |  | 
|  | 688 | bool ignore_pmdown_time;  /* Doesn't benefit from pmdown delay */ | 
|  | 689 |  | 
|  | 690 | /* probe ordering - for components with runtime dependencies */ | 
|  | 691 | int probe_order; | 
|  | 692 | int remove_order; | 
|  | 693 | }; | 
|  | 694 |  | 
|  | 695 | /* SoC platform interface */ | 
|  | 696 | struct snd_soc_platform_driver { | 
|  | 697 |  | 
|  | 698 | int (*probe)(struct snd_soc_platform *); | 
|  | 699 | int (*remove)(struct snd_soc_platform *); | 
|  | 700 | int (*suspend)(struct snd_soc_dai *dai); | 
|  | 701 | int (*resume)(struct snd_soc_dai *dai); | 
|  | 702 |  | 
|  | 703 | /* pcm creation and destruction */ | 
|  | 704 | int (*pcm_new)(struct snd_soc_pcm_runtime *); | 
|  | 705 | void (*pcm_free)(struct snd_pcm *); | 
|  | 706 |  | 
|  | 707 | /* Default control and setup, added after probe() is run */ | 
|  | 708 | const struct snd_kcontrol_new *controls; | 
|  | 709 | int num_controls; | 
|  | 710 | const struct snd_soc_dapm_widget *dapm_widgets; | 
|  | 711 | int num_dapm_widgets; | 
|  | 712 | const struct snd_soc_dapm_route *dapm_routes; | 
|  | 713 | int num_dapm_routes; | 
|  | 714 |  | 
|  | 715 | /* | 
|  | 716 | * For platform caused delay reporting. | 
|  | 717 | * Optional. | 
|  | 718 | */ | 
|  | 719 | snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *, | 
|  | 720 | struct snd_soc_dai *); | 
|  | 721 |  | 
|  | 722 | /* platform stream ops */ | 
|  | 723 | struct snd_pcm_ops *ops; | 
|  | 724 |  | 
|  | 725 | /* platform stream completion event */ | 
|  | 726 | int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); | 
|  | 727 |  | 
|  | 728 | /* probe ordering - for components with runtime dependencies */ | 
|  | 729 | int probe_order; | 
|  | 730 | int remove_order; | 
|  | 731 |  | 
|  | 732 | /* platform IO - used for platform DAPM */ | 
|  | 733 | unsigned int (*read)(struct snd_soc_platform *, unsigned int); | 
|  | 734 | int (*write)(struct snd_soc_platform *, unsigned int, unsigned int); | 
|  | 735 | }; | 
|  | 736 |  | 
|  | 737 | struct snd_soc_platform { | 
|  | 738 | const char *name; | 
|  | 739 | int id; | 
|  | 740 | struct device *dev; | 
|  | 741 | struct snd_soc_platform_driver *driver; | 
|  | 742 | struct mutex mutex; | 
|  | 743 |  | 
|  | 744 | unsigned int suspended:1; /* platform is suspended */ | 
|  | 745 | unsigned int probed:1; | 
|  | 746 |  | 
|  | 747 | struct snd_soc_card *card; | 
|  | 748 | struct list_head list; | 
|  | 749 | struct list_head card_list; | 
|  | 750 |  | 
|  | 751 | struct snd_soc_dapm_context dapm; | 
|  | 752 |  | 
|  | 753 | #ifdef CONFIG_DEBUG_FS | 
|  | 754 | struct dentry *debugfs_platform_root; | 
|  | 755 | struct dentry *debugfs_dapm; | 
|  | 756 | #endif | 
|  | 757 | }; | 
|  | 758 |  | 
|  | 759 | struct snd_soc_dai_link { | 
|  | 760 | /* config - must be set by machine driver */ | 
|  | 761 | const char *name;			/* Codec name */ | 
|  | 762 | const char *stream_name;		/* Stream name */ | 
|  | 763 | const char *codec_name;		/* for multi-codec */ | 
|  | 764 | const struct device_node *codec_of_node; | 
|  | 765 | const char *platform_name;	/* for multi-platform */ | 
|  | 766 | const struct device_node *platform_of_node; | 
|  | 767 | const char *cpu_dai_name; | 
|  | 768 | const struct device_node *cpu_dai_of_node; | 
|  | 769 | const char *codec_dai_name; | 
|  | 770 |  | 
|  | 771 | unsigned int dai_fmt;           /* format to set on init */ | 
|  | 772 |  | 
|  | 773 | /* Keep DAI active over suspend */ | 
|  | 774 | unsigned int ignore_suspend:1; | 
|  | 775 |  | 
|  | 776 | /* Symmetry requirements */ | 
|  | 777 | unsigned int symmetric_rates:1; | 
|  | 778 |  | 
|  | 779 | /* pmdown_time is ignored at stop */ | 
|  | 780 | unsigned int ignore_pmdown_time:1; | 
|  | 781 |  | 
|  | 782 | /* codec/machine specific init - e.g. add machine controls */ | 
|  | 783 | int (*init)(struct snd_soc_pcm_runtime *rtd); | 
|  | 784 |  | 
|  | 785 | /* machine stream operations */ | 
|  | 786 | struct snd_soc_ops *ops; | 
|  | 787 | }; | 
|  | 788 |  | 
|  | 789 | struct snd_soc_codec_conf { | 
|  | 790 | const char *dev_name; | 
|  | 791 |  | 
|  | 792 | /* | 
|  | 793 | * optional map of kcontrol, widget and path name prefixes that are | 
|  | 794 | * associated per device | 
|  | 795 | */ | 
|  | 796 | const char *name_prefix; | 
|  | 797 |  | 
|  | 798 | /* | 
|  | 799 | * set this to the desired compression type if you want to | 
|  | 800 | * override the one supplied in codec->driver->compress_type | 
|  | 801 | */ | 
|  | 802 | enum snd_soc_compress_type compress_type; | 
|  | 803 | }; | 
|  | 804 |  | 
|  | 805 | struct snd_soc_aux_dev { | 
|  | 806 | const char *name;		/* Codec name */ | 
|  | 807 | const char *codec_name;		/* for multi-codec */ | 
|  | 808 |  | 
|  | 809 | /* codec/machine specific init - e.g. add machine controls */ | 
|  | 810 | int (*init)(struct snd_soc_dapm_context *dapm); | 
|  | 811 | }; | 
|  | 812 |  | 
|  | 813 | /* SoC card */ | 
|  | 814 | struct snd_soc_card { | 
|  | 815 | const char *name; | 
|  | 816 | const char *long_name; | 
|  | 817 | const char *driver_name; | 
|  | 818 | struct device *dev; | 
|  | 819 | struct snd_card *snd_card; | 
|  | 820 | struct module *owner; | 
|  | 821 |  | 
|  | 822 | struct list_head list; | 
|  | 823 | struct mutex mutex; | 
|  | 824 | struct mutex dapm_mutex; | 
|  | 825 |  | 
|  | 826 | bool instantiated; | 
|  | 827 |  | 
|  | 828 | int (*probe)(struct snd_soc_card *card); | 
|  | 829 | int (*late_probe)(struct snd_soc_card *card); | 
|  | 830 | int (*remove)(struct snd_soc_card *card); | 
|  | 831 |  | 
|  | 832 | /* the pre and post PM functions are used to do any PM work before and | 
|  | 833 | * after the codec and DAI's do any PM work. */ | 
|  | 834 | int (*suspend_pre)(struct snd_soc_card *card); | 
|  | 835 | int (*suspend_post)(struct snd_soc_card *card); | 
|  | 836 | int (*resume_pre)(struct snd_soc_card *card); | 
|  | 837 | int (*resume_post)(struct snd_soc_card *card); | 
|  | 838 |  | 
|  | 839 | /* callbacks */ | 
|  | 840 | int (*set_bias_level)(struct snd_soc_card *, | 
|  | 841 | struct snd_soc_dapm_context *dapm, | 
|  | 842 | enum snd_soc_bias_level level); | 
|  | 843 | int (*set_bias_level_post)(struct snd_soc_card *, | 
|  | 844 | struct snd_soc_dapm_context *dapm, | 
|  | 845 | enum snd_soc_bias_level level); | 
|  | 846 |  | 
|  | 847 | long pmdown_time; | 
|  | 848 |  | 
|  | 849 | /* CPU <--> Codec DAI links  */ | 
|  | 850 | struct snd_soc_dai_link *dai_link; | 
|  | 851 | int num_links; | 
|  | 852 | struct snd_soc_pcm_runtime *rtd; | 
|  | 853 | int num_rtd; | 
|  | 854 |  | 
|  | 855 | /* optional codec specific configuration */ | 
|  | 856 | struct snd_soc_codec_conf *codec_conf; | 
|  | 857 | int num_configs; | 
|  | 858 |  | 
|  | 859 | /* | 
|  | 860 | * optional auxiliary devices such as amplifiers or codecs with DAI | 
|  | 861 | * link unused | 
|  | 862 | */ | 
|  | 863 | struct snd_soc_aux_dev *aux_dev; | 
|  | 864 | int num_aux_devs; | 
|  | 865 | struct snd_soc_pcm_runtime *rtd_aux; | 
|  | 866 | int num_aux_rtd; | 
|  | 867 |  | 
|  | 868 | const struct snd_kcontrol_new *controls; | 
|  | 869 | int num_controls; | 
|  | 870 |  | 
|  | 871 | /* | 
|  | 872 | * Card-specific routes and widgets. | 
|  | 873 | */ | 
|  | 874 | const struct snd_soc_dapm_widget *dapm_widgets; | 
|  | 875 | int num_dapm_widgets; | 
|  | 876 | const struct snd_soc_dapm_route *dapm_routes; | 
|  | 877 | int num_dapm_routes; | 
|  | 878 | bool fully_routed; | 
|  | 879 |  | 
|  | 880 | struct work_struct deferred_resume_work; | 
|  | 881 |  | 
|  | 882 | /* lists of probed devices belonging to this card */ | 
|  | 883 | struct list_head codec_dev_list; | 
|  | 884 | struct list_head platform_dev_list; | 
|  | 885 | struct list_head dai_dev_list; | 
|  | 886 |  | 
|  | 887 | struct list_head widgets; | 
|  | 888 | struct list_head paths; | 
|  | 889 | struct list_head dapm_list; | 
|  | 890 | struct list_head dapm_dirty; | 
|  | 891 |  | 
|  | 892 | /* Generic DAPM context for the card */ | 
|  | 893 | struct snd_soc_dapm_context dapm; | 
|  | 894 | struct snd_soc_dapm_stats dapm_stats; | 
|  | 895 |  | 
|  | 896 | #ifdef CONFIG_DEBUG_FS | 
|  | 897 | struct dentry *debugfs_card_root; | 
|  | 898 | struct dentry *debugfs_pop_time; | 
|  | 899 | #endif | 
|  | 900 | u32 pop_time; | 
|  | 901 |  | 
|  | 902 | void *drvdata; | 
|  | 903 | }; | 
|  | 904 |  | 
|  | 905 | /* SoC machine DAI configuration, glues a codec and cpu DAI together */ | 
|  | 906 | struct snd_soc_pcm_runtime { | 
|  | 907 | struct device *dev; | 
|  | 908 | struct snd_soc_card *card; | 
|  | 909 | struct snd_soc_dai_link *dai_link; | 
|  | 910 | struct mutex pcm_mutex; | 
|  | 911 | enum snd_soc_pcm_subclass pcm_subclass; | 
|  | 912 | struct snd_pcm_ops ops; | 
|  | 913 |  | 
|  | 914 | unsigned int complete:1; | 
|  | 915 | unsigned int dev_registered:1; | 
|  | 916 |  | 
|  | 917 | long pmdown_time; | 
|  | 918 |  | 
|  | 919 | /* runtime devices */ | 
|  | 920 | struct snd_pcm *pcm; | 
|  | 921 | struct snd_soc_codec *codec; | 
|  | 922 | struct snd_soc_platform *platform; | 
|  | 923 | struct snd_soc_dai *codec_dai; | 
|  | 924 | struct snd_soc_dai *cpu_dai; | 
|  | 925 |  | 
|  | 926 | struct delayed_work delayed_work; | 
|  | 927 | }; | 
|  | 928 |  | 
|  | 929 | /* mixer control */ | 
|  | 930 | /*struct soc_mixer_control { | 
|  | 931 | int min, max, platform_max; | 
|  | 932 | unsigned int reg, rreg, shift, rshift, invert; | 
|  | 933 | };*/ | 
|  | 934 | /* mixer control */ | 
|  | 935 | struct soc_mixer_control { | 
|  | 936 | int min, max, platform_max; | 
|  | 937 | int reg, rreg; | 
|  | 938 | unsigned int shift, rshift; | 
|  | 939 | unsigned int sign_bit; | 
|  | 940 | unsigned int invert:1; | 
|  | 941 | unsigned int autodisable:1; | 
|  | 942 | //struct snd_soc_dobj dobj; | 
|  | 943 | }; | 
|  | 944 | struct soc_bytes { | 
|  | 945 | int base; | 
|  | 946 | int num_regs; | 
|  | 947 | u32 mask; | 
|  | 948 | }; | 
|  | 949 |  | 
|  | 950 | /* enumerated kcontrol */ | 
|  | 951 | struct soc_enum { | 
|  | 952 | unsigned short reg; | 
|  | 953 | unsigned short reg2; | 
|  | 954 | unsigned char shift_l; | 
|  | 955 | unsigned char shift_r; | 
|  | 956 | unsigned int max; | 
|  | 957 | unsigned int mask; | 
|  | 958 | const char * const *texts; | 
|  | 959 | const unsigned int *values; | 
|  | 960 | void *dapm; | 
|  | 961 | }; | 
|  | 962 |  | 
|  | 963 | /* codec IO */ | 
|  | 964 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); | 
|  | 965 | unsigned int snd_soc_write(struct snd_soc_codec *codec, | 
|  | 966 | unsigned int reg, unsigned int val); | 
|  | 967 | unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec, | 
|  | 968 | unsigned int reg, const void *data, size_t len); | 
|  | 969 |  | 
|  | 970 | /* device driver data */ | 
|  | 971 |  | 
|  | 972 | static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card, | 
|  | 973 | void *data) | 
|  | 974 | { | 
|  | 975 | card->drvdata = data; | 
|  | 976 | } | 
|  | 977 |  | 
|  | 978 | static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card) | 
|  | 979 | { | 
|  | 980 | return card->drvdata; | 
|  | 981 | } | 
|  | 982 |  | 
|  | 983 | static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, | 
|  | 984 | void *data) | 
|  | 985 | { | 
|  | 986 | dev_set_drvdata(codec->dev, data); | 
|  | 987 | } | 
|  | 988 |  | 
|  | 989 | static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec) | 
|  | 990 | { | 
|  | 991 | return dev_get_drvdata(codec->dev); | 
|  | 992 | } | 
|  | 993 |  | 
|  | 994 | static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform, | 
|  | 995 | void *data) | 
|  | 996 | { | 
|  | 997 | dev_set_drvdata(platform->dev, data); | 
|  | 998 | } | 
|  | 999 |  | 
|  | 1000 | static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform) | 
|  | 1001 | { | 
|  | 1002 | return dev_get_drvdata(platform->dev); | 
|  | 1003 | } | 
|  | 1004 |  | 
|  | 1005 | static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd, | 
|  | 1006 | void *data) | 
|  | 1007 | { | 
|  | 1008 | dev_set_drvdata(rtd->dev, data); | 
|  | 1009 | } | 
|  | 1010 |  | 
|  | 1011 | static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd) | 
|  | 1012 | { | 
|  | 1013 | return dev_get_drvdata(rtd->dev); | 
|  | 1014 | } | 
|  | 1015 |  | 
|  | 1016 | static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) | 
|  | 1017 | { | 
|  | 1018 | INIT_LIST_HEAD(&card->dai_dev_list); | 
|  | 1019 | INIT_LIST_HEAD(&card->codec_dev_list); | 
|  | 1020 | INIT_LIST_HEAD(&card->platform_dev_list); | 
|  | 1021 | INIT_LIST_HEAD(&card->widgets); | 
|  | 1022 | INIT_LIST_HEAD(&card->paths); | 
|  | 1023 | INIT_LIST_HEAD(&card->dapm_list); | 
|  | 1024 | } | 
|  | 1025 |  | 
|  | 1026 | static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc) | 
|  | 1027 | { | 
|  | 1028 | if (mc->reg == mc->rreg && mc->shift == mc->rshift) | 
|  | 1029 | return 0; | 
|  | 1030 | /* | 
|  | 1031 | * mc->reg == mc->rreg && mc->shift != mc->rshift, or | 
|  | 1032 | * mc->reg != mc->rreg means that the control is | 
|  | 1033 | * stereo (bits in one register or in two registers) | 
|  | 1034 | */ | 
|  | 1035 | return 1; | 
|  | 1036 | } | 
|  | 1037 |  | 
|  | 1038 | int snd_soc_util_init(void); | 
|  | 1039 | void snd_soc_util_exit(void); | 
|  | 1040 |  | 
|  | 1041 | int snd_soc_of_parse_card_name(struct snd_soc_card *card, | 
|  | 1042 | const char *propname); | 
|  | 1043 | int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | 
|  | 1044 | const char *propname); | 
|  | 1045 |  | 
|  | 1046 | #include <sound/soc-dai.h> | 
|  | 1047 |  | 
|  | 1048 | #ifdef CONFIG_DEBUG_FS | 
|  | 1049 | extern struct dentry *snd_soc_debugfs_root; | 
|  | 1050 | #endif | 
|  | 1051 |  | 
|  | 1052 | extern const struct dev_pm_ops snd_soc_pm_ops; | 
|  | 1053 |  | 
|  | 1054 | #endif |