Skip to content

Commit 78230c4

Browse files
committed
Merge tag 'omapdrm-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux into drm-next
omapdrm patches for v4.17 * Fix sparse warnings from omapdrm * HPD support for DVI connector * Big cleanup to remove static variables * tag 'omapdrm-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux: (69 commits) drm/omap: fix compile error when DPI is disabled drm/omap: fix compile error when debugfs is disabled drm: omapdrm: displays: panel-dsi-cm: Fix field access before set drm/omap: cleanup color space conversion drm/omap: Allow HDMI audio setup even if we do not have video configured drm/omap: fix maximum sizes drm/omap: add writeback funcs to dispc_ops drm/omap: fix scaling limits for WB drm/omap: fix WB height with interlace drm/omap: fix WBDELAYCOUNT with interlace drm/omap: fix WBDELAYCOUNT for HDMI drm/omap: set WB channel-in in wb_setup() drm/omap: Add pclk setting case when channel is DSS_WB drm/omap: dispc: disp_wb_setup to check return code drm/omap: remove leftover enums dt-bindings: display: add HPD gpio to DVI connector drm/omap: add HPD support to connector-dvi drm/omap: Init fbdev emulation only when we have displays drm/omap: cleanup fbdev init/free drm/omap: fix omap_fbdev_free() when omap_fbdev_create() wasn't called ...
2 parents b65bd40 + 037f031 commit 78230c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4277
-3831
lines changed

Documentation/devicetree/bindings/display/connector/dvi-connector.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Optional properties:
1010
- analog: the connector has DVI analog pins
1111
- digital: the connector has DVI digital pins
1212
- dual-link: the connector has pins for DVI dual-link
13+
- hpd-gpios: HPD GPIO number
1314

1415
Required nodes:
1516
- Video port for DVI input

drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,32 @@ static const struct videomode tvc_pal_vm = {
4040
DISPLAY_FLAGS_VSYNC_LOW,
4141
};
4242

43-
static const struct of_device_id tvc_of_match[];
44-
4543
#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
4644

4745
static int tvc_connect(struct omap_dss_device *dssdev)
4846
{
4947
struct panel_drv_data *ddata = to_panel_data(dssdev);
50-
struct omap_dss_device *in = ddata->in;
48+
struct omap_dss_device *in;
5149
int r;
5250

5351
dev_dbg(ddata->dev, "connect\n");
5452

5553
if (omapdss_device_is_connected(dssdev))
5654
return 0;
5755

56+
in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
57+
if (IS_ERR(in)) {
58+
dev_err(ddata->dev, "failed to find video source\n");
59+
return PTR_ERR(in);
60+
}
61+
5862
r = in->ops.atv->connect(in, dssdev);
59-
if (r)
63+
if (r) {
64+
omap_dss_put_device(in);
6065
return r;
66+
}
6167

68+
ddata->in = in;
6269
return 0;
6370
}
6471

@@ -73,6 +80,9 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
7380
return;
7481

7582
in->ops.atv->disconnect(in, dssdev);
83+
84+
omap_dss_put_device(in);
85+
ddata->in = NULL;
7686
}
7787

7888
static int tvc_enable(struct omap_dss_device *dssdev)
@@ -175,43 +185,19 @@ static struct omap_dss_driver tvc_driver = {
175185
.set_wss = tvc_set_wss,
176186
};
177187

178-
static int tvc_probe_of(struct platform_device *pdev)
179-
{
180-
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
181-
struct device_node *node = pdev->dev.of_node;
182-
struct omap_dss_device *in;
183-
184-
in = omapdss_of_find_source_for_first_ep(node);
185-
if (IS_ERR(in)) {
186-
dev_err(&pdev->dev, "failed to find video source\n");
187-
return PTR_ERR(in);
188-
}
189-
190-
ddata->in = in;
191-
192-
return 0;
193-
}
194-
195188
static int tvc_probe(struct platform_device *pdev)
196189
{
197190
struct panel_drv_data *ddata;
198191
struct omap_dss_device *dssdev;
199192
int r;
200193

201-
if (!pdev->dev.of_node)
202-
return -ENODEV;
203-
204194
ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
205195
if (!ddata)
206196
return -ENOMEM;
207197

208198
platform_set_drvdata(pdev, ddata);
209199
ddata->dev = &pdev->dev;
210200

211-
r = tvc_probe_of(pdev);
212-
if (r)
213-
return r;
214-
215201
ddata->vm = tvc_pal_vm;
216202

217203
dssdev = &ddata->dssdev;
@@ -224,28 +210,22 @@ static int tvc_probe(struct platform_device *pdev)
224210
r = omapdss_register_display(dssdev);
225211
if (r) {
226212
dev_err(&pdev->dev, "Failed to register panel\n");
227-
goto err_reg;
213+
return r;
228214
}
229215

230216
return 0;
231-
err_reg:
232-
omap_dss_put_device(ddata->in);
233-
return r;
234217
}
235218

