blob: 462e635dfc74bc084f2c140480c4e6fe8e8cd7cc [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 *
Liam Girdwoodd3311242008-10-12 13:17:36 +01007 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
Liam Girdwood0664d882006-12-18 14:39:02 +01008 * with code, comments and ideas from :-
9 * Richard Purdie <richard@openedhand.com>
Frank Mandarinodb2a4162006-10-06 18:31:09 +020010 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
Frank Mandarinodb2a4162006-10-06 18:31:09 +020016 * TODO:
17 * o Add hw rules to enforce rates, etc.
18 * o More testing with other codecs/machines.
19 * o Add more codecs and platforms to ensure good API coverage.
20 * o Support TDM on PCM and I2S
21 */
22
23#include <linux/module.h>
24#include <linux/moduleparam.h>
25#include <linux/init.h>
26#include <linux/delay.h>
27#include <linux/pm.h>
28#include <linux/bitops.h>
29#include <linux/platform_device.h>
Frank Mandarinodb2a4162006-10-06 18:31:09 +020030#include <sound/core.h>
31#include <sound/pcm.h>
32#include <sound/pcm_params.h>
33#include <sound/soc.h>
34#include <sound/soc-dapm.h>
35#include <sound/initval.h>
36
37/* debug */
38#define SOC_DEBUG 0
39#if SOC_DEBUG
40#define dbg(format, arg...) printk(format, ## arg)
41#else
42#define dbg(format, arg...)
43#endif
Liam Girdwooda71a4682006-10-19 20:35:56 +020044
Frank Mandarinodb2a4162006-10-06 18:31:09 +020045static DEFINE_MUTEX(pcm_mutex);
46static DEFINE_MUTEX(io_mutex);
Frank Mandarinodb2a4162006-10-06 18:31:09 +020047static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq);
48
Frank Mandarinodb2a4162006-10-06 18:31:09 +020049/*
50 * This is a timeout to do a DAPM powerdown after a stream is closed().
51 * It can be used to eliminate pops between different playback streams, e.g.
52 * between two audio tracks.
53 */
54static int pmdown_time = 5000;
55module_param(pmdown_time, int, 0);
56MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
57
Liam Girdwood965ac422007-01-31 14:14:57 +010058/*
59 * This function forces any delayed work to be queued and run.
60 */
61static int run_delayed_work(struct delayed_work *dwork)
62{
63 int ret;
64
65 /* cancel any work waiting to be queued. */
66 ret = cancel_delayed_work(dwork);
67
68 /* if there was any work waiting then we run it now and
69 * wait for it's completion */
70 if (ret) {
71 schedule_delayed_work(dwork, 0);
72 flush_scheduled_work();
73 }
74 return ret;
75}
76
Frank Mandarinodb2a4162006-10-06 18:31:09 +020077#ifdef CONFIG_SND_SOC_AC97_BUS
78/* unregister ac97 codec */
79static int soc_ac97_dev_unregister(struct snd_soc_codec *codec)
80{
81 if (codec->ac97->dev.bus)
82 device_unregister(&codec->ac97->dev);
83 return 0;
84}
85
86/* stop no dev release warning */
87static void soc_ac97_device_release(struct device *dev){}
88
89/* register ac97 codec to bus */
90static int soc_ac97_dev_register(struct snd_soc_codec *codec)
91{
92 int err;
93
94 codec->ac97->dev.bus = &ac97_bus_type;
95 codec->ac97->dev.parent = NULL;
96 codec->ac97->dev.release = soc_ac97_device_release;
97
98 snprintf(codec->ac97->dev.bus_id, BUS_ID_SIZE, "%d-%d:%s",
99 codec->card->number, 0, codec->name);
100 err = device_register(&codec->ac97->dev);
101 if (err < 0) {
102 snd_printk(KERN_ERR "Can't register ac97 bus\n");
103 codec->ac97->dev.bus = NULL;
104 return err;
105 }
106 return 0;
107}
108#endif
109
Mark Brown3ff3f642008-05-19 12:32:25 +0200110static inline const char *get_dai_name(int type)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200111{
Mark Brown3ff3f642008-05-19 12:32:25 +0200112 switch (type) {
Liam Girdwooda68660e2007-05-10 19:27:27 +0200113 case SND_SOC_DAI_AC97_BUS:
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200114 case SND_SOC_DAI_AC97:
115 return "AC97";
116 case SND_SOC_DAI_I2S:
117 return "I2S";
118 case SND_SOC_DAI_PCM:
119 return "PCM";
120 }
121 return NULL;
122}
123
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200124/*
125 * Called by ALSA when a PCM substream is opened, the runtime->hw record is
126 * then initialized and any private data can be allocated. This also calls
127 * startup for the cpu DAI, platform, machine and codec DAI.
128 */
129static int soc_pcm_open(struct snd_pcm_substream *substream)
130{
131 struct snd_soc_pcm_runtime *rtd = substream->private_data;
132 struct snd_soc_device *socdev = rtd->socdev;
133 struct snd_pcm_runtime *runtime = substream->runtime;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100134 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200135 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100136 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
137 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200138 int ret = 0;
139
140 mutex_lock(&pcm_mutex);
141
142 /* startup the audio subsystem */
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100143 if (cpu_dai->ops.startup) {
144 ret = cpu_dai->ops.startup(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200145 if (ret < 0) {
146 printk(KERN_ERR "asoc: can't open interface %s\n",
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100147 cpu_dai->name);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200148 goto out;
149 }
150 }
151
152 if (platform->pcm_ops->open) {
153 ret = platform->pcm_ops->open(substream);
154 if (ret < 0) {
155 printk(KERN_ERR "asoc: can't open platform %s\n", platform->name);
156 goto platform_err;
157 }
158 }
159
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100160 if (codec_dai->ops.startup) {
161 ret = codec_dai->ops.startup(substream);
162 if (ret < 0) {
163 printk(KERN_ERR "asoc: can't open codec %s\n",
164 codec_dai->name);
165 goto codec_dai_err;
166 }
167 }
168
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200169 if (machine->ops && machine->ops->startup) {
170 ret = machine->ops->startup(substream);
171 if (ret < 0) {
172 printk(KERN_ERR "asoc: %s startup failed\n", machine->name);
173 goto machine_err;
174 }
175 }
176
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200177 /* Check that the codec and cpu DAI's are compatible */
178 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
179 runtime->hw.rate_min =
Mark Brown3ff3f642008-05-19 12:32:25 +0200180 max(codec_dai->playback.rate_min,
181 cpu_dai->playback.rate_min);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200182 runtime->hw.rate_max =
Mark Brown3ff3f642008-05-19 12:32:25 +0200183 min(codec_dai->playback.rate_max,
184 cpu_dai->playback.rate_max);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200185 runtime->hw.channels_min =
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100186 max(codec_dai->playback.channels_min,
187 cpu_dai->playback.channels_min);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200188 runtime->hw.channels_max =
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100189 min(codec_dai->playback.channels_max,
190 cpu_dai->playback.channels_max);
191 runtime->hw.formats =
192 codec_dai->playback.formats & cpu_dai->playback.formats;
193 runtime->hw.rates =
194 codec_dai->playback.rates & cpu_dai->playback.rates;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200195 } else {
196 runtime->hw.rate_min =
Mark Brown3ff3f642008-05-19 12:32:25 +0200197 max(codec_dai->capture.rate_min,
198 cpu_dai->capture.rate_min);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200199 runtime->hw.rate_max =
Mark Brown3ff3f642008-05-19 12:32:25 +0200200 min(codec_dai->capture.rate_max,
201 cpu_dai->capture.rate_max);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200202 runtime->hw.channels_min =
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100203 max(codec_dai->capture.channels_min,
204 cpu_dai->capture.channels_min);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200205 runtime->hw.channels_max =
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100206 min(codec_dai->capture.channels_max,
207 cpu_dai->capture.channels_max);
208 runtime->hw.formats =
209 codec_dai->capture.formats & cpu_dai->capture.formats;
210 runtime->hw.rates =
211 codec_dai->capture.rates & cpu_dai->capture.rates;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200212 }
213
214 snd_pcm_limit_hw_rates(runtime);
215 if (!runtime->hw.rates) {
216 printk(KERN_ERR "asoc: %s <-> %s No matching rates\n",
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100217 codec_dai->name, cpu_dai->name);
218 goto machine_err;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200219 }
220 if (!runtime->hw.formats) {
221 printk(KERN_ERR "asoc: %s <-> %s No matching formats\n",
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100222 codec_dai->name, cpu_dai->name);
223 goto machine_err;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200224 }
225 if (!runtime->hw.channels_min || !runtime->hw.channels_max) {
226 printk(KERN_ERR "asoc: %s <-> %s No matching channels\n",
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100227 codec_dai->name, cpu_dai->name);
228 goto machine_err;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200229 }
230
Mark Brown3ff3f642008-05-19 12:32:25 +0200231 dbg("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name);
Liam Girdwoodb5c5fd22006-10-13 19:13:41 +0200232 dbg("asoc: rate mask 0x%x\n", runtime->hw.rates);
233 dbg("asoc: min ch %d max ch %d\n", runtime->hw.channels_min,
234 runtime->hw.channels_max);
235 dbg("asoc: min rate %d max rate %d\n", runtime->hw.rate_min,
236 runtime->hw.rate_max);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200237
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200238 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100239 cpu_dai->playback.active = codec_dai->playback.active = 1;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200240 else
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100241 cpu_dai->capture.active = codec_dai->capture.active = 1;
242 cpu_dai->active = codec_dai->active = 1;
243 cpu_dai->runtime = runtime;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200244 socdev->codec->active++;
245 mutex_unlock(&pcm_mutex);
246 return 0;
247
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100248machine_err:
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200249 if (machine->ops && machine->ops->shutdown)
250 machine->ops->shutdown(substream);
251
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100252codec_dai_err:
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200253 if (platform->pcm_ops->close)
254 platform->pcm_ops->close(substream);
255
256platform_err:
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100257 if (cpu_dai->ops.shutdown)
258 cpu_dai->ops.shutdown(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200259out:
260 mutex_unlock(&pcm_mutex);
261 return ret;
262}
263
264/*
Robert P. J. Day3a4fa0a2007-10-19 23:10:43 +0200265 * Power down the audio subsystem pmdown_time msecs after close is called.
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200266 * This is to ensure there are no pops or clicks in between any music tracks
267 * due to DAPM power cycling.
268 */
Andrew Morton4484bb22006-12-15 09:30:07 +0100269static void close_delayed_work(struct work_struct *work)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200270{
Andrew Morton4484bb22006-12-15 09:30:07 +0100271 struct snd_soc_device *socdev =
272 container_of(work, struct snd_soc_device, delayed_work.work);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200273 struct snd_soc_codec *codec = socdev->codec;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100274 struct snd_soc_dai *codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200275 int i;
276
277 mutex_lock(&pcm_mutex);
Mark Brown3ff3f642008-05-19 12:32:25 +0200278 for (i = 0; i < codec->num_dai; i++) {
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200279 codec_dai = &codec->dai[i];
280
281 dbg("pop wq checking: %s status: %s waiting: %s\n",
282 codec_dai->playback.stream_name,
283 codec_dai->playback.active ? "active" : "inactive",
284 codec_dai->pop_wait ? "yes" : "no");
285
286 /* are we waiting on this codec DAI stream */
287 if (codec_dai->pop_wait == 1) {
288
Mark Brown0be98982008-05-19 12:31:28 +0200289 /* Reduce power if no longer active */
Liam Girdwood3c1c47e2008-01-10 14:38:24 +0100290 if (codec->active == 0) {
291 dbg("pop wq D1 %s %s\n", codec->name,
292 codec_dai->playback.stream_name);
Mark Brown0be98982008-05-19 12:31:28 +0200293 snd_soc_dapm_set_bias_level(socdev,
294 SND_SOC_BIAS_PREPARE);
Liam Girdwood3c1c47e2008-01-10 14:38:24 +0100295 }
296
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200297 codec_dai->pop_wait = 0;
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100298 snd_soc_dapm_stream_event(codec,
299 codec_dai->playback.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200300 SND_SOC_DAPM_STREAM_STOP);
301
Mark Brown0be98982008-05-19 12:31:28 +0200302 /* Fall into standby if no longer active */
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200303 if (codec->active == 0) {
304 dbg("pop wq D3 %s %s\n", codec->name,
305 codec_dai->playback.stream_name);
Mark Brown0be98982008-05-19 12:31:28 +0200306 snd_soc_dapm_set_bias_level(socdev,
307 SND_SOC_BIAS_STANDBY);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200308 }
309 }
310 }
311 mutex_unlock(&pcm_mutex);
312}
313
314/*
315 * Called by ALSA when a PCM substream is closed. Private data can be
316 * freed here. The cpu DAI, codec DAI, machine and platform are also
317 * shutdown.
318 */
319static int soc_codec_close(struct snd_pcm_substream *substream)
320{
321 struct snd_soc_pcm_runtime *rtd = substream->private_data;
322 struct snd_soc_device *socdev = rtd->socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100323 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200324 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100325 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
326 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200327 struct snd_soc_codec *codec = socdev->codec;
328
329 mutex_lock(&pcm_mutex);
330
331 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100332 cpu_dai->playback.active = codec_dai->playback.active = 0;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200333 else
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100334 cpu_dai->capture.active = codec_dai->capture.active = 0;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200335
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100336 if (codec_dai->playback.active == 0 &&
337 codec_dai->capture.active == 0) {
338 cpu_dai->active = codec_dai->active = 0;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200339 }
340 codec->active--;
341
Mark Brown6010b2d2008-09-06 18:33:24 +0100342 /* Muting the DAC suppresses artifacts caused during digital
343 * shutdown, for example from stopping clocks.
344 */
345 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
346 snd_soc_dai_digital_mute(codec_dai, 1);
347
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100348 if (cpu_dai->ops.shutdown)
349 cpu_dai->ops.shutdown(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200350
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100351 if (codec_dai->ops.shutdown)
352 codec_dai->ops.shutdown(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200353
354 if (machine->ops && machine->ops->shutdown)
355 machine->ops->shutdown(substream);
356
357 if (platform->pcm_ops->close)
358 platform->pcm_ops->close(substream);
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100359 cpu_dai->runtime = NULL;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200360
361 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
362 /* start delayed pop wq here for playback streams */
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100363 codec_dai->pop_wait = 1;
Takashi Iwai4bb09522006-12-19 17:16:14 +0100364 schedule_delayed_work(&socdev->delayed_work,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200365 msecs_to_jiffies(pmdown_time));
366 } else {
367 /* capture streams can be powered down now */
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100368 snd_soc_dapm_stream_event(codec,
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100369 codec_dai->capture.stream_name,
370 SND_SOC_DAPM_STREAM_STOP);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200371
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100372 if (codec->active == 0 && codec_dai->pop_wait == 0)
Mark Brown0be98982008-05-19 12:31:28 +0200373 snd_soc_dapm_set_bias_level(socdev,
374 SND_SOC_BIAS_STANDBY);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200375 }
376
377 mutex_unlock(&pcm_mutex);
378 return 0;
379}
380
381/*
382 * Called by ALSA when the PCM substream is prepared, can set format, sample
383 * rate, etc. This function is non atomic and can be called multiple times,
384 * it can refer to the runtime info.
385 */
386static int soc_pcm_prepare(struct snd_pcm_substream *substream)
387{
388 struct snd_soc_pcm_runtime *rtd = substream->private_data;
389 struct snd_soc_device *socdev = rtd->socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100390 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200391 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100392 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
393 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200394 struct snd_soc_codec *codec = socdev->codec;
395 int ret = 0;
396
397 mutex_lock(&pcm_mutex);
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100398
399 if (machine->ops && machine->ops->prepare) {
400 ret = machine->ops->prepare(substream);
401 if (ret < 0) {
402 printk(KERN_ERR "asoc: machine prepare error\n");
403 goto out;
404 }
405 }
406
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200407 if (platform->pcm_ops->prepare) {
408 ret = platform->pcm_ops->prepare(substream);
Liam Girdwooda71a4682006-10-19 20:35:56 +0200409 if (ret < 0) {
410 printk(KERN_ERR "asoc: platform prepare error\n");
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200411 goto out;
Liam Girdwooda71a4682006-10-19 20:35:56 +0200412 }
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200413 }
414
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100415 if (codec_dai->ops.prepare) {
416 ret = codec_dai->ops.prepare(substream);
Liam Girdwooda71a4682006-10-19 20:35:56 +0200417 if (ret < 0) {
418 printk(KERN_ERR "asoc: codec DAI prepare error\n");
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200419 goto out;
Liam Girdwooda71a4682006-10-19 20:35:56 +0200420 }
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200421 }
422
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100423 if (cpu_dai->ops.prepare) {
424 ret = cpu_dai->ops.prepare(substream);
425 if (ret < 0) {
426 printk(KERN_ERR "asoc: cpu DAI prepare error\n");
427 goto out;
428 }
429 }
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200430
431 /* we only want to start a DAPM playback stream if we are not waiting
432 * on an existing one stopping */
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100433 if (codec_dai->pop_wait) {
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200434 /* we are waiting for the delayed work to start */
435 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100436 snd_soc_dapm_stream_event(socdev->codec,
437 codec_dai->capture.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200438 SND_SOC_DAPM_STREAM_START);
439 else {
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100440 codec_dai->pop_wait = 0;
Andrew Morton4484bb22006-12-15 09:30:07 +0100441 cancel_delayed_work(&socdev->delayed_work);
Liam Girdwood8c6529d2008-07-08 13:19:13 +0100442 snd_soc_dai_digital_mute(codec_dai, 0);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200443 }
444 } else {
445 /* no delayed work - do we need to power up codec */
Mark Brown0be98982008-05-19 12:31:28 +0200446 if (codec->bias_level != SND_SOC_BIAS_ON) {
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200447
Mark Brown0be98982008-05-19 12:31:28 +0200448 snd_soc_dapm_set_bias_level(socdev,
449 SND_SOC_BIAS_PREPARE);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200450
451 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
452 snd_soc_dapm_stream_event(codec,
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100453 codec_dai->playback.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200454 SND_SOC_DAPM_STREAM_START);
455 else
456 snd_soc_dapm_stream_event(codec,
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100457 codec_dai->capture.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200458 SND_SOC_DAPM_STREAM_START);
459
Mark Brown0be98982008-05-19 12:31:28 +0200460 snd_soc_dapm_set_bias_level(socdev, SND_SOC_BIAS_ON);
Liam Girdwood8c6529d2008-07-08 13:19:13 +0100461 snd_soc_dai_digital_mute(codec_dai, 0);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200462
463 } else {
464 /* codec already powered - power on widgets */
465 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
466 snd_soc_dapm_stream_event(codec,
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100467 codec_dai->playback.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200468 SND_SOC_DAPM_STREAM_START);
469 else
470 snd_soc_dapm_stream_event(codec,
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100471 codec_dai->capture.stream_name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200472 SND_SOC_DAPM_STREAM_START);
Liam Girdwood8c6529d2008-07-08 13:19:13 +0100473
474 snd_soc_dai_digital_mute(codec_dai, 0);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200475 }
476 }
477
478out:
479 mutex_unlock(&pcm_mutex);
480 return ret;
481}
482
483/*
484 * Called by ALSA when the hardware params are set by application. This
485 * function can also be called multiple times and can allocate buffers
486 * (using snd_pcm_lib_* ). It's non-atomic.
487 */
488static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
489 struct snd_pcm_hw_params *params)
490{
491 struct snd_soc_pcm_runtime *rtd = substream->private_data;
492 struct snd_soc_device *socdev = rtd->socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100493 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200494 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100495 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
496 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200497 int ret = 0;
498
499 mutex_lock(&pcm_mutex);
500
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100501 if (machine->ops && machine->ops->hw_params) {
502 ret = machine->ops->hw_params(substream, params);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200503 if (ret < 0) {
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100504 printk(KERN_ERR "asoc: machine hw_params failed\n");
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200505 goto out;
506 }
507 }
508
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100509 if (codec_dai->ops.hw_params) {
510 ret = codec_dai->ops.hw_params(substream, params);
511 if (ret < 0) {
512 printk(KERN_ERR "asoc: can't set codec %s hw params\n",
513 codec_dai->name);
514 goto codec_err;
515 }
516 }
517
518 if (cpu_dai->ops.hw_params) {
519 ret = cpu_dai->ops.hw_params(substream, params);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200520 if (ret < 0) {
Mark Brown3ff3f642008-05-19 12:32:25 +0200521 printk(KERN_ERR "asoc: interface %s hw params failed\n",
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100522 cpu_dai->name);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200523 goto interface_err;
524 }
525 }
526
527 if (platform->pcm_ops->hw_params) {
528 ret = platform->pcm_ops->hw_params(substream, params);
529 if (ret < 0) {
Mark Brown3ff3f642008-05-19 12:32:25 +0200530 printk(KERN_ERR "asoc: platform %s hw params failed\n",
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200531 platform->name);
532 goto platform_err;
533 }
534 }
535
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200536out:
537 mutex_unlock(&pcm_mutex);
538 return ret;
539
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200540platform_err:
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100541 if (cpu_dai->ops.hw_free)
542 cpu_dai->ops.hw_free(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200543
544interface_err:
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100545 if (codec_dai->ops.hw_free)
546 codec_dai->ops.hw_free(substream);
547
548codec_err:
Mark Brown3ff3f642008-05-19 12:32:25 +0200549 if (machine->ops && machine->ops->hw_free)
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100550 machine->ops->hw_free(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200551
552 mutex_unlock(&pcm_mutex);
553 return ret;
554}
555
556/*
557 * Free's resources allocated by hw_params, can be called multiple times
558 */
559static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
560{
561 struct snd_soc_pcm_runtime *rtd = substream->private_data;
562 struct snd_soc_device *socdev = rtd->socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100563 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200564 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100565 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
566 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200567 struct snd_soc_codec *codec = socdev->codec;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200568
569 mutex_lock(&pcm_mutex);
570
571 /* apply codec digital mute */
Liam Girdwood8c6529d2008-07-08 13:19:13 +0100572 if (!codec->active)
573 snd_soc_dai_digital_mute(codec_dai, 1);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200574
575 /* free any machine hw params */
576 if (machine->ops && machine->ops->hw_free)
577 machine->ops->hw_free(substream);
578
579 /* free any DMA resources */
580 if (platform->pcm_ops->hw_free)
581 platform->pcm_ops->hw_free(substream);
582
583 /* now free hw params for the DAI's */
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100584 if (codec_dai->ops.hw_free)
585 codec_dai->ops.hw_free(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200586
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100587 if (cpu_dai->ops.hw_free)
588 cpu_dai->ops.hw_free(substream);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200589
590 mutex_unlock(&pcm_mutex);
591 return 0;
592}
593
594static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
595{
596 struct snd_soc_pcm_runtime *rtd = substream->private_data;
597 struct snd_soc_device *socdev = rtd->socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100598 struct snd_soc_dai_link *machine = rtd->dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200599 struct snd_soc_platform *platform = socdev->platform;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100600 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
601 struct snd_soc_dai *codec_dai = machine->codec_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200602 int ret;
603
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100604 if (codec_dai->ops.trigger) {
605 ret = codec_dai->ops.trigger(substream, cmd);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200606 if (ret < 0)
607 return ret;
608 }
609
610 if (platform->pcm_ops->trigger) {
611 ret = platform->pcm_ops->trigger(substream, cmd);
612 if (ret < 0)
613 return ret;
614 }
615
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100616 if (cpu_dai->ops.trigger) {
617 ret = cpu_dai->ops.trigger(substream, cmd);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200618 if (ret < 0)
619 return ret;
620 }
621 return 0;
622}
623
624/* ASoC PCM operations */
625static struct snd_pcm_ops soc_pcm_ops = {
626 .open = soc_pcm_open,
627 .close = soc_codec_close,
628 .hw_params = soc_pcm_hw_params,
629 .hw_free = soc_pcm_hw_free,
630 .prepare = soc_pcm_prepare,
631 .trigger = soc_pcm_trigger,
632};
633
634#ifdef CONFIG_PM
635/* powers down audio subsystem for suspend */
636static int soc_suspend(struct platform_device *pdev, pm_message_t state)
637{
Mark Brown3ff3f642008-05-19 12:32:25 +0200638 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
639 struct snd_soc_machine *machine = socdev->machine;
640 struct snd_soc_platform *platform = socdev->platform;
641 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200642 struct snd_soc_codec *codec = socdev->codec;
643 int i;
644
Andy Green6ed25972008-06-13 16:24:05 +0100645 /* Due to the resume being scheduled into a workqueue we could
646 * suspend before that's finished - wait for it to complete.
647 */
648 snd_power_lock(codec->card);
649 snd_power_wait(codec->card, SNDRV_CTL_POWER_D0);
650 snd_power_unlock(codec->card);
651
652 /* we're going to block userspace touching us until resume completes */
653 snd_power_change_state(codec->card, SNDRV_CTL_POWER_D3hot);
654
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200655 /* mute any active DAC's */
Mark Brown3ff3f642008-05-19 12:32:25 +0200656 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100657 struct snd_soc_dai *dai = machine->dai_link[i].codec_dai;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100658 if (dai->dai_ops.digital_mute && dai->playback.active)
659 dai->dai_ops.digital_mute(dai, 1);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200660 }
661
Liam Girdwood4ccab3e2008-01-10 14:39:01 +0100662 /* suspend all pcms */
663 for (i = 0; i < machine->num_links; i++)
664 snd_pcm_suspend_all(machine->dai_link[i].pcm);
665
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200666 if (machine->suspend_pre)
667 machine->suspend_pre(pdev, state);
668
Mark Brown3ff3f642008-05-19 12:32:25 +0200669 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100670 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200671 if (cpu_dai->suspend && cpu_dai->type != SND_SOC_DAI_AC97)
672 cpu_dai->suspend(pdev, cpu_dai);
673 if (platform->suspend)
674 platform->suspend(pdev, cpu_dai);
675 }
676
677 /* close any waiting streams and save state */
Liam Girdwood965ac422007-01-31 14:14:57 +0100678 run_delayed_work(&socdev->delayed_work);
Mark Brown0be98982008-05-19 12:31:28 +0200679 codec->suspend_bias_level = codec->bias_level;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200680
Mark Brown3ff3f642008-05-19 12:32:25 +0200681 for (i = 0; i < codec->num_dai; i++) {
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200682 char *stream = codec->dai[i].playback.stream_name;
683 if (stream != NULL)
684 snd_soc_dapm_stream_event(codec, stream,
685 SND_SOC_DAPM_STREAM_SUSPEND);
686 stream = codec->dai[i].capture.stream_name;
687 if (stream != NULL)
688 snd_soc_dapm_stream_event(codec, stream,
689 SND_SOC_DAPM_STREAM_SUSPEND);
690 }
691
692 if (codec_dev->suspend)
693 codec_dev->suspend(pdev, state);
694
Mark Brown3ff3f642008-05-19 12:32:25 +0200695 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100696 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200697 if (cpu_dai->suspend && cpu_dai->type == SND_SOC_DAI_AC97)
698 cpu_dai->suspend(pdev, cpu_dai);
699 }
700
701 if (machine->suspend_post)
702 machine->suspend_post(pdev, state);
703
704 return 0;
705}
706
Andy Green6ed25972008-06-13 16:24:05 +0100707/* deferred resume work, so resume can complete before we finished
708 * setting our codec back up, which can be very slow on I2C
709 */
710static void soc_resume_deferred(struct work_struct *work)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200711{
Andy Green6ed25972008-06-13 16:24:05 +0100712 struct snd_soc_device *socdev = container_of(work,
713 struct snd_soc_device,
714 deferred_resume_work);
Mark Brown3ff3f642008-05-19 12:32:25 +0200715 struct snd_soc_machine *machine = socdev->machine;
716 struct snd_soc_platform *platform = socdev->platform;
717 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200718 struct snd_soc_codec *codec = socdev->codec;
Andy Green6ed25972008-06-13 16:24:05 +0100719 struct platform_device *pdev = to_platform_device(socdev->dev);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200720 int i;
721
Andy Green6ed25972008-06-13 16:24:05 +0100722 /* our power state is still SNDRV_CTL_POWER_D3hot from suspend time,
723 * so userspace apps are blocked from touching us
724 */
725
726 dev_info(socdev->dev, "starting resume work\n");
727
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200728 if (machine->resume_pre)
729 machine->resume_pre(pdev);
730
Mark Brown3ff3f642008-05-19 12:32:25 +0200731 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100732 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200733 if (cpu_dai->resume && cpu_dai->type == SND_SOC_DAI_AC97)
734 cpu_dai->resume(pdev, cpu_dai);
735 }
736
737 if (codec_dev->resume)
738 codec_dev->resume(pdev);
739
Mark Brown3ff3f642008-05-19 12:32:25 +0200740 for (i = 0; i < codec->num_dai; i++) {
741 char *stream = codec->dai[i].playback.stream_name;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200742 if (stream != NULL)
743 snd_soc_dapm_stream_event(codec, stream,
744 SND_SOC_DAPM_STREAM_RESUME);
745 stream = codec->dai[i].capture.stream_name;
746 if (stream != NULL)
747 snd_soc_dapm_stream_event(codec, stream,
748 SND_SOC_DAPM_STREAM_RESUME);
749 }
750
Mark Brown3ff3f642008-05-19 12:32:25 +0200751 /* unmute any active DACs */
752 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100753 struct snd_soc_dai *dai = machine->dai_link[i].codec_dai;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100754 if (dai->dai_ops.digital_mute && dai->playback.active)
755 dai->dai_ops.digital_mute(dai, 0);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200756 }
757
Mark Brown3ff3f642008-05-19 12:32:25 +0200758 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100759 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200760 if (cpu_dai->resume && cpu_dai->type != SND_SOC_DAI_AC97)
761 cpu_dai->resume(pdev, cpu_dai);
762 if (platform->resume)
763 platform->resume(pdev, cpu_dai);
764 }
765
766 if (machine->resume_post)
767 machine->resume_post(pdev);
768
Andy Green6ed25972008-06-13 16:24:05 +0100769 dev_info(socdev->dev, "resume work completed\n");
770
771 /* userspace can access us now we are back as we were before */
772 snd_power_change_state(codec->card, SNDRV_CTL_POWER_D0);
773}
774
775/* powers up audio subsystem after a suspend */
776static int soc_resume(struct platform_device *pdev)
777{
778 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
779
780 dev_info(socdev->dev, "scheduling resume work\n");
781
782 if (!schedule_work(&socdev->deferred_resume_work))
783 dev_err(socdev->dev, "work item may be lost\n");
784
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200785 return 0;
786}
787
788#else
789#define soc_suspend NULL
790#define soc_resume NULL
791#endif
792
793/* probes a new socdev */
794static int soc_probe(struct platform_device *pdev)
795{
796 int ret = 0, i;
797 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
798 struct snd_soc_machine *machine = socdev->machine;
799 struct snd_soc_platform *platform = socdev->platform;
800 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
801
802 if (machine->probe) {
803 ret = machine->probe(pdev);
Mark Brown3ff3f642008-05-19 12:32:25 +0200804 if (ret < 0)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200805 return ret;
806 }
807
808 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100809 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200810 if (cpu_dai->probe) {
Mark Brownbdb92872008-06-11 13:47:10 +0100811 ret = cpu_dai->probe(pdev, cpu_dai);
Mark Brown3ff3f642008-05-19 12:32:25 +0200812 if (ret < 0)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200813 goto cpu_dai_err;
814 }
815 }
816
817 if (codec_dev->probe) {
818 ret = codec_dev->probe(pdev);
Mark Brown3ff3f642008-05-19 12:32:25 +0200819 if (ret < 0)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200820 goto cpu_dai_err;
821 }
822
823 if (platform->probe) {
824 ret = platform->probe(pdev);
Mark Brown3ff3f642008-05-19 12:32:25 +0200825 if (ret < 0)
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200826 goto platform_err;
827 }
828
829 /* DAPM stream work */
Andrew Morton4484bb22006-12-15 09:30:07 +0100830 INIT_DELAYED_WORK(&socdev->delayed_work, close_delayed_work);
Randy Dunlap1301a962008-06-17 19:19:34 +0100831#ifdef CONFIG_PM
Andy Green6ed25972008-06-13 16:24:05 +0100832 /* deferred resume work */
833 INIT_WORK(&socdev->deferred_resume_work, soc_resume_deferred);
Randy Dunlap1301a962008-06-17 19:19:34 +0100834#endif
Andy Green6ed25972008-06-13 16:24:05 +0100835
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200836 return 0;
837
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200838platform_err:
839 if (codec_dev->remove)
840 codec_dev->remove(pdev);
841
842cpu_dai_err:
Liam Girdwood18b9b3d2007-01-30 17:18:45 +0100843 for (i--; i >= 0; i--) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100844 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200845 if (cpu_dai->remove)
Mark Brownbdb92872008-06-11 13:47:10 +0100846 cpu_dai->remove(pdev, cpu_dai);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200847 }
848
849 if (machine->remove)
850 machine->remove(pdev);
851
852 return ret;
853}
854
855/* removes a socdev */
856static int soc_remove(struct platform_device *pdev)
857{
858 int i;
859 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
860 struct snd_soc_machine *machine = socdev->machine;
861 struct snd_soc_platform *platform = socdev->platform;
862 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
863
Liam Girdwood965ac422007-01-31 14:14:57 +0100864 run_delayed_work(&socdev->delayed_work);
865
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200866 if (platform->remove)
867 platform->remove(pdev);
868
869 if (codec_dev->remove)
870 codec_dev->remove(pdev);
871
872 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100873 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200874 if (cpu_dai->remove)
Mark Brownbdb92872008-06-11 13:47:10 +0100875 cpu_dai->remove(pdev, cpu_dai);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200876 }
877
878 if (machine->remove)
879 machine->remove(pdev);
880
881 return 0;
882}
883
884/* ASoC platform driver */
885static struct platform_driver soc_driver = {
886 .driver = {
887 .name = "soc-audio",
Kay Sievers8b45a202008-04-14 13:33:36 +0200888 .owner = THIS_MODULE,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200889 },
890 .probe = soc_probe,
891 .remove = soc_remove,
892 .suspend = soc_suspend,
893 .resume = soc_resume,
894};
895
896/* create a new pcm */
897static int soc_new_pcm(struct snd_soc_device *socdev,
898 struct snd_soc_dai_link *dai_link, int num)
899{
900 struct snd_soc_codec *codec = socdev->codec;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100901 struct snd_soc_dai *codec_dai = dai_link->codec_dai;
902 struct snd_soc_dai *cpu_dai = dai_link->cpu_dai;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200903 struct snd_soc_pcm_runtime *rtd;
904 struct snd_pcm *pcm;
905 char new_name[64];
906 int ret = 0, playback = 0, capture = 0;
907
908 rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL);
909 if (rtd == NULL)
910 return -ENOMEM;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100911
912 rtd->dai = dai_link;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200913 rtd->socdev = socdev;
Liam Girdwoodcb666e52007-02-02 17:13:49 +0100914 codec_dai->codec = socdev->codec;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200915
916 /* check client and interface hw capabilities */
Mark Brown3ff3f642008-05-19 12:32:25 +0200917 sprintf(new_name, "%s %s-%s-%d", dai_link->stream_name, codec_dai->name,
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200918 get_dai_name(cpu_dai->type), num);
919
920 if (codec_dai->playback.channels_min)
921 playback = 1;
922 if (codec_dai->capture.channels_min)
923 capture = 1;
924
925 ret = snd_pcm_new(codec->card, new_name, codec->pcm_devs++, playback,
926 capture, &pcm);
927 if (ret < 0) {
Mark Brown3ff3f642008-05-19 12:32:25 +0200928 printk(KERN_ERR "asoc: can't create pcm for codec %s\n",
929 codec->name);
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200930 kfree(rtd);
931 return ret;
932 }
933
Liam Girdwood4ccab3e2008-01-10 14:39:01 +0100934 dai_link->pcm = pcm;
Frank Mandarinodb2a4162006-10-06 18:31:09 +0200935 pcm->private_data = rtd;
936 soc_pcm_ops.mmap = socdev->platform->pcm_ops->mmap;
937 soc_pcm_ops.pointer = socdev->platform->pcm_ops->pointer;
938 soc_pcm_ops.ioctl = socdev->platform->pcm_ops->ioctl;
939 soc_pcm_ops.copy = socdev->platform->pcm_ops->copy;
940 soc_pcm_ops.silence = socdev->platform->pcm_ops->silence;
941 soc_pcm_ops.ack = socdev->platform->pcm_ops->ack;
942 soc_pcm_ops.page = socdev->platform->pcm_ops->page;
943
944 if (playback)
945 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops);
946
947 if (capture)
948 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops);
949
950 ret = socdev->platform->pcm_new(codec->card, codec_dai, pcm);
951 if (ret < 0) {
952 printk(KERN_ERR "asoc: platform pcm constructor failed\n");
953 kfree(rtd);
954 return ret;
955 }
956
957 pcm->private_free = socdev->platform->pcm_free;
958 printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name,
959 cpu_dai->name);
960 return ret;
961}
962
963/* codec register dump */
964static ssize_t codec_reg_show(struct device *dev,
965 struct device_attribute *attr, char *buf)
966{
967 struct snd_soc_device *devdata = dev_get_drvdata(dev);
968 struct snd_soc_codec *codec = devdata->codec;
969 int i, step = 1, count = 0;
970
971 if (!codec->reg_cache_size)
972 return 0;
973
974 if (codec->reg_cache_step)
975 step = codec->reg_cache_step;
976
977 count += sprintf(buf, "%s registers\n", codec->name);
Mark Brown58cd33c2008-07-29 11:42:25 +0100978 for (i = 0; i < codec->reg_cache_size; i += step) {
979 count += sprintf(buf + count, "%2x: ", i);
980 if (count >= PAGE_SIZE - 1)
981 break;
982
983 if (codec->display_register)
984 count += codec->display_register(codec, buf + count,
985 PAGE_SIZE - count, i);
986 else
987 count += snprintf(buf + count, PAGE_SIZE - count,
988 "%4x", codec->read(codec, i));
989
990 if (count >= PAGE_SIZE - 1)
991 break;
992
993 count += snprintf(buf + count, PAGE_SIZE - count, "\n");
994 if (count >= PAGE_SIZE - 1)
995 break;
996 }
997
998 /* Truncate count; min() would cause a warning */
999 if (count >= PAGE_SIZE)
1000 count = PAGE_SIZE - 1;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001001
1002 return count;
1003}
1004static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
1005
1006/**
1007 * snd_soc_new_ac97_codec - initailise AC97 device
1008 * @codec: audio codec
1009 * @ops: AC97 bus operations
1010 * @num: AC97 codec number
1011 *
1012 * Initialises AC97 codec resources for use by ad-hoc devices only.
1013 */
1014int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
1015 struct snd_ac97_bus_ops *ops, int num)
1016{
1017 mutex_lock(&codec->mutex);
1018
1019 codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL);
1020 if (codec->ac97 == NULL) {
1021 mutex_unlock(&codec->mutex);
1022 return -ENOMEM;
1023 }
1024
1025 codec->ac97->bus = kzalloc(sizeof(struct snd_ac97_bus), GFP_KERNEL);
1026 if (codec->ac97->bus == NULL) {
1027 kfree(codec->ac97);
1028 codec->ac97 = NULL;
1029 mutex_unlock(&codec->mutex);
1030 return -ENOMEM;
1031 }
1032
1033 codec->ac97->bus->ops = ops;
1034 codec->ac97->num = num;
1035 mutex_unlock(&codec->mutex);
1036 return 0;
1037}
1038EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);
1039
1040/**
1041 * snd_soc_free_ac97_codec - free AC97 codec device
1042 * @codec: audio codec
1043 *
1044 * Frees AC97 codec device resources.
1045 */
1046void snd_soc_free_ac97_codec(struct snd_soc_codec *codec)
1047{
1048 mutex_lock(&codec->mutex);
1049 kfree(codec->ac97->bus);
1050 kfree(codec->ac97);
1051 codec->ac97 = NULL;
1052 mutex_unlock(&codec->mutex);
1053}
1054EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec);
1055
1056/**
1057 * snd_soc_update_bits - update codec register bits
1058 * @codec: audio codec
1059 * @reg: codec register
1060 * @mask: register mask
1061 * @value: new value
1062 *
1063 * Writes new register value.
1064 *
1065 * Returns 1 for change else 0.
1066 */
1067int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
1068 unsigned short mask, unsigned short value)
1069{
1070 int change;
1071 unsigned short old, new;
1072
1073 mutex_lock(&io_mutex);
1074 old = snd_soc_read(codec, reg);
1075 new = (old & ~mask) | value;
1076 change = old != new;
1077 if (change)
1078 snd_soc_write(codec, reg, new);
1079
1080 mutex_unlock(&io_mutex);
1081 return change;
1082}
1083EXPORT_SYMBOL_GPL(snd_soc_update_bits);
1084
1085/**
1086 * snd_soc_test_bits - test register for change
1087 * @codec: audio codec
1088 * @reg: codec register
1089 * @mask: register mask
1090 * @value: new value
1091 *
1092 * Tests a register with a new value and checks if the new value is
1093 * different from the old value.
1094 *
1095 * Returns 1 for change else 0.
1096 */
1097int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
1098 unsigned short mask, unsigned short value)
1099{
1100 int change;
1101 unsigned short old, new;
1102
1103 mutex_lock(&io_mutex);
1104 old = snd_soc_read(codec, reg);
1105 new = (old & ~mask) | value;
1106 change = old != new;
1107 mutex_unlock(&io_mutex);
1108
1109 return change;
1110}
1111EXPORT_SYMBOL_GPL(snd_soc_test_bits);
1112
1113/**
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001114 * snd_soc_new_pcms - create new sound card and pcms
1115 * @socdev: the SoC audio device
1116 *
1117 * Create a new sound card based upon the codec and interface pcms.
1118 *
1119 * Returns 0 for success, else error.
1120 */
Liam Girdwoodbc7320c2007-02-01 12:26:07 +01001121int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001122{
1123 struct snd_soc_codec *codec = socdev->codec;
1124 struct snd_soc_machine *machine = socdev->machine;
1125 int ret = 0, i;
1126
1127 mutex_lock(&codec->mutex);
1128
1129 /* register a sound card */
1130 codec->card = snd_card_new(idx, xid, codec->owner, 0);
1131 if (!codec->card) {
1132 printk(KERN_ERR "asoc: can't create sound card for codec %s\n",
1133 codec->name);
1134 mutex_unlock(&codec->mutex);
1135 return -ENODEV;
1136 }
1137
1138 codec->card->dev = socdev->dev;
1139 codec->card->private_data = codec;
1140 strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver));
1141
1142 /* create the pcms */
Mark Brown3ff3f642008-05-19 12:32:25 +02001143 for (i = 0; i < machine->num_links; i++) {
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001144 ret = soc_new_pcm(socdev, &machine->dai_link[i], i);
1145 if (ret < 0) {
1146 printk(KERN_ERR "asoc: can't create pcm %s\n",
1147 machine->dai_link[i].stream_name);
1148 mutex_unlock(&codec->mutex);
1149 return ret;
1150 }
1151 }
1152
1153 mutex_unlock(&codec->mutex);
1154 return ret;
1155}
1156EXPORT_SYMBOL_GPL(snd_soc_new_pcms);
1157
1158/**
1159 * snd_soc_register_card - register sound card
1160 * @socdev: the SoC audio device
1161 *
1162 * Register a SoC sound card. Also registers an AC97 device if the
1163 * codec is AC97 for ad hoc devices.
1164 *
1165 * Returns 0 for success, else error.
1166 */
1167int snd_soc_register_card(struct snd_soc_device *socdev)
1168{
1169 struct snd_soc_codec *codec = socdev->codec;
1170 struct snd_soc_machine *machine = socdev->machine;
Liam Girdwood12e74f72006-10-16 21:19:48 +02001171 int ret = 0, i, ac97 = 0, err = 0;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001172
Mark Brown3ff3f642008-05-19 12:32:25 +02001173 for (i = 0; i < machine->num_links; i++) {
Liam Girdwood12e74f72006-10-16 21:19:48 +02001174 if (socdev->machine->dai_link[i].init) {
1175 err = socdev->machine->dai_link[i].init(codec);
1176 if (err < 0) {
1177 printk(KERN_ERR "asoc: failed to init %s\n",
1178 socdev->machine->dai_link[i].stream_name);
1179 continue;
1180 }
1181 }
Mark Brown3ff3f642008-05-19 12:32:25 +02001182 if (socdev->machine->dai_link[i].codec_dai->type ==
Liam Girdwooda68660e2007-05-10 19:27:27 +02001183 SND_SOC_DAI_AC97_BUS)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001184 ac97 = 1;
1185 }
1186 snprintf(codec->card->shortname, sizeof(codec->card->shortname),
1187 "%s", machine->name);
1188 snprintf(codec->card->longname, sizeof(codec->card->longname),
1189 "%s (%s)", machine->name, codec->name);
1190
1191 ret = snd_card_register(codec->card);
1192 if (ret < 0) {
Mark Brown3ff3f642008-05-19 12:32:25 +02001193 printk(KERN_ERR "asoc: failed to register soundcard for %s\n",
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001194 codec->name);
Liam Girdwood12e74f72006-10-16 21:19:48 +02001195 goto out;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001196 }
1197
Mark Brown08c8efe2008-01-21 14:33:37 +01001198 mutex_lock(&codec->mutex);
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001199#ifdef CONFIG_SND_SOC_AC97_BUS
Liam Girdwood12e74f72006-10-16 21:19:48 +02001200 if (ac97) {
1201 ret = soc_ac97_dev_register(codec);
1202 if (ret < 0) {
1203 printk(KERN_ERR "asoc: AC97 device register failed\n");
1204 snd_card_free(codec->card);
Mark Brown08c8efe2008-01-21 14:33:37 +01001205 mutex_unlock(&codec->mutex);
Liam Girdwood12e74f72006-10-16 21:19:48 +02001206 goto out;
1207 }
1208 }
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001209#endif
1210
Liam Girdwood12e74f72006-10-16 21:19:48 +02001211 err = snd_soc_dapm_sys_add(socdev->dev);
1212 if (err < 0)
1213 printk(KERN_WARNING "asoc: failed to add dapm sysfs entries\n");
1214
1215 err = device_create_file(socdev->dev, &dev_attr_codec_reg);
1216 if (err < 0)
Mark Brown3ff3f642008-05-19 12:32:25 +02001217 printk(KERN_WARNING "asoc: failed to add codec sysfs files\n");
Mark Brown08c8efe2008-01-21 14:33:37 +01001218
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001219 mutex_unlock(&codec->mutex);
Mark Brown08c8efe2008-01-21 14:33:37 +01001220
1221out:
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001222 return ret;
1223}
1224EXPORT_SYMBOL_GPL(snd_soc_register_card);
1225
1226/**
1227 * snd_soc_free_pcms - free sound card and pcms
1228 * @socdev: the SoC audio device
1229 *
1230 * Frees sound card and pcms associated with the socdev.
1231 * Also unregister the codec if it is an AC97 device.
1232 */
1233void snd_soc_free_pcms(struct snd_soc_device *socdev)
1234{
1235 struct snd_soc_codec *codec = socdev->codec;
Liam Girdwooda68660e2007-05-10 19:27:27 +02001236#ifdef CONFIG_SND_SOC_AC97_BUS
Liam Girdwood3c4b2662008-07-07 16:07:17 +01001237 struct snd_soc_dai *codec_dai;
Liam Girdwooda68660e2007-05-10 19:27:27 +02001238 int i;
1239#endif
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001240
1241 mutex_lock(&codec->mutex);
1242#ifdef CONFIG_SND_SOC_AC97_BUS
Mark Brown3ff3f642008-05-19 12:32:25 +02001243 for (i = 0; i < codec->num_dai; i++) {
Liam Girdwooda68660e2007-05-10 19:27:27 +02001244 codec_dai = &codec->dai[i];
1245 if (codec_dai->type == SND_SOC_DAI_AC97_BUS && codec->ac97) {
1246 soc_ac97_dev_unregister(codec);
1247 goto free_card;
1248 }
1249 }
1250free_card:
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001251#endif
1252
1253 if (codec->card)
1254 snd_card_free(codec->card);
1255 device_remove_file(socdev->dev, &dev_attr_codec_reg);
1256 mutex_unlock(&codec->mutex);
1257}
1258EXPORT_SYMBOL_GPL(snd_soc_free_pcms);
1259
1260/**
1261 * snd_soc_set_runtime_hwparams - set the runtime hardware parameters
1262 * @substream: the pcm substream
1263 * @hw: the hardware parameters
1264 *
1265 * Sets the substream runtime hardware parameters.
1266 */
1267int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
1268 const struct snd_pcm_hardware *hw)
1269{
1270 struct snd_pcm_runtime *runtime = substream->runtime;
1271 runtime->hw.info = hw->info;
1272 runtime->hw.formats = hw->formats;
1273 runtime->hw.period_bytes_min = hw->period_bytes_min;
1274 runtime->hw.period_bytes_max = hw->period_bytes_max;
1275 runtime->hw.periods_min = hw->periods_min;
1276 runtime->hw.periods_max = hw->periods_max;
1277 runtime->hw.buffer_bytes_max = hw->buffer_bytes_max;
1278 runtime->hw.fifo_size = hw->fifo_size;
1279 return 0;
1280}
1281EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams);
1282
1283/**
1284 * snd_soc_cnew - create new control
1285 * @_template: control template
1286 * @data: control private data
1287 * @lnng_name: control long name
1288 *
1289 * Create a new mixer control from a template control.
1290 *
1291 * Returns 0 for success, else error.
1292 */
1293struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
1294 void *data, char *long_name)
1295{
1296 struct snd_kcontrol_new template;
1297
1298 memcpy(&template, _template, sizeof(template));
1299 if (long_name)
1300 template.name = long_name;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001301 template.index = 0;
1302
1303 return snd_ctl_new1(&template, data);
1304}
1305EXPORT_SYMBOL_GPL(snd_soc_cnew);
1306
1307/**
1308 * snd_soc_info_enum_double - enumerated double mixer info callback
1309 * @kcontrol: mixer control
1310 * @uinfo: control element information
1311 *
1312 * Callback to provide information about a double enumerated
1313 * mixer control.
1314 *
1315 * Returns 0 for success.
1316 */
1317int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
1318 struct snd_ctl_elem_info *uinfo)
1319{
1320 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1321
1322 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1323 uinfo->count = e->shift_l == e->shift_r ? 1 : 2;
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001324 uinfo->value.enumerated.items = e->max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001325
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001326 if (uinfo->value.enumerated.item > e->max - 1)
1327 uinfo->value.enumerated.item = e->max - 1;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001328 strcpy(uinfo->value.enumerated.name,
1329 e->texts[uinfo->value.enumerated.item]);
1330 return 0;
1331}
1332EXPORT_SYMBOL_GPL(snd_soc_info_enum_double);
1333
1334/**
1335 * snd_soc_get_enum_double - enumerated double mixer get callback
1336 * @kcontrol: mixer control
1337 * @uinfo: control element information
1338 *
1339 * Callback to get the value of a double enumerated mixer.
1340 *
1341 * Returns 0 for success.
1342 */
1343int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
1344 struct snd_ctl_elem_value *ucontrol)
1345{
1346 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1347 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1348 unsigned short val, bitmask;
1349
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001350 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001351 ;
1352 val = snd_soc_read(codec, e->reg);
Mark Brown3ff3f642008-05-19 12:32:25 +02001353 ucontrol->value.enumerated.item[0]
1354 = (val >> e->shift_l) & (bitmask - 1);
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001355 if (e->shift_l != e->shift_r)
1356 ucontrol->value.enumerated.item[1] =
1357 (val >> e->shift_r) & (bitmask - 1);
1358
1359 return 0;
1360}
1361EXPORT_SYMBOL_GPL(snd_soc_get_enum_double);
1362
1363/**
1364 * snd_soc_put_enum_double - enumerated double mixer put callback
1365 * @kcontrol: mixer control
1366 * @uinfo: control element information
1367 *
1368 * Callback to set the value of a double enumerated mixer.
1369 *
1370 * Returns 0 for success.
1371 */
1372int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
1373 struct snd_ctl_elem_value *ucontrol)
1374{
1375 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1376 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1377 unsigned short val;
1378 unsigned short mask, bitmask;
1379
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001380 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001381 ;
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001382 if (ucontrol->value.enumerated.item[0] > e->max - 1)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001383 return -EINVAL;
1384 val = ucontrol->value.enumerated.item[0] << e->shift_l;
1385 mask = (bitmask - 1) << e->shift_l;
1386 if (e->shift_l != e->shift_r) {
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001387 if (ucontrol->value.enumerated.item[1] > e->max - 1)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001388 return -EINVAL;
1389 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
1390 mask |= (bitmask - 1) << e->shift_r;
1391 }
1392
1393 return snd_soc_update_bits(codec, e->reg, mask, val);
1394}
1395EXPORT_SYMBOL_GPL(snd_soc_put_enum_double);
1396
1397/**
1398 * snd_soc_info_enum_ext - external enumerated single mixer info callback
1399 * @kcontrol: mixer control
1400 * @uinfo: control element information
1401 *
1402 * Callback to provide information about an external enumerated
1403 * single mixer.
1404 *
1405 * Returns 0 for success.
1406 */
1407int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
1408 struct snd_ctl_elem_info *uinfo)
1409{
1410 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1411
1412 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1413 uinfo->count = 1;
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001414 uinfo->value.enumerated.items = e->max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001415
Jon Smirlf8ba0b72008-07-29 11:42:27 +01001416 if (uinfo->value.enumerated.item > e->max - 1)
1417 uinfo->value.enumerated.item = e->max - 1;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001418 strcpy(uinfo->value.enumerated.name,
1419 e->texts[uinfo->value.enumerated.item]);
1420 return 0;
1421}
1422EXPORT_SYMBOL_GPL(snd_soc_info_enum_ext);
1423
1424/**
1425 * snd_soc_info_volsw_ext - external single mixer info callback
1426 * @kcontrol: mixer control
1427 * @uinfo: control element information
1428 *
1429 * Callback to provide information about a single external mixer control.
1430 *
1431 * Returns 0 for success.
1432 */
1433int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
1434 struct snd_ctl_elem_info *uinfo)
1435{
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001436 int max = kcontrol->private_value;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001437
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001438 if (max == 1)
1439 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1440 else
1441 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1442
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001443 uinfo->count = 1;
1444 uinfo->value.integer.min = 0;
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001445 uinfo->value.integer.max = max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001446 return 0;
1447}
1448EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext);
1449
1450/**
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001451 * snd_soc_info_volsw - single mixer info callback
1452 * @kcontrol: mixer control
1453 * @uinfo: control element information
1454 *
1455 * Callback to provide information about a single mixer control.
1456 *
1457 * Returns 0 for success.
1458 */
1459int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
1460 struct snd_ctl_elem_info *uinfo)
1461{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001462 struct soc_mixer_control *mc =
1463 (struct soc_mixer_control *)kcontrol->private_value;
1464 int max = mc->max;
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001465 unsigned int shift = mc->min;
1466 unsigned int rshift = mc->rshift;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001467
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001468 if (max == 1)
1469 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1470 else
1471 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1472
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001473 uinfo->count = shift == rshift ? 1 : 2;
1474 uinfo->value.integer.min = 0;
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001475 uinfo->value.integer.max = max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001476 return 0;
1477}
1478EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
1479
1480/**
1481 * snd_soc_get_volsw - single mixer get callback
1482 * @kcontrol: mixer control
1483 * @uinfo: control element information
1484 *
1485 * Callback to get the value of a single mixer control.
1486 *
1487 * Returns 0 for success.
1488 */
1489int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
1490 struct snd_ctl_elem_value *ucontrol)
1491{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001492 struct soc_mixer_control *mc =
1493 (struct soc_mixer_control *)kcontrol->private_value;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001494 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001495 unsigned int reg = mc->reg;
1496 unsigned int shift = mc->shift;
1497 unsigned int rshift = mc->rshift;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001498 int max = mc->max;
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001499 unsigned int mask = (1 << fls(max)) - 1;
1500 unsigned int invert = mc->invert;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001501
1502 ucontrol->value.integer.value[0] =
1503 (snd_soc_read(codec, reg) >> shift) & mask;
1504 if (shift != rshift)
1505 ucontrol->value.integer.value[1] =
1506 (snd_soc_read(codec, reg) >> rshift) & mask;
1507 if (invert) {
1508 ucontrol->value.integer.value[0] =
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001509 max - ucontrol->value.integer.value[0];
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001510 if (shift != rshift)
1511 ucontrol->value.integer.value[1] =
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001512 max - ucontrol->value.integer.value[1];
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001513 }
1514
1515 return 0;
1516}
1517EXPORT_SYMBOL_GPL(snd_soc_get_volsw);
1518
1519/**
1520 * snd_soc_put_volsw - single mixer put callback
1521 * @kcontrol: mixer control
1522 * @uinfo: control element information
1523 *
1524 * Callback to set the value of a single mixer control.
1525 *
1526 * Returns 0 for success.
1527 */
1528int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
1529 struct snd_ctl_elem_value *ucontrol)
1530{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001531 struct soc_mixer_control *mc =
1532 (struct soc_mixer_control *)kcontrol->private_value;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001533 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001534 unsigned int reg = mc->reg;
1535 unsigned int shift = mc->shift;
1536 unsigned int rshift = mc->rshift;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001537 int max = mc->max;
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001538 unsigned int mask = (1 << fls(max)) - 1;
1539 unsigned int invert = mc->invert;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001540 unsigned short val, val2, val_mask;
1541
1542 val = (ucontrol->value.integer.value[0] & mask);
1543 if (invert)
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001544 val = max - val;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001545 val_mask = mask << shift;
1546 val = val << shift;
1547 if (shift != rshift) {
1548 val2 = (ucontrol->value.integer.value[1] & mask);
1549 if (invert)
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001550 val2 = max - val2;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001551 val_mask |= mask << rshift;
1552 val |= val2 << rshift;
1553 }
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001554 return snd_soc_update_bits(codec, reg, val_mask, val);
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001555}
1556EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
1557
1558/**
1559 * snd_soc_info_volsw_2r - double mixer info callback
1560 * @kcontrol: mixer control
1561 * @uinfo: control element information
1562 *
1563 * Callback to provide information about a double mixer control that
1564 * spans 2 codec registers.
1565 *
1566 * Returns 0 for success.
1567 */
1568int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
1569 struct snd_ctl_elem_info *uinfo)
1570{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001571 struct soc_mixer_control *mc =
1572 (struct soc_mixer_control *)kcontrol->private_value;
1573 int max = mc->max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001574
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001575 if (max == 1)
1576 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1577 else
1578 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1579
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001580 uinfo->count = 2;
1581 uinfo->value.integer.min = 0;
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001582 uinfo->value.integer.max = max;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001583 return 0;
1584}
1585EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r);
1586
1587/**
1588 * snd_soc_get_volsw_2r - double mixer get callback
1589 * @kcontrol: mixer control
1590 * @uinfo: control element information
1591 *
1592 * Callback to get the value of a double mixer control that spans 2 registers.
1593 *
1594 * Returns 0 for success.
1595 */
1596int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
1597 struct snd_ctl_elem_value *ucontrol)
1598{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001599 struct soc_mixer_control *mc =
1600 (struct soc_mixer_control *)kcontrol->private_value;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001601 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001602 unsigned int reg = mc->reg;
1603 unsigned int reg2 = mc->rreg;
1604 unsigned int shift = mc->shift;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001605 int max = mc->max;
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001606 unsigned int mask = (1<<fls(max))-1;
1607 unsigned int invert = mc->invert;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001608
1609 ucontrol->value.integer.value[0] =
1610 (snd_soc_read(codec, reg) >> shift) & mask;
1611 ucontrol->value.integer.value[1] =
1612 (snd_soc_read(codec, reg2) >> shift) & mask;
1613 if (invert) {
1614 ucontrol->value.integer.value[0] =
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001615 max - ucontrol->value.integer.value[0];
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001616 ucontrol->value.integer.value[1] =
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001617 max - ucontrol->value.integer.value[1];
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001618 }
1619
1620 return 0;
1621}
1622EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r);
1623
1624/**
1625 * snd_soc_put_volsw_2r - double mixer set callback
1626 * @kcontrol: mixer control
1627 * @uinfo: control element information
1628 *
1629 * Callback to set the value of a double mixer control that spans 2 registers.
1630 *
1631 * Returns 0 for success.
1632 */
1633int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
1634 struct snd_ctl_elem_value *ucontrol)
1635{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001636 struct soc_mixer_control *mc =
1637 (struct soc_mixer_control *)kcontrol->private_value;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001638 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001639 unsigned int reg = mc->reg;
1640 unsigned int reg2 = mc->rreg;
1641 unsigned int shift = mc->shift;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001642 int max = mc->max;
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001643 unsigned int mask = (1 << fls(max)) - 1;
1644 unsigned int invert = mc->invert;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001645 int err;
1646 unsigned short val, val2, val_mask;
1647
1648 val_mask = mask << shift;
1649 val = (ucontrol->value.integer.value[0] & mask);
1650 val2 = (ucontrol->value.integer.value[1] & mask);
1651
1652 if (invert) {
Philipp Zabela7a4ac82008-01-10 14:37:42 +01001653 val = max - val;
1654 val2 = max - val2;
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001655 }
1656
1657 val = val << shift;
1658 val2 = val2 << shift;
1659
Mark Brown3ff3f642008-05-19 12:32:25 +02001660 err = snd_soc_update_bits(codec, reg, val_mask, val);
1661 if (err < 0)
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001662 return err;
1663
1664 err = snd_soc_update_bits(codec, reg2, val_mask, val2);
1665 return err;
1666}
1667EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r);
1668
Mark Browne13ac2e2008-05-28 17:58:05 +01001669/**
1670 * snd_soc_info_volsw_s8 - signed mixer info callback
1671 * @kcontrol: mixer control
1672 * @uinfo: control element information
1673 *
1674 * Callback to provide information about a signed mixer control.
1675 *
1676 * Returns 0 for success.
1677 */
1678int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
1679 struct snd_ctl_elem_info *uinfo)
1680{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001681 struct soc_mixer_control *mc =
1682 (struct soc_mixer_control *)kcontrol->private_value;
1683 int max = mc->max;
1684 int min = mc->min;
Mark Browne13ac2e2008-05-28 17:58:05 +01001685
1686 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1687 uinfo->count = 2;
1688 uinfo->value.integer.min = 0;
1689 uinfo->value.integer.max = max-min;
1690 return 0;
1691}
1692EXPORT_SYMBOL_GPL(snd_soc_info_volsw_s8);
1693
1694/**
1695 * snd_soc_get_volsw_s8 - signed mixer get callback
1696 * @kcontrol: mixer control
1697 * @uinfo: control element information
1698 *
1699 * Callback to get the value of a signed mixer control.
1700 *
1701 * Returns 0 for success.
1702 */
1703int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
1704 struct snd_ctl_elem_value *ucontrol)
1705{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001706 struct soc_mixer_control *mc =
1707 (struct soc_mixer_control *)kcontrol->private_value;
Mark Browne13ac2e2008-05-28 17:58:05 +01001708 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001709 unsigned int reg = mc->reg;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001710 int min = mc->min;
Mark Browne13ac2e2008-05-28 17:58:05 +01001711 int val = snd_soc_read(codec, reg);
1712
1713 ucontrol->value.integer.value[0] =
1714 ((signed char)(val & 0xff))-min;
1715 ucontrol->value.integer.value[1] =
1716 ((signed char)((val >> 8) & 0xff))-min;
1717 return 0;
1718}
1719EXPORT_SYMBOL_GPL(snd_soc_get_volsw_s8);
1720
1721/**
1722 * snd_soc_put_volsw_sgn - signed mixer put callback
1723 * @kcontrol: mixer control
1724 * @uinfo: control element information
1725 *
1726 * Callback to set the value of a signed mixer control.
1727 *
1728 * Returns 0 for success.
1729 */
1730int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
1731 struct snd_ctl_elem_value *ucontrol)
1732{
Jon Smirl4eaa9812008-07-29 11:42:26 +01001733 struct soc_mixer_control *mc =
1734 (struct soc_mixer_control *)kcontrol->private_value;
Mark Browne13ac2e2008-05-28 17:58:05 +01001735 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Jon Smirl815ecf8d2008-07-29 10:22:24 -04001736 unsigned int reg = mc->reg;
Jon Smirl4eaa9812008-07-29 11:42:26 +01001737 int min = mc->min;
Mark Browne13ac2e2008-05-28 17:58:05 +01001738 unsigned short val;
1739
1740 val = (ucontrol->value.integer.value[0]+min) & 0xff;
1741 val |= ((ucontrol->value.integer.value[1]+min) & 0xff) << 8;
1742
1743 return snd_soc_update_bits(codec, reg, 0xffff, val);
1744}
1745EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8);
1746
Liam Girdwood8c6529d2008-07-08 13:19:13 +01001747/**
1748 * snd_soc_dai_set_sysclk - configure DAI system or master clock.
1749 * @dai: DAI
1750 * @clk_id: DAI specific clock ID
1751 * @freq: new clock frequency in Hz
1752 * @dir: new clock direction - input/output.
1753 *
1754 * Configures the DAI master (MCLK) or system (SYSCLK) clocking.
1755 */
1756int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
1757 unsigned int freq, int dir)
1758{
1759 if (dai->dai_ops.set_sysclk)
1760 return dai->dai_ops.set_sysclk(dai, clk_id, freq, dir);
1761 else
1762 return -EINVAL;
1763}
1764EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
1765
1766/**
1767 * snd_soc_dai_set_clkdiv - configure DAI clock dividers.
1768 * @dai: DAI
1769 * @clk_id: DAI specific clock divider ID
1770 * @div: new clock divisor.
1771 *
1772 * Configures the clock dividers. This is used to derive the best DAI bit and
1773 * frame clocks from the system or master clock. It's best to set the DAI bit
1774 * and frame clocks as low as possible to save system power.
1775 */
1776int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
1777 int div_id, int div)
1778{
1779 if (dai->dai_ops.set_clkdiv)
1780 return dai->dai_ops.set_clkdiv(dai, div_id, div);
1781 else
1782 return -EINVAL;
1783}
1784EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv);
1785
1786/**
1787 * snd_soc_dai_set_pll - configure DAI PLL.
1788 * @dai: DAI
1789 * @pll_id: DAI specific PLL ID
1790 * @freq_in: PLL input clock frequency in Hz
1791 * @freq_out: requested PLL output clock frequency in Hz
1792 *
1793 * Configures and enables PLL to generate output clock based on input clock.
1794 */
1795int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
1796 int pll_id, unsigned int freq_in, unsigned int freq_out)
1797{
1798 if (dai->dai_ops.set_pll)
1799 return dai->dai_ops.set_pll(dai, pll_id, freq_in, freq_out);
1800 else
1801 return -EINVAL;
1802}
1803EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll);
1804
1805/**
1806 * snd_soc_dai_set_fmt - configure DAI hardware audio format.
1807 * @dai: DAI
1808 * @clk_id: DAI specific clock ID
1809 * @fmt: SND_SOC_DAIFMT_ format value.
1810 *
1811 * Configures the DAI hardware format and clocking.
1812 */
1813int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
1814{
1815 if (dai->dai_ops.set_fmt)
1816 return dai->dai_ops.set_fmt(dai, fmt);
1817 else
1818 return -EINVAL;
1819}
1820EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
1821
1822/**
1823 * snd_soc_dai_set_tdm_slot - configure DAI TDM.
1824 * @dai: DAI
1825 * @mask: DAI specific mask representing used slots.
1826 * @slots: Number of slots in use.
1827 *
1828 * Configures a DAI for TDM operation. Both mask and slots are codec and DAI
1829 * specific.
1830 */
1831int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
1832 unsigned int mask, int slots)
1833{
1834 if (dai->dai_ops.set_sysclk)
1835 return dai->dai_ops.set_tdm_slot(dai, mask, slots);
1836 else
1837 return -EINVAL;
1838}
1839EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot);
1840
1841/**
1842 * snd_soc_dai_set_tristate - configure DAI system or master clock.
1843 * @dai: DAI
1844 * @tristate: tristate enable
1845 *
1846 * Tristates the DAI so that others can use it.
1847 */
1848int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
1849{
1850 if (dai->dai_ops.set_sysclk)
1851 return dai->dai_ops.set_tristate(dai, tristate);
1852 else
1853 return -EINVAL;
1854}
1855EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate);
1856
1857/**
1858 * snd_soc_dai_digital_mute - configure DAI system or master clock.
1859 * @dai: DAI
1860 * @mute: mute enable
1861 *
1862 * Mutes the DAI DAC.
1863 */
1864int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute)
1865{
1866 if (dai->dai_ops.digital_mute)
1867 return dai->dai_ops.digital_mute(dai, mute);
1868 else
1869 return -EINVAL;
1870}
1871EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);
1872
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001873static int __devinit snd_soc_init(void)
1874{
1875 printk(KERN_INFO "ASoC version %s\n", SND_SOC_VERSION);
1876 return platform_driver_register(&soc_driver);
1877}
1878
1879static void snd_soc_exit(void)
1880{
Mark Brown3ff3f642008-05-19 12:32:25 +02001881 platform_driver_unregister(&soc_driver);
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001882}
1883
1884module_init(snd_soc_init);
1885module_exit(snd_soc_exit);
1886
1887/* Module information */
Liam Girdwoodd3311242008-10-12 13:17:36 +01001888MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk");
Frank Mandarinodb2a4162006-10-06 18:31:09 +02001889MODULE_DESCRIPTION("ALSA SoC Core");
1890MODULE_LICENSE("GPL");
Kay Sievers8b45a202008-04-14 13:33:36 +02001891MODULE_ALIAS("platform:soc-audio");