soc.h (8990c1bc4be46473ad19bf2fa612ca57286f3df4) | soc.h (8ddab3f5107c3955e70e87a632d4d179ddba1189) |
---|---|
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 --- 208 unchanged lines hidden (view full) --- 217 SND_SOC_BIAS_OFF, 218 SND_SOC_BIAS_STANDBY, 219 SND_SOC_BIAS_PREPARE, 220 SND_SOC_BIAS_ON, 221}; 222 223struct snd_jack; 224struct snd_soc_card; | 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 --- 208 unchanged lines hidden (view full) --- 217 SND_SOC_BIAS_OFF, 218 SND_SOC_BIAS_STANDBY, 219 SND_SOC_BIAS_PREPARE, 220 SND_SOC_BIAS_ON, 221}; 222 223struct snd_jack; 224struct snd_soc_card; |
225struct snd_soc_device; | |
226struct snd_soc_pcm_stream; 227struct snd_soc_ops; | 225struct snd_soc_pcm_stream; 226struct snd_soc_ops; |
228struct snd_soc_dai_mode; | |
229struct snd_soc_pcm_runtime; 230struct snd_soc_dai; 231struct snd_soc_dai_driver; 232struct snd_soc_platform; 233struct snd_soc_dai_link; 234struct snd_soc_platform_driver; 235struct snd_soc_codec; 236struct snd_soc_codec_driver; 237struct soc_enum; | 227struct snd_soc_pcm_runtime; 228struct snd_soc_dai; 229struct snd_soc_dai_driver; 230struct snd_soc_platform; 231struct snd_soc_dai_link; 232struct snd_soc_platform_driver; 233struct snd_soc_codec; 234struct snd_soc_codec_driver; 235struct soc_enum; |
238struct snd_soc_ac97_ops; | |
239struct snd_soc_jack; 240struct snd_soc_jack_pin; | 236struct snd_soc_jack; 237struct snd_soc_jack_pin; |
238struct snd_soc_cache_ops; 239#include <sound/soc-dapm.h> |
|
241 242#ifdef CONFIG_GPIOLIB 243struct snd_soc_jack_gpio; 244#endif 245 246typedef int (*hw_write_t)(void *,const char* ,int); 247 248extern struct snd_ac97_bus_ops soc_ac97_ops; 249 250enum snd_soc_control_type { 251 SND_SOC_CUSTOM, 252 SND_SOC_I2C, 253 SND_SOC_SPI, 254}; 255 | 240 241#ifdef CONFIG_GPIOLIB 242struct snd_soc_jack_gpio; 243#endif 244 245typedef int (*hw_write_t)(void *,const char* ,int); 246 247extern struct snd_ac97_bus_ops soc_ac97_ops; 248 249enum snd_soc_control_type { 250 SND_SOC_CUSTOM, 251 SND_SOC_I2C, 252 SND_SOC_SPI, 253}; 254 |
255enum snd_soc_compress_type { 256 SND_SOC_FLAT_COMPRESSION = 1, 257 SND_SOC_LZO_COMPRESSION, 258 SND_SOC_RBTREE_COMPRESSION 259}; 260 |
|
256int snd_soc_register_platform(struct device *dev, 257 struct snd_soc_platform_driver *platform_drv); 258void snd_soc_unregister_platform(struct device *dev); 259int snd_soc_register_codec(struct device *dev, | 261int snd_soc_register_platform(struct device *dev, 262 struct snd_soc_platform_driver *platform_drv); 263void snd_soc_unregister_platform(struct device *dev); 264int 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); 262void snd_soc_unregister_codec(struct device *dev); 263int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg); 264int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, 265 int addr_bits, int data_bits, 266 enum snd_soc_control_type control); | 266 struct snd_soc_dai_driver *dai_drv, int num_dai); 267void snd_soc_unregister_codec(struct device *dev); 268int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg); 269int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, 270 int addr_bits, int data_bits, 271 enum snd_soc_control_type control); |
272int snd_soc_cache_sync(struct snd_soc_codec *codec); 273int snd_soc_cache_init(struct snd_soc_codec *codec); 274int snd_soc_cache_exit(struct snd_soc_codec *codec); 275int snd_soc_cache_write(struct snd_soc_codec *codec, 276 unsigned int reg, unsigned int value); 277int snd_soc_cache_read(struct snd_soc_codec *codec, 278 unsigned int reg, unsigned int *value); |
|
267 268/* Utility functions to get clock rates from various things */ 269int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); 270int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params); 271int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots); 272int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms); 273 274/* set runtime hw params */ --- 140 unchanged lines hidden (view full) --- 415 int (*startup)(struct snd_pcm_substream *); 416 void (*shutdown)(struct snd_pcm_substream *); 417 int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *); 418 int (*hw_free)(struct snd_pcm_substream *); 419 int (*prepare)(struct snd_pcm_substream *); 420 int (*trigger)(struct snd_pcm_substream *, int); 421}; 422 | 279 280/* Utility functions to get clock rates from various things */ 281int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); 282int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params); 283int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots); 284int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms); 285 286/* set runtime hw params */ --- 140 unchanged lines hidden (view full) --- 427 int (*startup)(struct snd_pcm_substream *); 428 void (*shutdown)(struct snd_pcm_substream *); 429 int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *); 430 int (*hw_free)(struct snd_pcm_substream *); 431 int (*prepare)(struct snd_pcm_substream *); 432 int (*trigger)(struct snd_pcm_substream *, int); 433}; 434 |
435/* SoC cache ops */ 436struct 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 */ 424struct snd_soc_codec { 425 const char *name; | 448/* SoC Audio Codec device */ 449struct snd_soc_codec { 450 const char *name; |
451 const char *name_prefix; |
|
426 int id; 427 struct device *dev; | 452 int id; 453 struct device *dev; |
428 struct snd_soc_codec_driver *driver; | 454 const struct snd_soc_codec_driver *driver; |
429 430 struct mutex mutex; 431 struct snd_soc_card *card; 432 struct list_head list; 433 struct list_head card_list; 434 int num_dai; | 455 456 struct mutex mutex; 457 struct snd_soc_card *card; 458 struct list_head list; 459 struct list_head card_list; 460 int num_dai; |
461 enum snd_soc_compress_type compress_type; |
|
435 436 /* runtime */ 437 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ 438 unsigned int active; | 462 463 /* runtime */ 464 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ 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 */ 441 unsigned int cache_sync:1; /* Cache needs to be synced to hardware */ 442 unsigned int suspended:1; /* Codec is in suspend PM state */ 443 unsigned int probed:1; /* Codec has been probed */ 444 unsigned int ac97_registered:1; /* Codec has been AC97 registered */ 445 unsigned int ac97_created:1; /* Codec has been created by SoC */ 446 unsigned int sysfs_registered:1; /* codec has been sysfs registered */ | 466 unsigned int cache_only:1; /* Suppress writes to hardware */ 467 unsigned int cache_sync:1; /* Cache needs to be synced to hardware */ 468 unsigned int suspended:1; /* Codec is in suspend PM state */ 469 unsigned int probed:1; /* Codec has been probed */ 470 unsigned int ac97_registered:1; /* Codec has been AC97 registered */ 471 unsigned int ac97_created:1; /* Codec has been created by SoC */ 472 unsigned int sysfs_registered:1; /* codec has been sysfs registered */ |
473 unsigned int cache_init:1; /* codec cache has been initialized */ |
|
447 448 /* codec IO */ 449 void *control_data; /* codec control (i2c/3wire) data */ 450 hw_write_t hw_write; 451 unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); | 474 475 /* codec IO */ 476 void *control_data; /* codec control (i2c/3wire) data */ 477 hw_write_t hw_write; 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 454 /* dapm */ | 485 486 /* dapm */ |
455 u32 pop_time; 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; | 487 struct snd_soc_dapm_context dapm; |
461 462#ifdef CONFIG_DEBUG_FS 463 struct dentry *debugfs_codec_root; 464 struct dentry *debugfs_reg; | 488 489#ifdef CONFIG_DEBUG_FS 490 struct dentry *debugfs_codec_root; 491 struct dentry *debugfs_reg; |
465 struct dentry *debugfs_pop_time; | |
466 struct dentry *debugfs_dapm; 467#endif 468}; 469 470/* codec driver */ 471struct snd_soc_codec_driver { 472 473 /* driver ops */ --- 9 unchanged lines hidden (view full) --- 483 int (*display_register)(struct snd_soc_codec *, char *, 484 size_t, unsigned int); 485 int (*volatile_register)(unsigned int); 486 int (*readable_register)(unsigned int); 487 short reg_cache_size; 488 short reg_cache_step; 489 short reg_word_size; 490 const void *reg_cache_default; | 492 struct dentry *debugfs_dapm; 493#endif 494}; 495 496/* codec driver */ 497struct snd_soc_codec_driver { 498 499 /* driver ops */ --- 9 unchanged lines hidden (view full) --- 509 int (*display_register)(struct snd_soc_codec *, char *, 510 size_t, unsigned int); 511 int (*volatile_register)(unsigned int); 512 int (*readable_register)(unsigned int); 513 short reg_cache_size; 514 short reg_cache_step; 515 short reg_word_size; 516 const void *reg_cache_default; |
517 enum snd_soc_compress_type compress_type; |
|
491 492 /* codec bias level */ 493 int (*set_bias_level)(struct snd_soc_codec *, 494 enum snd_soc_bias_level level); 495}; 496 497/* SoC platform interface */ 498struct snd_soc_platform_driver { --- 50 unchanged lines hidden (view full) --- 549 550 /* codec/machine specific init - e.g. add machine controls */ 551 int (*init)(struct snd_soc_pcm_runtime *rtd); 552 553 /* machine stream operations */ 554 struct snd_soc_ops *ops; 555}; 556 | 518 519 /* codec bias level */ 520 int (*set_bias_level)(struct snd_soc_codec *, 521 enum snd_soc_bias_level level); 522}; 523 524/* SoC platform interface */ 525struct snd_soc_platform_driver { --- 50 unchanged lines hidden (view full) --- 576 577 /* codec/machine specific init - e.g. add machine controls */ 578 int (*init)(struct snd_soc_pcm_runtime *rtd); 579 580 /* machine stream operations */ 581 struct snd_soc_ops *ops; 582}; 583 |
584struct 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 600struct 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 */ 558struct snd_soc_card { 559 const char *name; 560 struct device *dev; 561 struct snd_card *snd_card; 562 struct module *owner; 563 564 struct list_head list; --- 9 unchanged lines hidden (view full) --- 574 int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); 575 int (*suspend_post)(struct platform_device *pdev, pm_message_t state); 576 int (*resume_pre)(struct platform_device *pdev); 577 int (*resume_post)(struct platform_device *pdev); 578 579 /* callbacks */ 580 int (*set_bias_level)(struct snd_soc_card *, 581 enum snd_soc_bias_level level); | 608/* SoC card */ 609struct snd_soc_card { 610 const char *name; 611 struct device *dev; 612 struct snd_card *snd_card; 613 struct module *owner; 614 615 struct list_head list; --- 9 unchanged lines hidden (view full) --- 625 int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); 626 int (*suspend_post)(struct platform_device *pdev, pm_message_t state); 627 int (*resume_pre)(struct platform_device *pdev); 628 int (*resume_post)(struct platform_device *pdev); 629 630 /* callbacks */ 631 int (*set_bias_level)(struct snd_soc_card *, 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 583 long pmdown_time; 584 585 /* CPU <--> Codec DAI links */ 586 struct snd_soc_dai_link *dai_link; 587 int num_links; 588 struct snd_soc_pcm_runtime *rtd; 589 int num_rtd; 590 | 635 636 long pmdown_time; 637 638 /* CPU <--> Codec DAI links */ 639 struct snd_soc_dai_link *dai_link; 640 int num_links; 641 struct snd_soc_pcm_runtime *rtd; 642 int num_rtd; 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; 592 593 /* lists of probed devices belonging to this card */ 594 struct list_head codec_dev_list; 595 struct list_head platform_dev_list; 596 struct list_head dai_dev_list; | 657 struct work_struct deferred_resume_work; 658 659 /* lists of probed devices belonging to this card */ 660 struct list_head codec_dev_list; 661 struct list_head platform_dev_list; 662 struct list_head dai_dev_list; |
663 664 struct list_head paths; 665 666#ifdef CONFIG_DEBUG_FS 667 struct dentry *debugfs_card_root; 668 struct dentry *debugfs_pop_time; 669#endif 670 u32 pop_time; |
|
597}; 598 599/* SoC machine DAI configuration, glues a codec and cpu DAI together */ 600struct snd_soc_pcm_runtime { 601 struct device dev; 602 struct snd_soc_card *card; 603 struct snd_soc_dai_link *dai_link; 604 --- 29 unchanged lines hidden (view full) --- 634 unsigned int max; 635 unsigned int mask; 636 const char **texts; 637 const unsigned int *values; 638 void *dapm; 639}; 640 641/* codec IO */ | 671}; 672 673/* SoC machine DAI configuration, glues a codec and cpu DAI together */ 674struct snd_soc_pcm_runtime { 675 struct device dev; 676 struct snd_soc_card *card; 677 struct snd_soc_dai_link *dai_link; 678 --- 29 unchanged lines hidden (view full) --- 708 unsigned int max; 709 unsigned int mask; 710 const char **texts; 711 const unsigned int *values; 712 void *dapm; 713}; 714 715/* codec IO */ |
642static inline unsigned int snd_soc_read(struct snd_soc_codec *codec, 643 unsigned int reg) 644{ 645 return codec->driver->read(codec, reg); 646} | 716unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); 717unsigned int snd_soc_write(struct snd_soc_codec *codec, 718 unsigned int reg, unsigned int val); |
647 | 719 |
648static 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 | |
654/* device driver data */ 655 656static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, 657 void *data) 658{ 659 dev_set_drvdata(codec->dev, data); 660} 661 --- 30 unchanged lines hidden --- | 720/* device driver data */ 721 722static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, 723 void *data) 724{ 725 dev_set_drvdata(codec->dev, data); 726} 727 --- 30 unchanged lines hidden --- |