From a0f87ce5bdfca334994eaf2e31fa9a85c2b1d18e Mon Sep 17 00:00:00 2001 From: Tushar Behera Date: Fri, 18 May 2012 16:02:37 +0530 Subject: [PATCH] ASoC: codec: i2s_stub: Add a dummy I2S based codec driver HDMI (in Samsung EXYNOS based SoCs) can be configured to source audio data from I2S bus. For boards on which there are no external audio chips, we still need to create a I2S-based soundcard with a dummy codec driver to enable I2S subsystem to pump data to the I2S bus, which can be used by HDMI module. This patch adds a I2S stub audio codec driver which can be used to create a I2S soundcard when external chip is not there. Signed-off-by: Tushar Behera --- sound/soc/codecs/Kconfig | 3 ++ sound/soc/codecs/Makefile | 2 + sound/soc/codecs/i2s_stub.c | 74 +++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 sound/soc/codecs/i2s_stub.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 983d087aa92a..8d6bd6b47099 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -258,6 +258,9 @@ config SND_SOC_CX20442 tristate depends on TTY +config SND_SOC_I2S_STUB + tristate + config SND_SOC_JZ4740_CODEC select REGMAP_MMIO tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index bc126764a44d..349b4aa5c9ab 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -30,6 +30,7 @@ snd-soc-da732x-objs := da732x.o snd-soc-da9055-objs := da9055.o snd-soc-bt-sco-objs := bt-sco.o snd-soc-dmic-objs := dmic.o +snd-soc-i2s-stub-objs := i2s_stub.o snd-soc-isabelle-objs := isabelle.o snd-soc-jz4740-codec-objs := jz4740.o snd-soc-l3-objs := l3.o @@ -163,6 +164,7 @@ obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o +obj-$(CONFIG_SND_SOC_I2S_STUB) += snd-soc-i2s-stub.o obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o obj-$(CONFIG_SND_SOC_JZ4740_CODEC) += snd-soc-jz4740-codec.o obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o diff --git a/sound/soc/codecs/i2s_stub.c b/sound/soc/codecs/i2s_stub.c new file mode 100644 index 000000000000..df6b08944ed3 --- /dev/null +++ b/sound/soc/codecs/i2s_stub.c @@ -0,0 +1,74 @@ +/* + * ALSA SoC I2S Stub Codec driver + * + * This driver is used by controllers which can operate in I2S mode with + * Stub codec driver for I2S mode. + * + * The code is based on sound/soc/codec/spdif_transceiver.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include + + +#define I2S_STUB_RATES SNDRV_PCM_RATE_8000_192000 +#define I2S_STUB_FORMATS SNDRV_PCM_FMTBIT_S16_LE + +static struct snd_soc_codec_driver soc_codec_i2s_stub; + +static struct snd_soc_dai_driver i2s_stub_dai = { + .name = "i2s-stub-hifi", + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 2, + .rates = I2S_STUB_RATES, + .formats = I2S_STUB_FORMATS, + }, +}; + +static int i2s_stub_probe(struct platform_device *pdev) +{ + return snd_soc_register_codec(&pdev->dev, &soc_codec_i2s_stub, + &i2s_stub_dai, 1); +} + +static int i2s_stub_remove(struct platform_device *pdev) +{ + snd_soc_unregister_codec(&pdev->dev); + return 0; +} + +#ifdef CONFIG_OF +static const struct of_device_id i2s_stub_dt_ids[] = { + { .compatible = "linux,i2s-stub", }, + { } +}; +MODULE_DEVICE_TABLE(of, i2s_stub_dt_ids); +#endif + +static struct platform_driver i2s_stub_driver = { + .probe = i2s_stub_probe, + .remove = i2s_stub_remove, + .driver = { + .name = "i2s-stub", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(i2s_stub_dt_ids), + }, +}; + +module_platform_driver(i2s_stub_driver); + +MODULE_AUTHOR("Tushar Behera"); +MODULE_DESCRIPTION("I2S stub codec driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform: i2s-stub");