2 * sound/soc/sprd/dai/vaudio/vaudio.c
4 * SpreadTrum Vaudio for the dsp stream.
6 * Copyright (C) 2012 SpreadTrum Ltd.
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 #include "sprd-asoc-debug.h"
18 #define pr_fmt(fmt) pr_sprd_fmt(" DSP ") fmt
20 #include <linux/module.h>
21 #include <linux/moduleparam.h>
22 #include <linux/init.h>
23 #include <linux/kernel.h>
24 #include <linux/string.h>
25 #include <linux/sysfs.h>
26 #include <linux/stat.h>
27 #include <linux/device.h>
28 #include <linux/platform_device.h>
29 #include <linux/slab.h>
32 #include <sound/core.h>
33 #include <sound/soc.h>
34 #include <sound/soc-dapm.h>
35 #include <sound/pcm_params.h>
36 #include <sound/tlv.h>
38 #include "sprd-asoc-common.h"
41 static int sprd_vaudio_startup(struct snd_pcm_substream *substream,
42 struct snd_soc_dai *dai)
44 struct snd_soc_card *card = dai->card;
47 sp_asoc_pr_dbg("%s\n", __func__);
49 kfree(snd_soc_dai_get_dma_data(dai, substream));
50 snd_soc_dai_set_dma_data(dai, substream, NULL);
52 for (i = 0; i < card->num_rtd; i++) {
53 card->rtd[i].dai_link->ignore_suspend = 1;
59 static void sprd_vaudio_shutdown(struct snd_pcm_substream *substream,
60 struct snd_soc_dai *dai)
62 struct snd_soc_card *card = dai->card;
65 sp_asoc_pr_dbg("%s\n", __func__);
67 for (i = 0; i < card->num_rtd; i++) {
68 card->rtd[i].dai_link->ignore_suspend = 0;
72 static struct snd_soc_dai_ops sprd_vaudio_dai_ops = {
73 .startup = sprd_vaudio_startup,
74 .shutdown = sprd_vaudio_shutdown,
77 struct snd_soc_dai_driver sprd_vaudio_dai[] = {
79 .id = VAUDIO_MAGIC_ID,
84 .rates = SNDRV_PCM_RATE_CONTINUOUS,
85 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
89 .rates = SNDRV_PCM_RATE_CONTINUOUS,
90 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
91 .ops = &sprd_vaudio_dai_ops,
94 .id = VAUDIO_MAGIC_ID + 1,
95 .name = "vaudio-ad23",
98 .channels_max = 2, /*ad23 */
99 .rates = SNDRV_PCM_RATE_CONTINUOUS,
100 .formats = SNDRV_PCM_FMTBIT_S16_LE,
102 .ops = &sprd_vaudio_dai_ops,
106 static const struct snd_soc_component_driver sprd_vaudio_component = {
110 static int sprd_vaudio_drv_probe(struct platform_device *pdev)
114 sp_asoc_pr_dbg("%s\n", __func__);
117 snd_soc_register_component(&pdev->dev, &sprd_vaudio_component,
119 ARRAY_SIZE(sprd_vaudio_dai));
121 sp_asoc_pr_dbg("return %i\n", ret);
126 static int sprd_vaudio_drv_remove(struct platform_device *pdev)
128 snd_soc_unregister_component(&pdev->dev);
133 static const struct of_device_id vaudio_of_match[] = {
134 {.compatible = "sprd,vaudio",},
138 MODULE_DEVICE_TABLE(of, vaudio_of_match);
141 static struct platform_driver sprd_vaudio_driver = {
144 .owner = THIS_MODULE,
145 .of_match_table = of_match_ptr(vaudio_of_match),
148 .probe = sprd_vaudio_drv_probe,
149 .remove = sprd_vaudio_drv_remove,
152 module_platform_driver(sprd_vaudio_driver);
154 MODULE_DESCRIPTION("SPRD ASoC Vaudio CUP-DAI driver for the DSP");
155 MODULE_AUTHOR("Ken Kuang <ken.kuang@spreadtrum.com>");
156 MODULE_LICENSE("GPL");
157 MODULE_ALIAS("cpu-dai:sprd-vaudio");