staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XII
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / sound / soc / omap / omap4-hdmi-card.c
blob9f32615b81f785d9d43f489fabed4ec61f1d7b0b
1 /*
2 * omap4-hdmi-card.c
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
20 * 02110-1301 USA
24 #include <sound/pcm.h>
25 #include <sound/soc.h>
26 #include <asm/mach-types.h>
27 #include <video/omapdss.h>
29 #define DRV_NAME "omap4-hdmi-audio"
31 static int omap4_hdmi_dai_hw_params(struct snd_pcm_substream *substream,
32 struct snd_pcm_hw_params *params)
34 int i;
35 struct omap_overlay_manager *mgr = NULL;
36 struct device *dev = substream->pcm->card->dev;
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;
46 if (i == omap_dss_get_num_overlay_managers()) {
47 dev_err(dev, "HDMI display device not found!\n");
48 return -ENODEV;
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;
57 return 0;
60 static struct snd_soc_ops omap4_hdmi_dai_ops = {
61 .hw_params = omap4_hdmi_dai_hw_params,
64 static 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,
74 static struct snd_soc_card snd_soc_omap4_hdmi = {
75 .name = "OMAP4HDMI",
76 .dai_link = &omap4_hdmi_dai,
77 .num_links = 1,
80 static __devinit int omap4_hdmi_probe(struct platform_device *pdev)
82 struct snd_soc_card *card = &snd_soc_omap4_hdmi;
83 int ret;
85 card->dev = &pdev->dev;
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;
93 return 0;
96 static int __devexit omap4_hdmi_remove(struct platform_device *pdev)
98 struct snd_soc_card *card = platform_get_drvdata(pdev);
100 snd_soc_unregister_card(card);
101 card->dev = NULL;
102 return 0;
105 static struct platform_driver omap4_hdmi_driver = {
106 .driver = {
107 .name = "omap4-hdmi-audio",
108 .owner = THIS_MODULE,
110 .probe = omap4_hdmi_probe,
111 .remove = __devexit_p(omap4_hdmi_remove),
114 static int __init omap4_hdmi_init(void)
116 return platform_driver_register(&omap4_hdmi_driver);
118 module_init(omap4_hdmi_init);
120 static void __exit omap4_hdmi_exit(void)
122 platform_driver_unregister(&omap4_hdmi_driver);
124 module_exit(omap4_hdmi_exit);
126 MODULE_AUTHOR("Ricardo Neri <ricardo.neri@ti.com>");
127 MODULE_DESCRIPTION("OMAP4 HDMI machine ASoC driver");
128 MODULE_LICENSE("GPL");
129 MODULE_ALIAS("platform:" DRV_NAME);