2 * soc-core.c -- ALSA SoC Audio Layer
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Copyright 2005 Openedhand Ltd.
6 * Copyright (C) 2010 Slimlogic Ltd.
7 * Copyright (C) 2010 Texas Instruments Inc.
9 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
10 * with code, comments and ideas from :-
11 * Richard Purdie <richard@openedhand.com>
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
19 * o Add hw rules to enforce rates, etc.
20 * o More testing with other codecs/machines.
21 * o Add more codecs and platforms to ensure good API coverage.
22 * o Support TDM on PCM and I2S
25 #include <linux/module.h>
26 #include <linux/moduleparam.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
30 #include <linux/bitops.h>
31 #include <linux/debugfs.h>
32 #include <linux/platform_device.h>
33 #include <linux/slab.h>
34 #include <sound/ac97_codec.h>
35 #include <sound/core.h>
36 #include <sound/jack.h>
37 #include <sound/pcm.h>
38 #include <sound/pcm_params.h>
39 #include <sound/soc.h>
40 #include <sound/initval.h>
42 #define CREATE_TRACE_POINTS
43 #include <trace/events/asoc.h>
47 static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq);
49 #ifdef CONFIG_DEBUG_FS
50 struct dentry *snd_soc_debugfs_root;
51 EXPORT_SYMBOL_GPL(snd_soc_debugfs_root);
54 static DEFINE_MUTEX(client_mutex);
55 static LIST_HEAD(card_list);
56 static LIST_HEAD(dai_list);
57 static LIST_HEAD(platform_list);
58 static LIST_HEAD(codec_list);
60 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
63 * This is a timeout to do a DAPM powerdown after a stream is closed().
64 * It can be used to eliminate pops between different playback streams, e.g.
65 * between two audio tracks.
67 static int pmdown_time = 5000;
68 module_param(pmdown_time, int, 0);
69 MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
71 /* returns the minimum number of bytes needed to represent
72 * a particular given value */
73 static int min_bytes_needed(unsigned long val)
78 for (i = (sizeof val * 8) - 1; i >= 0; --i, ++c)
81 c = (sizeof val * 8) - c;
89 /* fill buf which is 'len' bytes with a formatted
90 * string of the form 'reg: value\n' */
91 static int format_register_str(struct snd_soc_codec *codec,
92 unsigned int reg, char *buf, size_t len)
94 int wordsize = min_bytes_needed(codec->driver->reg_cache_size) * 2;
95 int regsize = codec->driver->reg_word_size * 2;
98 char regbuf[regsize + 1];
100 /* since tmpbuf is allocated on the stack, warn the callers if they
101 * try to abuse this function */
104 /* +2 for ': ' and + 1 for '\n' */
105 if (wordsize + regsize + 2 + 1 != len)
108 ret = snd_soc_read(codec , reg);
110 memset(regbuf, 'X', regsize);
111 regbuf[regsize] = '\0';
113 snprintf(regbuf, regsize + 1, "%.*x", regsize, ret);
116 /* prepare the buffer */
117 snprintf(tmpbuf, len + 1, "%.*x: %s\n", wordsize, reg, regbuf);
118 /* copy it back to the caller without the '\0' */
119 memcpy(buf, tmpbuf, len);
124 /* codec register dump */
125 static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf,
126 size_t count, loff_t pos)
129 int wordsize, regsize;
134 wordsize = min_bytes_needed(codec->driver->reg_cache_size) * 2;
135 regsize = codec->driver->reg_word_size * 2;
137 len = wordsize + regsize + 2 + 1;
139 if (!codec->driver->reg_cache_size)
142 if (codec->driver->reg_cache_step)
143 step = codec->driver->reg_cache_step;
145 for (i = 0; i < codec->driver->reg_cache_size; i += step) {
146 if (codec->readable_register && !codec->readable_register(codec, i))
148 if (codec->driver->display_register) {
149 count += codec->driver->display_register(codec, buf + count,
150 PAGE_SIZE - count, i);
152 /* only support larger than PAGE_SIZE bytes debugfs
153 * entries for the default case */
155 if (total + len >= count - 1)
157 format_register_str(codec, i, buf + total, len);
164 total = min(total, count - 1);
169 static ssize_t codec_reg_show(struct device *dev,
170 struct device_attribute *attr, char *buf)
172 struct snd_soc_pcm_runtime *rtd =
173 container_of(dev, struct snd_soc_pcm_runtime, dev);
175 return soc_codec_reg_show(rtd->codec, buf, PAGE_SIZE, 0);
178 static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
180 static ssize_t pmdown_time_show(struct device *dev,
181 struct device_attribute *attr, char *buf)
183 struct snd_soc_pcm_runtime *rtd =
184 container_of(dev, struct snd_soc_pcm_runtime, dev);
186 return sprintf(buf, "%ld\n", rtd->pmdown_time);
189 static ssize_t pmdown_time_set(struct device *dev,
190 struct device_attribute *attr,
191 const char *buf, size_t count)
193 struct snd_soc_pcm_runtime *rtd =
194 container_of(dev, struct snd_soc_pcm_runtime, dev);
197 ret = strict_strtol(buf, 10, &rtd->pmdown_time);
204 static DEVICE_ATTR(pmdown_time, 0644, pmdown_time_show, pmdown_time_set);
206 #ifdef CONFIG_DEBUG_FS
207 static int codec_reg_open_file(struct inode *inode, struct file *file)
209 file->private_data = inode->i_private;
213 static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf,
214 size_t count, loff_t *ppos)
217 struct snd_soc_codec *codec = file->private_data;
220 if (*ppos < 0 || !count)
223 buf = kmalloc(count, GFP_KERNEL);
227 ret = soc_codec_reg_show(codec, buf, count, *ppos);
229 if (copy_to_user(user_buf, buf, ret)) {
240 static ssize_t codec_reg_write_file(struct file *file,
241 const char __user *user_buf, size_t count, loff_t *ppos)
246 unsigned long reg, value;
248 struct snd_soc_codec *codec = file->private_data;
250 buf_size = min(count, (sizeof(buf)-1));
251 if (copy_from_user(buf, user_buf, buf_size))
255 if (codec->driver->reg_cache_step)
256 step = codec->driver->reg_cache_step;
258 while (*start == ' ')
260 reg = simple_strtoul(start, &start, 16);
261 while (*start == ' ')
263 if (strict_strtoul(start, 16, &value))
266 /* Userspace has been fiddling around behind the kernel's back */
267 add_taint(TAINT_USER);
269 snd_soc_write(codec, reg, value);
273 static const struct file_operations codec_reg_fops = {
274 .open = codec_reg_open_file,
275 .read = codec_reg_read_file,
276 .write = codec_reg_write_file,
277 .llseek = default_llseek,
280 static void soc_init_codec_debugfs(struct snd_soc_codec *codec)
282 struct dentry *debugfs_card_root = codec->card->debugfs_card_root;
284 codec->debugfs_codec_root = debugfs_create_dir(codec->name,
286 if (!codec->debugfs_codec_root) {
288 "ASoC: Failed to create codec debugfs directory\n");
292 debugfs_create_bool("cache_sync", 0444, codec->debugfs_codec_root,
294 debugfs_create_bool("cache_only", 0444, codec->debugfs_codec_root,
297 codec->debugfs_reg = debugfs_create_file("codec_reg", 0644,
298 codec->debugfs_codec_root,
299 codec, &codec_reg_fops);
300 if (!codec->debugfs_reg)
302 "ASoC: Failed to create codec register debugfs file\n");
304 snd_soc_dapm_debugfs_init(&codec->dapm, codec->debugfs_codec_root);
307 static void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec)
309 debugfs_remove_recursive(codec->debugfs_codec_root);
312 static ssize_t codec_list_read_file(struct file *file, char __user *user_buf,
313 size_t count, loff_t *ppos)
315 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
316 ssize_t len, ret = 0;
317 struct snd_soc_codec *codec;
322 list_for_each_entry(codec, &codec_list, list) {
323 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
327 if (ret > PAGE_SIZE) {
334 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
341 static const struct file_operations codec_list_fops = {
342 .read = codec_list_read_file,
343 .llseek = default_llseek,/* read accesses f_pos */
346 static ssize_t dai_list_read_file(struct file *file, char __user *user_buf,
347 size_t count, loff_t *ppos)
349 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
350 ssize_t len, ret = 0;
351 struct snd_soc_dai *dai;
356 list_for_each_entry(dai, &dai_list, list) {
357 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", dai->name);
360 if (ret > PAGE_SIZE) {
366 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
373 static const struct file_operations dai_list_fops = {
374 .read = dai_list_read_file,
375 .llseek = default_llseek,/* read accesses f_pos */
378 static ssize_t platform_list_read_file(struct file *file,
379 char __user *user_buf,
380 size_t count, loff_t *ppos)
382 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
383 ssize_t len, ret = 0;
384 struct snd_soc_platform *platform;
389 list_for_each_entry(platform, &platform_list, list) {
390 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
394 if (ret > PAGE_SIZE) {
400 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
407 static const struct file_operations platform_list_fops = {
408 .read = platform_list_read_file,
409 .llseek = default_llseek,/* read accesses f_pos */
412 static void soc_init_card_debugfs(struct snd_soc_card *card)
414 card->debugfs_card_root = debugfs_create_dir(card->name,
415 snd_soc_debugfs_root);
416 if (!card->debugfs_card_root) {
418 "ASoC: Failed to create codec debugfs directory\n");
422 card->debugfs_pop_time = debugfs_create_u32("dapm_pop_time", 0644,
423 card->debugfs_card_root,
425 if (!card->debugfs_pop_time)
427 "Failed to create pop time debugfs file\n");
430 static void soc_cleanup_card_debugfs(struct snd_soc_card *card)
432 debugfs_remove_recursive(card->debugfs_card_root);
437 static inline void soc_init_codec_debugfs(struct snd_soc_codec *codec)
441 static inline void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec)
445 static inline void soc_init_card_debugfs(struct snd_soc_card *card)
449 static inline void soc_cleanup_card_debugfs(struct snd_soc_card *card)
454 #ifdef CONFIG_SND_SOC_AC97_BUS
455 /* unregister ac97 codec */
456 static int soc_ac97_dev_unregister(struct snd_soc_codec *codec)
458 if (codec->ac97->dev.bus)
459 device_unregister(&codec->ac97->dev);
463 /* stop no dev release warning */
464 static void soc_ac97_device_release(struct device *dev){}
466 /* register ac97 codec to bus */
467 static int soc_ac97_dev_register(struct snd_soc_codec *codec)
471 codec->ac97->dev.bus = &ac97_bus_type;
472 codec->ac97->dev.parent = codec->card->dev;
473 codec->ac97->dev.release = soc_ac97_device_release;
475 dev_set_name(&codec->ac97->dev, "%d-%d:%s",
476 codec->card->snd_card->number, 0, codec->name);
477 err = device_register(&codec->ac97->dev);
479 snd_printk(KERN_ERR "Can't register ac97 bus\n");
480 codec->ac97->dev.bus = NULL;
487 #ifdef CONFIG_PM_SLEEP
488 /* powers down audio subsystem for suspend */
489 int snd_soc_suspend(struct device *dev)
491 struct snd_soc_card *card = dev_get_drvdata(dev);
492 struct snd_soc_codec *codec;
495 /* If the initialization of this soc device failed, there is no codec
496 * associated with it. Just bail out in this case.
498 if (list_empty(&card->codec_dev_list))
501 /* Due to the resume being scheduled into a workqueue we could
502 * suspend before that's finished - wait for it to complete.
504 snd_power_lock(card->snd_card);
505 snd_power_wait(card->snd_card, SNDRV_CTL_POWER_D0);
506 snd_power_unlock(card->snd_card);
508 /* we're going to block userspace touching us until resume completes */
509 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D3hot);
511 /* mute any active DACs */
512 for (i = 0; i < card->num_rtd; i++) {
513 struct snd_soc_dai *dai = card->rtd[i].codec_dai;
514 struct snd_soc_dai_driver *drv = dai->driver;
516 if (card->rtd[i].dai_link->ignore_suspend)
519 if (drv->ops->digital_mute && dai->playback_active)
520 drv->ops->digital_mute(dai, 1);
523 /* suspend all pcms */
524 for (i = 0; i < card->num_rtd; i++) {
525 if (card->rtd[i].dai_link->ignore_suspend)
528 snd_pcm_suspend_all(card->rtd[i].pcm);
531 if (card->suspend_pre)
532 card->suspend_pre(card);
534 for (i = 0; i < card->num_rtd; i++) {
535 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
536 struct snd_soc_platform *platform = card->rtd[i].platform;
538 if (card->rtd[i].dai_link->ignore_suspend)
541 if (cpu_dai->driver->suspend && !cpu_dai->driver->ac97_control)
542 cpu_dai->driver->suspend(cpu_dai);
543 if (platform->driver->suspend && !platform->suspended) {
544 platform->driver->suspend(cpu_dai);
545 platform->suspended = 1;
549 /* close any waiting streams and save state */
550 for (i = 0; i < card->num_rtd; i++) {
551 flush_delayed_work_sync(&card->rtd[i].delayed_work);
552 card->rtd[i].codec->dapm.suspend_bias_level = card->rtd[i].codec->dapm.bias_level;
555 for (i = 0; i < card->num_rtd; i++) {
556 struct snd_soc_dai_driver *driver = card->rtd[i].codec_dai->driver;
558 if (card->rtd[i].dai_link->ignore_suspend)
561 if (driver->playback.stream_name != NULL)
562 snd_soc_dapm_stream_event(&card->rtd[i], driver->playback.stream_name,
563 SND_SOC_DAPM_STREAM_SUSPEND);
565 if (driver->capture.stream_name != NULL)
566 snd_soc_dapm_stream_event(&card->rtd[i], driver->capture.stream_name,
567 SND_SOC_DAPM_STREAM_SUSPEND);
570 /* suspend all CODECs */
571 list_for_each_entry(codec, &card->codec_dev_list, card_list) {
572 /* If there are paths active then the CODEC will be held with
573 * bias _ON and should not be suspended. */
574 if (!codec->suspended && codec->driver->suspend) {
575 switch (codec->dapm.bias_level) {
576 case SND_SOC_BIAS_STANDBY:
577 case SND_SOC_BIAS_OFF:
578 codec->driver->suspend(codec, PMSG_SUSPEND);
579 codec->suspended = 1;
582 dev_dbg(codec->dev, "CODEC is on over suspend\n");
588 for (i = 0; i < card->num_rtd; i++) {
589 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
591 if (card->rtd[i].dai_link->ignore_suspend)
594 if (cpu_dai->driver->suspend && cpu_dai->driver->ac97_control)
595 cpu_dai->driver->suspend(cpu_dai);
598 if (card->suspend_post)
599 card->suspend_post(card);
603 EXPORT_SYMBOL_GPL(snd_soc_suspend);
605 /* deferred resume work, so resume can complete before we finished
606 * setting our codec back up, which can be very slow on I2C
608 static void soc_resume_deferred(struct work_struct *work)
610 struct snd_soc_card *card =
611 container_of(work, struct snd_soc_card, deferred_resume_work);
612 struct snd_soc_codec *codec;
615 /* our power state is still SNDRV_CTL_POWER_D3hot from suspend time,
616 * so userspace apps are blocked from touching us
619 dev_dbg(card->dev, "starting resume work\n");
621 /* Bring us up into D2 so that DAPM starts enabling things */
622 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D2);
624 if (card->resume_pre)
625 card->resume_pre(card);
627 /* resume AC97 DAIs */
628 for (i = 0; i < card->num_rtd; i++) {
629 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
631 if (card->rtd[i].dai_link->ignore_suspend)
634 if (cpu_dai->driver->resume && cpu_dai->driver->ac97_control)
635 cpu_dai->driver->resume(cpu_dai);
638 list_for_each_entry(codec, &card->codec_dev_list, card_list) {
639 /* If the CODEC was idle over suspend then it will have been
640 * left with bias OFF or STANDBY and suspended so we must now
641 * resume. Otherwise the suspend was suppressed.
643 if (codec->driver->resume && codec->suspended) {
644 switch (codec->dapm.bias_level) {
645 case SND_SOC_BIAS_STANDBY:
646 case SND_SOC_BIAS_OFF:
647 codec->driver->resume(codec);
648 codec->suspended = 0;
651 dev_dbg(codec->dev, "CODEC was on over suspend\n");
657 for (i = 0; i < card->num_rtd; i++) {
658 struct snd_soc_dai_driver *driver = card->rtd[i].codec_dai->driver;
660 if (card->rtd[i].dai_link->ignore_suspend)
663 if (driver->playback.stream_name != NULL)
664 snd_soc_dapm_stream_event(&card->rtd[i], driver->playback.stream_name,
665 SND_SOC_DAPM_STREAM_RESUME);
667 if (driver->capture.stream_name != NULL)
668 snd_soc_dapm_stream_event(&card->rtd[i], driver->capture.stream_name,
669 SND_SOC_DAPM_STREAM_RESUME);
672 /* unmute any active DACs */
673 for (i = 0; i < card->num_rtd; i++) {
674 struct snd_soc_dai *dai = card->rtd[i].codec_dai;
675 struct snd_soc_dai_driver *drv = dai->driver;
677 if (card->rtd[i].dai_link->ignore_suspend)
680 if (drv->ops->digital_mute && dai->playback_active)
681 drv->ops->digital_mute(dai, 0);
684 for (i = 0; i < card->num_rtd; i++) {
685 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
686 struct snd_soc_platform *platform = card->rtd[i].platform;
688 if (card->rtd[i].dai_link->ignore_suspend)
691 if (cpu_dai->driver->resume && !cpu_dai->driver->ac97_control)
692 cpu_dai->driver->resume(cpu_dai);
693 if (platform->driver->resume && platform->suspended) {
694 platform->driver->resume(cpu_dai);
695 platform->suspended = 0;
699 if (card->resume_post)
700 card->resume_post(card);
702 dev_dbg(card->dev, "resume work completed\n");
704 /* userspace can access us now we are back as we were before */
705 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0);
708 /* powers up audio subsystem after a suspend */
709 int snd_soc_resume(struct device *dev)
711 struct snd_soc_card *card = dev_get_drvdata(dev);
712 int i, ac97_control = 0;
714 /* AC97 devices might have other drivers hanging off them so
715 * need to resume immediately. Other drivers don't have that
716 * problem and may take a substantial amount of time to resume
717 * due to I/O costs and anti-pop so handle them out of line.
719 for (i = 0; i < card->num_rtd; i++) {
720 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
721 ac97_control |= cpu_dai->driver->ac97_control;
724 dev_dbg(dev, "Resuming AC97 immediately\n");
725 soc_resume_deferred(&card->deferred_resume_work);
727 dev_dbg(dev, "Scheduling resume work\n");
728 if (!schedule_work(&card->deferred_resume_work))
729 dev_err(dev, "resume work item may be lost\n");
734 EXPORT_SYMBOL_GPL(snd_soc_resume);
736 #define snd_soc_suspend NULL
737 #define snd_soc_resume NULL
740 static struct snd_soc_dai_ops null_dai_ops = {
743 static int soc_bind_dai_link(struct snd_soc_card *card, int num)
745 struct snd_soc_dai_link *dai_link = &card->dai_link[num];
746 struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
747 struct snd_soc_codec *codec;
748 struct snd_soc_platform *platform;
749 struct snd_soc_dai *codec_dai, *cpu_dai;
750 const char *platform_name;
754 dev_dbg(card->dev, "binding %s at idx %d\n", dai_link->name, num);
756 /* do we already have the CPU DAI for this link ? */
760 /* no, then find CPU DAI from registered DAIs*/
761 list_for_each_entry(cpu_dai, &dai_list, list) {
762 if (!strcmp(cpu_dai->name, dai_link->cpu_dai_name)) {
763 rtd->cpu_dai = cpu_dai;
767 dev_dbg(card->dev, "CPU DAI %s not registered\n",
768 dai_link->cpu_dai_name);
771 /* do we already have the CODEC for this link ? */
776 /* no, then find CODEC from registered CODECs*/
777 list_for_each_entry(codec, &codec_list, list) {
778 if (!strcmp(codec->name, dai_link->codec_name)) {
781 /* CODEC found, so find CODEC DAI from registered DAIs from this CODEC*/
782 list_for_each_entry(codec_dai, &dai_list, list) {
783 if (codec->dev == codec_dai->dev &&
784 !strcmp(codec_dai->name, dai_link->codec_dai_name)) {
785 rtd->codec_dai = codec_dai;
789 dev_dbg(card->dev, "CODEC DAI %s not registered\n",
790 dai_link->codec_dai_name);
795 dev_dbg(card->dev, "CODEC %s not registered\n",
796 dai_link->codec_name);
799 /* do we need a platform? */
803 /* if there's no platform we match on the empty platform */
804 platform_name = dai_link->platform_name;
806 platform_name = "snd-soc-dummy";
808 /* no, then find one from the set of registered platforms */
809 list_for_each_entry(platform, &platform_list, list) {
810 if (!strcmp(platform->name, platform_name)) {
811 rtd->platform = platform;
816 dev_dbg(card->dev, "platform %s not registered\n",
817 dai_link->platform_name);
821 /* mark rtd as complete if we found all 4 of our client devices */
822 if (rtd->codec && rtd->codec_dai && rtd->platform && rtd->cpu_dai) {
829 static void soc_remove_codec(struct snd_soc_codec *codec)
833 if (codec->driver->remove) {
834 err = codec->driver->remove(codec);
837 "asoc: failed to remove %s: %d\n",
841 /* Make sure all DAPM widgets are freed */
842 snd_soc_dapm_free(&codec->dapm);
844 soc_cleanup_codec_debugfs(codec);
846 list_del(&codec->card_list);
847 module_put(codec->dev->driver->owner);
850 static void soc_remove_dai_link(struct snd_soc_card *card, int num, int order)
852 struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
853 struct snd_soc_codec *codec = rtd->codec;
854 struct snd_soc_platform *platform = rtd->platform;
855 struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai;
858 /* unregister the rtd device */
859 if (rtd->dev_registered) {
860 device_remove_file(&rtd->dev, &dev_attr_pmdown_time);
861 device_remove_file(&rtd->dev, &dev_attr_codec_reg);
862 device_unregister(&rtd->dev);
863 rtd->dev_registered = 0;
866 /* remove the CODEC DAI */
867 if (codec_dai && codec_dai->probed &&
868 codec_dai->driver->remove_order == order) {
869 if (codec_dai->driver->remove) {
870 err = codec_dai->driver->remove(codec_dai);
872 printk(KERN_ERR "asoc: failed to remove %s\n", codec_dai->name);
874 codec_dai->probed = 0;
875 list_del(&codec_dai->card_list);
878 /* remove the platform */
879 if (platform && platform->probed &&
880 platform->driver->remove_order == order) {
881 if (platform->driver->remove) {
882 err = platform->driver->remove(platform);
884 printk(KERN_ERR "asoc: failed to remove %s\n", platform->name);
886 platform->probed = 0;
887 list_del(&platform->card_list);
888 module_put(platform->dev->driver->owner);
891 /* remove the CODEC */
892 if (codec && codec->probed &&
893 codec->driver->remove_order == order)
894 soc_remove_codec(codec);
896 /* remove the cpu_dai */
897 if (cpu_dai && cpu_dai->probed &&
898 cpu_dai->driver->remove_order == order) {
899 if (cpu_dai->driver->remove) {
900 err = cpu_dai->driver->remove(cpu_dai);
902 printk(KERN_ERR "asoc: failed to remove %s\n", cpu_dai->name);
905 list_del(&cpu_dai->card_list);
906 module_put(cpu_dai->dev->driver->owner);
910 static void soc_remove_dai_links(struct snd_soc_card *card)
914 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
916 for (dai = 0; dai < card->num_rtd; dai++)
917 soc_remove_dai_link(card, dai, order);
922 static void soc_set_name_prefix(struct snd_soc_card *card,
923 struct snd_soc_codec *codec)
927 if (card->codec_conf == NULL)
930 for (i = 0; i < card->num_configs; i++) {
931 struct snd_soc_codec_conf *map = &card->codec_conf[i];
932 if (map->dev_name && !strcmp(codec->name, map->dev_name)) {
933 codec->name_prefix = map->name_prefix;
939 static int soc_probe_codec(struct snd_soc_card *card,
940 struct snd_soc_codec *codec)
943 const struct snd_soc_codec_driver *driver = codec->driver;
946 codec->dapm.card = card;
947 soc_set_name_prefix(card, codec);
949 if (!try_module_get(codec->dev->driver->owner))
952 soc_init_codec_debugfs(codec);
954 if (driver->dapm_widgets)
955 snd_soc_dapm_new_controls(&codec->dapm, driver->dapm_widgets,
956 driver->num_dapm_widgets);
959 ret = driver->probe(codec);
962 "asoc: failed to probe CODEC %s: %d\n",
968 if (driver->controls)
969 snd_soc_add_controls(codec, driver->controls,
970 driver->num_controls);
971 if (driver->dapm_routes)
972 snd_soc_dapm_add_routes(&codec->dapm, driver->dapm_routes,
973 driver->num_dapm_routes);
975 /* mark codec as probed and add to card codec list */
977 list_add(&codec->card_list, &card->codec_dev_list);
978 list_add(&codec->dapm.list, &card->dapm_list);
983 soc_cleanup_codec_debugfs(codec);
984 module_put(codec->dev->driver->owner);
989 static int soc_probe_platform(struct snd_soc_card *card,
990 struct snd_soc_platform *platform)
993 const struct snd_soc_platform_driver *driver = platform->driver;
995 platform->card = card;
997 if (!try_module_get(platform->dev->driver->owner))
1000 if (driver->probe) {
1001 ret = driver->probe(platform);
1003 dev_err(platform->dev,
1004 "asoc: failed to probe platform %s: %d\n",
1005 platform->name, ret);
1010 /* mark platform as probed and add to card platform list */
1011 platform->probed = 1;
1012 list_add(&platform->card_list, &card->platform_dev_list);
1017 module_put(platform->dev->driver->owner);
1022 static void rtd_release(struct device *dev) {}
1024 static int soc_post_component_init(struct snd_soc_card *card,
1025 struct snd_soc_codec *codec,
1026 int num, int dailess)
1028 struct snd_soc_dai_link *dai_link = NULL;
1029 struct snd_soc_aux_dev *aux_dev = NULL;
1030 struct snd_soc_pcm_runtime *rtd;
1031 const char *temp, *name;
1035 dai_link = &card->dai_link[num];
1036 rtd = &card->rtd[num];
1037 name = dai_link->name;
1039 aux_dev = &card->aux_dev[num];
1040 rtd = &card->rtd_aux[num];
1041 name = aux_dev->name;
1045 /* machine controls, routes and widgets are not prefixed */
1046 temp = codec->name_prefix;
1047 codec->name_prefix = NULL;
1049 /* do machine specific initialization */
1050 if (!dailess && dai_link->init)
1051 ret = dai_link->init(rtd);
1052 else if (dailess && aux_dev->init)
1053 ret = aux_dev->init(&codec->dapm);
1055 dev_err(card->dev, "asoc: failed to init %s: %d\n", name, ret);
1058 codec->name_prefix = temp;
1060 /* Make sure all DAPM widgets are instantiated */
1061 snd_soc_dapm_new_widgets(&codec->dapm);
1063 /* register the rtd device */
1065 rtd->dev.parent = card->dev;
1066 rtd->dev.release = rtd_release;
1067 rtd->dev.init_name = name;
1068 mutex_init(&rtd->pcm_mutex);
1069 ret = device_register(&rtd->dev);
1072 "asoc: failed to register runtime device: %d\n", ret);
1075 rtd->dev_registered = 1;
1077 /* add DAPM sysfs entries for this codec */
1078 ret = snd_soc_dapm_sys_add(&rtd->dev);
1081 "asoc: failed to add codec dapm sysfs entries: %d\n",
1084 /* add codec sysfs entries */
1085 ret = device_create_file(&rtd->dev, &dev_attr_codec_reg);
1088 "asoc: failed to add codec sysfs files: %d\n", ret);
1093 static int soc_probe_dai_link(struct snd_soc_card *card, int num, int order)
1095 struct snd_soc_dai_link *dai_link = &card->dai_link[num];
1096 struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
1097 struct snd_soc_codec *codec = rtd->codec;
1098 struct snd_soc_platform *platform = rtd->platform;
1099 struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai;
1102 dev_dbg(card->dev, "probe %s dai link %d late %d\n",
1103 card->name, num, order);
1105 /* config components */
1106 codec_dai->codec = codec;
1107 cpu_dai->platform = platform;
1108 codec_dai->card = card;
1109 cpu_dai->card = card;
1111 /* set default power off timeout */
1112 rtd->pmdown_time = pmdown_time;
1114 /* probe the cpu_dai */
1115 if (!cpu_dai->probed &&
1116 cpu_dai->driver->probe_order == order) {
1117 if (!try_module_get(cpu_dai->dev->driver->owner))
1120 if (cpu_dai->driver->probe) {
1121 ret = cpu_dai->driver->probe(cpu_dai);
1123 printk(KERN_ERR "asoc: failed to probe CPU DAI %s\n",
1125 module_put(cpu_dai->dev->driver->owner);
1129 cpu_dai->probed = 1;
1130 /* mark cpu_dai as probed and add to card cpu_dai list */
1131 list_add(&cpu_dai->card_list, &card->dai_dev_list);
1134 /* probe the CODEC */
1135 if (!codec->probed &&
1136 codec->driver->probe_order == order) {
1137 ret = soc_probe_codec(card, codec);
1142 /* probe the platform */
1143 if (!platform->probed &&
1144 platform->driver->probe_order == order) {
1145 ret = soc_probe_platform(card, platform);
1150 /* probe the CODEC DAI */
1151 if (!codec_dai->probed && codec_dai->driver->probe_order == order) {
1152 if (codec_dai->driver->probe) {
1153 ret = codec_dai->driver->probe(codec_dai);
1155 printk(KERN_ERR "asoc: failed to probe CODEC DAI %s\n",
1161 /* mark cpu_dai as probed and add to card cpu_dai list */
1162 codec_dai->probed = 1;
1163 list_add(&codec_dai->card_list, &card->dai_dev_list);
1166 /* complete DAI probe during last probe */
1167 if (order != SND_SOC_COMP_ORDER_LAST)
1170 ret = soc_post_component_init(card, codec, num, 0);
1174 ret = device_create_file(&rtd->dev, &dev_attr_pmdown_time);
1176 printk(KERN_WARNING "asoc: failed to add pmdown_time sysfs\n");
1178 /* create the pcm */
1179 ret = soc_new_pcm(rtd, num);
1181 printk(KERN_ERR "asoc: can't create pcm %s\n", dai_link->stream_name);
1185 /* add platform data for AC97 devices */
1186 if (rtd->codec_dai->driver->ac97_control)
1187 snd_ac97_dev_add_pdata(codec->ac97, rtd->cpu_dai->ac97_pdata);
1192 #ifdef CONFIG_SND_SOC_AC97_BUS
1193 static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
1197 /* Only instantiate AC97 if not already done by the adaptor
1198 * for the generic AC97 subsystem.
1200 if (rtd->codec_dai->driver->ac97_control && !rtd->codec->ac97_registered) {
1202 * It is possible that the AC97 device is already registered to
1203 * the device subsystem. This happens when the device is created
1204 * via snd_ac97_mixer(). Currently only SoC codec that does so
1205 * is the generic AC97 glue but others migh emerge.
1207 * In those cases we don't try to register the device again.
1209 if (!rtd->codec->ac97_created)
1212 ret = soc_ac97_dev_register(rtd->codec);
1214 printk(KERN_ERR "asoc: AC97 device register failed\n");
1218 rtd->codec->ac97_registered = 1;
1223 static void soc_unregister_ac97_dai_link(struct snd_soc_codec *codec)
1225 if (codec->ac97_registered) {
1226 soc_ac97_dev_unregister(codec);
1227 codec->ac97_registered = 0;
1232 static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
1234 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
1235 struct snd_soc_codec *codec;
1238 /* find CODEC from registered CODECs*/
1239 list_for_each_entry(codec, &codec_list, list) {
1240 if (!strcmp(codec->name, aux_dev->codec_name)) {
1241 if (codec->probed) {
1243 "asoc: codec already probed");
1250 /* codec not found */
1251 dev_err(card->dev, "asoc: codec %s not found", aux_dev->codec_name);
1255 ret = soc_probe_codec(card, codec);
1259 ret = soc_post_component_init(card, codec, num, 1);
1265 static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
1267 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
1268 struct snd_soc_codec *codec = rtd->codec;
1270 /* unregister the rtd device */
1271 if (rtd->dev_registered) {
1272 device_remove_file(&rtd->dev, &dev_attr_codec_reg);
1273 device_unregister(&rtd->dev);
1274 rtd->dev_registered = 0;
1277 if (codec && codec->probed)
1278 soc_remove_codec(codec);
1281 static int snd_soc_init_codec_cache(struct snd_soc_codec *codec,
1282 enum snd_soc_compress_type compress_type)
1286 if (codec->cache_init)
1289 /* override the compress_type if necessary */
1290 if (compress_type && codec->compress_type != compress_type)
1291 codec->compress_type = compress_type;
1292 ret = snd_soc_cache_init(codec);
1294 dev_err(codec->dev, "Failed to set cache compression type: %d\n",
1298 codec->cache_init = 1;
1302 static void snd_soc_instantiate_card(struct snd_soc_card *card)
1304 struct snd_soc_codec *codec;
1305 struct snd_soc_codec_conf *codec_conf;
1306 enum snd_soc_compress_type compress_type;
1309 mutex_lock(&card->mutex);
1311 if (card->instantiated) {
1312 mutex_unlock(&card->mutex);
1317 for (i = 0; i < card->num_links; i++)
1318 soc_bind_dai_link(card, i);
1320 /* bind completed ? */
1321 if (card->num_rtd != card->num_links) {
1322 mutex_unlock(&card->mutex);
1326 /* initialize the register cache for each available codec */
1327 list_for_each_entry(codec, &codec_list, list) {
1328 if (codec->cache_init)
1330 /* by default we don't override the compress_type */
1332 /* check to see if we need to override the compress_type */
1333 for (i = 0; i < card->num_configs; ++i) {
1334 codec_conf = &card->codec_conf[i];
1335 if (!strcmp(codec->name, codec_conf->dev_name)) {
1336 compress_type = codec_conf->compress_type;
1337 if (compress_type && compress_type
1338 != codec->compress_type)
1342 ret = snd_soc_init_codec_cache(codec, compress_type);
1344 mutex_unlock(&card->mutex);
1349 /* card bind complete so register a sound card */
1350 ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
1351 card->owner, 0, &card->snd_card);
1353 printk(KERN_ERR "asoc: can't create sound card for card %s\n",
1355 mutex_unlock(&card->mutex);
1358 card->snd_card->dev = card->dev;
1360 card->dapm.bias_level = SND_SOC_BIAS_OFF;
1361 card->dapm.dev = card->dev;
1362 card->dapm.card = card;
1363 list_add(&card->dapm.list, &card->dapm_list);
1365 #ifdef CONFIG_DEBUG_FS
1366 snd_soc_dapm_debugfs_init(&card->dapm, card->debugfs_card_root);
1369 #ifdef CONFIG_PM_SLEEP
1370 /* deferred resume work */
1371 INIT_WORK(&card->deferred_resume_work, soc_resume_deferred);
1374 if (card->dapm_widgets)
1375 snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets,
1376 card->num_dapm_widgets);
1378 /* initialise the sound card only once */
1380 ret = card->probe(card);
1382 goto card_probe_error;
1385 /* early DAI link probe */
1386 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
1388 for (i = 0; i < card->num_links; i++) {
1389 ret = soc_probe_dai_link(card, i, order);
1391 pr_err("asoc: failed to instantiate card %s: %d\n",
1398 for (i = 0; i < card->num_aux_devs; i++) {
1399 ret = soc_probe_aux_dev(card, i);
1401 pr_err("asoc: failed to add auxiliary devices %s: %d\n",
1403 goto probe_aux_dev_err;
1407 /* We should have a non-codec control add function but we don't */
1409 snd_soc_add_controls(list_first_entry(&card->codec_dev_list,
1410 struct snd_soc_codec,
1413 card->num_controls);
1415 if (card->dapm_routes)
1416 snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
1417 card->num_dapm_routes);
1419 snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname),
1421 snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
1422 "%s", card->long_name ? card->long_name : card->name);
1423 snprintf(card->snd_card->driver, sizeof(card->snd_card->driver),
1424 "%s", card->driver_name ? card->driver_name : card->name);
1426 if (card->late_probe) {
1427 ret = card->late_probe(card);
1429 dev_err(card->dev, "%s late_probe() failed: %d\n",
1431 goto probe_aux_dev_err;
1435 ret = snd_card_register(card->snd_card);
1437 printk(KERN_ERR "asoc: failed to register soundcard for %s\n", card->name);
1438 goto probe_aux_dev_err;
1441 #ifdef CONFIG_SND_SOC_AC97_BUS
1442 /* register any AC97 codecs */
1443 for (i = 0; i < card->num_rtd; i++) {
1444 ret = soc_register_ac97_dai_link(&card->rtd[i]);
1446 printk(KERN_ERR "asoc: failed to register AC97 %s\n", card->name);
1448 soc_unregister_ac97_dai_link(card->rtd[i].codec);
1449 goto probe_aux_dev_err;
1454 card->instantiated = 1;
1455 mutex_unlock(&card->mutex);
1459 for (i = 0; i < card->num_aux_devs; i++)
1460 soc_remove_aux_dev(card, i);
1463 soc_remove_dai_links(card);
1469 snd_card_free(card->snd_card);
1471 mutex_unlock(&card->mutex);
1475 * Attempt to initialise any uninitialised cards. Must be called with
1478 static void snd_soc_instantiate_cards(void)
1480 struct snd_soc_card *card;
1481 list_for_each_entry(card, &card_list, list)
1482 snd_soc_instantiate_card(card);
1485 /* probes a new socdev */
1486 static int soc_probe(struct platform_device *pdev)
1488 struct snd_soc_card *card = platform_get_drvdata(pdev);
1492 * no card, so machine driver should be registering card
1493 * we should not be here in that case so ret error
1498 /* Bodge while we unpick instantiation */
1499 card->dev = &pdev->dev;
1501 ret = snd_soc_register_card(card);
1503 dev_err(&pdev->dev, "Failed to register card\n");
1510 static int soc_cleanup_card_resources(struct snd_soc_card *card)
1514 /* make sure any delayed work runs */
1515 for (i = 0; i < card->num_rtd; i++) {
1516 struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
1517 flush_delayed_work_sync(&rtd->delayed_work);
1520 /* remove auxiliary devices */
1521 for (i = 0; i < card->num_aux_devs; i++)
1522 soc_remove_aux_dev(card, i);
1524 /* remove and free each DAI */
1525 soc_remove_dai_links(card);
1527 soc_cleanup_card_debugfs(card);
1529 /* remove the card */
1533 snd_soc_dapm_free(&card->dapm);
1536 snd_card_free(card->snd_card);
1541 /* removes a socdev */
1542 static int soc_remove(struct platform_device *pdev)
1544 struct snd_soc_card *card = platform_get_drvdata(pdev);
1546 snd_soc_unregister_card(card);
1550 int snd_soc_poweroff(struct device *dev)
1552 struct snd_soc_card *card = dev_get_drvdata(dev);
1555 if (!card->instantiated)
1558 /* Flush out pmdown_time work - we actually do want to run it
1559 * now, we're shutting down so no imminent restart. */
1560 for (i = 0; i < card->num_rtd; i++) {
1561 struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
1562 flush_delayed_work_sync(&rtd->delayed_work);
1565 snd_soc_dapm_shutdown(card);
1569 EXPORT_SYMBOL_GPL(snd_soc_poweroff);
1571 const struct dev_pm_ops snd_soc_pm_ops = {
1572 .suspend = snd_soc_suspend,
1573 .resume = snd_soc_resume,
1574 .poweroff = snd_soc_poweroff,
1576 EXPORT_SYMBOL_GPL(snd_soc_pm_ops);
1578 /* ASoC platform driver */
1579 static struct platform_driver soc_driver = {
1581 .name = "soc-audio",
1582 .owner = THIS_MODULE,
1583 .pm = &snd_soc_pm_ops,
1586 .remove = soc_remove,
1590 * snd_soc_codec_volatile_register: Report if a register is volatile.
1592 * @codec: CODEC to query.
1593 * @reg: Register to query.
1595 * Boolean function indiciating if a CODEC register is volatile.
1597 int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
1600 if (codec->volatile_register)
1601 return codec->volatile_register(codec, reg);
1605 EXPORT_SYMBOL_GPL(snd_soc_codec_volatile_register);
1608 * snd_soc_codec_readable_register: Report if a register is readable.
1610 * @codec: CODEC to query.
1611 * @reg: Register to query.
1613 * Boolean function indicating if a CODEC register is readable.
1615 int snd_soc_codec_readable_register(struct snd_soc_codec *codec,
1618 if (codec->readable_register)
1619 return codec->readable_register(codec, reg);
1623 EXPORT_SYMBOL_GPL(snd_soc_codec_readable_register);
1626 * snd_soc_codec_writable_register: Report if a register is writable.
1628 * @codec: CODEC to query.
1629 * @reg: Register to query.
1631 * Boolean function indicating if a CODEC register is writable.
1633 int snd_soc_codec_writable_register(struct snd_soc_codec *codec,
1636 if (codec->writable_register)
1637 return codec->writable_register(codec, reg);
1641 EXPORT_SYMBOL_GPL(snd_soc_codec_writable_register);
1643 int snd_soc_platform_read(struct snd_soc_platform *platform,
1648 if (!platform->driver->read) {
1649 dev_err(platform->dev, "platform has no read back\n");
1653 ret = platform->driver->read(platform, reg);
1654 dev_dbg(platform->dev, "read %x => %x\n", reg, ret);
1658 EXPORT_SYMBOL_GPL(snd_soc_platform_read);
1660 int snd_soc_platform_write(struct snd_soc_platform *platform,
1661 unsigned int reg, unsigned int val)
1663 if (!platform->driver->write) {
1664 dev_err(platform->dev, "platform has no write back\n");
1668 dev_dbg(platform->dev, "write %x = %x\n", reg, val);
1669 return platform->driver->write(platform, reg, val);
1671 EXPORT_SYMBOL_GPL(snd_soc_platform_write);
1674 * snd_soc_new_ac97_codec - initailise AC97 device
1675 * @codec: audio codec
1676 * @ops: AC97 bus operations
1677 * @num: AC97 codec number
1679 * Initialises AC97 codec resources for use by ad-hoc devices only.
1681 int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
1682 struct snd_ac97_bus_ops *ops, int num)
1684 mutex_lock(&codec->mutex);
1686 codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL);
1687 if (codec->ac97 == NULL) {
1688 mutex_unlock(&codec->mutex);
1692 codec->ac97->bus = kzalloc(sizeof(struct snd_ac97_bus), GFP_KERNEL);
1693 if (codec->ac97->bus == NULL) {
1696 mutex_unlock(&codec->mutex);
1700 codec->ac97->bus->ops = ops;
1701 codec->ac97->num = num;
1704 * Mark the AC97 device to be created by us. This way we ensure that the
1705 * device will be registered with the device subsystem later on.
1707 codec->ac97_created = 1;
1709 mutex_unlock(&codec->mutex);
1712 EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);
1715 * snd_soc_free_ac97_codec - free AC97 codec device
1716 * @codec: audio codec
1718 * Frees AC97 codec device resources.
1720 void snd_soc_free_ac97_codec(struct snd_soc_codec *codec)
1722 mutex_lock(&codec->mutex);
1723 #ifdef CONFIG_SND_SOC_AC97_BUS
1724 soc_unregister_ac97_dai_link(codec);
1726 kfree(codec->ac97->bus);
1729 codec->ac97_created = 0;
1730 mutex_unlock(&codec->mutex);
1732 EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec);
1734 unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg)
1738 ret = codec->read(codec, reg);
1739 dev_dbg(codec->dev, "read %x => %x\n", reg, ret);
1740 trace_snd_soc_reg_read(codec, reg, ret);
1744 EXPORT_SYMBOL_GPL(snd_soc_read);
1746 unsigned int snd_soc_write(struct snd_soc_codec *codec,
1747 unsigned int reg, unsigned int val)
1749 dev_dbg(codec->dev, "write %x = %x\n", reg, val);
1750 trace_snd_soc_reg_write(codec, reg, val);
1751 return codec->write(codec, reg, val);
1753 EXPORT_SYMBOL_GPL(snd_soc_write);
1755 unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec,
1756 unsigned int reg, const void *data, size_t len)
1758 return codec->bulk_write_raw(codec, reg, data, len);
1760 EXPORT_SYMBOL_GPL(snd_soc_bulk_write_raw);
1763 * snd_soc_update_bits - update codec register bits
1764 * @codec: audio codec
1765 * @reg: codec register
1766 * @mask: register mask
1769 * Writes new register value.
1771 * Returns 1 for change, 0 for no change, or negative error code.
1773 int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
1774 unsigned int mask, unsigned int value)
1777 unsigned int old, new;
1780 ret = snd_soc_read(codec, reg);
1785 new = (old & ~mask) | (value & mask);
1786 change = old != new;
1788 ret = snd_soc_write(codec, reg, new);
1795 EXPORT_SYMBOL_GPL(snd_soc_update_bits);
1798 * snd_soc_update_bits_locked - update codec register bits
1799 * @codec: audio codec
1800 * @reg: codec register
1801 * @mask: register mask
1804 * Writes new register value, and takes the codec mutex.
1806 * Returns 1 for change else 0.
1808 int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
1809 unsigned short reg, unsigned int mask,
1814 mutex_lock(&codec->mutex);
1815 change = snd_soc_update_bits(codec, reg, mask, value);
1816 mutex_unlock(&codec->mutex);
1820 EXPORT_SYMBOL_GPL(snd_soc_update_bits_locked);
1823 * snd_soc_test_bits - test register for change
1824 * @codec: audio codec
1825 * @reg: codec register
1826 * @mask: register mask
1829 * Tests a register with a new value and checks if the new value is
1830 * different from the old value.
1832 * Returns 1 for change else 0.
1834 int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
1835 unsigned int mask, unsigned int value)
1838 unsigned int old, new;
1840 old = snd_soc_read(codec, reg);
1841 new = (old & ~mask) | value;
1842 change = old != new;
1846 EXPORT_SYMBOL_GPL(snd_soc_test_bits);
1849 * snd_soc_set_runtime_hwparams - set the runtime hardware parameters
1850 * @substream: the pcm substream
1851 * @hw: the hardware parameters
1853 * Sets the substream runtime hardware parameters.
1855 int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
1856 const struct snd_pcm_hardware *hw)
1858 struct snd_pcm_runtime *runtime = substream->runtime;
1859 runtime->hw.info = hw->info;
1860 runtime->hw.formats = hw->formats;
1861 runtime->hw.period_bytes_min = hw->period_bytes_min;
1862 runtime->hw.period_bytes_max = hw->period_bytes_max;
1863 runtime->hw.periods_min = hw->periods_min;
1864 runtime->hw.periods_max = hw->periods_max;
1865 runtime->hw.buffer_bytes_max = hw->buffer_bytes_max;
1866 runtime->hw.fifo_size = hw->fifo_size;
1869 EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams);
1872 * snd_soc_cnew - create new control
1873 * @_template: control template
1874 * @data: control private data
1875 * @long_name: control long name
1876 * @prefix: control name prefix
1878 * Create a new mixer control from a template control.
1880 * Returns 0 for success, else error.
1882 struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
1883 void *data, char *long_name,
1886 struct snd_kcontrol_new template;
1887 struct snd_kcontrol *kcontrol;
1891 memcpy(&template, _template, sizeof(template));
1895 long_name = template.name;
1898 name_len = strlen(long_name) + strlen(prefix) + 2;
1899 name = kmalloc(name_len, GFP_ATOMIC);
1903 snprintf(name, name_len, "%s %s", prefix, long_name);
1905 template.name = name;
1907 template.name = long_name;
1910 kcontrol = snd_ctl_new1(&template, data);
1916 EXPORT_SYMBOL_GPL(snd_soc_cnew);
1919 * snd_soc_add_controls - add an array of controls to a codec.
1920 * Convienience function to add a list of controls. Many codecs were
1921 * duplicating this code.
1923 * @codec: codec to add controls to
1924 * @controls: array of controls to add
1925 * @num_controls: number of elements in the array
1927 * Return 0 for success, else error.
1929 int snd_soc_add_controls(struct snd_soc_codec *codec,
1930 const struct snd_kcontrol_new *controls, int num_controls)
1932 struct snd_card *card = codec->card->snd_card;
1935 for (i = 0; i < num_controls; i++) {
1936 const struct snd_kcontrol_new *control = &controls[i];
1937 err = snd_ctl_add(card, snd_soc_cnew(control, codec,
1939 codec->name_prefix));
1941 dev_err(codec->dev, "%s: Failed to add %s: %d\n",
1942 codec->name, control->name, err);
1949 EXPORT_SYMBOL_GPL(snd_soc_add_controls);
1952 * snd_soc_info_enum_double - enumerated double mixer info callback
1953 * @kcontrol: mixer control
1954 * @uinfo: control element information
1956 * Callback to provide information about a double enumerated
1959 * Returns 0 for success.
1961 int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
1962 struct snd_ctl_elem_info *uinfo)
1964 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1966 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1967 uinfo->count = e->shift_l == e->shift_r ? 1 : 2;
1968 uinfo->value.enumerated.items = e->max;
1970 if (uinfo->value.enumerated.item > e->max - 1)
1971 uinfo->value.enumerated.item = e->max - 1;
1972 strcpy(uinfo->value.enumerated.name,
1973 e->texts[uinfo->value.enumerated.item]);
1976 EXPORT_SYMBOL_GPL(snd_soc_info_enum_double);
1979 * snd_soc_get_enum_double - enumerated double mixer get callback
1980 * @kcontrol: mixer control
1981 * @ucontrol: control element information
1983 * Callback to get the value of a double enumerated mixer.
1985 * Returns 0 for success.
1987 int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
1988 struct snd_ctl_elem_value *ucontrol)
1990 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1991 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1992 unsigned int val, bitmask;
1994 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
1996 val = snd_soc_read(codec, e->reg);
1997 ucontrol->value.enumerated.item[0]
1998 = (val >> e->shift_l) & (bitmask - 1);
1999 if (e->shift_l != e->shift_r)
2000 ucontrol->value.enumerated.item[1] =
2001 (val >> e->shift_r) & (bitmask - 1);
2005 EXPORT_SYMBOL_GPL(snd_soc_get_enum_double);
2008 * snd_soc_put_enum_double - enumerated double mixer put callback
2009 * @kcontrol: mixer control
2010 * @ucontrol: control element information
2012 * Callback to set the value of a double enumerated mixer.
2014 * Returns 0 for success.
2016 int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
2017 struct snd_ctl_elem_value *ucontrol)
2019 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2020 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2022 unsigned int mask, bitmask;
2024 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
2026 if (ucontrol->value.enumerated.item[0] > e->max - 1)
2028 val = ucontrol->value.enumerated.item[0] << e->shift_l;
2029 mask = (bitmask - 1) << e->shift_l;
2030 if (e->shift_l != e->shift_r) {
2031 if (ucontrol->value.enumerated.item[1] > e->max - 1)
2033 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
2034 mask |= (bitmask - 1) << e->shift_r;
2037 return snd_soc_update_bits_locked(codec, e->reg, mask, val);
2039 EXPORT_SYMBOL_GPL(snd_soc_put_enum_double);
2042 * snd_soc_get_value_enum_double - semi enumerated double mixer get callback
2043 * @kcontrol: mixer control
2044 * @ucontrol: control element information
2046 * Callback to get the value of a double semi enumerated mixer.
2048 * Semi enumerated mixer: the enumerated items are referred as values. Can be
2049 * used for handling bitfield coded enumeration for example.
2051 * Returns 0 for success.
2053 int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
2054 struct snd_ctl_elem_value *ucontrol)
2056 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2057 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2058 unsigned int reg_val, val, mux;
2060 reg_val = snd_soc_read(codec, e->reg);
2061 val = (reg_val >> e->shift_l) & e->mask;
2062 for (mux = 0; mux < e->max; mux++) {
2063 if (val == e->values[mux])
2066 ucontrol->value.enumerated.item[0] = mux;
2067 if (e->shift_l != e->shift_r) {
2068 val = (reg_val >> e->shift_r) & e->mask;
2069 for (mux = 0; mux < e->max; mux++) {
2070 if (val == e->values[mux])
2073 ucontrol->value.enumerated.item[1] = mux;
2078 EXPORT_SYMBOL_GPL(snd_soc_get_value_enum_double);
2081 * snd_soc_put_value_enum_double - semi enumerated double mixer put callback
2082 * @kcontrol: mixer control
2083 * @ucontrol: control element information
2085 * Callback to set the value of a double semi enumerated mixer.
2087 * Semi enumerated mixer: the enumerated items are referred as values. Can be
2088 * used for handling bitfield coded enumeration for example.
2090 * Returns 0 for success.
2092 int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
2093 struct snd_ctl_elem_value *ucontrol)
2095 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2096 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2100 if (ucontrol->value.enumerated.item[0] > e->max - 1)
2102 val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l;
2103 mask = e->mask << e->shift_l;
2104 if (e->shift_l != e->shift_r) {
2105 if (ucontrol->value.enumerated.item[1] > e->max - 1)
2107 val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r;
2108 mask |= e->mask << e->shift_r;
2111 return snd_soc_update_bits_locked(codec, e->reg, mask, val);
2113 EXPORT_SYMBOL_GPL(snd_soc_put_value_enum_double);
2116 * snd_soc_info_enum_ext - external enumerated single mixer info callback
2117 * @kcontrol: mixer control
2118 * @uinfo: control element information
2120 * Callback to provide information about an external enumerated
2123 * Returns 0 for success.
2125 int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
2126 struct snd_ctl_elem_info *uinfo)
2128 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2130 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2132 uinfo->value.enumerated.items = e->max;
2134 if (uinfo->value.enumerated.item > e->max - 1)
2135 uinfo->value.enumerated.item = e->max - 1;
2136 strcpy(uinfo->value.enumerated.name,
2137 e->texts[uinfo->value.enumerated.item]);
2140 EXPORT_SYMBOL_GPL(snd_soc_info_enum_ext);
2143 * snd_soc_info_volsw_ext - external single mixer info callback
2144 * @kcontrol: mixer control
2145 * @uinfo: control element information
2147 * Callback to provide information about a single external mixer control.
2149 * Returns 0 for success.
2151 int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
2152 struct snd_ctl_elem_info *uinfo)
2154 int max = kcontrol->private_value;
2156 if (max == 1 && !strstr(kcontrol->id.name, " Volume"))
2157 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
2159 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2162 uinfo->value.integer.min = 0;
2163 uinfo->value.integer.max = max;
2166 EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext);
2169 * snd_soc_info_volsw - single mixer info callback
2170 * @kcontrol: mixer control
2171 * @uinfo: control element information
2173 * Callback to provide information about a single mixer control.
2175 * Returns 0 for success.
2177 int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
2178 struct snd_ctl_elem_info *uinfo)
2180 struct soc_mixer_control *mc =
2181 (struct soc_mixer_control *)kcontrol->private_value;
2183 unsigned int shift = mc->shift;
2184 unsigned int rshift = mc->rshift;
2186 if (!mc->platform_max)
2187 mc->platform_max = mc->max;
2188 platform_max = mc->platform_max;
2190 if (platform_max == 1 && !strstr(kcontrol->id.name, " Volume"))
2191 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
2193 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2195 uinfo->count = shift == rshift ? 1 : 2;
2196 uinfo->value.integer.min = 0;
2197 uinfo->value.integer.max = platform_max;
2200 EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
2203 * snd_soc_get_volsw - single mixer get callback
2204 * @kcontrol: mixer control
2205 * @ucontrol: control element information
2207 * Callback to get the value of a single mixer control.
2209 * Returns 0 for success.
2211 int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
2212 struct snd_ctl_elem_value *ucontrol)
2214 struct soc_mixer_control *mc =
2215 (struct soc_mixer_control *)kcontrol->private_value;
2216 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2217 unsigned int reg = mc->reg;
2218 unsigned int shift = mc->shift;
2219 unsigned int rshift = mc->rshift;
2221 unsigned int mask = (1 << fls(max)) - 1;
2222 unsigned int invert = mc->invert;
2224 ucontrol->value.integer.value[0] =
2225 (snd_soc_read(codec, reg) >> shift) & mask;
2226 if (shift != rshift)
2227 ucontrol->value.integer.value[1] =
2228 (snd_soc_read(codec, reg) >> rshift) & mask;
2230 ucontrol->value.integer.value[0] =
2231 max - ucontrol->value.integer.value[0];
2232 if (shift != rshift)
2233 ucontrol->value.integer.value[1] =
2234 max - ucontrol->value.integer.value[1];
2239 EXPORT_SYMBOL_GPL(snd_soc_get_volsw);
2242 * snd_soc_put_volsw - single mixer put callback
2243 * @kcontrol: mixer control
2244 * @ucontrol: control element information
2246 * Callback to set the value of a single mixer control.
2248 * Returns 0 for success.
2250 int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
2251 struct snd_ctl_elem_value *ucontrol)
2253 struct soc_mixer_control *mc =
2254 (struct soc_mixer_control *)kcontrol->private_value;
2255 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2256 unsigned int reg = mc->reg;
2257 unsigned int shift = mc->shift;
2258 unsigned int rshift = mc->rshift;
2260 unsigned int mask = (1 << fls(max)) - 1;
2261 unsigned int invert = mc->invert;
2262 unsigned int val, val2, val_mask;
2264 val = (ucontrol->value.integer.value[0] & mask);
2267 val_mask = mask << shift;
2269 if (shift != rshift) {
2270 val2 = (ucontrol->value.integer.value[1] & mask);
2273 val_mask |= mask << rshift;
2274 val |= val2 << rshift;
2276 return snd_soc_update_bits_locked(codec, reg, val_mask, val);
2278 EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
2281 * snd_soc_info_volsw_2r - double mixer info callback
2282 * @kcontrol: mixer control
2283 * @uinfo: control element information
2285 * Callback to provide information about a double mixer control that
2286 * spans 2 codec registers.
2288 * Returns 0 for success.
2290 int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
2291 struct snd_ctl_elem_info *uinfo)
2293 struct soc_mixer_control *mc =
2294 (struct soc_mixer_control *)kcontrol->private_value;
2297 if (!mc->platform_max)
2298 mc->platform_max = mc->max;
2299 platform_max = mc->platform_max;
2301 if (platform_max == 1 && !strstr(kcontrol->id.name, " Volume"))
2302 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
2304 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2307 uinfo->value.integer.min = 0;
2308 uinfo->value.integer.max = platform_max;
2311 EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r);
2314 * snd_soc_get_volsw_2r - double mixer get callback
2315 * @kcontrol: mixer control
2316 * @ucontrol: control element information
2318 * Callback to get the value of a double mixer control that spans 2 registers.
2320 * Returns 0 for success.
2322 int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
2323 struct snd_ctl_elem_value *ucontrol)
2325 struct soc_mixer_control *mc =
2326 (struct soc_mixer_control *)kcontrol->private_value;
2327 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2328 unsigned int reg = mc->reg;
2329 unsigned int reg2 = mc->rreg;
2330 unsigned int shift = mc->shift;
2332 unsigned int mask = (1 << fls(max)) - 1;
2333 unsigned int invert = mc->invert;
2335 ucontrol->value.integer.value[0] =
2336 (snd_soc_read(codec, reg) >> shift) & mask;
2337 ucontrol->value.integer.value[1] =
2338 (snd_soc_read(codec, reg2) >> shift) & mask;
2340 ucontrol->value.integer.value[0] =
2341 max - ucontrol->value.integer.value[0];
2342 ucontrol->value.integer.value[1] =
2343 max - ucontrol->value.integer.value[1];
2348 EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r);
2351 * snd_soc_put_volsw_2r - double mixer set callback
2352 * @kcontrol: mixer control
2353 * @ucontrol: control element information
2355 * Callback to set the value of a double mixer control that spans 2 registers.
2357 * Returns 0 for success.
2359 int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
2360 struct snd_ctl_elem_value *ucontrol)
2362 struct soc_mixer_control *mc =
2363 (struct soc_mixer_control *)kcontrol->private_value;
2364 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2365 unsigned int reg = mc->reg;
2366 unsigned int reg2 = mc->rreg;
2367 unsigned int shift = mc->shift;
2369 unsigned int mask = (1 << fls(max)) - 1;
2370 unsigned int invert = mc->invert;
2372 unsigned int val, val2, val_mask;
2374 val_mask = mask << shift;
2375 val = (ucontrol->value.integer.value[0] & mask);
2376 val2 = (ucontrol->value.integer.value[1] & mask);
2384 val2 = val2 << shift;
2386 err = snd_soc_update_bits_locked(codec, reg, val_mask, val);
2390 err = snd_soc_update_bits_locked(codec, reg2, val_mask, val2);
2393 EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r);
2396 * snd_soc_info_volsw_s8 - signed mixer info callback
2397 * @kcontrol: mixer control
2398 * @uinfo: control element information
2400 * Callback to provide information about a signed mixer control.
2402 * Returns 0 for success.
2404 int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
2405 struct snd_ctl_elem_info *uinfo)
2407 struct soc_mixer_control *mc =
2408 (struct soc_mixer_control *)kcontrol->private_value;
2412 if (!mc->platform_max)
2413 mc->platform_max = mc->max;
2414 platform_max = mc->platform_max;
2416 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2418 uinfo->value.integer.min = 0;
2419 uinfo->value.integer.max = platform_max - min;
2422 EXPORT_SYMBOL_GPL(snd_soc_info_volsw_s8);
2425 * snd_soc_get_volsw_s8 - signed mixer get callback
2426 * @kcontrol: mixer control
2427 * @ucontrol: control element information
2429 * Callback to get the value of a signed mixer control.
2431 * Returns 0 for success.
2433 int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
2434 struct snd_ctl_elem_value *ucontrol)
2436 struct soc_mixer_control *mc =
2437 (struct soc_mixer_control *)kcontrol->private_value;
2438 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2439 unsigned int reg = mc->reg;
2441 int val = snd_soc_read(codec, reg);
2443 ucontrol->value.integer.value[0] =
2444 ((signed char)(val & 0xff))-min;
2445 ucontrol->value.integer.value[1] =
2446 ((signed char)((val >> 8) & 0xff))-min;
2449 EXPORT_SYMBOL_GPL(snd_soc_get_volsw_s8);
2452 * snd_soc_put_volsw_sgn - signed mixer put callback
2453 * @kcontrol: mixer control
2454 * @ucontrol: control element information
2456 * Callback to set the value of a signed mixer control.
2458 * Returns 0 for success.
2460 int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
2461 struct snd_ctl_elem_value *ucontrol)
2463 struct soc_mixer_control *mc =
2464 (struct soc_mixer_control *)kcontrol->private_value;
2465 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2466 unsigned int reg = mc->reg;
2470 val = (ucontrol->value.integer.value[0]+min) & 0xff;
2471 val |= ((ucontrol->value.integer.value[1]+min) & 0xff) << 8;
2473 return snd_soc_update_bits_locked(codec, reg, 0xffff, val);
2475 EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8);
2478 * snd_soc_limit_volume - Set new limit to an existing volume control.
2480 * @codec: where to look for the control
2481 * @name: Name of the control
2482 * @max: new maximum limit
2484 * Return 0 for success, else error.
2486 int snd_soc_limit_volume(struct snd_soc_codec *codec,
2487 const char *name, int max)
2489 struct snd_card *card = codec->card->snd_card;
2490 struct snd_kcontrol *kctl;
2491 struct soc_mixer_control *mc;
2495 /* Sanity check for name and max */
2496 if (unlikely(!name || max <= 0))
2499 list_for_each_entry(kctl, &card->controls, list) {
2500 if (!strncmp(kctl->id.name, name, sizeof(kctl->id.name))) {
2506 mc = (struct soc_mixer_control *)kctl->private_value;
2507 if (max <= mc->max) {
2508 mc->platform_max = max;
2514 EXPORT_SYMBOL_GPL(snd_soc_limit_volume);
2517 * snd_soc_info_volsw_2r_sx - double with tlv and variable data size
2518 * mixer info callback
2519 * @kcontrol: mixer control
2520 * @uinfo: control element information
2522 * Returns 0 for success.
2524 int snd_soc_info_volsw_2r_sx(struct snd_kcontrol *kcontrol,
2525 struct snd_ctl_elem_info *uinfo)
2527 struct soc_mixer_control *mc =
2528 (struct soc_mixer_control *)kcontrol->private_value;
2532 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2534 uinfo->value.integer.min = 0;
2535 uinfo->value.integer.max = max-min;
2539 EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r_sx);
2542 * snd_soc_get_volsw_2r_sx - double with tlv and variable data size
2543 * mixer get callback
2544 * @kcontrol: mixer control
2545 * @uinfo: control element information
2547 * Returns 0 for success.
2549 int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol,
2550 struct snd_ctl_elem_value *ucontrol)
2552 struct soc_mixer_control *mc =
2553 (struct soc_mixer_control *)kcontrol->private_value;
2554 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2555 unsigned int mask = (1<<mc->shift)-1;
2557 int val = snd_soc_read(codec, mc->reg) & mask;
2558 int valr = snd_soc_read(codec, mc->rreg) & mask;
2560 ucontrol->value.integer.value[0] = ((val & 0xff)-min) & mask;
2561 ucontrol->value.integer.value[1] = ((valr & 0xff)-min) & mask;
2564 EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r_sx);
2567 * snd_soc_put_volsw_2r_sx - double with tlv and variable data size
2568 * mixer put callback
2569 * @kcontrol: mixer control
2570 * @uinfo: control element information
2572 * Returns 0 for success.
2574 int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol,
2575 struct snd_ctl_elem_value *ucontrol)
2577 struct soc_mixer_control *mc =
2578 (struct soc_mixer_control *)kcontrol->private_value;
2579 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2580 unsigned int mask = (1<<mc->shift)-1;
2583 unsigned int val, valr, oval, ovalr;
2585 val = ((ucontrol->value.integer.value[0]+min) & 0xff);
2587 valr = ((ucontrol->value.integer.value[1]+min) & 0xff);
2590 oval = snd_soc_read(codec, mc->reg) & mask;
2591 ovalr = snd_soc_read(codec, mc->rreg) & mask;
2595 ret = snd_soc_write(codec, mc->reg, val);
2599 if (ovalr != valr) {
2600 ret = snd_soc_write(codec, mc->rreg, valr);
2607 EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r_sx);
2610 * snd_soc_dai_set_sysclk - configure DAI system or master clock.
2612 * @clk_id: DAI specific clock ID
2613 * @freq: new clock frequency in Hz
2614 * @dir: new clock direction - input/output.
2616 * Configures the DAI master (MCLK) or system (SYSCLK) clocking.
2618 int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
2619 unsigned int freq, int dir)
2621 if (dai->driver && dai->driver->ops->set_sysclk)
2622 return dai->driver->ops->set_sysclk(dai, clk_id, freq, dir);
2623 else if (dai->codec && dai->codec->driver->set_sysclk)
2624 return dai->codec->driver->set_sysclk(dai->codec, clk_id,
2629 EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
2632 * snd_soc_codec_set_sysclk - configure CODEC system or master clock.
2634 * @clk_id: DAI specific clock ID
2635 * @freq: new clock frequency in Hz
2636 * @dir: new clock direction - input/output.
2638 * Configures the CODEC master (MCLK) or system (SYSCLK) clocking.
2640 int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
2641 unsigned int freq, int dir)
2643 if (codec->driver->set_sysclk)
2644 return codec->driver->set_sysclk(codec, clk_id, freq, dir);
2648 EXPORT_SYMBOL_GPL(snd_soc_codec_set_sysclk);
2651 * snd_soc_dai_set_clkdiv - configure DAI clock dividers.
2653 * @div_id: DAI specific clock divider ID
2654 * @div: new clock divisor.
2656 * Configures the clock dividers. This is used to derive the best DAI bit and
2657 * frame clocks from the system or master clock. It's best to set the DAI bit
2658 * and frame clocks as low as possible to save system power.
2660 int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
2661 int div_id, int div)
2663 if (dai->driver && dai->driver->ops->set_clkdiv)
2664 return dai->driver->ops->set_clkdiv(dai, div_id, div);
2668 EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv);
2671 * snd_soc_dai_set_pll - configure DAI PLL.
2673 * @pll_id: DAI specific PLL ID
2674 * @source: DAI specific source for the PLL
2675 * @freq_in: PLL input clock frequency in Hz
2676 * @freq_out: requested PLL output clock frequency in Hz
2678 * Configures and enables PLL to generate output clock based on input clock.
2680 int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
2681 unsigned int freq_in, unsigned int freq_out)
2683 if (dai->driver && dai->driver->ops->set_pll)
2684 return dai->driver->ops->set_pll(dai, pll_id, source,
2686 else if (dai->codec && dai->codec->driver->set_pll)
2687 return dai->codec->driver->set_pll(dai->codec, pll_id, source,
2692 EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll);
2695 * snd_soc_codec_set_pll - configure codec PLL.
2697 * @pll_id: DAI specific PLL ID
2698 * @source: DAI specific source for the PLL
2699 * @freq_in: PLL input clock frequency in Hz
2700 * @freq_out: requested PLL output clock frequency in Hz
2702 * Configures and enables PLL to generate output clock based on input clock.
2704 int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
2705 unsigned int freq_in, unsigned int freq_out)
2707 if (codec->driver->set_pll)
2708 return codec->driver->set_pll(codec, pll_id, source,
2713 EXPORT_SYMBOL_GPL(snd_soc_codec_set_pll);
2716 * snd_soc_dai_set_fmt - configure DAI hardware audio format.
2718 * @fmt: SND_SOC_DAIFMT_ format value.
2720 * Configures the DAI hardware format and clocking.
2722 int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
2724 if (dai->driver && dai->driver->ops->set_fmt)
2725 return dai->driver->ops->set_fmt(dai, fmt);
2729 EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
2732 * snd_soc_dai_set_tdm_slot - configure DAI TDM.
2734 * @tx_mask: bitmask representing active TX slots.
2735 * @rx_mask: bitmask representing active RX slots.
2736 * @slots: Number of slots in use.
2737 * @slot_width: Width in bits for each slot.
2739 * Configures a DAI for TDM operation. Both mask and slots are codec and DAI
2742 int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
2743 unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
2745 if (dai->driver && dai->driver->ops->set_tdm_slot)
2746 return dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask,
2751 EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot);
2754 * snd_soc_dai_set_channel_map - configure DAI audio channel map
2756 * @tx_num: how many TX channels
2757 * @tx_slot: pointer to an array which imply the TX slot number channel
2759 * @rx_num: how many RX channels
2760 * @rx_slot: pointer to an array which imply the RX slot number channel
2763 * configure the relationship between channel number and TDM slot number.
2765 int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
2766 unsigned int tx_num, unsigned int *tx_slot,
2767 unsigned int rx_num, unsigned int *rx_slot)
2769 if (dai->driver && dai->driver->ops->set_channel_map)
2770 return dai->driver->ops->set_channel_map(dai, tx_num, tx_slot,
2775 EXPORT_SYMBOL_GPL(snd_soc_dai_set_channel_map);
2778 * snd_soc_dai_set_tristate - configure DAI system or master clock.
2780 * @tristate: tristate enable
2782 * Tristates the DAI so that others can use it.
2784 int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
2786 if (dai->driver && dai->driver->ops->set_tristate)
2787 return dai->driver->ops->set_tristate(dai, tristate);
2791 EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate);
2794 * snd_soc_dai_digital_mute - configure DAI system or master clock.
2796 * @mute: mute enable
2798 * Mutes the DAI DAC.
2800 int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute)
2802 if (dai->driver && dai->driver->ops->digital_mute)
2803 return dai->driver->ops->digital_mute(dai, mute);
2807 EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);
2810 * snd_soc_register_card - Register a card with the ASoC core
2812 * @card: Card to register
2815 int snd_soc_register_card(struct snd_soc_card *card)
2819 if (!card->name || !card->dev)
2822 dev_set_drvdata(card->dev, card);
2824 snd_soc_initialize_card_lists(card);
2826 soc_init_card_debugfs(card);
2828 card->rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime) *
2829 (card->num_links + card->num_aux_devs),
2831 if (card->rtd == NULL)
2833 card->rtd_aux = &card->rtd[card->num_links];
2835 for (i = 0; i < card->num_links; i++)
2836 card->rtd[i].dai_link = &card->dai_link[i];
2838 INIT_LIST_HEAD(&card->list);
2839 card->instantiated = 0;
2840 mutex_init(&card->mutex);
2842 mutex_lock(&client_mutex);
2843 list_add(&card->list, &card_list);
2844 snd_soc_instantiate_cards();
2845 mutex_unlock(&client_mutex);
2847 dev_dbg(card->dev, "Registered card '%s'\n", card->name);
2851 EXPORT_SYMBOL_GPL(snd_soc_register_card);
2854 * snd_soc_unregister_card - Unregister a card with the ASoC core
2856 * @card: Card to unregister
2859 int snd_soc_unregister_card(struct snd_soc_card *card)
2861 if (card->instantiated)
2862 soc_cleanup_card_resources(card);
2863 mutex_lock(&client_mutex);
2864 list_del(&card->list);
2865 mutex_unlock(&client_mutex);
2866 dev_dbg(card->dev, "Unregistered card '%s'\n", card->name);
2870 EXPORT_SYMBOL_GPL(snd_soc_unregister_card);
2873 * Simplify DAI link configuration by removing ".-1" from device names
2874 * and sanitizing names.
2876 static char *fmt_single_name(struct device *dev, int *id)
2878 char *found, name[NAME_SIZE];
2881 if (dev_name(dev) == NULL)
2884 strlcpy(name, dev_name(dev), NAME_SIZE);
2886 /* are we a "%s.%d" name (platform and SPI components) */
2887 found = strstr(name, dev->driver->name);
2890 if (sscanf(&found[strlen(dev->driver->name)], ".%d", id) == 1) {
2892 /* discard ID from name if ID == -1 */
2894 found[strlen(dev->driver->name)] = '\0';
2898 /* I2C component devices are named "bus-addr" */
2899 if (sscanf(name, "%x-%x", &id1, &id2) == 2) {
2900 char tmp[NAME_SIZE];
2902 /* create unique ID number from I2C addr and bus */
2903 *id = ((id1 & 0xffff) << 16) + id2;
2905 /* sanitize component name for DAI link creation */
2906 snprintf(tmp, NAME_SIZE, "%s.%s", dev->driver->name, name);
2907 strlcpy(name, tmp, NAME_SIZE);
2912 return kstrdup(name, GFP_KERNEL);
2916 * Simplify DAI link naming for single devices with multiple DAIs by removing
2917 * any ".-1" and using the DAI name (instead of device name).
2919 static inline char *fmt_multiple_name(struct device *dev,
2920 struct snd_soc_dai_driver *dai_drv)
2922 if (dai_drv->name == NULL) {
2923 printk(KERN_ERR "asoc: error - multiple DAI %s registered with no name\n",
2928 return kstrdup(dai_drv->name, GFP_KERNEL);
2932 * snd_soc_register_dai - Register a DAI with the ASoC core
2934 * @dai: DAI to register
2936 int snd_soc_register_dai(struct device *dev,
2937 struct snd_soc_dai_driver *dai_drv)
2939 struct snd_soc_dai *dai;
2941 dev_dbg(dev, "dai register %s\n", dev_name(dev));
2943 dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL);
2947 /* create DAI component name */
2948 dai->name = fmt_single_name(dev, &dai->id);
2949 if (dai->name == NULL) {
2955 dai->driver = dai_drv;
2956 if (!dai->driver->ops)
2957 dai->driver->ops = &null_dai_ops;
2959 mutex_lock(&client_mutex);
2960 list_add(&dai->list, &dai_list);
2961 snd_soc_instantiate_cards();
2962 mutex_unlock(&client_mutex);
2964 pr_debug("Registered DAI '%s'\n", dai->name);
2968 EXPORT_SYMBOL_GPL(snd_soc_register_dai);
2971 * snd_soc_unregister_dai - Unregister a DAI from the ASoC core
2973 * @dai: DAI to unregister
2975 void snd_soc_unregister_dai(struct device *dev)
2977 struct snd_soc_dai *dai;
2979 list_for_each_entry(dai, &dai_list, list) {
2980 if (dev == dai->dev)
2986 mutex_lock(&client_mutex);
2987 list_del(&dai->list);
2988 mutex_unlock(&client_mutex);
2990 pr_debug("Unregistered DAI '%s'\n", dai->name);
2994 EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
2997 * snd_soc_register_dais - Register multiple DAIs with the ASoC core
2999 * @dai: Array of DAIs to register
3000 * @count: Number of DAIs
3002 int snd_soc_register_dais(struct device *dev,
3003 struct snd_soc_dai_driver *dai_drv, size_t count)
3005 struct snd_soc_dai *dai;
3008 dev_dbg(dev, "dai register %s #%Zu\n", dev_name(dev), count);
3010 for (i = 0; i < count; i++) {
3012 dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL);
3018 /* create DAI component name */
3019 dai->name = fmt_multiple_name(dev, &dai_drv[i]);
3020 if (dai->name == NULL) {
3027 dai->driver = &dai_drv[i];
3028 if (dai->driver->id)
3029 dai->id = dai->driver->id;
3032 if (!dai->driver->ops)
3033 dai->driver->ops = &null_dai_ops;
3035 mutex_lock(&client_mutex);
3036 list_add(&dai->list, &dai_list);
3037 mutex_unlock(&client_mutex);
3039 pr_debug("Registered DAI '%s'\n", dai->name);
3042 mutex_lock(&client_mutex);
3043 snd_soc_instantiate_cards();
3044 mutex_unlock(&client_mutex);
3048 for (i--; i >= 0; i--)
3049 snd_soc_unregister_dai(dev);
3053 EXPORT_SYMBOL_GPL(snd_soc_register_dais);
3056 * snd_soc_unregister_dais - Unregister multiple DAIs from the ASoC core
3058 * @dai: Array of DAIs to unregister
3059 * @count: Number of DAIs
3061 void snd_soc_unregister_dais(struct device *dev, size_t count)
3065 for (i = 0; i < count; i++)
3066 snd_soc_unregister_dai(dev);
3068 EXPORT_SYMBOL_GPL(snd_soc_unregister_dais);
3071 * snd_soc_register_platform - Register a platform with the ASoC core
3073 * @platform: platform to register
3075 int snd_soc_register_platform(struct device *dev,
3076 struct snd_soc_platform_driver *platform_drv)
3078 struct snd_soc_platform *platform;
3080 dev_dbg(dev, "platform register %s\n", dev_name(dev));
3082 platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL);
3083 if (platform == NULL)
3086 /* create platform component name */
3087 platform->name = fmt_single_name(dev, &platform->id);
3088 if (platform->name == NULL) {
3093 platform->dev = dev;
3094 platform->driver = platform_drv;
3096 mutex_lock(&client_mutex);
3097 list_add(&platform->list, &platform_list);
3098 snd_soc_instantiate_cards();
3099 mutex_unlock(&client_mutex);
3101 pr_debug("Registered platform '%s'\n", platform->name);
3105 EXPORT_SYMBOL_GPL(snd_soc_register_platform);
3108 * snd_soc_unregister_platform - Unregister a platform from the ASoC core
3110 * @platform: platform to unregister
3112 void snd_soc_unregister_platform(struct device *dev)
3114 struct snd_soc_platform *platform;
3116 list_for_each_entry(platform, &platform_list, list) {
3117 if (dev == platform->dev)
3123 mutex_lock(&client_mutex);
3124 list_del(&platform->list);
3125 mutex_unlock(&client_mutex);
3127 pr_debug("Unregistered platform '%s'\n", platform->name);
3128 kfree(platform->name);
3131 EXPORT_SYMBOL_GPL(snd_soc_unregister_platform);
3133 static u64 codec_format_map[] = {
3134 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE,
3135 SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE,
3136 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE,
3137 SNDRV_PCM_FMTBIT_U24_LE | SNDRV_PCM_FMTBIT_U24_BE,
3138 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE,
3139 SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_U32_BE,
3140 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_U24_3BE,
3141 SNDRV_PCM_FMTBIT_U24_3LE | SNDRV_PCM_FMTBIT_U24_3BE,
3142 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE,
3143 SNDRV_PCM_FMTBIT_U20_3LE | SNDRV_PCM_FMTBIT_U20_3BE,
3144 SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE,
3145 SNDRV_PCM_FMTBIT_U18_3LE | SNDRV_PCM_FMTBIT_U18_3BE,
3146 SNDRV_PCM_FMTBIT_FLOAT_LE | SNDRV_PCM_FMTBIT_FLOAT_BE,
3147 SNDRV_PCM_FMTBIT_FLOAT64_LE | SNDRV_PCM_FMTBIT_FLOAT64_BE,
3148 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE
3149 | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE,
3152 /* Fix up the DAI formats for endianness: codecs don't actually see
3153 * the endianness of the data but we're using the CPU format
3154 * definitions which do need to include endianness so we ensure that
3155 * codec DAIs always have both big and little endian variants set.
3157 static void fixup_codec_formats(struct snd_soc_pcm_stream *stream)
3161 for (i = 0; i < ARRAY_SIZE(codec_format_map); i++)
3162 if (stream->formats & codec_format_map[i])
3163 stream->formats |= codec_format_map[i];
3167 * snd_soc_register_codec - Register a codec with the ASoC core
3169 * @codec: codec to register
3171 int snd_soc_register_codec(struct device *dev,
3172 const struct snd_soc_codec_driver *codec_drv,
3173 struct snd_soc_dai_driver *dai_drv,
3177 struct snd_soc_codec *codec;
3180 dev_dbg(dev, "codec register %s\n", dev_name(dev));
3182 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
3186 /* create CODEC component name */
3187 codec->name = fmt_single_name(dev, &codec->id);
3188 if (codec->name == NULL) {
3193 if (codec_drv->compress_type)
3194 codec->compress_type = codec_drv->compress_type;
3196 codec->compress_type = SND_SOC_FLAT_COMPRESSION;
3198 codec->write = codec_drv->write;
3199 codec->read = codec_drv->read;
3200 codec->volatile_register = codec_drv->volatile_register;
3201 codec->readable_register = codec_drv->readable_register;
3202 codec->writable_register = codec_drv->writable_register;
3203 codec->dapm.bias_level = SND_SOC_BIAS_OFF;
3204 codec->dapm.dev = dev;
3205 codec->dapm.codec = codec;
3206 codec->dapm.seq_notifier = codec_drv->seq_notifier;
3208 codec->driver = codec_drv;
3209 codec->num_dai = num_dai;
3210 mutex_init(&codec->mutex);
3212 /* allocate CODEC register cache */
3213 if (codec_drv->reg_cache_size && codec_drv->reg_word_size) {
3214 reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
3215 codec->reg_size = reg_size;
3216 /* it is necessary to make a copy of the default register cache
3217 * because in the case of using a compression type that requires
3218 * the default register cache to be marked as __devinitconst the
3219 * kernel might have freed the array by the time we initialize
3222 if (codec_drv->reg_cache_default) {
3223 codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default,
3224 reg_size, GFP_KERNEL);
3225 if (!codec->reg_def_copy) {
3232 if (codec_drv->reg_access_size && codec_drv->reg_access_default) {
3233 if (!codec->volatile_register)
3234 codec->volatile_register = snd_soc_default_volatile_register;
3235 if (!codec->readable_register)
3236 codec->readable_register = snd_soc_default_readable_register;
3237 if (!codec->writable_register)
3238 codec->writable_register = snd_soc_default_writable_register;
3241 for (i = 0; i < num_dai; i++) {
3242 fixup_codec_formats(&dai_drv[i].playback);
3243 fixup_codec_formats(&dai_drv[i].capture);
3246 /* register any DAIs */
3248 ret = snd_soc_register_dais(dev, dai_drv, num_dai);
3253 mutex_lock(&client_mutex);
3254 list_add(&codec->list, &codec_list);
3255 snd_soc_instantiate_cards();
3256 mutex_unlock(&client_mutex);
3258 pr_debug("Registered codec '%s'\n", codec->name);
3262 kfree(codec->reg_def_copy);
3263 codec->reg_def_copy = NULL;
3268 EXPORT_SYMBOL_GPL(snd_soc_register_codec);
3271 * snd_soc_unregister_codec - Unregister a codec from the ASoC core
3273 * @codec: codec to unregister
3275 void snd_soc_unregister_codec(struct device *dev)
3277 struct snd_soc_codec *codec;
3280 list_for_each_entry(codec, &codec_list, list) {
3281 if (dev == codec->dev)
3288 for (i = 0; i < codec->num_dai; i++)
3289 snd_soc_unregister_dai(dev);
3291 mutex_lock(&client_mutex);
3292 list_del(&codec->list);
3293 mutex_unlock(&client_mutex);
3295 pr_debug("Unregistered codec '%s'\n", codec->name);
3297 snd_soc_cache_exit(codec);
3298 kfree(codec->reg_def_copy);
3302 EXPORT_SYMBOL_GPL(snd_soc_unregister_codec);
3304 static int __init snd_soc_init(void)
3306 #ifdef CONFIG_DEBUG_FS
3307 snd_soc_debugfs_root = debugfs_create_dir("asoc", NULL);
3308 if (IS_ERR(snd_soc_debugfs_root) || !snd_soc_debugfs_root) {
3310 "ASoC: Failed to create debugfs directory\n");
3311 snd_soc_debugfs_root = NULL;
3314 if (!debugfs_create_file("codecs", 0444, snd_soc_debugfs_root, NULL,
3316 pr_warn("ASoC: Failed to create CODEC list debugfs file\n");
3318 if (!debugfs_create_file("dais", 0444, snd_soc_debugfs_root, NULL,
3320 pr_warn("ASoC: Failed to create DAI list debugfs file\n");
3322 if (!debugfs_create_file("platforms", 0444, snd_soc_debugfs_root, NULL,
3323 &platform_list_fops))
3324 pr_warn("ASoC: Failed to create platform list debugfs file\n");
3327 snd_soc_util_init();
3329 return platform_driver_register(&soc_driver);
3331 module_init(snd_soc_init);
3333 static void __exit snd_soc_exit(void)
3335 snd_soc_util_exit();
3337 #ifdef CONFIG_DEBUG_FS
3338 debugfs_remove_recursive(snd_soc_debugfs_root);
3340 platform_driver_unregister(&soc_driver);
3342 module_exit(snd_soc_exit);
3344 /* Module information */
3345 MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk");
3346 MODULE_DESCRIPTION("ALSA SoC Core");
3347 MODULE_LICENSE("GPL");
3348 MODULE_ALIAS("platform:soc-audio");