From de73a7b38e4972af64c5e3e10798bdfca0277a10 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Thu, 11 Apr 2013 13:56:34 +0400 Subject: [PATCH] asoc: add dummy codec --- sound/soc/codecs/Kconfig | 10 +++++ sound/soc/codecs/Makefile | 2 + sound/soc/codecs/dummy.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 sound/soc/codecs/dummy.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 45b7256..1f5a704 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -10,6 +10,7 @@ config SND_SOC_I2C_AND_SPI config SND_SOC_ALL_CODECS tristate "Build all ASoC CODEC drivers" + select SND_SOC_DUMMY select SND_SOC_88PM860X if MFD_88PM860X select SND_SOC_L3 select SND_SOC_AB8500_CODEC if ABX500_CORE @@ -134,6 +135,15 @@ config SND_SOC_ALL_CODECS If unsure select "N". +config SND_SOC_DUMMY + tristate + +config SND_SOC_DUMMY_NAME + string "Name of the dummy codec" + depends on SND_SOC_DUMMY + help + Specify platform device name, if any, or leave blank + config SND_SOC_88PM860X tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 6a3b3c3..7514d5e 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -1,3 +1,4 @@ +snd-soc-dummy-objs := dummy.o snd-soc-88pm860x-objs := 88pm860x-codec.o snd-soc-ab8500-codec-objs := ab8500-codec.o snd-soc-ac97-objs := ac97.o @@ -121,6 +122,7 @@ snd-soc-wm-hubs-objs := wm_hubs.o snd-soc-max9877-objs := max9877.o snd-soc-tpa6130a2-objs := tpa6130a2.o +obj-$(CONFIG_SND_SOC_DUMMY) += snd-soc-dummy.o obj-$(CONFIG_SND_SOC_88PM860X) += snd-soc-88pm860x.o obj-$(CONFIG_SND_SOC_AB8500_CODEC) += snd-soc-ab8500-codec.o obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o diff --git a/sound/soc/codecs/dummy.c b/sound/soc/codecs/dummy.c new file mode 100644 index 0000000..28e04d3 --- /dev/null +++ b/sound/soc/codecs/dummy.c @@ -0,0 +1,94 @@ +/* + * ALSA SoC dummy driver + * + * This driver is used by controllers which can operate in DIT (SPDI/F) where + * no codec is needed. This file provides stub codec that can be used + * in these configurations. TI DaVinci Audio controller uses this driver. + * + * Author: Stas Sergeev + * + * Based on spdif_transciever.c by Steve Chen, + * Copyright: (C) 2009 MontaVista Software, Inc., + * Copyright: (C) 2009 Texas Instruments, India + * + * 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 + +#define DRV_NAME "dummy-codec" + +#define STUB_RATES SNDRV_PCM_RATE_8000_96000 +#define STUB_FORMATS SNDRV_PCM_FMTBIT_S16_LE + + +static struct snd_soc_codec_driver soc_codec_codec_dit; + +static struct snd_soc_dai_driver dummy_stub_dai = { + .name = "dummy-hifi", + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 384, + .rates = STUB_RATES, + .formats = STUB_FORMATS, + }, +}; + +static int codec_dummy_probe(struct platform_device *pdev) +{ + return snd_soc_register_codec(&pdev->dev, &soc_codec_codec_dit, + &dummy_stub_dai, 1); +} + +static int codec_dummy_remove(struct platform_device *pdev) +{ + snd_soc_unregister_codec(&pdev->dev); + return 0; +} + +static struct platform_driver codec_dummy_driver = { + .probe = codec_dummy_probe, + .remove = codec_dummy_remove, + .driver = { + .owner = THIS_MODULE, + }, +}; + +static struct platform_device *pdev; + +static int __init dummy_modinit(void) +{ + if (!CONFIG_SND_SOC_DUMMY_NAME[0]) { + struct platform_device *pd; + pd = platform_device_register_simple(DRV_NAME, -1, NULL, 0); + if (IS_ERR(pd)) + return PTR_ERR(pd); + pdev = pd; + codec_dummy_driver.driver.name = DRV_NAME; + } else { + codec_dummy_driver.driver.name = CONFIG_SND_SOC_DUMMY_NAME; + } + return platform_driver_register(&codec_dummy_driver); +} + +static void __exit dummy_exit(void) +{ + platform_driver_unregister(&codec_dummy_driver); + if (pdev) + platform_device_unregister(pdev); +} + +module_init(dummy_modinit); +module_exit(dummy_exit); + +MODULE_AUTHOR("Stas Sergeev "); +MODULE_DESCRIPTION("dummy codec driver"); +MODULE_LICENSE("GPL"); -- 1.7.11.7