Skip to content

Commit 7877632

Browse files
pinchartltomba
authored andcommitted
drm: omapdrm: displays: Get panel source at connect time
The connector drivers need a handle to the source they are connected to in order to control the source. All drivers get that handle at probe time, resulting in probe deferral when the source hasn't been probed yet. However they don't need the handle until their connect handler is called. Move retrieval of the source handle to the connect handler to avoid probe deferrals. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
1 parent 30a5fd2 commit 7877632

File tree

8 files changed

+119
-153
lines changed

8 files changed

+119
-153
lines changed

drivers/gpu/drm/omapdrm/displays/panel-dpi.c

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,25 @@ struct panel_drv_data {
3838
static int panel_dpi_connect(struct omap_dss_device *dssdev)
3939
{
4040
struct panel_drv_data *ddata = to_panel_data(dssdev);
41-
struct omap_dss_device *in = ddata->in;
41+
struct omap_dss_device *in;
4242
int r;
4343

4444
if (omapdss_device_is_connected(dssdev))
4545
return 0;
4646

47+
in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
48+
if (IS_ERR(in)) {
49+
dev_err(dssdev->dev, "failed to find video source\n");
50+
return PTR_ERR(in);
51+
}
52+
4753
r = in->ops.dpi->connect(in, dssdev);
48-
if (r)
54+
if (r) {
55+
omap_dss_put_device(in);
4956
return r;
57+
}
5058

59+
ddata->in = in;
5160
return 0;
5261
}
5362

@@ -60,6 +69,9 @@ static void panel_dpi_disconnect(struct omap_dss_device *dssdev)
6069
return;
6170

6271
in->ops.dpi->disconnect(in, dssdev);
72+
73+
omap_dss_put_device(in);
74+
ddata->in = NULL;
6375
}
6476

6577
static int panel_dpi_enable(struct omap_dss_device *dssdev)
@@ -165,7 +177,6 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
165177
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
166178
struct device_node *node = pdev->dev.of_node;
167179
struct device_node *bl_node;
168-
struct omap_dss_device *in;
169180
int r;
170181
struct display_timing timing;
171182
struct gpio_desc *gpio;
@@ -207,15 +218,6 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
207218

208219
videomode_from_timing(&timing, &ddata->vm);
209220

210-
in = omapdss_of_find_source_for_first_ep(node);
211-
if (IS_ERR(in)) {
212-
dev_err(&pdev->dev, "failed to find video source\n");
213-
r = PTR_ERR(in);
214-
goto error_free_backlight;
215-
}
216-
217-
ddata->in = in;
218-
219221
return 0;
220222

221223
error_free_backlight:
@@ -251,29 +253,22 @@ static int panel_dpi_probe(struct platform_device *pdev)
251253
r = omapdss_register_display(dssdev);
252254
if (r) {
253255
dev_err(&pdev->dev, "Failed to register panel\n");
254-
goto err_reg;
256+
return r;
255257
}
256258

257259
return 0;
258-
259-
err_reg:
260-
omap_dss_put_device(ddata->in);
261-
return r;
262260
}
263261

264262
static int __exit panel_dpi_remove(struct platform_device *pdev)
265263
{
266264
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
267265
struct omap_dss_device *dssdev = &ddata->dssdev;
268-
struct omap_dss_device *in = ddata->in;
269266

270267
omapdss_unregister_display(dssdev);
271268

272269
panel_dpi_disable(dssdev);
273270
panel_dpi_disconnect(dssdev);
274271

275-
omap_dss_put_device(in);
276-
277272
if (ddata->backlight)
278273
put_device(&ddata->backlight->dev);
279274

drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -759,17 +759,23 @@ static int dsicm_panel_reset(struct panel_drv_data *ddata)
759759
static int dsicm_connect(struct omap_dss_device *dssdev)
760760
{
761761
struct panel_drv_data *ddata = to_panel_data(dssdev);
762-
struct omap_dss_device *in = ddata->in;
763762
struct device *dev = &ddata->pdev->dev;
763+
struct omap_dss_device *in;
764764
int r;
765765

766766
if (omapdss_device_is_connected(dssdev))
767767
return 0;
768768

769+
in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
770+
if (IS_ERR(in)) {
771+
dev_err(dssdev->dev, "failed to find video source\n");
772+
return PTR_ERR(in);
773+
}
774+
769775
r = in->ops.dsi->connect(in, dssdev);
770776
if (r) {
771777
dev_err(dev, "Failed to connect to video source\n");
772-
return r;
778+
goto err_connect;
773779
}
774780

775781
r = in->ops.dsi->request_vc(ddata->in, &ddata->channel);
@@ -784,12 +790,15 @@ static int dsicm_connect(struct omap_dss_device *dssdev)
784790
goto err_vc_id;
785791
}
786792

793+
ddata->in = in;
787794
return 0;
788795

789796
err_vc_id:
790797
in->ops.dsi->release_vc(ddata->in, ddata->channel);
791798
err_req_vc:
792799
in->ops.dsi->disconnect(in, dssdev);
800+
err_connect:
801+
omap_dss_put_device(in);
793802
return r;
794803
}
795804

