2 * soc-core.c -- ALSA SoC Audio Layer
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Copyright 2005 Openedhand Ltd.
7 * Author: Liam Girdwood
8 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
9 * with code, comments and ideas from :-
10 * Richard Purdie <richard@openedhand.com>
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
18 * 12th Aug 2005 Initial version.
19 * 25th Oct 2005 Working Codec, Interface and Platform registration.
22 * o Add hw rules to enforce rates, etc.
23 * o More testing with other codecs/machines.
24 * o Add more codecs and platforms to ensure good API coverage.
25 * o Support TDM on PCM and I2S
28 #include <linux/module.h>
29 #include <linux/moduleparam.h>
30 #include <linux/init.h>
31 #include <linux/delay.h>
33 #include <linux/bitops.h>
34 #include <linux/platform_device.h>
35 #include <sound/driver.h>
36 #include <sound/core.h>
37 #include <sound/pcm.h>
38 #include <sound/pcm_params.h>
39 #include <sound/soc.h>
40 #include <sound/soc-dapm.h>
41 #include <sound/initval.h>
46 #define dbg(format, arg...) printk(format, ## arg)
48 #define dbg(format, arg...)
50 /* debug DAI capabilities matching */
51 #define SOC_DEBUG_DAI 0
53 #define dbgc(format, arg...) printk(format, ## arg)
55 #define dbgc(format, arg...)
58 #define CODEC_CPU(codec, cpu) ((codec << 4) | cpu)
60 static DEFINE_MUTEX(pcm_mutex);
61 static DEFINE_MUTEX(io_mutex);
62 static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq);
64 /* supported sample rates */
65 /* ATTENTION: these values depend on the definition in pcm.h! */
66 static const unsigned int rates[] = {
67 5512, 8000, 11025, 16000, 22050, 32000, 44100,
68 48000, 64000, 88200, 96000, 176400, 192000
72 * This is a timeout to do a DAPM powerdown after a stream is closed().
73 * It can be used to eliminate pops between different playback streams, e.g.
74 * between two audio tracks.
76 static int pmdown_time = 5000;
77 module_param(pmdown_time, int, 0);
78 MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
81 * This function forces any delayed work to be queued and run.
83 static int run_delayed_work(struct delayed_work *dwork)
87 /* cancel any work waiting to be queued. */
88 ret = cancel_delayed_work(dwork);
90 /* if there was any work waiting then we run it now and
91 * wait for it's completion */
93 schedule_delayed_work(dwork, 0);
94 flush_scheduled_work();
99 #ifdef CONFIG_SND_SOC_AC97_BUS
100 /* unregister ac97 codec */
101 static int soc_ac97_dev_unregister(struct snd_soc_codec *codec)
103 if (codec->ac97->dev.bus)
104 device_unregister(&codec->ac97->dev);
108 /* stop no dev release warning */
109 static void soc_ac97_device_release(struct device *dev){}
111 /* register ac97 codec to bus */
112 static int soc_ac97_dev_register(struct snd_soc_codec *codec)
116 codec->ac97->dev.bus = &ac97_bus_type;
117 codec->ac97->dev.parent = NULL;
118 codec->ac97->dev.release = soc_ac97_device_release;
120 snprintf(codec->ac97->dev.bus_id, BUS_ID_SIZE, "%d-%d:%s",
121 codec->card->number, 0, codec->name);
122 err = device_register(&codec->ac97->dev);
124 snd_printk(KERN_ERR "Can't register ac97 bus\n");
125 codec->ac97->dev.bus = NULL;
132 static inline const char* get_dai_name(int type)
135 case SND_SOC_DAI_AC97:
137 case SND_SOC_DAI_I2S:
139 case SND_SOC_DAI_PCM:
145 /* get rate format from rate */
146 static inline int soc_get_rate_format(int rate)
150 for (i = 0; i < ARRAY_SIZE(rates); i++) {
151 if (rates[i] == rate)
157 /* gets the audio system mclk/sysclk for the given parameters */
158 static unsigned inline int soc_get_mclk(struct snd_soc_pcm_runtime *rtd,
159 struct snd_soc_clock_info *info)
161 struct snd_soc_device *socdev = rtd->socdev;
162 struct snd_soc_machine *machine = socdev->machine;
165 /* find the matching machine config and get it's mclk for the given
166 * sample rate and hardware format */
167 for(i = 0; i < machine->num_links; i++) {
168 if (machine->dai_link[i].cpu_dai == rtd->cpu_dai &&
169 machine->dai_link[i].config_sysclk)
170 return machine->dai_link[i].config_sysclk(rtd, info);
175 /* changes a bitclk multiplier mask to a divider mask */
176 static u64 soc_bfs_rcw_to_div(u64 bfs, int rate, unsigned int mclk,
177 unsigned int pcmfmt, unsigned int chn)
181 int size = snd_pcm_format_physical_width(pcmfmt), min = 0;
186 /* the minimum bit clock that has enough bandwidth */
187 min = size * rate * chn;
188 dbgc("rcw --> div min bclk %d with mclk %d\n", min, mclk);
190 for (i = 0; i < 64; i++) {
191 if ((bfs >> i) & 0x1) {
193 bfs_ |= SND_SOC_FSBD(mclk/j);
194 dbgc("rcw --> div support mult %d\n",
195 SND_SOC_FSBD_REAL(1<<i));
202 /* changes a bitclk divider mask to a multiplier mask */
203 static u64 soc_bfs_div_to_rcw(u64 bfs, int rate, unsigned int mclk,
204 unsigned int pcmfmt, unsigned int chn)
209 int size = snd_pcm_format_physical_width(pcmfmt), min = 0;
214 /* the minimum bit clock that has enough bandwidth */
215 min = size * rate * chn;
216 dbgc("div to rcw min bclk %d with mclk %d\n", min, mclk);
218 for (i = 0; i < 64; i++) {
219 if ((bfs >> i) & 0x1) {
222 bfs_ |= SND_SOC_FSBW(j/min);
223 dbgc("div --> rcw support div %d\n",
224 SND_SOC_FSBW_REAL(1<<i));
232 /* changes a constant bitclk to a multiplier mask */
233 static u64 soc_bfs_rate_to_rcw(u64 bfs, int rate, unsigned int mclk,
234 unsigned int pcmfmt, unsigned int chn)
236 unsigned int bfs_ = rate * bfs;
237 int size = snd_pcm_format_physical_width(pcmfmt), min = 0;
242 /* the minimum bit clock that has enough bandwidth */
243 min = size * rate * chn;
244 dbgc("rate --> rcw min bclk %d with mclk %d\n", min, mclk);
249 bfs_ = SND_SOC_FSBW(bfs_/min);
250 dbgc("rate --> rcw support div %d\n", SND_SOC_FSBW_REAL(bfs_));
255 /* changes a bitclk multiplier mask to a divider mask */
256 static u64 soc_bfs_rate_to_div(u64 bfs, int rate, unsigned int mclk,
257 unsigned int pcmfmt, unsigned int chn)
259 unsigned int bfs_ = rate * bfs;
260 int size = snd_pcm_format_physical_width(pcmfmt), min = 0;
265 /* the minimum bit clock that has enough bandwidth */
266 min = size * rate * chn;
267 dbgc("rate --> div min bclk %d with mclk %d\n", min, mclk);
272 bfs_ = SND_SOC_FSBW(mclk/bfs_);
273 dbgc("rate --> div support div %d\n", SND_SOC_FSBD_REAL(bfs_));
278 /* Matches codec DAI and SoC CPU DAI hardware parameters */
279 static int soc_hw_match_params(struct snd_pcm_substream *substream,
280 struct snd_pcm_hw_params *params)
282 struct snd_soc_pcm_runtime *rtd = substream->private_data;
283 struct snd_soc_dai_mode *codec_dai_mode = NULL;
284 struct snd_soc_dai_mode *cpu_dai_mode = NULL;
285 struct snd_soc_clock_info clk_info;
286 unsigned int fs, mclk, rate = params_rate(params),
287 chn, j, k, cpu_bclk, codec_bclk, pcmrate;
289 u64 codec_bfs, cpu_bfs;
291 dbg("asoc: match version %s\n", SND_SOC_VERSION);
292 clk_info.rate = rate;
293 pcmrate = soc_get_rate_format(rate);
295 /* try and find a match from the codec and cpu DAI capabilities */
296 for (j = 0; j < rtd->codec_dai->caps.num_modes; j++) {
297 for (k = 0; k < rtd->cpu_dai->caps.num_modes; k++) {
298 codec_dai_mode = &rtd->codec_dai->caps.mode[j];
299 cpu_dai_mode = &rtd->cpu_dai->caps.mode[k];
301 if (!(codec_dai_mode->pcmrate & cpu_dai_mode->pcmrate &
303 dbgc("asoc: DAI[%d:%d] failed to match rate\n", j, k);
307 fmt = codec_dai_mode->fmt & cpu_dai_mode->fmt;
308 if (!(fmt & SND_SOC_DAIFMT_FORMAT_MASK)) {
309 dbgc("asoc: DAI[%d:%d] failed to match format\n", j, k);
313 if (!(fmt & SND_SOC_DAIFMT_CLOCK_MASK)) {
314 dbgc("asoc: DAI[%d:%d] failed to match clock masters\n",
319 if (!(fmt & SND_SOC_DAIFMT_INV_MASK)) {
320 dbgc("asoc: DAI[%d:%d] failed to match invert\n", j, k);
324 if (!(codec_dai_mode->pcmfmt & cpu_dai_mode->pcmfmt)) {
325 dbgc("asoc: DAI[%d:%d] failed to match pcm format\n", j, k);
329 if (!(codec_dai_mode->pcmdir & cpu_dai_mode->pcmdir)) {
330 dbgc("asoc: DAI[%d:%d] failed to match direction\n", j, k);
334 /* todo - still need to add tdm selection */
335 rtd->cpu_dai->dai_runtime.fmt =
336 rtd->codec_dai->dai_runtime.fmt =
337 1 << (ffs(fmt & SND_SOC_DAIFMT_FORMAT_MASK) -1) |
338 1 << (ffs(fmt & SND_SOC_DAIFMT_CLOCK_MASK) - 1) |
339 1 << (ffs(fmt & SND_SOC_DAIFMT_INV_MASK) - 1);
340 clk_info.bclk_master =
341 rtd->cpu_dai->dai_runtime.fmt & SND_SOC_DAIFMT_CLOCK_MASK;
343 /* make sure the ratio between rate and master
344 * clock is acceptable*/
345 fs = (cpu_dai_mode->fs & codec_dai_mode->fs);
347 dbgc("asoc: DAI[%d:%d] failed to match FS\n", j, k);
350 clk_info.fs = rtd->cpu_dai->dai_runtime.fs =
351 rtd->codec_dai->dai_runtime.fs = fs;
353 /* calculate audio system clocking using slowest clocks possible*/
354 mclk = soc_get_mclk(rtd, &clk_info);
356 dbgc("asoc: DAI[%d:%d] configuration not clockable\n", j, k);
357 dbgc("asoc: rate %d fs %d master %x\n", rate, fs,
358 clk_info.bclk_master);
362 /* calculate word size (per channel) and frame size */
363 rtd->codec_dai->dai_runtime.pcmfmt =
364 rtd->cpu_dai->dai_runtime.pcmfmt =
365 1 << params_format(params);
367 chn = params_channels(params);
368 /* i2s always has left and right */
369 if (params_channels(params) == 1 &&
370 rtd->cpu_dai->dai_runtime.fmt & (SND_SOC_DAIFMT_I2S |
371 SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_LEFT_J))
374 /* Calculate bfs - the ratio between bitclock and the sample rate
375 * We must take into consideration the dividers and multipliers
376 * used in the codec and cpu DAI modes. We always choose the
377 * lowest possible clocks to reduce power.
379 switch (CODEC_CPU(codec_dai_mode->flags, cpu_dai_mode->flags)) {
380 case CODEC_CPU(SND_SOC_DAI_BFS_DIV, SND_SOC_DAI_BFS_DIV):
381 /* cpu & codec bfs dividers */
382 rtd->cpu_dai->dai_runtime.bfs =
383 rtd->codec_dai->dai_runtime.bfs =
384 1 << (fls(codec_dai_mode->bfs & cpu_dai_mode->bfs) - 1);
386 case CODEC_CPU(SND_SOC_DAI_BFS_DIV, SND_SOC_DAI_BFS_RCW):
387 /* normalise bfs codec divider & cpu rcw mult */
388 codec_bfs = soc_bfs_div_to_rcw(codec_dai_mode->bfs, rate,
389 mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn);
390 rtd->cpu_dai->dai_runtime.bfs =
391 1 << (ffs(codec_bfs & cpu_dai_mode->bfs) - 1);
392 cpu_bfs = soc_bfs_rcw_to_div(cpu_dai_mode->bfs, rate, mclk,
393 rtd->codec_dai->dai_runtime.pcmfmt, chn);
394 rtd->codec_dai->dai_runtime.bfs =
395 1 << (fls(codec_dai_mode->bfs & cpu_bfs) - 1);
397 case CODEC_CPU(SND_SOC_DAI_BFS_RCW, SND_SOC_DAI_BFS_DIV):
398 /* normalise bfs codec rcw mult & cpu divider */
399 codec_bfs = soc_bfs_rcw_to_div(codec_dai_mode->bfs, rate,
400 mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn);
401 rtd->cpu_dai->dai_runtime.bfs =
402 1 << (fls(codec_bfs & cpu_dai_mode->bfs) -1);
403 cpu_bfs = soc_bfs_div_to_rcw(cpu_dai_mode->bfs, rate, mclk,
404 rtd->codec_dai->dai_runtime.pcmfmt, chn);
405 rtd->codec_dai->dai_runtime.bfs =
406 1 << (ffs(codec_dai_mode->bfs & cpu_bfs) -1);
408 case CODEC_CPU(SND_SOC_DAI_BFS_RCW, SND_SOC_DAI_BFS_RCW):
409 /* codec & cpu bfs rate rcw multipliers */
410 rtd->cpu_dai->dai_runtime.bfs =
411 rtd->codec_dai->dai_runtime.bfs =
412 1 << (ffs(codec_dai_mode->bfs & cpu_dai_mode->bfs) -1);
414 case CODEC_CPU(SND_SOC_DAI_BFS_DIV, SND_SOC_DAI_BFS_RATE):
415 /* normalise cpu bfs rate const multiplier & codec div */
416 cpu_bfs = soc_bfs_rate_to_div(cpu_dai_mode->bfs, rate,
417 mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn);
418 if(codec_dai_mode->bfs & cpu_bfs) {
419 rtd->codec_dai->dai_runtime.bfs = cpu_bfs;
420 rtd->cpu_dai->dai_runtime.bfs = cpu_dai_mode->bfs;
422 rtd->cpu_dai->dai_runtime.bfs = 0;
424 case CODEC_CPU(SND_SOC_DAI_BFS_RCW, SND_SOC_DAI_BFS_RATE):
425 /* normalise cpu bfs rate const multiplier & codec rcw mult */
426 cpu_bfs = soc_bfs_rate_to_rcw(cpu_dai_mode->bfs, rate,
427 mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn);
428 if(codec_dai_mode->bfs & cpu_bfs) {
429 rtd->codec_dai->dai_runtime.bfs = cpu_bfs;
430 rtd->cpu_dai->dai_runtime.bfs = cpu_dai_mode->bfs;
432 rtd->cpu_dai->dai_runtime.bfs = 0;
434 case CODEC_CPU(SND_SOC_DAI_BFS_RATE, SND_SOC_DAI_BFS_RCW):
435 /* normalise cpu bfs rate rcw multiplier & codec const mult */
436 codec_bfs = soc_bfs_rate_to_rcw(codec_dai_mode->bfs, rate,
437 mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn);
438 if(cpu_dai_mode->bfs & codec_bfs) {
439 rtd->cpu_dai->dai_runtime.bfs = codec_bfs;
440 rtd->codec_dai->dai_runtime.bfs = codec_dai_mode->bfs;
442 rtd->cpu_dai->dai_runtime.bfs = 0;
444 case CODEC_CPU(SND_SOC_DAI_BFS_RATE, SND_SOC_DAI_BFS_DIV):
445 /* normalise cpu bfs div & codec const mult */
446 codec_bfs = soc_bfs_rate_to_div(codec_dai_mode->bfs, rate,
447 mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn);
448 if(cpu_dai_mode->bfs & codec_bfs) {
449 rtd->cpu_dai->dai_runtime.bfs = codec_bfs;
450 rtd->codec_dai->dai_runtime.bfs = codec_dai_mode->bfs;
452 rtd->cpu_dai->dai_runtime.bfs = 0;
454 case CODEC_CPU(SND_SOC_DAI_BFS_RATE, SND_SOC_DAI_BFS_RATE):
455 /* cpu & codec constant mult */
456 if(codec_dai_mode->bfs == cpu_dai_mode->bfs)
457 rtd->cpu_dai->dai_runtime.bfs =
458 rtd->codec_dai->dai_runtime.bfs =
461 rtd->cpu_dai->dai_runtime.bfs =
462 rtd->codec_dai->dai_runtime.bfs = 0;
466 /* make sure the bit clock speed is acceptable */
467 if (!rtd->cpu_dai->dai_runtime.bfs ||
468 !rtd->codec_dai->dai_runtime.bfs) {
469 dbgc("asoc: DAI[%d:%d] failed to match BFS\n", j, k);
470 dbgc("asoc: cpu_dai %llu codec %llu\n",
471 rtd->cpu_dai->dai_runtime.bfs,
472 rtd->codec_dai->dai_runtime.bfs);
473 dbgc("asoc: mclk %d hwfmt %x\n", mclk, fmt);
480 printk(KERN_ERR "asoc: no matching DAI found between codec and CPU\n");
484 /* we have matching DAI's, so complete the runtime info */
485 rtd->codec_dai->dai_runtime.pcmrate =
486 rtd->cpu_dai->dai_runtime.pcmrate =
487 soc_get_rate_format(rate);
489 rtd->codec_dai->dai_runtime.priv = codec_dai_mode->priv;
490 rtd->cpu_dai->dai_runtime.priv = cpu_dai_mode->priv;
491 rtd->codec_dai->dai_runtime.flags = codec_dai_mode->flags;
492 rtd->cpu_dai->dai_runtime.flags = cpu_dai_mode->flags;
495 dbg("asoc: DAI[%d:%d] Match OK\n", j, k);
496 if (rtd->codec_dai->dai_runtime.flags == SND_SOC_DAI_BFS_DIV) {
497 codec_bclk = (rtd->codec_dai->dai_runtime.fs * params_rate(params)) /
498 SND_SOC_FSBD_REAL(rtd->codec_dai->dai_runtime.bfs);
499 dbg("asoc: codec fs %d mclk %d bfs div %d bclk %d\n",
500 rtd->codec_dai->dai_runtime.fs, mclk,
501 SND_SOC_FSBD_REAL(rtd->codec_dai->dai_runtime.bfs), codec_bclk);
502 } else if(rtd->codec_dai->dai_runtime.flags == SND_SOC_DAI_BFS_RATE) {
503 codec_bclk = params_rate(params) * rtd->codec_dai->dai_runtime.bfs;
504 dbg("asoc: codec fs %d mclk %d bfs rate mult %llu bclk %d\n",
505 rtd->codec_dai->dai_runtime.fs, mclk,
506 rtd->codec_dai->dai_runtime.bfs, codec_bclk);
507 } else if (rtd->cpu_dai->dai_runtime.flags == SND_SOC_DAI_BFS_RCW) {
508 codec_bclk = params_rate(params) * params_channels(params) *
509 snd_pcm_format_physical_width(rtd->codec_dai->dai_runtime.pcmfmt) *
510 SND_SOC_FSBW_REAL(rtd->codec_dai->dai_runtime.bfs);
511 dbg("asoc: codec fs %d mclk %d bfs rcw mult %d bclk %d\n",
512 rtd->codec_dai->dai_runtime.fs, mclk,
513 SND_SOC_FSBW_REAL(rtd->codec_dai->dai_runtime.bfs), codec_bclk);
517 if (rtd->cpu_dai->dai_runtime.flags == SND_SOC_DAI_BFS_DIV) {
518 cpu_bclk = (rtd->cpu_dai->dai_runtime.fs * params_rate(params)) /
519 SND_SOC_FSBD_REAL(rtd->cpu_dai->dai_runtime.bfs);
520 dbg("asoc: cpu fs %d mclk %d bfs div %d bclk %d\n",
521 rtd->cpu_dai->dai_runtime.fs, mclk,
522 SND_SOC_FSBD_REAL(rtd->cpu_dai->dai_runtime.bfs), cpu_bclk);
523 } else if (rtd->cpu_dai->dai_runtime.flags == SND_SOC_DAI_BFS_RATE) {
524 cpu_bclk = params_rate(params) * rtd->cpu_dai->dai_runtime.bfs;
525 dbg("asoc: cpu fs %d mclk %d bfs rate mult %llu bclk %d\n",
526 rtd->cpu_dai->dai_runtime.fs, mclk,
527 rtd->cpu_dai->dai_runtime.bfs, cpu_bclk);
528 } else if (rtd->cpu_dai->dai_runtime.flags == SND_SOC_DAI_BFS_RCW) {
529 cpu_bclk = params_rate(params) * params_channels(params) *
530 snd_pcm_format_physical_width(rtd->cpu_dai->dai_runtime.pcmfmt) *
531 SND_SOC_FSBW_REAL(rtd->cpu_dai->dai_runtime.bfs);
532 dbg("asoc: cpu fs %d mclk %d bfs mult rcw %d bclk %d\n",
533 rtd->cpu_dai->dai_runtime.fs, mclk,
534 SND_SOC_FSBW_REAL(rtd->cpu_dai->dai_runtime.bfs), cpu_bclk);
539 * Check we have matching bitclocks. If we don't then it means the
540 * sysclock returned by either the codec or cpu DAI (selected by the
541 * machine sysclock function) is wrong compared with the supported DAI
542 * modes for the codec or cpu DAI. Check your codec or CPU DAI
543 * config_sysclock() functions.
545 if (cpu_bclk != codec_bclk && cpu_bclk){
547 "asoc: codec and cpu bitclocks differ, audio may be wrong speed\n"
549 printk(KERN_ERR "asoc: codec %d != cpu %d\n", codec_bclk, cpu_bclk);
552 switch(rtd->cpu_dai->dai_runtime.fmt & SND_SOC_DAIFMT_CLOCK_MASK) {
553 case SND_SOC_DAIFMT_CBM_CFM:
554 dbg("asoc: DAI codec BCLK master, LRC master\n");
556 case SND_SOC_DAIFMT_CBS_CFM:
557 dbg("asoc: DAI codec BCLK slave, LRC master\n");
559 case SND_SOC_DAIFMT_CBM_CFS:
560 dbg("asoc: DAI codec BCLK master, LRC slave\n");
562 case SND_SOC_DAIFMT_CBS_CFS:
563 dbg("asoc: DAI codec BCLK slave, LRC slave\n");
566 dbg("asoc: mode %x, invert %x\n",
567 rtd->cpu_dai->dai_runtime.fmt & SND_SOC_DAIFMT_FORMAT_MASK,
568 rtd->cpu_dai->dai_runtime.fmt & SND_SOC_DAIFMT_INV_MASK);
569 dbg("asoc: audio rate %d chn %d fmt %x\n", params_rate(params),
570 params_channels(params), params_format(params));
575 static inline u32 get_rates(struct snd_soc_dai_mode *modes, int nmodes)
580 for(i = 0; i < nmodes; i++)
581 rates |= modes[i].pcmrate;
586 static inline u64 get_formats(struct snd_soc_dai_mode *modes, int nmodes)
591 for(i = 0; i < nmodes; i++)
592 formats |= modes[i].pcmfmt;
598 * Called by ALSA when a PCM substream is opened, the runtime->hw record is
599 * then initialized and any private data can be allocated. This also calls
600 * startup for the cpu DAI, platform, machine and codec DAI.
602 static int soc_pcm_open(struct snd_pcm_substream *substream)
604 struct snd_soc_pcm_runtime *rtd = substream->private_data;
605 struct snd_soc_device *socdev = rtd->socdev;
606 struct snd_pcm_runtime *runtime = substream->runtime;
607 struct snd_soc_machine *machine = socdev->machine;
608 struct snd_soc_platform *platform = socdev->platform;
609 struct snd_soc_codec_dai *codec_dai = rtd->codec_dai;
610 struct snd_soc_cpu_dai *cpu_dai = rtd->cpu_dai;
613 mutex_lock(&pcm_mutex);
615 /* startup the audio subsystem */
616 if (rtd->cpu_dai->ops.startup) {
617 ret = rtd->cpu_dai->ops.startup(substream);
619 printk(KERN_ERR "asoc: can't open interface %s\n",
625 if (platform->pcm_ops->open) {
626 ret = platform->pcm_ops->open(substream);
628 printk(KERN_ERR "asoc: can't open platform %s\n", platform->name);
633 if (machine->ops && machine->ops->startup) {
634 ret = machine->ops->startup(substream);
636 printk(KERN_ERR "asoc: %s startup failed\n", machine->name);
641 if (rtd->codec_dai->ops.startup) {
642 ret = rtd->codec_dai->ops.startup(substream);
644 printk(KERN_ERR "asoc: can't open codec %s\n",
645 rtd->codec_dai->name);
650 /* create runtime params from DMA, codec and cpu DAI */
651 if (runtime->hw.rates)
653 get_rates(codec_dai->caps.mode, codec_dai->caps.num_modes) &
654 get_rates(cpu_dai->caps.mode, cpu_dai->caps.num_modes);
657 get_rates(codec_dai->caps.mode, codec_dai->caps.num_modes) &
658 get_rates(cpu_dai->caps.mode, cpu_dai->caps.num_modes);
659 if (runtime->hw.formats)
660 runtime->hw.formats &=
661 get_formats(codec_dai->caps.mode, codec_dai->caps.num_modes) &
662 get_formats(cpu_dai->caps.mode, cpu_dai->caps.num_modes);
664 runtime->hw.formats =
665 get_formats(codec_dai->caps.mode, codec_dai->caps.num_modes) &
666 get_formats(cpu_dai->caps.mode, cpu_dai->caps.num_modes);
668 /* Check that the codec and cpu DAI's are compatible */
669 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
670 runtime->hw.rate_min =
671 max(rtd->codec_dai->playback.rate_min,
672 rtd->cpu_dai->playback.rate_min);
673 runtime->hw.rate_max =
674 min(rtd->codec_dai->playback.rate_max,
675 rtd->cpu_dai->playback.rate_max);
676 runtime->hw.channels_min =
677 max(rtd->codec_dai->playback.channels_min,
678 rtd->cpu_dai->playback.channels_min);
679 runtime->hw.channels_max =
680 min(rtd->codec_dai->playback.channels_max,
681 rtd->cpu_dai->playback.channels_max);
683 runtime->hw.rate_min =
684 max(rtd->codec_dai->capture.rate_min,
685 rtd->cpu_dai->capture.rate_min);
686 runtime->hw.rate_max =
687 min(rtd->codec_dai->capture.rate_max,
688 rtd->cpu_dai->capture.rate_max);
689 runtime->hw.channels_min =
690 max(rtd->codec_dai->capture.channels_min,
691 rtd->cpu_dai->capture.channels_min);
692 runtime->hw.channels_max =
693 min(rtd->codec_dai->capture.channels_max,
694 rtd->cpu_dai->capture.channels_max);
697 snd_pcm_limit_hw_rates(runtime);
698 if (!runtime->hw.rates) {
699 printk(KERN_ERR "asoc: %s <-> %s No matching rates\n",
700 rtd->codec_dai->name, rtd->cpu_dai->name);
703 if (!runtime->hw.formats) {
704 printk(KERN_ERR "asoc: %s <-> %s No matching formats\n",
705 rtd->codec_dai->name, rtd->cpu_dai->name);
708 if (!runtime->hw.channels_min || !runtime->hw.channels_max) {
709 printk(KERN_ERR "asoc: %s <-> %s No matching channels\n",
710 rtd->codec_dai->name, rtd->cpu_dai->name);
714 dbg("asoc: %s <-> %s info:\n", rtd->codec_dai->name, rtd->cpu_dai->name);
715 dbg("asoc: rate mask 0x%x\n", runtime->hw.rates);
716 dbg("asoc: min ch %d max ch %d\n", runtime->hw.channels_min,
717 runtime->hw.channels_max);
718 dbg("asoc: min rate %d max rate %d\n", runtime->hw.rate_min,
719 runtime->hw.rate_max);
722 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
723 rtd->cpu_dai->playback.active = rtd->codec_dai->playback.active = 1;
725 rtd->cpu_dai->capture.active = rtd->codec_dai->capture.active = 1;
726 rtd->cpu_dai->active = rtd->codec_dai->active = 1;
727 rtd->cpu_dai->runtime = runtime;
728 socdev->codec->active++;
729 mutex_unlock(&pcm_mutex);
733 if (machine->ops && machine->ops->shutdown)
734 machine->ops->shutdown(substream);
737 if (platform->pcm_ops->close)
738 platform->pcm_ops->close(substream);
741 if (rtd->cpu_dai->ops.shutdown)
742 rtd->cpu_dai->ops.shutdown(substream);
744 mutex_unlock(&pcm_mutex);
749 * Power down the audio subsytem pmdown_time msecs after close is called.
750 * This is to ensure there are no pops or clicks in between any music tracks
751 * due to DAPM power cycling.
753 static void close_delayed_work(struct work_struct *work)
755 struct snd_soc_device *socdev =
756 container_of(work, struct snd_soc_device, delayed_work.work);
757 struct snd_soc_codec *codec = socdev->codec;
758 struct snd_soc_codec_dai *codec_dai;
761 mutex_lock(&pcm_mutex);
762 for(i = 0; i < codec->num_dai; i++) {
763 codec_dai = &codec->dai[i];
765 dbg("pop wq checking: %s status: %s waiting: %s\n",
766 codec_dai->playback.stream_name,
767 codec_dai->playback.active ? "active" : "inactive",
768 codec_dai->pop_wait ? "yes" : "no");
770 /* are we waiting on this codec DAI stream */
771 if (codec_dai->pop_wait == 1) {
773 codec_dai->pop_wait = 0;
774 snd_soc_dapm_stream_event(codec, codec_dai->playback.stream_name,
775 SND_SOC_DAPM_STREAM_STOP);
777 /* power down the codec power domain if no longer active */
778 if (codec->active == 0) {
779 dbg("pop wq D3 %s %s\n", codec->name,
780 codec_dai->playback.stream_name);
781 if (codec->dapm_event)
782 codec->dapm_event(codec, SNDRV_CTL_POWER_D3hot);
786 mutex_unlock(&pcm_mutex);
790 * Called by ALSA when a PCM substream is closed. Private data can be
791 * freed here. The cpu DAI, codec DAI, machine and platform are also
794 static int soc_codec_close(struct snd_pcm_substream *substream)
796 struct snd_soc_pcm_runtime *rtd = substream->private_data;
797 struct snd_soc_device *socdev = rtd->socdev;
798 struct snd_soc_machine *machine = socdev->machine;
799 struct snd_soc_platform *platform = socdev->platform;
800 struct snd_soc_codec *codec = socdev->codec;
802 mutex_lock(&pcm_mutex);
804 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
805 rtd->cpu_dai->playback.active = rtd->codec_dai->playback.active = 0;
807 rtd->cpu_dai->capture.active = rtd->codec_dai->capture.active = 0;
809 if (rtd->codec_dai->playback.active == 0 &&
810 rtd->codec_dai->capture.active == 0) {
811 rtd->cpu_dai->active = rtd->codec_dai->active = 0;
815 if (rtd->cpu_dai->ops.shutdown)
816 rtd->cpu_dai->ops.shutdown(substream);
818 if (rtd->codec_dai->ops.shutdown)
819 rtd->codec_dai->ops.shutdown(substream);
821 if (machine->ops && machine->ops->shutdown)
822 machine->ops->shutdown(substream);
824 if (platform->pcm_ops->close)
825 platform->pcm_ops->close(substream);
826 rtd->cpu_dai->runtime = NULL;
828 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
829 /* start delayed pop wq here for playback streams */
830 rtd->codec_dai->pop_wait = 1;
831 schedule_delayed_work(&socdev->delayed_work,
832 msecs_to_jiffies(pmdown_time));
834 /* capture streams can be powered down now */
835 snd_soc_dapm_stream_event(codec, rtd->codec_dai->capture.stream_name,
836 SND_SOC_DAPM_STREAM_STOP);
838 if (codec->active == 0 && rtd->codec_dai->pop_wait == 0){
839 if (codec->dapm_event)
840 codec->dapm_event(codec, SNDRV_CTL_POWER_D3hot);
844 mutex_unlock(&pcm_mutex);
849 * Called by ALSA when the PCM substream is prepared, can set format, sample
850 * rate, etc. This function is non atomic and can be called multiple times,
851 * it can refer to the runtime info.
853 static int soc_pcm_prepare(struct snd_pcm_substream *substream)
855 struct snd_soc_pcm_runtime *rtd = substream->private_data;
856 struct snd_soc_device *socdev = rtd->socdev;
857 struct snd_soc_platform *platform = socdev->platform;
858 struct snd_soc_codec *codec = socdev->codec;
861 mutex_lock(&pcm_mutex);
862 if (platform->pcm_ops->prepare) {
863 ret = platform->pcm_ops->prepare(substream);
865 printk(KERN_ERR "asoc: platform prepare error\n");
870 if (rtd->codec_dai->ops.prepare) {
871 ret = rtd->codec_dai->ops.prepare(substream);
873 printk(KERN_ERR "asoc: codec DAI prepare error\n");
878 if (rtd->cpu_dai->ops.prepare)
879 ret = rtd->cpu_dai->ops.prepare(substream);
881 /* we only want to start a DAPM playback stream if we are not waiting
882 * on an existing one stopping */
883 if (rtd->codec_dai->pop_wait) {
884 /* we are waiting for the delayed work to start */
885 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
886 snd_soc_dapm_stream_event(codec,
887 rtd->codec_dai->capture.stream_name,
888 SND_SOC_DAPM_STREAM_START);
890 rtd->codec_dai->pop_wait = 0;
891 cancel_delayed_work(&socdev->delayed_work);
892 if (rtd->codec_dai->digital_mute)
893 rtd->codec_dai->digital_mute(codec, rtd->codec_dai, 0);
896 /* no delayed work - do we need to power up codec */
897 if (codec->dapm_state != SNDRV_CTL_POWER_D0) {
899 if (codec->dapm_event)
900 codec->dapm_event(codec, SNDRV_CTL_POWER_D1);
902 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
903 snd_soc_dapm_stream_event(codec,
904 rtd->codec_dai->playback.stream_name,
905 SND_SOC_DAPM_STREAM_START);
907 snd_soc_dapm_stream_event(codec,
908 rtd->codec_dai->capture.stream_name,
909 SND_SOC_DAPM_STREAM_START);
911 if (codec->dapm_event)
912 codec->dapm_event(codec, SNDRV_CTL_POWER_D0);
913 if (rtd->codec_dai->digital_mute)
914 rtd->codec_dai->digital_mute(codec, rtd->codec_dai, 0);
917 /* codec already powered - power on widgets */
918 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
919 snd_soc_dapm_stream_event(codec,
920 rtd->codec_dai->playback.stream_name,
921 SND_SOC_DAPM_STREAM_START);
923 snd_soc_dapm_stream_event(codec,
924 rtd->codec_dai->capture.stream_name,
925 SND_SOC_DAPM_STREAM_START);
926 if (rtd->codec_dai->digital_mute)
927 rtd->codec_dai->digital_mute(codec, rtd->codec_dai, 0);
932 mutex_unlock(&pcm_mutex);
937 * Called by ALSA when the hardware params are set by application. This
938 * function can also be called multiple times and can allocate buffers
939 * (using snd_pcm_lib_* ). It's non-atomic.
941 static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
942 struct snd_pcm_hw_params *params)
944 struct snd_soc_pcm_runtime *rtd = substream->private_data;
945 struct snd_soc_device *socdev = rtd->socdev;
946 struct snd_soc_platform *platform = socdev->platform;
947 struct snd_soc_machine *machine = socdev->machine;
950 mutex_lock(&pcm_mutex);
952 /* we don't need to match any AC97 params */
953 if (rtd->cpu_dai->type != SND_SOC_DAI_AC97) {
954 ret = soc_hw_match_params(substream, params);
958 struct snd_soc_clock_info clk_info;
959 clk_info.rate = params_rate(params);
960 ret = soc_get_mclk(rtd, &clk_info);
965 if (rtd->codec_dai->ops.hw_params) {
966 ret = rtd->codec_dai->ops.hw_params(substream, params);
968 printk(KERN_ERR "asoc: can't set codec %s hw params\n",
969 rtd->codec_dai->name);
974 if (rtd->cpu_dai->ops.hw_params) {
975 ret = rtd->cpu_dai->ops.hw_params(substream, params);
977 printk(KERN_ERR "asoc: can't set interface %s hw params\n",
983 if (platform->pcm_ops->hw_params) {
984 ret = platform->pcm_ops->hw_params(substream, params);
986 printk(KERN_ERR "asoc: can't set platform %s hw params\n",
992 if (machine->ops && machine->ops->hw_params) {
993 ret = machine->ops->hw_params(substream, params);
995 printk(KERN_ERR "asoc: machine hw_params failed\n");
1001 mutex_unlock(&pcm_mutex);
1005 if (platform->pcm_ops->hw_free)
1006 platform->pcm_ops->hw_free(substream);
1009 if (rtd->cpu_dai->ops.hw_free)
1010 rtd->cpu_dai->ops.hw_free(substream);
1013 if (rtd->codec_dai->ops.hw_free)
1014 rtd->codec_dai->ops.hw_free(substream);
1016 mutex_unlock(&pcm_mutex);
1021 * Free's resources allocated by hw_params, can be called multiple times
1023 static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
1025 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1026 struct snd_soc_device *socdev = rtd->socdev;
1027 struct snd_soc_platform *platform = socdev->platform;
1028 struct snd_soc_codec *codec = socdev->codec;
1029 struct snd_soc_machine *machine = socdev->machine;
1031 mutex_lock(&pcm_mutex);
1033 /* apply codec digital mute */
1034 if (!codec->active && rtd->codec_dai->digital_mute)
1035 rtd->codec_dai->digital_mute(codec, rtd->codec_dai, 1);
1037 /* free any machine hw params */
1038 if (machine->ops && machine->ops->hw_free)
1039 machine->ops->hw_free(substream);
1041 /* free any DMA resources */
1042 if (platform->pcm_ops->hw_free)
1043 platform->pcm_ops->hw_free(substream);
1045 /* now free hw params for the DAI's */
1046 if (rtd->codec_dai->ops.hw_free)
1047 rtd->codec_dai->ops.hw_free(substream);
1049 if (rtd->cpu_dai->ops.hw_free)
1050 rtd->cpu_dai->ops.hw_free(substream);
1052 mutex_unlock(&pcm_mutex);
1056 static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1058 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1059 struct snd_soc_device *socdev = rtd->socdev;
1060 struct snd_soc_platform *platform = socdev->platform;
1063 if (rtd->codec_dai->ops.trigger) {
1064 ret = rtd->codec_dai->ops.trigger(substream, cmd);
1069 if (platform->pcm_ops->trigger) {
1070 ret = platform->pcm_ops->trigger(substream, cmd);
1075 if (rtd->cpu_dai->ops.trigger) {
1076 ret = rtd->cpu_dai->ops.trigger(substream, cmd);
1083 /* ASoC PCM operations */
1084 static struct snd_pcm_ops soc_pcm_ops = {
1085 .open = soc_pcm_open,
1086 .close = soc_codec_close,
1087 .hw_params = soc_pcm_hw_params,
1088 .hw_free = soc_pcm_hw_free,
1089 .prepare = soc_pcm_prepare,
1090 .trigger = soc_pcm_trigger,
1094 /* powers down audio subsystem for suspend */
1095 static int soc_suspend(struct platform_device *pdev, pm_message_t state)
1097 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1098 struct snd_soc_machine *machine = socdev->machine;
1099 struct snd_soc_platform *platform = socdev->platform;
1100 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
1101 struct snd_soc_codec *codec = socdev->codec;
1104 /* mute any active DAC's */
1105 for(i = 0; i < machine->num_links; i++) {
1106 struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai;
1107 if (dai->digital_mute && dai->playback.active)
1108 dai->digital_mute(codec, dai, 1);
1111 if (machine->suspend_pre)
1112 machine->suspend_pre(pdev, state);
1114 for(i = 0; i < machine->num_links; i++) {
1115 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
1116 if (cpu_dai->suspend && cpu_dai->type != SND_SOC_DAI_AC97)
1117 cpu_dai->suspend(pdev, cpu_dai);
1118 if (platform->suspend)
1119 platform->suspend(pdev, cpu_dai);
1122 /* close any waiting streams and save state */
1123 run_delayed_work(&socdev->delayed_work);
1124 codec->suspend_dapm_state = codec->dapm_state;
1126 for(i = 0; i < codec->num_dai; i++) {
1127 char *stream = codec->dai[i].playback.stream_name;
1129 snd_soc_dapm_stream_event(codec, stream,
1130 SND_SOC_DAPM_STREAM_SUSPEND);
1131 stream = codec->dai[i].capture.stream_name;
1133 snd_soc_dapm_stream_event(codec, stream,
1134 SND_SOC_DAPM_STREAM_SUSPEND);
1137 if (codec_dev->suspend)
1138 codec_dev->suspend(pdev, state);
1140 for(i = 0; i < machine->num_links; i++) {
1141 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
1142 if (cpu_dai->suspend && cpu_dai->type == SND_SOC_DAI_AC97)
1143 cpu_dai->suspend(pdev, cpu_dai);
1146 if (machine->suspend_post)
1147 machine->suspend_post(pdev, state);
1152 /* powers up audio subsystem after a suspend */
1153 static int soc_resume(struct platform_device *pdev)
1155 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1156 struct snd_soc_machine *machine = socdev->machine;
1157 struct snd_soc_platform *platform = socdev->platform;
1158 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
1159 struct snd_soc_codec *codec = socdev->codec;
1162 if (machine->resume_pre)
1163 machine->resume_pre(pdev);
1165 for(i = 0; i < machine->num_links; i++) {
1166 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
1167 if (cpu_dai->resume && cpu_dai->type == SND_SOC_DAI_AC97)
1168 cpu_dai->resume(pdev, cpu_dai);
1171 if (codec_dev->resume)
1172 codec_dev->resume(pdev);
1174 for(i = 0; i < codec->num_dai; i++) {
1175 char* stream = codec->dai[i].playback.stream_name;
1177 snd_soc_dapm_stream_event(codec, stream,
1178 SND_SOC_DAPM_STREAM_RESUME);
1179 stream = codec->dai[i].capture.stream_name;
1181 snd_soc_dapm_stream_event(codec, stream,
1182 SND_SOC_DAPM_STREAM_RESUME);
1185 /* unmute any active DAC's */
1186 for(i = 0; i < machine->num_links; i++) {
1187 struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai;
1188 if (dai->digital_mute && dai->playback.active)
1189 dai->digital_mute(codec, dai, 0);
1192 for(i = 0; i < machine->num_links; i++) {
1193 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
1194 if (cpu_dai->resume && cpu_dai->type != SND_SOC_DAI_AC97)
1195 cpu_dai->resume(pdev, cpu_dai);
1196 if (platform->resume)
1197 platform->resume(pdev, cpu_dai);
1200 if (machine->resume_post)
1201 machine->resume_post(pdev);
1207 #define soc_suspend NULL
1208 #define soc_resume NULL
1211 /* probes a new socdev */
1212 static int soc_probe(struct platform_device *pdev)
1215 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1216 struct snd_soc_machine *machine = socdev->machine;
1217 struct snd_soc_platform *platform = socdev->platform;
1218 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
1220 if (machine->probe) {
1221 ret = machine->probe(pdev);
1226 for (i = 0; i < machine->num_links; i++) {
1227 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
1228 if (cpu_dai->probe) {
1229 ret = cpu_dai->probe(pdev);
1235 if (codec_dev->probe) {
1236 ret = codec_dev->probe(pdev);
1241 if (platform->probe) {
1242 ret = platform->probe(pdev);
1247 /* DAPM stream work */
1248 INIT_DELAYED_WORK(&socdev->delayed_work, close_delayed_work);
1252 if (codec_dev->remove)
1253 codec_dev->remove(pdev);
1256 for (i--; i >= 0; i--) {
1257 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
1258 if (cpu_dai->remove)
1259 cpu_dai->remove(pdev);
1262 if (machine->remove)
1263 machine->remove(pdev);
1268 /* removes a socdev */
1269 static int soc_remove(struct platform_device *pdev)
1272 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1273 struct snd_soc_machine *machine = socdev->machine;
1274 struct snd_soc_platform *platform = socdev->platform;
1275 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
1277 run_delayed_work(&socdev->delayed_work);
1279 if (platform->remove)
1280 platform->remove(pdev);
1282 if (codec_dev->remove)
1283 codec_dev->remove(pdev);
1285 for (i = 0; i < machine->num_links; i++) {
1286 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
1287 if (cpu_dai->remove)
1288 cpu_dai->remove(pdev);
1291 if (machine->remove)
1292 machine->remove(pdev);
1297 /* ASoC platform driver */
1298 static struct platform_driver soc_driver = {
1300 .name = "soc-audio",
1303 .remove = soc_remove,
1304 .suspend = soc_suspend,
1305 .resume = soc_resume,
1308 /* create a new pcm */
1309 static int soc_new_pcm(struct snd_soc_device *socdev,
1310 struct snd_soc_dai_link *dai_link, int num)
1312 struct snd_soc_codec *codec = socdev->codec;
1313 struct snd_soc_codec_dai *codec_dai = dai_link->codec_dai;
1314 struct snd_soc_cpu_dai *cpu_dai = dai_link->cpu_dai;
1315 struct snd_soc_pcm_runtime *rtd;
1316 struct snd_pcm *pcm;
1318 int ret = 0, playback = 0, capture = 0;
1320 rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL);
1323 rtd->cpu_dai = cpu_dai;
1324 rtd->codec_dai = codec_dai;
1325 rtd->socdev = socdev;
1327 /* check client and interface hw capabilities */
1328 sprintf(new_name, "%s %s-%s-%d",dai_link->stream_name, codec_dai->name,
1329 get_dai_name(cpu_dai->type), num);
1331 if (codec_dai->playback.channels_min)
1333 if (codec_dai->capture.channels_min)
1336 ret = snd_pcm_new(codec->card, new_name, codec->pcm_devs++, playback,
1339 printk(KERN_ERR "asoc: can't create pcm for codec %s\n", codec->name);
1344 pcm->private_data = rtd;
1345 soc_pcm_ops.mmap = socdev->platform->pcm_ops->mmap;
1346 soc_pcm_ops.pointer = socdev->platform->pcm_ops->pointer;
1347 soc_pcm_ops.ioctl = socdev->platform->pcm_ops->ioctl;
1348 soc_pcm_ops.copy = socdev->platform->pcm_ops->copy;
1349 soc_pcm_ops.silence = socdev->platform->pcm_ops->silence;
1350 soc_pcm_ops.ack = socdev->platform->pcm_ops->ack;
1351 soc_pcm_ops.page = socdev->platform->pcm_ops->page;
1354 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops);
1357 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops);
1359 ret = socdev->platform->pcm_new(codec->card, codec_dai, pcm);
1361 printk(KERN_ERR "asoc: platform pcm constructor failed\n");
1366 pcm->private_free = socdev->platform->pcm_free;
1367 printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name,
1372 /* codec register dump */
1373 static ssize_t codec_reg_show(struct device *dev,
1374 struct device_attribute *attr, char *buf)
1376 struct snd_soc_device *devdata = dev_get_drvdata(dev);
1377 struct snd_soc_codec *codec = devdata->codec;
1378 int i, step = 1, count = 0;
1380 if (!codec->reg_cache_size)
1383 if (codec->reg_cache_step)
1384 step = codec->reg_cache_step;
1386 count += sprintf(buf, "%s registers\n", codec->name);
1387 for(i = 0; i < codec->reg_cache_size; i += step)
1388 count += sprintf(buf + count, "%2x: %4x\n", i, codec->read(codec, i));
1392 static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
1395 * snd_soc_new_ac97_codec - initailise AC97 device
1396 * @codec: audio codec
1397 * @ops: AC97 bus operations
1398 * @num: AC97 codec number
1400 * Initialises AC97 codec resources for use by ad-hoc devices only.
1402 int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
1403 struct snd_ac97_bus_ops *ops, int num)
1405 mutex_lock(&codec->mutex);
1407 codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL);
1408 if (codec->ac97 == NULL) {
1409 mutex_unlock(&codec->mutex);
1413 codec->ac97->bus = kzalloc(sizeof(struct snd_ac97_bus), GFP_KERNEL);
1414 if (codec->ac97->bus == NULL) {
1417 mutex_unlock(&codec->mutex);
1421 codec->ac97->bus->ops = ops;
1422 codec->ac97->num = num;
1423 mutex_unlock(&codec->mutex);
1426 EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);
1429 * snd_soc_free_ac97_codec - free AC97 codec device
1430 * @codec: audio codec
1432 * Frees AC97 codec device resources.
1434 void snd_soc_free_ac97_codec(struct snd_soc_codec *codec)
1436 mutex_lock(&codec->mutex);
1437 kfree(codec->ac97->bus);
1440 mutex_unlock(&codec->mutex);
1442 EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec);
1445 * snd_soc_update_bits - update codec register bits
1446 * @codec: audio codec
1447 * @reg: codec register
1448 * @mask: register mask
1451 * Writes new register value.
1453 * Returns 1 for change else 0.
1455 int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
1456 unsigned short mask, unsigned short value)
1459 unsigned short old, new;
1461 mutex_lock(&io_mutex);
1462 old = snd_soc_read(codec, reg);
1463 new = (old & ~mask) | value;
1464 change = old != new;
1466 snd_soc_write(codec, reg, new);
1468 mutex_unlock(&io_mutex);
1471 EXPORT_SYMBOL_GPL(snd_soc_update_bits);
1474 * snd_soc_test_bits - test register for change
1475 * @codec: audio codec
1476 * @reg: codec register
1477 * @mask: register mask
1480 * Tests a register with a new value and checks if the new value is
1481 * different from the old value.
1483 * Returns 1 for change else 0.
1485 int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
1486 unsigned short mask, unsigned short value)
1489 unsigned short old, new;
1491 mutex_lock(&io_mutex);
1492 old = snd_soc_read(codec, reg);
1493 new = (old & ~mask) | value;
1494 change = old != new;
1495 mutex_unlock(&io_mutex);
1499 EXPORT_SYMBOL_GPL(snd_soc_test_bits);
1502 * snd_soc_get_rate - get int sample rate
1503 * @hwpcmrate: the hardware pcm rate
1505 * Returns the audio rate integaer value, else 0.
1507 int snd_soc_get_rate(int hwpcmrate)
1509 int rate = ffs(hwpcmrate) - 1;
1511 if (rate > ARRAY_SIZE(rates))
1515 EXPORT_SYMBOL_GPL(snd_soc_get_rate);
1518 * snd_soc_new_pcms - create new sound card and pcms
1519 * @socdev: the SoC audio device
1521 * Create a new sound card based upon the codec and interface pcms.
1523 * Returns 0 for success, else error.
1525 int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
1527 struct snd_soc_codec *codec = socdev->codec;
1528 struct snd_soc_machine *machine = socdev->machine;
1531 mutex_lock(&codec->mutex);
1533 /* register a sound card */
1534 codec->card = snd_card_new(idx, xid, codec->owner, 0);
1536 printk(KERN_ERR "asoc: can't create sound card for codec %s\n",
1538 mutex_unlock(&codec->mutex);
1542 codec->card->dev = socdev->dev;
1543 codec->card->private_data = codec;
1544 strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver));
1546 /* create the pcms */
1547 for(i = 0; i < machine->num_links; i++) {
1548 ret = soc_new_pcm(socdev, &machine->dai_link[i], i);
1550 printk(KERN_ERR "asoc: can't create pcm %s\n",
1551 machine->dai_link[i].stream_name);
1552 mutex_unlock(&codec->mutex);
1557 mutex_unlock(&codec->mutex);
1560 EXPORT_SYMBOL_GPL(snd_soc_new_pcms);
1563 * snd_soc_register_card - register sound card
1564 * @socdev: the SoC audio device
1566 * Register a SoC sound card. Also registers an AC97 device if the
1567 * codec is AC97 for ad hoc devices.
1569 * Returns 0 for success, else error.
1571 int snd_soc_register_card(struct snd_soc_device *socdev)
1573 struct snd_soc_codec *codec = socdev->codec;
1574 struct snd_soc_machine *machine = socdev->machine;
1575 int ret = 0, i, ac97 = 0, err = 0;
1577 mutex_lock(&codec->mutex);
1578 for(i = 0; i < machine->num_links; i++) {
1579 if (socdev->machine->dai_link[i].init) {
1580 err = socdev->machine->dai_link[i].init(codec);
1582 printk(KERN_ERR "asoc: failed to init %s\n",
1583 socdev->machine->dai_link[i].stream_name);
1587 if (socdev->machine->dai_link[i].cpu_dai->type == SND_SOC_DAI_AC97)
1590 snprintf(codec->card->shortname, sizeof(codec->card->shortname),
1591 "%s", machine->name);
1592 snprintf(codec->card->longname, sizeof(codec->card->longname),
1593 "%s (%s)", machine->name, codec->name);
1595 ret = snd_card_register(codec->card);
1597 printk(KERN_ERR "asoc: failed to register soundcard for codec %s\n",
1602 #ifdef CONFIG_SND_SOC_AC97_BUS
1604 ret = soc_ac97_dev_register(codec);
1606 printk(KERN_ERR "asoc: AC97 device register failed\n");
1607 snd_card_free(codec->card);
1613 err = snd_soc_dapm_sys_add(socdev->dev);
1615 printk(KERN_WARNING "asoc: failed to add dapm sysfs entries\n");
1617 err = device_create_file(socdev->dev, &dev_attr_codec_reg);
1619 printk(KERN_WARNING "asoc: failed to add codec sysfs entries\n");
1621 mutex_unlock(&codec->mutex);
1624 EXPORT_SYMBOL_GPL(snd_soc_register_card);
1627 * snd_soc_free_pcms - free sound card and pcms
1628 * @socdev: the SoC audio device
1630 * Frees sound card and pcms associated with the socdev.
1631 * Also unregister the codec if it is an AC97 device.
1633 void snd_soc_free_pcms(struct snd_soc_device *socdev)
1635 struct snd_soc_codec *codec = socdev->codec;
1637 mutex_lock(&codec->mutex);
1638 #ifdef CONFIG_SND_SOC_AC97_BUS
1640 soc_ac97_dev_unregister(codec);
1644 snd_card_free(codec->card);
1645 device_remove_file(socdev->dev, &dev_attr_codec_reg);
1646 mutex_unlock(&codec->mutex);
1648 EXPORT_SYMBOL_GPL(snd_soc_free_pcms);
1651 * snd_soc_set_runtime_hwparams - set the runtime hardware parameters
1652 * @substream: the pcm substream
1653 * @hw: the hardware parameters
1655 * Sets the substream runtime hardware parameters.
1657 int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
1658 const struct snd_pcm_hardware *hw)
1660 struct snd_pcm_runtime *runtime = substream->runtime;
1661 runtime->hw.info = hw->info;
1662 runtime->hw.formats = hw->formats;
1663 runtime->hw.period_bytes_min = hw->period_bytes_min;
1664 runtime->hw.period_bytes_max = hw->period_bytes_max;
1665 runtime->hw.periods_min = hw->periods_min;
1666 runtime->hw.periods_max = hw->periods_max;
1667 runtime->hw.buffer_bytes_max = hw->buffer_bytes_max;
1668 runtime->hw.fifo_size = hw->fifo_size;
1671 EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams);
1674 * snd_soc_cnew - create new control
1675 * @_template: control template
1676 * @data: control private data
1677 * @lnng_name: control long name
1679 * Create a new mixer control from a template control.
1681 * Returns 0 for success, else error.
1683 struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
1684 void *data, char *long_name)
1686 struct snd_kcontrol_new template;
1688 memcpy(&template, _template, sizeof(template));
1690 template.name = long_name;
1691 template.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
1694 return snd_ctl_new1(&template, data);
1696 EXPORT_SYMBOL_GPL(snd_soc_cnew);
1699 * snd_soc_info_enum_double - enumerated double mixer info callback
1700 * @kcontrol: mixer control
1701 * @uinfo: control element information
1703 * Callback to provide information about a double enumerated
1706 * Returns 0 for success.
1708 int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
1709 struct snd_ctl_elem_info *uinfo)
1711 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1713 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1714 uinfo->count = e->shift_l == e->shift_r ? 1 : 2;
1715 uinfo->value.enumerated.items = e->mask;
1717 if (uinfo->value.enumerated.item > e->mask - 1)
1718 uinfo->value.enumerated.item = e->mask - 1;
1719 strcpy(uinfo->value.enumerated.name,
1720 e->texts[uinfo->value.enumerated.item]);
1723 EXPORT_SYMBOL_GPL(snd_soc_info_enum_double);
1726 * snd_soc_get_enum_double - enumerated double mixer get callback
1727 * @kcontrol: mixer control
1728 * @uinfo: control element information
1730 * Callback to get the value of a double enumerated mixer.
1732 * Returns 0 for success.
1734 int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
1735 struct snd_ctl_elem_value *ucontrol)
1737 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1738 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1739 unsigned short val, bitmask;
1741 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
1743 val = snd_soc_read(codec, e->reg);
1744 ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1);
1745 if (e->shift_l != e->shift_r)
1746 ucontrol->value.enumerated.item[1] =
1747 (val >> e->shift_r) & (bitmask - 1);
1751 EXPORT_SYMBOL_GPL(snd_soc_get_enum_double);
1754 * snd_soc_put_enum_double - enumerated double mixer put callback
1755 * @kcontrol: mixer control
1756 * @uinfo: control element information
1758 * Callback to set the value of a double enumerated mixer.
1760 * Returns 0 for success.
1762 int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
1763 struct snd_ctl_elem_value *ucontrol)
1765 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1766 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1768 unsigned short mask, bitmask;
1770 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
1772 if (ucontrol->value.enumerated.item[0] > e->mask - 1)
1774 val = ucontrol->value.enumerated.item[0] << e->shift_l;
1775 mask = (bitmask - 1) << e->shift_l;
1776 if (e->shift_l != e->shift_r) {
1777 if (ucontrol->value.enumerated.item[1] > e->mask - 1)
1779 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
1780 mask |= (bitmask - 1) << e->shift_r;
1783 return snd_soc_update_bits(codec, e->reg, mask, val);
1785 EXPORT_SYMBOL_GPL(snd_soc_put_enum_double);
1788 * snd_soc_info_enum_ext - external enumerated single mixer info callback
1789 * @kcontrol: mixer control
1790 * @uinfo: control element information
1792 * Callback to provide information about an external enumerated
1795 * Returns 0 for success.
1797 int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
1798 struct snd_ctl_elem_info *uinfo)
1800 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1802 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1804 uinfo->value.enumerated.items = e->mask;
1806 if (uinfo->value.enumerated.item > e->mask - 1)
1807 uinfo->value.enumerated.item = e->mask - 1;
1808 strcpy(uinfo->value.enumerated.name,
1809 e->texts[uinfo->value.enumerated.item]);
1812 EXPORT_SYMBOL_GPL(snd_soc_info_enum_ext);
1815 * snd_soc_info_volsw_ext - external single mixer info callback
1816 * @kcontrol: mixer control
1817 * @uinfo: control element information
1819 * Callback to provide information about a single external mixer control.
1821 * Returns 0 for success.
1823 int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
1824 struct snd_ctl_elem_info *uinfo)
1826 int mask = kcontrol->private_value;
1829 mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
1831 uinfo->value.integer.min = 0;
1832 uinfo->value.integer.max = mask;
1835 EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext);
1838 * snd_soc_info_bool_ext - external single boolean mixer info callback
1839 * @kcontrol: mixer control
1840 * @uinfo: control element information
1842 * Callback to provide information about a single boolean external mixer control.
1844 * Returns 0 for success.
1846 int snd_soc_info_bool_ext(struct snd_kcontrol *kcontrol,
1847 struct snd_ctl_elem_info *uinfo)
1849 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1851 uinfo->value.integer.min = 0;
1852 uinfo->value.integer.max = 1;
1855 EXPORT_SYMBOL_GPL(snd_soc_info_bool_ext);
1858 * snd_soc_info_volsw - single mixer info callback
1859 * @kcontrol: mixer control
1860 * @uinfo: control element information
1862 * Callback to provide information about a single mixer control.
1864 * Returns 0 for success.
1866 int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
1867 struct snd_ctl_elem_info *uinfo)
1869 int mask = (kcontrol->private_value >> 16) & 0xff;
1870 int shift = (kcontrol->private_value >> 8) & 0x0f;
1871 int rshift = (kcontrol->private_value >> 12) & 0x0f;
1874 mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
1875 uinfo->count = shift == rshift ? 1 : 2;
1876 uinfo->value.integer.min = 0;
1877 uinfo->value.integer.max = mask;
1880 EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
1883 * snd_soc_get_volsw - single mixer get callback
1884 * @kcontrol: mixer control
1885 * @uinfo: control element information
1887 * Callback to get the value of a single mixer control.
1889 * Returns 0 for success.
1891 int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
1892 struct snd_ctl_elem_value *ucontrol)
1894 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1895 int reg = kcontrol->private_value & 0xff;
1896 int shift = (kcontrol->private_value >> 8) & 0x0f;
1897 int rshift = (kcontrol->private_value >> 12) & 0x0f;
1898 int mask = (kcontrol->private_value >> 16) & 0xff;
1899 int invert = (kcontrol->private_value >> 24) & 0x01;
1901 ucontrol->value.integer.value[0] =
1902 (snd_soc_read(codec, reg) >> shift) & mask;
1903 if (shift != rshift)
1904 ucontrol->value.integer.value[1] =
1905 (snd_soc_read(codec, reg) >> rshift) & mask;
1907 ucontrol->value.integer.value[0] =
1908 mask - ucontrol->value.integer.value[0];
1909 if (shift != rshift)
1910 ucontrol->value.integer.value[1] =
1911 mask - ucontrol->value.integer.value[1];
1916 EXPORT_SYMBOL_GPL(snd_soc_get_volsw);
1919 * snd_soc_put_volsw - single mixer put callback
1920 * @kcontrol: mixer control
1921 * @uinfo: control element information
1923 * Callback to set the value of a single mixer control.
1925 * Returns 0 for success.
1927 int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
1928 struct snd_ctl_elem_value *ucontrol)
1930 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1931 int reg = kcontrol->private_value & 0xff;
1932 int shift = (kcontrol->private_value >> 8) & 0x0f;
1933 int rshift = (kcontrol->private_value >> 12) & 0x0f;
1934 int mask = (kcontrol->private_value >> 16) & 0xff;
1935 int invert = (kcontrol->private_value >> 24) & 0x01;
1937 unsigned short val, val2, val_mask;
1939 val = (ucontrol->value.integer.value[0] & mask);
1942 val_mask = mask << shift;
1944 if (shift != rshift) {
1945 val2 = (ucontrol->value.integer.value[1] & mask);
1948 val_mask |= mask << rshift;
1949 val |= val2 << rshift;
1951 err = snd_soc_update_bits(codec, reg, val_mask, val);
1954 EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
1957 * snd_soc_info_volsw_2r - double mixer info callback
1958 * @kcontrol: mixer control
1959 * @uinfo: control element information
1961 * Callback to provide information about a double mixer control that
1962 * spans 2 codec registers.
1964 * Returns 0 for success.
1966 int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
1967 struct snd_ctl_elem_info *uinfo)
1969 int mask = (kcontrol->private_value >> 12) & 0xff;
1972 mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
1974 uinfo->value.integer.min = 0;
1975 uinfo->value.integer.max = mask;
1978 EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r);
1981 * snd_soc_get_volsw_2r - double mixer get callback
1982 * @kcontrol: mixer control
1983 * @uinfo: control element information
1985 * Callback to get the value of a double mixer control that spans 2 registers.
1987 * Returns 0 for success.
1989 int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
1990 struct snd_ctl_elem_value *ucontrol)
1992 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1993 int reg = kcontrol->private_value & 0xff;
1994 int reg2 = (kcontrol->private_value >> 24) & 0xff;
1995 int shift = (kcontrol->private_value >> 8) & 0x0f;
1996 int mask = (kcontrol->private_value >> 12) & 0xff;
1997 int invert = (kcontrol->private_value >> 20) & 0x01;
1999 ucontrol->value.integer.value[0] =
2000 (snd_soc_read(codec, reg) >> shift) & mask;
2001 ucontrol->value.integer.value[1] =
2002 (snd_soc_read(codec, reg2) >> shift) & mask;
2004 ucontrol->value.integer.value[0] =
2005 mask - ucontrol->value.integer.value[0];
2006 ucontrol->value.integer.value[1] =
2007 mask - ucontrol->value.integer.value[1];
2012 EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r);
2015 * snd_soc_put_volsw_2r - double mixer set callback
2016 * @kcontrol: mixer control
2017 * @uinfo: control element information
2019 * Callback to set the value of a double mixer control that spans 2 registers.
2021 * Returns 0 for success.
2023 int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
2024 struct snd_ctl_elem_value *ucontrol)
2026 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2027 int reg = kcontrol->private_value & 0xff;
2028 int reg2 = (kcontrol->private_value >> 24) & 0xff;
2029 int shift = (kcontrol->private_value >> 8) & 0x0f;
2030 int mask = (kcontrol->private_value >> 12) & 0xff;
2031 int invert = (kcontrol->private_value >> 20) & 0x01;
2033 unsigned short val, val2, val_mask;
2035 val_mask = mask << shift;
2036 val = (ucontrol->value.integer.value[0] & mask);
2037 val2 = (ucontrol->value.integer.value[1] & mask);
2045 val2 = val2 << shift;
2047 if ((err = snd_soc_update_bits(codec, reg, val_mask, val)) < 0)
2050 err = snd_soc_update_bits(codec, reg2, val_mask, val2);
2053 EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r);
2055 static int __devinit snd_soc_init(void)
2057 printk(KERN_INFO "ASoC version %s\n", SND_SOC_VERSION);
2058 return platform_driver_register(&soc_driver);
2061 static void snd_soc_exit(void)
2063 platform_driver_unregister(&soc_driver);
2066 module_init(snd_soc_init);
2067 module_exit(snd_soc_exit);
2069 /* Module information */
2070 MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
2071 MODULE_DESCRIPTION("ALSA SoC Core");
2072 MODULE_LICENSE("GPL");