blob: 1563ceedf61a09e8f3fdd3a2b6367ad544534fd5 [file] [log] [blame]
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001/*
2 * soc-core.c -- ALSA SoC Audio Layer
3 *
4 * Copyright 2005 Wolfson Microelectronics PLC.
Liam Girdwood0664d882006-12-18 14:39:02 +01005 * Copyright 2005 Openedhand Ltd.
6 *
Frank Mandarinodb2a4162006-10-06 18:31:09 +02007 * Author: Liam Girdwood
8 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
Liam Girdwood0664d882006-12-18 14:39:02 +01009 * with code, comments and ideas from :-
10 * Richard Purdie <richard@openedhand.com>
Frank Mandarinodb2a4162006-10-06 18:31:09 +020011 *
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.
16 *
Frank Mandarinodb2a4162006-10-06 18:31:09 +020017 * TODO:
18 * o Add hw rules to enforce rates, etc.
19 * o More testing with other codecs/machines.
20 * o Add more codecs and platforms to ensure good API coverage.
21 * o Support TDM on PCM and I2S
22 */
23
24#include <linux/module.h>
25#include <linux/moduleparam.h>
26#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/pm.h>
29#include <linux/bitops.h>
30#include <linux/platform_device.h>
Frank Mandarinodb2a4162006-10-06 18:31:09 +020031#include <sound/core.h>
32#include <sound/pcm.h>
33#include <sound/pcm_params.h>
34#include <sound/soc.h>
35#include <sound/soc-dapm.h>
36#include <sound/initval.h>
37
38/* debug */
39#define SOC_DEBUG 0
40#if SOC_DEBUG
41#define dbg(format, arg...) printk(format, ## arg)
42#else
43#define dbg(format, arg...)
44#endif
Liam Girdwooda71a4682006-10-19 20:35:56 +020045
Frank Mandarinodb2a4162006-10-06 18:31:09 +020046static DEFINE_MUTEX(pcm_mutex);
47static DEFINE_MUTEX(io_mutex);
Frank Mandarinodb2a4162006-10-06 18:31:09 +020048static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq);
49
Frank Mandarinodb2a4162006-10-06 18:31:09 +020050/*
51 * This is a timeout to do a DAPM powerdown after a stream is closed().
52 * It can be used to eliminate pops between different playback streams, e.g.
53 * between two audio tracks.
54 */
55static int pmdown_time = 5000;
56module_param(pmdown_time, int, 0);
57MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
58
Liam Girdwood965ac422007-01-31 14:14:57 +010059/*
60 * This function forces any delayed work to be queued and run.
61 */
62static int run_delayed_work(struct delayed_work *dwork)
63{
64 int ret;
65
66 /* cancel any work waiting to be queued. */
67 ret = cancel_delayed_work(dwork);
68
69 /* if there was any work waiting then we run it now and
70 * wait for it's completion */
71 if (ret) {
72 schedule_delayed_work(dwork, 0);
73 flush_scheduled_work();
74 }
75 return ret;
76}
77
Frank Mandarinodb2a4162006-10-06 18:31:09 +020078#ifdef CONFIG_SND_SOC_AC97_BUS
79/* unregister ac97 codec */
80static int soc_ac97_dev_unregister(struct snd_soc_codec *codec)
81{
82 if (codec->ac97->dev.bus)
83 device_unregister(&codec->ac97->dev);
84 return 0;
85}
86
87/* stop no dev release warning */
88static void soc_ac97_device_release(struct device *dev){}
89
90/* register ac97 codec to bus */
91static int soc_ac97_dev_register(struct snd_soc_codec *codec)
92{
93 int err;
94
95 codec->ac97->dev.bus = &ac97_bus_type;
96 codec->ac97->dev.parent = NULL;
97 codec->ac97->dev.release = soc_ac97_device_release;
98
99 snprintf(codec->ac97->dev.bus_id, BUS_ID_SIZE, "%d-%d:%s",
100 codec->card->number, 0, codec->name);
101 err = device_register(&codec->ac97->dev);
102 if (err < 0) {
103 snd_printk(KERN_ERR "Can't register ac97 bus\n");
104 codec->ac97->dev.bus = NULL;
105 return err;
106 }
107 return 0;
108}
109#endif
110
Mark Brown3ff3f642008-05-19 12:32:25 +0200111static inline const char *get_dai_name(int type)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200112{
Mark Brown3ff3f642008-05-19 12:32:25 +0200113 switch (type) {
Liam Girdwooda68660e2007-05-10 19:27:27 +0200114 case SND_SOC_DAI_AC97_BUS:
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200115 case SND_SOC_DAI_AC97:
116 return "AC97";
117 case SND_SOC_DAI_I2S:
118 return "I2S";
119 case SND_SOC_DAI_PCM:
120 return "PCM";
121 }
122 return NULL;
123}
124
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200125/*
126 * Called by ALSA when a PCM substream is opened, the runtime->hw record is
127 * then initialized and any private data can be allocated. This also calls
128 * startup for the cpu DAI, platform, machine and codec DAI.
129 */
130static int soc_pcm_open(struct snd_pcm_substream *substream)
131{
132 struct snd_soc_pcm_runtime *rtd = substream->private_data;
133 struct snd_soc_device *socdev = rtd->socdev;
134 struct snd_pcm_runtime *runtime = substream->runtime;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100135 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200136 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100137 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
138 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200139 int ret = 0;
140
141 mutex_lock(&pcm_mutex);
142
143 /* startup the audio subsystem */
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100144 if (cpu_dai->ops.startup) {
145 ret = cpu_dai->ops.startup(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200146 if (ret < 0) {
147 printk(KERN_ERR "asoc: can't open interface %s\n",
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100148 cpu_dai->name);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200149 goto out;
150 }
151 }
152
153 if (platform->pcm_ops->open) {
154 ret = platform->pcm_ops->open(substream);
155 if (ret < 0) {
156 printk(KERN_ERR "asoc: can't open platform %s\n", platform->name);
157 goto platform_err;
158 }
159 }
160
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100161 if (codec_dai->ops.startup) {
162 ret = codec_dai->ops.startup(substream);
163 if (ret < 0) {
164 printk(KERN_ERR "asoc: can't open codec %s\n",
165 codec_dai->name);
166 goto codec_dai_err;
167 }
168 }
169
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200170 if (machine->ops && machine->ops->startup) {
171 ret = machine->ops->startup(substream);
172 if (ret < 0) {
173 printk(KERN_ERR "asoc: %s startup failed\n", machine->name);
174 goto machine_err;
175 }
176 }
177
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200178 /* Check that the codec and cpu DAI's are compatible */
179 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
180 runtime->hw.rate_min =
Mark Brown3ff3f642008-05-19 12:32:25 +0200181 max(codec_dai->playback.rate_min,
182 cpu_dai->playback.rate_min);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200183 runtime->hw.rate_max =
Mark Brown3ff3f642008-05-19 12:32:25 +0200184 min(codec_dai->playback.rate_max,
185 cpu_dai->playback.rate_max);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200186 runtime->hw.channels_min =
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100187 max(codec_dai->playback.channels_min,
188 cpu_dai->playback.channels_min);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200189 runtime->hw.channels_max =
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100190 min(codec_dai->playback.channels_max,
191 cpu_dai->playback.channels_max);
192 runtime->hw.formats =
193 codec_dai->playback.formats & cpu_dai->playback.formats;
194 runtime->hw.rates =
195 codec_dai->playback.rates & cpu_dai->playback.rates;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200196 } else {
197 runtime->hw.rate_min =
Mark Brown3ff3f642008-05-19 12:32:25 +0200198 max(codec_dai->capture.rate_min,
199 cpu_dai->capture.rate_min);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200200 runtime->hw.rate_max =
Mark Brown3ff3f642008-05-19 12:32:25 +0200201 min(codec_dai->capture.rate_max,
202 cpu_dai->capture.rate_max);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200203 runtime->hw.channels_min =
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100204 max(codec_dai->capture.channels_min,
205 cpu_dai->capture.channels_min);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200206 runtime->hw.channels_max =
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100207 min(codec_dai->capture.channels_max,
208 cpu_dai->capture.channels_max);
209 runtime->hw.formats =
210 codec_dai->capture.formats & cpu_dai->capture.formats;
211 runtime->hw.rates =
212 codec_dai->capture.rates & cpu_dai->capture.rates;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200213 }
214
215 snd_pcm_limit_hw_rates(runtime);
216 if (!runtime->hw.rates) {
217 printk(KERN_ERR "asoc: %s <-> %s No matching rates\n",
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100218 codec_dai->name, cpu_dai->name);
219 goto machine_err;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200220 }
221 if (!runtime->hw.formats) {
222 printk(KERN_ERR "asoc: %s <-> %s No matching formats\n",
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100223 codec_dai->name, cpu_dai->name);
224 goto machine_err;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200225 }
226 if (!runtime->hw.channels_min || !runtime->hw.channels_max) {
227 printk(KERN_ERR "asoc: %s <-> %s No matching channels\n",
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100228 codec_dai->name, cpu_dai->name);
229 goto machine_err;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200230 }
231
Mark Brown3ff3f642008-05-19 12:32:25 +0200232 dbg("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name);
Liam Girdwoodb5c5fd22006-10-13 19:13:41 +0200233 dbg("asoc: rate mask 0x%x\n", runtime->hw.rates);
234 dbg("asoc: min ch %d max ch %d\n", runtime->hw.channels_min,
235 runtime->hw.channels_max);
236 dbg("asoc: min rate %d max rate %d\n", runtime->hw.rate_min,
237 runtime->hw.rate_max);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200238
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200239 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100240 cpu_dai->playback.active = codec_dai->playback.active = 1;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200241 else
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100242 cpu_dai->capture.active = codec_dai->capture.active = 1;
243 cpu_dai->active = codec_dai->active = 1;
244 cpu_dai->runtime = runtime;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200245 socdev->codec->active++;
246 mutex_unlock(&pcm_mutex);
247 return 0;
248
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100249machine_err:
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200250 if (machine->ops && machine->ops->shutdown)
251 machine->ops->shutdown(substream);
252
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100253codec_dai_err:
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200254 if (platform->pcm_ops->close)
255 platform->pcm_ops->close(substream);
256
257platform_err:
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100258 if (cpu_dai->ops.shutdown)
259 cpu_dai->ops.shutdown(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200260out:
261 mutex_unlock(&pcm_mutex);
262 return ret;
263}
264
265/*
Robert P. J. Day3a4fa0a2007-10-19 23:10:43 +0200266 * Power down the audio subsystem pmdown_time msecs after close is called.
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200267 * This is to ensure there are no pops or clicks in between any music tracks
268 * due to DAPM power cycling.
269 */
Andrew Morton4484bb22006-12-15 09:30:07 +0100270static void close_delayed_work(struct work_struct *work)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200271{
Andrew Morton4484bb22006-12-15 09:30:07 +0100272 struct snd_soc_device *socdev =
273 container_of(work, struct snd_soc_device, delayed_work.work);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200274 struct snd_soc_codec *codec = socdev->codec;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100275 struct snd_soc_dai *codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200276 int i;
277
278 mutex_lock(&pcm_mutex);
Mark Brown3ff3f642008-05-19 12:32:25 +0200279 for (i = 0; i < codec->num_dai; i++) {
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200280 codec_dai = &codec->dai[i];
281
282 dbg("pop wq checking: %s status: %s waiting: %s\n",
283 codec_dai->playback.stream_name,
284 codec_dai->playback.active ? "active" : "inactive",
285 codec_dai->pop_wait ? "yes" : "no");
286
287 /* are we waiting on this codec DAI stream */
288 if (codec_dai->pop_wait == 1) {
289
Mark Brown0be98982008-05-19 12:31:28 +0200290 /* Reduce power if no longer active */
Liam Girdwood3c1c47e2008-01-10 14:38:24 +0100291 if (codec->active == 0) {
292 dbg("pop wq D1 %s %s\n", codec->name,
293 codec_dai->playback.stream_name);
Mark Brown0be98982008-05-19 12:31:28 +0200294 snd_soc_dapm_set_bias_level(socdev,
295 SND_SOC_BIAS_PREPARE);
Liam Girdwood3c1c47e2008-01-10 14:38:24 +0100296 }
297
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200298 codec_dai->pop_wait = 0;
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100299 snd_soc_dapm_stream_event(codec,
300 codec_dai->playback.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200301 SND_SOC_DAPM_STREAM_STOP);
302
Mark Brown0be98982008-05-19 12:31:28 +0200303 /* Fall into standby if no longer active */
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200304 if (codec->active == 0) {
305 dbg("pop wq D3 %s %s\n", codec->name,
306 codec_dai->playback.stream_name);
Mark Brown0be98982008-05-19 12:31:28 +0200307 snd_soc_dapm_set_bias_level(socdev,
308 SND_SOC_BIAS_STANDBY);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200309 }
310 }
311 }
312 mutex_unlock(&pcm_mutex);
313}
314
315/*
316 * Called by ALSA when a PCM substream is closed. Private data can be
317 * freed here. The cpu DAI, codec DAI, machine and platform are also
318 * shutdown.
319 */
320static int soc_codec_close(struct snd_pcm_substream *substream)
321{
322 struct snd_soc_pcm_runtime *rtd = substream->private_data;
323 struct snd_soc_device *socdev = rtd->socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100324 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200325 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100326 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
327 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200328 struct snd_soc_codec *codec = socdev->codec;
329
330 mutex_lock(&pcm_mutex);
331
332 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100333 cpu_dai->playback.active = codec_dai->playback.active = 0;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200334 else
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100335 cpu_dai->capture.active = codec_dai->capture.active = 0;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200336
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100337 if (codec_dai->playback.active == 0 &&
338 codec_dai->capture.active == 0) {
339 cpu_dai->active = codec_dai->active = 0;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200340 }
341 codec->active--;
342
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100343 if (cpu_dai->ops.shutdown)
344 cpu_dai->ops.shutdown(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200345
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100346 if (codec_dai->ops.shutdown)
347 codec_dai->ops.shutdown(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200348
349 if (machine->ops && machine->ops->shutdown)
350 machine->ops->shutdown(substream);
351
352 if (platform->pcm_ops->close)
353 platform->pcm_ops->close(substream);
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100354 cpu_dai->runtime = NULL;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200355
356 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
357 /* start delayed pop wq here for playback streams */
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100358 codec_dai->pop_wait = 1;
Takashi Iwai4bb09522006-12-19 17:16:14 +0100359 schedule_delayed_work(&socdev->delayed_work,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200360 msecs_to_jiffies(pmdown_time));
361 } else {
362 /* capture streams can be powered down now */
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100363 snd_soc_dapm_stream_event(codec,
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100364 codec_dai->capture.stream_name,
365 SND_SOC_DAPM_STREAM_STOP);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200366
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100367 if (codec->active == 0 && codec_dai->pop_wait == 0)
Mark Brown0be98982008-05-19 12:31:28 +0200368 snd_soc_dapm_set_bias_level(socdev,
369 SND_SOC_BIAS_STANDBY);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200370 }
371
372 mutex_unlock(&pcm_mutex);
373 return 0;
374}
375
376/*
377 * Called by ALSA when the PCM substream is prepared, can set format, sample
378 * rate, etc. This function is non atomic and can be called multiple times,
379 * it can refer to the runtime info.
380 */
381static int soc_pcm_prepare(struct snd_pcm_substream *substream)
382{
383 struct snd_soc_pcm_runtime *rtd = substream->private_data;
384 struct snd_soc_device *socdev = rtd->socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100385 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200386 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100387 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
388 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200389 struct snd_soc_codec *codec = socdev->codec;
390 int ret = 0;
391
392 mutex_lock(&pcm_mutex);
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100393
394 if (machine->ops && machine->ops->prepare) {
395 ret = machine->ops->prepare(substream);
396 if (ret < 0) {
397 printk(KERN_ERR "asoc: machine prepare error\n");
398 goto out;
399 }
400 }
401
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200402 if (platform->pcm_ops->prepare) {
403 ret = platform->pcm_ops->prepare(substream);
Liam Girdwooda71a4682006-10-19 20:35:56 +0200404 if (ret < 0) {
405 printk(KERN_ERR "asoc: platform prepare error\n");
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200406 goto out;
Liam Girdwooda71a4682006-10-19 20:35:56 +0200407 }
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200408 }
409
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100410 if (codec_dai->ops.prepare) {
411 ret = codec_dai->ops.prepare(substream);
Liam Girdwooda71a4682006-10-19 20:35:56 +0200412 if (ret < 0) {
413 printk(KERN_ERR "asoc: codec DAI prepare error\n");
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200414 goto out;
Liam Girdwooda71a4682006-10-19 20:35:56 +0200415 }
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200416 }
417
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100418 if (cpu_dai->ops.prepare) {
419 ret = cpu_dai->ops.prepare(substream);
420 if (ret < 0) {
421 printk(KERN_ERR "asoc: cpu DAI prepare error\n");
422 goto out;
423 }
424 }
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200425
426 /* we only want to start a DAPM playback stream if we are not waiting
427 * on an existing one stopping */
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100428 if (codec_dai->pop_wait) {
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200429 /* we are waiting for the delayed work to start */
430 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100431 snd_soc_dapm_stream_event(socdev->codec,
432 codec_dai->capture.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200433 SND_SOC_DAPM_STREAM_START);
434 else {
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100435 codec_dai->pop_wait = 0;
Andrew Morton4484bb22006-12-15 09:30:07 +0100436 cancel_delayed_work(&socdev->delayed_work);
Liam Girdwood8c6529d2008-07-08 13:19:13 +0100437 snd_soc_dai_digital_mute(codec_dai, 0);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200438 }
439 } else {
440 /* no delayed work - do we need to power up codec */
Mark Brown0be98982008-05-19 12:31:28 +0200441 if (codec->bias_level != SND_SOC_BIAS_ON) {
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200442
Mark Brown0be98982008-05-19 12:31:28 +0200443 snd_soc_dapm_set_bias_level(socdev,
444 SND_SOC_BIAS_PREPARE);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200445
446 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
447 snd_soc_dapm_stream_event(codec,
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100448 codec_dai->playback.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200449 SND_SOC_DAPM_STREAM_START);
450 else
451 snd_soc_dapm_stream_event(codec,
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100452 codec_dai->capture.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200453 SND_SOC_DAPM_STREAM_START);
454
Mark Brown0be98982008-05-19 12:31:28 +0200455 snd_soc_dapm_set_bias_level(socdev, SND_SOC_BIAS_ON);
Liam Girdwood8c6529d2008-07-08 13:19:13 +0100456 snd_soc_dai_digital_mute(codec_dai, 0);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200457
458 } else {
459 /* codec already powered - power on widgets */
460 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
461 snd_soc_dapm_stream_event(codec,
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100462 codec_dai->playback.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200463 SND_SOC_DAPM_STREAM_START);
464 else
465 snd_soc_dapm_stream_event(codec,
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100466 codec_dai->capture.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200467 SND_SOC_DAPM_STREAM_START);
Liam Girdwood8c6529d2008-07-08 13:19:13 +0100468
469 snd_soc_dai_digital_mute(codec_dai, 0);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200470 }
471 }
472
473out:
474 mutex_unlock(&pcm_mutex);
475 return ret;
476}
477
478/*
479 * Called by ALSA when the hardware params are set by application. This
480 * function can also be called multiple times and can allocate buffers
481 * (using snd_pcm_lib_* ). It's non-atomic.
482 */
483static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
484 struct snd_pcm_hw_params *params)
485{
486 struct snd_soc_pcm_runtime *rtd = substream->private_data;
487 struct snd_soc_device *socdev = rtd->socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100488 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200489 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100490 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
491 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200492 int ret = 0;
493
494 mutex_lock(&pcm_mutex);
495
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100496 if (machine->ops && machine->ops->hw_params) {
497 ret = machine->ops->hw_params(substream, params);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200498 if (ret < 0) {
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100499 printk(KERN_ERR "asoc: machine hw_params failed\n");
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200500 goto out;
501 }
502 }
503
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100504 if (codec_dai->ops.hw_params) {
505 ret = codec_dai->ops.hw_params(substream, params);
506 if (ret < 0) {
507 printk(KERN_ERR "asoc: can't set codec %s hw params\n",
508 codec_dai->name);
509 goto codec_err;
510 }
511 }
512
513 if (cpu_dai->ops.hw_params) {
514 ret = cpu_dai->ops.hw_params(substream, params);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200515 if (ret < 0) {
Mark Brown3ff3f642008-05-19 12:32:25 +0200516 printk(KERN_ERR "asoc: interface %s hw params failed\n",
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100517 cpu_dai->name);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200518 goto interface_err;
519 }
520 }
521
522 if (platform->pcm_ops->hw_params) {
523 ret = platform->pcm_ops->hw_params(substream, params);
524 if (ret < 0) {
Mark Brown3ff3f642008-05-19 12:32:25 +0200525 printk(KERN_ERR "asoc: platform %s hw params failed\n",
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200526 platform->name);
527 goto platform_err;
528 }
529 }
530
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200531out:
532 mutex_unlock(&pcm_mutex);
533 return ret;
534
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200535platform_err:
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100536 if (cpu_dai->ops.hw_free)
537 cpu_dai->ops.hw_free(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200538
539interface_err:
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100540 if (codec_dai->ops.hw_free)
541 codec_dai->ops.hw_free(substream);
542
543codec_err:
Mark Brown3ff3f642008-05-19 12:32:25 +0200544 if (machine->ops && machine->ops->hw_free)
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100545 machine->ops->hw_free(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200546
547 mutex_unlock(&pcm_mutex);
548 return ret;
549}
550
551/*
552 * Free's resources allocated by hw_params, can be called multiple times
553 */
554static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
555{
556 struct snd_soc_pcm_runtime *rtd = substream->private_data;
557 struct snd_soc_device *socdev = rtd->socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100558 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200559 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100560 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
561 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200562 struct snd_soc_codec *codec = socdev->codec;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200563
564 mutex_lock(&pcm_mutex);
565
566 /* apply codec digital mute */
Liam Girdwood8c6529d2008-07-08 13:19:13 +0100567 if (!codec->active)
568 snd_soc_dai_digital_mute(codec_dai, 1);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200569
570 /* free any machine hw params */
571 if (machine->ops && machine->ops->hw_free)
572 machine->ops->hw_free(substream);
573
574 /* free any DMA resources */
575 if (platform->pcm_ops->hw_free)
576 platform->pcm_ops->hw_free(substream);
577
578 /* now free hw params for the DAI's */
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100579 if (codec_dai->ops.hw_free)
580 codec_dai->ops.hw_free(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200581
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100582 if (cpu_dai->ops.hw_free)
583 cpu_dai->ops.hw_free(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200584
585 mutex_unlock(&pcm_mutex);
586 return 0;
587}
588
589static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
590{
591 struct snd_soc_pcm_runtime *rtd = substream->private_data;
592 struct snd_soc_device *socdev = rtd->socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100593 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200594 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100595 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
596 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200597 int ret;
598
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100599 if (codec_dai->ops.trigger) {
600 ret = codec_dai->ops.trigger(substream, cmd);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200601 if (ret < 0)
602 return ret;
603 }
604
605 if (platform->pcm_ops->trigger) {
606 ret = platform->pcm_ops->trigger(substream, cmd);
607 if (ret < 0)
608 return ret;
609 }
610
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100611 if (cpu_dai->ops.trigger) {
612 ret = cpu_dai->ops.trigger(substream, cmd);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200613 if (ret < 0)
614 return ret;
615 }
616 return 0;
617}
618
619/* ASoC PCM operations */
620static struct snd_pcm_ops soc_pcm_ops = {
621 .open = soc_pcm_open,
622 .close = soc_codec_close,
623 .hw_params = soc_pcm_hw_params,
624 .hw_free = soc_pcm_hw_free,
625 .prepare = soc_pcm_prepare,
626 .trigger = soc_pcm_trigger,
627};
628
629#ifdef CONFIG_PM
630/* powers down audio subsystem for suspend */
631static int soc_suspend(struct platform_device *pdev, pm_message_t state)
632{
Mark Brown3ff3f642008-05-19 12:32:25 +0200633 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
634 struct snd_soc_machine *machine = socdev->machine;
635 struct snd_soc_platform *platform = socdev->platform;
636 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200637 struct snd_soc_codec *codec = socdev->codec;
638 int i;
639
Andy Green6ed25972008-06-13 16:24:05 +0100640 /* Due to the resume being scheduled into a workqueue we could
641 * suspend before that's finished - wait for it to complete.
642 */
643 snd_power_lock(codec->card);
644 snd_power_wait(codec->card, SNDRV_CTL_POWER_D0);
645 snd_power_unlock(codec->card);
646
647 /* we're going to block userspace touching us until resume completes */
648 snd_power_change_state(codec->card, SNDRV_CTL_POWER_D3hot);
649
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200650 /* mute any active DAC's */
Mark Brown3ff3f642008-05-19 12:32:25 +0200651 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100652 struct snd_soc_dai *dai = machine->dai_link[i].codec_dai;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100653 if (dai->dai_ops.digital_mute && dai->playback.active)
654 dai->dai_ops.digital_mute(dai, 1);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200655 }
656
Liam Girdwood4ccab3e2008-01-10 14:39:01 +0100657 /* suspend all pcms */
658 for (i = 0; i < machine->num_links; i++)
659 snd_pcm_suspend_all(machine->dai_link[i].pcm);
660
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200661 if (machine->suspend_pre)
662 machine->suspend_pre(pdev, state);
663
Mark Brown3ff3f642008-05-19 12:32:25 +0200664 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100665 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200666 if (cpu_dai->suspend && cpu_dai->type != SND_SOC_DAI_AC97)
667 cpu_dai->suspend(pdev, cpu_dai);
668 if (platform->suspend)
669 platform->suspend(pdev, cpu_dai);
670 }
671
672 /* close any waiting streams and save state */
Liam Girdwood965ac422007-01-31 14:14:57 +0100673 run_delayed_work(&socdev->delayed_work);
Mark Brown0be98982008-05-19 12:31:28 +0200674 codec->suspend_bias_level = codec->bias_level;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200675
Mark Brown3ff3f642008-05-19 12:32:25 +0200676 for (i = 0; i < codec->num_dai; i++) {
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200677 char *stream = codec->dai[i].playback.stream_name;
678 if (stream != NULL)
679 snd_soc_dapm_stream_event(codec, stream,
680 SND_SOC_DAPM_STREAM_SUSPEND);
681 stream = codec->dai[i].capture.stream_name;
682 if (stream != NULL)
683 snd_soc_dapm_stream_event(codec, stream,
684 SND_SOC_DAPM_STREAM_SUSPEND);
685 }
686
687 if (codec_dev->suspend)
688 codec_dev->suspend(pdev, state);
689
Mark Brown3ff3f642008-05-19 12:32:25 +0200690 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100691 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200692 if (cpu_dai->suspend && cpu_dai->type == SND_SOC_DAI_AC97)
693 cpu_dai->suspend(pdev, cpu_dai);
694 }
695
696 if (machine->suspend_post)
697 machine->suspend_post(pdev, state);
698
699 return 0;
700}
701
Andy Green6ed25972008-06-13 16:24:05 +0100702/* deferred resume work, so resume can complete before we finished
703 * setting our codec back up, which can be very slow on I2C
704 */
705static void soc_resume_deferred(struct work_struct *work)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200706{
Andy Green6ed25972008-06-13 16:24:05 +0100707 struct snd_soc_device *socdev = container_of(work,
708 struct snd_soc_device,
709 deferred_resume_work);
Mark Brown3ff3f642008-05-19 12:32:25 +0200710 struct snd_soc_machine *machine = socdev->machine;
711 struct snd_soc_platform *platform = socdev->platform;
712 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200713 struct snd_soc_codec *codec = socdev->codec;
Andy Green6ed25972008-06-13 16:24:05 +0100714 struct platform_device *pdev = to_platform_device(socdev->dev);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200715 int i;
716
Andy Green6ed25972008-06-13 16:24:05 +0100717 /* our power state is still SNDRV_CTL_POWER_D3hot from suspend time,
718 * so userspace apps are blocked from touching us
719 */
720
721 dev_info(socdev->dev, "starting resume work\n");
722
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200723 if (machine->resume_pre)
724 machine->resume_pre(pdev);
725
Mark Brown3ff3f642008-05-19 12:32:25 +0200726 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100727 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200728 if (cpu_dai->resume && cpu_dai->type == SND_SOC_DAI_AC97)
729 cpu_dai->resume(pdev, cpu_dai);
730 }
731
732 if (codec_dev->resume)
733 codec_dev->resume(pdev);
734
Mark Brown3ff3f642008-05-19 12:32:25 +0200735 for (i = 0; i < codec->num_dai; i++) {
736 char *stream = codec->dai[i].playback.stream_name;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200737 if (stream != NULL)
738 snd_soc_dapm_stream_event(codec, stream,
739 SND_SOC_DAPM_STREAM_RESUME);
740 stream = codec->dai[i].capture.stream_name;
741 if (stream != NULL)
742 snd_soc_dapm_stream_event(codec, stream,
743 SND_SOC_DAPM_STREAM_RESUME);
744 }
745
Mark Brown3ff3f642008-05-19 12:32:25 +0200746 /* unmute any active DACs */
747 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100748 struct snd_soc_dai *dai = machine->dai_link[i].codec_dai;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100749 if (dai->dai_ops.digital_mute && dai->playback.active)
750 dai->dai_ops.digital_mute(dai, 0);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200751 }
752
Mark Brown3ff3f642008-05-19 12:32:25 +0200753 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100754 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200755 if (cpu_dai->resume && cpu_dai->type != SND_SOC_DAI_AC97)
756 cpu_dai->resume(pdev, cpu_dai);
757 if (platform->resume)
758 platform->resume(pdev, cpu_dai);
759 }
760
761 if (machine->resume_post)
762 machine->resume_post(pdev);
763
Andy Green6ed25972008-06-13 16:24:05 +0100764 dev_info(socdev->dev, "resume work completed\n");
765
766 /* userspace can access us now we are back as we were before */
767 snd_power_change_state(codec->card, SNDRV_CTL_POWER_D0);
768}
769
770/* powers up audio subsystem after a suspend */
771static int soc_resume(struct platform_device *pdev)
772{
773 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
774
775 dev_info(socdev->dev, "scheduling resume work\n");
776
777 if (!schedule_work(&socdev->deferred_resume_work))
778 dev_err(socdev->dev, "work item may be lost\n");
779
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200780 return 0;
781}
782
783#else
784#define soc_suspend NULL
785#define soc_resume NULL
786#endif
787
788/* probes a new socdev */
789static int soc_probe(struct platform_device *pdev)
790{
791 int ret = 0, i;
792 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
793 struct snd_soc_machine *machine = socdev->machine;
794 struct snd_soc_platform *platform = socdev->platform;
795 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
796
797 if (machine->probe) {
798 ret = machine->probe(pdev);
Mark Brown3ff3f642008-05-19 12:32:25 +0200799 if (ret < 0)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200800 return ret;
801 }
802
803 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100804 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200805 if (cpu_dai->probe) {
Mark Brownbdb92872008-06-11 13:47:10 +0100806 ret = cpu_dai->probe(pdev, cpu_dai);
Mark Brown3ff3f642008-05-19 12:32:25 +0200807 if (ret < 0)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200808 goto cpu_dai_err;
809 }
810 }
811
812 if (codec_dev->probe) {
813 ret = codec_dev->probe(pdev);
Mark Brown3ff3f642008-05-19 12:32:25 +0200814 if (ret < 0)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200815 goto cpu_dai_err;
816 }
817
818 if (platform->probe) {
819 ret = platform->probe(pdev);
Mark Brown3ff3f642008-05-19 12:32:25 +0200820 if (ret < 0)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200821 goto platform_err;
822 }
823
824 /* DAPM stream work */
Andrew Morton4484bb22006-12-15 09:30:07 +0100825 INIT_DELAYED_WORK(&socdev->delayed_work, close_delayed_work);
Randy Dunlap1301a962008-06-17 19:19:34 +0100826#ifdef CONFIG_PM
Andy Green6ed25972008-06-13 16:24:05 +0100827 /* deferred resume work */
828 INIT_WORK(&socdev->deferred_resume_work, soc_resume_deferred);
Randy Dunlap1301a962008-06-17 19:19:34 +0100829#endif
Andy Green6ed25972008-06-13 16:24:05 +0100830
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200831 return 0;
832
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200833platform_err:
834 if (codec_dev->remove)
835 codec_dev->remove(pdev);
836
837cpu_dai_err:
Liam Girdwood18b9b3d2007-01-30 17:18:45 +0100838 for (i--; i >= 0; i--) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100839 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200840 if (cpu_dai->remove)
Mark Brownbdb92872008-06-11 13:47:10 +0100841 cpu_dai->remove(pdev, cpu_dai);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200842 }
843
844 if (machine->remove)
845 machine->remove(pdev);
846
847 return ret;
848}
849
850/* removes a socdev */
851static int soc_remove(struct platform_device *pdev)
852{
853 int i;
854 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
855 struct snd_soc_machine *machine = socdev->machine;
856 struct snd_soc_platform *platform = socdev->platform;
857 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
858
Liam Girdwood965ac422007-01-31 14:14:57 +0100859 run_delayed_work(&socdev->delayed_work);
860
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200861 if (platform->remove)
862 platform->remove(pdev);
863
864 if (codec_dev->remove)
865 codec_dev->remove(pdev);
866
867 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100868 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200869 if (cpu_dai->remove)
Mark Brownbdb92872008-06-11 13:47:10 +0100870 cpu_dai->remove(pdev, cpu_dai);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200871 }
872
873 if (machine->remove)
874 machine->remove(pdev);
875
876 return 0;
877}
878
879/* ASoC platform driver */
880static struct platform_driver soc_driver = {
881 .driver = {
882 .name = "soc-audio",
Kay Sievers8b45a202008-04-14 13:33:36 +0200883 .owner = THIS_MODULE,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200884 },
885 .probe = soc_probe,
886 .remove = soc_remove,
887 .suspend = soc_suspend,
888 .resume = soc_resume,
889};
890
891/* create a new pcm */
892static int soc_new_pcm(struct snd_soc_device *socdev,
893 struct snd_soc_dai_link *dai_link, int num)
894{
895 struct snd_soc_codec *codec = socdev->codec;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100896 struct snd_soc_dai *codec_dai = dai_link->codec_dai;
897 struct snd_soc_dai *cpu_dai = dai_link->cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200898 struct snd_soc_pcm_runtime *rtd;
899 struct snd_pcm *pcm;
900 char new_name[64];
901 int ret = 0, playback = 0, capture = 0;
902
903 rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL);
904 if (rtd == NULL)
905 return -ENOMEM;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100906
907 rtd->dai = dai_link;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200908 rtd->socdev = socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100909 codec_dai->codec = socdev->codec;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200910
911 /* check client and interface hw capabilities */
Mark Brown3ff3f642008-05-19 12:32:25 +0200912 sprintf(new_name, "%s %s-%s-%d", dai_link->stream_name, codec_dai->name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200913 get_dai_name(cpu_dai->type), num);
914
915 if (codec_dai->playback.channels_min)
916 playback = 1;
917 if (codec_dai->capture.channels_min)
918 capture = 1;
919
920 ret = snd_pcm_new(codec->card, new_name, codec->pcm_devs++, playback,
921 capture, &pcm);
922 if (ret < 0) {
Mark Brown3ff3f642008-05-19 12:32:25 +0200923 printk(KERN_ERR "asoc: can't create pcm for codec %s\n",
924 codec->name);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200925 kfree(rtd);
926 return ret;
927 }
928
Liam Girdwood4ccab3e2008-01-10 14:39:01 +0100929 dai_link->pcm = pcm;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200930 pcm->private_data = rtd;
931 soc_pcm_ops.mmap = socdev->platform->pcm_ops->mmap;
932 soc_pcm_ops.pointer = socdev->platform->pcm_ops->pointer;
933 soc_pcm_ops.ioctl = socdev->platform->pcm_ops->ioctl;
934 soc_pcm_ops.copy = socdev->platform->pcm_ops->copy;
935 soc_pcm_ops.silence = socdev->platform->pcm_ops->silence;
936 soc_pcm_ops.ack = socdev->platform->pcm_ops->ack;
937 soc_pcm_ops.page = socdev->platform->pcm_ops->page;
938
939 if (playback)
940 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops);
941
942 if (capture)
943 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops);
944
945 ret = socdev->platform->pcm_new(codec->card, codec_dai, pcm);
946 if (ret < 0) {
947 printk(KERN_ERR "asoc: platform pcm constructor failed\n");
948 kfree(rtd);
949 return ret;
950 }
951
952 pcm->private_free = socdev->platform->pcm_free;
953 printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name,
954 cpu_dai->name);
955 return ret;
956}
957
958/* codec register dump */
959static ssize_t codec_reg_show(struct device *dev,
960 struct device_attribute *attr, char *buf)
961{
962 struct snd_soc_device *devdata = dev_get_drvdata(dev);
963 struct snd_soc_codec *codec = devdata->codec;
964 int i, step = 1, count = 0;
965
966 if (!codec->reg_cache_size)
967 return 0;
968
969 if (codec->reg_cache_step)
970 step = codec->reg_cache_step;
971
972 count += sprintf(buf, "%s registers\n", codec->name);
Mark Brown58cd33c2008-07-29 11:42:25 +0100973 for (i = 0; i < codec->reg_cache_size; i += step) {
974 count += sprintf(buf + count, "%2x: ", i);
975 if (count >= PAGE_SIZE - 1)
976 break;
977
978 if (codec->display_register)
979 count += codec->display_register(codec, buf + count,
980 PAGE_SIZE - count, i);
981 else
982 count += snprintf(buf + count, PAGE_SIZE - count,
983 "%4x", codec->read(codec, i));
984
985 if (count >= PAGE_SIZE - 1)
986 break;
987
988 count += snprintf(buf + count, PAGE_SIZE - count, "\n");
989 if (count >= PAGE_SIZE - 1)
990 break;
991 }
992
993 /* Truncate count; min() would cause a warning */
994 if (count >= PAGE_SIZE)
995 count = PAGE_SIZE - 1;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200996
997 return count;
998}
999static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
1000
1001/**
1002 * snd_soc_new_ac97_codec - initailise AC97 device
1003 * @codec: audio codec
1004 * @ops: AC97 bus operations
1005 * @num: AC97 codec number
1006 *
1007 * Initialises AC97 codec resources for use by ad-hoc devices only.
1008 */
1009int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
1010 struct snd_ac97_bus_ops *ops, int num)
1011{
1012 mutex_lock(&codec->mutex);
1013
1014 codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL);
1015 if (codec->ac97 == NULL) {
1016 mutex_unlock(&codec->mutex);
1017 return -ENOMEM;
1018 }
1019
1020 codec->ac97->bus = kzalloc(sizeof(struct snd_ac97_bus), GFP_KERNEL);
1021 if (codec->ac97->bus == NULL) {
1022 kfree(codec->ac97);
1023 codec->ac97 = NULL;
1024 mutex_unlock(&codec->mutex);
1025 return -ENOMEM;
1026 }
1027
1028 codec->ac97->bus->ops = ops;
1029 codec->ac97->num = num;
1030 mutex_unlock(&codec->mutex);
1031 return 0;
1032}
1033EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);
1034
1035/**
1036 * snd_soc_free_ac97_codec - free AC97 codec device
1037 * @codec: audio codec
1038 *
1039 * Frees AC97 codec device resources.
1040 */
1041void snd_soc_free_ac97_codec(struct snd_soc_codec *codec)
1042{
1043 mutex_lock(&codec->mutex);
1044 kfree(codec->ac97->bus);
1045 kfree(codec->ac97);
1046 codec->ac97 = NULL;
1047 mutex_unlock(&codec->mutex);
1048}
1049EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec);
1050
1051/**
1052 * snd_soc_update_bits - update codec register bits
1053 * @codec: audio codec
1054 * @reg: codec register
1055 * @mask: register mask
1056 * @value: new value
1057 *
1058 * Writes new register value.
1059 *
1060 * Returns 1 for change else 0.
1061 */
1062int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
1063 unsigned short mask, unsigned short value)
1064{
1065 int change;
1066 unsigned short old, new;
1067
1068 mutex_lock(&io_mutex);
1069 old = snd_soc_read(codec, reg);
1070 new = (old & ~mask) | value;
1071 change = old != new;
1072 if (change)
1073 snd_soc_write(codec, reg, new);
1074
1075 mutex_unlock(&io_mutex);
1076 return change;
1077}
1078EXPORT_SYMBOL_GPL(snd_soc_update_bits);
1079
1080/**
1081 * snd_soc_test_bits - test register for change
1082 * @codec: audio codec
1083 * @reg: codec register
1084 * @mask: register mask
1085 * @value: new value
1086 *
1087 * Tests a register with a new value and checks if the new value is
1088 * different from the old value.
1089 *
1090 * Returns 1 for change else 0.
1091 */
1092int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
1093 unsigned short mask, unsigned short value)
1094{
1095 int change;
1096 unsigned short old, new;
1097
1098 mutex_lock(&io_mutex);
1099 old = snd_soc_read(codec, reg);
1100 new = (old & ~mask) | value;
1101 change = old != new;
1102 mutex_unlock(&io_mutex);
1103
1104 return change;
1105}
1106EXPORT_SYMBOL_GPL(snd_soc_test_bits);
1107
1108/**
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001109 * snd_soc_new_pcms - create new sound card and pcms
1110 * @socdev: the SoC audio device
1111 *
1112 * Create a new sound card based upon the codec and interface pcms.
1113 *
1114 * Returns 0 for success, else error.
1115 */
Liam Girdwoodbc7320c2007-02-01 12:26:07 +01001116int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001117{
1118 struct snd_soc_codec *codec = socdev->codec;
1119 struct snd_soc_machine *machine = socdev->machine;
1120 int ret = 0, i;
1121
1122 mutex_lock(&codec->mutex);
1123
1124 /* register a sound card */
1125 codec->card = snd_card_new(idx, xid, codec->owner, 0);
1126 if (!codec->card) {
1127 printk(KERN_ERR "asoc: can't create sound card for codec %s\n",
1128 codec->name);
1129 mutex_unlock(&codec->mutex);
1130 return -ENODEV;
1131 }
1132
1133 codec->card->dev = socdev->dev;
1134 codec->card->private_data = codec;
1135 strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver));
1136
1137 /* create the pcms */
Mark Brown3ff3f642008-05-19 12:32:25 +02001138 for (i = 0; i < machine->num_links; i++) {
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001139 ret = soc_new_pcm(socdev, &machine->dai_link[i], i);
1140 if (ret < 0) {
1141 printk(KERN_ERR "asoc: can't create pcm %s\n",
1142 machine->dai_link[i].stream_name);
1143 mutex_unlock(&codec->mutex);
1144 return ret;
1145 }
1146 }
1147
1148 mutex_unlock(&codec->mutex);
1149 return ret;
1150}
1151EXPORT_SYMBOL_GPL(snd_soc_new_pcms);
1152
1153/**
1154 * snd_soc_register_card - register sound card
1155 * @socdev: the SoC audio device
1156 *
1157 * Register a SoC sound card. Also registers an AC97 device if the
1158 * codec is AC97 for ad hoc devices.
1159 *
1160 * Returns 0 for success, else error.
1161 */
1162int snd_soc_register_card(struct snd_soc_device *socdev)
1163{
1164 struct snd_soc_codec *codec = socdev->codec;
1165 struct snd_soc_machine *machine = socdev->machine;
Liam Girdwood12e74f72006-10-16 21:19:48 +02001166 int ret = 0, i, ac97 = 0, err = 0;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001167
Mark Brown3ff3f642008-05-19 12:32:25 +02001168 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood12e74f72006-10-16 21:19:48 +02001169 if (socdev->machine->dai_link[i].init) {
1170 err = socdev->machine->dai_link[i].init(codec);
1171 if (err < 0) {
1172 printk(KERN_ERR "asoc: failed to init %s\n",
1173 socdev->machine->dai_link[i].stream_name);
1174 continue;
1175 }
1176 }
Mark Brown3ff3f642008-05-19 12:32:25 +02001177 if (socdev->machine->dai_link[i].codec_dai->type ==
Liam Girdwooda68660e2007-05-10 19:27:27 +02001178 SND_SOC_DAI_AC97_BUS)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001179 ac97 = 1;
1180 }
1181 snprintf(codec->card->shortname, sizeof(codec->card->shortname),
1182 "%s", machine->name);
1183 snprintf(codec->card->longname, sizeof(codec->card->longname),
1184 "%s (%s)", machine->name, codec->name);
1185
1186 ret = snd_card_register(codec->card);
1187 if (ret < 0) {
Mark Brown3ff3f642008-05-19 12:32:25 +02001188 printk(KERN_ERR "asoc: failed to register soundcard for %s\n",
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001189 codec->name);
Liam Girdwood12e74f72006-10-16 21:19:48 +02001190 goto out;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001191 }
1192
Mark Brown08c8efe2008-01-21 14:33:37 +01001193 mutex_lock(&codec->mutex);
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001194#ifdef CONFIG_SND_SOC_AC97_BUS
Liam Girdwood12e74f72006-10-16 21:19:48 +02001195 if (ac97) {
1196 ret = soc_ac97_dev_register(codec);
1197 if (ret < 0) {
1198 printk(KERN_ERR "asoc: AC97 device register failed\n");
1199 snd_card_free(codec->card);
Mark Brown08c8efe2008-01-21 14:33:37 +01001200 mutex_unlock(&codec->mutex);
Liam Girdwood12e74f72006-10-16 21:19:48 +02001201 goto out;
1202 }
1203 }
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001204#endif
1205
Liam Girdwood12e74f72006-10-16 21:19:48 +02001206 err = snd_soc_dapm_sys_add(socdev->dev);
1207 if (err < 0)
1208 printk(KERN_WARNING "asoc: failed to add dapm sysfs entries\n");
1209
1210 err = device_create_file(socdev->dev, &dev_attr_codec_reg);
1211 if (err < 0)
Mark Brown3ff3f642008-05-19 12:32:25 +02001212 printk(KERN_WARNING "asoc: failed to add codec sysfs files\n");
Mark Brown08c8efe2008-01-21 14:33:37 +01001213
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001214 mutex_unlock(&codec->mutex);
Mark Brown08c8efe2008-01-21 14:33:37 +01001215
1216out:
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001217 return ret;
1218}
1219EXPORT_SYMBOL_GPL(snd_soc_register_card);
1220
1221/**
1222 * snd_soc_free_pcms - free sound card and pcms
1223 * @socdev: the SoC audio device
1224 *
1225 * Frees sound card and pcms associated with the socdev.
1226 * Also unregister the codec if it is an AC97 device.
1227 */
1228void snd_soc_free_pcms(struct snd_soc_device *socdev)
1229{
1230 struct snd_soc_codec *codec = socdev->codec;
Liam Girdwooda68660e2007-05-10 19:27:27 +02001231#ifdef CONFIG_SND_SOC_AC97_BUS
Liam Girdwood3c4b2662008-07-07 16:07:17 +01001232 struct snd_soc_dai *codec_dai;
Liam Girdwooda68660e2007-05-10 19:27:27 +02001233 int i;
1234#endif
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001235
1236 mutex_lock(&codec->mutex);
1237#ifdef CONFIG_SND_SOC_AC97_BUS
Mark Brown3ff3f642008-05-19 12:32:25 +02001238 for (i = 0; i < codec->num_dai; i++) {
Liam Girdwooda68660e2007-05-10 19:27:27 +02001239 codec_dai = &codec->dai[i];
1240 if (codec_dai->type == SND_SOC_DAI_AC97_BUS && codec->ac97) {
1241 soc_ac97_dev_unregister(codec);
1242 goto free_card;
1243 }
1244 }
1245free_card:
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001246#endif
1247
1248 if (codec->card)
1249 snd_card_free(codec->card);
1250 device_remove_file(socdev->dev, &dev_attr_codec_reg);
1251 mutex_unlock(&codec->mutex);
1252}
1253EXPORT_SYMBOL_GPL(snd_soc_free_pcms);
1254
1255/**
1256 * snd_soc_set_runtime_hwparams - set the runtime hardware parameters
1257 * @substream: the pcm substream
1258 * @hw: the hardware parameters
1259 *
1260 * Sets the substream runtime hardware parameters.
1261 */
1262int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
1263 const struct snd_pcm_hardware *hw)
1264{
1265 struct snd_pcm_runtime *runtime = substream->runtime;
1266 runtime->hw.info = hw->info;
1267 runtime->hw.formats = hw->formats;
1268 runtime->hw.period_bytes_min = hw->period_bytes_min;
1269 runtime->hw.period_bytes_max = hw->period_bytes_max;
1270 runtime->hw.periods_min = hw->periods_min;
1271 runtime->hw.periods_max = hw->periods_max;
1272 runtime->hw.buffer_bytes_max = hw->buffer_bytes_max;
1273 runtime->hw.fifo_size = hw->fifo_size;
1274 return 0;
1275}
1276EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams);
1277
1278/**
1279 * snd_soc_cnew - create new control
1280 * @_template: control template
1281 * @data: control private data
1282 * @lnng_name: control long name
1283 *
1284 * Create a new mixer control from a template control.
1285 *
1286 * Returns 0 for success, else error.
1287 */
1288struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
1289 void *data, char *long_name)
1290{
1291 struct snd_kcontrol_new template;
1292
1293 memcpy(&template, _template, sizeof(template));
1294 if (long_name)
1295 template.name = long_name;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001296 template.index = 0;
1297
1298 return snd_ctl_new1(&template, data);
1299}
1300EXPORT_SYMBOL_GPL(snd_soc_cnew);
1301
1302/**
1303 * snd_soc_info_enum_double - enumerated double mixer info callback
1304 * @kcontrol: mixer control
1305 * @uinfo: control element information
1306 *
1307 * Callback to provide information about a double enumerated
1308 * mixer control.
1309 *
1310 * Returns 0 for success.
1311 */
1312int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
1313 struct snd_ctl_elem_info *uinfo)
1314{
1315 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1316
1317 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1318 uinfo->count = e->shift_l == e->shift_r ? 1 : 2;
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001319 uinfo->value.enumerated.items = e->max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001320
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001321 if (uinfo->value.enumerated.item > e->max - 1)
1322 uinfo->value.enumerated.item = e->max - 1;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001323 strcpy(uinfo->value.enumerated.name,
1324 e->texts[uinfo->value.enumerated.item]);
1325 return 0;
1326}
1327EXPORT_SYMBOL_GPL(snd_soc_info_enum_double);
1328
1329/**
1330 * snd_soc_get_enum_double - enumerated double mixer get callback
1331 * @kcontrol: mixer control
1332 * @uinfo: control element information
1333 *
1334 * Callback to get the value of a double enumerated mixer.
1335 *
1336 * Returns 0 for success.
1337 */
1338int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
1339 struct snd_ctl_elem_value *ucontrol)
1340{
1341 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1342 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1343 unsigned short val, bitmask;
1344
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001345 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001346 ;
1347 val = snd_soc_read(codec, e->reg);
Mark Brown3ff3f642008-05-19 12:32:25 +02001348 ucontrol->value.enumerated.item[0]
1349 = (val >> e->shift_l) & (bitmask - 1);
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001350 if (e->shift_l != e->shift_r)
1351 ucontrol->value.enumerated.item[1] =
1352 (val >> e->shift_r) & (bitmask - 1);
1353
1354 return 0;
1355}
1356EXPORT_SYMBOL_GPL(snd_soc_get_enum_double);
1357
1358/**
1359 * snd_soc_put_enum_double - enumerated double mixer put callback
1360 * @kcontrol: mixer control
1361 * @uinfo: control element information
1362 *
1363 * Callback to set the value of a double enumerated mixer.
1364 *
1365 * Returns 0 for success.
1366 */
1367int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
1368 struct snd_ctl_elem_value *ucontrol)
1369{
1370 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1371 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1372 unsigned short val;
1373 unsigned short mask, bitmask;
1374
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001375 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001376 ;
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001377 if (ucontrol->value.enumerated.item[0] > e->max - 1)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001378 return -EINVAL;
1379 val = ucontrol->value.enumerated.item[0] << e->shift_l;
1380 mask = (bitmask - 1) << e->shift_l;
1381 if (e->shift_l != e->shift_r) {
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001382 if (ucontrol->value.enumerated.item[1] > e->max - 1)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001383 return -EINVAL;
1384 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
1385 mask |= (bitmask - 1) << e->shift_r;
1386 }
1387
1388 return snd_soc_update_bits(codec, e->reg, mask, val);
1389}
1390EXPORT_SYMBOL_GPL(snd_soc_put_enum_double);
1391
1392/**
1393 * snd_soc_info_enum_ext - external enumerated single mixer info callback
1394 * @kcontrol: mixer control
1395 * @uinfo: control element information
1396 *
1397 * Callback to provide information about an external enumerated
1398 * single mixer.
1399 *
1400 * Returns 0 for success.
1401 */
1402int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
1403 struct snd_ctl_elem_info *uinfo)
1404{
1405 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1406
1407 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1408 uinfo->count = 1;
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001409 uinfo->value.enumerated.items = e->max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001410
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001411 if (uinfo->value.enumerated.item > e->max - 1)
1412 uinfo->value.enumerated.item = e->max - 1;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001413 strcpy(uinfo->value.enumerated.name,
1414 e->texts[uinfo->value.enumerated.item]);
1415 return 0;
1416}
1417EXPORT_SYMBOL_GPL(snd_soc_info_enum_ext);
1418
1419/**
1420 * snd_soc_info_volsw_ext - external single mixer info callback
1421 * @kcontrol: mixer control
1422 * @uinfo: control element information
1423 *
1424 * Callback to provide information about a single external mixer control.
1425 *
1426 * Returns 0 for success.
1427 */
1428int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
1429 struct snd_ctl_elem_info *uinfo)
1430{
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001431 int max = kcontrol->private_value;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001432
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001433 if (max == 1)
1434 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1435 else
1436 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1437
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001438 uinfo->count = 1;
1439 uinfo->value.integer.min = 0;
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001440 uinfo->value.integer.max = max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001441 return 0;
1442}
1443EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext);
1444
1445/**
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001446 * snd_soc_info_volsw - single mixer info callback
1447 * @kcontrol: mixer control
1448 * @uinfo: control element information
1449 *
1450 * Callback to provide information about a single mixer control.
1451 *
1452 * Returns 0 for success.
1453 */
1454int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
1455 struct snd_ctl_elem_info *uinfo)
1456{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001457 struct soc_mixer_control *mc =
1458 (struct soc_mixer_control *)kcontrol->private_value;
1459 int max = mc->max;
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001460 unsigned int shift = mc->min;
1461 unsigned int rshift = mc->rshift;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001462
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001463 if (max == 1)
1464 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1465 else
1466 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1467
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001468 uinfo->count = shift == rshift ? 1 : 2;
1469 uinfo->value.integer.min = 0;
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001470 uinfo->value.integer.max = max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001471 return 0;
1472}
1473EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
1474
1475/**
1476 * snd_soc_get_volsw - single mixer get callback
1477 * @kcontrol: mixer control
1478 * @uinfo: control element information
1479 *
1480 * Callback to get the value of a single mixer control.
1481 *
1482 * Returns 0 for success.
1483 */
1484int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
1485 struct snd_ctl_elem_value *ucontrol)
1486{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001487 struct soc_mixer_control *mc =
1488 (struct soc_mixer_control *)kcontrol->private_value;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001489 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001490 unsigned int reg = mc->reg;
1491 unsigned int shift = mc->shift;
1492 unsigned int rshift = mc->rshift;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001493 int max = mc->max;
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001494 unsigned int mask = (1 << fls(max)) - 1;
1495 unsigned int invert = mc->invert;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001496
1497 ucontrol->value.integer.value[0] =
1498 (snd_soc_read(codec, reg) >> shift) & mask;
1499 if (shift != rshift)
1500 ucontrol->value.integer.value[1] =
1501 (snd_soc_read(codec, reg) >> rshift) & mask;
1502 if (invert) {
1503 ucontrol->value.integer.value[0] =
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001504 max - ucontrol->value.integer.value[0];
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001505 if (shift != rshift)
1506 ucontrol->value.integer.value[1] =
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001507 max - ucontrol->value.integer.value[1];
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001508 }
1509
1510 return 0;
1511}
1512EXPORT_SYMBOL_GPL(snd_soc_get_volsw);
1513
1514/**
1515 * snd_soc_put_volsw - single mixer put callback
1516 * @kcontrol: mixer control
1517 * @uinfo: control element information
1518 *
1519 * Callback to set the value of a single mixer control.
1520 *
1521 * Returns 0 for success.
1522 */
1523int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
1524 struct snd_ctl_elem_value *ucontrol)
1525{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001526 struct soc_mixer_control *mc =
1527 (struct soc_mixer_control *)kcontrol->private_value;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001528 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001529 unsigned int reg = mc->reg;
1530 unsigned int shift = mc->shift;
1531 unsigned int rshift = mc->rshift;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001532 int max = mc->max;
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001533 unsigned int mask = (1 << fls(max)) - 1;
1534 unsigned int invert = mc->invert;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001535 unsigned short val, val2, val_mask;
1536
1537 val = (ucontrol->value.integer.value[0] & mask);
1538 if (invert)
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001539 val = max - val;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001540 val_mask = mask << shift;
1541 val = val << shift;
1542 if (shift != rshift) {
1543 val2 = (ucontrol->value.integer.value[1] & mask);
1544 if (invert)
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001545 val2 = max - val2;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001546 val_mask |= mask << rshift;
1547 val |= val2 << rshift;
1548 }
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001549 return snd_soc_update_bits(codec, reg, val_mask, val);
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001550}
1551EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
1552
1553/**
1554 * snd_soc_info_volsw_2r - double mixer info callback
1555 * @kcontrol: mixer control
1556 * @uinfo: control element information
1557 *
1558 * Callback to provide information about a double mixer control that
1559 * spans 2 codec registers.
1560 *
1561 * Returns 0 for success.
1562 */
1563int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
1564 struct snd_ctl_elem_info *uinfo)
1565{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001566 struct soc_mixer_control *mc =
1567 (struct soc_mixer_control *)kcontrol->private_value;
1568 int max = mc->max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001569
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001570 if (max == 1)
1571 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1572 else
1573 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1574
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001575 uinfo->count = 2;
1576 uinfo->value.integer.min = 0;
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001577 uinfo->value.integer.max = max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001578 return 0;
1579}
1580EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r);
1581
1582/**
1583 * snd_soc_get_volsw_2r - double mixer get callback
1584 * @kcontrol: mixer control
1585 * @uinfo: control element information
1586 *
1587 * Callback to get the value of a double mixer control that spans 2 registers.
1588 *
1589 * Returns 0 for success.
1590 */
1591int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
1592 struct snd_ctl_elem_value *ucontrol)
1593{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001594 struct soc_mixer_control *mc =
1595 (struct soc_mixer_control *)kcontrol->private_value;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001596 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001597 unsigned int reg = mc->reg;
1598 unsigned int reg2 = mc->rreg;
1599 unsigned int shift = mc->shift;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001600 int max = mc->max;
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001601 unsigned int mask = (1<<fls(max))-1;
1602 unsigned int invert = mc->invert;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001603
1604 ucontrol->value.integer.value[0] =
1605 (snd_soc_read(codec, reg) >> shift) & mask;
1606 ucontrol->value.integer.value[1] =
1607 (snd_soc_read(codec, reg2) >> shift) & mask;
1608 if (invert) {
1609 ucontrol->value.integer.value[0] =
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001610 max - ucontrol->value.integer.value[0];
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001611 ucontrol->value.integer.value[1] =
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001612 max - ucontrol->value.integer.value[1];
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001613 }
1614
1615 return 0;
1616}
1617EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r);
1618
1619/**
1620 * snd_soc_put_volsw_2r - double mixer set callback
1621 * @kcontrol: mixer control
1622 * @uinfo: control element information
1623 *
1624 * Callback to set the value of a double mixer control that spans 2 registers.
1625 *
1626 * Returns 0 for success.
1627 */
1628int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
1629 struct snd_ctl_elem_value *ucontrol)
1630{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001631 struct soc_mixer_control *mc =
1632 (struct soc_mixer_control *)kcontrol->private_value;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001633 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001634 unsigned int reg = mc->reg;
1635 unsigned int reg2 = mc->rreg;
1636 unsigned int shift = mc->shift;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001637 int max = mc->max;
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001638 unsigned int mask = (1 << fls(max)) - 1;
1639 unsigned int invert = mc->invert;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001640 int err;
1641 unsigned short val, val2, val_mask;
1642
1643 val_mask = mask << shift;
1644 val = (ucontrol->value.integer.value[0] & mask);
1645 val2 = (ucontrol->value.integer.value[1] & mask);
1646
1647 if (invert) {
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001648 val = max - val;
1649 val2 = max - val2;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001650 }
1651
1652 val = val << shift;
1653 val2 = val2 << shift;
1654
Mark Brown3ff3f642008-05-19 12:32:25 +02001655 err = snd_soc_update_bits(codec, reg, val_mask, val);
1656 if (err < 0)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001657 return err;
1658
1659 err = snd_soc_update_bits(codec, reg2, val_mask, val2);
1660 return err;
1661}
1662EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r);
1663
Mark Browne13ac2e2008-05-28 17:58:05 +01001664/**
1665 * snd_soc_info_volsw_s8 - signed mixer info callback
1666 * @kcontrol: mixer control
1667 * @uinfo: control element information
1668 *
1669 * Callback to provide information about a signed mixer control.
1670 *
1671 * Returns 0 for success.
1672 */
1673int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
1674 struct snd_ctl_elem_info *uinfo)
1675{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001676 struct soc_mixer_control *mc =
1677 (struct soc_mixer_control *)kcontrol->private_value;
1678 int max = mc->max;
1679 int min = mc->min;
Mark Browne13ac2e2008-05-28 17:58:05 +01001680
1681 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1682 uinfo->count = 2;
1683 uinfo->value.integer.min = 0;
1684 uinfo->value.integer.max = max-min;
1685 return 0;
1686}
1687EXPORT_SYMBOL_GPL(snd_soc_info_volsw_s8);
1688
1689/**
1690 * snd_soc_get_volsw_s8 - signed mixer get callback
1691 * @kcontrol: mixer control
1692 * @uinfo: control element information
1693 *
1694 * Callback to get the value of a signed mixer control.
1695 *
1696 * Returns 0 for success.
1697 */
1698int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
1699 struct snd_ctl_elem_value *ucontrol)
1700{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001701 struct soc_mixer_control *mc =
1702 (struct soc_mixer_control *)kcontrol->private_value;
Mark Browne13ac2e2008-05-28 17:58:05 +01001703 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001704 unsigned int reg = mc->reg;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001705 int min = mc->min;
Mark Browne13ac2e2008-05-28 17:58:05 +01001706 int val = snd_soc_read(codec, reg);
1707
1708 ucontrol->value.integer.value[0] =
1709 ((signed char)(val & 0xff))-min;
1710 ucontrol->value.integer.value[1] =
1711 ((signed char)((val >> 8) & 0xff))-min;
1712 return 0;
1713}
1714EXPORT_SYMBOL_GPL(snd_soc_get_volsw_s8);
1715
1716/**
1717 * snd_soc_put_volsw_sgn - signed mixer put callback
1718 * @kcontrol: mixer control
1719 * @uinfo: control element information
1720 *
1721 * Callback to set the value of a signed mixer control.
1722 *
1723 * Returns 0 for success.
1724 */
1725int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
1726 struct snd_ctl_elem_value *ucontrol)
1727{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001728 struct soc_mixer_control *mc =
1729 (struct soc_mixer_control *)kcontrol->private_value;
Mark Browne13ac2e2008-05-28 17:58:05 +01001730 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001731 unsigned int reg = mc->reg;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001732 int min = mc->min;
Mark Browne13ac2e2008-05-28 17:58:05 +01001733 unsigned short val;
1734
1735 val = (ucontrol->value.integer.value[0]+min) & 0xff;
1736 val |= ((ucontrol->value.integer.value[1]+min) & 0xff) << 8;
1737
1738 return snd_soc_update_bits(codec, reg, 0xffff, val);
1739}
1740EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8);
1741
Liam Girdwood8c6529d2008-07-08 13:19:13 +01001742/**
1743 * snd_soc_dai_set_sysclk - configure DAI system or master clock.
1744 * @dai: DAI
1745 * @clk_id: DAI specific clock ID
1746 * @freq: new clock frequency in Hz
1747 * @dir: new clock direction - input/output.
1748 *
1749 * Configures the DAI master (MCLK) or system (SYSCLK) clocking.
1750 */
1751int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
1752 unsigned int freq, int dir)
1753{
1754 if (dai->dai_ops.set_sysclk)
1755 return dai->dai_ops.set_sysclk(dai, clk_id, freq, dir);
1756 else
1757 return -EINVAL;
1758}
1759EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
1760
1761/**
1762 * snd_soc_dai_set_clkdiv - configure DAI clock dividers.
1763 * @dai: DAI
1764 * @clk_id: DAI specific clock divider ID
1765 * @div: new clock divisor.
1766 *
1767 * Configures the clock dividers. This is used to derive the best DAI bit and
1768 * frame clocks from the system or master clock. It's best to set the DAI bit
1769 * and frame clocks as low as possible to save system power.
1770 */
1771int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
1772 int div_id, int div)
1773{
1774 if (dai->dai_ops.set_clkdiv)
1775 return dai->dai_ops.set_clkdiv(dai, div_id, div);
1776 else
1777 return -EINVAL;
1778}
1779EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv);
1780
1781/**
1782 * snd_soc_dai_set_pll - configure DAI PLL.
1783 * @dai: DAI
1784 * @pll_id: DAI specific PLL ID
1785 * @freq_in: PLL input clock frequency in Hz
1786 * @freq_out: requested PLL output clock frequency in Hz
1787 *
1788 * Configures and enables PLL to generate output clock based on input clock.
1789 */
1790int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
1791 int pll_id, unsigned int freq_in, unsigned int freq_out)
1792{
1793 if (dai->dai_ops.set_pll)
1794 return dai->dai_ops.set_pll(dai, pll_id, freq_in, freq_out);
1795 else
1796 return -EINVAL;
1797}
1798EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll);
1799
1800/**
1801 * snd_soc_dai_set_fmt - configure DAI hardware audio format.
1802 * @dai: DAI
1803 * @clk_id: DAI specific clock ID
1804 * @fmt: SND_SOC_DAIFMT_ format value.
1805 *
1806 * Configures the DAI hardware format and clocking.
1807 */
1808int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
1809{
1810 if (dai->dai_ops.set_fmt)
1811 return dai->dai_ops.set_fmt(dai, fmt);
1812 else
1813 return -EINVAL;
1814}
1815EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
1816
1817/**
1818 * snd_soc_dai_set_tdm_slot - configure DAI TDM.
1819 * @dai: DAI
1820 * @mask: DAI specific mask representing used slots.
1821 * @slots: Number of slots in use.
1822 *
1823 * Configures a DAI for TDM operation. Both mask and slots are codec and DAI
1824 * specific.
1825 */
1826int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
1827 unsigned int mask, int slots)
1828{
1829 if (dai->dai_ops.set_sysclk)
1830 return dai->dai_ops.set_tdm_slot(dai, mask, slots);
1831 else
1832 return -EINVAL;
1833}
1834EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot);
1835
1836/**
1837 * snd_soc_dai_set_tristate - configure DAI system or master clock.
1838 * @dai: DAI
1839 * @tristate: tristate enable
1840 *
1841 * Tristates the DAI so that others can use it.
1842 */
1843int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
1844{
1845 if (dai->dai_ops.set_sysclk)
1846 return dai->dai_ops.set_tristate(dai, tristate);
1847 else
1848 return -EINVAL;
1849}
1850EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate);
1851
1852/**
1853 * snd_soc_dai_digital_mute - configure DAI system or master clock.
1854 * @dai: DAI
1855 * @mute: mute enable
1856 *
1857 * Mutes the DAI DAC.
1858 */
1859int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute)
1860{
1861 if (dai->dai_ops.digital_mute)
1862 return dai->dai_ops.digital_mute(dai, mute);
1863 else
1864 return -EINVAL;
1865}
1866EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);
1867
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001868static int __devinit snd_soc_init(void)
1869{
1870 printk(KERN_INFO "ASoC version %s\n", SND_SOC_VERSION);
1871 return platform_driver_register(&soc_driver);
1872}
1873
1874static void snd_soc_exit(void)
1875{
Mark Brown3ff3f642008-05-19 12:32:25 +02001876 platform_driver_unregister(&soc_driver);
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001877}
1878
1879module_init(snd_soc_init);
1880module_exit(snd_soc_exit);
1881
1882/* Module information */
1883MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
1884MODULE_DESCRIPTION("ALSA SoC Core");
1885MODULE_LICENSE("GPL");
Kay Sievers8b45a202008-04-14 13:33:36 +02001886MODULE_ALIAS("platform:soc-audio");