2 * Copyright (C) 2009 Nokia Corporation
3 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <linux/kernel.h>
21 #include <linux/err.h>
23 #include <linux/mutex.h>
24 #include <linux/module.h>
26 #include <video/omapdss.h>
34 static ssize_t
display_output_type_show(struct device
*dev
,
35 struct device_attribute
*attr
, char *buf
)
37 struct omap_dss_device
*dssdev
= to_dss_device(dev
);
40 switch (dssdev
->phy
.venc
.type
) {
41 case OMAP_DSS_VENC_TYPE_COMPOSITE
:
44 case OMAP_DSS_VENC_TYPE_SVIDEO
:
51 return snprintf(buf
, PAGE_SIZE
, "%s\n", ret
);
54 static ssize_t
display_output_type_store(struct device
*dev
,
55 struct device_attribute
*attr
, const char *buf
, size_t size
)
57 struct omap_dss_device
*dssdev
= to_dss_device(dev
);
58 enum omap_dss_venc_type new_type
;
60 if (sysfs_streq("composite", buf
))
61 new_type
= OMAP_DSS_VENC_TYPE_COMPOSITE
;
62 else if (sysfs_streq("svideo", buf
))
63 new_type
= OMAP_DSS_VENC_TYPE_SVIDEO
;
67 mutex_lock(&venc_panel
.lock
);
69 if (dssdev
->phy
.venc
.type
!= new_type
) {
70 dssdev
->phy
.venc
.type
= new_type
;
71 omapdss_venc_set_type(dssdev
, new_type
);
72 if (dssdev
->state
== OMAP_DSS_DISPLAY_ACTIVE
) {
73 omapdss_venc_display_disable(dssdev
);
74 omapdss_venc_display_enable(dssdev
);
78 mutex_unlock(&venc_panel
.lock
);
83 static DEVICE_ATTR(output_type
, S_IRUGO
| S_IWUSR
,
84 display_output_type_show
, display_output_type_store
);
86 static int venc_panel_probe(struct omap_dss_device
*dssdev
)
88 /* set default timings to PAL */
89 const struct omap_video_timings default_timings
= {
100 .vsync_level
= OMAPDSS_SIG_ACTIVE_HIGH
,
101 .hsync_level
= OMAPDSS_SIG_ACTIVE_HIGH
,
106 mutex_init(&venc_panel
.lock
);
108 dssdev
->panel
.timings
= default_timings
;
110 return device_create_file(dssdev
->dev
, &dev_attr_output_type
);
113 static void venc_panel_remove(struct omap_dss_device
*dssdev
)
115 device_remove_file(dssdev
->dev
, &dev_attr_output_type
);
118 static int venc_panel_enable(struct omap_dss_device
*dssdev
)
122 dev_dbg(dssdev
->dev
, "venc_panel_enable\n");
124 mutex_lock(&venc_panel
.lock
);
126 if (dssdev
->state
!= OMAP_DSS_DISPLAY_DISABLED
) {
131 omapdss_venc_set_timings(dssdev
, &dssdev
->panel
.timings
);
132 omapdss_venc_set_type(dssdev
, dssdev
->phy
.venc
.type
);
133 omapdss_venc_invert_vid_out_polarity(dssdev
,
134 dssdev
->phy
.venc
.invert_polarity
);
136 r
= omapdss_venc_display_enable(dssdev
);
140 dssdev
->state
= OMAP_DSS_DISPLAY_ACTIVE
;
142 mutex_unlock(&venc_panel
.lock
);
146 mutex_unlock(&venc_panel
.lock
);
151 static void venc_panel_disable(struct omap_dss_device
*dssdev
)
153 dev_dbg(dssdev
->dev
, "venc_panel_disable\n");
155 mutex_lock(&venc_panel
.lock
);
157 if (dssdev
->state
== OMAP_DSS_DISPLAY_DISABLED
)
160 omapdss_venc_display_disable(dssdev
);
162 dssdev
->state
= OMAP_DSS_DISPLAY_DISABLED
;
164 mutex_unlock(&venc_panel
.lock
);
167 static void venc_panel_set_timings(struct omap_dss_device
*dssdev
,
168 struct omap_video_timings
*timings
)
170 dev_dbg(dssdev
->dev
, "venc_panel_set_timings\n");
172 mutex_lock(&venc_panel
.lock
);
174 omapdss_venc_set_timings(dssdev
, timings
);
175 dssdev
->panel
.timings
= *timings
;
177 mutex_unlock(&venc_panel
.lock
);
180 static int venc_panel_check_timings(struct omap_dss_device
*dssdev
,
181 struct omap_video_timings
*timings
)
183 dev_dbg(dssdev
->dev
, "venc_panel_check_timings\n");
185 return omapdss_venc_check_timings(dssdev
, timings
);
188 static u32
venc_panel_get_wss(struct omap_dss_device
*dssdev
)
190 dev_dbg(dssdev
->dev
, "venc_panel_get_wss\n");
192 return omapdss_venc_get_wss(dssdev
);
195 static int venc_panel_set_wss(struct omap_dss_device
*dssdev
, u32 wss
)
197 dev_dbg(dssdev
->dev
, "venc_panel_set_wss\n");
199 return omapdss_venc_set_wss(dssdev
, wss
);
202 static struct omap_dss_driver venc_driver
= {
203 .probe
= venc_panel_probe
,
204 .remove
= venc_panel_remove
,
206 .enable
= venc_panel_enable
,
207 .disable
= venc_panel_disable
,
209 .get_resolution
= omapdss_default_get_resolution
,
210 .get_recommended_bpp
= omapdss_default_get_recommended_bpp
,
212 .set_timings
= venc_panel_set_timings
,
213 .check_timings
= venc_panel_check_timings
,
215 .get_wss
= venc_panel_get_wss
,
216 .set_wss
= venc_panel_set_wss
,
220 .owner
= THIS_MODULE
,
224 int venc_panel_init(void)
226 return omap_dss_register_driver(&venc_driver
);
229 void venc_panel_exit(void)
231 omap_dss_unregister_driver(&venc_driver
);