diff options
Diffstat (limited to 'include/sound/soc.h')
| -rw-r--r-- | include/sound/soc.h | 206 |
1 files changed, 36 insertions, 170 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index 5e0189876afd..f86e455d3828 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
| @@ -21,8 +21,6 @@ | |||
| 21 | #include <sound/control.h> | 21 | #include <sound/control.h> |
| 22 | #include <sound/ac97_codec.h> | 22 | #include <sound/ac97_codec.h> |
| 23 | 23 | ||
| 24 | #define SND_SOC_VERSION "0.13.2" | ||
| 25 | |||
| 26 | /* | 24 | /* |
| 27 | * Convenience kcontrol builders | 25 | * Convenience kcontrol builders |
| 28 | */ | 26 | */ |
| @@ -145,105 +143,31 @@ enum snd_soc_bias_level { | |||
| 145 | SND_SOC_BIAS_OFF, | 143 | SND_SOC_BIAS_OFF, |
| 146 | }; | 144 | }; |
| 147 | 145 | ||
| 148 | /* | ||
| 149 | * Digital Audio Interface (DAI) types | ||
| 150 | */ | ||
| 151 | #define SND_SOC_DAI_AC97 0x1 | ||
| 152 | #define SND_SOC_DAI_I2S 0x2 | ||
| 153 | #define SND_SOC_DAI_PCM 0x4 | ||
| 154 | #define SND_SOC_DAI_AC97_BUS 0x8 /* for custom i.e. non ac97_codec.c */ | ||
| 155 | |||
| 156 | /* | ||
| 157 | * DAI hardware audio formats | ||
| 158 | */ | ||
| 159 | #define SND_SOC_DAIFMT_I2S 0 /* I2S mode */ | ||
| 160 | #define SND_SOC_DAIFMT_RIGHT_J 1 /* Right justified mode */ | ||
| 161 | #define SND_SOC_DAIFMT_LEFT_J 2 /* Left Justified mode */ | ||
| 162 | #define SND_SOC_DAIFMT_DSP_A 3 /* L data msb after FRM or LRC */ | ||
| 163 | #define SND_SOC_DAIFMT_DSP_B 4 /* L data msb during FRM or LRC */ | ||
| 164 | #define SND_SOC_DAIFMT_AC97 5 /* AC97 */ | ||
| 165 | |||
| 166 | #define SND_SOC_DAIFMT_MSB SND_SOC_DAIFMT_LEFT_J | ||
| 167 | #define SND_SOC_DAIFMT_LSB SND_SOC_DAIFMT_RIGHT_J | ||
| 168 | |||
| 169 | /* | ||
| 170 | * DAI Gating | ||
| 171 | */ | ||
| 172 | #define SND_SOC_DAIFMT_CONT (0 << 4) /* continuous clock */ | ||
| 173 | #define SND_SOC_DAIFMT_GATED (1 << 4) /* clock is gated when not Tx/Rx */ | ||
| 174 | |||
| 175 | /* | ||
| 176 | * DAI Sync | ||
| 177 | * Synchronous LR (Left Right) clocks and Frame signals. | ||
| 178 | */ | ||
| 179 | #define SND_SOC_DAIFMT_SYNC (0 << 5) /* Tx FRM = Rx FRM */ | ||
| 180 | #define SND_SOC_DAIFMT_ASYNC (1 << 5) /* Tx FRM ~ Rx FRM */ | ||
| 181 | |||
| 182 | /* | ||
| 183 | * TDM | ||
| 184 | */ | ||
| 185 | #define SND_SOC_DAIFMT_TDM (1 << 6) | ||
| 186 | |||
| 187 | /* | ||
| 188 | * DAI hardware signal inversions | ||
| 189 | */ | ||
| 190 | #define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bclk + frm */ | ||
| 191 | #define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal bclk + inv frm */ | ||
| 192 | #define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert bclk + nor frm */ | ||
| 193 | #define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert bclk + frm */ | ||
| 194 | |||
| 195 | /* | ||
| 196 | * DAI hardware clock masters | ||
| 197 | * This is wrt the codec, the inverse is true for the interface | ||
| 198 | * i.e. if the codec is clk and frm master then the interface is | ||
| 199 | * clk and frame slave. | ||
| 200 | */ | ||
| 201 | #define SND_SOC_DAIFMT_CBM_CFM (0 << 12) /* codec clk & frm master */ | ||
| 202 | #define SND_SOC_DAIFMT_CBS_CFM (1 << 12) /* codec clk slave & frm master */ | ||
| 203 | #define SND_SOC_DAIFMT_CBM_CFS (2 << 12) /* codec clk master & frame slave */ | ||
| 204 | #define SND_SOC_DAIFMT_CBS_CFS (3 << 12) /* codec clk & frm slave */ | ||
| 205 | |||
| 206 | #define SND_SOC_DAIFMT_FORMAT_MASK 0x000f | ||
| 207 | #define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0 | ||
| 208 | #define SND_SOC_DAIFMT_INV_MASK 0x0f00 | ||
| 209 | #define SND_SOC_DAIFMT_MASTER_MASK 0xf000 | ||
| 210 | |||
| 211 | |||
| 212 | /* | ||
| 213 | * Master Clock Directions | ||
| 214 | */ | ||
| 215 | #define SND_SOC_CLOCK_IN 0 | ||
| 216 | #define SND_SOC_CLOCK_OUT 1 | ||
| 217 | |||
| 218 | /* | ||
| 219 | * AC97 codec ID's bitmask | ||
| 220 | */ | ||
| 221 | #define SND_SOC_DAI_AC97_ID0 (1 << 0) | ||
| 222 | #define SND_SOC_DAI_AC97_ID1 (1 << 1) | ||
| 223 | #define SND_SOC_DAI_AC97_ID2 (1 << 2) | ||
| 224 | #define SND_SOC_DAI_AC97_ID3 (1 << 3) | ||
| 225 | |||
| 226 | struct snd_soc_device; | 146 | struct snd_soc_device; |
| 227 | struct snd_soc_pcm_stream; | 147 | struct snd_soc_pcm_stream; |
| 228 | struct snd_soc_ops; | 148 | struct snd_soc_ops; |
| 229 | struct snd_soc_dai_mode; | 149 | struct snd_soc_dai_mode; |
| 230 | struct snd_soc_pcm_runtime; | 150 | struct snd_soc_pcm_runtime; |
| 231 | struct snd_soc_dai; | 151 | struct snd_soc_dai; |
| 152 | struct snd_soc_platform; | ||
| 232 | struct snd_soc_codec; | 153 | struct snd_soc_codec; |
| 233 | struct snd_soc_machine_config; | ||
| 234 | struct soc_enum; | 154 | struct soc_enum; |
| 235 | struct snd_soc_ac97_ops; | 155 | struct snd_soc_ac97_ops; |
| 236 | struct snd_soc_clock_info; | ||
| 237 | 156 | ||
| 238 | typedef int (*hw_write_t)(void *,const char* ,int); | 157 | typedef int (*hw_write_t)(void *,const char* ,int); |
| 239 | typedef int (*hw_read_t)(void *,char* ,int); | 158 | typedef int (*hw_read_t)(void *,char* ,int); |
| 240 | 159 | ||
| 241 | extern struct snd_ac97_bus_ops soc_ac97_ops; | 160 | extern struct snd_ac97_bus_ops soc_ac97_ops; |
| 242 | 161 | ||
| 162 | int snd_soc_register_platform(struct snd_soc_platform *platform); | ||
| 163 | void snd_soc_unregister_platform(struct snd_soc_platform *platform); | ||
| 164 | int snd_soc_register_codec(struct snd_soc_codec *codec); | ||
| 165 | void snd_soc_unregister_codec(struct snd_soc_codec *codec); | ||
| 166 | |||
| 243 | /* pcm <-> DAI connect */ | 167 | /* pcm <-> DAI connect */ |
| 244 | void snd_soc_free_pcms(struct snd_soc_device *socdev); | 168 | void snd_soc_free_pcms(struct snd_soc_device *socdev); |
| 245 | int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid); | 169 | int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid); |
| 246 | int snd_soc_register_card(struct snd_soc_device *socdev); | 170 | int snd_soc_init_card(struct snd_soc_device *socdev); |
| 247 | 171 | ||
| 248 | /* set runtime hw params */ | 172 | /* set runtime hw params */ |
| 249 | int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, | 173 | int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, |
| @@ -263,27 +187,6 @@ int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, | |||
| 263 | struct snd_ac97_bus_ops *ops, int num); | 187 | struct snd_ac97_bus_ops *ops, int num); |
| 264 | void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); | 188 | void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); |
| 265 | 189 | ||
| 266 | /* Digital Audio Interface clocking API.*/ | ||
| 267 | int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, | ||
| 268 | unsigned int freq, int dir); | ||
| 269 | |||
| 270 | int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, | ||
| 271 | int div_id, int div); | ||
| 272 | |||
| 273 | int snd_soc_dai_set_pll(struct snd_soc_dai *dai, | ||
| 274 | int pll_id, unsigned int freq_in, unsigned int freq_out); | ||
| 275 | |||
| 276 | /* Digital Audio interface formatting */ | ||
| 277 | int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt); | ||
| 278 | |||
| 279 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, | ||
| 280 | unsigned int mask, int slots); | ||
| 281 | |||
| 282 | int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate); | ||
| 283 | |||
| 284 | /* Digital Audio Interface mute */ | ||
| 285 | int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute); | ||
| 286 | |||
| 287 | /* | 190 | /* |
| 288 | *Controls | 191 | *Controls |
| 289 | */ | 192 | */ |
| @@ -341,66 +244,14 @@ struct snd_soc_ops { | |||
| 341 | int (*trigger)(struct snd_pcm_substream *, int); | 244 | int (*trigger)(struct snd_pcm_substream *, int); |
| 342 | }; | 245 | }; |
| 343 | 246 | ||
| 344 | /* ASoC DAI ops */ | ||
| 345 | struct snd_soc_dai_ops { | ||
| 346 | /* DAI clocking configuration */ | ||
| 347 | int (*set_sysclk)(struct snd_soc_dai *dai, | ||
| 348 | int clk_id, unsigned int freq, int dir); | ||
| 349 | int (*set_pll)(struct snd_soc_dai *dai, | ||
| 350 | int pll_id, unsigned int freq_in, unsigned int freq_out); | ||
| 351 | int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div); | ||
| 352 | |||
| 353 | /* DAI format configuration */ | ||
| 354 | int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt); | ||
| 355 | int (*set_tdm_slot)(struct snd_soc_dai *dai, | ||
| 356 | unsigned int mask, int slots); | ||
| 357 | int (*set_tristate)(struct snd_soc_dai *dai, int tristate); | ||
| 358 | |||
| 359 | /* digital mute */ | ||
| 360 | int (*digital_mute)(struct snd_soc_dai *dai, int mute); | ||
| 361 | }; | ||
| 362 | |||
| 363 | /* SoC DAI (Digital Audio Interface) */ | ||
| 364 | struct snd_soc_dai { | ||
| 365 | /* DAI description */ | ||
| 366 | char *name; | ||
| 367 | unsigned int id; | ||
| 368 | unsigned char type; | ||
| 369 | |||
| 370 | /* DAI callbacks */ | ||
| 371 | int (*probe)(struct platform_device *pdev, | ||
| 372 | struct snd_soc_dai *dai); | ||
| 373 | void (*remove)(struct platform_device *pdev, | ||
| 374 | struct snd_soc_dai *dai); | ||
| 375 | int (*suspend)(struct platform_device *pdev, | ||
| 376 | struct snd_soc_dai *dai); | ||
| 377 | int (*resume)(struct platform_device *pdev, | ||
| 378 | struct snd_soc_dai *dai); | ||
| 379 | |||
| 380 | /* ops */ | ||
| 381 | struct snd_soc_ops ops; | ||
| 382 | struct snd_soc_dai_ops dai_ops; | ||
| 383 | |||
| 384 | /* DAI capabilities */ | ||
| 385 | struct snd_soc_pcm_stream capture; | ||
| 386 | struct snd_soc_pcm_stream playback; | ||
| 387 | |||
| 388 | /* DAI runtime info */ | ||
| 389 | struct snd_pcm_runtime *runtime; | ||
| 390 | struct snd_soc_codec *codec; | ||
| 391 | unsigned int active; | ||
| 392 | unsigned char pop_wait:1; | ||
| 393 | void *dma_data; | ||
| 394 | |||
| 395 | /* DAI private data */ | ||
| 396 | void *private_data; | ||
| 397 | }; | ||
| 398 | |||
| 399 | /* SoC Audio Codec */ | 247 | /* SoC Audio Codec */ |
| 400 | struct snd_soc_codec { | 248 | struct snd_soc_codec { |
| 401 | char *name; | 249 | char *name; |
| 402 | struct module *owner; | 250 | struct module *owner; |
| 403 | struct mutex mutex; | 251 | struct mutex mutex; |
| 252 | struct device *dev; | ||
| 253 | |||
| 254 | struct list_head list; | ||
| 404 | 255 | ||
| 405 | /* callbacks */ | 256 | /* callbacks */ |
| 406 | int (*set_bias_level)(struct snd_soc_codec *, | 257 | int (*set_bias_level)(struct snd_soc_codec *, |
| @@ -426,6 +277,7 @@ struct snd_soc_codec { | |||
| 426 | short reg_cache_step; | 277 | short reg_cache_step; |
| 427 | 278 | ||
| 428 | /* dapm */ | 279 | /* dapm */ |
| 280 | u32 pop_time; | ||
| 429 | struct list_head dapm_widgets; | 281 | struct list_head dapm_widgets; |
| 430 | struct list_head dapm_paths; | 282 | struct list_head dapm_paths; |
| 431 | enum snd_soc_bias_level bias_level; | 283 | enum snd_soc_bias_level bias_level; |
| @@ -435,6 +287,11 @@ struct snd_soc_codec { | |||
| 435 | /* codec DAI's */ | 287 | /* codec DAI's */ |
| 436 | struct snd_soc_dai *dai; | 288 | struct snd_soc_dai *dai; |
| 437 | unsigned int num_dai; | 289 | unsigned int num_dai; |
| 290 | |||
| 291 | #ifdef CONFIG_DEBUG_FS | ||
| 292 | struct dentry *debugfs_reg; | ||
| 293 | struct dentry *debugfs_pop_time; | ||
| 294 | #endif | ||
| 438 | }; | 295 | }; |
| 439 | 296 | ||
| 440 | /* codec device */ | 297 | /* codec device */ |
| @@ -448,13 +305,12 @@ struct snd_soc_codec_device { | |||
| 448 | /* SoC platform interface */ | 305 | /* SoC platform interface */ |
| 449 | struct snd_soc_platform { | 306 | struct snd_soc_platform { |
| 450 | char *name; | 307 | char *name; |
| 308 | struct list_head list; | ||
| 451 | 309 | ||
| 452 | int (*probe)(struct platform_device *pdev); | 310 | int (*probe)(struct platform_device *pdev); |
| 453 | int (*remove)(struct platform_device *pdev); | 311 | int (*remove)(struct platform_device *pdev); |
| 454 | int (*suspend)(struct platform_device *pdev, | 312 | int (*suspend)(struct snd_soc_dai *dai); |
| 455 | struct snd_soc_dai *dai); | 313 | int (*resume)(struct snd_soc_dai *dai); |
| 456 | int (*resume)(struct platform_device *pdev, | ||
| 457 | struct snd_soc_dai *dai); | ||
| 458 | 314 | ||
| 459 | /* pcm creation and destruction */ | 315 | /* pcm creation and destruction */ |
| 460 | int (*pcm_new)(struct snd_card *, struct snd_soc_dai *, | 316 | int (*pcm_new)(struct snd_card *, struct snd_soc_dai *, |
| @@ -484,9 +340,14 @@ struct snd_soc_dai_link { | |||
| 484 | struct snd_pcm *pcm; | 340 | struct snd_pcm *pcm; |
| 485 | }; | 341 | }; |
| 486 | 342 | ||
| 487 | /* SoC machine */ | 343 | /* SoC card */ |
| 488 | struct snd_soc_machine { | 344 | struct snd_soc_card { |
| 489 | char *name; | 345 | char *name; |
| 346 | struct device *dev; | ||
| 347 | |||
| 348 | struct list_head list; | ||
| 349 | |||
| 350 | int instantiated; | ||
| 490 | 351 | ||
| 491 | int (*probe)(struct platform_device *pdev); | 352 | int (*probe)(struct platform_device *pdev); |
| 492 | int (*remove)(struct platform_device *pdev); | 353 | int (*remove)(struct platform_device *pdev); |
| @@ -499,23 +360,26 @@ struct snd_soc_machine { | |||
| 499 | int (*resume_post)(struct platform_device *pdev); | 360 | int (*resume_post)(struct platform_device *pdev); |
| 500 | 361 | ||
| 501 | /* callbacks */ | 362 | /* callbacks */ |
| 502 | int (*set_bias_level)(struct snd_soc_machine *, | 363 | int (*set_bias_level)(struct snd_soc_card *, |
| 503 | enum snd_soc_bias_level level); | 364 | enum snd_soc_bias_level level); |
| 504 | 365 | ||
| 505 | /* CPU <--> Codec DAI links */ | 366 | /* CPU <--> Codec DAI links */ |
| 506 | struct snd_soc_dai_link *dai_link; | 367 | struct snd_soc_dai_link *dai_link; |
| 507 | int num_links; | 368 | int num_links; |
| 369 | |||
| 370 | struct snd_soc_device *socdev; | ||
| 371 | |||
| 372 | struct snd_soc_platform *platform; | ||
| 373 | struct delayed_work delayed_work; | ||
| 374 | struct work_struct deferred_resume_work; | ||
| 508 | }; | 375 | }; |
| 509 | 376 | ||
| 510 | /* SoC Device - the audio subsystem */ | 377 | /* SoC Device - the audio subsystem */ |
| 511 | struct snd_soc_device { | 378 | struct snd_soc_device { |
| 512 | struct device *dev; | 379 | struct device *dev; |
| 513 | struct snd_soc_machine *machine; | 380 | struct snd_soc_card *card; |
| 514 | struct snd_soc_platform *platform; | ||
| 515 | struct snd_soc_codec *codec; | 381 | struct snd_soc_codec *codec; |
| 516 | struct snd_soc_codec_device *codec_dev; | 382 | struct snd_soc_codec_device *codec_dev; |
| 517 | struct delayed_work delayed_work; | ||
| 518 | struct work_struct deferred_resume_work; | ||
| 519 | void *codec_data; | 383 | void *codec_data; |
| 520 | }; | 384 | }; |
| 521 | 385 | ||
| @@ -542,4 +406,6 @@ struct soc_enum { | |||
| 542 | void *dapm; | 406 | void *dapm; |
| 543 | }; | 407 | }; |
| 544 | 408 | ||
| 409 | #include <sound/soc-dai.h> | ||
| 410 | |||
| 545 | #endif | 411 | #endif |
