[PATCH 14/20] drm: Implement timings adjustments for frame packing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When using the frame packing and a single big framebuffer, some hardware
requires that we do everything like if we were scanning out the big
buffer itself. Let's instrument drm_mode_set_crtcinfo() to be able to do
this adjustement if the driver is asking for it.

Suggested-by: Daniel Vetter <daniel.vetter@xxxxxxxx>
Signed-off-by: Damien Lespiau <damien.lespiau@xxxxxxxxx>
---
 drivers/gpu/drm/drm_modes.c | 51 ++++++++++++++++++++++++++++++++++++++++++++-
 include/drm/drm_crtc.h      |  3 ++-
 2 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index ef26eb2..d9c5a34 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -704,15 +704,47 @@ int drm_mode_vrefresh(const struct drm_display_mode *mode)
 }
 EXPORT_SYMBOL(drm_mode_vrefresh);
 
+static bool drm_mode_is_ntsc(const struct drm_display_mode *mode)
+{
+	int ntsc_clock;
+
+	ntsc_clock = DIV_ROUND_UP(mode->vtotal * mode->htotal * mode->vrefresh,
+				  1001);
+
+	if (ntsc_clock == mode->clock)
+		return true;
+
+	return false;
+}
+
+static void drm_mode_reconstruct_crtc_clock(struct drm_display_mode *mode)
+{
+	int clock;
+
+	clock = mode->crtc_vtotal * mode->crtc_htotal *
+		drm_mode_vrefresh(mode) / 1000;
+
+	if (drm_mode_is_ntsc(mode))
+		mode->crtc_clock = DIV_ROUND_UP(clock * 1000, 1001);
+	else
+		mode->crtc_clock = clock;
+}
+
 /**
  * drm_mode_set_crtcinfo - set CRTC modesetting parameters
  * @p: mode
- * @adjust_flags: unused? (FIXME)
+ * @adjust_flags: a combination of adjustment flags
  *
  * LOCKING:
  * None.
  *
  * Setup the CRTC modesetting parameters for @p, adjusting if necessary.
+ *
+ * - The CRTC_INTERLACE_HALVE_V flag can be used to halve vertical timings of
+ *   interlaced modes.
+ * - The CRTC_STEREO_DOUBLE flag can be used to compute the timings for
+ *   buffers containing two eyes (only adjust the timings when needed, eg. for
+ *   "frame packing" or "side by side full").
  */
 void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags)
 {
@@ -753,6 +785,23 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags)
 		p->crtc_vtotal *= p->vscan;
 	}
 
+	if (adjust_flags & CRTC_STEREO_DOUBLE) {
+		unsigned int layout = p->flags & DRM_MODE_FLAG_3D_MASK;
+		int vactive_space;
+
+		switch (layout) {
+		case DRM_MODE_FLAG_3D_FRAME_PACKING:
+			vactive_space = p->vtotal - p->vdisplay;
+
+			p->crtc_vdisplay += p->vdisplay + vactive_space;
+			p->crtc_vsync_start += p->vdisplay + vactive_space;
+			p->crtc_vsync_end += p->vdisplay + vactive_space;
+			p->crtc_vtotal += p->vdisplay + vactive_space;
+			drm_mode_reconstruct_crtc_clock(p);
+			break;
+		}
+	}
+
 	p->crtc_vblank_start = min(p->crtc_vsync_start, p->crtc_vdisplay);
 	p->crtc_vblank_end = max(p->crtc_vsync_end, p->crtc_vtotal);
 	p->crtc_hblank_start = min(p->crtc_hsync_start, p->crtc_hdisplay);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 73478bc..b2d08ca 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -125,7 +125,8 @@ enum drm_mode_status {
 	.vscan = (vs), .flags = (f), \
 	.base.type = DRM_MODE_OBJECT_MODE
 
-#define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */
+#define CRTC_INTERLACE_HALVE_V	(1 << 0) /* halve V values for interlacing */
+#define CRTC_STEREO_DOUBLE	(1 << 1) /* adjust timings for stereo modes */
 
 struct drm_display_mode {
 	/* Header */
-- 
1.8.3.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux