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