2 * Analog TV Connector driver
4 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
5 * Author: Tomi Valkeinen <tomi.valkeinen@ti.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.
12 #include <linux/slab.h>
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
17 #include "../dss/omapdss.h"
19 struct panel_drv_data {
20 struct omap_dss_device dssdev;
21 struct omap_dss_device *in;
28 static const struct videomode tvc_pal_vm = {
31 .pixelclock = 13500000,
39 .flags = DISPLAY_FLAGS_INTERLACED | DISPLAY_FLAGS_HSYNC_LOW |
40 DISPLAY_FLAGS_VSYNC_LOW,
43 #define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
45 static int tvc_connect(struct omap_dss_device *dssdev)
47 struct panel_drv_data *ddata = to_panel_data(dssdev);
48 struct omap_dss_device *in;
51 dev_dbg(ddata->dev, "connect\n");
53 if (omapdss_device_is_connected(dssdev))
56 in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
58 dev_err(ddata->dev, "failed to find video source\n");
62 r = in->ops.atv->connect(in, dssdev);
64 omap_dss_put_device(in);
72 static void tvc_disconnect(struct omap_dss_device *dssdev)
74 struct panel_drv_data *ddata = to_panel_data(dssdev);
75 struct omap_dss_device *in = ddata->in;
77 dev_dbg(ddata->dev, "disconnect\n");
79 if (!omapdss_device_is_connected(dssdev))
82 in->ops.atv->disconnect(in, dssdev);
84 omap_dss_put_device(in);
88 static int tvc_enable(struct omap_dss_device *dssdev)
90 struct panel_drv_data *ddata = to_panel_data(dssdev);
91 struct omap_dss_device *in = ddata->in;
94 dev_dbg(ddata->dev, "enable\n");
96 if (!omapdss_device_is_connected(dssdev))
99 if (omapdss_device_is_enabled(dssdev))
102 in->ops.atv->set_timings(in, &ddata->vm);
104 r = in->ops.atv->enable(in);
108 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
113 static void tvc_disable(struct omap_dss_device *dssdev)
115 struct panel_drv_data *ddata = to_panel_data(dssdev);
116 struct omap_dss_device *in = ddata->in;
118 dev_dbg(ddata->dev, "disable\n");
120 if (!omapdss_device_is_enabled(dssdev))
123 in->ops.atv->disable(in);
125 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
128 static void tvc_set_timings(struct omap_dss_device *dssdev,
129 struct videomode *vm)
131 struct panel_drv_data *ddata = to_panel_data(dssdev);
132 struct omap_dss_device *in = ddata->in;
135 dssdev->panel.vm = *vm;
137 in->ops.atv->set_timings(in, vm);
140 static void tvc_get_timings(struct omap_dss_device *dssdev,
141 struct videomode *vm)
143 struct panel_drv_data *ddata = to_panel_data(dssdev);
148 static int tvc_check_timings(struct omap_dss_device *dssdev,
149 struct videomode *vm)
151 struct panel_drv_data *ddata = to_panel_data(dssdev);
152 struct omap_dss_device *in = ddata->in;
154 return in->ops.atv->check_timings(in, vm);
157 static u32 tvc_get_wss(struct omap_dss_device *dssdev)
159 struct panel_drv_data *ddata = to_panel_data(dssdev);
160 struct omap_dss_device *in = ddata->in;
162 return in->ops.atv->get_wss(in);
165 static int tvc_set_wss(struct omap_dss_device *dssdev, u32 wss)
167 struct panel_drv_data *ddata = to_panel_data(dssdev);
168 struct omap_dss_device *in = ddata->in;
170 return in->ops.atv->set_wss(in, wss);
173 static struct omap_dss_driver tvc_driver = {
174 .connect = tvc_connect,
175 .disconnect = tvc_disconnect,
177 .enable = tvc_enable,
178 .disable = tvc_disable,
180 .set_timings = tvc_set_timings,
181 .get_timings = tvc_get_timings,
182 .check_timings = tvc_check_timings,
184 .get_wss = tvc_get_wss,
185 .set_wss = tvc_set_wss,
188 static int tvc_probe(struct platform_device *pdev)
190 struct panel_drv_data *ddata;
191 struct omap_dss_device *dssdev;
194 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
198 platform_set_drvdata(pdev, ddata);
199 ddata->dev = &pdev->dev;
201 ddata->vm = tvc_pal_vm;
203 dssdev = &ddata->dssdev;
204 dssdev->driver = &tvc_driver;
205 dssdev->dev = &pdev->dev;
206 dssdev->type = OMAP_DISPLAY_TYPE_VENC;
207 dssdev->owner = THIS_MODULE;
208 dssdev->panel.vm = tvc_pal_vm;
210 r = omapdss_register_display(dssdev);
212 dev_err(&pdev->dev, "Failed to register panel\n");
219 static int __exit tvc_remove(struct platform_device *pdev)
221 struct panel_drv_data *ddata = platform_get_drvdata(pdev);
222 struct omap_dss_device *dssdev = &ddata->dssdev;
224 omapdss_unregister_display(&ddata->dssdev);
227 tvc_disconnect(dssdev);
232 static const struct of_device_id tvc_of_match[] = {
233 { .compatible = "omapdss,svideo-connector", },
234 { .compatible = "omapdss,composite-video-connector", },
238 MODULE_DEVICE_TABLE(of, tvc_of_match);
240 static struct platform_driver tvc_connector_driver = {
242 .remove = __exit_p(tvc_remove),
244 .name = "connector-analog-tv",
245 .of_match_table = tvc_of_match,
246 .suppress_bind_attrs = true,
250 module_platform_driver(tvc_connector_driver);
252 MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
253 MODULE_DESCRIPTION("Analog TV Connector driver");
254 MODULE_LICENSE("GPL");