diff options
author | Sugar Zhang <sugar.zhang@rock-chips.com> | 2018-03-23 14:59:51 +0800 |
---|---|---|
committer | Tao Huang <huangtao@rock-chips.com> | 2018-03-26 11:41:36 +0800 |
commit | ecf08a42085cc2fb29a52e3b6af448b812a17809 (patch) | |
tree | 11d9a6a31bd64de64e9e85fe7ad06e6133dcb1ea | |
parent | 4519e311620998c4d3ed3dd0631c97a1daab4a2c (diff) |
ASoC: codec: add dummy codec for rockchip
Change-Id: I86cb74994d49178525e15b61b5056fd3995e904d
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
-rw-r--r-- | Documentation/devicetree/bindings/sound/rockchip,dummy-codec.txt | 11 | ||||
-rw-r--r-- | sound/soc/codecs/Kconfig | 3 | ||||
-rw-r--r-- | sound/soc/codecs/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/codecs/dummy-codec.c | 84 |
4 files changed, 100 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/rockchip,dummy-codec.txt b/Documentation/devicetree/bindings/sound/rockchip,dummy-codec.txt new file mode 100644 index 000000000000..e1ee65168c39 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/rockchip,dummy-codec.txt @@ -0,0 +1,11 @@ +* Rockchip Dummy Codec + +Required properties: + +- compatible: "rockchip,dummy-codec" + +Example for rk3308 dummy codec: + +dummy_codec: dummy-codec { + compatible = "rockchip,dummy-codec"; +}; diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index b6ae5a8016c8..b0bc586c4118 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -471,6 +471,9 @@ config SND_SOC_DA732X config SND_SOC_DA9055 tristate +config SND_SOC_DUMMY_CODEC + tristate "dummy codec" + config SND_SOC_DW_HDMI_AUDIO tristate "dw hdmi audio" depends on RK_HDMI diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 666ff31de4ff..7fe7433f2643 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -55,6 +55,7 @@ snd-soc-da7213-objs := da7213.o snd-soc-da7219-objs := da7219.o da7219-aad.o snd-soc-da732x-objs := da732x.o snd-soc-da9055-objs := da9055.o +snd-soc-dummy-codec-objs := dummy-codec.o snd-soc-dw-hdmi-audio-objs := dw-hdmi-audio.o snd-soc-bt-sco-objs := bt-sco.o snd-soc-dmic-objs := dmic.o @@ -267,6 +268,7 @@ obj-$(CONFIG_SND_SOC_DA7213) += snd-soc-da7213.o obj-$(CONFIG_SND_SOC_DA7219) += snd-soc-da7219.o obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o +obj-$(CONFIG_SND_SOC_DUMMY_CODEC) += snd-soc-dummy-codec.o obj-$(CONFIG_SND_SOC_DW_HDMI_AUDIO) += snd-soc-dw-hdmi-audio.o obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o diff --git a/sound/soc/codecs/dummy-codec.c b/sound/soc/codecs/dummy-codec.c new file mode 100644 index 000000000000..d8c97a27d9f2 --- /dev/null +++ b/sound/soc/codecs/dummy-codec.c @@ -0,0 +1,84 @@ +/* + * dummy_codec.c -- dummy audio codec for rockchip + * + * Copyright (C) 2018 Fuzhou Rockchip Electronics Co., 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 <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/slab.h> +#include <linux/of.h> +#include <linux/of_gpio.h> +#include <sound/soc.h> +#include <sound/pcm.h> +#include <sound/initval.h> + +struct snd_soc_dai_driver dummy_dai = { + .name = "dummy_codec", + .playback = { + .stream_name = "Dummy Playback", + .channels_min = 2, + .channels_max = 8, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats = (SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S20_3LE | + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE), + }, + .capture = { + .stream_name = "Dummy Capture", + .channels_min = 2, + .channels_max = 8, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats = (SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S20_3LE | + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE), + }, +}; + +static struct snd_soc_codec_driver soc_dummy_codec; + +static int rockchip_dummy_codec_probe(struct platform_device *pdev) +{ + return snd_soc_register_codec(&pdev->dev, &soc_dummy_codec, + &dummy_dai, 1); +} + +static int rockchip_dummy_codec_remove(struct platform_device *pdev) +{ + snd_soc_unregister_codec(&pdev->dev); + + return 0; +} + +static const struct of_device_id rockchip_dummy_codec_of_match[] = { + { .compatible = "rockchip,dummy-codec", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_dummy_codec_of_match); + +static struct platform_driver rockchip_dummy_codec_driver = { + .driver = { + .name = "dummy_codec", + .of_match_table = of_match_ptr(rockchip_dummy_codec_of_match), + }, + .probe = rockchip_dummy_codec_probe, + .remove = rockchip_dummy_codec_remove, +}; + +module_platform_driver(rockchip_dummy_codec_driver); + +MODULE_AUTHOR("Sugar <sugar.zhang@rock-chips.com>"); +MODULE_DESCRIPTION("Rockchip Dummy Codec Driver"); +MODULE_LICENSE("GPL v2"); |