aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/soc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sound/soc.h')
-rw-r--r--include/sound/soc.h245
1 files changed, 148 insertions, 97 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 65e9d03ed4f5..5c3bce83f28a 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -214,10 +214,10 @@
214 * @OFF: Power Off. No restrictions on transition times. 214 * @OFF: Power Off. No restrictions on transition times.
215 */ 215 */
216enum snd_soc_bias_level { 216enum 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
223struct snd_jack; 223struct snd_jack;
@@ -228,13 +228,17 @@ struct snd_soc_ops;
228struct snd_soc_dai_mode; 228struct snd_soc_dai_mode;
229struct snd_soc_pcm_runtime; 229struct snd_soc_pcm_runtime;
230struct snd_soc_dai; 230struct snd_soc_dai;
231struct snd_soc_dai_driver;
231struct snd_soc_platform; 232struct snd_soc_platform;
232struct snd_soc_dai_link; 233struct snd_soc_dai_link;
234struct snd_soc_platform_driver;
233struct snd_soc_codec; 235struct snd_soc_codec;
236struct snd_soc_codec_driver;
234struct soc_enum; 237struct soc_enum;
235struct snd_soc_ac97_ops; 238struct snd_soc_ac97_ops;
236struct snd_soc_jack; 239struct snd_soc_jack;
237struct snd_soc_jack_pin; 240struct snd_soc_jack_pin;
241
238#ifdef CONFIG_GPIOLIB 242#ifdef CONFIG_GPIOLIB
239struct snd_soc_jack_gpio; 243struct snd_soc_jack_gpio;
240#endif 244#endif
@@ -249,19 +253,18 @@ enum snd_soc_control_type {
249 SND_SOC_SPI, 253 SND_SOC_SPI,
250}; 254};
251 255
252int snd_soc_register_platform(struct snd_soc_platform *platform); 256int snd_soc_register_platform(struct device *dev,
253void snd_soc_unregister_platform(struct snd_soc_platform *platform); 257 struct snd_soc_platform_driver *platform_drv);
254int snd_soc_register_codec(struct snd_soc_codec *codec); 258void snd_soc_unregister_platform(struct device *dev);
255void snd_soc_unregister_codec(struct snd_soc_codec *codec); 259int snd_soc_register_codec(struct device *dev,
260 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);
256int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg); 263int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg);
257int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, 264int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
258 int addr_bits, int data_bits, 265 int addr_bits, int data_bits,
259 enum snd_soc_control_type control); 266 enum snd_soc_control_type control);
260 267
261/* pcm <-> DAI connect */
262void snd_soc_free_pcms(struct snd_soc_device *socdev);
263int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
264
265/* Utility functions to get clock rates from various things */ 268/* Utility functions to get clock rates from various things */
266int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); 269int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
267int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params); 270int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
@@ -273,7 +276,7 @@ int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
273 const struct snd_pcm_hardware *hw); 276 const struct snd_pcm_hardware *hw);
274 277
275/* Jack reporting */ 278/* Jack reporting */
276int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type, 279int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
277 struct snd_soc_jack *jack); 280 struct snd_soc_jack *jack);
278void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); 281void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
279int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, 282int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
@@ -382,7 +385,7 @@ struct snd_soc_jack_gpio {
382 int invert; 385 int invert;
383 int debounce_time; 386 int debounce_time;
384 struct snd_soc_jack *jack; 387 struct snd_soc_jack *jack;
385 struct work_struct work; 388 struct delayed_work work;
386 389
387 int (*jack_status_check)(void); 390 int (*jack_status_check)(void);
388}; 391};
@@ -390,7 +393,7 @@ struct snd_soc_jack_gpio {
390 393
391struct snd_soc_jack { 394struct snd_soc_jack {
392 struct snd_jack *jack; 395 struct snd_jack *jack;
393 struct snd_soc_card *card; 396 struct snd_soc_codec *codec;
394 struct list_head pins; 397 struct list_head pins;
395 int status; 398 int status;
396 struct blocking_notifier_head notifier; 399 struct blocking_notifier_head notifier;
@@ -398,15 +401,13 @@ struct snd_soc_jack {
398 401
399/* SoC PCM stream information */ 402/* SoC PCM stream information */
400struct snd_soc_pcm_stream { 403struct snd_soc_pcm_stream {
401 char *stream_name; 404 const char *stream_name;
402 u64 formats; /* SNDRV_PCM_FMTBIT_* */ 405 u64 formats; /* SNDRV_PCM_FMTBIT_* */
403 unsigned int rates; /* SNDRV_PCM_RATE_* */ 406 unsigned int rates; /* SNDRV_PCM_RATE_* */
404 unsigned int rate_min; /* min rate */ 407 unsigned int rate_min; /* min rate */
405 unsigned int rate_max; /* max rate */ 408 unsigned int rate_max; /* max rate */
406 unsigned int channels_min; /* min channels */ 409 unsigned int channels_min; /* min channels */
407 unsigned int channels_max; /* max channels */ 410 unsigned int channels_max; /* max channels */
408 unsigned int active; /* stream is in use */
409 void *dma_data; /* used by platform code */
410}; 411};
411 412
412/* SoC audio ops */ 413/* SoC audio ops */
@@ -419,44 +420,36 @@ struct snd_soc_ops {
419 int (*trigger)(struct snd_pcm_substream *, int); 420 int (*trigger)(struct snd_pcm_substream *, int);
420}; 421};
421 422
422/* SoC Audio Codec */ 423/* SoC Audio Codec device */
423struct snd_soc_codec { 424struct snd_soc_codec {
424 char *name; 425 const char *name;
425 struct module *owner; 426 int id;
426 struct mutex mutex;
427 struct device *dev; 427 struct device *dev;
428 struct snd_soc_device *socdev; 428 struct snd_soc_codec_driver *driver;
429 429
430 struct mutex mutex;
431 struct snd_soc_card *card;
430 struct list_head list; 432 struct list_head list;
431 433 struct list_head card_list;
432 /* callbacks */ 434 int num_dai;
433 int (*set_bias_level)(struct snd_soc_codec *,
434 enum snd_soc_bias_level level);
435 435
436 /* runtime */ 436 /* runtime */
437 struct snd_card *card;
438 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ 437 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
439 unsigned int active; 438 unsigned int active;
440 unsigned int pcm_devs; 439 unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */
441 void *drvdata; 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 */
442 447
443 /* codec IO */ 448 /* codec IO */
444 void *control_data; /* codec control (i2c/3wire) data */ 449 void *control_data; /* codec control (i2c/3wire) data */
445 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
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; 450 hw_write_t hw_write;
452 unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); 451 unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int);
453 void *reg_cache; 452 void *reg_cache;
454 short reg_cache_size;
455 short reg_cache_step;
456
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 453
461 /* dapm */ 454 /* dapm */
462 u32 pop_time; 455 u32 pop_time;
@@ -466,10 +459,6 @@ struct snd_soc_codec {
466 enum snd_soc_bias_level suspend_bias_level; 459 enum snd_soc_bias_level suspend_bias_level;
467 struct delayed_work delayed_work; 460 struct delayed_work delayed_work;
468 461
469 /* codec DAI's */
470 struct snd_soc_dai *dai;
471 unsigned int num_dai;
472
473#ifdef CONFIG_DEBUG_FS 462#ifdef CONFIG_DEBUG_FS
474 struct dentry *debugfs_codec_root; 463 struct dentry *debugfs_codec_root;
475 struct dentry *debugfs_reg; 464 struct dentry *debugfs_reg;
@@ -478,23 +467,40 @@ struct snd_soc_codec {
478#endif 467#endif
479}; 468};
480 469
481/* codec device */ 470/* codec driver */
482struct snd_soc_codec_device { 471struct snd_soc_codec_driver {
483 int (*probe)(struct platform_device *pdev); 472
484 int (*remove)(struct platform_device *pdev); 473 /* driver ops */
485 int (*suspend)(struct platform_device *pdev, pm_message_t state); 474 int (*probe)(struct snd_soc_codec *);
486 int (*resume)(struct platform_device *pdev); 475 int (*remove)(struct snd_soc_codec *);
476 int (*suspend)(struct snd_soc_codec *,
477 pm_message_t state);
478 int (*resume)(struct snd_soc_codec *);
479
480 /* codec IO */
481 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
482 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
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;
491
492 /* codec bias level */
493 int (*set_bias_level)(struct snd_soc_codec *,
494 enum snd_soc_bias_level level);
487}; 495};
488 496
489/* SoC platform interface */ 497/* SoC platform interface */
490struct snd_soc_platform { 498struct snd_soc_platform_driver {
491 char *name;
492 struct list_head list;
493 499
494 int (*probe)(struct platform_device *pdev); 500 int (*probe)(struct snd_soc_platform *);
495 int (*remove)(struct platform_device *pdev); 501 int (*remove)(struct snd_soc_platform *);
496 int (*suspend)(struct snd_soc_dai_link *dai_link); 502 int (*suspend)(struct snd_soc_dai *dai);
497 int (*resume)(struct snd_soc_dai_link *dai_link); 503 int (*resume)(struct snd_soc_dai *dai);
498 504
499 /* pcm creation and destruction */ 505 /* pcm creation and destruction */
500 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *, 506 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
@@ -509,23 +515,31 @@ struct snd_soc_platform {
509 struct snd_soc_dai *); 515 struct snd_soc_dai *);
510 516
511 /* platform stream ops */ 517 /* platform stream ops */
512 struct snd_pcm_ops *pcm_ops; 518 struct snd_pcm_ops *ops;
513}; 519};
514 520
515/* SoC machine DAI configuration, glues a codec and cpu DAI together */ 521struct snd_soc_platform {
516struct snd_soc_dai_link { 522 const char *name;
517 char *name; /* Codec name */ 523 int id;
518 char *stream_name; /* Stream name */ 524 struct device *dev;
525 struct snd_soc_platform_driver *driver;
519 526
520 /* DAI */ 527 unsigned int suspended:1; /* platform is suspended */
521 struct snd_soc_dai *codec_dai; 528 unsigned int probed:1;
522 struct snd_soc_dai *cpu_dai;
523 529
524 /* machine stream operations */ 530 struct snd_soc_card *card;
525 struct snd_soc_ops *ops; 531 struct list_head list;
532 struct list_head card_list;
533};
526 534
527 /* codec/machine specific init - e.g. add machine controls */ 535struct snd_soc_dai_link {
528 int (*init)(struct snd_soc_codec *codec); 536 /* config - must be set by machine driver */
537 const char *name; /* Codec name */
538 const char *stream_name; /* Stream name */
539 const char *codec_name; /* for multi-codec */
540 const char *platform_name; /* for multi-platform */
541 const char *cpu_dai_name;
542 const char *codec_dai_name;
529 543
530 /* Keep DAI active over suspend */ 544 /* Keep DAI active over suspend */
531 unsigned int ignore_suspend:1; 545 unsigned int ignore_suspend:1;
@@ -533,21 +547,24 @@ struct snd_soc_dai_link {
533 /* Symmetry requirements */ 547 /* Symmetry requirements */
534 unsigned int symmetric_rates:1; 548 unsigned int symmetric_rates:1;
535 549
536 /* Symmetry data - only valid if symmetry is being enforced */ 550 /* codec/machine specific init - e.g. add machine controls */
537 unsigned int rate; 551 int (*init)(struct snd_soc_pcm_runtime *rtd);
538 552
539 /* DAI pcm */ 553 /* machine stream operations */
540 struct snd_pcm *pcm; 554 struct snd_soc_ops *ops;
541}; 555};
542 556
543/* SoC card */ 557/* SoC card */
544struct snd_soc_card { 558struct snd_soc_card {
545 char *name; 559 const char *name;
546 struct device *dev; 560 struct device *dev;
561 struct snd_card *snd_card;
562 struct module *owner;
547 563
548 struct list_head list; 564 struct list_head list;
565 struct mutex mutex;
549 566
550 int instantiated; 567 bool instantiated;
551 568
552 int (*probe)(struct platform_device *pdev); 569 int (*probe)(struct platform_device *pdev);
553 int (*remove)(struct platform_device *pdev); 570 int (*remove)(struct platform_device *pdev);
@@ -568,28 +585,38 @@ struct snd_soc_card {
568 /* CPU <--> Codec DAI links */ 585 /* CPU <--> Codec DAI links */
569 struct snd_soc_dai_link *dai_link; 586 struct snd_soc_dai_link *dai_link;
570 int num_links; 587 int num_links;
588 struct snd_soc_pcm_runtime *rtd;
589 int num_rtd;
571 590
572 struct snd_soc_device *socdev;
573
574 struct snd_soc_codec *codec;
575
576 struct snd_soc_platform *platform;
577 struct delayed_work delayed_work;
578 struct work_struct deferred_resume_work; 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;
579}; 597};
580 598
581/* SoC Device - the audio subsystem */ 599/* SoC machine DAI configuration, glues a codec and cpu DAI together */
582struct snd_soc_device { 600struct snd_soc_pcm_runtime {
583 struct device *dev; 601 struct device dev;
584 struct snd_soc_card *card; 602 struct snd_soc_card *card;
585 struct snd_soc_codec_device *codec_dev; 603 struct snd_soc_dai_link *dai_link;
586 void *codec_data; 604
587}; 605 unsigned int complete:1;
606 unsigned int dev_registered:1;
607
608 /* Symmetry data - only valid if symmetry is being enforced */
609 unsigned int rate;
610 long pmdown_time;
588 611
589/* runtime channel data */ 612 /* runtime devices */
590struct snd_soc_pcm_runtime { 613 struct snd_pcm *pcm;
591 struct snd_soc_dai_link *dai; 614 struct snd_soc_codec *codec;
592 struct snd_soc_device *socdev; 615 struct snd_soc_platform *platform;
616 struct snd_soc_dai *codec_dai;
617 struct snd_soc_dai *cpu_dai;
618
619 struct delayed_work delayed_work;
593}; 620};
594 621
595/* mixer control */ 622/* mixer control */
@@ -615,24 +642,48 @@ struct soc_enum {
615static inline unsigned int snd_soc_read(struct snd_soc_codec *codec, 642static inline unsigned int snd_soc_read(struct snd_soc_codec *codec,
616 unsigned int reg) 643 unsigned int reg)
617{ 644{
618 return codec->read(codec, reg); 645 return codec->driver->read(codec, reg);
619} 646}
620 647
621static inline unsigned int snd_soc_write(struct snd_soc_codec *codec, 648static inline unsigned int snd_soc_write(struct snd_soc_codec *codec,
622 unsigned int reg, unsigned int val) 649 unsigned int reg, unsigned int val)
623{ 650{
624 return codec->write(codec, reg, val); 651 return codec->driver->write(codec, reg, val);
625} 652}
626 653
654/* device driver data */
655
627static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, 656static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
628 void *data) 657 void *data)
629{ 658{
630 codec->drvdata = data; 659 dev_set_drvdata(codec->dev, data);
631} 660}
632 661
633static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec) 662static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec)
634{ 663{
635 return codec->drvdata; 664 return dev_get_drvdata(codec->dev);
665}
666
667static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform,
668 void *data)
669{
670 dev_set_drvdata(platform->dev, data);
671}
672
673static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform)
674{
675 return dev_get_drvdata(platform->dev);
676}
677
678static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd,
679 void *data)
680{
681 dev_set_drvdata(&rtd->dev, data);
682}
683
684static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd)
685{
686 return dev_get_drvdata(&rtd->dev);
636} 687}
637 688
638#include <sound/soc-dai.h> 689#include <sound/soc-dai.h>