]>
Commit | Line | Data |
---|---|---|
db2a4165 FM |
1 | /* |
2 | * soc-core.c -- ALSA SoC Audio Layer | |
3 | * | |
4 | * Copyright 2005 Wolfson Microelectronics PLC. | |
0664d888 LG |
5 | * Copyright 2005 Openedhand Ltd. |
6 | * | |
d331124d | 7 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> |
0664d888 LG |
8 | * with code, comments and ideas from :- |
9 | * Richard Purdie <richard@openedhand.com> | |
db2a4165 FM |
10 | * |
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 | * | |
db2a4165 FM |
16 | * 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> | |
12ef193d | 29 | #include <linux/debugfs.h> |
db2a4165 | 30 | #include <linux/platform_device.h> |
db2a4165 FM |
31 | #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 | |
a71a468a | 45 | |
db2a4165 FM |
46 | static DEFINE_MUTEX(pcm_mutex); |
47 | static DEFINE_MUTEX(io_mutex); | |
db2a4165 FM |
48 | static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq); |
49 | ||
db2a4165 FM |
50 | /* |
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 | */ | |
55 | static int pmdown_time = 5000; | |
56 | module_param(pmdown_time, int, 0); | |
57 | MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)"); | |
58 | ||
965ac42c LG |
59 | /* |
60 | * This function forces any delayed work to be queued and run. | |
61 | */ | |
62 | static 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 | ||
db2a4165 FM |
78 | #ifdef CONFIG_SND_SOC_AC97_BUS |
79 | /* unregister ac97 codec */ | |
80 | static 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 */ | |
88 | static void soc_ac97_device_release(struct device *dev){} | |
89 | ||
90 | /* register ac97 codec to bus */ | |
91 | static 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 | ||
3ff3f64b | 111 | static inline const char *get_dai_name(int type) |
db2a4165 | 112 | { |
3ff3f64b | 113 | switch (type) { |
a68660e0 | 114 | case SND_SOC_DAI_AC97_BUS: |
db2a4165 FM |
115 | 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 | ||
db2a4165 FM |
125 | /* |
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 | */ | |
130 | static 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; | |
cb666e5b | 135 | struct snd_soc_dai_link *machine = rtd->dai; |
db2a4165 | 136 | struct snd_soc_platform *platform = socdev->platform; |
3c4b266f LG |
137 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
138 | struct snd_soc_dai *codec_dai = machine->codec_dai; | |
db2a4165 FM |
139 | int ret = 0; |
140 | ||
141 | mutex_lock(&pcm_mutex); | |
142 | ||
143 | /* startup the audio subsystem */ | |
cb666e5b LG |
144 | if (cpu_dai->ops.startup) { |
145 | ret = cpu_dai->ops.startup(substream); | |
db2a4165 FM |
146 | if (ret < 0) { |
147 | printk(KERN_ERR "asoc: can't open interface %s\n", | |
cb666e5b | 148 | cpu_dai->name); |
db2a4165 FM |
149 | 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 | ||
cb666e5b LG |
161 | if (codec_dai->ops.startup) { |
162 | ret = codec_dai->ops.startup(substream); | |
db2a4165 | 163 | if (ret < 0) { |
cb666e5b LG |
164 | printk(KERN_ERR "asoc: can't open codec %s\n", |
165 | codec_dai->name); | |
166 | goto codec_dai_err; | |
db2a4165 FM |
167 | } |
168 | } | |
169 | ||
cb666e5b LG |
170 | if (machine->ops && machine->ops->startup) { |
171 | ret = machine->ops->startup(substream); | |
db2a4165 | 172 | if (ret < 0) { |
cb666e5b LG |
173 | printk(KERN_ERR "asoc: %s startup failed\n", machine->name); |
174 | goto machine_err; | |
db2a4165 FM |
175 | } |
176 | } | |
177 | ||
db2a4165 FM |
178 | /* Check that the codec and cpu DAI's are compatible */ |
179 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | |
180 | runtime->hw.rate_min = | |
3ff3f64b MB |
181 | max(codec_dai->playback.rate_min, |
182 | cpu_dai->playback.rate_min); | |
db2a4165 | 183 | runtime->hw.rate_max = |
3ff3f64b MB |
184 | min(codec_dai->playback.rate_max, |
185 | cpu_dai->playback.rate_max); | |
db2a4165 | 186 | runtime->hw.channels_min = |
cb666e5b LG |
187 | max(codec_dai->playback.channels_min, |
188 | cpu_dai->playback.channels_min); | |
db2a4165 | 189 | runtime->hw.channels_max = |
cb666e5b LG |
190 | 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; | |
db2a4165 FM |
196 | } else { |
197 | runtime->hw.rate_min = | |
3ff3f64b MB |
198 | max(codec_dai->capture.rate_min, |
199 | cpu_dai->capture.rate_min); | |
db2a4165 | 200 | runtime->hw.rate_max = |
3ff3f64b MB |
201 | min(codec_dai->capture.rate_max, |
202 | cpu_dai->capture.rate_max); | |
db2a4165 | 203 | runtime->hw.channels_min = |
cb666e5b LG |
204 | max(codec_dai->capture.channels_min, |
205 | cpu_dai->capture.channels_min); | |
db2a4165 | 206 | runtime->hw.channels_max = |
cb666e5b LG |
207 | 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; | |
db2a4165 FM |
213 | } |
214 | ||
215 | snd_pcm_limit_hw_rates(runtime); | |
216 | if (!runtime->hw.rates) { | |
217 | printk(KERN_ERR "asoc: %s <-> %s No matching rates\n", | |
cb666e5b LG |
218 | codec_dai->name, cpu_dai->name); |
219 | goto machine_err; | |
db2a4165 FM |
220 | } |
221 | if (!runtime->hw.formats) { | |
222 | printk(KERN_ERR "asoc: %s <-> %s No matching formats\n", | |
cb666e5b LG |
223 | codec_dai->name, cpu_dai->name); |
224 | goto machine_err; | |
db2a4165 FM |
225 | } |
226 | if (!runtime->hw.channels_min || !runtime->hw.channels_max) { | |
227 | printk(KERN_ERR "asoc: %s <-> %s No matching channels\n", | |
cb666e5b LG |
228 | codec_dai->name, cpu_dai->name); |
229 | goto machine_err; | |
db2a4165 FM |
230 | } |
231 | ||
3ff3f64b | 232 | dbg("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name); |
b5c5fd24 LG |
233 | 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); | |
db2a4165 | 238 | |
db2a4165 | 239 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
cb666e5b | 240 | cpu_dai->playback.active = codec_dai->playback.active = 1; |
db2a4165 | 241 | else |
cb666e5b LG |
242 | cpu_dai->capture.active = codec_dai->capture.active = 1; |
243 | cpu_dai->active = codec_dai->active = 1; | |
244 | cpu_dai->runtime = runtime; | |
db2a4165 FM |
245 | socdev->codec->active++; |
246 | mutex_unlock(&pcm_mutex); | |
247 | return 0; | |
248 | ||
cb666e5b | 249 | machine_err: |
db2a4165 FM |
250 | if (machine->ops && machine->ops->shutdown) |
251 | machine->ops->shutdown(substream); | |
252 | ||
cb666e5b | 253 | codec_dai_err: |
db2a4165 FM |
254 | if (platform->pcm_ops->close) |
255 | platform->pcm_ops->close(substream); | |
256 | ||
257 | platform_err: | |
cb666e5b LG |
258 | if (cpu_dai->ops.shutdown) |
259 | cpu_dai->ops.shutdown(substream); | |
db2a4165 FM |
260 | out: |
261 | mutex_unlock(&pcm_mutex); | |
262 | return ret; | |
263 | } | |
264 | ||
265 | /* | |
3a4fa0a2 | 266 | * Power down the audio subsystem pmdown_time msecs after close is called. |
db2a4165 FM |
267 | * This is to ensure there are no pops or clicks in between any music tracks |
268 | * due to DAPM power cycling. | |
269 | */ | |
4484bb2e | 270 | static void close_delayed_work(struct work_struct *work) |
db2a4165 | 271 | { |
4484bb2e AM |
272 | struct snd_soc_device *socdev = |
273 | container_of(work, struct snd_soc_device, delayed_work.work); | |
db2a4165 | 274 | struct snd_soc_codec *codec = socdev->codec; |
3c4b266f | 275 | struct snd_soc_dai *codec_dai; |
db2a4165 FM |
276 | int i; |
277 | ||
278 | mutex_lock(&pcm_mutex); | |
3ff3f64b | 279 | for (i = 0; i < codec->num_dai; i++) { |
db2a4165 FM |
280 | 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 | ||
0be9898a | 290 | /* Reduce power if no longer active */ |
3c1c47e0 LG |
291 | if (codec->active == 0) { |
292 | dbg("pop wq D1 %s %s\n", codec->name, | |
293 | codec_dai->playback.stream_name); | |
0be9898a MB |
294 | snd_soc_dapm_set_bias_level(socdev, |
295 | SND_SOC_BIAS_PREPARE); | |
3c1c47e0 LG |
296 | } |
297 | ||
db2a4165 | 298 | codec_dai->pop_wait = 0; |
0b4d221b LG |
299 | snd_soc_dapm_stream_event(codec, |
300 | codec_dai->playback.stream_name, | |
db2a4165 FM |
301 | SND_SOC_DAPM_STREAM_STOP); |
302 | ||
0be9898a | 303 | /* Fall into standby if no longer active */ |
db2a4165 FM |
304 | if (codec->active == 0) { |
305 | dbg("pop wq D3 %s %s\n", codec->name, | |
306 | codec_dai->playback.stream_name); | |
0be9898a MB |
307 | snd_soc_dapm_set_bias_level(socdev, |
308 | SND_SOC_BIAS_STANDBY); | |
db2a4165 FM |
309 | } |
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 | */ | |
320 | static 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; | |
cb666e5b | 324 | struct snd_soc_dai_link *machine = rtd->dai; |
db2a4165 | 325 | struct snd_soc_platform *platform = socdev->platform; |
3c4b266f LG |
326 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
327 | struct snd_soc_dai *codec_dai = machine->codec_dai; | |
db2a4165 FM |
328 | struct snd_soc_codec *codec = socdev->codec; |
329 | ||
330 | mutex_lock(&pcm_mutex); | |
331 | ||
332 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | |
cb666e5b | 333 | cpu_dai->playback.active = codec_dai->playback.active = 0; |
db2a4165 | 334 | else |
cb666e5b | 335 | cpu_dai->capture.active = codec_dai->capture.active = 0; |
db2a4165 | 336 | |
cb666e5b LG |
337 | if (codec_dai->playback.active == 0 && |
338 | codec_dai->capture.active == 0) { | |
339 | cpu_dai->active = codec_dai->active = 0; | |
db2a4165 FM |
340 | } |
341 | codec->active--; | |
342 | ||
6010b2da MB |
343 | /* Muting the DAC suppresses artifacts caused during digital |
344 | * shutdown, for example from stopping clocks. | |
345 | */ | |
346 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | |
347 | snd_soc_dai_digital_mute(codec_dai, 1); | |
348 | ||
cb666e5b LG |
349 | if (cpu_dai->ops.shutdown) |
350 | cpu_dai->ops.shutdown(substream); | |
db2a4165 | 351 | |
cb666e5b LG |
352 | if (codec_dai->ops.shutdown) |
353 | codec_dai->ops.shutdown(substream); | |
db2a4165 FM |
354 | |
355 | if (machine->ops && machine->ops->shutdown) | |
356 | machine->ops->shutdown(substream); | |
357 | ||
358 | if (platform->pcm_ops->close) | |
359 | platform->pcm_ops->close(substream); | |
cb666e5b | 360 | cpu_dai->runtime = NULL; |
db2a4165 FM |
361 | |
362 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | |
363 | /* start delayed pop wq here for playback streams */ | |
cb666e5b | 364 | codec_dai->pop_wait = 1; |
4bb09523 | 365 | schedule_delayed_work(&socdev->delayed_work, |
db2a4165 FM |
366 | msecs_to_jiffies(pmdown_time)); |
367 | } else { | |
368 | /* capture streams can be powered down now */ | |
cb666e5b | 369 | snd_soc_dapm_stream_event(codec, |
0b4d221b LG |
370 | codec_dai->capture.stream_name, |
371 | SND_SOC_DAPM_STREAM_STOP); | |
db2a4165 | 372 | |
0b4d221b | 373 | if (codec->active == 0 && codec_dai->pop_wait == 0) |
0be9898a MB |
374 | snd_soc_dapm_set_bias_level(socdev, |
375 | SND_SOC_BIAS_STANDBY); | |
db2a4165 FM |
376 | } |
377 | ||
378 | mutex_unlock(&pcm_mutex); | |
379 | return 0; | |
380 | } | |
381 | ||
382 | /* | |
383 | * Called by ALSA when the PCM substream is prepared, can set format, sample | |
384 | * rate, etc. This function is non atomic and can be called multiple times, | |
385 | * it can refer to the runtime info. | |
386 | */ | |
387 | static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |
388 | { | |
389 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
390 | struct snd_soc_device *socdev = rtd->socdev; | |
cb666e5b | 391 | struct snd_soc_dai_link *machine = rtd->dai; |
db2a4165 | 392 | struct snd_soc_platform *platform = socdev->platform; |
3c4b266f LG |
393 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
394 | struct snd_soc_dai *codec_dai = machine->codec_dai; | |
db2a4165 FM |
395 | struct snd_soc_codec *codec = socdev->codec; |
396 | int ret = 0; | |
397 | ||
398 | mutex_lock(&pcm_mutex); | |
cb666e5b LG |
399 | |
400 | if (machine->ops && machine->ops->prepare) { | |
401 | ret = machine->ops->prepare(substream); | |
402 | if (ret < 0) { | |
403 | printk(KERN_ERR "asoc: machine prepare error\n"); | |
404 | goto out; | |
405 | } | |
406 | } | |
407 | ||
db2a4165 FM |
408 | if (platform->pcm_ops->prepare) { |
409 | ret = platform->pcm_ops->prepare(substream); | |
a71a468a LG |
410 | if (ret < 0) { |
411 | printk(KERN_ERR "asoc: platform prepare error\n"); | |
db2a4165 | 412 | goto out; |
a71a468a | 413 | } |
db2a4165 FM |
414 | } |
415 | ||
cb666e5b LG |
416 | if (codec_dai->ops.prepare) { |
417 | ret = codec_dai->ops.prepare(substream); | |
a71a468a LG |
418 | if (ret < 0) { |
419 | printk(KERN_ERR "asoc: codec DAI prepare error\n"); | |
db2a4165 | 420 | goto out; |
a71a468a | 421 | } |
db2a4165 FM |
422 | } |
423 | ||
cb666e5b LG |
424 | if (cpu_dai->ops.prepare) { |
425 | ret = cpu_dai->ops.prepare(substream); | |
426 | if (ret < 0) { | |
427 | printk(KERN_ERR "asoc: cpu DAI prepare error\n"); | |
428 | goto out; | |
429 | } | |
430 | } | |
db2a4165 | 431 | |
d45f6219 MB |
432 | /* cancel any delayed stream shutdown that is pending */ |
433 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && | |
434 | codec_dai->pop_wait) { | |
435 | codec_dai->pop_wait = 0; | |
436 | cancel_delayed_work(&socdev->delayed_work); | |
437 | } | |
db2a4165 | 438 | |
d45f6219 MB |
439 | /* do we need to power up codec */ |
440 | if (codec->bias_level != SND_SOC_BIAS_ON) { | |
441 | snd_soc_dapm_set_bias_level(socdev, | |
442 | SND_SOC_BIAS_PREPARE); | |
db2a4165 | 443 | |
d45f6219 MB |
444 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
445 | snd_soc_dapm_stream_event(codec, | |
cb666e5b | 446 | codec_dai->playback.stream_name, |
db2a4165 | 447 | SND_SOC_DAPM_STREAM_START); |
d45f6219 MB |
448 | else |
449 | snd_soc_dapm_stream_event(codec, | |
cb666e5b | 450 | codec_dai->capture.stream_name, |
db2a4165 FM |
451 | SND_SOC_DAPM_STREAM_START); |
452 | ||
d45f6219 MB |
453 | snd_soc_dapm_set_bias_level(socdev, SND_SOC_BIAS_ON); |
454 | snd_soc_dai_digital_mute(codec_dai, 0); | |
db2a4165 | 455 | |
d45f6219 MB |
456 | } else { |
457 | /* codec already powered - power on widgets */ | |
458 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | |
459 | snd_soc_dapm_stream_event(codec, | |
cb666e5b | 460 | codec_dai->playback.stream_name, |
db2a4165 | 461 | SND_SOC_DAPM_STREAM_START); |
d45f6219 MB |
462 | else |
463 | snd_soc_dapm_stream_event(codec, | |
cb666e5b | 464 | codec_dai->capture.stream_name, |
db2a4165 | 465 | SND_SOC_DAPM_STREAM_START); |
8c6529db | 466 | |
d45f6219 | 467 | snd_soc_dai_digital_mute(codec_dai, 0); |
db2a4165 FM |
468 | } |
469 | ||
470 | out: | |
471 | mutex_unlock(&pcm_mutex); | |
472 | return ret; | |
473 | } | |
474 | ||
475 | /* | |
476 | * Called by ALSA when the hardware params are set by application. This | |
477 | * function can also be called multiple times and can allocate buffers | |
478 | * (using snd_pcm_lib_* ). It's non-atomic. | |
479 | */ | |
480 | static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |
481 | struct snd_pcm_hw_params *params) | |
482 | { | |
483 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
484 | struct snd_soc_device *socdev = rtd->socdev; | |
cb666e5b | 485 | struct snd_soc_dai_link *machine = rtd->dai; |
db2a4165 | 486 | struct snd_soc_platform *platform = socdev->platform; |
3c4b266f LG |
487 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
488 | struct snd_soc_dai *codec_dai = machine->codec_dai; | |
db2a4165 FM |
489 | int ret = 0; |
490 | ||
491 | mutex_lock(&pcm_mutex); | |
492 | ||
cb666e5b LG |
493 | if (machine->ops && machine->ops->hw_params) { |
494 | ret = machine->ops->hw_params(substream, params); | |
495 | if (ret < 0) { | |
496 | printk(KERN_ERR "asoc: machine hw_params failed\n"); | |
db2a4165 | 497 | goto out; |
cb666e5b | 498 | } |
db2a4165 FM |
499 | } |
500 | ||
cb666e5b LG |
501 | if (codec_dai->ops.hw_params) { |
502 | ret = codec_dai->ops.hw_params(substream, params); | |
db2a4165 FM |
503 | if (ret < 0) { |
504 | printk(KERN_ERR "asoc: can't set codec %s hw params\n", | |
cb666e5b LG |
505 | codec_dai->name); |
506 | goto codec_err; | |
db2a4165 FM |
507 | } |
508 | } | |
509 | ||
cb666e5b LG |
510 | if (cpu_dai->ops.hw_params) { |
511 | ret = cpu_dai->ops.hw_params(substream, params); | |
db2a4165 | 512 | if (ret < 0) { |
3ff3f64b | 513 | printk(KERN_ERR "asoc: interface %s hw params failed\n", |
cb666e5b | 514 | cpu_dai->name); |
db2a4165 FM |
515 | goto interface_err; |
516 | } | |
517 | } | |
518 | ||
519 | if (platform->pcm_ops->hw_params) { | |
520 | ret = platform->pcm_ops->hw_params(substream, params); | |
521 | if (ret < 0) { | |
3ff3f64b | 522 | printk(KERN_ERR "asoc: platform %s hw params failed\n", |
db2a4165 FM |
523 | platform->name); |
524 | goto platform_err; | |
525 | } | |
526 | } | |
527 | ||
db2a4165 FM |
528 | out: |
529 | mutex_unlock(&pcm_mutex); | |
530 | return ret; | |
531 | ||
db2a4165 | 532 | platform_err: |
cb666e5b LG |
533 | if (cpu_dai->ops.hw_free) |
534 | cpu_dai->ops.hw_free(substream); | |
db2a4165 FM |
535 | |
536 | interface_err: | |
cb666e5b LG |
537 | if (codec_dai->ops.hw_free) |
538 | codec_dai->ops.hw_free(substream); | |
539 | ||
540 | codec_err: | |
3ff3f64b | 541 | if (machine->ops && machine->ops->hw_free) |
cb666e5b | 542 | machine->ops->hw_free(substream); |
db2a4165 FM |
543 | |
544 | mutex_unlock(&pcm_mutex); | |
545 | return ret; | |
546 | } | |
547 | ||
548 | /* | |
549 | * Free's resources allocated by hw_params, can be called multiple times | |
550 | */ | |
551 | static int soc_pcm_hw_free(struct snd_pcm_substream *substream) | |
552 | { | |
553 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
554 | struct snd_soc_device *socdev = rtd->socdev; | |
cb666e5b | 555 | struct snd_soc_dai_link *machine = rtd->dai; |
db2a4165 | 556 | struct snd_soc_platform *platform = socdev->platform; |
3c4b266f LG |
557 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
558 | struct snd_soc_dai *codec_dai = machine->codec_dai; | |
db2a4165 | 559 | struct snd_soc_codec *codec = socdev->codec; |
db2a4165 FM |
560 | |
561 | mutex_lock(&pcm_mutex); | |
562 | ||
563 | /* apply codec digital mute */ | |
8c6529db LG |
564 | if (!codec->active) |
565 | snd_soc_dai_digital_mute(codec_dai, 1); | |
db2a4165 FM |
566 | |
567 | /* free any machine hw params */ | |
568 | if (machine->ops && machine->ops->hw_free) | |
569 | machine->ops->hw_free(substream); | |
570 | ||
571 | /* free any DMA resources */ | |
572 | if (platform->pcm_ops->hw_free) | |
573 | platform->pcm_ops->hw_free(substream); | |
574 | ||
575 | /* now free hw params for the DAI's */ | |
cb666e5b LG |
576 | if (codec_dai->ops.hw_free) |
577 | codec_dai->ops.hw_free(substream); | |
db2a4165 | 578 | |
cb666e5b LG |
579 | if (cpu_dai->ops.hw_free) |
580 | cpu_dai->ops.hw_free(substream); | |
db2a4165 FM |
581 | |
582 | mutex_unlock(&pcm_mutex); | |
583 | return 0; | |
584 | } | |
585 | ||
586 | static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |
587 | { | |
588 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
589 | struct snd_soc_device *socdev = rtd->socdev; | |
cb666e5b | 590 | struct snd_soc_dai_link *machine = rtd->dai; |
db2a4165 | 591 | struct snd_soc_platform *platform = socdev->platform; |
3c4b266f LG |
592 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
593 | struct snd_soc_dai *codec_dai = machine->codec_dai; | |
db2a4165 FM |
594 | int ret; |
595 | ||
cb666e5b LG |
596 | if (codec_dai->ops.trigger) { |
597 | ret = codec_dai->ops.trigger(substream, cmd); | |
db2a4165 FM |
598 | if (ret < 0) |
599 | return ret; | |
600 | } | |
601 | ||
602 | if (platform->pcm_ops->trigger) { | |
603 | ret = platform->pcm_ops->trigger(substream, cmd); | |
604 | if (ret < 0) | |
605 | return ret; | |
606 | } | |
607 | ||
cb666e5b LG |
608 | if (cpu_dai->ops.trigger) { |
609 | ret = cpu_dai->ops.trigger(substream, cmd); | |
db2a4165 FM |
610 | if (ret < 0) |
611 | return ret; | |
612 | } | |
613 | return 0; | |
614 | } | |
615 | ||
616 | /* ASoC PCM operations */ | |
617 | static struct snd_pcm_ops soc_pcm_ops = { | |
618 | .open = soc_pcm_open, | |
619 | .close = soc_codec_close, | |
620 | .hw_params = soc_pcm_hw_params, | |
621 | .hw_free = soc_pcm_hw_free, | |
622 | .prepare = soc_pcm_prepare, | |
623 | .trigger = soc_pcm_trigger, | |
624 | }; | |
625 | ||
626 | #ifdef CONFIG_PM | |
627 | /* powers down audio subsystem for suspend */ | |
628 | static int soc_suspend(struct platform_device *pdev, pm_message_t state) | |
629 | { | |
3ff3f64b MB |
630 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
631 | struct snd_soc_machine *machine = socdev->machine; | |
632 | struct snd_soc_platform *platform = socdev->platform; | |
633 | struct snd_soc_codec_device *codec_dev = socdev->codec_dev; | |
db2a4165 FM |
634 | struct snd_soc_codec *codec = socdev->codec; |
635 | int i; | |
636 | ||
6ed25978 AG |
637 | /* Due to the resume being scheduled into a workqueue we could |
638 | * suspend before that's finished - wait for it to complete. | |
639 | */ | |
640 | snd_power_lock(codec->card); | |
641 | snd_power_wait(codec->card, SNDRV_CTL_POWER_D0); | |
642 | snd_power_unlock(codec->card); | |
643 | ||
644 | /* we're going to block userspace touching us until resume completes */ | |
645 | snd_power_change_state(codec->card, SNDRV_CTL_POWER_D3hot); | |
646 | ||
db2a4165 | 647 | /* mute any active DAC's */ |
3ff3f64b | 648 | for (i = 0; i < machine->num_links; i++) { |
3c4b266f | 649 | struct snd_soc_dai *dai = machine->dai_link[i].codec_dai; |
cb666e5b LG |
650 | if (dai->dai_ops.digital_mute && dai->playback.active) |
651 | dai->dai_ops.digital_mute(dai, 1); | |
db2a4165 FM |
652 | } |
653 | ||
4ccab3e7 LG |
654 | /* suspend all pcms */ |
655 | for (i = 0; i < machine->num_links; i++) | |
656 | snd_pcm_suspend_all(machine->dai_link[i].pcm); | |
657 | ||
db2a4165 FM |
658 | if (machine->suspend_pre) |
659 | machine->suspend_pre(pdev, state); | |
660 | ||
3ff3f64b | 661 | for (i = 0; i < machine->num_links; i++) { |
3c4b266f | 662 | struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai; |
db2a4165 FM |
663 | if (cpu_dai->suspend && cpu_dai->type != SND_SOC_DAI_AC97) |
664 | cpu_dai->suspend(pdev, cpu_dai); | |
665 | if (platform->suspend) | |
666 | platform->suspend(pdev, cpu_dai); | |
667 | } | |
668 | ||
669 | /* close any waiting streams and save state */ | |
965ac42c | 670 | run_delayed_work(&socdev->delayed_work); |
0be9898a | 671 | codec->suspend_bias_level = codec->bias_level; |
db2a4165 | 672 | |
3ff3f64b | 673 | for (i = 0; i < codec->num_dai; i++) { |
db2a4165 FM |
674 | char *stream = codec->dai[i].playback.stream_name; |
675 | if (stream != NULL) | |
676 | snd_soc_dapm_stream_event(codec, stream, | |
677 | SND_SOC_DAPM_STREAM_SUSPEND); | |
678 | stream = codec->dai[i].capture.stream_name; | |
679 | if (stream != NULL) | |
680 | snd_soc_dapm_stream_event(codec, stream, | |
681 | SND_SOC_DAPM_STREAM_SUSPEND); | |
682 | } | |
683 | ||
684 | if (codec_dev->suspend) | |
685 | codec_dev->suspend(pdev, state); | |
686 | ||
3ff3f64b | 687 | for (i = 0; i < machine->num_links; i++) { |
3c4b266f | 688 | struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai; |
db2a4165 FM |
689 | if (cpu_dai->suspend && cpu_dai->type == SND_SOC_DAI_AC97) |
690 | cpu_dai->suspend(pdev, cpu_dai); | |
691 | } | |
692 | ||
693 | if (machine->suspend_post) | |
694 | machine->suspend_post(pdev, state); | |
695 | ||
696 | return 0; | |
697 | } | |
698 | ||
6ed25978 AG |
699 | /* deferred resume work, so resume can complete before we finished |
700 | * setting our codec back up, which can be very slow on I2C | |
701 | */ | |
702 | static void soc_resume_deferred(struct work_struct *work) | |
db2a4165 | 703 | { |
6ed25978 AG |
704 | struct snd_soc_device *socdev = container_of(work, |
705 | struct snd_soc_device, | |
706 | deferred_resume_work); | |
3ff3f64b MB |
707 | struct snd_soc_machine *machine = socdev->machine; |
708 | struct snd_soc_platform *platform = socdev->platform; | |
709 | struct snd_soc_codec_device *codec_dev = socdev->codec_dev; | |
db2a4165 | 710 | struct snd_soc_codec *codec = socdev->codec; |
6ed25978 | 711 | struct platform_device *pdev = to_platform_device(socdev->dev); |
db2a4165 FM |
712 | int i; |
713 | ||
6ed25978 AG |
714 | /* our power state is still SNDRV_CTL_POWER_D3hot from suspend time, |
715 | * so userspace apps are blocked from touching us | |
716 | */ | |
717 | ||
718 | dev_info(socdev->dev, "starting resume work\n"); | |
719 | ||
db2a4165 FM |
720 | if (machine->resume_pre) |
721 | machine->resume_pre(pdev); | |
722 | ||
3ff3f64b | 723 | for (i = 0; i < machine->num_links; i++) { |
3c4b266f | 724 | struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai; |
db2a4165 FM |
725 | if (cpu_dai->resume && cpu_dai->type == SND_SOC_DAI_AC97) |
726 | cpu_dai->resume(pdev, cpu_dai); | |
727 | } | |
728 | ||
729 | if (codec_dev->resume) | |
730 | codec_dev->resume(pdev); | |
731 | ||
3ff3f64b MB |
732 | for (i = 0; i < codec->num_dai; i++) { |
733 | char *stream = codec->dai[i].playback.stream_name; | |
db2a4165 FM |
734 | if (stream != NULL) |
735 | snd_soc_dapm_stream_event(codec, stream, | |
736 | SND_SOC_DAPM_STREAM_RESUME); | |
737 | stream = codec->dai[i].capture.stream_name; | |
738 | if (stream != NULL) | |
739 | snd_soc_dapm_stream_event(codec, stream, | |
740 | SND_SOC_DAPM_STREAM_RESUME); | |
741 | } | |
742 | ||
3ff3f64b MB |
743 | /* unmute any active DACs */ |
744 | for (i = 0; i < machine->num_links; i++) { | |
3c4b266f | 745 | struct snd_soc_dai *dai = machine->dai_link[i].codec_dai; |
cb666e5b LG |
746 | if (dai->dai_ops.digital_mute && dai->playback.active) |
747 | dai->dai_ops.digital_mute(dai, 0); | |
db2a4165 FM |
748 | } |
749 | ||
3ff3f64b | 750 | for (i = 0; i < machine->num_links; i++) { |
3c4b266f | 751 | struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai; |
db2a4165 FM |
752 | if (cpu_dai->resume && cpu_dai->type != SND_SOC_DAI_AC97) |
753 | cpu_dai->resume(pdev, cpu_dai); | |
754 | if (platform->resume) | |
755 | platform->resume(pdev, cpu_dai); | |
756 | } | |
757 | ||
758 | if (machine->resume_post) | |
759 | machine->resume_post(pdev); | |
760 | ||
6ed25978 AG |
761 | dev_info(socdev->dev, "resume work completed\n"); |
762 | ||
763 | /* userspace can access us now we are back as we were before */ | |
764 | snd_power_change_state(codec->card, SNDRV_CTL_POWER_D0); | |
765 | } | |
766 | ||
767 | /* powers up audio subsystem after a suspend */ | |
768 | static int soc_resume(struct platform_device *pdev) | |
769 | { | |
770 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | |
771 | ||
772 | dev_info(socdev->dev, "scheduling resume work\n"); | |
773 | ||
774 | if (!schedule_work(&socdev->deferred_resume_work)) | |
775 | dev_err(socdev->dev, "work item may be lost\n"); | |
776 | ||
db2a4165 FM |
777 | return 0; |
778 | } | |
779 | ||
780 | #else | |
781 | #define soc_suspend NULL | |
782 | #define soc_resume NULL | |
783 | #endif | |
784 | ||
785 | /* probes a new socdev */ | |
786 | static int soc_probe(struct platform_device *pdev) | |
787 | { | |
788 | int ret = 0, i; | |
789 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | |
790 | struct snd_soc_machine *machine = socdev->machine; | |
791 | struct snd_soc_platform *platform = socdev->platform; | |
792 | struct snd_soc_codec_device *codec_dev = socdev->codec_dev; | |
793 | ||
794 | if (machine->probe) { | |
795 | ret = machine->probe(pdev); | |
3ff3f64b | 796 | if (ret < 0) |
db2a4165 FM |
797 | return ret; |
798 | } | |
799 | ||
800 | for (i = 0; i < machine->num_links; i++) { | |
3c4b266f | 801 | struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai; |
db2a4165 | 802 | if (cpu_dai->probe) { |
bdb92876 | 803 | ret = cpu_dai->probe(pdev, cpu_dai); |
3ff3f64b | 804 | if (ret < 0) |
db2a4165 FM |
805 | goto cpu_dai_err; |
806 | } | |
807 | } | |
808 | ||
809 | if (codec_dev->probe) { | |
810 | ret = codec_dev->probe(pdev); | |
3ff3f64b | 811 | if (ret < 0) |
db2a4165 FM |
812 | goto cpu_dai_err; |
813 | } | |
814 | ||
815 | if (platform->probe) { | |
816 | ret = platform->probe(pdev); | |
3ff3f64b | 817 | if (ret < 0) |
db2a4165 FM |
818 | goto platform_err; |
819 | } | |
820 | ||
821 | /* DAPM stream work */ | |
4484bb2e | 822 | INIT_DELAYED_WORK(&socdev->delayed_work, close_delayed_work); |
1301a964 | 823 | #ifdef CONFIG_PM |
6ed25978 AG |
824 | /* deferred resume work */ |
825 | INIT_WORK(&socdev->deferred_resume_work, soc_resume_deferred); | |
1301a964 | 826 | #endif |
6ed25978 | 827 | |
db2a4165 FM |
828 | return 0; |
829 | ||
db2a4165 FM |
830 | platform_err: |
831 | if (codec_dev->remove) | |
832 | codec_dev->remove(pdev); | |
833 | ||
834 | cpu_dai_err: | |
18b9b3d9 | 835 | for (i--; i >= 0; i--) { |
3c4b266f | 836 | struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai; |
db2a4165 | 837 | if (cpu_dai->remove) |
bdb92876 | 838 | cpu_dai->remove(pdev, cpu_dai); |
db2a4165 FM |
839 | } |
840 | ||
841 | if (machine->remove) | |
842 | machine->remove(pdev); | |
843 | ||
844 | return ret; | |
845 | } | |
846 | ||
847 | /* removes a socdev */ | |
848 | static int soc_remove(struct platform_device *pdev) | |
849 | { | |
850 | int i; | |
851 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | |
852 | struct snd_soc_machine *machine = socdev->machine; | |
853 | struct snd_soc_platform *platform = socdev->platform; | |
854 | struct snd_soc_codec_device *codec_dev = socdev->codec_dev; | |
855 | ||
965ac42c LG |
856 | run_delayed_work(&socdev->delayed_work); |
857 | ||
db2a4165 FM |
858 | if (platform->remove) |
859 | platform->remove(pdev); | |
860 | ||
861 | if (codec_dev->remove) | |
862 | codec_dev->remove(pdev); | |
863 | ||
864 | for (i = 0; i < machine->num_links; i++) { | |
3c4b266f | 865 | struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai; |
db2a4165 | 866 | if (cpu_dai->remove) |
bdb92876 | 867 | cpu_dai->remove(pdev, cpu_dai); |
db2a4165 FM |
868 | } |
869 | ||
870 | if (machine->remove) | |
871 | machine->remove(pdev); | |
872 | ||
873 | return 0; | |
874 | } | |
875 | ||
876 | /* ASoC platform driver */ | |
877 | static struct platform_driver soc_driver = { | |
878 | .driver = { | |
879 | .name = "soc-audio", | |
8b45a209 | 880 | .owner = THIS_MODULE, |
db2a4165 FM |
881 | }, |
882 | .probe = soc_probe, | |
883 | .remove = soc_remove, | |
884 | .suspend = soc_suspend, | |
885 | .resume = soc_resume, | |
886 | }; | |
887 | ||
888 | /* create a new pcm */ | |
889 | static int soc_new_pcm(struct snd_soc_device *socdev, | |
890 | struct snd_soc_dai_link *dai_link, int num) | |
891 | { | |
892 | struct snd_soc_codec *codec = socdev->codec; | |
3c4b266f LG |
893 | struct snd_soc_dai *codec_dai = dai_link->codec_dai; |
894 | struct snd_soc_dai *cpu_dai = dai_link->cpu_dai; | |
db2a4165 FM |
895 | struct snd_soc_pcm_runtime *rtd; |
896 | struct snd_pcm *pcm; | |
897 | char new_name[64]; | |
898 | int ret = 0, playback = 0, capture = 0; | |
899 | ||
900 | rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL); | |
901 | if (rtd == NULL) | |
902 | return -ENOMEM; | |
cb666e5b LG |
903 | |
904 | rtd->dai = dai_link; | |
db2a4165 | 905 | rtd->socdev = socdev; |
cb666e5b | 906 | codec_dai->codec = socdev->codec; |
db2a4165 FM |
907 | |
908 | /* check client and interface hw capabilities */ | |
3ff3f64b | 909 | sprintf(new_name, "%s %s-%s-%d", dai_link->stream_name, codec_dai->name, |
db2a4165 FM |
910 | get_dai_name(cpu_dai->type), num); |
911 | ||
912 | if (codec_dai->playback.channels_min) | |
913 | playback = 1; | |
914 | if (codec_dai->capture.channels_min) | |
915 | capture = 1; | |
916 | ||
917 | ret = snd_pcm_new(codec->card, new_name, codec->pcm_devs++, playback, | |
918 | capture, &pcm); | |
919 | if (ret < 0) { | |
3ff3f64b MB |
920 | printk(KERN_ERR "asoc: can't create pcm for codec %s\n", |
921 | codec->name); | |
db2a4165 FM |
922 | kfree(rtd); |
923 | return ret; | |
924 | } | |
925 | ||
4ccab3e7 | 926 | dai_link->pcm = pcm; |
db2a4165 FM |
927 | pcm->private_data = rtd; |
928 | soc_pcm_ops.mmap = socdev->platform->pcm_ops->mmap; | |
929 | soc_pcm_ops.pointer = socdev->platform->pcm_ops->pointer; | |
930 | soc_pcm_ops.ioctl = socdev->platform->pcm_ops->ioctl; | |
931 | soc_pcm_ops.copy = socdev->platform->pcm_ops->copy; | |
932 | soc_pcm_ops.silence = socdev->platform->pcm_ops->silence; | |
933 | soc_pcm_ops.ack = socdev->platform->pcm_ops->ack; | |
934 | soc_pcm_ops.page = socdev->platform->pcm_ops->page; | |
935 | ||
936 | if (playback) | |
937 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops); | |
938 | ||
939 | if (capture) | |
940 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops); | |
941 | ||
942 | ret = socdev->platform->pcm_new(codec->card, codec_dai, pcm); | |
943 | if (ret < 0) { | |
944 | printk(KERN_ERR "asoc: platform pcm constructor failed\n"); | |
945 | kfree(rtd); | |
946 | return ret; | |
947 | } | |
948 | ||
949 | pcm->private_free = socdev->platform->pcm_free; | |
950 | printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name, | |
951 | cpu_dai->name); | |
952 | return ret; | |
953 | } | |
954 | ||
955 | /* codec register dump */ | |
12ef193d | 956 | static ssize_t soc_codec_reg_show(struct snd_soc_device *devdata, char *buf) |
db2a4165 | 957 | { |
db2a4165 FM |
958 | struct snd_soc_codec *codec = devdata->codec; |
959 | int i, step = 1, count = 0; | |
960 | ||
961 | if (!codec->reg_cache_size) | |
962 | return 0; | |
963 | ||
964 | if (codec->reg_cache_step) | |
965 | step = codec->reg_cache_step; | |
966 | ||
967 | count += sprintf(buf, "%s registers\n", codec->name); | |
58cd33c0 MB |
968 | for (i = 0; i < codec->reg_cache_size; i += step) { |
969 | count += sprintf(buf + count, "%2x: ", i); | |
970 | if (count >= PAGE_SIZE - 1) | |
971 | break; | |
972 | ||
973 | if (codec->display_register) | |
974 | count += codec->display_register(codec, buf + count, | |
975 | PAGE_SIZE - count, i); | |
976 | else | |
977 | count += snprintf(buf + count, PAGE_SIZE - count, | |
978 | "%4x", codec->read(codec, i)); | |
979 | ||
980 | if (count >= PAGE_SIZE - 1) | |
981 | break; | |
982 | ||
983 | count += snprintf(buf + count, PAGE_SIZE - count, "\n"); | |
984 | if (count >= PAGE_SIZE - 1) | |
985 | break; | |
986 | } | |
987 | ||
988 | /* Truncate count; min() would cause a warning */ | |
989 | if (count >= PAGE_SIZE) | |
990 | count = PAGE_SIZE - 1; | |
db2a4165 FM |
991 | |
992 | return count; | |
993 | } | |
12ef193d TK |
994 | static ssize_t codec_reg_show(struct device *dev, |
995 | struct device_attribute *attr, char *buf) | |
996 | { | |
997 | struct snd_soc_device *devdata = dev_get_drvdata(dev); | |
998 | return soc_codec_reg_show(devdata, buf); | |
999 | } | |
1000 | ||
db2a4165 FM |
1001 | static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL); |
1002 | ||
12ef193d TK |
1003 | #ifdef CONFIG_DEBUG_FS |
1004 | static int codec_reg_open_file(struct inode *inode, struct file *file) | |
1005 | { | |
1006 | file->private_data = inode->i_private; | |
1007 | return 0; | |
1008 | } | |
1009 | ||
1010 | static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf, | |
1011 | size_t count, loff_t *ppos) | |
1012 | { | |
1013 | ssize_t ret; | |
1014 | struct snd_soc_device *devdata = file->private_data; | |
1015 | char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | |
1016 | if (!buf) | |
1017 | return -ENOMEM; | |
1018 | ret = soc_codec_reg_show(devdata, buf); | |
1019 | if (ret >= 0) | |
1020 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); | |
1021 | kfree(buf); | |
1022 | return ret; | |
1023 | } | |
1024 | ||
1025 | static ssize_t codec_reg_write_file(struct file *file, | |
1026 | const char __user *user_buf, size_t count, loff_t *ppos) | |
1027 | { | |
1028 | char buf[32]; | |
1029 | int buf_size; | |
1030 | char *start = buf; | |
1031 | unsigned long reg, value; | |
1032 | int step = 1; | |
1033 | struct snd_soc_device *devdata = file->private_data; | |
1034 | struct snd_soc_codec *codec = devdata->codec; | |
1035 | ||
1036 | buf_size = min(count, (sizeof(buf)-1)); | |
1037 | if (copy_from_user(buf, user_buf, buf_size)) | |
1038 | return -EFAULT; | |
1039 | buf[buf_size] = 0; | |
1040 | ||
1041 | if (codec->reg_cache_step) | |
1042 | step = codec->reg_cache_step; | |
1043 | ||
1044 | while (*start == ' ') | |
1045 | start++; | |
1046 | reg = simple_strtoul(start, &start, 16); | |
1047 | if ((reg >= codec->reg_cache_size) || (reg % step)) | |
1048 | return -EINVAL; | |
1049 | while (*start == ' ') | |
1050 | start++; | |
1051 | if (strict_strtoul(start, 16, &value)) | |
1052 | return -EINVAL; | |
1053 | codec->write(codec, reg, value); | |
1054 | return buf_size; | |
1055 | } | |
1056 | ||
1057 | static const struct file_operations codec_reg_fops = { | |
1058 | .open = codec_reg_open_file, | |
1059 | .read = codec_reg_read_file, | |
1060 | .write = codec_reg_write_file, | |
1061 | }; | |
1062 | ||
1063 | static void soc_init_debugfs(struct snd_soc_device *socdev) | |
1064 | { | |
1065 | struct dentry *root, *file; | |
1066 | struct snd_soc_codec *codec = socdev->codec; | |
1067 | root = debugfs_create_dir(dev_name(socdev->dev), NULL); | |
1068 | if (IS_ERR(root) || !root) | |
1069 | goto exit1; | |
1070 | ||
1071 | file = debugfs_create_file("codec_reg", 0644, | |
1072 | root, socdev, &codec_reg_fops); | |
1073 | if (!file) | |
1074 | goto exit2; | |
1075 | ||
1076 | file = debugfs_create_u32("dapm_pop_time", 0744, | |
1077 | root, &codec->pop_time); | |
1078 | if (!file) | |
1079 | goto exit2; | |
1080 | socdev->debugfs_root = root; | |
1081 | return; | |
1082 | exit2: | |
1083 | debugfs_remove_recursive(root); | |
1084 | exit1: | |
1085 | dev_err(socdev->dev, "debugfs is not available\n"); | |
1086 | } | |
1087 | ||
1088 | static void soc_cleanup_debugfs(struct snd_soc_device *socdev) | |
1089 | { | |
1090 | debugfs_remove_recursive(socdev->debugfs_root); | |
1091 | socdev->debugfs_root = NULL; | |
1092 | } | |
1093 | ||
1094 | #else | |
1095 | ||
1096 | static inline void soc_init_debugfs(struct snd_soc_device *socdev) | |
1097 | { | |
1098 | } | |
1099 | ||
1100 | static inline void soc_cleanup_debugfs(struct snd_soc_device *socdev) | |
1101 | { | |
1102 | } | |
1103 | #endif | |
1104 | ||
db2a4165 FM |
1105 | /** |
1106 | * snd_soc_new_ac97_codec - initailise AC97 device | |
1107 | * @codec: audio codec | |
1108 | * @ops: AC97 bus operations | |
1109 | * @num: AC97 codec number | |
1110 | * | |
1111 | * Initialises AC97 codec resources for use by ad-hoc devices only. | |
1112 | */ | |
1113 | int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, | |
1114 | struct snd_ac97_bus_ops *ops, int num) | |
1115 | { | |
1116 | mutex_lock(&codec->mutex); | |
1117 | ||
1118 | codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL); | |
1119 | if (codec->ac97 == NULL) { | |
1120 | mutex_unlock(&codec->mutex); | |
1121 | return -ENOMEM; | |
1122 | } | |
1123 | ||
1124 | codec->ac97->bus = kzalloc(sizeof(struct snd_ac97_bus), GFP_KERNEL); | |
1125 | if (codec->ac97->bus == NULL) { | |
1126 | kfree(codec->ac97); | |
1127 | codec->ac97 = NULL; | |
1128 | mutex_unlock(&codec->mutex); | |
1129 | return -ENOMEM; | |
1130 | } | |
1131 | ||
1132 | codec->ac97->bus->ops = ops; | |
1133 | codec->ac97->num = num; | |
1134 | mutex_unlock(&codec->mutex); | |
1135 | return 0; | |
1136 | } | |
1137 | EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec); | |
1138 | ||
1139 | /** | |
1140 | * snd_soc_free_ac97_codec - free AC97 codec device | |
1141 | * @codec: audio codec | |
1142 | * | |
1143 | * Frees AC97 codec device resources. | |
1144 | */ | |
1145 | void snd_soc_free_ac97_codec(struct snd_soc_codec *codec) | |
1146 | { | |
1147 | mutex_lock(&codec->mutex); | |
1148 | kfree(codec->ac97->bus); | |
1149 | kfree(codec->ac97); | |
1150 | codec->ac97 = NULL; | |
1151 | mutex_unlock(&codec->mutex); | |
1152 | } | |
1153 | EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); | |
1154 | ||
1155 | /** | |
1156 | * snd_soc_update_bits - update codec register bits | |
1157 | * @codec: audio codec | |
1158 | * @reg: codec register | |
1159 | * @mask: register mask | |
1160 | * @value: new value | |
1161 | * | |
1162 | * Writes new register value. | |
1163 | * | |
1164 | * Returns 1 for change else 0. | |
1165 | */ | |
1166 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, | |
1167 | unsigned short mask, unsigned short value) | |
1168 | { | |
1169 | int change; | |
1170 | unsigned short old, new; | |
1171 | ||
1172 | mutex_lock(&io_mutex); | |
1173 | old = snd_soc_read(codec, reg); | |
1174 | new = (old & ~mask) | value; | |
1175 | change = old != new; | |
1176 | if (change) | |
1177 | snd_soc_write(codec, reg, new); | |
1178 | ||
1179 | mutex_unlock(&io_mutex); | |
1180 | return change; | |
1181 | } | |
1182 | EXPORT_SYMBOL_GPL(snd_soc_update_bits); | |
1183 | ||
1184 | /** | |
1185 | * snd_soc_test_bits - test register for change | |
1186 | * @codec: audio codec | |
1187 | * @reg: codec register | |
1188 | * @mask: register mask | |
1189 | * @value: new value | |
1190 | * | |
1191 | * Tests a register with a new value and checks if the new value is | |
1192 | * different from the old value. | |
1193 | * | |
1194 | * Returns 1 for change else 0. | |
1195 | */ | |
1196 | int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, | |
1197 | unsigned short mask, unsigned short value) | |
1198 | { | |
1199 | int change; | |
1200 | unsigned short old, new; | |
1201 | ||
1202 | mutex_lock(&io_mutex); | |
1203 | old = snd_soc_read(codec, reg); | |
1204 | new = (old & ~mask) | value; | |
1205 | change = old != new; | |
1206 | mutex_unlock(&io_mutex); | |
1207 | ||
1208 | return change; | |
1209 | } | |
1210 | EXPORT_SYMBOL_GPL(snd_soc_test_bits); | |
1211 | ||
db2a4165 FM |
1212 | /** |
1213 | * snd_soc_new_pcms - create new sound card and pcms | |
1214 | * @socdev: the SoC audio device | |
1215 | * | |
1216 | * Create a new sound card based upon the codec and interface pcms. | |
1217 | * | |
1218 | * Returns 0 for success, else error. | |
1219 | */ | |
bc7320c5 | 1220 | int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid) |
db2a4165 FM |
1221 | { |
1222 | struct snd_soc_codec *codec = socdev->codec; | |
1223 | struct snd_soc_machine *machine = socdev->machine; | |
1224 | int ret = 0, i; | |
1225 | ||
1226 | mutex_lock(&codec->mutex); | |
1227 | ||
1228 | /* register a sound card */ | |
1229 | codec->card = snd_card_new(idx, xid, codec->owner, 0); | |
1230 | if (!codec->card) { | |
1231 | printk(KERN_ERR "asoc: can't create sound card for codec %s\n", | |
1232 | codec->name); | |
1233 | mutex_unlock(&codec->mutex); | |
1234 | return -ENODEV; | |
1235 | } | |
1236 | ||
1237 | codec->card->dev = socdev->dev; | |
1238 | codec->card->private_data = codec; | |
1239 | strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver)); | |
1240 | ||
1241 | /* create the pcms */ | |
3ff3f64b | 1242 | for (i = 0; i < machine->num_links; i++) { |
db2a4165 FM |
1243 | ret = soc_new_pcm(socdev, &machine->dai_link[i], i); |
1244 | if (ret < 0) { | |
1245 | printk(KERN_ERR "asoc: can't create pcm %s\n", | |
1246 | machine->dai_link[i].stream_name); | |
1247 | mutex_unlock(&codec->mutex); | |
1248 | return ret; | |
1249 | } | |
1250 | } | |
1251 | ||
1252 | mutex_unlock(&codec->mutex); | |
1253 | return ret; | |
1254 | } | |
1255 | EXPORT_SYMBOL_GPL(snd_soc_new_pcms); | |
1256 | ||
1257 | /** | |
1258 | * snd_soc_register_card - register sound card | |
1259 | * @socdev: the SoC audio device | |
1260 | * | |
1261 | * Register a SoC sound card. Also registers an AC97 device if the | |
1262 | * codec is AC97 for ad hoc devices. | |
1263 | * | |
1264 | * Returns 0 for success, else error. | |
1265 | */ | |
1266 | int snd_soc_register_card(struct snd_soc_device *socdev) | |
1267 | { | |
1268 | struct snd_soc_codec *codec = socdev->codec; | |
1269 | struct snd_soc_machine *machine = socdev->machine; | |
12e74f7d | 1270 | int ret = 0, i, ac97 = 0, err = 0; |
db2a4165 | 1271 | |
3ff3f64b | 1272 | for (i = 0; i < machine->num_links; i++) { |
12e74f7d LG |
1273 | if (socdev->machine->dai_link[i].init) { |
1274 | err = socdev->machine->dai_link[i].init(codec); | |
1275 | if (err < 0) { | |
1276 | printk(KERN_ERR "asoc: failed to init %s\n", | |
1277 | socdev->machine->dai_link[i].stream_name); | |
1278 | continue; | |
1279 | } | |
1280 | } | |
3ff3f64b | 1281 | if (socdev->machine->dai_link[i].codec_dai->type == |
a68660e0 | 1282 | SND_SOC_DAI_AC97_BUS) |
db2a4165 FM |
1283 | ac97 = 1; |
1284 | } | |
1285 | snprintf(codec->card->shortname, sizeof(codec->card->shortname), | |
1286 | "%s", machine->name); | |
1287 | snprintf(codec->card->longname, sizeof(codec->card->longname), | |
1288 | "%s (%s)", machine->name, codec->name); | |
1289 | ||
1290 | ret = snd_card_register(codec->card); | |
1291 | if (ret < 0) { | |
3ff3f64b | 1292 | printk(KERN_ERR "asoc: failed to register soundcard for %s\n", |
db2a4165 | 1293 | codec->name); |
12e74f7d | 1294 | goto out; |
db2a4165 FM |
1295 | } |
1296 | ||
08c8efe6 | 1297 | mutex_lock(&codec->mutex); |
db2a4165 | 1298 | #ifdef CONFIG_SND_SOC_AC97_BUS |
12e74f7d LG |
1299 | if (ac97) { |
1300 | ret = soc_ac97_dev_register(codec); | |
1301 | if (ret < 0) { | |
1302 | printk(KERN_ERR "asoc: AC97 device register failed\n"); | |
1303 | snd_card_free(codec->card); | |
08c8efe6 | 1304 | mutex_unlock(&codec->mutex); |
12e74f7d LG |
1305 | goto out; |
1306 | } | |
1307 | } | |
db2a4165 FM |
1308 | #endif |
1309 | ||
12e74f7d LG |
1310 | err = snd_soc_dapm_sys_add(socdev->dev); |
1311 | if (err < 0) | |
1312 | printk(KERN_WARNING "asoc: failed to add dapm sysfs entries\n"); | |
1313 | ||
1314 | err = device_create_file(socdev->dev, &dev_attr_codec_reg); | |
1315 | if (err < 0) | |
3ff3f64b | 1316 | printk(KERN_WARNING "asoc: failed to add codec sysfs files\n"); |
08c8efe6 | 1317 | |
12ef193d | 1318 | soc_init_debugfs(socdev); |
db2a4165 | 1319 | mutex_unlock(&codec->mutex); |
08c8efe6 MB |
1320 | |
1321 | out: | |
db2a4165 FM |
1322 | return ret; |
1323 | } | |
1324 | EXPORT_SYMBOL_GPL(snd_soc_register_card); | |
1325 | ||
1326 | /** | |
1327 | * snd_soc_free_pcms - free sound card and pcms | |
1328 | * @socdev: the SoC audio device | |
1329 | * | |
1330 | * Frees sound card and pcms associated with the socdev. | |
1331 | * Also unregister the codec if it is an AC97 device. | |
1332 | */ | |
1333 | void snd_soc_free_pcms(struct snd_soc_device *socdev) | |
1334 | { | |
1335 | struct snd_soc_codec *codec = socdev->codec; | |
a68660e0 | 1336 | #ifdef CONFIG_SND_SOC_AC97_BUS |
3c4b266f | 1337 | struct snd_soc_dai *codec_dai; |
a68660e0 LG |
1338 | int i; |
1339 | #endif | |
db2a4165 FM |
1340 | |
1341 | mutex_lock(&codec->mutex); | |
12ef193d | 1342 | soc_cleanup_debugfs(socdev); |
db2a4165 | 1343 | #ifdef CONFIG_SND_SOC_AC97_BUS |
3ff3f64b | 1344 | for (i = 0; i < codec->num_dai; i++) { |
a68660e0 LG |
1345 | codec_dai = &codec->dai[i]; |
1346 | if (codec_dai->type == SND_SOC_DAI_AC97_BUS && codec->ac97) { | |
1347 | soc_ac97_dev_unregister(codec); | |
1348 | goto free_card; | |
1349 | } | |
1350 | } | |
1351 | free_card: | |
db2a4165 FM |
1352 | #endif |
1353 | ||
1354 | if (codec->card) | |
1355 | snd_card_free(codec->card); | |
1356 | device_remove_file(socdev->dev, &dev_attr_codec_reg); | |
1357 | mutex_unlock(&codec->mutex); | |
1358 | } | |
1359 | EXPORT_SYMBOL_GPL(snd_soc_free_pcms); | |
1360 | ||
1361 | /** | |
1362 | * snd_soc_set_runtime_hwparams - set the runtime hardware parameters | |
1363 | * @substream: the pcm substream | |
1364 | * @hw: the hardware parameters | |
1365 | * | |
1366 | * Sets the substream runtime hardware parameters. | |
1367 | */ | |
1368 | int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, | |
1369 | const struct snd_pcm_hardware *hw) | |
1370 | { | |
1371 | struct snd_pcm_runtime *runtime = substream->runtime; | |
1372 | runtime->hw.info = hw->info; | |
1373 | runtime->hw.formats = hw->formats; | |
1374 | runtime->hw.period_bytes_min = hw->period_bytes_min; | |
1375 | runtime->hw.period_bytes_max = hw->period_bytes_max; | |
1376 | runtime->hw.periods_min = hw->periods_min; | |
1377 | runtime->hw.periods_max = hw->periods_max; | |
1378 | runtime->hw.buffer_bytes_max = hw->buffer_bytes_max; | |
1379 | runtime->hw.fifo_size = hw->fifo_size; | |
1380 | return 0; | |
1381 | } | |
1382 | EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams); | |
1383 | ||
1384 | /** | |
1385 | * snd_soc_cnew - create new control | |
1386 | * @_template: control template | |
1387 | * @data: control private data | |
1388 | * @lnng_name: control long name | |
1389 | * | |
1390 | * Create a new mixer control from a template control. | |
1391 | * | |
1392 | * Returns 0 for success, else error. | |
1393 | */ | |
1394 | struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, | |
1395 | void *data, char *long_name) | |
1396 | { | |
1397 | struct snd_kcontrol_new template; | |
1398 | ||
1399 | memcpy(&template, _template, sizeof(template)); | |
1400 | if (long_name) | |
1401 | template.name = long_name; | |
db2a4165 FM |
1402 | template.index = 0; |
1403 | ||
1404 | return snd_ctl_new1(&template, data); | |
1405 | } | |
1406 | EXPORT_SYMBOL_GPL(snd_soc_cnew); | |
1407 | ||
1408 | /** | |
1409 | * snd_soc_info_enum_double - enumerated double mixer info callback | |
1410 | * @kcontrol: mixer control | |
1411 | * @uinfo: control element information | |
1412 | * | |
1413 | * Callback to provide information about a double enumerated | |
1414 | * mixer control. | |
1415 | * | |
1416 | * Returns 0 for success. | |
1417 | */ | |
1418 | int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, | |
1419 | struct snd_ctl_elem_info *uinfo) | |
1420 | { | |
1421 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | |
1422 | ||
1423 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
1424 | uinfo->count = e->shift_l == e->shift_r ? 1 : 2; | |
f8ba0b7b | 1425 | uinfo->value.enumerated.items = e->max; |
db2a4165 | 1426 | |
f8ba0b7b JS |
1427 | if (uinfo->value.enumerated.item > e->max - 1) |
1428 | uinfo->value.enumerated.item = e->max - 1; | |
db2a4165 FM |
1429 | strcpy(uinfo->value.enumerated.name, |
1430 | e->texts[uinfo->value.enumerated.item]); | |
1431 | return 0; | |
1432 | } | |
1433 | EXPORT_SYMBOL_GPL(snd_soc_info_enum_double); | |
1434 | ||
1435 | /** | |
1436 | * snd_soc_get_enum_double - enumerated double mixer get callback | |
1437 | * @kcontrol: mixer control | |
1438 | * @uinfo: control element information | |
1439 | * | |
1440 | * Callback to get the value of a double enumerated mixer. | |
1441 | * | |
1442 | * Returns 0 for success. | |
1443 | */ | |
1444 | int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, | |
1445 | struct snd_ctl_elem_value *ucontrol) | |
1446 | { | |
1447 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | |
1448 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | |
1449 | unsigned short val, bitmask; | |
1450 | ||
f8ba0b7b | 1451 | for (bitmask = 1; bitmask < e->max; bitmask <<= 1) |
db2a4165 FM |
1452 | ; |
1453 | val = snd_soc_read(codec, e->reg); | |
3ff3f64b MB |
1454 | ucontrol->value.enumerated.item[0] |
1455 | = (val >> e->shift_l) & (bitmask - 1); | |
db2a4165 FM |
1456 | if (e->shift_l != e->shift_r) |
1457 | ucontrol->value.enumerated.item[1] = | |
1458 | (val >> e->shift_r) & (bitmask - 1); | |
1459 | ||
1460 | return 0; | |
1461 | } | |
1462 | EXPORT_SYMBOL_GPL(snd_soc_get_enum_double); | |
1463 | ||
1464 | /** | |
1465 | * snd_soc_put_enum_double - enumerated double mixer put callback | |
1466 | * @kcontrol: mixer control | |
1467 | * @uinfo: control element information | |
1468 | * | |
1469 | * Callback to set the value of a double enumerated mixer. | |
1470 | * | |
1471 | * Returns 0 for success. | |
1472 | */ | |
1473 | int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, | |
1474 | struct snd_ctl_elem_value *ucontrol) | |
1475 | { | |
1476 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | |
1477 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | |
1478 | unsigned short val; | |
1479 | unsigned short mask, bitmask; | |
1480 | ||
f8ba0b7b | 1481 | for (bitmask = 1; bitmask < e->max; bitmask <<= 1) |
db2a4165 | 1482 | ; |
f8ba0b7b | 1483 | if (ucontrol->value.enumerated.item[0] > e->max - 1) |
db2a4165 FM |
1484 | return -EINVAL; |
1485 | val = ucontrol->value.enumerated.item[0] << e->shift_l; | |
1486 | mask = (bitmask - 1) << e->shift_l; | |
1487 | if (e->shift_l != e->shift_r) { | |
f8ba0b7b | 1488 | if (ucontrol->value.enumerated.item[1] > e->max - 1) |
db2a4165 FM |
1489 | return -EINVAL; |
1490 | val |= ucontrol->value.enumerated.item[1] << e->shift_r; | |
1491 | mask |= (bitmask - 1) << e->shift_r; | |
1492 | } | |
1493 | ||
1494 | return snd_soc_update_bits(codec, e->reg, mask, val); | |
1495 | } | |
1496 | EXPORT_SYMBOL_GPL(snd_soc_put_enum_double); | |
1497 | ||
1498 | /** | |
1499 | * snd_soc_info_enum_ext - external enumerated single mixer info callback | |
1500 | * @kcontrol: mixer control | |
1501 | * @uinfo: control element information | |
1502 | * | |
1503 | * Callback to provide information about an external enumerated | |
1504 | * single mixer. | |
1505 | * | |
1506 | * Returns 0 for success. | |
1507 | */ | |
1508 | int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol, | |
1509 | struct snd_ctl_elem_info *uinfo) | |
1510 | { | |
1511 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | |
1512 | ||
1513 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
1514 | uinfo->count = 1; | |
f8ba0b7b | 1515 | uinfo->value.enumerated.items = e->max; |
db2a4165 | 1516 | |
f8ba0b7b JS |
1517 | if (uinfo->value.enumerated.item > e->max - 1) |
1518 | uinfo->value.enumerated.item = e->max - 1; | |
db2a4165 FM |
1519 | strcpy(uinfo->value.enumerated.name, |
1520 | e->texts[uinfo->value.enumerated.item]); | |
1521 | return 0; | |
1522 | } | |
1523 | EXPORT_SYMBOL_GPL(snd_soc_info_enum_ext); | |
1524 | ||
1525 | /** | |
1526 | * snd_soc_info_volsw_ext - external single mixer info callback | |
1527 | * @kcontrol: mixer control | |
1528 | * @uinfo: control element information | |
1529 | * | |
1530 | * Callback to provide information about a single external mixer control. | |
1531 | * | |
1532 | * Returns 0 for success. | |
1533 | */ | |
1534 | int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, | |
1535 | struct snd_ctl_elem_info *uinfo) | |
1536 | { | |
a7a4ac86 PZ |
1537 | int max = kcontrol->private_value; |
1538 | ||
1539 | if (max == 1) | |
1540 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | |
1541 | else | |
1542 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | |
db2a4165 | 1543 | |
db2a4165 FM |
1544 | uinfo->count = 1; |
1545 | uinfo->value.integer.min = 0; | |
a7a4ac86 | 1546 | uinfo->value.integer.max = max; |
db2a4165 FM |
1547 | return 0; |
1548 | } | |
1549 | EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext); | |
1550 | ||
db2a4165 FM |
1551 | /** |
1552 | * snd_soc_info_volsw - single mixer info callback | |
1553 | * @kcontrol: mixer control | |
1554 | * @uinfo: control element information | |
1555 | * | |
1556 | * Callback to provide information about a single mixer control. | |
1557 | * | |
1558 | * Returns 0 for success. | |
1559 | */ | |
1560 | int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, | |
1561 | struct snd_ctl_elem_info *uinfo) | |
1562 | { | |
4eaa9819 JS |
1563 | struct soc_mixer_control *mc = |
1564 | (struct soc_mixer_control *)kcontrol->private_value; | |
1565 | int max = mc->max; | |
815ecf8d JS |
1566 | unsigned int shift = mc->min; |
1567 | unsigned int rshift = mc->rshift; | |
db2a4165 | 1568 | |
a7a4ac86 PZ |
1569 | if (max == 1) |
1570 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | |
1571 | else | |
1572 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | |
1573 | ||
db2a4165 FM |
1574 | uinfo->count = shift == rshift ? 1 : 2; |
1575 | uinfo->value.integer.min = 0; | |
a7a4ac86 | 1576 | uinfo->value.integer.max = max; |
db2a4165 FM |
1577 | return 0; |
1578 | } | |
1579 | EXPORT_SYMBOL_GPL(snd_soc_info_volsw); | |
1580 | ||
1581 | /** | |
1582 | * snd_soc_get_volsw - single mixer get callback | |
1583 | * @kcontrol: mixer control | |
1584 | * @uinfo: control element information | |
1585 | * | |
1586 | * Callback to get the value of a single mixer control. | |
1587 | * | |
1588 | * Returns 0 for success. | |
1589 | */ | |
1590 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, | |
1591 | struct snd_ctl_elem_value *ucontrol) | |
1592 | { | |
4eaa9819 JS |
1593 | struct soc_mixer_control *mc = |
1594 | (struct soc_mixer_control *)kcontrol->private_value; | |
db2a4165 | 1595 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
815ecf8d JS |
1596 | unsigned int reg = mc->reg; |
1597 | unsigned int shift = mc->shift; | |
1598 | unsigned int rshift = mc->rshift; | |
4eaa9819 | 1599 | int max = mc->max; |
815ecf8d JS |
1600 | unsigned int mask = (1 << fls(max)) - 1; |
1601 | unsigned int invert = mc->invert; | |
db2a4165 FM |
1602 | |
1603 | ucontrol->value.integer.value[0] = | |
1604 | (snd_soc_read(codec, reg) >> shift) & mask; | |
1605 | if (shift != rshift) | |
1606 | ucontrol->value.integer.value[1] = | |
1607 | (snd_soc_read(codec, reg) >> rshift) & mask; | |
1608 | if (invert) { | |
1609 | ucontrol->value.integer.value[0] = | |
a7a4ac86 | 1610 | max - ucontrol->value.integer.value[0]; |
db2a4165 FM |
1611 | if (shift != rshift) |
1612 | ucontrol->value.integer.value[1] = | |
a7a4ac86 | 1613 | max - ucontrol->value.integer.value[1]; |
db2a4165 FM |
1614 | } |
1615 | ||
1616 | return 0; | |
1617 | } | |
1618 | EXPORT_SYMBOL_GPL(snd_soc_get_volsw); | |
1619 | ||
1620 | /** | |
1621 | * snd_soc_put_volsw - single mixer put callback | |
1622 | * @kcontrol: mixer control | |
1623 | * @uinfo: control element information | |
1624 | * | |
1625 | * Callback to set the value of a single mixer control. | |
1626 | * | |
1627 | * Returns 0 for success. | |
1628 | */ | |
1629 | int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, | |
1630 | struct snd_ctl_elem_value *ucontrol) | |
1631 | { | |
4eaa9819 JS |
1632 | struct soc_mixer_control *mc = |
1633 | (struct soc_mixer_control *)kcontrol->private_value; | |
db2a4165 | 1634 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
815ecf8d JS |
1635 | unsigned int reg = mc->reg; |
1636 | unsigned int shift = mc->shift; | |
1637 | unsigned int rshift = mc->rshift; | |
4eaa9819 | 1638 | int max = mc->max; |
815ecf8d JS |
1639 | unsigned int mask = (1 << fls(max)) - 1; |
1640 | unsigned int invert = mc->invert; | |
db2a4165 FM |
1641 | unsigned short val, val2, val_mask; |
1642 | ||
1643 | val = (ucontrol->value.integer.value[0] & mask); | |
1644 | if (invert) | |
a7a4ac86 | 1645 | val = max - val; |
db2a4165 FM |
1646 | val_mask = mask << shift; |
1647 | val = val << shift; | |
1648 | if (shift != rshift) { | |
1649 | val2 = (ucontrol->value.integer.value[1] & mask); | |
1650 | if (invert) | |
a7a4ac86 | 1651 | val2 = max - val2; |
db2a4165 FM |
1652 | val_mask |= mask << rshift; |
1653 | val |= val2 << rshift; | |
1654 | } | |
a7a4ac86 | 1655 | return snd_soc_update_bits(codec, reg, val_mask, val); |
db2a4165 FM |
1656 | } |
1657 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw); | |
1658 | ||
1659 | /** | |
1660 | * snd_soc_info_volsw_2r - double mixer info callback | |
1661 | * @kcontrol: mixer control | |
1662 | * @uinfo: control element information | |
1663 | * | |
1664 | * Callback to provide information about a double mixer control that | |
1665 | * spans 2 codec registers. | |
1666 | * | |
1667 | * Returns 0 for success. | |
1668 | */ | |
1669 | int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol, | |
1670 | struct snd_ctl_elem_info *uinfo) | |
1671 | { | |
4eaa9819 JS |
1672 | struct soc_mixer_control *mc = |
1673 | (struct soc_mixer_control *)kcontrol->private_value; | |
1674 | int max = mc->max; | |
a7a4ac86 PZ |
1675 | |
1676 | if (max == 1) | |
1677 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | |
1678 | else | |
1679 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | |
db2a4165 | 1680 | |
db2a4165 FM |
1681 | uinfo->count = 2; |
1682 | uinfo->value.integer.min = 0; | |
a7a4ac86 | 1683 | uinfo->value.integer.max = max; |
db2a4165 FM |
1684 | return 0; |
1685 | } | |
1686 | EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r); | |
1687 | ||
1688 | /** | |
1689 | * snd_soc_get_volsw_2r - double mixer get callback | |
1690 | * @kcontrol: mixer control | |
1691 | * @uinfo: control element information | |
1692 | * | |
1693 | * Callback to get the value of a double mixer control that spans 2 registers. | |
1694 | * | |
1695 | * Returns 0 for success. | |
1696 | */ | |
1697 | int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol, | |
1698 | struct snd_ctl_elem_value *ucontrol) | |
1699 | { | |
4eaa9819 JS |
1700 | struct soc_mixer_control *mc = |
1701 | (struct soc_mixer_control *)kcontrol->private_value; | |
db2a4165 | 1702 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
815ecf8d JS |
1703 | unsigned int reg = mc->reg; |
1704 | unsigned int reg2 = mc->rreg; | |
1705 | unsigned int shift = mc->shift; | |
4eaa9819 | 1706 | int max = mc->max; |
815ecf8d JS |
1707 | unsigned int mask = (1<<fls(max))-1; |
1708 | unsigned int invert = mc->invert; | |
db2a4165 FM |
1709 | |
1710 | ucontrol->value.integer.value[0] = | |
1711 | (snd_soc_read(codec, reg) >> shift) & mask; | |
1712 | ucontrol->value.integer.value[1] = | |
1713 | (snd_soc_read(codec, reg2) >> shift) & mask; | |
1714 | if (invert) { | |
1715 | ucontrol->value.integer.value[0] = | |
a7a4ac86 | 1716 | max - ucontrol->value.integer.value[0]; |
db2a4165 | 1717 | ucontrol->value.integer.value[1] = |
a7a4ac86 | 1718 | max - ucontrol->value.integer.value[1]; |
db2a4165 FM |
1719 | } |
1720 | ||
1721 | return 0; | |
1722 | } | |
1723 | EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r); | |
1724 | ||
1725 | /** | |
1726 | * snd_soc_put_volsw_2r - double mixer set callback | |
1727 | * @kcontrol: mixer control | |
1728 | * @uinfo: control element information | |
1729 | * | |
1730 | * Callback to set the value of a double mixer control that spans 2 registers. | |
1731 | * | |
1732 | * Returns 0 for success. | |
1733 | */ | |
1734 | int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol, | |
1735 | struct snd_ctl_elem_value *ucontrol) | |
1736 | { | |
4eaa9819 JS |
1737 | struct soc_mixer_control *mc = |
1738 | (struct soc_mixer_control *)kcontrol->private_value; | |
db2a4165 | 1739 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
815ecf8d JS |
1740 | unsigned int reg = mc->reg; |
1741 | unsigned int reg2 = mc->rreg; | |
1742 | unsigned int shift = mc->shift; | |
4eaa9819 | 1743 | int max = mc->max; |
815ecf8d JS |
1744 | unsigned int mask = (1 << fls(max)) - 1; |
1745 | unsigned int invert = mc->invert; | |
db2a4165 FM |
1746 | int err; |
1747 | unsigned short val, val2, val_mask; | |
1748 | ||
1749 | val_mask = mask << shift; | |
1750 | val = (ucontrol->value.integer.value[0] & mask); | |
1751 | val2 = (ucontrol->value.integer.value[1] & mask); | |
1752 | ||
1753 | if (invert) { | |
a7a4ac86 PZ |
1754 | val = max - val; |
1755 | val2 = max - val2; | |
db2a4165 FM |
1756 | } |
1757 | ||
1758 | val = val << shift; | |
1759 | val2 = val2 << shift; | |
1760 | ||
3ff3f64b MB |
1761 | err = snd_soc_update_bits(codec, reg, val_mask, val); |
1762 | if (err < 0) | |
db2a4165 FM |
1763 | return err; |
1764 | ||
1765 | err = snd_soc_update_bits(codec, reg2, val_mask, val2); | |
1766 | return err; | |
1767 | } | |
1768 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r); | |
1769 | ||
e13ac2e9 MB |
1770 | /** |
1771 | * snd_soc_info_volsw_s8 - signed mixer info callback | |
1772 | * @kcontrol: mixer control | |
1773 | * @uinfo: control element information | |
1774 | * | |
1775 | * Callback to provide information about a signed mixer control. | |
1776 | * | |
1777 | * Returns 0 for success. | |
1778 | */ | |
1779 | int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, | |
1780 | struct snd_ctl_elem_info *uinfo) | |
1781 | { | |
4eaa9819 JS |
1782 | struct soc_mixer_control *mc = |
1783 | (struct soc_mixer_control *)kcontrol->private_value; | |
1784 | int max = mc->max; | |
1785 | int min = mc->min; | |
e13ac2e9 MB |
1786 | |
1787 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | |
1788 | uinfo->count = 2; | |
1789 | uinfo->value.integer.min = 0; | |
1790 | uinfo->value.integer.max = max-min; | |
1791 | return 0; | |
1792 | } | |
1793 | EXPORT_SYMBOL_GPL(snd_soc_info_volsw_s8); | |
1794 | ||
1795 | /** | |
1796 | * snd_soc_get_volsw_s8 - signed mixer get callback | |
1797 | * @kcontrol: mixer control | |
1798 | * @uinfo: control element information | |
1799 | * | |
1800 | * Callback to get the value of a signed mixer control. | |
1801 | * | |
1802 | * Returns 0 for success. | |
1803 | */ | |
1804 | int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, | |
1805 | struct snd_ctl_elem_value *ucontrol) | |
1806 | { | |
4eaa9819 JS |
1807 | struct soc_mixer_control *mc = |
1808 | (struct soc_mixer_control *)kcontrol->private_value; | |
e13ac2e9 | 1809 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
815ecf8d | 1810 | unsigned int reg = mc->reg; |
4eaa9819 | 1811 | int min = mc->min; |
e13ac2e9 MB |
1812 | int val = snd_soc_read(codec, reg); |
1813 | ||
1814 | ucontrol->value.integer.value[0] = | |
1815 | ((signed char)(val & 0xff))-min; | |
1816 | ucontrol->value.integer.value[1] = | |
1817 | ((signed char)((val >> 8) & 0xff))-min; | |
1818 | return 0; | |
1819 | } | |
1820 | EXPORT_SYMBOL_GPL(snd_soc_get_volsw_s8); | |
1821 | ||
1822 | /** | |
1823 | * snd_soc_put_volsw_sgn - signed mixer put callback | |
1824 | * @kcontrol: mixer control | |
1825 | * @uinfo: control element information | |
1826 | * | |
1827 | * Callback to set the value of a signed mixer control. | |
1828 | * | |
1829 | * Returns 0 for success. | |
1830 | */ | |
1831 | int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol, | |
1832 | struct snd_ctl_elem_value *ucontrol) | |
1833 | { | |
4eaa9819 JS |
1834 | struct soc_mixer_control *mc = |
1835 | (struct soc_mixer_control *)kcontrol->private_value; | |
e13ac2e9 | 1836 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
815ecf8d | 1837 | unsigned int reg = mc->reg; |
4eaa9819 | 1838 | int min = mc->min; |
e13ac2e9 MB |
1839 | unsigned short val; |
1840 | ||
1841 | val = (ucontrol->value.integer.value[0]+min) & 0xff; | |
1842 | val |= ((ucontrol->value.integer.value[1]+min) & 0xff) << 8; | |
1843 | ||
1844 | return snd_soc_update_bits(codec, reg, 0xffff, val); | |
1845 | } | |
1846 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8); | |
1847 | ||
8c6529db LG |
1848 | /** |
1849 | * snd_soc_dai_set_sysclk - configure DAI system or master clock. | |
1850 | * @dai: DAI | |
1851 | * @clk_id: DAI specific clock ID | |
1852 | * @freq: new clock frequency in Hz | |
1853 | * @dir: new clock direction - input/output. | |
1854 | * | |
1855 | * Configures the DAI master (MCLK) or system (SYSCLK) clocking. | |
1856 | */ | |
1857 | int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, | |
1858 | unsigned int freq, int dir) | |
1859 | { | |
1860 | if (dai->dai_ops.set_sysclk) | |
1861 | return dai->dai_ops.set_sysclk(dai, clk_id, freq, dir); | |
1862 | else | |
1863 | return -EINVAL; | |
1864 | } | |
1865 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk); | |
1866 | ||
1867 | /** | |
1868 | * snd_soc_dai_set_clkdiv - configure DAI clock dividers. | |
1869 | * @dai: DAI | |
1870 | * @clk_id: DAI specific clock divider ID | |
1871 | * @div: new clock divisor. | |
1872 | * | |
1873 | * Configures the clock dividers. This is used to derive the best DAI bit and | |
1874 | * frame clocks from the system or master clock. It's best to set the DAI bit | |
1875 | * and frame clocks as low as possible to save system power. | |
1876 | */ | |
1877 | int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, | |
1878 | int div_id, int div) | |
1879 | { | |
1880 | if (dai->dai_ops.set_clkdiv) | |
1881 | return dai->dai_ops.set_clkdiv(dai, div_id, div); | |
1882 | else | |
1883 | return -EINVAL; | |
1884 | } | |
1885 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv); | |
1886 | ||
1887 | /** | |
1888 | * snd_soc_dai_set_pll - configure DAI PLL. | |
1889 | * @dai: DAI | |
1890 | * @pll_id: DAI specific PLL ID | |
1891 | * @freq_in: PLL input clock frequency in Hz | |
1892 | * @freq_out: requested PLL output clock frequency in Hz | |
1893 | * | |
1894 | * Configures and enables PLL to generate output clock based on input clock. | |
1895 | */ | |
1896 | int snd_soc_dai_set_pll(struct snd_soc_dai *dai, | |
1897 | int pll_id, unsigned int freq_in, unsigned int freq_out) | |
1898 | { | |
1899 | if (dai->dai_ops.set_pll) | |
1900 | return dai->dai_ops.set_pll(dai, pll_id, freq_in, freq_out); | |
1901 | else | |
1902 | return -EINVAL; | |
1903 | } | |
1904 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll); | |
1905 | ||
1906 | /** | |
1907 | * snd_soc_dai_set_fmt - configure DAI hardware audio format. | |
1908 | * @dai: DAI | |
1909 | * @clk_id: DAI specific clock ID | |
1910 | * @fmt: SND_SOC_DAIFMT_ format value. | |
1911 | * | |
1912 | * Configures the DAI hardware format and clocking. | |
1913 | */ | |
1914 | int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |
1915 | { | |
1916 | if (dai->dai_ops.set_fmt) | |
1917 | return dai->dai_ops.set_fmt(dai, fmt); | |
1918 | else | |
1919 | return -EINVAL; | |
1920 | } | |
1921 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt); | |
1922 | ||
1923 | /** | |
1924 | * snd_soc_dai_set_tdm_slot - configure DAI TDM. | |
1925 | * @dai: DAI | |
1926 | * @mask: DAI specific mask representing used slots. | |
1927 | * @slots: Number of slots in use. | |
1928 | * | |
1929 | * Configures a DAI for TDM operation. Both mask and slots are codec and DAI | |
1930 | * specific. | |
1931 | */ | |
1932 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, | |
1933 | unsigned int mask, int slots) | |
1934 | { | |
1935 | if (dai->dai_ops.set_sysclk) | |
1936 | return dai->dai_ops.set_tdm_slot(dai, mask, slots); | |
1937 | else | |
1938 | return -EINVAL; | |
1939 | } | |
1940 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot); | |
1941 | ||
1942 | /** | |
1943 | * snd_soc_dai_set_tristate - configure DAI system or master clock. | |
1944 | * @dai: DAI | |
1945 | * @tristate: tristate enable | |
1946 | * | |
1947 | * Tristates the DAI so that others can use it. | |
1948 | */ | |
1949 | int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate) | |
1950 | { | |
1951 | if (dai->dai_ops.set_sysclk) | |
1952 | return dai->dai_ops.set_tristate(dai, tristate); | |
1953 | else | |
1954 | return -EINVAL; | |
1955 | } | |
1956 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate); | |
1957 | ||
1958 | /** | |
1959 | * snd_soc_dai_digital_mute - configure DAI system or master clock. | |
1960 | * @dai: DAI | |
1961 | * @mute: mute enable | |
1962 | * | |
1963 | * Mutes the DAI DAC. | |
1964 | */ | |
1965 | int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute) | |
1966 | { | |
1967 | if (dai->dai_ops.digital_mute) | |
1968 | return dai->dai_ops.digital_mute(dai, mute); | |
1969 | else | |
1970 | return -EINVAL; | |
1971 | } | |
1972 | EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute); | |
1973 | ||
db2a4165 FM |
1974 | static int __devinit snd_soc_init(void) |
1975 | { | |
1976 | printk(KERN_INFO "ASoC version %s\n", SND_SOC_VERSION); | |
1977 | return platform_driver_register(&soc_driver); | |
1978 | } | |
1979 | ||
1980 | static void snd_soc_exit(void) | |
1981 | { | |
3ff3f64b | 1982 | platform_driver_unregister(&soc_driver); |
db2a4165 FM |
1983 | } |
1984 | ||
1985 | module_init(snd_soc_init); | |
1986 | module_exit(snd_soc_exit); | |
1987 | ||
1988 | /* Module information */ | |
d331124d | 1989 | MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk"); |
db2a4165 FM |
1990 | MODULE_DESCRIPTION("ALSA SoC Core"); |
1991 | MODULE_LICENSE("GPL"); | |
8b45a209 | 1992 | MODULE_ALIAS("platform:soc-audio"); |