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>
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.
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.
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
24 #include <linux/module.h>
25 #include <sound/pcm.h>
26 #include <sound/soc.h>
27 #include <asm/mach-types.h>
28 #include <video/omapdss.h>
30 #define DRV_NAME "omap4-hdmi-audio"
32 static int omap4_hdmi_dai_hw_params(struct snd_pcm_substream
*substream
,
33 struct snd_pcm_hw_params
*params
)
36 struct omap_overlay_manager
*mgr
= NULL
;
37 struct device
*dev
= substream
->pcm
->card
->dev
;
39 /* Find DSS HDMI device */
40 for (i
= 0; i
< omap_dss_get_num_overlay_managers(); i
++) {
41 mgr
= omap_dss_get_overlay_manager(i
);
42 if (mgr
&& mgr
->device
43 && mgr
->device
->type
== OMAP_DISPLAY_TYPE_HDMI
)
47 if (i
== omap_dss_get_num_overlay_managers()) {
48 dev_err(dev
, "HDMI display device not found!\n");
52 /* Make sure HDMI is power-on to avoid L3 interconnect errors */
53 if (mgr
->device
->state
!= OMAP_DSS_DISPLAY_ACTIVE
) {
54 dev_err(dev
, "HDMI display is not active!\n");
61 static struct snd_soc_ops omap4_hdmi_dai_ops
= {
62 .hw_params
= omap4_hdmi_dai_hw_params
,
65 static struct snd_soc_dai_link omap4_hdmi_dai
= {
67 .stream_name
= "HDMI",
68 .cpu_dai_name
= "hdmi-audio-dai",
69 .platform_name
= "omap-pcm-audio",
70 .codec_name
= "omapdss_hdmi",
71 .codec_dai_name
= "hdmi-audio-codec",
72 .ops
= &omap4_hdmi_dai_ops
,
75 static struct snd_soc_card snd_soc_omap4_hdmi
= {
78 .dai_link
= &omap4_hdmi_dai
,
82 static __devinit
int omap4_hdmi_probe(struct platform_device
*pdev
)
84 struct snd_soc_card
*card
= &snd_soc_omap4_hdmi
;
87 card
->dev
= &pdev
->dev
;
89 ret
= snd_soc_register_card(card
);
91 dev_err(&pdev
->dev
, "snd_soc_register_card failed (%d)\n", ret
);
98 static int __devexit
omap4_hdmi_remove(struct platform_device
*pdev
)
100 struct snd_soc_card
*card
= platform_get_drvdata(pdev
);
102 snd_soc_unregister_card(card
);
107 static struct platform_driver omap4_hdmi_driver
= {
109 .name
= "omap4-hdmi-audio",
110 .owner
= THIS_MODULE
,
112 .probe
= omap4_hdmi_probe
,
113 .remove
= __devexit_p(omap4_hdmi_remove
),
116 module_platform_driver(omap4_hdmi_driver
);
118 MODULE_AUTHOR("Ricardo Neri <ricardo.neri@ti.com>");
119 MODULE_DESCRIPTION("OMAP4 HDMI machine ASoC driver");
120 MODULE_LICENSE("GPL");
121 MODULE_ALIAS("platform:" DRV_NAME
);