4 * HDMI library support functions for TI OMAP4 processors.
6 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
7 * Authors: Mythri P k <mythripk@ti.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published by
11 * the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along with
19 * this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <linux/kernel.h>
23 #include <linux/err.h>
25 #include <linux/mutex.h>
26 #include <linux/module.h>
27 #include <video/omapdss.h>
28 #include <linux/slab.h>
33 struct mutex hdmi_lock
;
37 static int hdmi_panel_probe(struct omap_dss_device
*dssdev
)
39 DSSDBG("ENTER hdmi_panel_probe\n");
41 dssdev
->panel
.config
= OMAP_DSS_LCD_TFT
|
42 OMAP_DSS_LCD_IVS
| OMAP_DSS_LCD_IHS
;
44 dssdev
->panel
.timings
= (struct omap_video_timings
){640, 480, 25175, 96, 16, 48, 2 , 11, 31};
46 DSSDBG("hdmi_panel_probe x_res= %d y_res = %d\n",
47 dssdev
->panel
.timings
.x_res
,
48 dssdev
->panel
.timings
.y_res
);
52 static void hdmi_panel_remove(struct omap_dss_device
*dssdev
)
57 static int hdmi_panel_enable(struct omap_dss_device
*dssdev
)
60 DSSDBG("ENTER hdmi_panel_enable\n");
62 mutex_lock(&hdmi
.hdmi_lock
);
64 if (dssdev
->state
!= OMAP_DSS_DISPLAY_DISABLED
) {
69 r
= omapdss_hdmi_display_enable(dssdev
);
71 DSSERR("failed to power on\n");
75 dssdev
->state
= OMAP_DSS_DISPLAY_ACTIVE
;
78 mutex_unlock(&hdmi
.hdmi_lock
);
83 static void hdmi_panel_disable(struct omap_dss_device
*dssdev
)
85 mutex_lock(&hdmi
.hdmi_lock
);
87 if (dssdev
->state
== OMAP_DSS_DISPLAY_ACTIVE
)
88 omapdss_hdmi_display_disable(dssdev
);
90 dssdev
->state
= OMAP_DSS_DISPLAY_DISABLED
;
92 mutex_unlock(&hdmi
.hdmi_lock
);
95 static int hdmi_panel_suspend(struct omap_dss_device
*dssdev
)
99 mutex_lock(&hdmi
.hdmi_lock
);
101 if (dssdev
->state
!= OMAP_DSS_DISPLAY_ACTIVE
) {
106 dssdev
->state
= OMAP_DSS_DISPLAY_SUSPENDED
;
108 omapdss_hdmi_display_disable(dssdev
);
111 mutex_unlock(&hdmi
.hdmi_lock
);
116 static int hdmi_panel_resume(struct omap_dss_device
*dssdev
)
120 mutex_lock(&hdmi
.hdmi_lock
);
122 if (dssdev
->state
!= OMAP_DSS_DISPLAY_SUSPENDED
) {
127 r
= omapdss_hdmi_display_enable(dssdev
);
129 DSSERR("failed to power on\n");
133 dssdev
->state
= OMAP_DSS_DISPLAY_ACTIVE
;
136 mutex_unlock(&hdmi
.hdmi_lock
);
141 static void hdmi_get_timings(struct omap_dss_device
*dssdev
,
142 struct omap_video_timings
*timings
)
144 mutex_lock(&hdmi
.hdmi_lock
);
146 *timings
= dssdev
->panel
.timings
;
148 mutex_unlock(&hdmi
.hdmi_lock
);
151 static void hdmi_set_timings(struct omap_dss_device
*dssdev
,
152 struct omap_video_timings
*timings
)
154 DSSDBG("hdmi_set_timings\n");
156 mutex_lock(&hdmi
.hdmi_lock
);
158 dssdev
->panel
.timings
= *timings
;
159 omapdss_hdmi_display_set_timing(dssdev
);
161 mutex_unlock(&hdmi
.hdmi_lock
);
164 static int hdmi_check_timings(struct omap_dss_device
*dssdev
,
165 struct omap_video_timings
*timings
)
169 DSSDBG("hdmi_check_timings\n");
171 mutex_lock(&hdmi
.hdmi_lock
);
173 r
= omapdss_hdmi_display_check_timing(dssdev
, timings
);
175 mutex_unlock(&hdmi
.hdmi_lock
);
179 static int hdmi_read_edid(struct omap_dss_device
*dssdev
, u8
*buf
, int len
)
183 mutex_lock(&hdmi
.hdmi_lock
);
185 if (dssdev
->state
!= OMAP_DSS_DISPLAY_ACTIVE
) {
186 r
= omapdss_hdmi_display_enable(dssdev
);
191 r
= omapdss_hdmi_read_edid(buf
, len
);
193 if (dssdev
->state
== OMAP_DSS_DISPLAY_DISABLED
||
194 dssdev
->state
== OMAP_DSS_DISPLAY_SUSPENDED
)
195 omapdss_hdmi_display_disable(dssdev
);
197 mutex_unlock(&hdmi
.hdmi_lock
);
202 static bool hdmi_detect(struct omap_dss_device
*dssdev
)
206 mutex_lock(&hdmi
.hdmi_lock
);
208 if (dssdev
->state
!= OMAP_DSS_DISPLAY_ACTIVE
) {
209 r
= omapdss_hdmi_display_enable(dssdev
);
214 r
= omapdss_hdmi_detect();
216 if (dssdev
->state
== OMAP_DSS_DISPLAY_DISABLED
||
217 dssdev
->state
== OMAP_DSS_DISPLAY_SUSPENDED
)
218 omapdss_hdmi_display_disable(dssdev
);
220 mutex_unlock(&hdmi
.hdmi_lock
);
225 static struct omap_dss_driver hdmi_driver
= {
226 .probe
= hdmi_panel_probe
,
227 .remove
= hdmi_panel_remove
,
228 .enable
= hdmi_panel_enable
,
229 .disable
= hdmi_panel_disable
,
230 .suspend
= hdmi_panel_suspend
,
231 .resume
= hdmi_panel_resume
,
232 .get_timings
= hdmi_get_timings
,
233 .set_timings
= hdmi_set_timings
,
234 .check_timings
= hdmi_check_timings
,
235 .read_edid
= hdmi_read_edid
,
236 .detect
= hdmi_detect
,
238 .name
= "hdmi_panel",
239 .owner
= THIS_MODULE
,
243 int hdmi_panel_init(void)
245 mutex_init(&hdmi
.hdmi_lock
);
247 omap_dss_register_driver(&hdmi_driver
);
252 void hdmi_panel_exit(void)
254 omap_dss_unregister_driver(&hdmi_driver
);