[Intel-gfx] [PATCH 1/5] drm: Refactor mode stereo doubling into its own function

Matt Roper matthew.d.roper at intel.com
Tue Nov 18 03:10:35 CET 2014


There are places where we want to perform vertical doubling for stereo
modes without the other adjustments (doublescan, vscan > 1, etc.) that
drm_mode_set_crtcinfo() performs.  Refactor this logic into its own
function so that it can be called directly in such places.

Cc: dri-devel at lists.freedesktop.org
Suggested-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper at intel.com>
---
 drivers/gpu/drm/drm_modes.c | 39 ++++++++++++++++++++++++++-------------
 include/drm/drm_modes.h     |  1 +
 2 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 6d8b941..8c25de3 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -728,6 +728,30 @@ int drm_mode_vrefresh(const struct drm_display_mode *mode)
 EXPORT_SYMBOL(drm_mode_vrefresh);
 
 /**
+ * drm_mode_stereo_double - Adjust mode timings for stereo modes
+ * @p: mode to adjust vertical timings of
+ *
+ * Performs stereo doubling of mode parameters when required by the stereo
+ * layout.  This may be used directly in places where the additional
+ * adjustments of drm_mode_set_crtcinfo() are undesired.
+ */
+void drm_mode_stereo_double(struct drm_display_mode *p)
+{
+	unsigned int layout = p->flags & DRM_MODE_FLAG_3D_MASK;
+
+	switch (layout) {
+	case DRM_MODE_FLAG_3D_FRAME_PACKING:
+		p->crtc_clock *= 2;
+		p->crtc_vdisplay += p->crtc_vtotal;
+		p->crtc_vsync_start += p->crtc_vtotal;
+		p->crtc_vsync_end += p->crtc_vtotal;
+		p->crtc_vtotal += p->crtc_vtotal;
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_mode_stereo_double);
+
+/**
  * drm_mode_set_crtcinfo - set CRTC modesetting timing parameters
  * @p: mode
  * @adjust_flags: a combination of adjustment flags
@@ -779,19 +803,8 @@ 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;
-
-		switch (layout) {
-		case DRM_MODE_FLAG_3D_FRAME_PACKING:
-			p->crtc_clock *= 2;
-			p->crtc_vdisplay += p->crtc_vtotal;
-			p->crtc_vsync_start += p->crtc_vtotal;
-			p->crtc_vsync_end += p->crtc_vtotal;
-			p->crtc_vtotal += p->crtc_vtotal;
-			break;
-		}
-	}
+	if (adjust_flags & CRTC_STEREO_DOUBLE)
+		drm_mode_stereo_double(p);
 
 	p->crtc_vblank_start = min(p->crtc_vsync_start, p->crtc_vdisplay);
 	p->crtc_vblank_end = max(p->crtc_vsync_end, p->crtc_vtotal);
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index 91d0582..2b3d05e 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -205,6 +205,7 @@ void drm_mode_set_name(struct drm_display_mode *mode);
 int drm_mode_hsync(const struct drm_display_mode *mode);
 int drm_mode_vrefresh(const struct drm_display_mode *mode);
 
+void drm_mode_stereo_double(struct drm_display_mode *p);
 void drm_mode_set_crtcinfo(struct drm_display_mode *p,
 			   int adjust_flags);
 void drm_mode_copy(struct drm_display_mode *dst,
-- 
1.8.5.1




More information about the Intel-gfx mailing list