Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 1 | /* |
Barry Song | bf7c6e6 | 2013-05-16 14:08:07 +0800 | [diff] [blame] | 2 | * ALSA SoC codec driver for HDMI audio codecs. |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 3 | * 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 Kamat | a6b3431 | 2014-04-04 11:29:09 +0530 | [diff] [blame] | 23 | #include <linux/of.h> |
Jyri Sarha | 0f7f3d1 | 2013-12-20 12:40:16 +0200 | [diff] [blame] | 24 | #include <linux/of_device.h> |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 25 | |
| 26 | #define DRV_NAME "hdmi-audio-codec" |
| 27 | |
Mark Brown | c34e51b | 2013-08-19 12:17:36 +0100 | [diff] [blame] | 28 | static const struct snd_soc_dapm_widget hdmi_widgets[] = { |
| 29 | SND_SOC_DAPM_INPUT("RX"), |
| 30 | SND_SOC_DAPM_OUTPUT("TX"), |
| 31 | }; |
| 32 | |
| 33 | static const struct snd_soc_dapm_route hdmi_routes[] = { |
| 34 | { "Capture", NULL, "RX" }, |
| 35 | { "TX", NULL, "Playback" }, |
| 36 | }; |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 37 | |
Barry Song | bf7c6e6 | 2013-05-16 14:08:07 +0800 | [diff] [blame] | 38 | static struct snd_soc_dai_driver hdmi_codec_dai = { |
| 39 | .name = "hdmi-hifi", |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 40 | .playback = { |
Mark Brown | c34e51b | 2013-08-19 12:17:36 +0100 | [diff] [blame] | 41 | .stream_name = "Playback", |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 42 | .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 Sarha | c600e95 | 2013-11-19 14:12:25 +0200 | [diff] [blame] | 49 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, |
Jyri Sarha | 74d813c | 2014-10-14 20:29:26 +0300 | [diff] [blame] | 50 | .sig_bits = 24, |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 51 | }, |
Rongjun Ying | c6c0925 | 2013-07-17 14:12:16 +0800 | [diff] [blame] | 52 | .capture = { |
Mark Brown | c34e51b | 2013-08-19 12:17:36 +0100 | [diff] [blame] | 53 | .stream_name = "Capture", |
Rongjun Ying | c6c0925 | 2013-07-17 14:12:16 +0800 | [diff] [blame] | 54 | .channels_min = 2, |
| 55 | .channels_max = 2, |
| 56 | .rates = SNDRV_PCM_RATE_32000 | |
| 57 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | |
| 58 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | |
| 59 | SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000, |
| 60 | .formats = SNDRV_PCM_FMTBIT_S16_LE | |
| 61 | SNDRV_PCM_FMTBIT_S24_LE, |
| 62 | }, |
| 63 | |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 64 | }; |
| 65 | |
Jyri Sarha | 0f7f3d1 | 2013-12-20 12:40:16 +0200 | [diff] [blame] | 66 | #ifdef CONFIG_OF |
| 67 | static const struct of_device_id hdmi_audio_codec_ids[] = { |
| 68 | { .compatible = "linux,hdmi-audio", }, |
| 69 | { } |
| 70 | }; |
| 71 | MODULE_DEVICE_TABLE(of, hdmi_audio_codec_ids); |
| 72 | #endif |
| 73 | |
Mark Brown | c34e51b | 2013-08-19 12:17:36 +0100 | [diff] [blame] | 74 | static struct snd_soc_codec_driver hdmi_codec = { |
| 75 | .dapm_widgets = hdmi_widgets, |
| 76 | .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets), |
| 77 | .dapm_routes = hdmi_routes, |
| 78 | .num_dapm_routes = ARRAY_SIZE(hdmi_routes), |
Jyri Sarha | 6943409 | 2014-10-14 20:29:27 +0300 | [diff] [blame] | 79 | .ignore_pmdown_time = true, |
Mark Brown | c34e51b | 2013-08-19 12:17:36 +0100 | [diff] [blame] | 80 | }; |
| 81 | |
Barry Song | bf7c6e6 | 2013-05-16 14:08:07 +0800 | [diff] [blame] | 82 | static int hdmi_codec_probe(struct platform_device *pdev) |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 83 | { |
Barry Song | bf7c6e6 | 2013-05-16 14:08:07 +0800 | [diff] [blame] | 84 | return snd_soc_register_codec(&pdev->dev, &hdmi_codec, |
| 85 | &hdmi_codec_dai, 1); |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 86 | } |
| 87 | |
Barry Song | bf7c6e6 | 2013-05-16 14:08:07 +0800 | [diff] [blame] | 88 | static int hdmi_codec_remove(struct platform_device *pdev) |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 89 | { |
| 90 | snd_soc_unregister_codec(&pdev->dev); |
| 91 | return 0; |
| 92 | } |
| 93 | |
Barry Song | bf7c6e6 | 2013-05-16 14:08:07 +0800 | [diff] [blame] | 94 | static struct platform_driver hdmi_codec_driver = { |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 95 | .driver = { |
| 96 | .name = DRV_NAME, |
Jyri Sarha | 0f7f3d1 | 2013-12-20 12:40:16 +0200 | [diff] [blame] | 97 | .of_match_table = of_match_ptr(hdmi_audio_codec_ids), |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 98 | }, |
| 99 | |
Barry Song | bf7c6e6 | 2013-05-16 14:08:07 +0800 | [diff] [blame] | 100 | .probe = hdmi_codec_probe, |
| 101 | .remove = hdmi_codec_remove, |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 102 | }; |
| 103 | |
Barry Song | bf7c6e6 | 2013-05-16 14:08:07 +0800 | [diff] [blame] | 104 | module_platform_driver(hdmi_codec_driver); |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 105 | |
| 106 | MODULE_AUTHOR("Ricardo Neri <ricardo.neri@ti.com>"); |
Barry Song | bf7c6e6 | 2013-05-16 14:08:07 +0800 | [diff] [blame] | 107 | MODULE_DESCRIPTION("ASoC generic HDMI codec driver"); |
Ricardo Neri | 5452030 | 2012-05-18 01:42:33 -0500 | [diff] [blame] | 108 | MODULE_LICENSE("GPL"); |
| 109 | MODULE_ALIAS("platform:" DRV_NAME); |