236219
static int __exit tvc_remove(struct platform_device *pdev)
237220
{
238221
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
239222
struct omap_dss_device *dssdev = &ddata->dssdev;
240-
struct omap_dss_device *in = ddata->in;
241223

242224
omapdss_unregister_display(&ddata->dssdev);
243225

244226
tvc_disable(dssdev);
245227
tvc_disconnect(dssdev);
246228

247-
omap_dss_put_device(in);
248-
249229
return 0;
250230
}
251231

drivers/gpu/drm/omapdrm/displays/connector-dvi.c

Lines changed: 129 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* the Free Software Foundation.
1010
*/
1111

12+
#include <linux/gpio/consumer.h>
1213
#include <linux/i2c.h>
1314
#include <linux/module.h>
1415
#include <linux/platform_device.h>
@@ -44,23 +45,40 @@ struct panel_drv_data {
4445
struct videomode vm;
4546

4647
struct i2c_adapter *i2c_adapter;
48+
49+
struct gpio_desc *hpd_gpio;
50+
51+
void (*hpd_cb)(void *cb_data, enum drm_connector_status status);
52+
void *hpd_cb_data;
53+
bool hpd_enabled;
54+
/* mutex for hpd fields above */
55+
struct mutex hpd_lock;
4756
};
4857

4958
#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
5059

5160
static int dvic_connect(struct omap_dss_device *dssdev)
5261
{
5362
struct panel_drv_data *ddata = to_panel_data(dssdev);
54-
struct omap_dss_device *in = ddata->in;
63+
struct omap_dss_device *in;
5564
int r;
5665

5766
if (omapdss_device_is_connected(dssdev))
5867
return 0;
5968

69+
in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
70+
if (IS_ERR(in)) {
71+
dev_err(dssdev->dev, "failed to find video source\n");
72+
return PTR_ERR(in);
73+
}
74+
6075
r = in->ops.dvi->connect(in, dssdev);
61-
if (r)
76+
if (r) {
77+
omap_dss_put_device(in);
6278
return r;
79+
}
6380

81+
ddata->in = in;
6482
return 0;
6583
}
6684

@@ -73,6 +91,9 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
7391
return;
7492

7593
in->ops.dvi->disconnect(in, dssdev);
94+
95+
omap_dss_put_device(in);
96+
ddata->in = NULL;
7697
}
7798

7899
static int dvic_enable(struct omap_dss_device *dssdev)
@@ -177,6 +198,9 @@ static int dvic_read_edid(struct omap_dss_device *dssdev,
177198
struct panel_drv_data *ddata = to_panel_data(dssdev);
178199
int r, l, bytes_read;
179200

201+
if (ddata->hpd_gpio && !gpiod_get_value_cansleep(ddata->hpd_gpio))
202+
return -ENODEV;
203+
180204
if (!ddata->i2c_adapter)
181205
return -ENODEV;
182206

@@ -208,6 +232,9 @@ static bool dvic_detect(struct omap_dss_device *dssdev)
208232
unsigned char out;
209233
int r;
210234

235+
if (ddata->hpd_gpio)
236+
return gpiod_get_value_cansleep(ddata->hpd_gpio);
237+
211238
if (!ddata->i2c_adapter)
212239
return true;
213240

@@ -216,6 +243,60 @@ static bool dvic_detect(struct omap_dss_device *dssdev)
216243
return r == 0;
217244
}
218245

