diff options
Diffstat (limited to 'include/sound/soc.h')
-rw-r--r-- | include/sound/soc.h | 503 |
1 files changed, 383 insertions, 120 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index 65e9d03ed4f5..3a4bd3a3c68d 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -214,27 +214,31 @@ | |||
214 | * @OFF: Power Off. No restrictions on transition times. | 214 | * @OFF: Power Off. No restrictions on transition times. |
215 | */ | 215 | */ |
216 | enum snd_soc_bias_level { | 216 | enum snd_soc_bias_level { |
217 | SND_SOC_BIAS_ON, | ||
218 | SND_SOC_BIAS_PREPARE, | ||
219 | SND_SOC_BIAS_STANDBY, | ||
220 | SND_SOC_BIAS_OFF, | 217 | SND_SOC_BIAS_OFF, |
218 | SND_SOC_BIAS_STANDBY, | ||
219 | SND_SOC_BIAS_PREPARE, | ||
220 | SND_SOC_BIAS_ON, | ||
221 | }; | 221 | }; |
222 | 222 | ||
223 | struct snd_jack; | 223 | struct snd_jack; |
224 | struct snd_soc_card; | 224 | struct snd_soc_card; |
225 | struct snd_soc_device; | ||
226 | struct snd_soc_pcm_stream; | 225 | struct snd_soc_pcm_stream; |
227 | struct snd_soc_ops; | 226 | struct snd_soc_ops; |
228 | struct snd_soc_dai_mode; | ||
229 | struct snd_soc_pcm_runtime; | 227 | struct snd_soc_pcm_runtime; |
230 | struct snd_soc_dai; | 228 | struct snd_soc_dai; |
229 | struct snd_soc_dai_driver; | ||
231 | struct snd_soc_platform; | 230 | struct snd_soc_platform; |
232 | struct snd_soc_dai_link; | 231 | struct snd_soc_dai_link; |
232 | struct snd_soc_platform_driver; | ||
233 | struct snd_soc_codec; | 233 | struct snd_soc_codec; |
234 | struct snd_soc_codec_driver; | ||
234 | struct soc_enum; | 235 | struct soc_enum; |
235 | struct snd_soc_ac97_ops; | ||
236 | struct snd_soc_jack; | 236 | struct snd_soc_jack; |
237 | struct snd_soc_jack_zone; | ||
237 | struct snd_soc_jack_pin; | 238 | struct snd_soc_jack_pin; |
239 | struct snd_soc_cache_ops; | ||
240 | #include <sound/soc-dapm.h> | ||
241 | |||
238 | #ifdef CONFIG_GPIOLIB | 242 | #ifdef CONFIG_GPIOLIB |
239 | struct snd_soc_jack_gpio; | 243 | struct snd_soc_jack_gpio; |
240 | #endif | 244 | #endif |
@@ -244,23 +248,55 @@ typedef int (*hw_write_t)(void *,const char* ,int); | |||
244 | extern struct snd_ac97_bus_ops soc_ac97_ops; | 248 | extern struct snd_ac97_bus_ops soc_ac97_ops; |
245 | 249 | ||
246 | enum snd_soc_control_type { | 250 | enum snd_soc_control_type { |
247 | SND_SOC_CUSTOM, | 251 | SND_SOC_I2C = 1, |
248 | SND_SOC_I2C, | ||
249 | SND_SOC_SPI, | 252 | SND_SOC_SPI, |
250 | }; | 253 | }; |
251 | 254 | ||
252 | int snd_soc_register_platform(struct snd_soc_platform *platform); | 255 | enum snd_soc_compress_type { |
253 | void snd_soc_unregister_platform(struct snd_soc_platform *platform); | 256 | SND_SOC_FLAT_COMPRESSION = 1, |
254 | int snd_soc_register_codec(struct snd_soc_codec *codec); | 257 | SND_SOC_LZO_COMPRESSION, |
255 | void snd_soc_unregister_codec(struct snd_soc_codec *codec); | 258 | SND_SOC_RBTREE_COMPRESSION |
256 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg); | 259 | }; |
260 | |||
261 | int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id, | ||
262 | unsigned int freq, int dir); | ||
263 | int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, | ||
264 | unsigned int freq_in, unsigned int freq_out); | ||
265 | |||
266 | int snd_soc_register_card(struct snd_soc_card *card); | ||
267 | int snd_soc_unregister_card(struct snd_soc_card *card); | ||
268 | int snd_soc_suspend(struct device *dev); | ||
269 | int snd_soc_resume(struct device *dev); | ||
270 | int snd_soc_poweroff(struct device *dev); | ||
271 | int snd_soc_register_platform(struct device *dev, | ||
272 | struct snd_soc_platform_driver *platform_drv); | ||
273 | void snd_soc_unregister_platform(struct device *dev); | ||
274 | int snd_soc_register_codec(struct device *dev, | ||
275 | const struct snd_soc_codec_driver *codec_drv, | ||
276 | struct snd_soc_dai_driver *dai_drv, int num_dai); | ||
277 | void snd_soc_unregister_codec(struct device *dev); | ||
278 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, | ||
279 | unsigned int reg); | ||
280 | int snd_soc_codec_readable_register(struct snd_soc_codec *codec, | ||
281 | unsigned int reg); | ||
282 | int snd_soc_codec_writable_register(struct snd_soc_codec *codec, | ||
283 | unsigned int reg); | ||
257 | int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, | 284 | int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, |
258 | int addr_bits, int data_bits, | 285 | int addr_bits, int data_bits, |
259 | enum snd_soc_control_type control); | 286 | enum snd_soc_control_type control); |
260 | 287 | int snd_soc_cache_sync(struct snd_soc_codec *codec); | |
261 | /* pcm <-> DAI connect */ | 288 | int snd_soc_cache_init(struct snd_soc_codec *codec); |
262 | void snd_soc_free_pcms(struct snd_soc_device *socdev); | 289 | int snd_soc_cache_exit(struct snd_soc_codec *codec); |
263 | int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid); | 290 | int snd_soc_cache_write(struct snd_soc_codec *codec, |
291 | unsigned int reg, unsigned int value); | ||
292 | int snd_soc_cache_read(struct snd_soc_codec *codec, | ||
293 | unsigned int reg, unsigned int *value); | ||
294 | int snd_soc_default_volatile_register(struct snd_soc_codec *codec, | ||
295 | unsigned int reg); | ||
296 | int snd_soc_default_readable_register(struct snd_soc_codec *codec, | ||
297 | unsigned int reg); | ||
298 | int snd_soc_default_writable_register(struct snd_soc_codec *codec, | ||
299 | unsigned int reg); | ||
264 | 300 | ||
265 | /* Utility functions to get clock rates from various things */ | 301 | /* Utility functions to get clock rates from various things */ |
266 | int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); | 302 | int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); |
@@ -273,7 +309,7 @@ int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, | |||
273 | const struct snd_pcm_hardware *hw); | 309 | const struct snd_pcm_hardware *hw); |
274 | 310 | ||
275 | /* Jack reporting */ | 311 | /* Jack reporting */ |
276 | int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type, | 312 | int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, |
277 | struct snd_soc_jack *jack); | 313 | struct snd_soc_jack *jack); |
278 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); | 314 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); |
279 | int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, | 315 | int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, |
@@ -282,6 +318,9 @@ void snd_soc_jack_notifier_register(struct snd_soc_jack *jack, | |||
282 | struct notifier_block *nb); | 318 | struct notifier_block *nb); |
283 | void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack, | 319 | void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack, |
284 | struct notifier_block *nb); | 320 | struct notifier_block *nb); |
321 | int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count, | ||
322 | struct snd_soc_jack_zone *zones); | ||
323 | int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage); | ||
285 | #ifdef CONFIG_GPIOLIB | 324 | #ifdef CONFIG_GPIOLIB |
286 | int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | 325 | int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, |
287 | struct snd_soc_jack_gpio *gpios); | 326 | struct snd_soc_jack_gpio *gpios); |
@@ -306,7 +345,8 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); | |||
306 | *Controls | 345 | *Controls |
307 | */ | 346 | */ |
308 | struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, | 347 | struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, |
309 | void *data, char *long_name); | 348 | void *data, char *long_name, |
349 | const char *prefix); | ||
310 | int snd_soc_add_controls(struct snd_soc_codec *codec, | 350 | int snd_soc_add_controls(struct snd_soc_codec *codec, |
311 | const struct snd_kcontrol_new *controls, int num_controls); | 351 | const struct snd_kcontrol_new *controls, int num_controls); |
312 | int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, | 352 | int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, |
@@ -352,6 +392,22 @@ int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol, | |||
352 | struct snd_ctl_elem_value *ucontrol); | 392 | struct snd_ctl_elem_value *ucontrol); |
353 | 393 | ||
354 | /** | 394 | /** |
395 | * struct snd_soc_reg_access - Describes whether a given register is | ||
396 | * readable, writable or volatile. | ||
397 | * | ||
398 | * @reg: the register number | ||
399 | * @read: whether this register is readable | ||
400 | * @write: whether this register is writable | ||
401 | * @vol: whether this register is volatile | ||
402 | */ | ||
403 | struct snd_soc_reg_access { | ||
404 | u16 reg; | ||
405 | u16 read; | ||
406 | u16 write; | ||
407 | u16 vol; | ||
408 | }; | ||
409 | |||
410 | /** | ||
355 | * struct snd_soc_jack_pin - Describes a pin to update based on jack detection | 411 | * struct snd_soc_jack_pin - Describes a pin to update based on jack detection |
356 | * | 412 | * |
357 | * @pin: name of the pin to update | 413 | * @pin: name of the pin to update |
@@ -366,6 +422,24 @@ struct snd_soc_jack_pin { | |||
366 | }; | 422 | }; |
367 | 423 | ||
368 | /** | 424 | /** |
425 | * struct snd_soc_jack_zone - Describes voltage zones of jack detection | ||
426 | * | ||
427 | * @min_mv: start voltage in mv | ||
428 | * @max_mv: end voltage in mv | ||
429 | * @jack_type: type of jack that is expected for this voltage | ||
430 | * @debounce_time: debounce_time for jack, codec driver should wait for this | ||
431 | * duration before reading the adc for voltages | ||
432 | * @:list: list container | ||
433 | */ | ||
434 | struct snd_soc_jack_zone { | ||
435 | unsigned int min_mv; | ||
436 | unsigned int max_mv; | ||
437 | unsigned int jack_type; | ||
438 | unsigned int debounce_time; | ||
439 | struct list_head list; | ||
440 | }; | ||
441 | |||
442 | /** | ||
369 | * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection | 443 | * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection |
370 | * | 444 | * |
371 | * @gpio: gpio number | 445 | * @gpio: gpio number |
@@ -373,6 +447,10 @@ struct snd_soc_jack_pin { | |||
373 | * @report: value to report when jack detected | 447 | * @report: value to report when jack detected |
374 | * @invert: report presence in low state | 448 | * @invert: report presence in low state |
375 | * @debouce_time: debouce time in ms | 449 | * @debouce_time: debouce time in ms |
450 | * @wake: enable as wake source | ||
451 | * @jack_status_check: callback function which overrides the detection | ||
452 | * to provide more complex checks (eg, reading an | ||
453 | * ADC). | ||
376 | */ | 454 | */ |
377 | #ifdef CONFIG_GPIOLIB | 455 | #ifdef CONFIG_GPIOLIB |
378 | struct snd_soc_jack_gpio { | 456 | struct snd_soc_jack_gpio { |
@@ -381,8 +459,10 @@ struct snd_soc_jack_gpio { | |||
381 | int report; | 459 | int report; |
382 | int invert; | 460 | int invert; |
383 | int debounce_time; | 461 | int debounce_time; |
462 | bool wake; | ||
463 | |||
384 | struct snd_soc_jack *jack; | 464 | struct snd_soc_jack *jack; |
385 | struct work_struct work; | 465 | struct delayed_work work; |
386 | 466 | ||
387 | int (*jack_status_check)(void); | 467 | int (*jack_status_check)(void); |
388 | }; | 468 | }; |
@@ -390,23 +470,22 @@ struct snd_soc_jack_gpio { | |||
390 | 470 | ||
391 | struct snd_soc_jack { | 471 | struct snd_soc_jack { |
392 | struct snd_jack *jack; | 472 | struct snd_jack *jack; |
393 | struct snd_soc_card *card; | 473 | struct snd_soc_codec *codec; |
394 | struct list_head pins; | 474 | struct list_head pins; |
395 | int status; | 475 | int status; |
396 | struct blocking_notifier_head notifier; | 476 | struct blocking_notifier_head notifier; |
477 | struct list_head jack_zones; | ||
397 | }; | 478 | }; |
398 | 479 | ||
399 | /* SoC PCM stream information */ | 480 | /* SoC PCM stream information */ |
400 | struct snd_soc_pcm_stream { | 481 | struct snd_soc_pcm_stream { |
401 | char *stream_name; | 482 | const char *stream_name; |
402 | u64 formats; /* SNDRV_PCM_FMTBIT_* */ | 483 | u64 formats; /* SNDRV_PCM_FMTBIT_* */ |
403 | unsigned int rates; /* SNDRV_PCM_RATE_* */ | 484 | unsigned int rates; /* SNDRV_PCM_RATE_* */ |
404 | unsigned int rate_min; /* min rate */ | 485 | unsigned int rate_min; /* min rate */ |
405 | unsigned int rate_max; /* max rate */ | 486 | unsigned int rate_max; /* max rate */ |
406 | unsigned int channels_min; /* min channels */ | 487 | unsigned int channels_min; /* min channels */ |
407 | unsigned int channels_max; /* max channels */ | 488 | unsigned int channels_max; /* max channels */ |
408 | unsigned int active; /* stream is in use */ | ||
409 | void *dma_data; /* used by platform code */ | ||
410 | }; | 489 | }; |
411 | 490 | ||
412 | /* SoC audio ops */ | 491 | /* SoC audio ops */ |
@@ -419,82 +498,129 @@ struct snd_soc_ops { | |||
419 | int (*trigger)(struct snd_pcm_substream *, int); | 498 | int (*trigger)(struct snd_pcm_substream *, int); |
420 | }; | 499 | }; |
421 | 500 | ||
422 | /* SoC Audio Codec */ | 501 | /* SoC cache ops */ |
502 | struct snd_soc_cache_ops { | ||
503 | const char *name; | ||
504 | enum snd_soc_compress_type id; | ||
505 | int (*init)(struct snd_soc_codec *codec); | ||
506 | int (*exit)(struct snd_soc_codec *codec); | ||
507 | int (*read)(struct snd_soc_codec *codec, unsigned int reg, | ||
508 | unsigned int *value); | ||
509 | int (*write)(struct snd_soc_codec *codec, unsigned int reg, | ||
510 | unsigned int value); | ||
511 | int (*sync)(struct snd_soc_codec *codec); | ||
512 | }; | ||
513 | |||
514 | /* SoC Audio Codec device */ | ||
423 | struct snd_soc_codec { | 515 | struct snd_soc_codec { |
424 | char *name; | 516 | const char *name; |
425 | struct module *owner; | 517 | const char *name_prefix; |
426 | struct mutex mutex; | 518 | int id; |
427 | struct device *dev; | 519 | struct device *dev; |
428 | struct snd_soc_device *socdev; | 520 | const struct snd_soc_codec_driver *driver; |
429 | 521 | ||
522 | struct mutex mutex; | ||
523 | struct snd_soc_card *card; | ||
430 | struct list_head list; | 524 | struct list_head list; |
431 | 525 | struct list_head card_list; | |
432 | /* callbacks */ | 526 | int num_dai; |
433 | int (*set_bias_level)(struct snd_soc_codec *, | 527 | enum snd_soc_compress_type compress_type; |
434 | enum snd_soc_bias_level level); | 528 | size_t reg_size; /* reg_cache_size * reg_word_size */ |
529 | int (*volatile_register)(struct snd_soc_codec *, unsigned int); | ||
530 | int (*readable_register)(struct snd_soc_codec *, unsigned int); | ||
531 | int (*writable_register)(struct snd_soc_codec *, unsigned int); | ||
435 | 532 | ||
436 | /* runtime */ | 533 | /* runtime */ |
437 | struct snd_card *card; | ||
438 | struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ | 534 | struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ |
439 | unsigned int active; | 535 | unsigned int active; |
440 | unsigned int pcm_devs; | 536 | unsigned int cache_bypass:1; /* Suppress access to the cache */ |
441 | void *drvdata; | 537 | unsigned int suspended:1; /* Codec is in suspend PM state */ |
538 | unsigned int probed:1; /* Codec has been probed */ | ||
539 | unsigned int ac97_registered:1; /* Codec has been AC97 registered */ | ||
540 | unsigned int ac97_created:1; /* Codec has been created by SoC */ | ||
541 | unsigned int sysfs_registered:1; /* codec has been sysfs registered */ | ||
542 | unsigned int cache_init:1; /* codec cache has been initialized */ | ||
543 | u32 cache_only; /* Suppress writes to hardware */ | ||
544 | u32 cache_sync; /* Cache needs to be synced to hardware */ | ||
442 | 545 | ||
443 | /* codec IO */ | 546 | /* codec IO */ |
444 | void *control_data; /* codec control (i2c/3wire) data */ | 547 | void *control_data; /* codec control (i2c/3wire) data */ |
445 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | 548 | enum snd_soc_control_type control_type; |
446 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | ||
447 | int (*display_register)(struct snd_soc_codec *, char *, | ||
448 | size_t, unsigned int); | ||
449 | int (*volatile_register)(unsigned int); | ||
450 | int (*readable_register)(unsigned int); | ||
451 | hw_write_t hw_write; | 549 | hw_write_t hw_write; |
452 | unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); | 550 | unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); |
551 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | ||
552 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | ||
553 | int (*bulk_write_raw)(struct snd_soc_codec *, unsigned int, const void *, size_t); | ||
453 | void *reg_cache; | 554 | void *reg_cache; |
454 | short reg_cache_size; | 555 | const void *reg_def_copy; |
455 | short reg_cache_step; | 556 | const struct snd_soc_cache_ops *cache_ops; |
456 | 557 | struct mutex cache_rw_mutex; | |
457 | unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */ | ||
458 | unsigned int cache_only:1; /* Suppress writes to hardware */ | ||
459 | unsigned int cache_sync:1; /* Cache needs to be synced to hardware */ | ||
460 | 558 | ||
461 | /* dapm */ | 559 | /* dapm */ |
462 | u32 pop_time; | 560 | struct snd_soc_dapm_context dapm; |
463 | struct list_head dapm_widgets; | ||
464 | struct list_head dapm_paths; | ||
465 | enum snd_soc_bias_level bias_level; | ||
466 | enum snd_soc_bias_level suspend_bias_level; | ||
467 | struct delayed_work delayed_work; | ||
468 | |||
469 | /* codec DAI's */ | ||
470 | struct snd_soc_dai *dai; | ||
471 | unsigned int num_dai; | ||
472 | 561 | ||
473 | #ifdef CONFIG_DEBUG_FS | 562 | #ifdef CONFIG_DEBUG_FS |
474 | struct dentry *debugfs_codec_root; | 563 | struct dentry *debugfs_codec_root; |
475 | struct dentry *debugfs_reg; | 564 | struct dentry *debugfs_reg; |
476 | struct dentry *debugfs_pop_time; | ||
477 | struct dentry *debugfs_dapm; | 565 | struct dentry *debugfs_dapm; |
478 | #endif | 566 | #endif |
479 | }; | 567 | }; |
480 | 568 | ||
481 | /* codec device */ | 569 | /* codec driver */ |
482 | struct snd_soc_codec_device { | 570 | struct snd_soc_codec_driver { |
483 | int (*probe)(struct platform_device *pdev); | 571 | |
484 | int (*remove)(struct platform_device *pdev); | 572 | /* driver ops */ |
485 | int (*suspend)(struct platform_device *pdev, pm_message_t state); | 573 | int (*probe)(struct snd_soc_codec *); |
486 | int (*resume)(struct platform_device *pdev); | 574 | int (*remove)(struct snd_soc_codec *); |
575 | int (*suspend)(struct snd_soc_codec *, | ||
576 | pm_message_t state); | ||
577 | int (*resume)(struct snd_soc_codec *); | ||
578 | |||
579 | /* Default control and setup, added after probe() is run */ | ||
580 | const struct snd_kcontrol_new *controls; | ||
581 | int num_controls; | ||
582 | const struct snd_soc_dapm_widget *dapm_widgets; | ||
583 | int num_dapm_widgets; | ||
584 | const struct snd_soc_dapm_route *dapm_routes; | ||
585 | int num_dapm_routes; | ||
586 | |||
587 | /* codec wide operations */ | ||
588 | int (*set_sysclk)(struct snd_soc_codec *codec, | ||
589 | int clk_id, unsigned int freq, int dir); | ||
590 | int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source, | ||
591 | unsigned int freq_in, unsigned int freq_out); | ||
592 | |||
593 | /* codec IO */ | ||
594 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | ||
595 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | ||
596 | int (*display_register)(struct snd_soc_codec *, char *, | ||
597 | size_t, unsigned int); | ||
598 | int (*volatile_register)(struct snd_soc_codec *, unsigned int); | ||
599 | int (*readable_register)(struct snd_soc_codec *, unsigned int); | ||
600 | int (*writable_register)(struct snd_soc_codec *, unsigned int); | ||
601 | short reg_cache_size; | ||
602 | short reg_cache_step; | ||
603 | short reg_word_size; | ||
604 | const void *reg_cache_default; | ||
605 | short reg_access_size; | ||
606 | const struct snd_soc_reg_access *reg_access_default; | ||
607 | enum snd_soc_compress_type compress_type; | ||
608 | |||
609 | /* codec bias level */ | ||
610 | int (*set_bias_level)(struct snd_soc_codec *, | ||
611 | enum snd_soc_bias_level level); | ||
612 | |||
613 | void (*seq_notifier)(struct snd_soc_dapm_context *, | ||
614 | enum snd_soc_dapm_type, int); | ||
487 | }; | 615 | }; |
488 | 616 | ||
489 | /* SoC platform interface */ | 617 | /* SoC platform interface */ |
490 | struct snd_soc_platform { | 618 | struct snd_soc_platform_driver { |
491 | char *name; | ||
492 | struct list_head list; | ||
493 | 619 | ||
494 | int (*probe)(struct platform_device *pdev); | 620 | int (*probe)(struct snd_soc_platform *); |
495 | int (*remove)(struct platform_device *pdev); | 621 | int (*remove)(struct snd_soc_platform *); |
496 | int (*suspend)(struct snd_soc_dai_link *dai_link); | 622 | int (*suspend)(struct snd_soc_dai *dai); |
497 | int (*resume)(struct snd_soc_dai_link *dai_link); | 623 | int (*resume)(struct snd_soc_dai *dai); |
498 | 624 | ||
499 | /* pcm creation and destruction */ | 625 | /* pcm creation and destruction */ |
500 | int (*pcm_new)(struct snd_card *, struct snd_soc_dai *, | 626 | int (*pcm_new)(struct snd_card *, struct snd_soc_dai *, |
@@ -509,23 +635,31 @@ struct snd_soc_platform { | |||
509 | struct snd_soc_dai *); | 635 | struct snd_soc_dai *); |
510 | 636 | ||
511 | /* platform stream ops */ | 637 | /* platform stream ops */ |
512 | struct snd_pcm_ops *pcm_ops; | 638 | struct snd_pcm_ops *ops; |
513 | }; | 639 | }; |
514 | 640 | ||
515 | /* SoC machine DAI configuration, glues a codec and cpu DAI together */ | 641 | struct snd_soc_platform { |
516 | struct snd_soc_dai_link { | 642 | const char *name; |
517 | char *name; /* Codec name */ | 643 | int id; |
518 | char *stream_name; /* Stream name */ | 644 | struct device *dev; |
645 | struct snd_soc_platform_driver *driver; | ||
519 | 646 | ||
520 | /* DAI */ | 647 | unsigned int suspended:1; /* platform is suspended */ |
521 | struct snd_soc_dai *codec_dai; | 648 | unsigned int probed:1; |
522 | struct snd_soc_dai *cpu_dai; | ||
523 | 649 | ||
524 | /* machine stream operations */ | 650 | struct snd_soc_card *card; |
525 | struct snd_soc_ops *ops; | 651 | struct list_head list; |
652 | struct list_head card_list; | ||
653 | }; | ||
526 | 654 | ||
527 | /* codec/machine specific init - e.g. add machine controls */ | 655 | struct snd_soc_dai_link { |
528 | int (*init)(struct snd_soc_codec *codec); | 656 | /* config - must be set by machine driver */ |
657 | const char *name; /* Codec name */ | ||
658 | const char *stream_name; /* Stream name */ | ||
659 | const char *codec_name; /* for multi-codec */ | ||
660 | const char *platform_name; /* for multi-platform */ | ||
661 | const char *cpu_dai_name; | ||
662 | const char *codec_dai_name; | ||
529 | 663 | ||
530 | /* Keep DAI active over suspend */ | 664 | /* Keep DAI active over suspend */ |
531 | unsigned int ignore_suspend:1; | 665 | unsigned int ignore_suspend:1; |
@@ -533,63 +667,144 @@ struct snd_soc_dai_link { | |||
533 | /* Symmetry requirements */ | 667 | /* Symmetry requirements */ |
534 | unsigned int symmetric_rates:1; | 668 | unsigned int symmetric_rates:1; |
535 | 669 | ||
536 | /* Symmetry data - only valid if symmetry is being enforced */ | 670 | /* codec/machine specific init - e.g. add machine controls */ |
537 | unsigned int rate; | 671 | int (*init)(struct snd_soc_pcm_runtime *rtd); |
538 | 672 | ||
539 | /* DAI pcm */ | 673 | /* machine stream operations */ |
540 | struct snd_pcm *pcm; | 674 | struct snd_soc_ops *ops; |
675 | }; | ||
676 | |||
677 | struct snd_soc_codec_conf { | ||
678 | const char *dev_name; | ||
679 | |||
680 | /* | ||
681 | * optional map of kcontrol, widget and path name prefixes that are | ||
682 | * associated per device | ||
683 | */ | ||
684 | const char *name_prefix; | ||
685 | |||
686 | /* | ||
687 | * set this to the desired compression type if you want to | ||
688 | * override the one supplied in codec->driver->compress_type | ||
689 | */ | ||
690 | enum snd_soc_compress_type compress_type; | ||
691 | }; | ||
692 | |||
693 | struct snd_soc_aux_dev { | ||
694 | const char *name; /* Codec name */ | ||
695 | const char *codec_name; /* for multi-codec */ | ||
696 | |||
697 | /* codec/machine specific init - e.g. add machine controls */ | ||
698 | int (*init)(struct snd_soc_dapm_context *dapm); | ||
541 | }; | 699 | }; |
542 | 700 | ||
543 | /* SoC card */ | 701 | /* SoC card */ |
544 | struct snd_soc_card { | 702 | struct snd_soc_card { |
545 | char *name; | 703 | const char *name; |
704 | const char *long_name; | ||
705 | const char *driver_name; | ||
546 | struct device *dev; | 706 | struct device *dev; |
707 | struct snd_card *snd_card; | ||
708 | struct module *owner; | ||
547 | 709 | ||
548 | struct list_head list; | 710 | struct list_head list; |
711 | struct mutex mutex; | ||
549 | 712 | ||
550 | int instantiated; | 713 | bool instantiated; |
551 | 714 | ||
552 | int (*probe)(struct platform_device *pdev); | 715 | int (*probe)(struct snd_soc_card *card); |
553 | int (*remove)(struct platform_device *pdev); | 716 | int (*late_probe)(struct snd_soc_card *card); |
717 | int (*remove)(struct snd_soc_card *card); | ||
554 | 718 | ||
555 | /* the pre and post PM functions are used to do any PM work before and | 719 | /* the pre and post PM functions are used to do any PM work before and |
556 | * after the codec and DAI's do any PM work. */ | 720 | * after the codec and DAI's do any PM work. */ |
557 | int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); | 721 | int (*suspend_pre)(struct snd_soc_card *card); |
558 | int (*suspend_post)(struct platform_device *pdev, pm_message_t state); | 722 | int (*suspend_post)(struct snd_soc_card *card); |
559 | int (*resume_pre)(struct platform_device *pdev); | 723 | int (*resume_pre)(struct snd_soc_card *card); |
560 | int (*resume_post)(struct platform_device *pdev); | 724 | int (*resume_post)(struct snd_soc_card *card); |
561 | 725 | ||
562 | /* callbacks */ | 726 | /* callbacks */ |
563 | int (*set_bias_level)(struct snd_soc_card *, | 727 | int (*set_bias_level)(struct snd_soc_card *, |
564 | enum snd_soc_bias_level level); | 728 | enum snd_soc_bias_level level); |
729 | int (*set_bias_level_post)(struct snd_soc_card *, | ||
730 | enum snd_soc_bias_level level); | ||
565 | 731 | ||
566 | long pmdown_time; | 732 | long pmdown_time; |
567 | 733 | ||
568 | /* CPU <--> Codec DAI links */ | 734 | /* CPU <--> Codec DAI links */ |
569 | struct snd_soc_dai_link *dai_link; | 735 | struct snd_soc_dai_link *dai_link; |
570 | int num_links; | 736 | int num_links; |
737 | struct snd_soc_pcm_runtime *rtd; | ||
738 | int num_rtd; | ||
571 | 739 | ||
572 | struct snd_soc_device *socdev; | 740 | /* optional codec specific configuration */ |
741 | struct snd_soc_codec_conf *codec_conf; | ||
742 | int num_configs; | ||
573 | 743 | ||
574 | struct snd_soc_codec *codec; | 744 | /* |
745 | * optional auxiliary devices such as amplifiers or codecs with DAI | ||
746 | * link unused | ||
747 | */ | ||
748 | struct snd_soc_aux_dev *aux_dev; | ||
749 | int num_aux_devs; | ||
750 | struct snd_soc_pcm_runtime *rtd_aux; | ||
751 | int num_aux_rtd; | ||
752 | |||
753 | const struct snd_kcontrol_new *controls; | ||
754 | int num_controls; | ||
755 | |||
756 | /* | ||
757 | * Card-specific routes and widgets. | ||
758 | */ | ||
759 | const struct snd_soc_dapm_widget *dapm_widgets; | ||
760 | int num_dapm_widgets; | ||
761 | const struct snd_soc_dapm_route *dapm_routes; | ||
762 | int num_dapm_routes; | ||
575 | 763 | ||
576 | struct snd_soc_platform *platform; | ||
577 | struct delayed_work delayed_work; | ||
578 | struct work_struct deferred_resume_work; | 764 | struct work_struct deferred_resume_work; |
765 | |||
766 | /* lists of probed devices belonging to this card */ | ||
767 | struct list_head codec_dev_list; | ||
768 | struct list_head platform_dev_list; | ||
769 | struct list_head dai_dev_list; | ||
770 | |||
771 | struct list_head widgets; | ||
772 | struct list_head paths; | ||
773 | struct list_head dapm_list; | ||
774 | |||
775 | /* Generic DAPM context for the card */ | ||
776 | struct snd_soc_dapm_context dapm; | ||
777 | |||
778 | #ifdef CONFIG_DEBUG_FS | ||
779 | struct dentry *debugfs_card_root; | ||
780 | struct dentry *debugfs_pop_time; | ||
781 | #endif | ||
782 | u32 pop_time; | ||
783 | |||
784 | void *drvdata; | ||
579 | }; | 785 | }; |
580 | 786 | ||
581 | /* SoC Device - the audio subsystem */ | 787 | /* SoC machine DAI configuration, glues a codec and cpu DAI together */ |
582 | struct snd_soc_device { | 788 | struct snd_soc_pcm_runtime { |
583 | struct device *dev; | 789 | struct device dev; |
584 | struct snd_soc_card *card; | 790 | struct snd_soc_card *card; |
585 | struct snd_soc_codec_device *codec_dev; | 791 | struct snd_soc_dai_link *dai_link; |
586 | void *codec_data; | 792 | |
587 | }; | 793 | unsigned int complete:1; |
794 | unsigned int dev_registered:1; | ||
795 | |||
796 | /* Symmetry data - only valid if symmetry is being enforced */ | ||
797 | unsigned int rate; | ||
798 | long pmdown_time; | ||
588 | 799 | ||
589 | /* runtime channel data */ | 800 | /* runtime devices */ |
590 | struct snd_soc_pcm_runtime { | 801 | struct snd_pcm *pcm; |
591 | struct snd_soc_dai_link *dai; | 802 | struct snd_soc_codec *codec; |
592 | struct snd_soc_device *socdev; | 803 | struct snd_soc_platform *platform; |
804 | struct snd_soc_dai *codec_dai; | ||
805 | struct snd_soc_dai *cpu_dai; | ||
806 | |||
807 | struct delayed_work delayed_work; | ||
593 | }; | 808 | }; |
594 | 809 | ||
595 | /* mixer control */ | 810 | /* mixer control */ |
@@ -606,35 +821,83 @@ struct soc_enum { | |||
606 | unsigned char shift_r; | 821 | unsigned char shift_r; |
607 | unsigned int max; | 822 | unsigned int max; |
608 | unsigned int mask; | 823 | unsigned int mask; |
609 | const char **texts; | 824 | const char * const *texts; |
610 | const unsigned int *values; | 825 | const unsigned int *values; |
611 | void *dapm; | 826 | void *dapm; |
612 | }; | 827 | }; |
613 | 828 | ||
614 | /* codec IO */ | 829 | /* codec IO */ |
615 | static inline unsigned int snd_soc_read(struct snd_soc_codec *codec, | 830 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); |
616 | unsigned int reg) | 831 | unsigned int snd_soc_write(struct snd_soc_codec *codec, |
832 | unsigned int reg, unsigned int val); | ||
833 | unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec, | ||
834 | unsigned int reg, const void *data, size_t len); | ||
835 | |||
836 | /* device driver data */ | ||
837 | |||
838 | static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card, | ||
839 | void *data) | ||
617 | { | 840 | { |
618 | return codec->read(codec, reg); | 841 | card->drvdata = data; |
619 | } | 842 | } |
620 | 843 | ||
621 | static inline unsigned int snd_soc_write(struct snd_soc_codec *codec, | 844 | static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card) |
622 | unsigned int reg, unsigned int val) | ||
623 | { | 845 | { |
624 | return codec->write(codec, reg, val); | 846 | return card->drvdata; |
625 | } | 847 | } |
626 | 848 | ||
627 | static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, | 849 | static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, |
628 | void *data) | 850 | void *data) |
629 | { | 851 | { |
630 | codec->drvdata = data; | 852 | dev_set_drvdata(codec->dev, data); |
631 | } | 853 | } |
632 | 854 | ||
633 | static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec) | 855 | static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec) |
634 | { | 856 | { |
635 | return codec->drvdata; | 857 | return dev_get_drvdata(codec->dev); |
636 | } | 858 | } |
637 | 859 | ||
860 | static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform, | ||
861 | void *data) | ||
862 | { | ||
863 | dev_set_drvdata(platform->dev, data); | ||
864 | } | ||
865 | |||
866 | static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform) | ||
867 | { | ||
868 | return dev_get_drvdata(platform->dev); | ||
869 | } | ||
870 | |||
871 | static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd, | ||
872 | void *data) | ||
873 | { | ||
874 | dev_set_drvdata(&rtd->dev, data); | ||
875 | } | ||
876 | |||
877 | static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd) | ||
878 | { | ||
879 | return dev_get_drvdata(&rtd->dev); | ||
880 | } | ||
881 | |||
882 | static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) | ||
883 | { | ||
884 | INIT_LIST_HEAD(&card->dai_dev_list); | ||
885 | INIT_LIST_HEAD(&card->codec_dev_list); | ||
886 | INIT_LIST_HEAD(&card->platform_dev_list); | ||
887 | INIT_LIST_HEAD(&card->widgets); | ||
888 | INIT_LIST_HEAD(&card->paths); | ||
889 | INIT_LIST_HEAD(&card->dapm_list); | ||
890 | } | ||
891 | |||
892 | int snd_soc_util_init(void); | ||
893 | void snd_soc_util_exit(void); | ||
894 | |||
638 | #include <sound/soc-dai.h> | 895 | #include <sound/soc-dai.h> |
639 | 896 | ||
897 | #ifdef CONFIG_DEBUG_FS | ||
898 | extern struct dentry *snd_soc_debugfs_root; | ||
899 | #endif | ||
900 | |||
901 | extern const struct dev_pm_ops snd_soc_pm_ops; | ||
902 | |||
640 | #endif | 903 | #endif |