summaryrefslogtreecommitdiff
path: root/sound/soc/sprd/dai/vaudio
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2017-08-30 08:25:59 +0000
committerYuval Adam <_@yuv.al>2017-08-30 08:25:59 +0000
commit8e4bff4cab0ddac6060645b0715210484d02ff40 (patch)
tree3a5c3024371a04692a3a6d9974d001cdff8ebf84 /sound/soc/sprd/dai/vaudio
Initial file dump from open source releaseHEADmaster
Diffstat (limited to 'sound/soc/sprd/dai/vaudio')
-rw-r--r--sound/soc/sprd/dai/vaudio/Kconfig2
-rw-r--r--sound/soc/sprd/dai/vaudio/Makefile6
-rw-r--r--sound/soc/sprd/dai/vaudio/vaudio.c157
-rw-r--r--sound/soc/sprd/dai/vaudio/vaudio.h22
4 files changed, 187 insertions, 0 deletions
diff --git a/sound/soc/sprd/dai/vaudio/Kconfig b/sound/soc/sprd/dai/vaudio/Kconfig
new file mode 100644
index 00000000..7249ff93
--- /dev/null
+++ b/sound/soc/sprd/dai/vaudio/Kconfig
@@ -0,0 +1,2 @@
+config SND_SOC_SPRD_VAUDIO
+ tristate# "Vaudio"
diff --git a/sound/soc/sprd/dai/vaudio/Makefile b/sound/soc/sprd/dai/vaudio/Makefile
new file mode 100644
index 00000000..35056496
--- /dev/null
+++ b/sound/soc/sprd/dai/vaudio/Makefile
@@ -0,0 +1,6 @@
+# SPRD Vaudio Support
+SPRD_SOUND_TREE := sound/soc/sprd/
+KBUILD_CFLAGS += -I$(SPRD_SOUND_TREE) -I$(SPRD_SOUND_TREE)/dai
+
+snd-soc-sprd-vaudio-objs := vaudio.o
+obj-$(CONFIG_SND_SOC_SPRD_VAUDIO) += snd-soc-sprd-vaudio.o
diff --git a/sound/soc/sprd/dai/vaudio/vaudio.c b/sound/soc/sprd/dai/vaudio/vaudio.c
new file mode 100644
index 00000000..5f42cc1b
--- /dev/null
+++ b/sound/soc/sprd/dai/vaudio/vaudio.c
@@ -0,0 +1,157 @@
+/*
+ * sound/soc/sprd/dai/vaudio/vaudio.c
+ *
+ * SpreadTrum Vaudio for the dsp stream.
+ *
+ * Copyright (C) 2012 SpreadTrum Ltd.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+#include "sprd-asoc-debug.h"
+#define pr_fmt(fmt) pr_sprd_fmt(" DSP ") fmt
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/sysfs.h>
+#include <linux/stat.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+
+#include <sound/core.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/pcm_params.h>
+#include <sound/tlv.h>
+
+#include "sprd-asoc-common.h"
+#include "vaudio.h"
+
+static int sprd_vaudio_startup(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ struct snd_soc_card *card = dai->card;
+ int i;
+
+ sp_asoc_pr_dbg("%s\n", __func__);
+
+ kfree(snd_soc_dai_get_dma_data(dai, substream));
+ snd_soc_dai_set_dma_data(dai, substream, NULL);
+
+ for (i = 0; i < card->num_rtd; i++) {
+ card->rtd[i].dai_link->ignore_suspend = 1;
+ }
+
+ return 0;
+}
+
+static void sprd_vaudio_shutdown(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ struct snd_soc_card *card = dai->card;
+ int i;
+
+ sp_asoc_pr_dbg("%s\n", __func__);
+
+ for (i = 0; i < card->num_rtd; i++) {
+ card->rtd[i].dai_link->ignore_suspend = 0;
+ }
+}
+
+static struct snd_soc_dai_ops sprd_vaudio_dai_ops = {
+ .startup = sprd_vaudio_startup,
+ .shutdown = sprd_vaudio_shutdown,
+};
+
+struct snd_soc_dai_driver sprd_vaudio_dai[] = {
+ {
+ .id = VAUDIO_MAGIC_ID,
+ .name = "vaudio",
+ .playback = {
+ .channels_min = 1,
+ .channels_max = 2,
+ .rates = SNDRV_PCM_RATE_CONTINUOUS,
+ .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+ .capture = {
+ .channels_min = 1,
+ .channels_max = 2,
+ .rates = SNDRV_PCM_RATE_CONTINUOUS,
+ .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+ .ops = &sprd_vaudio_dai_ops,
+ },
+ {
+ .id = VAUDIO_MAGIC_ID + 1,
+ .name = "vaudio-ad23",
+ .capture = {
+ .channels_min = 1,
+ .channels_max = 2, /*ad23 */
+ .rates = SNDRV_PCM_RATE_CONTINUOUS,
+ .formats = SNDRV_PCM_FMTBIT_S16_LE,
+ },
+ .ops = &sprd_vaudio_dai_ops,
+ },
+};
+
+static const struct snd_soc_component_driver sprd_vaudio_component = {
+ .name = "vaudio",
+};
+
+static int sprd_vaudio_drv_probe(struct platform_device *pdev)
+{
+ int ret;
+
+ sp_asoc_pr_dbg("%s\n", __func__);
+
+ ret =
+ snd_soc_register_component(&pdev->dev, &sprd_vaudio_component,
+ sprd_vaudio_dai,
+ ARRAY_SIZE(sprd_vaudio_dai));
+
+ sp_asoc_pr_dbg("return %i\n", ret);
+
+ return ret;
+}
+
+static int sprd_vaudio_drv_remove(struct platform_device *pdev)
+{
+ snd_soc_unregister_component(&pdev->dev);
+ return 0;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id vaudio_of_match[] = {
+ {.compatible = "sprd,vaudio",},
+ {},
+};
+
+MODULE_DEVICE_TABLE(of, vaudio_of_match);
+#endif
+
+static struct platform_driver sprd_vaudio_driver = {
+ .driver = {
+ .name = "vaudio",
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(vaudio_of_match),
+ },
+
+ .probe = sprd_vaudio_drv_probe,
+ .remove = sprd_vaudio_drv_remove,
+};
+
+module_platform_driver(sprd_vaudio_driver);
+
+MODULE_DESCRIPTION("SPRD ASoC Vaudio CUP-DAI driver for the DSP");
+MODULE_AUTHOR("Ken Kuang <ken.kuang@spreadtrum.com>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("cpu-dai:sprd-vaudio");
diff --git a/sound/soc/sprd/dai/vaudio/vaudio.h b/sound/soc/sprd/dai/vaudio/vaudio.h
new file mode 100644
index 00000000..05377885
--- /dev/null
+++ b/sound/soc/sprd/dai/vaudio/vaudio.h
@@ -0,0 +1,22 @@
+/*
+ * sound/soc/sprd/dai/vaudio/vaudio.h
+ *
+ * SpreadTrum Vaudio for the dsp stream.
+ *
+ * Copyright (C) 2012 SpreadTrum Ltd.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+#ifndef __SPRD_VAUDIO_PCM_H
+#define __SPRD_VAUDIO_PCM_H
+
+#define VAUDIO_MAGIC_ID (0x5AD)
+
+#endif /* __SPRD_VAUDIO_PCM_H */