@@ -803,6 +812,9 @@ static void dsicm_disconnect(struct omap_dss_device *dssdev)
803812

804813
in->ops.dsi->release_vc(in, ddata->channel);
805814
in->ops.dsi->disconnect(in, dssdev);
815+
816+
omap_dss_put_device(in);
817+
ddata->in = NULL;
806818
}
807819

808820
static int dsicm_enable(struct omap_dss_device *dssdev)
@@ -1223,7 +1235,6 @@ static int dsicm_probe_of(struct platform_device *pdev)
12231235
struct device_node *node = pdev->dev.of_node;
12241236
struct device_node *backlight;
12251237
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
1226-
struct omap_dss_device *in;
12271238
struct display_timing timing;
12281239
int err;
12291240

@@ -1259,12 +1270,6 @@ static int dsicm_probe_of(struct platform_device *pdev)
12591270
ddata->height_mm = 0;
12601271
of_property_read_u32(node, "height-mm", &ddata->height_mm);
12611272

1262-
in = omapdss_of_find_source_for_first_ep(node);
1263-
if (IS_ERR(in)) {
1264-
dev_err(&pdev->dev, "failed to find video source\n");
1265-
return PTR_ERR(in);
1266-
}
1267-
12681273
ddata->vpnl = devm_regulator_get_optional(&pdev->dev, "vpnl");
12691274
if (IS_ERR(ddata->vpnl)) {
12701275
err = PTR_ERR(ddata->vpnl);
@@ -1281,8 +1286,6 @@ static int dsicm_probe_of(struct platform_device *pdev)
12811286
ddata->vddi = NULL;
12821287
}
12831288

1284-
ddata->in = in;
1285-
12861289
backlight = of_parse_phandle(node, "backlight", 0);
12871290
if (backlight) {
12881291
ddata->extbldev = of_find_backlight_by_node(backlight);
@@ -1421,8 +1424,6 @@ static int __exit dsicm_remove(struct platform_device *pdev)
14211424
if (ddata->extbldev)
14221425
put_device(&ddata->extbldev->dev);
14231426

1424-
omap_dss_put_device(ddata->in);
1425-
14261427
dsicm_cancel_ulps_work(ddata);
14271428
destroy_workqueue(ddata->workqueue);
14281429

drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,27 @@ static void init_lb035q02_panel(struct spi_device *spi)
119119
static int lb035q02_connect(struct omap_dss_device *dssdev)
120120
{
121121
struct panel_drv_data *ddata = to_panel_data(dssdev);
122-
struct omap_dss_device *in = ddata->in;
122+
struct omap_dss_device *in;
123123
int r;
124124

125125
if (omapdss_device_is_connected(dssdev))
126126
return 0;
127127

128+
in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
129+
if (IS_ERR(in)) {
130+
dev_err(dssdev->dev, "failed to find video source\n");
131+
return PTR_ERR(in);
132+
}
133+
128134
r = in->ops.dpi->connect(in, dssdev);
129-
if (r)
135+
if (r) {
136+
omap_dss_put_device(in);
130137
return r;
138+
}
131139

132140
init_lb035q02_panel(ddata->spi);
133141

142+
ddata->in = in;
134143
return 0;
135144
}
136145

@@ -143,6 +152,9 @@ static void lb035q02_disconnect(struct omap_dss_device *dssdev)
143152
return;
144153

145154
in->ops.dpi->disconnect(in, dssdev);
155+
156+
omap_dss_put_device(in);
157+
ddata->in = NULL;
146158
}
147159

148160
static int lb035q02_enable(struct omap_dss_device *dssdev)
@@ -230,9 +242,7 @@ static struct omap_dss_driver lb035q02_ops = {
230242

231243
static int lb035q02_probe_of(struct spi_device *spi)
232244
{
233-
struct device_node *node = spi->dev.of_node;
234245
struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
235-
struct omap_dss_device *in;
236246
struct gpio_desc *gpio;
237247

238248
gpio = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW);
@@ -243,14 +253,6 @@ static int lb035q02_probe_of(struct spi_device *spi)
243253

244254
ddata->enable_gpio = gpio;
245255

246-
in = omapdss_of_find_source_for_first_ep(node);
247-
if (IS_ERR(in)) {
248-
dev_err(&spi->dev, "failed to find video source\n");
249-
return PTR_ERR(in);
250-
}
251-
252-
ddata->in = in;
253-
254256
return 0;
255257
}
256258

