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.h118
1 files changed, 96 insertions, 22 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 2ebf7877c148..c703871f5f65 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -55,6 +55,18 @@
55 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ 55 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
56 .put = snd_soc_put_volsw, \ 56 .put = snd_soc_put_volsw, \
57 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } 57 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
58#define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
59{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
60 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
61 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
62 .tlv.p = (tlv_array),\
63 .info = snd_soc_info_volsw, \
64 .get = snd_soc_get_volsw_sx,\
65 .put = snd_soc_put_volsw_sx, \
66 .private_value = (unsigned long)&(struct soc_mixer_control) \
67 {.reg = xreg, .rreg = xreg, \
68 .shift = xshift, .rshift = xshift, \
69 .max = xmax, .min = xmin} }
58#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \ 70#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
59{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ 71{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
60 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ 72 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
@@ -85,6 +97,18 @@
85 .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ 97 .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
86 .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ 98 .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
87 xmax, xinvert) } 99 xmax, xinvert) }
100#define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
101{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
102 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
103 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
104 .tlv.p = (tlv_array), \
105 .info = snd_soc_info_volsw, \
106 .get = snd_soc_get_volsw_sx, \
107 .put = snd_soc_put_volsw_sx, \
108 .private_value = (unsigned long)&(struct soc_mixer_control) \
109 {.reg = xreg, .rreg = xrreg, \
110 .shift = xshift, .rshift = xshift, \
111 .max = xmax, .min = xmin} }
88#define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \ 112#define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
89{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 113{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
90 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 114 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
@@ -171,20 +195,6 @@
171 .get = xhandler_get, .put = xhandler_put, \ 195 .get = xhandler_get, .put = xhandler_put, \
172 .private_value = (unsigned long)&xenum } 196 .private_value = (unsigned long)&xenum }
173 197
174#define SOC_DOUBLE_R_SX_TLV(xname, xreg_left, xreg_right, xshift,\
175 xmin, xmax, tlv_array) \
176{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
177 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
178 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
179 .tlv.p = (tlv_array), \
180 .info = snd_soc_info_volsw_2r_sx, \
181 .get = snd_soc_get_volsw_2r_sx, \
182 .put = snd_soc_put_volsw_2r_sx, \
183 .private_value = (unsigned long)&(struct soc_mixer_control) \
184 {.reg = xreg_left, \
185 .rreg = xreg_right, .shift = xshift, \
186 .min = xmin, .max = xmax} }
187
188#define SND_SOC_BYTES(xname, xbase, xregs) \ 198#define SND_SOC_BYTES(xname, xbase, xregs) \
189{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 199{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
190 .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \ 200 .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
@@ -200,6 +210,19 @@
200 {.base = xbase, .num_regs = xregs, \ 210 {.base = xbase, .num_regs = xregs, \
201 .mask = xmask }) } 211 .mask = xmask }) }
202 212
213#define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
214 xmin, xmax, xinvert) \
215{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
216 .info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
217 .put = snd_soc_put_xr_sx, \
218 .private_value = (unsigned long)&(struct soc_mreg_control) \
219 {.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
220 .invert = xinvert, .min = xmin, .max = xmax} }
221
222#define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
223 SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
224 snd_soc_get_strobe, snd_soc_put_strobe)
225
203/* 226/*
204 * Simplified versions of above macros, declaring a struct and calculating 227 * Simplified versions of above macros, declaring a struct and calculating
205 * ARRAY_SIZE internally 228 * ARRAY_SIZE internally
@@ -264,6 +287,7 @@ struct snd_soc_jack_zone;
264struct snd_soc_jack_pin; 287struct snd_soc_jack_pin;
265struct snd_soc_cache_ops; 288struct snd_soc_cache_ops;
266#include <sound/soc-dapm.h> 289#include <sound/soc-dapm.h>
290#include <sound/soc-dpcm.h>
267 291
268#ifdef CONFIG_GPIOLIB 292#ifdef CONFIG_GPIOLIB
269struct snd_soc_jack_gpio; 293struct snd_soc_jack_gpio;
@@ -288,6 +312,11 @@ enum snd_soc_pcm_subclass {
288 SND_SOC_PCM_CLASS_BE = 1, 312 SND_SOC_PCM_CLASS_BE = 1,
289}; 313};
290 314
315enum snd_soc_card_subclass {
316 SND_SOC_CARD_CLASS_INIT = 0,
317 SND_SOC_CARD_CLASS_RUNTIME = 1,
318};
319
291int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id, 320int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
292 int source, unsigned int freq, int dir); 321 int source, unsigned int freq, int dir);
293int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, 322int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
@@ -333,6 +362,11 @@ int snd_soc_platform_write(struct snd_soc_platform *platform,
333 unsigned int reg, unsigned int val); 362 unsigned int reg, unsigned int val);
334int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num); 363int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
335 364
365struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
366 const char *dai_link, int stream);
367struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
368 const char *dai_link);
369
336/* Utility functions to get clock rates from various things */ 370/* Utility functions to get clock rates from various things */
337int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); 371int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
338int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params); 372int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
@@ -343,6 +377,9 @@ int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
343int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, 377int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
344 const struct snd_pcm_hardware *hw); 378 const struct snd_pcm_hardware *hw);
345 379
380int snd_soc_platform_trigger(struct snd_pcm_substream *substream,
381 int cmd, struct snd_soc_platform *platform);
382
346/* Jack reporting */ 383/* Jack reporting */
347int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, 384int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
348 struct snd_soc_jack *jack); 385 struct snd_soc_jack *jack);
@@ -413,6 +450,10 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
413 struct snd_ctl_elem_value *ucontrol); 450 struct snd_ctl_elem_value *ucontrol);
414#define snd_soc_get_volsw_2r snd_soc_get_volsw 451#define snd_soc_get_volsw_2r snd_soc_get_volsw
415#define snd_soc_put_volsw_2r snd_soc_put_volsw 452#define snd_soc_put_volsw_2r snd_soc_put_volsw
453int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
454 struct snd_ctl_elem_value *ucontrol);
455int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
456 struct snd_ctl_elem_value *ucontrol);
416int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, 457int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
417 struct snd_ctl_elem_info *uinfo); 458 struct snd_ctl_elem_info *uinfo);
418int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, 459int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
@@ -421,19 +462,22 @@ int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
421 struct snd_ctl_elem_value *ucontrol); 462 struct snd_ctl_elem_value *ucontrol);
422int snd_soc_limit_volume(struct snd_soc_codec *codec, 463int snd_soc_limit_volume(struct snd_soc_codec *codec,
423 const char *name, int max); 464 const char *name, int max);
424int snd_soc_info_volsw_2r_sx(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_info *uinfo);
426int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol,
427 struct snd_ctl_elem_value *ucontrol);
428int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol,
429 struct snd_ctl_elem_value *ucontrol);
430int snd_soc_bytes_info(struct snd_kcontrol *kcontrol, 465int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
431 struct snd_ctl_elem_info *uinfo); 466 struct snd_ctl_elem_info *uinfo);
432int snd_soc_bytes_get(struct snd_kcontrol *kcontrol, 467int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
433 struct snd_ctl_elem_value *ucontrol); 468 struct snd_ctl_elem_value *ucontrol);
434int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, 469int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
435 struct snd_ctl_elem_value *ucontrol); 470 struct snd_ctl_elem_value *ucontrol);
436 471int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
472 struct snd_ctl_elem_info *uinfo);
473int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
474 struct snd_ctl_elem_value *ucontrol);
475int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
476 struct snd_ctl_elem_value *ucontrol);
477int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol);
479int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_value *ucontrol);
437 481
438/** 482/**
439 * struct snd_soc_reg_access - Describes whether a given register is 483 * struct snd_soc_reg_access - Describes whether a given register is
@@ -513,6 +557,7 @@ struct snd_soc_jack_gpio {
513#endif 557#endif
514 558
515struct snd_soc_jack { 559struct snd_soc_jack {
560 struct mutex mutex;
516 struct snd_jack *jack; 561 struct snd_jack *jack;
517 struct snd_soc_codec *codec; 562 struct snd_soc_codec *codec;
518 struct list_head pins; 563 struct list_head pins;
@@ -711,6 +756,7 @@ struct snd_soc_platform_driver {
711 /* platform IO - used for platform DAPM */ 756 /* platform IO - used for platform DAPM */
712 unsigned int (*read)(struct snd_soc_platform *, unsigned int); 757 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
713 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int); 758 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
759 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
714}; 760};
715 761
716struct snd_soc_platform { 762struct snd_soc_platform {
@@ -746,21 +792,36 @@ struct snd_soc_dai_link {
746 const char *cpu_dai_name; 792 const char *cpu_dai_name;
747 const struct device_node *cpu_dai_of_node; 793 const struct device_node *cpu_dai_of_node;
748 const char *codec_dai_name; 794 const char *codec_dai_name;
795 int be_id; /* optional ID for machine driver BE identification */
796
797 const struct snd_soc_pcm_stream *params;
749 798
750 unsigned int dai_fmt; /* format to set on init */ 799 unsigned int dai_fmt; /* format to set on init */
751 800
801 enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
802
752 /* Keep DAI active over suspend */ 803 /* Keep DAI active over suspend */
753 unsigned int ignore_suspend:1; 804 unsigned int ignore_suspend:1;
754 805
755 /* Symmetry requirements */ 806 /* Symmetry requirements */
756 unsigned int symmetric_rates:1; 807 unsigned int symmetric_rates:1;
757 808
809 /* Do not create a PCM for this DAI link (Backend link) */
810 unsigned int no_pcm:1;
811
812 /* This DAI link can route to other DAI links at runtime (Frontend)*/
813 unsigned int dynamic:1;
814
758 /* pmdown_time is ignored at stop */ 815 /* pmdown_time is ignored at stop */
759 unsigned int ignore_pmdown_time:1; 816 unsigned int ignore_pmdown_time:1;
760 817
761 /* codec/machine specific init - e.g. add machine controls */ 818 /* codec/machine specific init - e.g. add machine controls */
762 int (*init)(struct snd_soc_pcm_runtime *rtd); 819 int (*init)(struct snd_soc_pcm_runtime *rtd);
763 820
821 /* optional hw_params re-writing for BE and FE sync */
822 int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
823 struct snd_pcm_hw_params *params);
824
764 /* machine stream operations */ 825 /* machine stream operations */
765 struct snd_soc_ops *ops; 826 struct snd_soc_ops *ops;
766}; 827};
@@ -800,6 +861,7 @@ struct snd_soc_card {
800 861
801 struct list_head list; 862 struct list_head list;
802 struct mutex mutex; 863 struct mutex mutex;
864 struct mutex dapm_mutex;
803 865
804 bool instantiated; 866 bool instantiated;
805 867
@@ -889,9 +951,11 @@ struct snd_soc_pcm_runtime {
889 enum snd_soc_pcm_subclass pcm_subclass; 951 enum snd_soc_pcm_subclass pcm_subclass;
890 struct snd_pcm_ops ops; 952 struct snd_pcm_ops ops;
891 953
892 unsigned int complete:1;
893 unsigned int dev_registered:1; 954 unsigned int dev_registered:1;
894 955
956 /* Dynamic PCM BE runtime data */
957 struct snd_soc_dpcm_runtime dpcm[2];
958
895 long pmdown_time; 959 long pmdown_time;
896 960
897 /* runtime devices */ 961 /* runtime devices */
@@ -902,6 +966,10 @@ struct snd_soc_pcm_runtime {
902 struct snd_soc_dai *cpu_dai; 966 struct snd_soc_dai *cpu_dai;
903 967
904 struct delayed_work delayed_work; 968 struct delayed_work delayed_work;
969#ifdef CONFIG_DEBUG_FS
970 struct dentry *debugfs_dpcm_root;
971 struct dentry *debugfs_dpcm_state;
972#endif
905}; 973};
906 974
907/* mixer control */ 975/* mixer control */
@@ -916,6 +984,12 @@ struct soc_bytes {
916 u32 mask; 984 u32 mask;
917}; 985};
918 986
987/* multi register control */
988struct soc_mreg_control {
989 long min, max;
990 unsigned int regbase, regcount, nbits, invert;
991};
992
919/* enumerated kcontrol */ 993/* enumerated kcontrol */
920struct soc_enum { 994struct soc_enum {
921 unsigned short reg; 995 unsigned short reg;