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

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

 



  * drm_mode_set_crtcinfo() does compensation for interlace and
doublescan timing effects already, so do it first and use the
compensated figures instead of the constant "vscan / ilace" terms
that we had before.

  * Also prefer using the mode->crtc_* fields generally instead of
the non-crtc_-prefixed versions, largely to avoid potential
confusion as to why some fields are the crtc_ versions and some
are not, but also in case drm_mode_set_crtcinfo() adds some more
mode-specific logic that we might want to use.

  * In one case, we use the non-crtc_-prefixed version of a mode
field, because the original form didn't include a "vscan / ilace"
term.

Signed-off-by: Alastair Bridgewater <alastair.bridgewater@xxxxxxxxx>
---
 drivers/gpu/drm/nouveau/nv50_display.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

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;
 }
 
-- 
2.10.2

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux