mfd: wm8350-i2c: Make sure the i2c regmap functions are compiled
[linux/fpc-iii.git] / drivers / video / omap2 / displays-new / connector-analog-tv.c
blobccd9073f706f6d59242a5b1866d74dcd2c9bffa6
1 /*
2 * Analog TV Connector driver
4 * Copyright (C) 2013 Texas Instruments
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>
16 #include <video/omapdss.h>
17 #include <video/omap-panel-data.h>
19 struct panel_drv_data {
20 struct omap_dss_device dssdev;
21 struct omap_dss_device *in;
23 struct device *dev;
25 struct omap_video_timings timings;
27 enum omap_dss_venc_type connector_type;
28 bool invert_polarity;
31 static const struct omap_video_timings tvc_pal_timings = {
32 .x_res = 720,
33 .y_res = 574,
34 .pixel_clock = 13500,
35 .hsw = 64,
36 .hfp = 12,
37 .hbp = 68,
38 .vsw = 5,
39 .vfp = 5,
40 .vbp = 41,
42 .interlace = true,
45 #define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
47 static int tvc_connect(struct omap_dss_device *dssdev)
49 struct panel_drv_data *ddata = to_panel_data(dssdev);
50 struct omap_dss_device *in = ddata->in;
51 int r;
53 dev_dbg(ddata->dev, "connect\n");
55 if (omapdss_device_is_connected(dssdev))
56 return 0;
58 r = in->ops.atv->connect(in, dssdev);
59 if (r)
60 return r;
62 return 0;
65 static void tvc_disconnect(struct omap_dss_device *dssdev)
67 struct panel_drv_data *ddata = to_panel_data(dssdev);
68 struct omap_dss_device *in = ddata->in;
70 dev_dbg(ddata->dev, "disconnect\n");
72 if (!omapdss_device_is_connected(dssdev))
73 return;
75 in->ops.atv->disconnect(in, dssdev);
78 static int tvc_enable(struct omap_dss_device *dssdev)
80 struct panel_drv_data *ddata = to_panel_data(dssdev);
81 struct omap_dss_device *in = ddata->in;
82 int r;
84 dev_dbg(ddata->dev, "enable\n");
86 if (!omapdss_device_is_connected(dssdev))
87 return -ENODEV;
89 if (omapdss_device_is_enabled(dssdev))
90 return 0;
92 in->ops.atv->set_timings(in, &ddata->timings);
94 in->ops.atv->set_type(in, ddata->connector_type);
95 in->ops.atv->invert_vid_out_polarity(in, ddata->invert_polarity);
97 r = in->ops.atv->enable(in);
98 if (r)
99 return r;
101 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
103 return r;
106 static void tvc_disable(struct omap_dss_device *dssdev)
108 struct panel_drv_data *ddata = to_panel_data(dssdev);
109 struct omap_dss_device *in = ddata->in;
111 dev_dbg(ddata->dev, "disable\n");
113 if (!omapdss_device_is_enabled(dssdev))
114 return;
116 in->ops.atv->disable(in);
118 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
121 static void tvc_set_timings(struct omap_dss_device *dssdev,
122 struct omap_video_timings *timings)
124 struct panel_drv_data *ddata = to_panel_data(dssdev);
125 struct omap_dss_device *in = ddata->in;
127 ddata->timings = *timings;
128 dssdev->panel.timings = *timings;
130 in->ops.atv->set_timings(in, timings);
133 static void tvc_get_timings(struct omap_dss_device *dssdev,
134 struct omap_video_timings *timings)
136 struct panel_drv_data *ddata = to_panel_data(dssdev);
138 *timings = ddata->timings;
141 static int tvc_check_timings(struct omap_dss_device *dssdev,
142 struct omap_video_timings *timings)
144 struct panel_drv_data *ddata = to_panel_data(dssdev);
145 struct omap_dss_device *in = ddata->in;
147 return in->ops.atv->check_timings(in, timings);
150 static u32 tvc_get_wss(struct omap_dss_device *dssdev)
152 struct panel_drv_data *ddata = to_panel_data(dssdev);
153 struct omap_dss_device *in = ddata->in;
155 return in->ops.atv->get_wss(in);
158 static int tvc_set_wss(struct omap_dss_device *dssdev, u32 wss)
160 struct panel_drv_data *ddata = to_panel_data(dssdev);
161 struct omap_dss_device *in = ddata->in;
163 return in->ops.atv->set_wss(in, wss);
166 static struct omap_dss_driver tvc_driver = {
167 .connect = tvc_connect,
168 .disconnect = tvc_disconnect,
170 .enable = tvc_enable,
171 .disable = tvc_disable,
173 .set_timings = tvc_set_timings,
174 .get_timings = tvc_get_timings,
175 .check_timings = tvc_check_timings,
177 .get_resolution = omapdss_default_get_resolution,
179 .get_wss = tvc_get_wss,
180 .set_wss = tvc_set_wss,
183 static int tvc_probe_pdata(struct platform_device *pdev)
185 struct panel_drv_data *ddata = platform_get_drvdata(pdev);
186 struct connector_atv_platform_data *pdata;
187 struct omap_dss_device *in, *dssdev;
189 pdata = dev_get_platdata(&pdev->dev);
191 in = omap_dss_find_output(pdata->source);
192 if (in == NULL) {
193 dev_err(&pdev->dev, "Failed to find video source\n");
194 return -EPROBE_DEFER;
197 ddata->in = in;
199 ddata->connector_type = pdata->connector_type;
200 ddata->invert_polarity = ddata->invert_polarity;
202 dssdev = &ddata->dssdev;
203 dssdev->name = pdata->name;
205 return 0;
208 static int tvc_probe(struct platform_device *pdev)
210 struct panel_drv_data *ddata;
211 struct omap_dss_device *dssdev;
212 int r;
214 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
215 if (!ddata)
216 return -ENOMEM;
218 platform_set_drvdata(pdev, ddata);
219 ddata->dev = &pdev->dev;
221 if (dev_get_platdata(&pdev->dev)) {
222 r = tvc_probe_pdata(pdev);
223 if (r)
224 return r;
225 } else {
226 return -ENODEV;
229 ddata->timings = tvc_pal_timings;
231 dssdev = &ddata->dssdev;
232 dssdev->driver = &tvc_driver;
233 dssdev->dev = &pdev->dev;
234 dssdev->type = OMAP_DISPLAY_TYPE_VENC;
235 dssdev->owner = THIS_MODULE;
236 dssdev->panel.timings = tvc_pal_timings;
238 r = omapdss_register_display(dssdev);
239 if (r) {
240 dev_err(&pdev->dev, "Failed to register panel\n");
241 goto err_reg;
244 return 0;
245 err_reg:
246 omap_dss_put_device(ddata->in);
247 return r;
250 static int __exit tvc_remove(struct platform_device *pdev)
252 struct panel_drv_data *ddata = platform_get_drvdata(pdev);
253 struct omap_dss_device *dssdev = &ddata->dssdev;
254 struct omap_dss_device *in = ddata->in;
256 omapdss_unregister_display(&ddata->dssdev);
258 tvc_disable(dssdev);
259 tvc_disconnect(dssdev);
261 omap_dss_put_device(in);
263 return 0;
266 static struct platform_driver tvc_connector_driver = {
267 .probe = tvc_probe,
268 .remove = __exit_p(tvc_remove),
269 .driver = {
270 .name = "connector-analog-tv",
271 .owner = THIS_MODULE,
275 module_platform_driver(tvc_connector_driver);
277 MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
278 MODULE_DESCRIPTION("Analog TV Connector driver");
279 MODULE_LICENSE("GPL");