Commit | Line | Data |
---|---|---|
55b95e0e RN |
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 | ||
da155d5b | 24 | #include <linux/module.h> |
55b95e0e RN |
25 | #include <sound/pcm.h> |
26 | #include <sound/soc.h> | |
27 | #include <asm/mach-types.h> | |
28 | #include <video/omapdss.h> | |
29 | ||
30 | #define DRV_NAME "omap4-hdmi-audio" | |
31 | ||
32 | static int omap4_hdmi_dai_hw_params(struct snd_pcm_substream *substream, | |
33 | struct snd_pcm_hw_params *params) | |
34 | { | |
35 | int i; | |
36 | struct omap_overlay_manager *mgr = NULL; | |
37 | struct device *dev = substream->pcm->card->dev; | |
38 | ||
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) | |
44 | break; | |
45 | } | |
46 | ||
47 | if (i == omap_dss_get_num_overlay_managers()) { | |
48 | dev_err(dev, "HDMI display device not found!\n"); | |
49 | return -ENODEV; | |
50 | } | |
51 | ||
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"); | |
55 | return -EIO; | |
56 | } | |
57 | ||
58 | return 0; | |
59 | } | |
60 | ||
61 | static struct snd_soc_ops omap4_hdmi_dai_ops = { | |
62 | .hw_params = omap4_hdmi_dai_hw_params, | |
63 | }; | |
64 | ||
65 | static struct snd_soc_dai_link omap4_hdmi_dai = { | |
66 | .name = "HDMI", | |
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, | |
73 | }; | |
74 | ||
75 | static struct snd_soc_card snd_soc_omap4_hdmi = { | |
76 | .name = "OMAP4HDMI", | |
77 | .dai_link = &omap4_hdmi_dai, | |
78 | .num_links = 1, | |
79 | }; | |
80 | ||
81 | static __devinit int omap4_hdmi_probe(struct platform_device *pdev) | |
82 | { | |
83 | struct snd_soc_card *card = &snd_soc_omap4_hdmi; | |
84 | int ret; | |
85 | ||
86 | card->dev = &pdev->dev; | |
87 | ||
88 | ret = snd_soc_register_card(card); | |
89 | if (ret) { | |
90 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); | |
91 | card->dev = NULL; | |
92 | return ret; | |
93 | } | |
94 | return 0; | |
95 | } | |
96 | ||
97 | static int __devexit omap4_hdmi_remove(struct platform_device *pdev) | |
98 | { | |
99 | struct snd_soc_card *card = platform_get_drvdata(pdev); | |
100 | ||
101 | snd_soc_unregister_card(card); | |
102 | card->dev = NULL; | |
103 | return 0; | |
104 | } | |
105 | ||
106 | static struct platform_driver omap4_hdmi_driver = { | |
107 | .driver = { | |
108 | .name = "omap4-hdmi-audio", | |
109 | .owner = THIS_MODULE, | |
110 | }, | |
111 | .probe = omap4_hdmi_probe, | |
112 | .remove = __devexit_p(omap4_hdmi_remove), | |
113 | }; | |
114 | ||
beda5bf5 | 115 | module_platform_driver(omap4_hdmi_driver); |
55b95e0e RN |
116 | |
117 | MODULE_AUTHOR("Ricardo Neri <ricardo.neri@ti.com>"); | |
118 | MODULE_DESCRIPTION("OMAP4 HDMI machine ASoC driver"); | |
119 | MODULE_LICENSE("GPL"); | |
120 | MODULE_ALIAS("platform:" DRV_NAME); |