@@ -284,29 +286,22 @@ static int lb035q02_panel_spi_probe(struct spi_device *spi)
284286
r = omapdss_register_display(dssdev);
285287
if (r) {
286288
dev_err(&spi->dev, "Failed to register panel\n");
287-
goto err_reg;
289+
return r;
288290
}
289291

290292
return 0;
291-
292-
err_reg:
293-
omap_dss_put_device(ddata->in);
294-
return r;
295293
}
296294

297295
static int lb035q02_panel_spi_remove(struct spi_device *spi)
298296
{
299297
struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
300298
struct omap_dss_device *dssdev = &ddata->dssdev;
301-
struct omap_dss_device *in = ddata->in;
302299

303300
omapdss_unregister_display(dssdev);
304301

305302
lb035q02_disable(dssdev);
306303
lb035q02_disconnect(dssdev);
307304

308-
omap_dss_put_device(in);
309-
310305
return 0;
311306
}
312307

drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,25 @@ static int init_nec_8048_wvga_lcd(struct spi_device *spi)
115115
static int nec_8048_connect(struct omap_dss_device *dssdev)
116116
{
117117
struct panel_drv_data *ddata = to_panel_data(dssdev);
118-
struct omap_dss_device *in = ddata->in;
118+
struct omap_dss_device *in;
119119
int r;
120120

121121
if (omapdss_device_is_connected(dssdev))
122122
return 0;
123123

124+
in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
125+
if (IS_ERR(in)) {
126+
dev_err(dssdev->dev, "failed to find video source\n");
127+
return PTR_ERR(in);
128+
}
129+
124130
r = in->ops.dpi->connect(in, dssdev);
125-
if (r)
131+
if (r) {
132+
omap_dss_put_device(in);
126133
return r;
134+
}
127135

136+
ddata->in = in;
128137
return 0;
129138
}
130139

@@ -137,6 +146,9 @@ static void nec_8048_disconnect(struct omap_dss_device *dssdev)
137146
return;
138147

139148
in->ops.dpi->disconnect(in, dssdev);
149+
150+
omap_dss_put_device(in);
151+
ddata->in = NULL;
140152
}
141153

142154
static int nec_8048_enable(struct omap_dss_device *dssdev)
@@ -226,7 +238,6 @@ static int nec_8048_probe_of(struct spi_device *spi)
226238
{
227239
struct device_node *node = spi->dev.of_node;
228240
struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
229-
struct omap_dss_device *in;
230241
int gpio;
231242

232243
gpio = of_get_named_gpio(node, "reset-gpios", 0);
@@ -239,14 +250,6 @@ static int nec_8048_probe_of(struct spi_device *spi)
239250
/* XXX the panel spec doesn't mention any QVGA pin?? */
240251
ddata->qvga_gpio = -ENOENT;
241252

242-
in = omapdss_of_find_source_for_first_ep(node);
243-
if (IS_ERR(in)) {
244-
dev_err(&spi->dev, "failed to find video source\n");
245-
return PTR_ERR(in);
246-
}
247-
248-
ddata->in = in;
249-
250253
return 0;
251254
}
252255

@@ -285,14 +288,14 @@ static int nec_8048_probe(struct spi_device *spi)
285288
r = devm_gpio_request_one(&spi->dev, ddata->qvga_gpio,
286289
GPIOF_OUT_INIT_HIGH, "lcd QVGA");
287290
if (r)
288-
goto err_gpio;
291+
return r;
289292
}
290293

291294
if (gpio_is_valid(ddata->res_gpio)) {
292295
r = devm_gpio_request_one(&spi->dev, ddata->res_gpio,
293296
GPIOF_OUT_INIT_LOW, "lcd RES");
294297
if (r)
295-
goto err_gpio;
298+
return r;
296299
}
297300

298301
ddata->vm = nec_8048_panel_vm;
@@ -307,22 +310,16 @@ static int nec_8048_probe(struct spi_device *spi)
307310
r = omapdss_register_display(dssdev);
308311
if (r) {
309312
dev_err(&spi->dev, "Failed to register panel\n");
310-
goto err_reg;
313+
return r;
311314
}
312315

313316
return 0;
314-
315-
err_reg:
316-
err_gpio:
317-
omap_dss_put_device(ddata->in);
318-
return r;
319317
}
320318

321319
static int nec_8048_remove(struct spi_device *spi)
322320
{
323321
struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
324322
struct omap_dss_device *dssdev = &ddata->dssdev;
325-
struct omap_dss_device *in = ddata->in;
326323

327324
dev_dbg(&ddata->spi->dev, "%s\n", __func__);
328325

@@ -331,8 +328,6 @@ static int nec_8048_remove(struct spi_device *spi)
331328
nec_8048_disable(dssdev);
332329
nec_8048_disconnect(dssdev);
333330

334-
omap_dss_put_device(in);
335-
336331
return 0;
337332
}
338333

0 commit comments

Comments
 (0)