blob: 1087fd5f9917b013e68e555607d3b6d811d42bd3 [file] [log] [blame]
Ricardo Neri54520302012-05-18 01:42:33 -05001/*
Barry Songbf7c6e62013-05-16 14:08:07 +08002 * ALSA SoC codec driver for HDMI audio codecs.
Ricardo Neri54520302012-05-18 01:42:33 -05003 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
4 * Author: Ricardo Neri <ricardo.neri@ti.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
19 *
20 */
21#include <linux/module.h>
22#include <sound/soc.h>
Sachin Kamata6b34312014-04-04 11:29:09 +053023#include <linux/of.h>
Jyri Sarha0f7f3d12013-12-20 12:40:16 +020024#include <linux/of_device.h>
Ricardo Neri54520302012-05-18 01:42:33 -050025
26#define DRV_NAME "hdmi-audio-codec"
27
Mark Brownc34e51b2013-08-19 12:17:36 +010028static const struct snd_soc_dapm_widget hdmi_widgets[] = {
29 SND_SOC_DAPM_INPUT("RX"),
30 SND_SOC_DAPM_OUTPUT("TX"),
31};
32
33static const struct snd_soc_dapm_route hdmi_routes[] = {
34 { "Capture", NULL, "RX" },
35 { "TX", NULL, "Playback" },
36};
Ricardo Neri54520302012-05-18 01:42:33 -050037
Barry Songbf7c6e62013-05-16 14:08:07 +080038static struct snd_soc_dai_driver hdmi_codec_dai = {
39 .name = "hdmi-hifi",
Ricardo Neri54520302012-05-18 01:42:33 -050040 .playback = {
Mark Brownc34e51b2013-08-19 12:17:36 +010041 .stream_name = "Playback",
Ricardo Neri54520302012-05-18 01:42:33 -050042 .channels_min = 2,
43 .channels_max = 8,
44 .rates = SNDRV_PCM_RATE_32000 |
45 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
46 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
47 SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000,
48 .formats = SNDRV_PCM_FMTBIT_S16_LE |
Jyri Sarhac600e952013-11-19 14:12:25 +020049 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
Ricardo Neri54520302012-05-18 01:42:33 -050050 },
Rongjun Yingc6c09252013-07-17 14:12:16 +080051 .capture = {
Mark Brownc34e51b2013-08-19 12:17:36 +010052 .stream_name = "Capture",
Rongjun Yingc6c09252013-07-17 14:12:16 +080053 .channels_min = 2,
54 .channels_max = 2,
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 |
60 SNDRV_PCM_FMTBIT_S24_LE,
61 },
62
Ricardo Neri54520302012-05-18 01:42:33 -050063};
64
Jyri Sarha0f7f3d12013-12-20 12:40:16 +020065#ifdef CONFIG_OF
66static const struct of_device_id hdmi_audio_codec_ids[] = {
67 { .compatible = "linux,hdmi-audio", },
68 { }
69};
70MODULE_DEVICE_TABLE(of, hdmi_audio_codec_ids);
71#endif
72
Mark Brownc34e51b2013-08-19 12:17:36 +010073static struct snd_soc_codec_driver hdmi_codec = {
74 .dapm_widgets = hdmi_widgets,
75 .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets),
76 .dapm_routes = hdmi_routes,
77 .num_dapm_routes = ARRAY_SIZE(hdmi_routes),
78};
79
Barry Songbf7c6e62013-05-16 14:08:07 +080080static int hdmi_codec_probe(struct platform_device *pdev)
Ricardo Neri54520302012-05-18 01:42:33 -050081{
Barry Songbf7c6e62013-05-16 14:08:07 +080082 return snd_soc_register_codec(&pdev->dev, &hdmi_codec,
83 &hdmi_codec_dai, 1);
Ricardo Neri54520302012-05-18 01:42:33 -050084}
85
Barry Songbf7c6e62013-05-16 14:08:07 +080086static int hdmi_codec_remove(struct platform_device *pdev)
Ricardo Neri54520302012-05-18 01:42:33 -050087{
88 snd_soc_unregister_codec(&pdev->dev);
89 return 0;
90}
91
Barry Songbf7c6e62013-05-16 14:08:07 +080092static struct platform_driver hdmi_codec_driver = {
Ricardo Neri54520302012-05-18 01:42:33 -050093 .driver = {
94 .name = DRV_NAME,
95 .owner = THIS_MODULE,
Jyri Sarha0f7f3d12013-12-20 12:40:16 +020096 .of_match_table = of_match_ptr(hdmi_audio_codec_ids),
Ricardo Neri54520302012-05-18 01:42:33 -050097 },
98
Barry Songbf7c6e62013-05-16 14:08:07 +080099 .probe = hdmi_codec_probe,
100 .remove = hdmi_codec_remove,
Ricardo Neri54520302012-05-18 01:42:33 -0500101};
102
Barry Songbf7c6e62013-05-16 14:08:07 +0800103module_platform_driver(hdmi_codec_driver);
Ricardo Neri54520302012-05-18 01:42:33 -0500104
105MODULE_AUTHOR("Ricardo Neri <ricardo.neri@ti.com>");
Barry Songbf7c6e62013-05-16 14:08:07 +0800106MODULE_DESCRIPTION("ASoC generic HDMI codec driver");
Ricardo Neri54520302012-05-18 01:42:33 -0500107MODULE_LICENSE("GPL");
108MODULE_ALIAS("platform:" DRV_NAME);