4 * DesignerWare ALSA SoC Codec driver for DW HDMI audio.
5 * Copyright (c) 2016 Fuzhou Rockchip Electronics Co., Ltd
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.*
20 #include <linux/init.h>
21 #include <linux/module.h>
22 #include <linux/device.h>
23 #include <sound/pcm.h>
24 #include <sound/soc.h>
25 #include <sound/core.h>
26 #include <sound/initval.h>
27 #include <sound/pcm_params.h>
28 #include "../../../drivers/video/rockchip/hdmi/rockchip-hdmi.h"
30 static int snd_dw_hdmi_dai_hw_params(struct snd_pcm_substream *substream,
31 struct snd_pcm_hw_params *params,
32 struct snd_soc_dai *codec_dai)
34 return snd_config_hdmi_audio(params);
37 static const struct snd_soc_dapm_widget snd_dw_hdmi_audio_widgets[] = {
38 SND_SOC_DAPM_OUTPUT("TX"),
41 static const struct snd_soc_dapm_route snd_dw_hdmi_audio_routes[] = {
42 { "TX", NULL, "Playback" },
45 static const struct snd_soc_dai_ops dw_hdmi_dai_ops = {
46 .hw_params = snd_dw_hdmi_dai_hw_params,
49 static struct snd_soc_dai_driver dw_hdmi_audio_dai = {
50 .name = "dw-hdmi-hifi",
52 .stream_name = "Playback",
55 .rates = SNDRV_PCM_RATE_32000 |
56 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
57 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
58 SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000,
59 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
61 .ops = &dw_hdmi_dai_ops,
64 static const struct snd_soc_codec_driver dw_hdmi_audio = {
65 .dapm_widgets = snd_dw_hdmi_audio_widgets,
66 .num_dapm_widgets = ARRAY_SIZE(snd_dw_hdmi_audio_widgets),
67 .dapm_routes = snd_dw_hdmi_audio_routes,
68 .num_dapm_routes = ARRAY_SIZE(snd_dw_hdmi_audio_routes),
71 static int dw_hdmi_audio_probe(struct platform_device *pdev)
75 ret = snd_soc_register_codec(&pdev->dev, &dw_hdmi_audio,
76 &dw_hdmi_audio_dai, 1);
78 dev_err(&pdev->dev, "register codec failed (%d)\n", ret);
83 static int dw_hdmi_audio_remove(struct platform_device *pdev)
85 snd_soc_unregister_codec(&pdev->dev);
90 static const struct of_device_id dw_hdmi_audio_ids[] = {
91 { .compatible = "dw-hdmi-audio", },
95 static struct platform_driver dw_hdmi_audio_driver = {
97 .name = "dw-hdmi-audio",
98 .of_match_table = of_match_ptr(dw_hdmi_audio_ids),
100 .probe = dw_hdmi_audio_probe,
101 .remove = dw_hdmi_audio_remove,
103 module_platform_driver(dw_hdmi_audio_driver);
105 MODULE_AUTHOR("Sugar Zhang <sugar.zhang@rock-chips.com>");
106 MODULE_DESCRIPTION("DW HDMI Audio ASoC Interface");
107 MODULE_LICENSE("GPL");