246+
static int dvic_register_hpd_cb(struct omap_dss_device *dssdev,
247+
void (*cb)(void *cb_data,
248+
enum drm_connector_status status),
249+
void *cb_data)
250+
{
251+
struct panel_drv_data *ddata = to_panel_data(dssdev);
252+
253+
if (!ddata->hpd_gpio)
254+
return -ENOTSUPP;
255+
256+
mutex_lock(&ddata->hpd_lock);
257+
ddata->hpd_cb = cb;
258+
ddata->hpd_cb_data = cb_data;
259+
mutex_unlock(&ddata->hpd_lock);
260+
return 0;
261+
}
262+
263+
static void dvic_unregister_hpd_cb(struct omap_dss_device *dssdev)
264+
{
265+
struct panel_drv_data *ddata = to_panel_data(dssdev);
266+
267+
if (!ddata->hpd_gpio)
268+
return;
269+
270+
mutex_lock(&ddata->hpd_lock);
271+
ddata->hpd_cb = NULL;
272+
ddata->hpd_cb_data = NULL;
273+
mutex_unlock(&ddata->hpd_lock);
274+
}
275+
276+
static void dvic_enable_hpd(struct omap_dss_device *dssdev)
277+
{
278+
struct panel_drv_data *ddata = to_panel_data(dssdev);
279+
280+
if (!ddata->hpd_gpio)
281+
return;
282+
283+
mutex_lock(&ddata->hpd_lock);
284+
ddata->hpd_enabled = true;
285+
mutex_unlock(&ddata->hpd_lock);
286+
}
287+
288+
static void dvic_disable_hpd(struct omap_dss_device *dssdev)
289+
{
290+
struct panel_drv_data *ddata = to_panel_data(dssdev);
291+
292+
if (!ddata->hpd_gpio)
293+
return;
294+
295+
mutex_lock(&ddata->hpd_lock);
296+
ddata->hpd_enabled = false;
297+
mutex_unlock(&ddata->hpd_lock);
298+
}
299+
219300
static struct omap_dss_driver dvic_driver = {
220301
.connect = dvic_connect,
221302
.disconnect = dvic_disconnect,
@@ -229,31 +310,67 @@ static struct omap_dss_driver dvic_driver = {
229310

230311
.read_edid = dvic_read_edid,
231312
.detect = dvic_detect,
313+
314+
.register_hpd_cb = dvic_register_hpd_cb,
315+
.unregister_hpd_cb = dvic_unregister_hpd_cb,
316+
.enable_hpd = dvic_enable_hpd,
317+
.disable_hpd = dvic_disable_hpd,
232318
};
233319

320+
static irqreturn_t dvic_hpd_isr(int irq, void *data)
321+
{
322+
struct panel_drv_data *ddata = data;
323+
324+
mutex_lock(&ddata->hpd_lock);
325+
if (ddata->hpd_enabled && ddata->hpd_cb) {
326+
enum drm_connector_status status;
327+
328+
if (dvic_detect(&ddata->dssdev))
329+
status = connector_status_connected;
330+
else
331+
status = connector_status_disconnected;
332+
333+
ddata->hpd_cb(ddata->hpd_cb_data, status);
334+
}
335+
mutex_unlock(&ddata->hpd_lock);
336+
337+
return IRQ_HANDLED;
338+
}
339+
234340
static int dvic_probe_of(struct platform_device *pdev)
235341
{
236342
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
237343
struct device_node *node = pdev->dev.of_node;
238-
struct omap_dss_device *in;
239344
struct device_node *adapter_node;
240345
struct i2c_adapter *adapter;
346+
struct gpio_desc *gpio;
347+
int r;
241348

242-
in = omapdss_of_find_source_for_first_ep(node);
243-
if (IS_ERR(in)) {
244-
dev_err(&pdev->dev, "failed to find video source\n");
245-
return PTR_ERR(in);
349+
gpio = devm_gpiod_get_optional(&pdev->dev, "hpd", GPIOD_IN);
350+
if (IS_ERR(gpio)) {
351+
dev_err(&pdev->dev, "failed to parse HPD gpio\n");
352+
return PTR_ERR(gpio);
246353
}
247354

248-
ddata->in = in;
355+
ddata->hpd_gpio = gpio;
356+
357+
mutex_init(&ddata->hpd_lock);
358+
359+
if (ddata->hpd_gpio) {
360+
r = devm_request_threaded_irq(&pdev->dev,
361+
gpiod_to_irq(ddata->hpd_gpio), NULL, dvic_hpd_isr,
362+
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
363+
"DVI HPD", ddata);
364+
if (r)
365+
return r;
366+
}
249367

250368
adapter_node = of_parse_phandle(node, "ddc-i2c-bus", 0);
251369
if (adapter_node) {
252370
adapter = of_get_i2c_adapter_by_node(adapter_node);
253371
of_node_put(adapter_node);
254372
if (adapter == NULL) {
255373
dev_err(&pdev->dev, "failed to parse ddc-i2c-bus\n");
256-
omap_dss_put_device(ddata->in);
257374
return -EPROBE_DEFER;
258375
}
259376

@@ -275,9 +392,6 @@ static int dvic_probe(struct platform_device *pdev)
275392

276393
platform_set_drvdata(pdev, ddata);
277394

278-
if (!pdev->dev.of_node)
279-
return -ENODEV;
280-
281395
r = dvic_probe_of(pdev);
282396
if (r)
283397
return r;
@@ -300,9 +414,8 @@ static int dvic_probe(struct platform_device *pdev)
300414
return 0;
301415

302416
err_reg:
303-
omap_dss_put_device(ddata->in);
304-
305417
i2c_put_adapter(ddata->i2c_adapter);
418+
mutex_destroy(&ddata->hpd_lock);
306419

307420
return r;
308421
}
@@ -311,17 +424,16 @@ static int __exit dvic_remove(struct platform_device *pdev)
311424
{
312425
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
313426
struct omap_dss_device *dssdev = &ddata->dssdev;
314-
struct omap_dss_device *in = ddata->in;
315427

316428
omapdss_unregister_display(&ddata->dssdev);
317429

318430
dvic_disable(dssdev);
319431
dvic_disconnect(dssdev);
320432

321-
omap_dss_put_device(in);
322-
323433
i2c_put_adapter(ddata->i2c_adapter);
324434

435+
mutex_destroy(&ddata->hpd_lock);
436+
325437
return 0;
326438
}
327439

0 commit comments

Comments
 (0)