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.h109
1 files changed, 94 insertions, 15 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 0d7718f9280d..65e9d03ed4f5 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -15,6 +15,7 @@
15 15
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/notifier.h>
18#include <linux/workqueue.h> 19#include <linux/workqueue.h>
19#include <linux/interrupt.h> 20#include <linux/interrupt.h>
20#include <linux/kernel.h> 21#include <linux/kernel.h>
@@ -29,10 +30,10 @@
29#define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \ 30#define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \
30 ((unsigned long)&(struct soc_mixer_control) \ 31 ((unsigned long)&(struct soc_mixer_control) \
31 {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \ 32 {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \
32 .invert = xinvert}) 33 .platform_max = xmax, .invert = xinvert})
33#define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \ 34#define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
34 ((unsigned long)&(struct soc_mixer_control) \ 35 ((unsigned long)&(struct soc_mixer_control) \
35 {.reg = xreg, .max = xmax, .invert = xinvert}) 36 {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert})
36#define SOC_SINGLE(xname, reg, shift, max, invert) \ 37#define SOC_SINGLE(xname, reg, shift, max, invert) \
37{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 38{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
38 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ 39 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
@@ -52,14 +53,14 @@
52 .put = snd_soc_put_volsw, \ 53 .put = snd_soc_put_volsw, \
53 .private_value = (unsigned long)&(struct soc_mixer_control) \ 54 .private_value = (unsigned long)&(struct soc_mixer_control) \
54 {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ 55 {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
55 .max = xmax, .invert = xinvert} } 56 .max = xmax, .platform_max = xmax, .invert = xinvert} }
56#define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \ 57#define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
57{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 58{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
58 .info = snd_soc_info_volsw_2r, \ 59 .info = snd_soc_info_volsw_2r, \
59 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ 60 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
60 .private_value = (unsigned long)&(struct soc_mixer_control) \ 61 .private_value = (unsigned long)&(struct soc_mixer_control) \
61 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ 62 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
62 .max = xmax, .invert = xinvert} } 63 .max = xmax, .platform_max = xmax, .invert = xinvert} }
63#define SOC_DOUBLE_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert, tlv_array) \ 64#define SOC_DOUBLE_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert, tlv_array) \
64{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ 65{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
65 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ 66 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
@@ -69,7 +70,7 @@
69 .put = snd_soc_put_volsw, \ 70 .put = snd_soc_put_volsw, \
70 .private_value = (unsigned long)&(struct soc_mixer_control) \ 71 .private_value = (unsigned long)&(struct soc_mixer_control) \
71 {.reg = xreg, .shift = shift_left, .rshift = shift_right,\ 72 {.reg = xreg, .shift = shift_left, .rshift = shift_right,\
72 .max = xmax, .invert = xinvert} } 73 .max = xmax, .platform_max = xmax, .invert = xinvert} }
73#define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \ 74#define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
74{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ 75{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
75 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ 76 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
@@ -79,7 +80,7 @@
79 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ 80 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
80 .private_value = (unsigned long)&(struct soc_mixer_control) \ 81 .private_value = (unsigned long)&(struct soc_mixer_control) \
81 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ 82 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
82 .max = xmax, .invert = xinvert} } 83 .max = xmax, .platform_max = xmax, .invert = xinvert} }
83#define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \ 84#define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
84{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 85{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
85 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 86 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
@@ -88,7 +89,8 @@
88 .info = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \ 89 .info = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \
89 .put = snd_soc_put_volsw_s8, \ 90 .put = snd_soc_put_volsw_s8, \
90 .private_value = (unsigned long)&(struct soc_mixer_control) \ 91 .private_value = (unsigned long)&(struct soc_mixer_control) \
91 {.reg = xreg, .min = xmin, .max = xmax} } 92 {.reg = xreg, .min = xmin, .max = xmax, \
93 .platform_max = xmax} }
92#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \ 94#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \
93{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ 95{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
94 .max = xmax, .texts = xtexts } 96 .max = xmax, .texts = xtexts }
@@ -125,7 +127,7 @@
125 .get = xhandler_get, .put = xhandler_put, \ 127 .get = xhandler_get, .put = xhandler_put, \
126 .private_value = (unsigned long)&(struct soc_mixer_control) \ 128 .private_value = (unsigned long)&(struct soc_mixer_control) \
127 {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ 129 {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
128 .max = xmax, .invert = xinvert} } 130 .max = xmax, .platform_max = xmax, .invert = xinvert} }
129#define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\ 131#define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
130 xhandler_get, xhandler_put, tlv_array) \ 132 xhandler_get, xhandler_put, tlv_array) \
131{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 133{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
@@ -145,7 +147,7 @@
145 .get = xhandler_get, .put = xhandler_put, \ 147 .get = xhandler_get, .put = xhandler_put, \
146 .private_value = (unsigned long)&(struct soc_mixer_control) \ 148 .private_value = (unsigned long)&(struct soc_mixer_control) \
147 {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ 149 {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
148 .max = xmax, .invert = xinvert} } 150 .max = xmax, .platform_max = xmax, .invert = xinvert} }
149#define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\ 151#define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
150 xhandler_get, xhandler_put, tlv_array) \ 152 xhandler_get, xhandler_put, tlv_array) \
151{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 153{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
@@ -156,7 +158,7 @@
156 .get = xhandler_get, .put = xhandler_put, \ 158 .get = xhandler_get, .put = xhandler_put, \
157 .private_value = (unsigned long)&(struct soc_mixer_control) \ 159 .private_value = (unsigned long)&(struct soc_mixer_control) \
158 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ 160 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
159 .max = xmax, .invert = xinvert} } 161 .max = xmax, .platform_max = xmax, .invert = xinvert} }
160#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \ 162#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
161{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 163{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
162 .info = snd_soc_info_bool_ext, \ 164 .info = snd_soc_info_bool_ext, \
@@ -168,6 +170,38 @@
168 .get = xhandler_get, .put = xhandler_put, \ 170 .get = xhandler_get, .put = xhandler_put, \
169 .private_value = (unsigned long)&xenum } 171 .private_value = (unsigned long)&xenum }
170 172
173#define SOC_DOUBLE_R_SX_TLV(xname, xreg_left, xreg_right, xshift,\
174 xmin, xmax, tlv_array) \
175{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
176 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
177 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
178 .tlv.p = (tlv_array), \
179 .info = snd_soc_info_volsw_2r_sx, \
180 .get = snd_soc_get_volsw_2r_sx, \
181 .put = snd_soc_put_volsw_2r_sx, \
182 .private_value = (unsigned long)&(struct soc_mixer_control) \
183 {.reg = xreg_left, \
184 .rreg = xreg_right, .shift = xshift, \
185 .min = xmin, .max = xmax} }
186
187
188/*
189 * Simplified versions of above macros, declaring a struct and calculating
190 * ARRAY_SIZE internally
191 */
192#define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
193 struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
194 ARRAY_SIZE(xtexts), xtexts)
195#define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
196 SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
197#define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
198 struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
199#define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
200 struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
201 ARRAY_SIZE(xtexts), xtexts, xvalues)
202#define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
203 SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
204
171/* 205/*
172 * Bias levels 206 * Bias levels
173 * 207 *
@@ -195,6 +229,7 @@ struct snd_soc_dai_mode;
195struct snd_soc_pcm_runtime; 229struct snd_soc_pcm_runtime;
196struct snd_soc_dai; 230struct snd_soc_dai;
197struct snd_soc_platform; 231struct snd_soc_platform;
232struct snd_soc_dai_link;
198struct snd_soc_codec; 233struct snd_soc_codec;
199struct soc_enum; 234struct soc_enum;
200struct snd_soc_ac97_ops; 235struct snd_soc_ac97_ops;
@@ -243,6 +278,10 @@ int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type,
243void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); 278void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
244int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, 279int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
245 struct snd_soc_jack_pin *pins); 280 struct snd_soc_jack_pin *pins);
281void snd_soc_jack_notifier_register(struct snd_soc_jack *jack,
282 struct notifier_block *nb);
283void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
284 struct notifier_block *nb);
246#ifdef CONFIG_GPIOLIB 285#ifdef CONFIG_GPIOLIB
247int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, 286int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
248 struct snd_soc_jack_gpio *gpios); 287 struct snd_soc_jack_gpio *gpios);
@@ -253,6 +292,9 @@ void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
253/* codec register bit access */ 292/* codec register bit access */
254int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, 293int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
255 unsigned int mask, unsigned int value); 294 unsigned int mask, unsigned int value);
295int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
296 unsigned short reg, unsigned int mask,
297 unsigned int value);
256int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, 298int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
257 unsigned int mask, unsigned int value); 299 unsigned int mask, unsigned int value);
258 300
@@ -300,6 +342,14 @@ int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
300 struct snd_ctl_elem_value *ucontrol); 342 struct snd_ctl_elem_value *ucontrol);
301int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol, 343int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
302 struct snd_ctl_elem_value *ucontrol); 344 struct snd_ctl_elem_value *ucontrol);
345int snd_soc_limit_volume(struct snd_soc_codec *codec,
346 const char *name, int max);
347int snd_soc_info_volsw_2r_sx(struct snd_kcontrol *kcontrol,
348 struct snd_ctl_elem_info *uinfo);
349int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol,
350 struct snd_ctl_elem_value *ucontrol);
351int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol,
352 struct snd_ctl_elem_value *ucontrol);
303 353
304/** 354/**
305 * struct snd_soc_jack_pin - Describes a pin to update based on jack detection 355 * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
@@ -343,6 +393,7 @@ struct snd_soc_jack {
343 struct snd_soc_card *card; 393 struct snd_soc_card *card;
344 struct list_head pins; 394 struct list_head pins;
345 int status; 395 int status;
396 struct blocking_notifier_head notifier;
346}; 397};
347 398
348/* SoC PCM stream information */ 399/* SoC PCM stream information */
@@ -354,7 +405,8 @@ struct snd_soc_pcm_stream {
354 unsigned int rate_max; /* max rate */ 405 unsigned int rate_max; /* max rate */
355 unsigned int channels_min; /* min channels */ 406 unsigned int channels_min; /* min channels */
356 unsigned int channels_max; /* max channels */ 407 unsigned int channels_max; /* max channels */
357 unsigned int active:1; /* stream is in use */ 408 unsigned int active; /* stream is in use */
409 void *dma_data; /* used by platform code */
358}; 410};
359 411
360/* SoC audio ops */ 412/* SoC audio ops */
@@ -386,7 +438,7 @@ struct snd_soc_codec {
386 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ 438 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
387 unsigned int active; 439 unsigned int active;
388 unsigned int pcm_devs; 440 unsigned int pcm_devs;
389 void *private_data; 441 void *drvdata;
390 442
391 /* codec IO */ 443 /* codec IO */
392 void *control_data; /* codec control (i2c/3wire) data */ 444 void *control_data; /* codec control (i2c/3wire) data */
@@ -402,6 +454,10 @@ struct snd_soc_codec {
402 short reg_cache_size; 454 short reg_cache_size;
403 short reg_cache_step; 455 short reg_cache_step;
404 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
405 /* dapm */ 461 /* dapm */
406 u32 pop_time; 462 u32 pop_time;
407 struct list_head dapm_widgets; 463 struct list_head dapm_widgets;
@@ -437,14 +493,21 @@ struct snd_soc_platform {
437 493
438 int (*probe)(struct platform_device *pdev); 494 int (*probe)(struct platform_device *pdev);
439 int (*remove)(struct platform_device *pdev); 495 int (*remove)(struct platform_device *pdev);
440 int (*suspend)(struct snd_soc_dai *dai); 496 int (*suspend)(struct snd_soc_dai_link *dai_link);
441 int (*resume)(struct snd_soc_dai *dai); 497 int (*resume)(struct snd_soc_dai_link *dai_link);
442 498
443 /* pcm creation and destruction */ 499 /* pcm creation and destruction */
444 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *, 500 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
445 struct snd_pcm *); 501 struct snd_pcm *);
446 void (*pcm_free)(struct snd_pcm *); 502 void (*pcm_free)(struct snd_pcm *);
447 503
504 /*
505 * For platform caused delay reporting.
506 * Optional.
507 */
508 snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
509 struct snd_soc_dai *);
510
448 /* platform stream ops */ 511 /* platform stream ops */
449 struct snd_pcm_ops *pcm_ops; 512 struct snd_pcm_ops *pcm_ops;
450}; 513};
@@ -464,6 +527,9 @@ struct snd_soc_dai_link {
464 /* codec/machine specific init - e.g. add machine controls */ 527 /* codec/machine specific init - e.g. add machine controls */
465 int (*init)(struct snd_soc_codec *codec); 528 int (*init)(struct snd_soc_codec *codec);
466 529
530 /* Keep DAI active over suspend */
531 unsigned int ignore_suspend:1;
532
467 /* Symmetry requirements */ 533 /* Symmetry requirements */
468 unsigned int symmetric_rates:1; 534 unsigned int symmetric_rates:1;
469 535
@@ -497,6 +563,8 @@ struct snd_soc_card {
497 int (*set_bias_level)(struct snd_soc_card *, 563 int (*set_bias_level)(struct snd_soc_card *,
498 enum snd_soc_bias_level level); 564 enum snd_soc_bias_level level);
499 565
566 long pmdown_time;
567
500 /* CPU <--> Codec DAI links */ 568 /* CPU <--> Codec DAI links */
501 struct snd_soc_dai_link *dai_link; 569 struct snd_soc_dai_link *dai_link;
502 int num_links; 570 int num_links;
@@ -526,7 +594,7 @@ struct snd_soc_pcm_runtime {
526 594
527/* mixer control */ 595/* mixer control */
528struct soc_mixer_control { 596struct soc_mixer_control {
529 int min, max; 597 int min, max, platform_max;
530 unsigned int reg, rreg, shift, rshift, invert; 598 unsigned int reg, rreg, shift, rshift, invert;
531}; 599};
532 600
@@ -556,6 +624,17 @@ static inline unsigned int snd_soc_write(struct snd_soc_codec *codec,
556 return codec->write(codec, reg, val); 624 return codec->write(codec, reg, val);
557} 625}
558 626
627static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
628 void *data)
629{
630 codec->drvdata = data;
631}
632
633static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec)
634{
635 return codec->drvdata;
636}
637
559#include <sound/soc-dai.h> 638#include <sound/soc-dai.h>
560 639
561#endif 640#endif