ASoC: dw-hdmi-audio: add dummy codec for DesignWare hdmi
authorSugar Zhang <sugar.zhang@rock-chips.com>
Mon, 16 May 2016 02:38:06 +0000 (10:38 +0800)
committerSugar Zhang <sugar.zhang@rock-chips.com>
Mon, 16 May 2016 02:41:51 +0000 (10:41 +0800)
this patch is depend on rk hdmi framework, so no need to upstream.

Change-Id: If9892c21c4c1cf7dfbb4efed67d188892b1b4bda
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
Documentation/devicetree/bindings/sound/dw-hdmi-audio.txt [new file with mode: 0644]
sound/soc/codecs/Kconfig
sound/soc/codecs/Makefile
sound/soc/codecs/dw-hdmi-audio.c [new file with mode: 0644]

diff --git a/Documentation/devicetree/bindings/sound/dw-hdmi-audio.txt b/Documentation/devicetree/bindings/sound/dw-hdmi-audio.txt
new file mode 100644 (file)
index 0000000..41fdb4d
--- /dev/null
@@ -0,0 +1,5 @@
+dw hdmi audio interface
+
+Required properties:
+
+- compatible : Should be "dw-hdmi-audio".
index f6f944aaf7af580a9b9ad4e4d9b51a7a0025d578..1ed8570fb6b7b8adb0fab853cfd7d95edd84f56d 100644 (file)
@@ -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
 
index 4682308b912f7fc6bc0c2d40d6db8531d69145c4..e79f80617918887be4b15b25e228eb04041a387c 100644 (file)
@@ -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 (file)
index 0000000..33cd801
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.*
+ *
+ */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/core.h>
+#include <sound/initval.h>
+#include <sound/pcm_params.h>
+#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 <sugar.zhang@rock-chips.com>");
+MODULE_DESCRIPTION("DW HDMI Audio ASoC Interface");
+MODULE_LICENSE("GPL");