diff options
Diffstat (limited to 'include/sound/soc.h')
-rw-r--r-- | include/sound/soc.h | 116 |
1 files changed, 92 insertions, 24 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index 5c3bce83f28a..74921f20a1d8 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -222,10 +222,8 @@ enum snd_soc_bias_level { | |||
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; |
231 | struct snd_soc_dai_driver; | 229 | struct snd_soc_dai_driver; |
@@ -235,9 +233,10 @@ struct snd_soc_platform_driver; | |||
235 | struct snd_soc_codec; | 233 | struct snd_soc_codec; |
236 | struct snd_soc_codec_driver; | 234 | struct snd_soc_codec_driver; |
237 | struct soc_enum; | 235 | struct soc_enum; |
238 | struct snd_soc_ac97_ops; | ||
239 | struct snd_soc_jack; | 236 | struct snd_soc_jack; |
240 | struct snd_soc_jack_pin; | 237 | struct snd_soc_jack_pin; |
238 | struct snd_soc_cache_ops; | ||
239 | #include <sound/soc-dapm.h> | ||
241 | 240 | ||
242 | #ifdef CONFIG_GPIOLIB | 241 | #ifdef CONFIG_GPIOLIB |
243 | struct snd_soc_jack_gpio; | 242 | struct snd_soc_jack_gpio; |
@@ -253,17 +252,30 @@ enum snd_soc_control_type { | |||
253 | SND_SOC_SPI, | 252 | SND_SOC_SPI, |
254 | }; | 253 | }; |
255 | 254 | ||
255 | enum snd_soc_compress_type { | ||
256 | SND_SOC_FLAT_COMPRESSION = 1, | ||
257 | SND_SOC_LZO_COMPRESSION, | ||
258 | SND_SOC_RBTREE_COMPRESSION | ||
259 | }; | ||
260 | |||
256 | int snd_soc_register_platform(struct device *dev, | 261 | int snd_soc_register_platform(struct device *dev, |
257 | struct snd_soc_platform_driver *platform_drv); | 262 | struct snd_soc_platform_driver *platform_drv); |
258 | void snd_soc_unregister_platform(struct device *dev); | 263 | void snd_soc_unregister_platform(struct device *dev); |
259 | int snd_soc_register_codec(struct device *dev, | 264 | int snd_soc_register_codec(struct device *dev, |
260 | struct snd_soc_codec_driver *codec_drv, | 265 | const struct snd_soc_codec_driver *codec_drv, |
261 | struct snd_soc_dai_driver *dai_drv, int num_dai); | 266 | struct snd_soc_dai_driver *dai_drv, int num_dai); |
262 | void snd_soc_unregister_codec(struct device *dev); | 267 | void snd_soc_unregister_codec(struct device *dev); |
263 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg); | 268 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg); |
264 | int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, | 269 | int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, |
265 | int addr_bits, int data_bits, | 270 | int addr_bits, int data_bits, |
266 | enum snd_soc_control_type control); | 271 | enum snd_soc_control_type control); |
272 | int snd_soc_cache_sync(struct snd_soc_codec *codec); | ||
273 | int snd_soc_cache_init(struct snd_soc_codec *codec); | ||
274 | int snd_soc_cache_exit(struct snd_soc_codec *codec); | ||
275 | int snd_soc_cache_write(struct snd_soc_codec *codec, | ||
276 | unsigned int reg, unsigned int value); | ||
277 | int snd_soc_cache_read(struct snd_soc_codec *codec, | ||
278 | unsigned int reg, unsigned int *value); | ||
267 | 279 | ||
268 | /* Utility functions to get clock rates from various things */ | 280 | /* Utility functions to get clock rates from various things */ |
269 | int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); | 281 | int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); |
@@ -420,23 +432,37 @@ struct snd_soc_ops { | |||
420 | int (*trigger)(struct snd_pcm_substream *, int); | 432 | int (*trigger)(struct snd_pcm_substream *, int); |
421 | }; | 433 | }; |
422 | 434 | ||
435 | /* SoC cache ops */ | ||
436 | struct snd_soc_cache_ops { | ||
437 | const char *name; | ||
438 | enum snd_soc_compress_type id; | ||
439 | int (*init)(struct snd_soc_codec *codec); | ||
440 | int (*exit)(struct snd_soc_codec *codec); | ||
441 | int (*read)(struct snd_soc_codec *codec, unsigned int reg, | ||
442 | unsigned int *value); | ||
443 | int (*write)(struct snd_soc_codec *codec, unsigned int reg, | ||
444 | unsigned int value); | ||
445 | int (*sync)(struct snd_soc_codec *codec); | ||
446 | }; | ||
447 | |||
423 | /* SoC Audio Codec device */ | 448 | /* SoC Audio Codec device */ |
424 | struct snd_soc_codec { | 449 | struct snd_soc_codec { |
425 | const char *name; | 450 | const char *name; |
451 | const char *name_prefix; | ||
426 | int id; | 452 | int id; |
427 | struct device *dev; | 453 | struct device *dev; |
428 | struct snd_soc_codec_driver *driver; | 454 | const struct snd_soc_codec_driver *driver; |
429 | 455 | ||
430 | struct mutex mutex; | 456 | struct mutex mutex; |
431 | struct snd_soc_card *card; | 457 | struct snd_soc_card *card; |
432 | struct list_head list; | 458 | struct list_head list; |
433 | struct list_head card_list; | 459 | struct list_head card_list; |
434 | int num_dai; | 460 | int num_dai; |
461 | enum snd_soc_compress_type compress_type; | ||
435 | 462 | ||
436 | /* runtime */ | 463 | /* runtime */ |
437 | struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ | 464 | struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ |
438 | unsigned int active; | 465 | unsigned int active; |
439 | unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */ | ||
440 | unsigned int cache_only:1; /* Suppress writes to hardware */ | 466 | unsigned int cache_only:1; /* Suppress writes to hardware */ |
441 | unsigned int cache_sync:1; /* Cache needs to be synced to hardware */ | 467 | unsigned int cache_sync:1; /* Cache needs to be synced to hardware */ |
442 | unsigned int suspended:1; /* Codec is in suspend PM state */ | 468 | unsigned int suspended:1; /* Codec is in suspend PM state */ |
@@ -444,25 +470,25 @@ struct snd_soc_codec { | |||
444 | unsigned int ac97_registered:1; /* Codec has been AC97 registered */ | 470 | unsigned int ac97_registered:1; /* Codec has been AC97 registered */ |
445 | unsigned int ac97_created:1; /* Codec has been created by SoC */ | 471 | unsigned int ac97_created:1; /* Codec has been created by SoC */ |
446 | unsigned int sysfs_registered:1; /* codec has been sysfs registered */ | 472 | unsigned int sysfs_registered:1; /* codec has been sysfs registered */ |
473 | unsigned int cache_init:1; /* codec cache has been initialized */ | ||
447 | 474 | ||
448 | /* codec IO */ | 475 | /* codec IO */ |
449 | void *control_data; /* codec control (i2c/3wire) data */ | 476 | void *control_data; /* codec control (i2c/3wire) data */ |
450 | hw_write_t hw_write; | 477 | hw_write_t hw_write; |
451 | unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); | 478 | unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); |
479 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | ||
480 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | ||
452 | void *reg_cache; | 481 | void *reg_cache; |
482 | const void *reg_def_copy; | ||
483 | const struct snd_soc_cache_ops *cache_ops; | ||
484 | struct mutex cache_rw_mutex; | ||
453 | 485 | ||
454 | /* dapm */ | 486 | /* dapm */ |
455 | u32 pop_time; | 487 | struct snd_soc_dapm_context dapm; |
456 | struct list_head dapm_widgets; | ||
457 | struct list_head dapm_paths; | ||
458 | enum snd_soc_bias_level bias_level; | ||
459 | enum snd_soc_bias_level suspend_bias_level; | ||
460 | struct delayed_work delayed_work; | ||
461 | 488 | ||
462 | #ifdef CONFIG_DEBUG_FS | 489 | #ifdef CONFIG_DEBUG_FS |
463 | struct dentry *debugfs_codec_root; | 490 | struct dentry *debugfs_codec_root; |
464 | struct dentry *debugfs_reg; | 491 | struct dentry *debugfs_reg; |
465 | struct dentry *debugfs_pop_time; | ||
466 | struct dentry *debugfs_dapm; | 492 | struct dentry *debugfs_dapm; |
467 | #endif | 493 | #endif |
468 | }; | 494 | }; |
@@ -488,6 +514,7 @@ struct snd_soc_codec_driver { | |||
488 | short reg_cache_step; | 514 | short reg_cache_step; |
489 | short reg_word_size; | 515 | short reg_word_size; |
490 | const void *reg_cache_default; | 516 | const void *reg_cache_default; |
517 | enum snd_soc_compress_type compress_type; | ||
491 | 518 | ||
492 | /* codec bias level */ | 519 | /* codec bias level */ |
493 | int (*set_bias_level)(struct snd_soc_codec *, | 520 | int (*set_bias_level)(struct snd_soc_codec *, |
@@ -554,6 +581,30 @@ struct snd_soc_dai_link { | |||
554 | struct snd_soc_ops *ops; | 581 | struct snd_soc_ops *ops; |
555 | }; | 582 | }; |
556 | 583 | ||
584 | struct snd_soc_codec_conf { | ||
585 | const char *dev_name; | ||
586 | |||
587 | /* | ||
588 | * optional map of kcontrol, widget and path name prefixes that are | ||
589 | * associated per device | ||
590 | */ | ||
591 | const char *name_prefix; | ||
592 | |||
593 | /* | ||
594 | * set this to the desired compression type if you want to | ||
595 | * override the one supplied in codec->driver->compress_type | ||
596 | */ | ||
597 | enum snd_soc_compress_type compress_type; | ||
598 | }; | ||
599 | |||
600 | struct snd_soc_aux_dev { | ||
601 | const char *name; /* Codec name */ | ||
602 | const char *codec_name; /* for multi-codec */ | ||
603 | |||
604 | /* codec/machine specific init - e.g. add machine controls */ | ||
605 | int (*init)(struct snd_soc_dapm_context *dapm); | ||
606 | }; | ||
607 | |||
557 | /* SoC card */ | 608 | /* SoC card */ |
558 | struct snd_soc_card { | 609 | struct snd_soc_card { |
559 | const char *name; | 610 | const char *name; |
@@ -579,6 +630,8 @@ struct snd_soc_card { | |||
579 | /* callbacks */ | 630 | /* callbacks */ |
580 | int (*set_bias_level)(struct snd_soc_card *, | 631 | int (*set_bias_level)(struct snd_soc_card *, |
581 | enum snd_soc_bias_level level); | 632 | enum snd_soc_bias_level level); |
633 | int (*set_bias_level_post)(struct snd_soc_card *, | ||
634 | enum snd_soc_bias_level level); | ||
582 | 635 | ||
583 | long pmdown_time; | 636 | long pmdown_time; |
584 | 637 | ||
@@ -588,12 +641,35 @@ struct snd_soc_card { | |||
588 | struct snd_soc_pcm_runtime *rtd; | 641 | struct snd_soc_pcm_runtime *rtd; |
589 | int num_rtd; | 642 | int num_rtd; |
590 | 643 | ||
644 | /* optional codec specific configuration */ | ||
645 | struct snd_soc_codec_conf *codec_conf; | ||
646 | int num_configs; | ||
647 | |||
648 | /* | ||
649 | * optional auxiliary devices such as amplifiers or codecs with DAI | ||
650 | * link unused | ||
651 | */ | ||
652 | struct snd_soc_aux_dev *aux_dev; | ||
653 | int num_aux_devs; | ||
654 | struct snd_soc_pcm_runtime *rtd_aux; | ||
655 | int num_aux_rtd; | ||
656 | |||
591 | struct work_struct deferred_resume_work; | 657 | struct work_struct deferred_resume_work; |
592 | 658 | ||
593 | /* lists of probed devices belonging to this card */ | 659 | /* lists of probed devices belonging to this card */ |
594 | struct list_head codec_dev_list; | 660 | struct list_head codec_dev_list; |
595 | struct list_head platform_dev_list; | 661 | struct list_head platform_dev_list; |
596 | struct list_head dai_dev_list; | 662 | struct list_head dai_dev_list; |
663 | |||
664 | struct list_head widgets; | ||
665 | struct list_head paths; | ||
666 | struct list_head dapm_list; | ||
667 | |||
668 | #ifdef CONFIG_DEBUG_FS | ||
669 | struct dentry *debugfs_card_root; | ||
670 | struct dentry *debugfs_pop_time; | ||
671 | #endif | ||
672 | u32 pop_time; | ||
597 | }; | 673 | }; |
598 | 674 | ||
599 | /* SoC machine DAI configuration, glues a codec and cpu DAI together */ | 675 | /* SoC machine DAI configuration, glues a codec and cpu DAI together */ |
@@ -639,17 +715,9 @@ struct soc_enum { | |||
639 | }; | 715 | }; |
640 | 716 | ||
641 | /* codec IO */ | 717 | /* codec IO */ |
642 | static inline unsigned int snd_soc_read(struct snd_soc_codec *codec, | 718 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); |
643 | unsigned int reg) | 719 | unsigned int snd_soc_write(struct snd_soc_codec *codec, |
644 | { | 720 | unsigned int reg, unsigned int val); |
645 | return codec->driver->read(codec, reg); | ||
646 | } | ||
647 | |||
648 | static inline unsigned int snd_soc_write(struct snd_soc_codec *codec, | ||
649 | unsigned int reg, unsigned int val) | ||
650 | { | ||
651 | return codec->driver->write(codec, reg, val); | ||
652 | } | ||
653 | 721 | ||
654 | /* device driver data */ | 722 | /* device driver data */ |
655 | 723 | ||