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.h175
1 files changed, 100 insertions, 75 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index d3c8c033dff8..1890d87c5204 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -73,6 +73,15 @@
73 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ 73 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
74 .private_value = (reg_left) | ((shift) << 8) | \ 74 .private_value = (reg_left) | ((shift) << 8) | \
75 ((max) << 12) | ((invert) << 20) | ((reg_right) << 24) } 75 ((max) << 12) | ((invert) << 20) | ((reg_right) << 24) }
76#define SOC_DOUBLE_S8_TLV(xname, reg, min, max, tlv_array) \
77{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
78 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
79 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
80 .tlv.p = (tlv_array), \
81 .info = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \
82 .put = snd_soc_put_volsw_s8, \
83 .private_value = (reg) | (((signed char)max) << 16) | \
84 (((signed char)min) << 24) }
76#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \ 85#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
77{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ 86{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
78 .mask = xmask, .texts = xtexts } 87 .mask = xmask, .texts = xtexts }
@@ -91,6 +100,15 @@
91 .info = snd_soc_info_volsw, \ 100 .info = snd_soc_info_volsw, \
92 .get = xhandler_get, .put = xhandler_put, \ 101 .get = xhandler_get, .put = xhandler_put, \
93 .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmask, xinvert) } 102 .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmask, xinvert) }
103#define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmask, xinvert,\
104 xhandler_get, xhandler_put, tlv_array) \
105{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
106 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
107 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
108 .tlv.p = (tlv_array), \
109 .info = snd_soc_info_volsw, \
110 .get = xhandler_get, .put = xhandler_put, \
111 .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmask, xinvert) }
94#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \ 112#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
95{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 113{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
96 .info = snd_soc_info_bool_ext, \ 114 .info = snd_soc_info_bool_ext, \
@@ -103,6 +121,24 @@
103 .private_value = (unsigned long)&xenum } 121 .private_value = (unsigned long)&xenum }
104 122
105/* 123/*
124 * Bias levels
125 *
126 * @ON: Bias is fully on for audio playback and capture operations.
127 * @PREPARE: Prepare for audio operations. Called before DAPM switching for
128 * stream start and stop operations.
129 * @STANDBY: Low power standby state when no playback/capture operations are
130 * in progress. NOTE: The transition time between STANDBY and ON
131 * should be as fast as possible and no longer than 10ms.
132 * @OFF: Power Off. No restrictions on transition times.
133 */
134enum snd_soc_bias_level {
135 SND_SOC_BIAS_ON,
136 SND_SOC_BIAS_PREPARE,
137 SND_SOC_BIAS_STANDBY,
138 SND_SOC_BIAS_OFF,
139};
140
141/*
106 * Digital Audio Interface (DAI) types 142 * Digital Audio Interface (DAI) types
107 */ 143 */
108#define SND_SOC_DAI_AC97 0x1 144#define SND_SOC_DAI_AC97 0x1
@@ -185,8 +221,7 @@ struct snd_soc_pcm_stream;
185struct snd_soc_ops; 221struct snd_soc_ops;
186struct snd_soc_dai_mode; 222struct snd_soc_dai_mode;
187struct snd_soc_pcm_runtime; 223struct snd_soc_pcm_runtime;
188struct snd_soc_codec_dai; 224struct snd_soc_dai;
189struct snd_soc_cpu_dai;
190struct snd_soc_codec; 225struct snd_soc_codec;
191struct snd_soc_machine_config; 226struct snd_soc_machine_config;
192struct soc_enum; 227struct soc_enum;
@@ -221,6 +256,27 @@ int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
221 struct snd_ac97_bus_ops *ops, int num); 256 struct snd_ac97_bus_ops *ops, int num);
222void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); 257void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
223 258
259/* Digital Audio Interface clocking API.*/
260int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
261 unsigned int freq, int dir);
262
263int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
264 int div_id, int div);
265
266int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
267 int pll_id, unsigned int freq_in, unsigned int freq_out);
268
269/* Digital Audio interface formatting */
270int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
271
272int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
273 unsigned int mask, int slots);
274
275int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
276
277/* Digital Audio Interface mute */
278int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute);
279
224/* 280/*
225 *Controls 281 *Controls
226 */ 282 */
@@ -249,6 +305,12 @@ int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
249 struct snd_ctl_elem_value *ucontrol); 305 struct snd_ctl_elem_value *ucontrol);
250int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol, 306int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
251 struct snd_ctl_elem_value *ucontrol); 307 struct snd_ctl_elem_value *ucontrol);
308int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
309 struct snd_ctl_elem_info *uinfo);
310int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
311 struct snd_ctl_elem_value *ucontrol);
312int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
313 struct snd_ctl_elem_value *ucontrol);
252 314
253/* SoC PCM stream information */ 315/* SoC PCM stream information */
254struct snd_soc_pcm_stream { 316struct snd_soc_pcm_stream {
@@ -272,87 +334,45 @@ struct snd_soc_ops {
272 int (*trigger)(struct snd_pcm_substream *, int); 334 int (*trigger)(struct snd_pcm_substream *, int);
273}; 335};
274 336
275/* ASoC codec DAI ops */ 337/* ASoC DAI ops */
276struct snd_soc_codec_ops { 338struct snd_soc_dai_ops {
277 /* codec DAI clocking configuration */ 339 /* DAI clocking configuration */
278 int (*set_sysclk)(struct snd_soc_codec_dai *codec_dai, 340 int (*set_sysclk)(struct snd_soc_dai *dai,
279 int clk_id, unsigned int freq, int dir); 341 int clk_id, unsigned int freq, int dir);
280 int (*set_pll)(struct snd_soc_codec_dai *codec_dai, 342 int (*set_pll)(struct snd_soc_dai *dai,
281 int pll_id, unsigned int freq_in, unsigned int freq_out); 343 int pll_id, unsigned int freq_in, unsigned int freq_out);
282 int (*set_clkdiv)(struct snd_soc_codec_dai *codec_dai, 344 int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div);
283 int div_id, int div);
284 345
285 /* CPU DAI format configuration */ 346 /* DAI format configuration */
286 int (*set_fmt)(struct snd_soc_codec_dai *codec_dai, 347 int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
287 unsigned int fmt); 348 int (*set_tdm_slot)(struct snd_soc_dai *dai,
288 int (*set_tdm_slot)(struct snd_soc_codec_dai *codec_dai,
289 unsigned int mask, int slots); 349 unsigned int mask, int slots);
290 int (*set_tristate)(struct snd_soc_codec_dai *, int tristate); 350 int (*set_tristate)(struct snd_soc_dai *dai, int tristate);
291 351
292 /* digital mute */ 352 /* digital mute */
293 int (*digital_mute)(struct snd_soc_codec_dai *, int mute); 353 int (*digital_mute)(struct snd_soc_dai *dai, int mute);
294};
295
296/* ASoC cpu DAI ops */
297struct snd_soc_cpu_ops {
298 /* CPU DAI clocking configuration */
299 int (*set_sysclk)(struct snd_soc_cpu_dai *cpu_dai,
300 int clk_id, unsigned int freq, int dir);
301 int (*set_clkdiv)(struct snd_soc_cpu_dai *cpu_dai,
302 int div_id, int div);
303 int (*set_pll)(struct snd_soc_cpu_dai *cpu_dai,
304 int pll_id, unsigned int freq_in, unsigned int freq_out);
305
306 /* CPU DAI format configuration */
307 int (*set_fmt)(struct snd_soc_cpu_dai *cpu_dai,
308 unsigned int fmt);
309 int (*set_tdm_slot)(struct snd_soc_cpu_dai *cpu_dai,
310 unsigned int mask, int slots);
311 int (*set_tristate)(struct snd_soc_cpu_dai *, int tristate);
312};
313
314/* SoC Codec DAI */
315struct snd_soc_codec_dai {
316 char *name;
317 int id;
318 unsigned char type;
319
320 /* DAI capabilities */
321 struct snd_soc_pcm_stream playback;
322 struct snd_soc_pcm_stream capture;
323
324 /* DAI runtime info */
325 struct snd_soc_codec *codec;
326 unsigned int active;
327 unsigned char pop_wait:1;
328
329 /* ops */
330 struct snd_soc_ops ops;
331 struct snd_soc_codec_ops dai_ops;
332
333 /* DAI private data */
334 void *private_data;
335}; 354};
336 355
337/* SoC CPU DAI */ 356/* SoC DAI (Digital Audio Interface) */
338struct snd_soc_cpu_dai { 357struct snd_soc_dai {
339
340 /* DAI description */ 358 /* DAI description */
341 char *name; 359 char *name;
342 unsigned int id; 360 unsigned int id;
343 unsigned char type; 361 unsigned char type;
344 362
345 /* DAI callbacks */ 363 /* DAI callbacks */
346 int (*probe)(struct platform_device *pdev); 364 int (*probe)(struct platform_device *pdev,
347 void (*remove)(struct platform_device *pdev); 365 struct snd_soc_dai *dai);
366 void (*remove)(struct platform_device *pdev,
367 struct snd_soc_dai *dai);
348 int (*suspend)(struct platform_device *pdev, 368 int (*suspend)(struct platform_device *pdev,
349 struct snd_soc_cpu_dai *cpu_dai); 369 struct snd_soc_dai *dai);
350 int (*resume)(struct platform_device *pdev, 370 int (*resume)(struct platform_device *pdev,
351 struct snd_soc_cpu_dai *cpu_dai); 371 struct snd_soc_dai *dai);
352 372
353 /* ops */ 373 /* ops */
354 struct snd_soc_ops ops; 374 struct snd_soc_ops ops;
355 struct snd_soc_cpu_ops dai_ops; 375 struct snd_soc_dai_ops dai_ops;
356 376
357 /* DAI capabilities */ 377 /* DAI capabilities */
358 struct snd_soc_pcm_stream capture; 378 struct snd_soc_pcm_stream capture;
@@ -360,7 +380,9 @@ struct snd_soc_cpu_dai {
360 380
361 /* DAI runtime info */ 381 /* DAI runtime info */
362 struct snd_pcm_runtime *runtime; 382 struct snd_pcm_runtime *runtime;
363 unsigned char active:1; 383 struct snd_soc_codec *codec;
384 unsigned int active;
385 unsigned char pop_wait:1;
364 void *dma_data; 386 void *dma_data;
365 387
366 /* DAI private data */ 388 /* DAI private data */
@@ -374,7 +396,8 @@ struct snd_soc_codec {
374 struct mutex mutex; 396 struct mutex mutex;
375 397
376 /* callbacks */ 398 /* callbacks */
377 int (*dapm_event)(struct snd_soc_codec *codec, int event); 399 int (*set_bias_level)(struct snd_soc_codec *,
400 enum snd_soc_bias_level level);
378 401
379 /* runtime */ 402 /* runtime */
380 struct snd_card *card; 403 struct snd_card *card;
@@ -396,12 +419,12 @@ struct snd_soc_codec {
396 /* dapm */ 419 /* dapm */
397 struct list_head dapm_widgets; 420 struct list_head dapm_widgets;
398 struct list_head dapm_paths; 421 struct list_head dapm_paths;
399 unsigned int dapm_state; 422 enum snd_soc_bias_level bias_level;
400 unsigned int suspend_dapm_state; 423 enum snd_soc_bias_level suspend_bias_level;
401 struct delayed_work delayed_work; 424 struct delayed_work delayed_work;
402 425
403 /* codec DAI's */ 426 /* codec DAI's */
404 struct snd_soc_codec_dai *dai; 427 struct snd_soc_dai *dai;
405 unsigned int num_dai; 428 unsigned int num_dai;
406}; 429};
407 430
@@ -420,12 +443,12 @@ struct snd_soc_platform {
420 int (*probe)(struct platform_device *pdev); 443 int (*probe)(struct platform_device *pdev);
421 int (*remove)(struct platform_device *pdev); 444 int (*remove)(struct platform_device *pdev);
422 int (*suspend)(struct platform_device *pdev, 445 int (*suspend)(struct platform_device *pdev,
423 struct snd_soc_cpu_dai *cpu_dai); 446 struct snd_soc_dai *dai);
424 int (*resume)(struct platform_device *pdev, 447 int (*resume)(struct platform_device *pdev,
425 struct snd_soc_cpu_dai *cpu_dai); 448 struct snd_soc_dai *dai);
426 449
427 /* pcm creation and destruction */ 450 /* pcm creation and destruction */
428 int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *, 451 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
429 struct snd_pcm *); 452 struct snd_pcm *);
430 void (*pcm_free)(struct snd_pcm *); 453 void (*pcm_free)(struct snd_pcm *);
431 454
@@ -439,8 +462,8 @@ struct snd_soc_dai_link {
439 char *stream_name; /* Stream name */ 462 char *stream_name; /* Stream name */
440 463
441 /* DAI */ 464 /* DAI */
442 struct snd_soc_codec_dai *codec_dai; 465 struct snd_soc_dai *codec_dai;
443 struct snd_soc_cpu_dai *cpu_dai; 466 struct snd_soc_dai *cpu_dai;
444 467
445 /* machine stream operations */ 468 /* machine stream operations */
446 struct snd_soc_ops *ops; 469 struct snd_soc_ops *ops;
@@ -467,7 +490,8 @@ struct snd_soc_machine {
467 int (*resume_post)(struct platform_device *pdev); 490 int (*resume_post)(struct platform_device *pdev);
468 491
469 /* callbacks */ 492 /* callbacks */
470 int (*dapm_event)(struct snd_soc_machine *, int event); 493 int (*set_bias_level)(struct snd_soc_machine *,
494 enum snd_soc_bias_level level);
471 495
472 /* CPU <--> Codec DAI links */ 496 /* CPU <--> Codec DAI links */
473 struct snd_soc_dai_link *dai_link; 497 struct snd_soc_dai_link *dai_link;
@@ -482,6 +506,7 @@ struct snd_soc_device {
482 struct snd_soc_codec *codec; 506 struct snd_soc_codec *codec;
483 struct snd_soc_codec_device *codec_dev; 507 struct snd_soc_codec_device *codec_dev;
484 struct delayed_work delayed_work; 508 struct delayed_work delayed_work;
509 struct work_struct deferred_resume_work;
485 void *codec_data; 510 void *codec_data;
486}; 511};
487 512