aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-06-07 11:32:16 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2018-09-03 09:13:30 -0400
commit8e9c1c6676ea3d0dc60d84ee9a69984a4bcf859f (patch)
treee549035e06fbd176d9a9b39556fab7d4ec34802f
parent31cd7afa3086f1206ef4c7434e033669702adf08 (diff)
drm/omap: Move bus flag hack to encoder implementation
The bus flags stored in omap_dss_device instances are used to fixup the video mode before setting it, to honour constraints that can't be expressed through drm_display_mode. The fixup occurs in the CRTC mode set operation and the resulting video mode is stored internally in the CRTC. It is then used next by omap_encoder_enable() to apply mode fixups for the omap_dss_device instances in omap_encoder_update(). Move the hack to the omap_encoder_update() function right before applying the omap_dss_device fixups, in order to group all fixups together. 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>
-rw-r--r--drivers/gpu/drm/omapdrm/omap_crtc.c42
-rw-r--r--drivers/gpu/drm/omapdrm/omap_encoder.c48
2 files changed, 43 insertions, 47 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 39693dfe54af..62928ec0e7db 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -420,8 +420,6 @@ static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc)
420{ 420{
421 struct omap_crtc *omap_crtc = to_omap_crtc(crtc); 421 struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
422 struct drm_display_mode *mode = &crtc->state->adjusted_mode; 422 struct drm_display_mode *mode = &crtc->state->adjusted_mode;
423 struct videomode *vm = &omap_crtc->vm;
424 struct omap_dss_device *dssdev;
425 423
426 DBG("%s: set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x", 424 DBG("%s: set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
427 omap_crtc->name, mode->base.id, mode->name, 425 omap_crtc->name, mode->base.id, mode->name,
@@ -430,45 +428,7 @@ static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc)
430 mode->vdisplay, mode->vsync_start, mode->vsync_end, mode->vtotal, 428 mode->vdisplay, mode->vsync_start, mode->vsync_end, mode->vtotal,
431 mode->type, mode->flags); 429 mode->type, mode->flags);
432 430
433 drm_display_mode_to_videomode(mode, vm); 431 drm_display_mode_to_videomode(mode, &omap_crtc->vm);
434
435 /*
436 * HACK: This fixes the vm flags.
437 * struct drm_display_mode does not contain the VSYNC/HSYNC/DE flags
438 * and they get lost when converting back and forth between
439 * struct drm_display_mode and struct videomode. The hack below
440 * goes and fetches the missing flags from the panel drivers.
441 *
442 * A better solution is to use DRM's bus-flags through the whole driver.
443 */
444
445 for (dssdev = omap_crtc->pipe->output; dssdev; dssdev = dssdev->next) {
446 unsigned long bus_flags = dssdev->bus_flags;
447
448 if (!(vm->flags & (DISPLAY_FLAGS_DE_LOW |
449 DISPLAY_FLAGS_DE_HIGH))) {
450 if (bus_flags & DRM_BUS_FLAG_DE_LOW)
451 vm->flags |= DISPLAY_FLAGS_DE_LOW;
452 else if (bus_flags & DRM_BUS_FLAG_DE_HIGH)
453 vm->flags |= DISPLAY_FLAGS_DE_HIGH;
454 }
455
456 if (!(vm->flags & (DISPLAY_FLAGS_PIXDATA_POSEDGE |
457 DISPLAY_FLAGS_PIXDATA_NEGEDGE))) {
458 if (bus_flags & DRM_BUS_FLAG_PIXDATA_POSEDGE)
459 vm->flags |= DISPLAY_FLAGS_PIXDATA_POSEDGE;
460 else if (bus_flags & DRM_BUS_FLAG_PIXDATA_NEGEDGE)
461 vm->flags |= DISPLAY_FLAGS_PIXDATA_NEGEDGE;
462 }
463
464 if (!(vm->flags & (DISPLAY_FLAGS_SYNC_POSEDGE |
465 DISPLAY_FLAGS_SYNC_NEGEDGE))) {
466 if (bus_flags & DRM_BUS_FLAG_SYNC_POSEDGE)
467 vm->flags |= DISPLAY_FLAGS_SYNC_POSEDGE;
468 else if (bus_flags & DRM_BUS_FLAG_SYNC_NEGEDGE)
469 vm->flags |= DISPLAY_FLAGS_SYNC_NEGEDGE;
470 }
471 }
472} 432}
473 433
474static int omap_crtc_atomic_check(struct drm_crtc *crtc, 434static int omap_crtc_atomic_check(struct drm_crtc *crtc,
diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c
index bb010c20d8b8..82cdcba961a8 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -103,13 +103,49 @@ static int omap_encoder_update(struct drm_encoder *encoder,
103 int ret; 103 int ret;
104 104
105 for (dssdev = omap_encoder->output; dssdev; dssdev = dssdev->next) { 105 for (dssdev = omap_encoder->output; dssdev; dssdev = dssdev->next) {
106 if (!dssdev->ops->check_timings) 106 unsigned long bus_flags = dssdev->bus_flags;
107 continue; 107
108 if (dssdev->ops->check_timings) {
109 ret = dssdev->ops->check_timings(dssdev, vm);
110 if (ret) {
111 dev_err(dev->dev, "invalid timings: %d\n", ret);
112 return ret;
113 }
114 }
115
116 /*
117 * HACK: This fixes the vm flags.
118 * struct drm_display_mode does not contain the VSYNC/HSYNC/DE
119 * flags and they get lost when converting back and forth
120 * between struct drm_display_mode and struct videomode. The
121 * hack below goes and fetches the missing flags.
122 *
123 * A better solution is to use DRM's bus-flags through the whole
124 * driver.
125 */
126
127 if (!(vm->flags & (DISPLAY_FLAGS_DE_LOW |
128 DISPLAY_FLAGS_DE_HIGH))) {
129 if (bus_flags & DRM_BUS_FLAG_DE_LOW)
130 vm->flags |= DISPLAY_FLAGS_DE_LOW;
131 else if (bus_flags & DRM_BUS_FLAG_DE_HIGH)
132 vm->flags |= DISPLAY_FLAGS_DE_HIGH;
133 }
134
135 if (!(vm->flags & (DISPLAY_FLAGS_PIXDATA_POSEDGE |
136 DISPLAY_FLAGS_PIXDATA_NEGEDGE))) {
137 if (bus_flags & DRM_BUS_FLAG_PIXDATA_POSEDGE)
138 vm->flags |= DISPLAY_FLAGS_PIXDATA_POSEDGE;
139 else if (bus_flags & DRM_BUS_FLAG_PIXDATA_NEGEDGE)
140 vm->flags |= DISPLAY_FLAGS_PIXDATA_NEGEDGE;
141 }
108 142
109 ret = dssdev->ops->check_timings(dssdev, vm); 143 if (!(vm->flags & (DISPLAY_FLAGS_SYNC_POSEDGE |
110 if (ret) { 144 DISPLAY_FLAGS_SYNC_NEGEDGE))) {
111 dev_err(dev->dev, "invalid timings: %d\n", ret); 145 if (bus_flags & DRM_BUS_FLAG_SYNC_POSEDGE)
112 return ret; 146 vm->flags |= DISPLAY_FLAGS_SYNC_POSEDGE;
147 else if (bus_flags & DRM_BUS_FLAG_SYNC_NEGEDGE)
148 vm->flags |= DISPLAY_FLAGS_SYNC_NEGEDGE;
113 } 149 }
114 } 150 }
115 151