| .. | .. |
|---|
| 19 | 19 | #include <linux/kernel.h> |
|---|
| 20 | 20 | #include <linux/regmap.h> |
|---|
| 21 | 21 | #include <linux/log2.h> |
|---|
| 22 | +#include <linux/android_kabi.h> |
|---|
| 22 | 23 | #include <sound/core.h> |
|---|
| 23 | 24 | #include <sound/pcm.h> |
|---|
| 24 | 25 | #include <sound/compress_driver.h> |
|---|
| .. | .. |
|---|
| 307 | 308 | .put = snd_soc_bytes_put, .private_value = \ |
|---|
| 308 | 309 | ((unsigned long)&(struct soc_bytes) \ |
|---|
| 309 | 310 | {.base = xbase, .num_regs = xregs }) } |
|---|
| 311 | +#define SND_SOC_BYTES_E(xname, xbase, xregs, xhandler_get, xhandler_put) \ |
|---|
| 312 | +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
|---|
| 313 | + .info = snd_soc_bytes_info, .get = xhandler_get, \ |
|---|
| 314 | + .put = xhandler_put, .private_value = \ |
|---|
| 315 | + ((unsigned long)&(struct soc_bytes) \ |
|---|
| 316 | + {.base = xbase, .num_regs = xregs }) } |
|---|
| 310 | 317 | |
|---|
| 311 | 318 | #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask) \ |
|---|
| 312 | 319 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
|---|
| .. | .. |
|---|
| 370 | 377 | #define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \ |
|---|
| 371 | 378 | const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts) |
|---|
| 372 | 379 | |
|---|
| 373 | | -/* |
|---|
| 374 | | - * Component probe and remove ordering levels for components with runtime |
|---|
| 375 | | - * dependencies. |
|---|
| 376 | | - */ |
|---|
| 377 | | -#define SND_SOC_COMP_ORDER_FIRST -2 |
|---|
| 378 | | -#define SND_SOC_COMP_ORDER_EARLY -1 |
|---|
| 379 | | -#define SND_SOC_COMP_ORDER_NORMAL 0 |
|---|
| 380 | | -#define SND_SOC_COMP_ORDER_LATE 1 |
|---|
| 381 | | -#define SND_SOC_COMP_ORDER_LAST 2 |
|---|
| 382 | | - |
|---|
| 383 | | -/* DAI Link Host Mode Support */ |
|---|
| 384 | | -#define SND_SOC_DAI_LINK_NO_HOST 0x1 |
|---|
| 385 | | -#define SND_SOC_DAI_LINK_OPT_HOST 0x2 |
|---|
| 386 | | - |
|---|
| 387 | | -/* |
|---|
| 388 | | - * Bias levels |
|---|
| 389 | | - * |
|---|
| 390 | | - * @ON: Bias is fully on for audio playback and capture operations. |
|---|
| 391 | | - * @PREPARE: Prepare for audio operations. Called before DAPM switching for |
|---|
| 392 | | - * stream start and stop operations. |
|---|
| 393 | | - * @STANDBY: Low power standby state when no playback/capture operations are |
|---|
| 394 | | - * in progress. NOTE: The transition time between STANDBY and ON |
|---|
| 395 | | - * should be as fast as possible and no longer than 10ms. |
|---|
| 396 | | - * @OFF: Power Off. No restrictions on transition times. |
|---|
| 397 | | - */ |
|---|
| 398 | | -enum snd_soc_bias_level { |
|---|
| 399 | | - SND_SOC_BIAS_OFF = 0, |
|---|
| 400 | | - SND_SOC_BIAS_STANDBY = 1, |
|---|
| 401 | | - SND_SOC_BIAS_PREPARE = 2, |
|---|
| 402 | | - SND_SOC_BIAS_ON = 3, |
|---|
| 403 | | -}; |
|---|
| 404 | | - |
|---|
| 405 | 380 | struct device_node; |
|---|
| 406 | 381 | struct snd_jack; |
|---|
| 407 | 382 | struct snd_soc_card; |
|---|
| .. | .. |
|---|
| 430 | 405 | SND_SOC_PCM_CLASS_BE = 1, |
|---|
| 431 | 406 | }; |
|---|
| 432 | 407 | |
|---|
| 433 | | -enum snd_soc_card_subclass { |
|---|
| 434 | | - SND_SOC_CARD_CLASS_INIT = 0, |
|---|
| 435 | | - SND_SOC_CARD_CLASS_RUNTIME = 1, |
|---|
| 436 | | -}; |
|---|
| 437 | | - |
|---|
| 438 | 408 | int snd_soc_register_card(struct snd_soc_card *card); |
|---|
| 439 | 409 | int snd_soc_unregister_card(struct snd_soc_card *card); |
|---|
| 440 | 410 | int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card); |
|---|
| .. | .. |
|---|
| 453 | 423 | } |
|---|
| 454 | 424 | #endif |
|---|
| 455 | 425 | int snd_soc_poweroff(struct device *dev); |
|---|
| 456 | | -int snd_soc_add_component(struct device *dev, |
|---|
| 457 | | - struct snd_soc_component *component, |
|---|
| 458 | | - const struct snd_soc_component_driver *component_driver, |
|---|
| 459 | | - struct snd_soc_dai_driver *dai_drv, |
|---|
| 460 | | - int num_dai); |
|---|
| 426 | +int snd_soc_component_initialize(struct snd_soc_component *component, |
|---|
| 427 | + const struct snd_soc_component_driver *driver, |
|---|
| 428 | + struct device *dev); |
|---|
| 429 | +int snd_soc_add_component(struct snd_soc_component *component, |
|---|
| 430 | + struct snd_soc_dai_driver *dai_drv, |
|---|
| 431 | + int num_dai); |
|---|
| 461 | 432 | int snd_soc_register_component(struct device *dev, |
|---|
| 462 | 433 | const struct snd_soc_component_driver *component_driver, |
|---|
| 463 | 434 | struct snd_soc_dai_driver *dai_drv, int num_dai); |
|---|
| .. | .. |
|---|
| 465 | 436 | const struct snd_soc_component_driver *component_driver, |
|---|
| 466 | 437 | struct snd_soc_dai_driver *dai_drv, int num_dai); |
|---|
| 467 | 438 | void snd_soc_unregister_component(struct device *dev); |
|---|
| 439 | +void snd_soc_unregister_component_by_driver(struct device *dev, |
|---|
| 440 | + const struct snd_soc_component_driver *component_driver); |
|---|
| 441 | +struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev, |
|---|
| 442 | + const char *driver_name); |
|---|
| 468 | 443 | struct snd_soc_component *snd_soc_lookup_component(struct device *dev, |
|---|
| 469 | 444 | const char *driver_name); |
|---|
| 470 | 445 | |
|---|
| .. | .. |
|---|
| 480 | 455 | |
|---|
| 481 | 456 | void snd_soc_disconnect_sync(struct device *dev); |
|---|
| 482 | 457 | |
|---|
| 483 | | -struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, |
|---|
| 484 | | - const char *dai_link, int stream); |
|---|
| 485 | 458 | struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, |
|---|
| 486 | | - const char *dai_link); |
|---|
| 459 | + struct snd_soc_dai_link *dai_link); |
|---|
| 487 | 460 | |
|---|
| 488 | 461 | bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd); |
|---|
| 489 | | -void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream); |
|---|
| 490 | | -void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream); |
|---|
| 462 | + |
|---|
| 463 | +void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd, |
|---|
| 464 | + int stream, int action); |
|---|
| 465 | +static inline void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, |
|---|
| 466 | + int stream) |
|---|
| 467 | +{ |
|---|
| 468 | + snd_soc_runtime_action(rtd, stream, 1); |
|---|
| 469 | +} |
|---|
| 470 | +static inline void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, |
|---|
| 471 | + int stream) |
|---|
| 472 | +{ |
|---|
| 473 | + snd_soc_runtime_action(rtd, stream, -1); |
|---|
| 474 | +} |
|---|
| 475 | + |
|---|
| 476 | +int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd, |
|---|
| 477 | + struct snd_pcm_hardware *hw, int stream); |
|---|
| 491 | 478 | |
|---|
| 492 | 479 | int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, |
|---|
| 493 | 480 | unsigned int dai_fmt); |
|---|
| .. | .. |
|---|
| 512 | 499 | int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, |
|---|
| 513 | 500 | const struct snd_pcm_hardware *hw); |
|---|
| 514 | 501 | |
|---|
| 515 | | -int soc_dai_hw_params(struct snd_pcm_substream *substream, |
|---|
| 516 | | - struct snd_pcm_hw_params *params, |
|---|
| 517 | | - struct snd_soc_dai *dai); |
|---|
| 518 | | - |
|---|
| 519 | 502 | /* Jack reporting */ |
|---|
| 520 | | -int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type, |
|---|
| 521 | | - struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins, |
|---|
| 522 | | - unsigned int num_pins); |
|---|
| 523 | | - |
|---|
| 524 | 503 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); |
|---|
| 525 | 504 | int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, |
|---|
| 526 | 505 | struct snd_soc_jack_pin *pins); |
|---|
| .. | .. |
|---|
| 560 | 539 | } |
|---|
| 561 | 540 | #endif |
|---|
| 562 | 541 | |
|---|
| 563 | | -void snd_soc_card_change_online_state(struct snd_soc_card *soc_card, |
|---|
| 564 | | - int online); |
|---|
| 565 | 542 | struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component); |
|---|
| 566 | 543 | struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component, |
|---|
| 567 | 544 | unsigned int id, unsigned int id_mask); |
|---|
| .. | .. |
|---|
| 592 | 569 | struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, |
|---|
| 593 | 570 | void *data, const char *long_name, |
|---|
| 594 | 571 | const char *prefix); |
|---|
| 595 | | -struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, |
|---|
| 596 | | - const char *name); |
|---|
| 597 | 572 | int snd_soc_add_component_controls(struct snd_soc_component *component, |
|---|
| 598 | 573 | const struct snd_kcontrol_new *controls, unsigned int num_controls); |
|---|
| 599 | 574 | int snd_soc_add_card_controls(struct snd_soc_card *soc_card, |
|---|
| .. | .. |
|---|
| 743 | 718 | unsigned int channels_min; /* min channels */ |
|---|
| 744 | 719 | unsigned int channels_max; /* max channels */ |
|---|
| 745 | 720 | unsigned int sig_bits; /* number of bits of content */ |
|---|
| 746 | | - const char *aif_name; /* DAPM AIF widget name */ |
|---|
| 747 | 721 | }; |
|---|
| 748 | 722 | |
|---|
| 749 | 723 | /* SoC audio ops */ |
|---|
| .. | .. |
|---|
| 763 | 737 | int (*trigger)(struct snd_compr_stream *); |
|---|
| 764 | 738 | }; |
|---|
| 765 | 739 | |
|---|
| 766 | | -/* component interface */ |
|---|
| 767 | | -struct snd_soc_component_driver { |
|---|
| 768 | | - const char *name; |
|---|
| 769 | | - |
|---|
| 770 | | - /* Default control and setup, added after probe() is run */ |
|---|
| 771 | | - const struct snd_kcontrol_new *controls; |
|---|
| 772 | | - unsigned int num_controls; |
|---|
| 773 | | - const struct snd_soc_dapm_widget *dapm_widgets; |
|---|
| 774 | | - unsigned int num_dapm_widgets; |
|---|
| 775 | | - const struct snd_soc_dapm_route *dapm_routes; |
|---|
| 776 | | - unsigned int num_dapm_routes; |
|---|
| 777 | | - |
|---|
| 778 | | - int (*probe)(struct snd_soc_component *); |
|---|
| 779 | | - void (*remove)(struct snd_soc_component *); |
|---|
| 780 | | - int (*suspend)(struct snd_soc_component *); |
|---|
| 781 | | - int (*resume)(struct snd_soc_component *); |
|---|
| 782 | | - |
|---|
| 783 | | - unsigned int (*read)(struct snd_soc_component *, unsigned int); |
|---|
| 784 | | - int (*write)(struct snd_soc_component *, unsigned int, unsigned int); |
|---|
| 785 | | - |
|---|
| 786 | | - /* pcm creation and destruction */ |
|---|
| 787 | | - int (*pcm_new)(struct snd_soc_pcm_runtime *); |
|---|
| 788 | | - void (*pcm_free)(struct snd_pcm *); |
|---|
| 789 | | - |
|---|
| 790 | | - /* component wide operations */ |
|---|
| 791 | | - int (*set_sysclk)(struct snd_soc_component *component, |
|---|
| 792 | | - int clk_id, int source, unsigned int freq, int dir); |
|---|
| 793 | | - int (*set_pll)(struct snd_soc_component *component, int pll_id, |
|---|
| 794 | | - int source, unsigned int freq_in, unsigned int freq_out); |
|---|
| 795 | | - int (*set_jack)(struct snd_soc_component *component, |
|---|
| 796 | | - struct snd_soc_jack *jack, void *data); |
|---|
| 797 | | - |
|---|
| 798 | | - /* DT */ |
|---|
| 799 | | - int (*of_xlate_dai_name)(struct snd_soc_component *component, |
|---|
| 800 | | - struct of_phandle_args *args, |
|---|
| 801 | | - const char **dai_name); |
|---|
| 802 | | - int (*of_xlate_dai_id)(struct snd_soc_component *comment, |
|---|
| 803 | | - struct device_node *endpoint); |
|---|
| 804 | | - void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type, |
|---|
| 805 | | - int subseq); |
|---|
| 806 | | - int (*stream_event)(struct snd_soc_component *, int event); |
|---|
| 807 | | - int (*set_bias_level)(struct snd_soc_component *component, |
|---|
| 808 | | - enum snd_soc_bias_level level); |
|---|
| 809 | | - |
|---|
| 810 | | - /* |
|---|
| 811 | | - * For platform-caused delay reporting, where the thread blocks waiting |
|---|
| 812 | | - * for the delay amount to be determined. Defining this will cause the |
|---|
| 813 | | - * ASoC core to skip calling the delay callbacks for all components in |
|---|
| 814 | | - * the runtime. |
|---|
| 815 | | - * Optional. |
|---|
| 816 | | - */ |
|---|
| 817 | | - snd_pcm_sframes_t (*delay_blk)(struct snd_pcm_substream *substream, |
|---|
| 818 | | - struct snd_soc_dai *dai); |
|---|
| 819 | | - |
|---|
| 820 | | - const struct snd_pcm_ops *ops; |
|---|
| 821 | | - const struct snd_compr_ops *compr_ops; |
|---|
| 822 | | - |
|---|
| 823 | | - /* probe ordering - for components with runtime dependencies */ |
|---|
| 824 | | - int probe_order; |
|---|
| 825 | | - int remove_order; |
|---|
| 826 | | - |
|---|
| 827 | | - /* bits */ |
|---|
| 828 | | - unsigned int idle_bias_on:1; |
|---|
| 829 | | - unsigned int suspend_bias_off:1; |
|---|
| 830 | | - unsigned int use_pmdown_time:1; /* care pmdown_time at stop */ |
|---|
| 831 | | - unsigned int endianness:1; |
|---|
| 832 | | - unsigned int non_legacy_dai_naming:1; |
|---|
| 833 | | - |
|---|
| 834 | | - /* this component uses topology and ignore machine driver FEs */ |
|---|
| 835 | | - const char *ignore_machine; |
|---|
| 836 | | - const char *topology_name_prefix; |
|---|
| 837 | | - int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd, |
|---|
| 838 | | - struct snd_pcm_hw_params *params); |
|---|
| 839 | | - bool use_dai_pcm_id; /* use the DAI link PCM ID as PCM device number */ |
|---|
| 840 | | - int be_pcm_base; /* base device ID for all BE PCMs */ |
|---|
| 841 | | -}; |
|---|
| 842 | | - |
|---|
| 843 | | -struct snd_soc_component { |
|---|
| 844 | | - const char *name; |
|---|
| 845 | | - int id; |
|---|
| 846 | | - const char *name_prefix; |
|---|
| 847 | | - struct device *dev; |
|---|
| 848 | | - struct snd_soc_card *card; |
|---|
| 849 | | - |
|---|
| 850 | | - unsigned int active; |
|---|
| 851 | | - |
|---|
| 852 | | - unsigned int suspended:1; /* is in suspend PM state */ |
|---|
| 853 | | - |
|---|
| 854 | | - struct list_head list; |
|---|
| 855 | | - struct list_head card_aux_list; /* for auxiliary bound components */ |
|---|
| 856 | | - struct list_head card_list; |
|---|
| 857 | | - |
|---|
| 858 | | - const struct snd_soc_component_driver *driver; |
|---|
| 859 | | - |
|---|
| 860 | | - struct list_head dai_list; |
|---|
| 861 | | - int num_dai; |
|---|
| 862 | | - |
|---|
| 863 | | - struct regmap *regmap; |
|---|
| 864 | | - int val_bytes; |
|---|
| 865 | | - |
|---|
| 866 | | - struct mutex io_mutex; |
|---|
| 867 | | - |
|---|
| 868 | | - /* attached dynamic objects */ |
|---|
| 869 | | - struct list_head dobj_list; |
|---|
| 870 | | - |
|---|
| 871 | | - /* |
|---|
| 872 | | - * DO NOT use any of the fields below in drivers, they are temporary and |
|---|
| 873 | | - * are going to be removed again soon. If you use them in driver code the |
|---|
| 874 | | - * driver will be marked as BROKEN when these fields are removed. |
|---|
| 875 | | - */ |
|---|
| 876 | | - |
|---|
| 877 | | - /* Don't use these, use snd_soc_component_get_dapm() */ |
|---|
| 878 | | - struct snd_soc_dapm_context dapm; |
|---|
| 879 | | - |
|---|
| 880 | | - /* machine specific init */ |
|---|
| 881 | | - int (*init)(struct snd_soc_component *component); |
|---|
| 882 | | - |
|---|
| 883 | | -#ifdef CONFIG_DEBUG_FS |
|---|
| 884 | | - struct dentry *debugfs_root; |
|---|
| 885 | | - const char *debugfs_prefix; |
|---|
| 886 | | -#endif |
|---|
| 887 | | -}; |
|---|
| 888 | | - |
|---|
| 889 | | -struct snd_soc_rtdcom_list { |
|---|
| 890 | | - struct snd_soc_component *component; |
|---|
| 891 | | - struct list_head list; /* rtd::component_list */ |
|---|
| 892 | | -}; |
|---|
| 893 | 740 | struct snd_soc_component* |
|---|
| 894 | 741 | snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd, |
|---|
| 895 | 742 | const char *driver_name); |
|---|
| 896 | | -#define for_each_rtdcom(rtd, rtdcom) \ |
|---|
| 897 | | - list_for_each_entry(rtdcom, &(rtd)->component_list, list) |
|---|
| 898 | | -#define for_each_rtdcom_safe(rtd, rtdcom1, rtdcom2) \ |
|---|
| 899 | | - list_for_each_entry_safe(rtdcom1, rtdcom2, &(rtd)->component_list, list) |
|---|
| 900 | 743 | |
|---|
| 901 | 744 | struct snd_soc_dai_link_component { |
|---|
| 902 | 745 | const char *name; |
|---|
| .. | .. |
|---|
| 904 | 747 | const char *dai_name; |
|---|
| 905 | 748 | }; |
|---|
| 906 | 749 | |
|---|
| 907 | | -enum snd_soc_async_ops { |
|---|
| 908 | | - ASYNC_DPCM_SND_SOC_OPEN = 1 << 0, |
|---|
| 909 | | - ASYNC_DPCM_SND_SOC_CLOSE = 1 << 1, |
|---|
| 910 | | - ASYNC_DPCM_SND_SOC_PREPARE = 1 << 2, |
|---|
| 911 | | - ASYNC_DPCM_SND_SOC_HW_PARAMS = 1 << 3, |
|---|
| 912 | | - ASYNC_DPCM_SND_SOC_FREE = 1 << 4, |
|---|
| 913 | | -}; |
|---|
| 914 | | - |
|---|
| 915 | 750 | struct snd_soc_dai_link { |
|---|
| 916 | 751 | /* config - must be set by machine driver */ |
|---|
| 917 | 752 | const char *name; /* Codec name */ |
|---|
| 918 | 753 | const char *stream_name; /* Stream name */ |
|---|
| 754 | + |
|---|
| 919 | 755 | /* |
|---|
| 920 | 756 | * You MAY specify the link's CPU-side device, either by device name, |
|---|
| 921 | 757 | * or by DT/OF node, but not both. If this information is omitted, |
|---|
| .. | .. |
|---|
| 923 | 759 | * must be globally unique. These fields are currently typically used |
|---|
| 924 | 760 | * only for codec to codec links, or systems using device tree. |
|---|
| 925 | 761 | */ |
|---|
| 926 | | - const char *cpu_name; |
|---|
| 927 | | - struct device_node *cpu_of_node; |
|---|
| 928 | 762 | /* |
|---|
| 929 | 763 | * You MAY specify the DAI name of the CPU DAI. If this information is |
|---|
| 930 | 764 | * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node |
|---|
| 931 | 765 | * only, which only works well when that device exposes a single DAI. |
|---|
| 932 | 766 | */ |
|---|
| 933 | | - const char *cpu_dai_name; |
|---|
| 767 | + struct snd_soc_dai_link_component *cpus; |
|---|
| 768 | + unsigned int num_cpus; |
|---|
| 769 | + |
|---|
| 934 | 770 | /* |
|---|
| 935 | 771 | * You MUST specify the link's codec, either by device name, or by |
|---|
| 936 | 772 | * DT/OF node, but not both. |
|---|
| 937 | 773 | */ |
|---|
| 938 | | - const char *codec_name; |
|---|
| 939 | | - struct device_node *codec_of_node; |
|---|
| 940 | 774 | /* You MUST specify the DAI name within the codec */ |
|---|
| 941 | | - const char *codec_dai_name; |
|---|
| 942 | | - |
|---|
| 943 | 775 | struct snd_soc_dai_link_component *codecs; |
|---|
| 944 | 776 | unsigned int num_codecs; |
|---|
| 945 | 777 | |
|---|
| 946 | 778 | /* |
|---|
| 947 | 779 | * You MAY specify the link's platform/PCM/DMA driver, either by |
|---|
| 948 | 780 | * device name, or by DT/OF node, but not both. Some forms of link |
|---|
| 949 | | - * do not need a platform. |
|---|
| 781 | + * do not need a platform. In such case, platforms are not mandatory. |
|---|
| 950 | 782 | */ |
|---|
| 951 | | - const char *platform_name; |
|---|
| 952 | | - struct device_node *platform_of_node; |
|---|
| 783 | + struct snd_soc_dai_link_component *platforms; |
|---|
| 784 | + unsigned int num_platforms; |
|---|
| 785 | + |
|---|
| 953 | 786 | int id; /* optional ID for machine driver link identification */ |
|---|
| 954 | 787 | |
|---|
| 955 | 788 | const struct snd_soc_pcm_stream *params; |
|---|
| .. | .. |
|---|
| 962 | 795 | /* codec/machine specific init - e.g. add machine controls */ |
|---|
| 963 | 796 | int (*init)(struct snd_soc_pcm_runtime *rtd); |
|---|
| 964 | 797 | |
|---|
| 798 | + /* codec/machine specific exit - dual of init() */ |
|---|
| 799 | + void (*exit)(struct snd_soc_pcm_runtime *rtd); |
|---|
| 800 | + |
|---|
| 965 | 801 | /* optional hw_params re-writing for BE and FE sync */ |
|---|
| 966 | 802 | int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd, |
|---|
| 967 | 803 | struct snd_pcm_hw_params *params); |
|---|
| .. | .. |
|---|
| 971 | 807 | const struct snd_soc_compr_ops *compr_ops; |
|---|
| 972 | 808 | |
|---|
| 973 | 809 | /* Mark this pcm with non atomic ops */ |
|---|
| 974 | | - bool nonatomic; |
|---|
| 810 | + unsigned int nonatomic:1; |
|---|
| 975 | 811 | |
|---|
| 976 | 812 | /* For unidirectional dai links */ |
|---|
| 977 | 813 | unsigned int playback_only:1; |
|---|
| .. | .. |
|---|
| 991 | 827 | /* This DAI link can route to other DAI links at runtime (Frontend)*/ |
|---|
| 992 | 828 | unsigned int dynamic:1; |
|---|
| 993 | 829 | |
|---|
| 994 | | - /* This DAI link can be reconfigured at runtime (Backend) */ |
|---|
| 995 | | - unsigned int dynamic_be:1; |
|---|
| 996 | | - |
|---|
| 997 | | - /* |
|---|
| 998 | | - * This DAI can support no host IO (no pcm data is |
|---|
| 999 | | - * copied to from host) |
|---|
| 1000 | | - */ |
|---|
| 1001 | | - unsigned int no_host_mode:2; |
|---|
| 1002 | | - |
|---|
| 1003 | 830 | /* DPCM capture and Playback support */ |
|---|
| 1004 | 831 | unsigned int dpcm_capture:1; |
|---|
| 1005 | 832 | unsigned int dpcm_playback:1; |
|---|
| .. | .. |
|---|
| 1017 | 844 | /* Do not create a PCM for this DAI link (Backend link) */ |
|---|
| 1018 | 845 | unsigned int ignore:1; |
|---|
| 1019 | 846 | |
|---|
| 1020 | | - struct list_head list; /* DAI link list of the soc card */ |
|---|
| 847 | +#ifdef CONFIG_SND_SOC_TOPOLOGY |
|---|
| 1021 | 848 | struct snd_soc_dobj dobj; /* For topology */ |
|---|
| 849 | +#endif |
|---|
| 1022 | 850 | |
|---|
| 1023 | | - /* this value determines what all ops can be started asynchronously */ |
|---|
| 1024 | | - enum snd_soc_async_ops async_ops; |
|---|
| 851 | + ANDROID_KABI_RESERVE(1); |
|---|
| 1025 | 852 | }; |
|---|
| 853 | +#define for_each_link_codecs(link, i, codec) \ |
|---|
| 854 | + for ((i) = 0; \ |
|---|
| 855 | + ((i) < link->num_codecs) && ((codec) = &link->codecs[i]); \ |
|---|
| 856 | + (i)++) |
|---|
| 857 | + |
|---|
| 858 | +#define for_each_link_platforms(link, i, platform) \ |
|---|
| 859 | + for ((i) = 0; \ |
|---|
| 860 | + ((i) < link->num_platforms) && \ |
|---|
| 861 | + ((platform) = &link->platforms[i]); \ |
|---|
| 862 | + (i)++) |
|---|
| 863 | + |
|---|
| 864 | +#define for_each_link_cpus(link, i, cpu) \ |
|---|
| 865 | + for ((i) = 0; \ |
|---|
| 866 | + ((i) < link->num_cpus) && ((cpu) = &link->cpus[i]); \ |
|---|
| 867 | + (i)++) |
|---|
| 868 | + |
|---|
| 869 | +/* |
|---|
| 870 | + * Sample 1 : Single CPU/Codec/Platform |
|---|
| 871 | + * |
|---|
| 872 | + * SND_SOC_DAILINK_DEFS(test, |
|---|
| 873 | + * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")), |
|---|
| 874 | + * DAILINK_COMP_ARRAY(COMP_CODEC("codec", "codec_dai")), |
|---|
| 875 | + * DAILINK_COMP_ARRAY(COMP_PLATFORM("platform"))); |
|---|
| 876 | + * |
|---|
| 877 | + * struct snd_soc_dai_link link = { |
|---|
| 878 | + * ... |
|---|
| 879 | + * SND_SOC_DAILINK_REG(test), |
|---|
| 880 | + * }; |
|---|
| 881 | + * |
|---|
| 882 | + * Sample 2 : Multi CPU/Codec, no Platform |
|---|
| 883 | + * |
|---|
| 884 | + * SND_SOC_DAILINK_DEFS(test, |
|---|
| 885 | + * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"), |
|---|
| 886 | + * COMP_CPU("cpu_dai2")), |
|---|
| 887 | + * DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"), |
|---|
| 888 | + * COMP_CODEC("codec2", "codec_dai2"))); |
|---|
| 889 | + * |
|---|
| 890 | + * struct snd_soc_dai_link link = { |
|---|
| 891 | + * ... |
|---|
| 892 | + * SND_SOC_DAILINK_REG(test), |
|---|
| 893 | + * }; |
|---|
| 894 | + * |
|---|
| 895 | + * Sample 3 : Define each CPU/Codec/Platform manually |
|---|
| 896 | + * |
|---|
| 897 | + * SND_SOC_DAILINK_DEF(test_cpu, |
|---|
| 898 | + * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"), |
|---|
| 899 | + * COMP_CPU("cpu_dai2"))); |
|---|
| 900 | + * SND_SOC_DAILINK_DEF(test_codec, |
|---|
| 901 | + * DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"), |
|---|
| 902 | + * COMP_CODEC("codec2", "codec_dai2"))); |
|---|
| 903 | + * SND_SOC_DAILINK_DEF(test_platform, |
|---|
| 904 | + * DAILINK_COMP_ARRAY(COMP_PLATFORM("platform"))); |
|---|
| 905 | + * |
|---|
| 906 | + * struct snd_soc_dai_link link = { |
|---|
| 907 | + * ... |
|---|
| 908 | + * SND_SOC_DAILINK_REG(test_cpu, |
|---|
| 909 | + * test_codec, |
|---|
| 910 | + * test_platform), |
|---|
| 911 | + * }; |
|---|
| 912 | + * |
|---|
| 913 | + * Sample 4 : Sample3 without platform |
|---|
| 914 | + * |
|---|
| 915 | + * struct snd_soc_dai_link link = { |
|---|
| 916 | + * ... |
|---|
| 917 | + * SND_SOC_DAILINK_REG(test_cpu, |
|---|
| 918 | + * test_codec); |
|---|
| 919 | + * }; |
|---|
| 920 | + */ |
|---|
| 921 | + |
|---|
| 922 | +#define SND_SOC_DAILINK_REG1(name) SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms) |
|---|
| 923 | +#define SND_SOC_DAILINK_REG2(cpu, codec) SND_SOC_DAILINK_REG3(cpu, codec, null_dailink_component) |
|---|
| 924 | +#define SND_SOC_DAILINK_REG3(cpu, codec, platform) \ |
|---|
| 925 | + .cpus = cpu, \ |
|---|
| 926 | + .num_cpus = ARRAY_SIZE(cpu), \ |
|---|
| 927 | + .codecs = codec, \ |
|---|
| 928 | + .num_codecs = ARRAY_SIZE(codec), \ |
|---|
| 929 | + .platforms = platform, \ |
|---|
| 930 | + .num_platforms = ARRAY_SIZE(platform) |
|---|
| 931 | + |
|---|
| 932 | +#define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func |
|---|
| 933 | +#define SND_SOC_DAILINK_REG(...) \ |
|---|
| 934 | + SND_SOC_DAILINK_REGx(__VA_ARGS__, \ |
|---|
| 935 | + SND_SOC_DAILINK_REG3, \ |
|---|
| 936 | + SND_SOC_DAILINK_REG2, \ |
|---|
| 937 | + SND_SOC_DAILINK_REG1)(__VA_ARGS__) |
|---|
| 938 | + |
|---|
| 939 | +#define SND_SOC_DAILINK_DEF(name, def...) \ |
|---|
| 940 | + static struct snd_soc_dai_link_component name[] = { def } |
|---|
| 941 | + |
|---|
| 942 | +#define SND_SOC_DAILINK_DEFS(name, cpu, codec, platform...) \ |
|---|
| 943 | + SND_SOC_DAILINK_DEF(name##_cpus, cpu); \ |
|---|
| 944 | + SND_SOC_DAILINK_DEF(name##_codecs, codec); \ |
|---|
| 945 | + SND_SOC_DAILINK_DEF(name##_platforms, platform) |
|---|
| 946 | + |
|---|
| 947 | +#define DAILINK_COMP_ARRAY(param...) param |
|---|
| 948 | +#define COMP_EMPTY() { } |
|---|
| 949 | +#define COMP_CPU(_dai) { .dai_name = _dai, } |
|---|
| 950 | +#define COMP_CODEC(_name, _dai) { .name = _name, .dai_name = _dai, } |
|---|
| 951 | +#define COMP_PLATFORM(_name) { .name = _name } |
|---|
| 952 | +#define COMP_AUX(_name) { .name = _name } |
|---|
| 953 | +#define COMP_CODEC_CONF(_name) { .name = _name } |
|---|
| 954 | +#define COMP_DUMMY() { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", } |
|---|
| 955 | + |
|---|
| 956 | +extern struct snd_soc_dai_link_component null_dailink_component[0]; |
|---|
| 957 | + |
|---|
| 1026 | 958 | |
|---|
| 1027 | 959 | struct snd_soc_codec_conf { |
|---|
| 1028 | 960 | /* |
|---|
| 1029 | 961 | * specify device either by device name, or by |
|---|
| 1030 | 962 | * DT/OF node, but not both. |
|---|
| 1031 | 963 | */ |
|---|
| 1032 | | - const char *dev_name; |
|---|
| 1033 | | - struct device_node *of_node; |
|---|
| 964 | + struct snd_soc_dai_link_component dlc; |
|---|
| 1034 | 965 | |
|---|
| 1035 | 966 | /* |
|---|
| 1036 | 967 | * optional map of kcontrol, widget and path name prefixes that are |
|---|
| .. | .. |
|---|
| 1040 | 971 | }; |
|---|
| 1041 | 972 | |
|---|
| 1042 | 973 | struct snd_soc_aux_dev { |
|---|
| 1043 | | - const char *name; /* Codec name */ |
|---|
| 1044 | | - |
|---|
| 1045 | 974 | /* |
|---|
| 1046 | 975 | * specify multi-codec either by device name, or by |
|---|
| 1047 | 976 | * DT/OF node, but not both. |
|---|
| 1048 | 977 | */ |
|---|
| 1049 | | - const char *codec_name; |
|---|
| 1050 | | - struct device_node *codec_of_node; |
|---|
| 978 | + struct snd_soc_dai_link_component dlc; |
|---|
| 1051 | 979 | |
|---|
| 1052 | 980 | /* codec/machine specific init - e.g. add machine controls */ |
|---|
| 1053 | 981 | int (*init)(struct snd_soc_component *component); |
|---|
| .. | .. |
|---|
| 1058 | 986 | const char *name; |
|---|
| 1059 | 987 | const char *long_name; |
|---|
| 1060 | 988 | const char *driver_name; |
|---|
| 989 | + const char *components; |
|---|
| 990 | +#ifdef CONFIG_DMI |
|---|
| 1061 | 991 | char dmi_longname[80]; |
|---|
| 992 | +#endif /* CONFIG_DMI */ |
|---|
| 1062 | 993 | char topology_shortname[32]; |
|---|
| 1063 | 994 | |
|---|
| 1064 | 995 | struct device *dev; |
|---|
| .. | .. |
|---|
| 1067 | 998 | |
|---|
| 1068 | 999 | struct mutex mutex; |
|---|
| 1069 | 1000 | struct mutex dapm_mutex; |
|---|
| 1070 | | - struct mutex dapm_power_mutex; |
|---|
| 1071 | 1001 | |
|---|
| 1072 | | - bool instantiated; |
|---|
| 1073 | | - bool topology_shortname_created; |
|---|
| 1002 | + /* Mutex for PCM operations */ |
|---|
| 1003 | + struct mutex pcm_mutex; |
|---|
| 1004 | + enum snd_soc_pcm_subclass pcm_subclass; |
|---|
| 1005 | + |
|---|
| 1006 | + spinlock_t dpcm_lock; |
|---|
| 1074 | 1007 | |
|---|
| 1075 | 1008 | int (*probe)(struct snd_soc_card *card); |
|---|
| 1076 | 1009 | int (*late_probe)(struct snd_soc_card *card); |
|---|
| .. | .. |
|---|
| 1101 | 1034 | /* CPU <--> Codec DAI links */ |
|---|
| 1102 | 1035 | struct snd_soc_dai_link *dai_link; /* predefined links only */ |
|---|
| 1103 | 1036 | int num_links; /* predefined links only */ |
|---|
| 1104 | | - struct list_head dai_link_list; /* all links */ |
|---|
| 1105 | | - int num_dai_links; |
|---|
| 1106 | 1037 | |
|---|
| 1107 | 1038 | struct list_head rtd_list; |
|---|
| 1108 | 1039 | int num_rtd; |
|---|
| .. | .. |
|---|
| 1134 | 1065 | int num_of_dapm_widgets; |
|---|
| 1135 | 1066 | const struct snd_soc_dapm_route *of_dapm_routes; |
|---|
| 1136 | 1067 | int num_of_dapm_routes; |
|---|
| 1137 | | - bool fully_routed; |
|---|
| 1138 | | - |
|---|
| 1139 | | - struct work_struct deferred_resume_work; |
|---|
| 1140 | 1068 | |
|---|
| 1141 | 1069 | /* lists of probed devices belonging to this card */ |
|---|
| 1142 | 1070 | struct list_head component_dev_list; |
|---|
| 1071 | + struct list_head list; |
|---|
| 1143 | 1072 | |
|---|
| 1144 | 1073 | struct list_head widgets; |
|---|
| 1145 | 1074 | struct list_head paths; |
|---|
| .. | .. |
|---|
| 1156 | 1085 | |
|---|
| 1157 | 1086 | #ifdef CONFIG_DEBUG_FS |
|---|
| 1158 | 1087 | struct dentry *debugfs_card_root; |
|---|
| 1159 | | - struct dentry *debugfs_pop_time; |
|---|
| 1088 | +#endif |
|---|
| 1089 | +#ifdef CONFIG_PM_SLEEP |
|---|
| 1090 | + struct work_struct deferred_resume_work; |
|---|
| 1160 | 1091 | #endif |
|---|
| 1161 | 1092 | u32 pop_time; |
|---|
| 1162 | 1093 | |
|---|
| 1094 | + /* bit field */ |
|---|
| 1095 | + unsigned int instantiated:1; |
|---|
| 1096 | + unsigned int topology_shortname_created:1; |
|---|
| 1097 | + unsigned int fully_routed:1; |
|---|
| 1098 | + unsigned int disable_route_checks:1; |
|---|
| 1099 | + unsigned int probed:1; |
|---|
| 1100 | + |
|---|
| 1163 | 1101 | void *drvdata; |
|---|
| 1102 | + |
|---|
| 1103 | + ANDROID_KABI_RESERVE(1); |
|---|
| 1104 | + ANDROID_KABI_RESERVE(2); |
|---|
| 1105 | + ANDROID_KABI_RESERVE(3); |
|---|
| 1106 | + ANDROID_KABI_RESERVE(4); |
|---|
| 1164 | 1107 | }; |
|---|
| 1108 | +#define for_each_card_prelinks(card, i, link) \ |
|---|
| 1109 | + for ((i) = 0; \ |
|---|
| 1110 | + ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \ |
|---|
| 1111 | + (i)++) |
|---|
| 1112 | +#define for_each_card_pre_auxs(card, i, aux) \ |
|---|
| 1113 | + for ((i) = 0; \ |
|---|
| 1114 | + ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \ |
|---|
| 1115 | + (i)++) |
|---|
| 1116 | + |
|---|
| 1117 | +#define for_each_card_rtds(card, rtd) \ |
|---|
| 1118 | + list_for_each_entry(rtd, &(card)->rtd_list, list) |
|---|
| 1119 | +#define for_each_card_rtds_safe(card, rtd, _rtd) \ |
|---|
| 1120 | + list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list) |
|---|
| 1121 | + |
|---|
| 1122 | +#define for_each_card_auxs(card, component) \ |
|---|
| 1123 | + list_for_each_entry(component, &card->aux_comp_list, card_aux_list) |
|---|
| 1124 | +#define for_each_card_auxs_safe(card, component, _comp) \ |
|---|
| 1125 | + list_for_each_entry_safe(component, _comp, \ |
|---|
| 1126 | + &card->aux_comp_list, card_aux_list) |
|---|
| 1127 | + |
|---|
| 1128 | +#define for_each_card_components(card, component) \ |
|---|
| 1129 | + list_for_each_entry(component, &(card)->component_dev_list, card_list) |
|---|
| 1130 | + |
|---|
| 1131 | +#define for_each_card_dapms(card, dapm) \ |
|---|
| 1132 | + list_for_each_entry(dapm, &card->dapm_list, list) |
|---|
| 1133 | + |
|---|
| 1134 | +#define for_each_card_widgets(card, w)\ |
|---|
| 1135 | + list_for_each_entry(w, &card->widgets, list) |
|---|
| 1136 | +#define for_each_card_widgets_safe(card, w, _w) \ |
|---|
| 1137 | + list_for_each_entry_safe(w, _w, &card->widgets, list) |
|---|
| 1165 | 1138 | |
|---|
| 1166 | 1139 | /* SoC machine DAI configuration, glues a codec and cpu DAI together */ |
|---|
| 1167 | 1140 | struct snd_soc_pcm_runtime { |
|---|
| 1168 | 1141 | struct device *dev; |
|---|
| 1169 | 1142 | struct snd_soc_card *card; |
|---|
| 1170 | 1143 | struct snd_soc_dai_link *dai_link; |
|---|
| 1171 | | - struct mutex pcm_mutex; |
|---|
| 1172 | | - enum snd_soc_pcm_subclass pcm_subclass; |
|---|
| 1173 | 1144 | struct snd_pcm_ops ops; |
|---|
| 1145 | + |
|---|
| 1146 | + unsigned int params_select; /* currently selected param for dai link */ |
|---|
| 1174 | 1147 | |
|---|
| 1175 | 1148 | /* Dynamic PCM BE runtime data */ |
|---|
| 1176 | 1149 | struct snd_soc_dpcm_runtime dpcm[2]; |
|---|
| 1177 | | - int fe_compr; |
|---|
| 1178 | 1150 | |
|---|
| 1179 | 1151 | long pmdown_time; |
|---|
| 1180 | 1152 | |
|---|
| 1181 | | - /* err in case of ops failed */ |
|---|
| 1182 | | - int err_ops; |
|---|
| 1183 | 1153 | /* runtime devices */ |
|---|
| 1184 | 1154 | struct snd_pcm *pcm; |
|---|
| 1185 | 1155 | struct snd_compr *compr; |
|---|
| 1186 | | - struct snd_soc_dai *codec_dai; |
|---|
| 1187 | | - struct snd_soc_dai *cpu_dai; |
|---|
| 1188 | 1156 | |
|---|
| 1189 | | - struct snd_soc_dai **codec_dais; |
|---|
| 1157 | + /* |
|---|
| 1158 | + * dais = cpu_dai + codec_dai |
|---|
| 1159 | + * see |
|---|
| 1160 | + * soc_new_pcm_runtime() |
|---|
| 1161 | + * asoc_rtd_to_cpu() |
|---|
| 1162 | + * asoc_rtd_to_codec() |
|---|
| 1163 | + */ |
|---|
| 1164 | + struct snd_soc_dai **dais; |
|---|
| 1190 | 1165 | unsigned int num_codecs; |
|---|
| 1166 | + unsigned int num_cpus; |
|---|
| 1167 | + |
|---|
| 1168 | + struct snd_soc_dapm_widget *playback_widget; |
|---|
| 1169 | + struct snd_soc_dapm_widget *capture_widget; |
|---|
| 1191 | 1170 | |
|---|
| 1192 | 1171 | struct delayed_work delayed_work; |
|---|
| 1172 | + void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd); |
|---|
| 1193 | 1173 | #ifdef CONFIG_DEBUG_FS |
|---|
| 1194 | 1174 | struct dentry *debugfs_dpcm_root; |
|---|
| 1195 | 1175 | #endif |
|---|
| 1196 | 1176 | |
|---|
| 1197 | 1177 | unsigned int num; /* 0-based and monotonic increasing */ |
|---|
| 1198 | 1178 | struct list_head list; /* rtd list of the soc card */ |
|---|
| 1199 | | - struct list_head component_list; /* list of connected components */ |
|---|
| 1179 | + |
|---|
| 1180 | + /* function mark */ |
|---|
| 1181 | + struct snd_pcm_substream *mark_startup; |
|---|
| 1200 | 1182 | |
|---|
| 1201 | 1183 | /* bit field */ |
|---|
| 1202 | | - unsigned int dev_registered:1; |
|---|
| 1203 | 1184 | unsigned int pop_wait:1; |
|---|
| 1185 | + unsigned int fe_compr:1; /* for Dynamic PCM */ |
|---|
| 1186 | + |
|---|
| 1187 | + int num_components; |
|---|
| 1188 | + |
|---|
| 1189 | + ANDROID_KABI_RESERVE(1); |
|---|
| 1190 | + |
|---|
| 1191 | + struct snd_soc_component *components[]; /* CPU/Codec/Platform */ |
|---|
| 1204 | 1192 | }; |
|---|
| 1193 | +/* see soc_new_pcm_runtime() */ |
|---|
| 1194 | +#define asoc_rtd_to_cpu(rtd, n) (rtd)->dais[n] |
|---|
| 1195 | +#define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->num_cpus] |
|---|
| 1196 | +#define asoc_substream_to_rtd(substream) \ |
|---|
| 1197 | + (struct snd_soc_pcm_runtime *)snd_pcm_substream_chip(substream) |
|---|
| 1198 | + |
|---|
| 1199 | +#define for_each_rtd_components(rtd, i, component) \ |
|---|
| 1200 | + for ((i) = 0, component = NULL; \ |
|---|
| 1201 | + ((i) < rtd->num_components) && ((component) = rtd->components[i]);\ |
|---|
| 1202 | + (i)++) |
|---|
| 1203 | +#define for_each_rtd_cpu_dais(rtd, i, dai) \ |
|---|
| 1204 | + for ((i) = 0; \ |
|---|
| 1205 | + ((i) < rtd->num_cpus) && ((dai) = asoc_rtd_to_cpu(rtd, i)); \ |
|---|
| 1206 | + (i)++) |
|---|
| 1207 | +#define for_each_rtd_cpu_dais_rollback(rtd, i, dai) \ |
|---|
| 1208 | + for (; (--(i) >= 0) && ((dai) = asoc_rtd_to_cpu(rtd, i));) |
|---|
| 1209 | +#define for_each_rtd_codec_dais(rtd, i, dai) \ |
|---|
| 1210 | + for ((i) = 0; \ |
|---|
| 1211 | + ((i) < rtd->num_codecs) && ((dai) = asoc_rtd_to_codec(rtd, i)); \ |
|---|
| 1212 | + (i)++) |
|---|
| 1213 | +#define for_each_rtd_codec_dais_rollback(rtd, i, dai) \ |
|---|
| 1214 | + for (; (--(i) >= 0) && ((dai) = asoc_rtd_to_codec(rtd, i));) |
|---|
| 1215 | +#define for_each_rtd_dais(rtd, i, dai) \ |
|---|
| 1216 | + for ((i) = 0; \ |
|---|
| 1217 | + ((i) < (rtd)->num_cpus + (rtd)->num_codecs) && \ |
|---|
| 1218 | + ((dai) = (rtd)->dais[i]); \ |
|---|
| 1219 | + (i)++) |
|---|
| 1220 | +#define for_each_rtd_dais_rollback(rtd, i, dai) \ |
|---|
| 1221 | + for (; (--(i) >= 0) && ((dai) = (rtd)->dais[i]);) |
|---|
| 1222 | + |
|---|
| 1223 | +void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd); |
|---|
| 1205 | 1224 | |
|---|
| 1206 | 1225 | /* mixer control */ |
|---|
| 1207 | 1226 | struct soc_mixer_control { |
|---|
| .. | .. |
|---|
| 1211 | 1230 | unsigned int sign_bit; |
|---|
| 1212 | 1231 | unsigned int invert:1; |
|---|
| 1213 | 1232 | unsigned int autodisable:1; |
|---|
| 1233 | +#ifdef CONFIG_SND_SOC_TOPOLOGY |
|---|
| 1214 | 1234 | struct snd_soc_dobj dobj; |
|---|
| 1235 | +#endif |
|---|
| 1236 | + |
|---|
| 1237 | + ANDROID_KABI_RESERVE(1); |
|---|
| 1215 | 1238 | }; |
|---|
| 1216 | 1239 | |
|---|
| 1217 | 1240 | struct soc_bytes { |
|---|
| .. | .. |
|---|
| 1222 | 1245 | |
|---|
| 1223 | 1246 | struct soc_bytes_ext { |
|---|
| 1224 | 1247 | int max; |
|---|
| 1248 | +#ifdef CONFIG_SND_SOC_TOPOLOGY |
|---|
| 1225 | 1249 | struct snd_soc_dobj dobj; |
|---|
| 1226 | | - |
|---|
| 1250 | +#endif |
|---|
| 1227 | 1251 | /* used for TLV byte control */ |
|---|
| 1228 | 1252 | int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes, |
|---|
| 1229 | 1253 | unsigned int size); |
|---|
| .. | .. |
|---|
| 1252 | 1276 | const char * const *texts; |
|---|
| 1253 | 1277 | const unsigned int *values; |
|---|
| 1254 | 1278 | unsigned int autodisable:1; |
|---|
| 1279 | +#ifdef CONFIG_SND_SOC_TOPOLOGY |
|---|
| 1255 | 1280 | struct snd_soc_dobj dobj; |
|---|
| 1256 | | -}; |
|---|
| 1257 | | - |
|---|
| 1258 | | -/** |
|---|
| 1259 | | - * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is |
|---|
| 1260 | | - * embedded in |
|---|
| 1261 | | - * @dapm: The DAPM context to cast to the component |
|---|
| 1262 | | - * |
|---|
| 1263 | | - * This function must only be used on DAPM contexts that are known to be part of |
|---|
| 1264 | | - * a component (e.g. in a component driver). Otherwise the behavior is |
|---|
| 1265 | | - * undefined. |
|---|
| 1266 | | - */ |
|---|
| 1267 | | -static inline struct snd_soc_component *snd_soc_dapm_to_component( |
|---|
| 1268 | | - struct snd_soc_dapm_context *dapm) |
|---|
| 1269 | | -{ |
|---|
| 1270 | | - return container_of(dapm, struct snd_soc_component, dapm); |
|---|
| 1271 | | -} |
|---|
| 1272 | | - |
|---|
| 1273 | | -/** |
|---|
| 1274 | | - * snd_soc_component_get_dapm() - Returns the DAPM context associated with a |
|---|
| 1275 | | - * component |
|---|
| 1276 | | - * @component: The component for which to get the DAPM context |
|---|
| 1277 | | - */ |
|---|
| 1278 | | -static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm( |
|---|
| 1279 | | - struct snd_soc_component *component) |
|---|
| 1280 | | -{ |
|---|
| 1281 | | - return &component->dapm; |
|---|
| 1282 | | -} |
|---|
| 1283 | | - |
|---|
| 1284 | | -/** |
|---|
| 1285 | | - * snd_soc_component_init_bias_level() - Initialize COMPONENT DAPM bias level |
|---|
| 1286 | | - * @component: The COMPONENT for which to initialize the DAPM bias level |
|---|
| 1287 | | - * @level: The DAPM level to initialize to |
|---|
| 1288 | | - * |
|---|
| 1289 | | - * Initializes the COMPONENT DAPM bias level. See snd_soc_dapm_init_bias_level(). |
|---|
| 1290 | | - */ |
|---|
| 1291 | | -static inline void |
|---|
| 1292 | | -snd_soc_component_init_bias_level(struct snd_soc_component *component, |
|---|
| 1293 | | - enum snd_soc_bias_level level) |
|---|
| 1294 | | -{ |
|---|
| 1295 | | - snd_soc_dapm_init_bias_level( |
|---|
| 1296 | | - snd_soc_component_get_dapm(component), level); |
|---|
| 1297 | | -} |
|---|
| 1298 | | - |
|---|
| 1299 | | -/** |
|---|
| 1300 | | - * snd_soc_component_get_bias_level() - Get current COMPONENT DAPM bias level |
|---|
| 1301 | | - * @component: The COMPONENT for which to get the DAPM bias level |
|---|
| 1302 | | - * |
|---|
| 1303 | | - * Returns: The current DAPM bias level of the COMPONENT. |
|---|
| 1304 | | - */ |
|---|
| 1305 | | -static inline enum snd_soc_bias_level |
|---|
| 1306 | | -snd_soc_component_get_bias_level(struct snd_soc_component *component) |
|---|
| 1307 | | -{ |
|---|
| 1308 | | - return snd_soc_dapm_get_bias_level( |
|---|
| 1309 | | - snd_soc_component_get_dapm(component)); |
|---|
| 1310 | | -} |
|---|
| 1311 | | - |
|---|
| 1312 | | -/** |
|---|
| 1313 | | - * snd_soc_component_force_bias_level() - Set the COMPONENT DAPM bias level |
|---|
| 1314 | | - * @component: The COMPONENT for which to set the level |
|---|
| 1315 | | - * @level: The level to set to |
|---|
| 1316 | | - * |
|---|
| 1317 | | - * Forces the COMPONENT bias level to a specific state. See |
|---|
| 1318 | | - * snd_soc_dapm_force_bias_level(). |
|---|
| 1319 | | - */ |
|---|
| 1320 | | -static inline int |
|---|
| 1321 | | -snd_soc_component_force_bias_level(struct snd_soc_component *component, |
|---|
| 1322 | | - enum snd_soc_bias_level level) |
|---|
| 1323 | | -{ |
|---|
| 1324 | | - return snd_soc_dapm_force_bias_level( |
|---|
| 1325 | | - snd_soc_component_get_dapm(component), |
|---|
| 1326 | | - level); |
|---|
| 1327 | | -} |
|---|
| 1328 | | - |
|---|
| 1329 | | -/** |
|---|
| 1330 | | - * snd_soc_dapm_kcontrol_component() - Returns the component associated to a kcontrol |
|---|
| 1331 | | - * @kcontrol: The kcontrol |
|---|
| 1332 | | - * |
|---|
| 1333 | | - * This function must only be used on DAPM contexts that are known to be part of |
|---|
| 1334 | | - * a COMPONENT (e.g. in a COMPONENT driver). Otherwise the behavior is undefined. |
|---|
| 1335 | | - */ |
|---|
| 1336 | | -static inline struct snd_soc_component *snd_soc_dapm_kcontrol_component( |
|---|
| 1337 | | - struct snd_kcontrol *kcontrol) |
|---|
| 1338 | | -{ |
|---|
| 1339 | | - return snd_soc_dapm_to_component(snd_soc_dapm_kcontrol_dapm(kcontrol)); |
|---|
| 1340 | | -} |
|---|
| 1341 | | - |
|---|
| 1342 | | -/** |
|---|
| 1343 | | - * snd_soc_component_cache_sync() - Sync the register cache with the hardware |
|---|
| 1344 | | - * @component: COMPONENT to sync |
|---|
| 1345 | | - * |
|---|
| 1346 | | - * Note: This function will call regcache_sync() |
|---|
| 1347 | | - */ |
|---|
| 1348 | | -static inline int snd_soc_component_cache_sync( |
|---|
| 1349 | | - struct snd_soc_component *component) |
|---|
| 1350 | | -{ |
|---|
| 1351 | | - return regcache_sync(component->regmap); |
|---|
| 1352 | | -} |
|---|
| 1353 | | - |
|---|
| 1354 | | -/* component IO */ |
|---|
| 1355 | | -int snd_soc_component_read(struct snd_soc_component *component, |
|---|
| 1356 | | - unsigned int reg, unsigned int *val); |
|---|
| 1357 | | -unsigned int snd_soc_component_read32(struct snd_soc_component *component, |
|---|
| 1358 | | - unsigned int reg); |
|---|
| 1359 | | -int snd_soc_component_write(struct snd_soc_component *component, |
|---|
| 1360 | | - unsigned int reg, unsigned int val); |
|---|
| 1361 | | -int snd_soc_component_update_bits(struct snd_soc_component *component, |
|---|
| 1362 | | - unsigned int reg, unsigned int mask, unsigned int val); |
|---|
| 1363 | | -int snd_soc_component_update_bits_async(struct snd_soc_component *component, |
|---|
| 1364 | | - unsigned int reg, unsigned int mask, unsigned int val); |
|---|
| 1365 | | -void snd_soc_component_async_complete(struct snd_soc_component *component); |
|---|
| 1366 | | -int snd_soc_component_test_bits(struct snd_soc_component *component, |
|---|
| 1367 | | - unsigned int reg, unsigned int mask, unsigned int value); |
|---|
| 1368 | | -struct snd_soc_component *soc_find_component( |
|---|
| 1369 | | - const struct device_node *of_node, const char *name); |
|---|
| 1370 | | - |
|---|
| 1371 | | -/* component wide operations */ |
|---|
| 1372 | | -int snd_soc_component_set_sysclk(struct snd_soc_component *component, |
|---|
| 1373 | | - int clk_id, int source, unsigned int freq, int dir); |
|---|
| 1374 | | -int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id, |
|---|
| 1375 | | - int source, unsigned int freq_in, |
|---|
| 1376 | | - unsigned int freq_out); |
|---|
| 1377 | | -int snd_soc_component_set_jack(struct snd_soc_component *component, |
|---|
| 1378 | | - struct snd_soc_jack *jack, void *data); |
|---|
| 1379 | | - |
|---|
| 1380 | | -#ifdef CONFIG_REGMAP |
|---|
| 1381 | | - |
|---|
| 1382 | | -void snd_soc_component_init_regmap(struct snd_soc_component *component, |
|---|
| 1383 | | - struct regmap *regmap); |
|---|
| 1384 | | -void snd_soc_component_exit_regmap(struct snd_soc_component *component); |
|---|
| 1385 | | - |
|---|
| 1386 | 1281 | #endif |
|---|
| 1387 | 1282 | |
|---|
| 1388 | | -/* device driver data */ |
|---|
| 1389 | | - |
|---|
| 1390 | | -static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card, |
|---|
| 1391 | | - void *data) |
|---|
| 1392 | | -{ |
|---|
| 1393 | | - card->drvdata = data; |
|---|
| 1394 | | -} |
|---|
| 1395 | | - |
|---|
| 1396 | | -static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card) |
|---|
| 1397 | | -{ |
|---|
| 1398 | | - return card->drvdata; |
|---|
| 1399 | | -} |
|---|
| 1400 | | - |
|---|
| 1401 | | -static inline void snd_soc_component_set_drvdata(struct snd_soc_component *c, |
|---|
| 1402 | | - void *data) |
|---|
| 1403 | | -{ |
|---|
| 1404 | | - dev_set_drvdata(c->dev, data); |
|---|
| 1405 | | -} |
|---|
| 1406 | | - |
|---|
| 1407 | | -static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c) |
|---|
| 1408 | | -{ |
|---|
| 1409 | | - return dev_get_drvdata(c->dev); |
|---|
| 1410 | | -} |
|---|
| 1411 | | - |
|---|
| 1412 | | -static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) |
|---|
| 1413 | | -{ |
|---|
| 1414 | | - INIT_LIST_HEAD(&card->widgets); |
|---|
| 1415 | | - INIT_LIST_HEAD(&card->paths); |
|---|
| 1416 | | - INIT_LIST_HEAD(&card->dapm_list); |
|---|
| 1417 | | - INIT_LIST_HEAD(&card->aux_comp_list); |
|---|
| 1418 | | - INIT_LIST_HEAD(&card->component_dev_list); |
|---|
| 1419 | | -} |
|---|
| 1283 | + ANDROID_KABI_RESERVE(1); |
|---|
| 1284 | +}; |
|---|
| 1420 | 1285 | |
|---|
| 1421 | 1286 | static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc) |
|---|
| 1422 | 1287 | { |
|---|
| 1423 | 1288 | if (mc->reg == mc->rreg && mc->shift == mc->rshift) |
|---|
| 1424 | | - return 0; |
|---|
| 1289 | + return false; |
|---|
| 1425 | 1290 | /* |
|---|
| 1426 | 1291 | * mc->reg == mc->rreg && mc->shift != mc->rshift, or |
|---|
| 1427 | 1292 | * mc->reg != mc->rreg means that the control is |
|---|
| 1428 | 1293 | * stereo (bits in one register or in two registers) |
|---|
| 1429 | 1294 | */ |
|---|
| 1430 | | - return 1; |
|---|
| 1295 | + return true; |
|---|
| 1431 | 1296 | } |
|---|
| 1432 | 1297 | |
|---|
| 1433 | 1298 | static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e, |
|---|
| .. | .. |
|---|
| 1452 | 1317 | return item; |
|---|
| 1453 | 1318 | |
|---|
| 1454 | 1319 | return e->values[item]; |
|---|
| 1455 | | -} |
|---|
| 1456 | | - |
|---|
| 1457 | | -static inline bool snd_soc_component_is_active( |
|---|
| 1458 | | - struct snd_soc_component *component) |
|---|
| 1459 | | -{ |
|---|
| 1460 | | - return component->active != 0; |
|---|
| 1461 | 1320 | } |
|---|
| 1462 | 1321 | |
|---|
| 1463 | 1322 | /** |
|---|
| .. | .. |
|---|
| 1491 | 1350 | unsigned int *rx_mask, |
|---|
| 1492 | 1351 | unsigned int *slots, |
|---|
| 1493 | 1352 | unsigned int *slot_width); |
|---|
| 1494 | | -void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card, |
|---|
| 1353 | +void snd_soc_of_parse_node_prefix(struct device_node *np, |
|---|
| 1495 | 1354 | struct snd_soc_codec_conf *codec_conf, |
|---|
| 1496 | 1355 | struct device_node *of_node, |
|---|
| 1497 | 1356 | const char *propname); |
|---|
| 1357 | +static inline |
|---|
| 1358 | +void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card, |
|---|
| 1359 | + struct snd_soc_codec_conf *codec_conf, |
|---|
| 1360 | + struct device_node *of_node, |
|---|
| 1361 | + const char *propname) |
|---|
| 1362 | +{ |
|---|
| 1363 | + snd_soc_of_parse_node_prefix(card->dev->of_node, |
|---|
| 1364 | + codec_conf, of_node, propname); |
|---|
| 1365 | +} |
|---|
| 1366 | + |
|---|
| 1498 | 1367 | int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, |
|---|
| 1499 | 1368 | const char *propname); |
|---|
| 1369 | +int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname); |
|---|
| 1500 | 1370 | unsigned int snd_soc_of_parse_daifmt(struct device_node *np, |
|---|
| 1501 | 1371 | const char *prefix, |
|---|
| 1502 | 1372 | struct device_node **bitclkmaster, |
|---|
| .. | .. |
|---|
| 1511 | 1381 | struct snd_soc_dai_link *dai_link); |
|---|
| 1512 | 1382 | void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link); |
|---|
| 1513 | 1383 | |
|---|
| 1514 | | -int snd_soc_add_dai_link(struct snd_soc_card *card, |
|---|
| 1515 | | - struct snd_soc_dai_link *dai_link); |
|---|
| 1516 | | -void snd_soc_remove_dai_link(struct snd_soc_card *card, |
|---|
| 1517 | | - struct snd_soc_dai_link *dai_link); |
|---|
| 1518 | | -struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, |
|---|
| 1519 | | - int id, const char *name, |
|---|
| 1520 | | - const char *stream_name); |
|---|
| 1384 | +int snd_soc_add_pcm_runtime(struct snd_soc_card *card, |
|---|
| 1385 | + struct snd_soc_dai_link *dai_link); |
|---|
| 1386 | +void snd_soc_remove_pcm_runtime(struct snd_soc_card *card, |
|---|
| 1387 | + struct snd_soc_pcm_runtime *rtd); |
|---|
| 1521 | 1388 | |
|---|
| 1522 | | -int snd_soc_register_dai(struct snd_soc_component *component, |
|---|
| 1523 | | - struct snd_soc_dai_driver *dai_drv); |
|---|
| 1389 | +struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, |
|---|
| 1390 | + struct snd_soc_dai_driver *dai_drv, |
|---|
| 1391 | + bool legacy_dai_naming); |
|---|
| 1392 | +struct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev, |
|---|
| 1393 | + struct snd_soc_component *component, |
|---|
| 1394 | + struct snd_soc_dai_driver *dai_drv, |
|---|
| 1395 | + bool legacy_dai_naming); |
|---|
| 1396 | +void snd_soc_unregister_dai(struct snd_soc_dai *dai); |
|---|
| 1524 | 1397 | |
|---|
| 1525 | 1398 | struct snd_soc_dai *snd_soc_find_dai( |
|---|
| 1399 | + const struct snd_soc_dai_link_component *dlc); |
|---|
| 1400 | +struct snd_soc_dai *snd_soc_find_dai_with_mutex( |
|---|
| 1526 | 1401 | const struct snd_soc_dai_link_component *dlc); |
|---|
| 1527 | 1402 | |
|---|
| 1528 | 1403 | #include <sound/soc-dai.h> |
|---|
| 1529 | 1404 | |
|---|
| 1530 | 1405 | static inline |
|---|
| 1531 | | -struct snd_soc_dai *snd_soc_card_get_codec_dai(struct snd_soc_card *card, |
|---|
| 1532 | | - const char *dai_name) |
|---|
| 1406 | +int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card, |
|---|
| 1407 | + const char *platform_name) |
|---|
| 1533 | 1408 | { |
|---|
| 1534 | | - struct snd_soc_pcm_runtime *rtd; |
|---|
| 1409 | + struct snd_soc_dai_link *dai_link; |
|---|
| 1410 | + const char *name; |
|---|
| 1411 | + int i; |
|---|
| 1535 | 1412 | |
|---|
| 1536 | | - list_for_each_entry(rtd, &card->rtd_list, list) { |
|---|
| 1537 | | - if (!strcmp(rtd->codec_dai->name, dai_name)) |
|---|
| 1538 | | - return rtd->codec_dai; |
|---|
| 1413 | + if (!platform_name) /* nothing to do */ |
|---|
| 1414 | + return 0; |
|---|
| 1415 | + |
|---|
| 1416 | + /* set platform name for each dailink */ |
|---|
| 1417 | + for_each_card_prelinks(card, i, dai_link) { |
|---|
| 1418 | + name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL); |
|---|
| 1419 | + if (!name) |
|---|
| 1420 | + return -ENOMEM; |
|---|
| 1421 | + |
|---|
| 1422 | + if (!dai_link->platforms) |
|---|
| 1423 | + return -EINVAL; |
|---|
| 1424 | + |
|---|
| 1425 | + /* only single platform is supported for now */ |
|---|
| 1426 | + dai_link->platforms->name = name; |
|---|
| 1539 | 1427 | } |
|---|
| 1540 | 1428 | |
|---|
| 1541 | | - return NULL; |
|---|
| 1429 | + return 0; |
|---|
| 1542 | 1430 | } |
|---|
| 1543 | 1431 | |
|---|
| 1544 | 1432 | #ifdef CONFIG_DEBUG_FS |
|---|
| .. | .. |
|---|
| 1558 | 1446 | mutex_unlock(&dapm->card->dapm_mutex); |
|---|
| 1559 | 1447 | } |
|---|
| 1560 | 1448 | |
|---|
| 1561 | | -int snd_soc_component_enable_pin(struct snd_soc_component *component, |
|---|
| 1562 | | - const char *pin); |
|---|
| 1563 | | -int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component, |
|---|
| 1564 | | - const char *pin); |
|---|
| 1565 | | -int snd_soc_component_disable_pin(struct snd_soc_component *component, |
|---|
| 1566 | | - const char *pin); |
|---|
| 1567 | | -int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component, |
|---|
| 1568 | | - const char *pin); |
|---|
| 1569 | | -int snd_soc_component_nc_pin(struct snd_soc_component *component, |
|---|
| 1570 | | - const char *pin); |
|---|
| 1571 | | -int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component, |
|---|
| 1572 | | - const char *pin); |
|---|
| 1573 | | -int snd_soc_component_get_pin_status(struct snd_soc_component *component, |
|---|
| 1574 | | - const char *pin); |
|---|
| 1575 | | -int snd_soc_component_force_enable_pin(struct snd_soc_component *component, |
|---|
| 1576 | | - const char *pin); |
|---|
| 1577 | | -int snd_soc_component_force_enable_pin_unlocked( |
|---|
| 1578 | | - struct snd_soc_component *component, |
|---|
| 1579 | | - const char *pin); |
|---|
| 1449 | +#include <sound/soc-component.h> |
|---|
| 1450 | +#include <sound/soc-card.h> |
|---|
| 1580 | 1451 | |
|---|
| 1581 | 1452 | #endif |
|---|