From 1d660dce6750f335a1810974e44bbe43b3e4c5f1 Mon Sep 17 00:00:00 2001 From: Sugar Zhang Date: Mon, 16 May 2016 10:38:06 +0800 Subject: [PATCH] ASoC: dw-hdmi-audio: add dummy codec for DesignWare hdmi this patch is depend on rk hdmi framework, so no need to upstream. Change-Id: If9892c21c4c1cf7dfbb4efed67d188892b1b4bda Signed-off-by: Sugar Zhang --- .../bindings/sound/dw-hdmi-audio.txt | 5 + sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/dw-hdmi-audio.c | 107 ++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/dw-hdmi-audio.txt create mode 100644 sound/soc/codecs/dw-hdmi-audio.c diff --git a/Documentation/devicetree/bindings/sound/dw-hdmi-audio.txt b/Documentation/devicetree/bindings/sound/dw-hdmi-audio.txt new file mode 100644 index 000000000000..41fdb4d1a4bf --- /dev/null +++ b/Documentation/devicetree/bindings/sound/dw-hdmi-audio.txt @@ -0,0 +1,5 @@ +dw hdmi audio interface + +Required properties: + +- compatible : Should be "dw-hdmi-audio". diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index f6f944aaf7af..1ed8570fb6b7 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -449,6 +449,10 @@ config SND_SOC_DA732X config SND_SOC_DA9055 tristate +config SND_SOC_DW_HDMI_AUDIO + tristate "dw hdmi audio" + depends on RK_HDMI + config SND_SOC_BT_SCO tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 4682308b912f..e79f80617918 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -53,6 +53,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-dw-hdmi-audio-objs := dw-hdmi-audio.o snd-soc-bt-sco-objs := bt-sco.o snd-soc-dmic-objs := dmic.o snd-soc-es8316-objs := es8316.o @@ -249,6 +250,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_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 obj-$(CONFIG_SND_SOC_ES8316) += snd-soc-es8316.o diff --git a/sound/soc/codecs/dw-hdmi-audio.c b/sound/soc/codecs/dw-hdmi-audio.c new file mode 100644 index 000000000000..33cd801ecd72 --- /dev/null +++ b/sound/soc/codecs/dw-hdmi-audio.c @@ -0,0 +1,107 @@ +/* + * dw-hdmi-audio.c + * + * DesignerWare ALSA SoC Codec driver for DW HDMI audio. + * Copyright (c) 2016 Fuzhou Rockchip Electronics Co., Ltd + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see .* + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../../drivers/video/rockchip/hdmi/rockchip-hdmi.h" + +static int snd_dw_hdmi_dai_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *codec_dai) +{ + return snd_config_hdmi_audio(params); +} + +static const struct snd_soc_dapm_widget snd_dw_hdmi_audio_widgets[] = { + SND_SOC_DAPM_OUTPUT("TX"), +}; + +static const struct snd_soc_dapm_route snd_dw_hdmi_audio_routes[] = { + { "TX", NULL, "Playback" }, +}; + +static const struct snd_soc_dai_ops dw_hdmi_dai_ops = { + .hw_params = snd_dw_hdmi_dai_hw_params, +}; + +static struct snd_soc_dai_driver dw_hdmi_audio_dai = { + .name = "dw-hdmi-hifi", + .playback = { + .stream_name = "Playback", + .channels_min = 2, + .channels_max = 8, + .rates = SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | + SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE, + }, + .ops = &dw_hdmi_dai_ops, +}; + +static const struct snd_soc_codec_driver dw_hdmi_audio = { + .dapm_widgets = snd_dw_hdmi_audio_widgets, + .num_dapm_widgets = ARRAY_SIZE(snd_dw_hdmi_audio_widgets), + .dapm_routes = snd_dw_hdmi_audio_routes, + .num_dapm_routes = ARRAY_SIZE(snd_dw_hdmi_audio_routes), +}; + +static int dw_hdmi_audio_probe(struct platform_device *pdev) +{ + int ret; + + ret = snd_soc_register_codec(&pdev->dev, &dw_hdmi_audio, + &dw_hdmi_audio_dai, 1); + if (ret) + dev_err(&pdev->dev, "register codec failed (%d)\n", ret); + + return ret; +} + +static int dw_hdmi_audio_remove(struct platform_device *pdev) +{ + snd_soc_unregister_codec(&pdev->dev); + + return 0; +} + +static const struct of_device_id dw_hdmi_audio_ids[] = { + { .compatible = "dw-hdmi-audio", }, + { } +}; + +static struct platform_driver dw_hdmi_audio_driver = { + .driver = { + .name = "dw-hdmi-audio", + .of_match_table = of_match_ptr(dw_hdmi_audio_ids), + }, + .probe = dw_hdmi_audio_probe, + .remove = dw_hdmi_audio_remove, +}; +module_platform_driver(dw_hdmi_audio_driver); + +MODULE_AUTHOR("Sugar Zhang "); +MODULE_DESCRIPTION("DW HDMI Audio ASoC Interface"); +MODULE_LICENSE("GPL"); -- 2.34.1