aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/omap
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-07-05 01:33:23 -0400
committerTakashi Iwai <tiwai@suse.de>2011-07-05 01:33:23 -0400
commit56aa53391059e3730a304da4dd96b7b123b9fb75 (patch)
tree35d228687f9d15509cd39b9797adef4cf047906e /sound/soc/omap
parent1ae4e9b99682adfe9ae170ed593f26fe89eb65b5 (diff)
parent404b566569cdcba71e0ee875d08053486309e56e (diff)
Merge branch 'for-3.1' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/asoc-2.6 into topic/asoc
Diffstat (limited to 'sound/soc/omap')
-rw-r--r--sound/soc/omap/Kconfig11
-rw-r--r--sound/soc/omap/Makefile4
-rw-r--r--sound/soc/omap/omap-hdmi.c158
-rw-r--r--sound/soc/omap/omap-hdmi.h36
-rw-r--r--sound/soc/omap/omap4-hdmi-card.c129
5 files changed, 338 insertions, 0 deletions
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig
index 99054cf1f68f..fe83d0d176be 100644
--- a/sound/soc/omap/Kconfig
+++ b/sound/soc/omap/Kconfig
@@ -9,6 +9,9 @@ config SND_OMAP_SOC_MCBSP
9config SND_OMAP_SOC_MCPDM 9config SND_OMAP_SOC_MCPDM
10 tristate 10 tristate
11 11
12config SND_OMAP_SOC_HDMI
13 tristate
14
12config SND_OMAP_SOC_N810 15config SND_OMAP_SOC_N810
13 tristate "SoC Audio support for Nokia N810" 16 tristate "SoC Audio support for Nokia N810"
14 depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C 17 depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C
@@ -100,6 +103,14 @@ config SND_OMAP_SOC_SDP4430
100 Say Y if you want to add support for SoC audio on Texas Instruments 103 Say Y if you want to add support for SoC audio on Texas Instruments
101 SDP4430. 104 SDP4430.
102 105
106config SND_OMAP_SOC_OMAP4_HDMI
107 tristate "SoC Audio support for Texas Instruments OMAP4 HDMI"
108 depends on SND_OMAP_SOC && OMAP4_DSS_HDMI && OMAP2_DSS && ARCH_OMAP4
109 select SND_OMAP_SOC_HDMI
110 help
111 Say Y if you want to add support for SoC HDMI audio on Texas Instruments
112 OMAP4 chips
113
103config SND_OMAP_SOC_OMAP3_PANDORA 114config SND_OMAP_SOC_OMAP3_PANDORA
104 tristate "SoC Audio support for OMAP3 Pandora" 115 tristate "SoC Audio support for OMAP3 Pandora"
105 depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP3_PANDORA 116 depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP3_PANDORA
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile
index 6c2c87eed5bb..59e2c8d1e38d 100644
--- a/sound/soc/omap/Makefile
+++ b/sound/soc/omap/Makefile
@@ -2,10 +2,12 @@
2snd-soc-omap-objs := omap-pcm.o 2snd-soc-omap-objs := omap-pcm.o
3snd-soc-omap-mcbsp-objs := omap-mcbsp.o 3snd-soc-omap-mcbsp-objs := omap-mcbsp.o
4snd-soc-omap-mcpdm-objs := omap-mcpdm.o mcpdm.o 4snd-soc-omap-mcpdm-objs := omap-mcpdm.o mcpdm.o
5snd-soc-omap-hdmi-objs := omap-hdmi.o
5 6
6obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o 7obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o
7obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o 8obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o
8obj-$(CONFIG_SND_OMAP_SOC_MCPDM) += snd-soc-omap-mcpdm.o 9obj-$(CONFIG_SND_OMAP_SOC_MCPDM) += snd-soc-omap-mcpdm.o
10obj-$(CONFIG_SND_OMAP_SOC_HDMI) += snd-soc-omap-hdmi.o
9 11
10# OMAP Machine Support 12# OMAP Machine Support
11snd-soc-n810-objs := n810.o 13snd-soc-n810-objs := n810.o
@@ -21,6 +23,7 @@ snd-soc-omap3pandora-objs := omap3pandora.o
21snd-soc-omap3beagle-objs := omap3beagle.o 23snd-soc-omap3beagle-objs := omap3beagle.o
22snd-soc-zoom2-objs := zoom2.o 24snd-soc-zoom2-objs := zoom2.o
23snd-soc-igep0020-objs := igep0020.o 25snd-soc-igep0020-objs := igep0020.o
26snd-soc-omap4-hdmi-objs := omap4-hdmi-card.o
24 27
25obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o 28obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o
26obj-$(CONFIG_SND_OMAP_SOC_RX51) += snd-soc-rx51.o 29obj-$(CONFIG_SND_OMAP_SOC_RX51) += snd-soc-rx51.o
@@ -36,3 +39,4 @@ obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o
36obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o 39obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o
37obj-$(CONFIG_SND_OMAP_SOC_ZOOM2) += snd-soc-zoom2.o 40obj-$(CONFIG_SND_OMAP_SOC_ZOOM2) += snd-soc-zoom2.o
38obj-$(CONFIG_SND_OMAP_SOC_IGEP0020) += snd-soc-igep0020.o 41obj-$(CONFIG_SND_OMAP_SOC_IGEP0020) += snd-soc-igep0020.o
42obj-$(CONFIG_SND_OMAP_SOC_OMAP4_HDMI) += snd-soc-omap4-hdmi.o
diff --git a/sound/soc/omap/omap-hdmi.c b/sound/soc/omap/omap-hdmi.c
new file mode 100644
index 000000000000..36c6eaeffb02
--- /dev/null
+++ b/sound/soc/omap/omap-hdmi.c
@@ -0,0 +1,158 @@
1/*
2 * omap-hdmi.c
3 *
4 * OMAP ALSA SoC DAI driver for HDMI audio on OMAP4 processors.
5 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
6 * Authors: Jorge Candelaria <jorge.candelaria@ti.com>
7 * Ricardo Neri <ricardo.neri@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#include <linux/init.h>
26#include <linux/module.h>
27#include <linux/device.h>
28#include <sound/core.h>
29#include <sound/pcm.h>
30#include <sound/pcm_params.h>
31#include <sound/initval.h>
32#include <sound/soc.h>
33
34#include <plat/dma.h>
35#include "omap-pcm.h"
36#include "omap-hdmi.h"
37
38#define DRV_NAME "hdmi-audio-dai"
39
40static struct omap_pcm_dma_data omap_hdmi_dai_dma_params = {
41 .name = "HDMI playback",
42 .sync_mode = OMAP_DMA_SYNC_PACKET,
43};
44
45static int omap_hdmi_dai_startup(struct snd_pcm_substream *substream,
46 struct snd_soc_dai *dai)
47{
48 int err;
49 /*
50 * Make sure that the period bytes are multiple of the DMA packet size.
51 * Largest packet size we use is 32 32-bit words = 128 bytes
52 */
53 err = snd_pcm_hw_constraint_step(substream->runtime, 0,
54 SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 128);
55 if (err < 0)
56 return err;
57
58 return 0;
59}
60
61static int omap_hdmi_dai_hw_params(struct snd_pcm_substream *substream,
62 struct snd_pcm_hw_params *params,
63 struct snd_soc_dai *dai)
64{
65 int err = 0;
66
67 switch (params_format(params)) {
68 case SNDRV_PCM_FORMAT_S16_LE:
69 omap_hdmi_dai_dma_params.packet_size = 16;
70 break;
71 case SNDRV_PCM_FORMAT_S24_LE:
72 omap_hdmi_dai_dma_params.packet_size = 32;
73 break;
74 default:
75 err = -EINVAL;
76 }
77
78 omap_hdmi_dai_dma_params.data_type = OMAP_DMA_DATA_TYPE_S32;
79
80 snd_soc_dai_set_dma_data(dai, substream,
81 &omap_hdmi_dai_dma_params);
82
83 return err;
84}
85
86static struct snd_soc_dai_ops omap_hdmi_dai_ops = {
87 .startup = omap_hdmi_dai_startup,
88 .hw_params = omap_hdmi_dai_hw_params,
89};
90
91static struct snd_soc_dai_driver omap_hdmi_dai = {
92 .playback = {
93 .channels_min = 2,
94 .channels_max = 2,
95 .rates = OMAP_HDMI_RATES,
96 .formats = OMAP_HDMI_FORMATS,
97 },
98 .ops = &omap_hdmi_dai_ops,
99};
100
101static __devinit int omap_hdmi_probe(struct platform_device *pdev)
102{
103 int ret;
104 struct resource *hdmi_rsrc;
105
106 hdmi_rsrc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
107 if (!hdmi_rsrc) {
108 dev_err(&pdev->dev, "Cannot obtain IORESOURCE_MEM HDMI\n");
109 return -EINVAL;
110 }
111
112 omap_hdmi_dai_dma_params.port_addr = hdmi_rsrc->start
113 + OMAP_HDMI_AUDIO_DMA_PORT;
114
115 hdmi_rsrc = platform_get_resource(pdev, IORESOURCE_DMA, 0);
116 if (!hdmi_rsrc) {
117 dev_err(&pdev->dev, "Cannot obtain IORESOURCE_DMA HDMI\n");
118 return -EINVAL;
119 }
120
121 omap_hdmi_dai_dma_params.dma_req = hdmi_rsrc->start;
122
123 ret = snd_soc_register_dai(&pdev->dev, &omap_hdmi_dai);
124 return ret;
125}
126
127static int __devexit omap_hdmi_remove(struct platform_device *pdev)
128{
129 snd_soc_unregister_dai(&pdev->dev);
130 return 0;
131}
132
133static struct platform_driver hdmi_dai_driver = {
134 .driver = {
135 .name = DRV_NAME,
136 .owner = THIS_MODULE,
137 },
138 .probe = omap_hdmi_probe,
139 .remove = __devexit_p(omap_hdmi_remove),
140};
141
142static int __init hdmi_dai_init(void)
143{
144 return platform_driver_register(&hdmi_dai_driver);
145}
146module_init(hdmi_dai_init);
147
148static void __exit hdmi_dai_exit(void)
149{
150 platform_driver_unregister(&hdmi_dai_driver);
151}
152module_exit(hdmi_dai_exit);
153
154MODULE_AUTHOR("Jorge Candelaria <jorge.candelaria@ti.com>");
155MODULE_AUTHOR("Ricardo Neri <ricardo.neri@ti.com>");
156MODULE_DESCRIPTION("OMAP HDMI SoC Interface");
157MODULE_LICENSE("GPL");
158MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/sound/soc/omap/omap-hdmi.h b/sound/soc/omap/omap-hdmi.h
new file mode 100644
index 000000000000..34c298d5057e
--- /dev/null
+++ b/sound/soc/omap/omap-hdmi.h
@@ -0,0 +1,36 @@
1/*
2 * omap-hdmi.h
3 *
4 * Definitions for OMAP ALSA SoC DAI driver for HDMI audio on OMAP4 processors.
5 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
6 * Authors: Jorge Candelaria <jorge.candelaria@ti.com>
7 * Ricardo Neri <ricardo.neri@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef __OMAP_HDMI_H__
26#define __OMAP_HDMI_H__
27
28#define OMAP_HDMI_AUDIO_DMA_PORT 0x8c
29
30#define OMAP_HDMI_RATES (SNDRV_PCM_RATE_32000 | \
31 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
32
33#define OMAP_HDMI_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
34 SNDRV_PCM_FMTBIT_S24_LE)
35
36#endif
diff --git a/sound/soc/omap/omap4-hdmi-card.c b/sound/soc/omap/omap4-hdmi-card.c
new file mode 100644
index 000000000000..9f32615b81f7
--- /dev/null
+++ b/sound/soc/omap/omap4-hdmi-card.c
@@ -0,0 +1,129 @@
1/*
2 * omap4-hdmi-card.c
3 *
4 * OMAP ALSA SoC machine driver for TI OMAP4 HDMI
5 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 * Author: Ricardo Neri <ricardo.neri@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#include <sound/pcm.h>
25#include <sound/soc.h>
26#include <asm/mach-types.h>
27#include <video/omapdss.h>
28
29#define DRV_NAME "omap4-hdmi-audio"
30
31static int omap4_hdmi_dai_hw_params(struct snd_pcm_substream *substream,
32 struct snd_pcm_hw_params *params)
33{
34 int i;
35 struct omap_overlay_manager *mgr = NULL;
36 struct device *dev = substream->pcm->card->dev;
37
38 /* Find DSS HDMI device */
39 for (i = 0; i < omap_dss_get_num_overlay_managers(); i++) {
40 mgr = omap_dss_get_overlay_manager(i);
41 if (mgr && mgr->device
42 && mgr->device->type == OMAP_DISPLAY_TYPE_HDMI)
43 break;
44 }
45
46 if (i == omap_dss_get_num_overlay_managers()) {
47 dev_err(dev, "HDMI display device not found!\n");
48 return -ENODEV;
49 }
50
51 /* Make sure HDMI is power-on to avoid L3 interconnect errors */
52 if (mgr->device->state != OMAP_DSS_DISPLAY_ACTIVE) {
53 dev_err(dev, "HDMI display is not active!\n");
54 return -EIO;
55 }
56
57 return 0;
58}
59
60static struct snd_soc_ops omap4_hdmi_dai_ops = {
61 .hw_params = omap4_hdmi_dai_hw_params,
62};
63
64static struct snd_soc_dai_link omap4_hdmi_dai = {
65 .name = "HDMI",
66 .stream_name = "HDMI",
67 .cpu_dai_name = "hdmi-audio-dai",
68 .platform_name = "omap-pcm-audio",
69 .codec_name = "omapdss_hdmi",
70 .codec_dai_name = "hdmi-audio-codec",
71 .ops = &omap4_hdmi_dai_ops,
72};
73
74static struct snd_soc_card snd_soc_omap4_hdmi = {
75 .name = "OMAP4HDMI",
76 .dai_link = &omap4_hdmi_dai,
77 .num_links = 1,
78};
79
80static __devinit int omap4_hdmi_probe(struct platform_device *pdev)
81{
82 struct snd_soc_card *card = &snd_soc_omap4_hdmi;
83 int ret;
84
85 card->dev = &pdev->dev;
86
87 ret = snd_soc_register_card(card);
88 if (ret) {
89 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
90 card->dev = NULL;
91 return ret;
92 }
93 return 0;
94}
95
96static int __devexit omap4_hdmi_remove(struct platform_device *pdev)
97{
98 struct snd_soc_card *card = platform_get_drvdata(pdev);
99
100 snd_soc_unregister_card(card);
101 card->dev = NULL;
102 return 0;
103}
104
105static struct platform_driver omap4_hdmi_driver = {
106 .driver = {
107 .name = "omap4-hdmi-audio",
108 .owner = THIS_MODULE,
109 },
110 .probe = omap4_hdmi_probe,
111 .remove = __devexit_p(omap4_hdmi_remove),
112};
113
114static int __init omap4_hdmi_init(void)
115{
116 return platform_driver_register(&omap4_hdmi_driver);
117}
118module_init(omap4_hdmi_init);
119
120static void __exit omap4_hdmi_exit(void)
121{
122 platform_driver_unregister(&omap4_hdmi_driver);
123}
124module_exit(omap4_hdmi_exit);
125
126MODULE_AUTHOR("Ricardo Neri <ricardo.neri@ti.com>");
127MODULE_DESCRIPTION("OMAP4 HDMI machine ASoC driver");
128MODULE_LICENSE("GPL");
129MODULE_ALIAS("platform:" DRV_NAME);