[Gta04-owner] [PATCH 3/3] gta04 soc audio: add skeleton for audio devices
John Ogness
gta04 at ogness.net
Sun Sep 4 15:51:02 CEST 2011
This patch adds the basic skeleton for the 4 audio devices of
the GTA04. The files will need to be expanded in order to
provide real hardware support.
Signed-off-by: John Ogness <john.ogness at linutronix.de>
---
sound/soc/omap/Makefile | 2
sound/soc/omap/gta04-audio.c | 128 ++++++++++++++++++++++++++++++
sound/soc/omap/gta04-fm.c | 132 +++++++++++++++++++++++++++++++
sound/soc/omap/gta04-headset.c | 127 +++++++++++++++++++++++++++++
sound/soc/omap/gta04-voice.c | 127 +++++++++++++++++++++++++++++
5 files changed, 515 insertions(+), 1 deletion(-)
commit 190275293013081a4d39d954e6ffca1d01c283e7
Author: John Ogness <john.ogness at linutronix.de>
Date: Sun Sep 4 15:31:20 2011 +0200
gta04: add audio devices
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile
index 3afd542..5eaedfd 100644
--- a/sound/soc/omap/Makefile
+++ b/sound/soc/omap/Makefile
@@ -16,7 +16,7 @@ snd-soc-am3517evm-objs := am3517evm.o
snd-soc-sdp3430-objs := sdp3430.o
snd-soc-omap3pandora-objs := omap3pandora.o
snd-soc-omap3beagle-objs := omap3beagle.o
-snd-soc-gta04-objs := gta04.o
+snd-soc-gta04-objs := gta04-audio.o gta04-voice.o gta04-headset.o gta04-fm.o
snd-soc-zoom2-objs := zoom2.o
snd-soc-igep0020-objs := igep0020.o
diff --git a/sound/soc/omap/gta04-audio.c b/sound/soc/omap/gta04-audio.c
new file mode 100644
index 0000000..7bd2eea
--- /dev/null
+++ b/sound/soc/omap/gta04-audio.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2011 John Ogness
+ * Author: John Ogness <john.ogness at linutronix.de>
+ *
+ * based on sound/soc/omap/omap3beagle.c by
+ * Steve Sakoman <steve at sakoman.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
+ * whether express or implied; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include <linux/platform_device.h>
+
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include "omap-mcbsp.h"
+#include "omap-pcm.h"
+#include "../codecs/twl4030.h"
+
+static int gta04_audio_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ /* setup codec dai and cpu dai hardware params */
+ return 0;
+}
+
+static int gta04_audio_init(struct snd_soc_codec *codec)
+{
+ /* add controls */
+ /* add routes */
+ /* setup pins */
+
+ snd_soc_dapm_sync(codec);
+ return 0;
+}
+
+static int gta04_audio_startup(struct snd_pcm_substream *substream)
+{
+ /* enable clock used by codec */
+ return 0;
+}
+
+static void gta04_audio_shutdown(struct snd_pcm_substream *substream)
+{
+ /* disable clock used by codec */
+}
+
+static struct snd_soc_ops gta04_audio_ops = {
+ .startup = gta04_audio_startup,
+ .hw_params = gta04_audio_hw_params,
+ .shutdown = gta04_audio_shutdown,
+};
+
+/* digital audio interface glue - connects codec <--> cpu */
+static struct snd_soc_dai_link gta04_audio_dai = {
+ .name = "twl4030",
+ .stream_name = "twl4030",
+ .cpu_dai = &omap_mcbsp_dai[0],
+ .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI],
+ .init = gta04_audio_init,
+ .ops = >a04_audio_ops,
+};
+
+/* audio machine driver */
+static struct snd_soc_card gta04_audio_card = {
+ .name = "gta04-audio",
+ .platform = &omap_soc_platform,
+ .dai_link = >a04_audio_dai,
+ .num_links = 1,
+};
+
+/* audio subsystem */
+static struct snd_soc_device gta04_audio_devdata = {
+ .card = >a04_audio_card,
+ .codec_dev = &soc_codec_dev_twl4030,
+ .codec_data = NULL, /* set if necessary */
+};
+
+static struct platform_device *gta04_audio_snd_device;
+
+static int __init gta04_audio_soc_init(void)
+{
+ struct device *dev;
+ int ret;
+
+ pr_info("gta04-audio SoC init\n");
+
+ gta04_audio_snd_device = platform_device_alloc("soc-audio", 0);
+ if (!gta04_audio_snd_device) {
+ printk(KERN_ERR "platform device allocation failed\n");
+ return -ENOMEM;
+ }
+
+ dev = >a04_audio_snd_device->dev;
+
+ platform_set_drvdata(gta04_audio_snd_device, >a04_audio_devdata);
+ gta04_audio_devdata.dev = >a04_audio_snd_device->dev;
+ *(unsigned int *)gta04_audio_dai.cpu_dai->private_data = 0;
+
+ ret = platform_device_add(gta04_audio_snd_device);
+ if (ret) {
+ printk(KERN_ERR "unable to add platform device\n");
+ platform_device_put(gta04_audio_snd_device);
+ }
+
+ return ret;
+}
+
+static void __exit gta04_audio_soc_exit(void)
+{
+ platform_device_unregister(gta04_audio_snd_device);
+}
+
+module_init(gta04_audio_soc_init);
+module_exit(gta04_audio_soc_exit);
+
+MODULE_AUTHOR("John Ogness <john.ogness at linutronix.de>");
+MODULE_DESCRIPTION("ALSA SoC GTA04 Audio");
+MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/omap/gta04-fm.c b/sound/soc/omap/gta04-fm.c
new file mode 100644
index 0000000..1019d5d
--- /dev/null
+++ b/sound/soc/omap/gta04-fm.c
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2011 John Ogness
+ * Author: John Ogness <john.ogness at linutronix.de>
+ *
+ * based on sound/soc/omap/omap3beagle.c by
+ * Steve Sakoman <steve at sakoman.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
+ * whether express or implied; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include <linux/platform_device.h>
+
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include "omap-mcbsp.h"
+#include "omap-pcm.h"
+#include "../codecs/si47xx.h"
+
+static int gta04_fm_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ /* setup codec dai and cpu dai hardware params */
+ return 0;
+}
+
+static int gta04_fm_init(struct snd_soc_codec *codec)
+{
+ /* add controls */
+ /* add routes */
+ /* setup pins */
+
+ snd_soc_dapm_sync(codec);
+ return 0;
+}
+
+static int gta04_fm_startup(struct snd_pcm_substream *substream)
+{
+ /* enable clock used by codec */
+ return 0;
+}
+
+static void gta04_fm_shutdown(struct snd_pcm_substream *substream)
+{
+ /* disable clock used by codec */
+}
+
+static struct snd_soc_ops gta04_fm_ops = {
+ .startup = gta04_fm_startup,
+ .hw_params = gta04_fm_hw_params,
+ .shutdown = gta04_fm_shutdown,
+};
+
+/* digital fm interface glue - connects codec <--> cpu */
+static struct snd_soc_dai_link gta04_fm_dai = {
+ .name = "Si47xx",
+ .stream_name = "Si47xx",
+ .cpu_dai = &omap_mcbsp_dai[3],
+ .codec_dai = &si47xx_dai,
+ .init = gta04_fm_init,
+ .ops = >a04_fm_ops,
+};
+
+/* fm machine driver */
+static struct snd_soc_card gta04_fm_card = {
+ .name = "gta04-fm",
+ .platform = &omap_soc_platform,
+ .dai_link = >a04_fm_dai,
+ .num_links = 1,
+};
+
+/* fm subsystem */
+static struct si47xx_setup_data gta04_fm_soc_data = {
+ .i2c_bus = 2,
+ .i2c_address = 0x11,
+};
+static struct snd_soc_device gta04_fm_devdata = {
+ .card = >a04_fm_card,
+ .codec_dev = &soc_codec_dev_si47xx,
+ .codec_data = >a04_fm_soc_data,
+};
+
+static struct platform_device *gta04_fm_snd_device;
+
+static int __init gta04_fm_soc_init(void)
+{
+ struct device *dev;
+ int ret;
+
+ pr_info("gta04-fm SoC init\n");
+
+ gta04_fm_snd_device = platform_device_alloc("soc-audio", 3);
+ if (!gta04_fm_snd_device) {
+ printk(KERN_ERR "platform device allocation failed\n");
+ return -ENOMEM;
+ }
+
+ dev = >a04_fm_snd_device->dev;
+
+ platform_set_drvdata(gta04_fm_snd_device, >a04_fm_devdata);
+ gta04_fm_devdata.dev = >a04_fm_snd_device->dev;
+ *(unsigned int *)gta04_fm_dai.cpu_dai->private_data = 3;
+
+ ret = platform_device_add(gta04_fm_snd_device);
+ if (ret) {
+ printk(KERN_ERR "unable to add platform device\n");
+ platform_device_put(gta04_fm_snd_device);
+ }
+
+ return ret;
+}
+
+static void __exit gta04_fm_soc_exit(void)
+{
+ platform_device_unregister(gta04_fm_snd_device);
+}
+
+module_init(gta04_fm_soc_init);
+module_exit(gta04_fm_soc_exit);
+
+MODULE_AUTHOR("John Ogness <john.ogness at linutronix.de>");
+MODULE_DESCRIPTION("ALSA SoC GTA04 FM");
+MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/omap/gta04-headset.c b/sound/soc/omap/gta04-headset.c
new file mode 100644
index 0000000..3cbf9c1
--- /dev/null
+++ b/sound/soc/omap/gta04-headset.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2011 John Ogness
+ * Author: John Ogness <john.ogness at linutronix.de>
+ *
+ * based on sound/soc/omap/omap3beagle.c by
+ * Steve Sakoman <steve at sakoman.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
+ * whether express or implied; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include <linux/platform_device.h>
+
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include "omap-mcbsp.h"
+#include "omap-pcm.h"
+#include "../codecs/w2cbw003-bt.h"
+
+static int gta04_headset_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ /* setup codec dai and cpu dai hardware params */
+ return 0;
+}
+
+static int gta04_headset_init(struct snd_soc_codec *codec)
+{
+ /* add controls */
+ /* add routes */
+ /* setup pins */
+
+ snd_soc_dapm_sync(codec);
+ return 0;
+}
+
+static int gta04_headset_startup(struct snd_pcm_substream *substream)
+{
+ /* enable clock used by codec */
+ return 0;
+}
+
+static void gta04_headset_shutdown(struct snd_pcm_substream *substream)
+{
+ /* disable clock used by codec */
+}
+
+static struct snd_soc_ops gta04_headset_ops = {
+ .startup = gta04_headset_startup,
+ .hw_params = gta04_headset_hw_params,
+ .shutdown = gta04_headset_shutdown,
+};
+
+/* digital headset interface glue - connects codec <--> cpu */
+static struct snd_soc_dai_link gta04_headset_dai = {
+ .name = "W2CBW003",
+ .stream_name = "W2CBW003",
+ .cpu_dai = &omap_mcbsp_dai[2],
+ .codec_dai = &w2cbw003_dai,
+ .init = gta04_headset_init,
+ .ops = >a04_headset_ops,
+};
+
+/* headset machine driver */
+static struct snd_soc_card gta04_headset_card = {
+ .name = "gta04-headset",
+ .platform = &omap_soc_platform,
+ .dai_link = >a04_headset_dai,
+ .num_links = 1,
+};
+
+/* headset subsystem */
+static struct snd_soc_device gta04_headset_devdata = {
+ .card = >a04_headset_card,
+ .codec_dev = &soc_codec_dev_w2cbw003,
+};
+
+static struct platform_device *gta04_headset_snd_device;
+
+static int __init gta04_headset_soc_init(void)
+{
+ struct device *dev;
+ int ret;
+
+ pr_info("gta04-headset SoC init\n");
+
+ gta04_headset_snd_device = platform_device_alloc("soc-audio", 2);
+ if (!gta04_headset_snd_device) {
+ printk(KERN_ERR "platform device allocation failed\n");
+ return -ENOMEM;
+ }
+
+ dev = >a04_headset_snd_device->dev;
+
+ platform_set_drvdata(gta04_headset_snd_device, >a04_headset_devdata);
+ gta04_headset_devdata.dev = >a04_headset_snd_device->dev;
+ *(unsigned int *)gta04_headset_dai.cpu_dai->private_data = 2;
+
+ ret = platform_device_add(gta04_headset_snd_device);
+ if (ret) {
+ printk(KERN_ERR "unable to add platform device\n");
+ platform_device_put(gta04_headset_snd_device);
+ }
+
+ return ret;
+}
+
+static void __exit gta04_headset_soc_exit(void)
+{
+ platform_device_unregister(gta04_headset_snd_device);
+}
+
+module_init(gta04_headset_soc_init);
+module_exit(gta04_headset_soc_exit);
+
+MODULE_AUTHOR("John Ogness <john.ogness at linutronix.de>");
+MODULE_DESCRIPTION("ALSA SoC GTA04 Headset");
+MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/omap/gta04-voice.c b/sound/soc/omap/gta04-voice.c
new file mode 100644
index 0000000..1f1450c
--- /dev/null
+++ b/sound/soc/omap/gta04-voice.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2011 John Ogness
+ * Author: John Ogness <john.ogness at linutronix.de>
+ *
+ * based on sound/soc/omap/omap3beagle.c by
+ * Steve Sakoman <steve at sakoman.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
+ * whether express or implied; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include <linux/platform_device.h>
+
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include "omap-mcbsp.h"
+#include "omap-pcm.h"
+#include "../codecs/gtm601.h"
+
+static int gta04_voice_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ /* setup codec dai and cpu dai hardware params */
+ return 0;
+}
+
+static int gta04_voice_init(struct snd_soc_codec *codec)
+{
+ /* add controls */
+ /* add routes */
+ /* setup pins */
+
+ snd_soc_dapm_sync(codec);
+ return 0;
+}
+
+static int gta04_voice_startup(struct snd_pcm_substream *substream)
+{
+ /* enable clock used by codec */
+ return 0;
+}
+
+static void gta04_voice_shutdown(struct snd_pcm_substream *substream)
+{
+ /* disable clock used by codec */
+}
+
+static struct snd_soc_ops gta04_voice_ops = {
+ .startup = gta04_voice_startup,
+ .hw_params = gta04_voice_hw_params,
+ .shutdown = gta04_voice_shutdown,
+};
+
+/* digital voice interface glue - connects codec <--> cpu */
+static struct snd_soc_dai_link gta04_voice_dai = {
+ .name = "GTM601",
+ .stream_name = "GTM601",
+ .cpu_dai = &omap_mcbsp_dai[1],
+ .codec_dai = >m601_dai,
+ .init = gta04_voice_init,
+ .ops = >a04_voice_ops,
+};
+
+/* voice machine driver */
+static struct snd_soc_card gta04_voice_card = {
+ .name = "gta04-voice",
+ .platform = &omap_soc_platform,
+ .dai_link = >a04_voice_dai,
+ .num_links = 1,
+};
+
+/* voice subsystem */
+static struct snd_soc_device gta04_voice_devdata = {
+ .card = >a04_voice_card,
+ .codec_dev = &soc_codec_dev_gtm601,
+};
+
+static struct platform_device *gta04_voice_snd_device;
+
+static int __init gta04_voice_soc_init(void)
+{
+ struct device *dev;
+ int ret;
+
+ pr_info("gta04-voice SoC init\n");
+
+ gta04_voice_snd_device = platform_device_alloc("soc-audio", 1);
+ if (!gta04_voice_snd_device) {
+ printk(KERN_ERR "platform device allocation failed\n");
+ return -ENOMEM;
+ }
+
+ dev = >a04_voice_snd_device->dev;
+
+ platform_set_drvdata(gta04_voice_snd_device, >a04_voice_devdata);
+ gta04_voice_devdata.dev = >a04_voice_snd_device->dev;
+ *(unsigned int *)gta04_voice_dai.cpu_dai->private_data = 1;
+
+ ret = platform_device_add(gta04_voice_snd_device);
+ if (ret) {
+ printk(KERN_ERR "unable to add platform device\n");
+ platform_device_put(gta04_voice_snd_device);
+ }
+
+ return ret;
+}
+
+static void __exit gta04_voice_soc_exit(void)
+{
+ platform_device_unregister(gta04_voice_snd_device);
+}
+
+module_init(gta04_voice_soc_init);
+module_exit(gta04_voice_soc_exit);
+
+MODULE_AUTHOR("John Ogness <john.ogness at linutronix.de>");
+MODULE_DESCRIPTION("ALSA SoC GTA04 Voice");
+MODULE_LICENSE("GPL v2");
More information about the Gta04-owner
mailing list