[v2,01/10] drm/nouveau: Use drm_mode_set_crtcinfo() to compensate for vscan / ilace

Submitted by Alastair Bridgewater on March 27, 2017, 9:57 p.m.

Details

Message ID 20170327215807.8461-2-alastair.bridgewater@gmail.com
State New
Headers show

Not browsing as part of any series.

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 32097fd..1acbb5a 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -2032,32 +2032,34 @@  static void
 nv50_head_atomic_check_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
 	struct drm_display_mode *mode = &asyh->state.adjusted_mode;
-	u32 ilace   = (mode->flags & DRM_MODE_FLAG_INTERLACE) ? 2 : 1;
-	u32 vscan   = (mode->flags & DRM_MODE_FLAG_DBLSCAN) ? 2 : 1;
-	u32 hbackp  =  mode->htotal - mode->hsync_end;
-	u32 vbackp  = (mode->vtotal - mode->vsync_end) * vscan / ilace;
-	u32 hfrontp =  mode->hsync_start - mode->hdisplay;
-	u32 vfrontp = (mode->vsync_start - mode->vdisplay) * vscan / ilace;
 	struct nv50_head_mode *m = &asyh->mode;
+	u32 hbackp, vbackp, hfrontp, vfrontp;
 
-	m->h.active = mode->htotal;
-	m->h.synce  = mode->hsync_end - mode->hsync_start - 1;
+	drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
+
+	hbackp = mode->crtc_htotal - mode->crtc_hsync_end;
+	vbackp = mode->crtc_vtotal - mode->crtc_vsync_end;
+	hfrontp =  mode->crtc_hsync_start - mode->crtc_hdisplay;
+	vfrontp = mode->crtc_vsync_start - mode->crtc_vdisplay;
+
+	m->h.active = mode->crtc_htotal;
+	m->h.synce  = mode->crtc_hsync_end - mode->crtc_hsync_start - 1;
 	m->h.blanke = m->h.synce + hbackp;
-	m->h.blanks = mode->htotal - hfrontp - 1;
+	m->h.blanks = mode->crtc_htotal - hfrontp - 1;
 
-	m->v.active = mode->vtotal * vscan / ilace;
-	m->v.synce  = ((mode->vsync_end - mode->vsync_start) * vscan / ilace) - 1;
+	m->v.active = mode->crtc_vtotal;
+	m->v.synce  = (mode->crtc_vsync_end - mode->crtc_vsync_start) - 1;
 	m->v.blanke = m->v.synce + vbackp;
 	m->v.blanks = m->v.active - vfrontp - 1;
 
 	/*XXX: Safe underestimate, even "0" works */
 	m->v.blankus = (m->v.active - mode->vdisplay - 2) * m->h.active;
 	m->v.blankus *= 1000;
-	m->v.blankus /= mode->clock;
+	m->v.blankus /= mode->crtc_clock;
 
 	if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
 		m->v.blank2e =  m->v.active + m->v.synce + vbackp;
-		m->v.blank2s =  m->v.blank2e + (mode->vdisplay * vscan / ilace);
+		m->v.blank2s =  m->v.blank2e + mode->crtc_vdisplay;
 		m->v.active  = (m->v.active * 2) + 1;
 		m->interlace = true;
 	} else {
@@ -2065,9 +2067,8 @@  nv50_head_atomic_check_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
 		m->v.blank2s = 1;
 		m->interlace = false;
 	}
-	m->clock = mode->clock;
+	m->clock = mode->crtc_clock;
 
-	drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
 	asyh->set.mode = true;
 }