aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2013-05-24 07:21:30 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2013-06-17 07:30:50 -0400
commit61a7f24a3f148b3fe491154943221f1a7fa729b7 (patch)
tree19dc97eb7705072e8f51797dc4fe5089f441d614 /drivers/video
parent3cb07ee66bca756921f0e967b687f4d0e05ba439 (diff)
OMAPDSS: Add new Analog TV Connector driver
Add Analog TV Connector driver which uses the new DSS device model and DSS ops. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/omap2/displays-new/Kconfig5
-rw-r--r--drivers/video/omap2/displays-new/Makefile1
-rw-r--r--drivers/video/omap2/displays-new/connector-analog-tv.c265
3 files changed, 271 insertions, 0 deletions
diff --git a/drivers/video/omap2/displays-new/Kconfig b/drivers/video/omap2/displays-new/Kconfig
index 9a66413959a1..532663814532 100644
--- a/drivers/video/omap2/displays-new/Kconfig
+++ b/drivers/video/omap2/displays-new/Kconfig
@@ -23,4 +23,9 @@ config DISPLAY_CONNECTOR_HDMI
23 help 23 help
24 Driver for a generic HDMI connector. 24 Driver for a generic HDMI connector.
25 25
26config DISPLAY_CONNECTOR_ANALOG_TV
27 tristate "Analog TV Connector"
28 help
29 Driver for a generic analog TV connector.
30
26endmenu 31endmenu
diff --git a/drivers/video/omap2/displays-new/Makefile b/drivers/video/omap2/displays-new/Makefile
index 1007b5f53fbc..083bf0895573 100644
--- a/drivers/video/omap2/displays-new/Makefile
+++ b/drivers/video/omap2/displays-new/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_DISPLAY_ENCODER_TFP410) += encoder-tfp410.o
2obj-$(CONFIG_DISPLAY_ENCODER_TPD12S015) += encoder-tpd12s015.o 2obj-$(CONFIG_DISPLAY_ENCODER_TPD12S015) += encoder-tpd12s015.o
3obj-$(CONFIG_DISPLAY_CONNECTOR_DVI) += connector-dvi.o 3obj-$(CONFIG_DISPLAY_CONNECTOR_DVI) += connector-dvi.o
4obj-$(CONFIG_DISPLAY_CONNECTOR_HDMI) += connector-hdmi.o 4obj-$(CONFIG_DISPLAY_CONNECTOR_HDMI) += connector-hdmi.o
5obj-$(CONFIG_DISPLAY_CONNECTOR_ANALOG_TV) += connector-analog-tv.o
diff --git a/drivers/video/omap2/displays-new/connector-analog-tv.c b/drivers/video/omap2/displays-new/connector-analog-tv.c
new file mode 100644
index 000000000000..5338f362293b
--- /dev/null
+++ b/drivers/video/omap2/displays-new/connector-analog-tv.c
@@ -0,0 +1,265 @@
1/*
2 * Analog TV Connector driver
3 *
4 * Copyright (C) 2013 Texas Instruments
5 * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
6 *
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.
10 */
11
12#include <linux/slab.h>
13#include <linux/module.h>
14#include <linux/platform_device.h>
15
16#include <video/omapdss.h>
17#include <video/omap-panel-data.h>
18
19struct panel_drv_data {
20 struct omap_dss_device dssdev;
21 struct omap_dss_device *in;
22
23 struct device *dev;
24
25 struct omap_video_timings timings;
26
27 enum omap_dss_venc_type connector_type;
28 bool invert_polarity;
29};
30
31#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
32
33static int tvc_connect(struct omap_dss_device *dssdev)
34{
35 struct panel_drv_data *ddata = to_panel_data(dssdev);
36 struct omap_dss_device *in = ddata->in;
37 int r;
38
39 dev_dbg(ddata->dev, "connect\n");
40
41 if (omapdss_device_is_connected(dssdev))
42 return 0;
43
44 r = in->ops.atv->connect(in, dssdev);
45 if (r)
46 return r;
47
48 return 0;
49}
50
51static void tvc_disconnect(struct omap_dss_device *dssdev)
52{
53 struct panel_drv_data *ddata = to_panel_data(dssdev);
54 struct omap_dss_device *in = ddata->in;
55
56 dev_dbg(ddata->dev, "disconnect\n");
57
58 if (!omapdss_device_is_connected(dssdev))
59 return;
60
61 in->ops.atv->disconnect(in, dssdev);
62}
63
64static int tvc_enable(struct omap_dss_device *dssdev)
65{
66 struct panel_drv_data *ddata = to_panel_data(dssdev);
67 struct omap_dss_device *in = ddata->in;
68 int r;
69
70 dev_dbg(ddata->dev, "enable\n");
71
72 if (!omapdss_device_is_connected(dssdev))
73 return -ENODEV;
74
75 if (omapdss_device_is_enabled(dssdev))
76 return 0;
77
78 in->ops.atv->set_timings(in, &ddata->timings);
79
80 in->ops.atv->set_type(in, ddata->connector_type);
81 in->ops.atv->invert_vid_out_polarity(in, ddata->invert_polarity);
82
83 r = in->ops.atv->enable(in);
84 if (r)
85 return r;
86
87 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
88
89 return r;
90}
91
92static void tvc_disable(struct omap_dss_device *dssdev)
93{
94 struct panel_drv_data *ddata = to_panel_data(dssdev);
95 struct omap_dss_device *in = ddata->in;
96
97 dev_dbg(ddata->dev, "disable\n");
98
99 if (!omapdss_device_is_enabled(dssdev))
100 return;
101
102 in->ops.atv->disable(in);
103
104 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
105}
106
107static void tvc_set_timings(struct omap_dss_device *dssdev,
108 struct omap_video_timings *timings)
109{
110 struct panel_drv_data *ddata = to_panel_data(dssdev);
111 struct omap_dss_device *in = ddata->in;
112
113 ddata->timings = *timings;
114 dssdev->panel.timings = *timings;
115
116 in->ops.atv->set_timings(in, timings);
117}
118
119static void tvc_get_timings(struct omap_dss_device *dssdev,
120 struct omap_video_timings *timings)
121{
122 struct panel_drv_data *ddata = to_panel_data(dssdev);
123
124 *timings = ddata->timings;
125}
126
127static int tvc_check_timings(struct omap_dss_device *dssdev,
128 struct omap_video_timings *timings)
129{
130 struct panel_drv_data *ddata = to_panel_data(dssdev);
131 struct omap_dss_device *in = ddata->in;
132
133 return in->ops.atv->check_timings(in, timings);
134}
135
136static u32 tvc_get_wss(struct omap_dss_device *dssdev)
137{
138 struct panel_drv_data *ddata = to_panel_data(dssdev);
139 struct omap_dss_device *in = ddata->in;
140
141 return in->ops.atv->get_wss(in);
142}
143
144static int tvc_set_wss(struct omap_dss_device *dssdev, u32 wss)
145{
146 struct panel_drv_data *ddata = to_panel_data(dssdev);
147 struct omap_dss_device *in = ddata->in;
148
149 return in->ops.atv->set_wss(in, wss);
150}
151
152static struct omap_dss_driver tvc_driver = {
153 .connect = tvc_connect,
154 .disconnect = tvc_disconnect,
155
156 .enable = tvc_enable,
157 .disable = tvc_disable,
158
159 .set_timings = tvc_set_timings,
160 .get_timings = tvc_get_timings,
161 .check_timings = tvc_check_timings,
162
163 .get_resolution = omapdss_default_get_resolution,
164
165 .get_wss = tvc_get_wss,
166 .set_wss = tvc_set_wss,
167};
168
169static int tvc_probe_pdata(struct platform_device *pdev)
170{
171 struct panel_drv_data *ddata = platform_get_drvdata(pdev);
172 struct connector_atv_platform_data *pdata;
173 struct omap_dss_device *in, *dssdev;
174
175 pdata = dev_get_platdata(&pdev->dev);
176
177 in = omap_dss_find_output(pdata->source);
178 if (in == NULL) {
179 dev_err(&pdev->dev, "Failed to find video source\n");
180 return -ENODEV;
181 }
182
183 ddata->in = in;
184
185 ddata->connector_type = pdata->connector_type;
186 ddata->invert_polarity = ddata->invert_polarity;
187
188 dssdev = &ddata->dssdev;
189 dssdev->name = pdata->name;
190
191 return 0;
192}
193
194static int tvc_probe(struct platform_device *pdev)
195{
196 struct panel_drv_data *ddata;
197 struct omap_dss_device *dssdev;
198 int r;
199
200 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
201 if (!ddata)
202 return -ENOMEM;
203
204 platform_set_drvdata(pdev, ddata);
205 ddata->dev = &pdev->dev;
206
207 if (dev_get_platdata(&pdev->dev)) {
208 r = tvc_probe_pdata(pdev);
209 if (r)
210 return r;
211 } else {
212 return -ENODEV;
213 }
214
215 ddata->timings = omap_dss_pal_timings;
216
217 dssdev = &ddata->dssdev;
218 dssdev->driver = &tvc_driver;
219 dssdev->dev = &pdev->dev;
220 dssdev->type = OMAP_DISPLAY_TYPE_VENC;
221 dssdev->owner = THIS_MODULE;
222 dssdev->panel.timings = omap_dss_pal_timings;
223
224 r = omapdss_register_display(dssdev);
225 if (r) {
226 dev_err(&pdev->dev, "Failed to register panel\n");
227 goto err_reg;
228 }
229
230 return 0;
231err_reg:
232 omap_dss_put_device(ddata->in);
233 return r;
234}
235
236static int __exit tvc_remove(struct platform_device *pdev)
237{
238 struct panel_drv_data *ddata = platform_get_drvdata(pdev);
239 struct omap_dss_device *dssdev = &ddata->dssdev;
240 struct omap_dss_device *in = ddata->in;
241
242 omapdss_unregister_display(&ddata->dssdev);
243
244 tvc_disable(dssdev);
245 tvc_disconnect(dssdev);
246
247 omap_dss_put_device(in);
248
249 return 0;
250}
251
252static struct platform_driver tvc_connector_driver = {
253 .probe = tvc_probe,
254 .remove = __exit_p(tvc_remove),
255 .driver = {
256 .name = "connector-analog-tv",
257 .owner = THIS_MODULE,
258 },
259};
260
261module_platform_driver(tvc_connector_driver);
262
263MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
264MODULE_DESCRIPTION("Analog TV Connector driver");
265MODULE_LICENSE("GPL");