All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alastair Bridgewater <alastair.bridgewater-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH v3 01/10] drm/nouveau: Clean up nv50_head_atomic_check_mode() and fix blankus calculation
Date: Tue, 11 Apr 2017 13:11:16 -0400	[thread overview]
Message-ID: <20170411171125.10496-2-alastair.bridgewater@gmail.com> (raw)
In-Reply-To: <20170411171125.10496-1-alastair.bridgewater-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

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.

And then it turns out that the hardware model for how the timing
parameters are configured is basically the standard model, but
starting one clock before the sync pulse rather than at the start
of the display area, which lets us drastically simplify the
overall timing calculations (verifying the changes by algebraic
operations is left as an exercise for the reader).

Finally, there were a couple of issues with the computation of
m->v.blankus that are addressed here.  Interlaced modes would
generate a negative intermediate result.  Double scan modes would
generate an overestimate rather than an underestimate.  And when
enabling frame-packing modes, a rather extreme overestimate would
be generated.  Fixed, by using the timings as adjusted for the
CRTC to find the length of the vertical blanking period instead of
mixing adjusted and pre-adjustment timing parameters.

Signed-off-by: Alastair Bridgewater <alastair.bridgewater@gmail.com>
---
 drivers/gpu/drm/nouveau/nv50_display.c | 44 ++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index c9910c8..c901f32 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -2035,34 +2035,37 @@ 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;
-	u32 blankus;
 	struct nv50_head_mode *m = &asyh->mode;
+	u32 blankus;
 
-	m->h.active = mode->htotal;
-	m->h.synce  = mode->hsync_end - mode->hsync_start - 1;
-	m->h.blanke = m->h.synce + hbackp;
-	m->h.blanks = mode->htotal - hfrontp - 1;
+	drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
 
-	m->v.active = mode->vtotal * vscan / ilace;
-	m->v.synce  = ((mode->vsync_end - mode->vsync_start) * vscan / ilace) - 1;
-	m->v.blanke = m->v.synce + vbackp;
-	m->v.blanks = m->v.active - vfrontp - 1;
+	/*
+	 * DRM modes are defined in terms of a repeating interval
+	 * starting with the active display area.  The hardware modes
+	 * are defined in terms of a repeating interval starting one
+	 * unit (pixel or line) into the sync pulse.  So, add bias.
+	 */
+
+	m->h.active = mode->crtc_htotal;
+	m->h.synce  = mode->crtc_hsync_end - mode->crtc_hsync_start - 1;
+	m->h.blanke = mode->crtc_hblank_end - mode->crtc_hsync_start - 1;
+	m->h.blanks = m->h.blanke + mode->crtc_hdisplay;
+
+	m->v.active = mode->crtc_vtotal;
+	m->v.synce  = mode->crtc_vsync_end - mode->crtc_vsync_start - 1;
+	m->v.blanke = mode->crtc_vblank_end - mode->crtc_vsync_start - 1;
+	m->v.blanks = m->v.blanke + mode->crtc_vdisplay;
 
 	/*XXX: Safe underestimate, even "0" works */
-	blankus = (m->v.active - mode->vdisplay - 2) * m->h.active;
+	blankus = (m->v.active - mode->crtc_vdisplay - 2) * m->h.active;
 	blankus *= 1000;
-	blankus /= mode->clock;
+	blankus /= mode->crtc_clock;
 	m->v.blankus = blankus;
 
 	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.blank2e =  m->v.active + m->v.blanke;
+		m->v.blank2s =  m->v.blank2e + mode->crtc_vdisplay;
 		m->v.active  = (m->v.active * 2) + 1;
 		m->interlace = true;
 	} else {
@@ -2070,9 +2073,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

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

  parent reply	other threads:[~2017-04-11 17:11 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-17 22:41 [PATCH 0/6] drm/nouveau: Enable HDMI Stereoscopy Alastair Bridgewater
     [not found] ` <20170117224204.27516-1-alastair.bridgewater-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-17 22:41   ` [PATCH 1/6] drm/nouveau: Extend NVKM HDMI power control method to set InfoFrames Alastair Bridgewater
     [not found]     ` <20170117224204.27516-2-alastair.bridgewater-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-18  3:19       ` Ilia Mirkin
2017-01-17 22:42   ` [PATCH 2/6] drm/nouveau: Pass mode-dependent AVI and Vendor HDMI InfoFrames to NVKM Alastair Bridgewater
     [not found]     ` <20170117224204.27516-3-alastair.bridgewater-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-18  3:31       ` Ilia Mirkin
2017-01-17 22:42   ` [PATCH 3/6] drm/nouveau: Use supplied HDMI InfoFrames on GT215 hardware Alastair Bridgewater
2017-01-17 22:42   ` [PATCH 4/6] drm/nouveau: Use supplied HDMI InfoFrames on GK104 hardware Alastair Bridgewater
2017-01-17 22:42   ` [PATCH 5/6] drm: Delete "mandatory" stereographic modes Alastair Bridgewater
     [not found]     ` <20170117224204.27516-6-alastair.bridgewater-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-18  5:10       ` Ilia Mirkin
     [not found]         ` <CAKb7UvigMUdD93eqa=3bM9VHSGztV3DWgv-8hx8ho7EmHrhtqA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-18 11:45           ` Damien Lespiau
     [not found]             ` <20170118114554.GA6460-q+Y1yDQJ1rIB9AHHLWeGtNQXobZC6xk2@public.gmane.org>
2017-01-18 16:27               ` Ilia Mirkin
     [not found]                 ` <CAKb7Uvg0wgmZG+S39XNP-r0Qny6ikDhwvyy9TAspOZQ_dEp1RQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-18 16:33                   ` Damien Lespiau
     [not found]                     ` <20170118163343.GD6460-q+Y1yDQJ1rIB9AHHLWeGtNQXobZC6xk2@public.gmane.org>
2017-01-18 16:41                       ` Damien Lespiau
2017-01-18 16:57                         ` [Nouveau] " Ilia Mirkin
2017-01-18 18:48                           ` Ilia Mirkin
     [not found]                             ` <CAKb7UviODH0YPH-EMUmO9Ssu5BrBb3GVa82SGawbQbiO5NKXAw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-18 19:01                               ` Damien Lespiau
     [not found]                                 ` <20170118190119.GF6460-q+Y1yDQJ1rIB9AHHLWeGtNQXobZC6xk2@public.gmane.org>
2017-01-18 21:35                                   ` Alastair Bridgewater
2017-01-17 22:42   ` [PATCH 6/6] drm/nouveau: Enable stereoscopic 3D output over HDMI Alastair Bridgewater
2017-03-27 21:57   ` [PATCH v2 00/10] Enable HDMI Stereoscopy Alastair Bridgewater
     [not found]     ` <20170327215807.8461-1-alastair.bridgewater-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-27 21:57       ` [PATCH v2 01/10] drm/nouveau: Use drm_mode_set_crtcinfo() to compensate for vscan / ilace Alastair Bridgewater
2017-03-27 21:57       ` [PATCH v2 02/10] drm/nouveau: Extend NVKM HDMI power control method to set InfoFrames Alastair Bridgewater
2017-03-27 21:58       ` [PATCH v2 03/10] drm/nouveau: Pass mode-dependent AVI and Vendor HDMI InfoFrames to NVKM Alastair Bridgewater
2017-03-27 21:58       ` [PATCH v2 04/10] drm/nouveau: Add mechanism to convert HDMI InfoFrames to hardware format Alastair Bridgewater
2017-03-27 21:58       ` [PATCH v2 05/10] drm/nouveau: Use supplied HDMI InfoFrames on G84 hardware Alastair Bridgewater
2017-03-27 21:58       ` [PATCH v2 06/10] drm/nouveau: Use supplied HDMI InfoFrames on GT215 hardware Alastair Bridgewater
2017-03-27 21:58       ` [PATCH v2 07/10] drm/nouveau: Use supplied HDMI InfoFrames on GF119 hardware Alastair Bridgewater
2017-03-27 21:58       ` [PATCH v2 08/10] drm/nouveau: Use supplied HDMI InfoFrames on GK104 hardware Alastair Bridgewater
2017-03-27 21:58       ` [PATCH v2 09/10] drm/nouveau: Handle frame-packing mode geometry and timing effects Alastair Bridgewater
     [not found]         ` <20170327215807.8461-10-alastair.bridgewater-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-28  1:54           ` kbuild test robot
2017-03-27 21:58       ` [PATCH v2 10/10] drm/nouveau: Enable stereoscopic 3D output over HDMI Alastair Bridgewater
2017-03-29 12:02       ` [PATCH v2 00/10] Enable HDMI Stereoscopy Ville Syrjälä
     [not found]         ` <20170329120247.GX30290-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-03-29 14:24           ` Alastair Bridgewater
     [not found]             ` <CAEcYz2Qb74b27efw=s+ZSSO4SEQQ2_mVKXz4D3za1GkVh_AHgg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-29 14:42               ` Ville Syrjälä
2017-03-29 14:48               ` Ilia Mirkin
2017-04-11 17:11   ` [PATCH v3 00/10] drm/nouveau " Alastair Bridgewater
     [not found]     ` <20170411171125.10496-1-alastair.bridgewater-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-04-11 17:11       ` Alastair Bridgewater [this message]
2017-04-11 17:11       ` [PATCH v3 02/10] drm/nouveau: Extend NVKM HDMI power control method to set InfoFrames Alastair Bridgewater
2017-04-11 17:11       ` [PATCH v3 03/10] drm/nouveau: Pass mode-dependent AVI and Vendor HDMI InfoFrames to NVKM Alastair Bridgewater
2017-04-11 17:11       ` [PATCH v3 04/10] drm/nouveau: Add mechanism to convert HDMI InfoFrames to hardware format Alastair Bridgewater
2017-04-11 17:11       ` [PATCH v3 05/10] drm/nouveau: Use supplied HDMI InfoFrames on G84 hardware Alastair Bridgewater
2017-04-11 17:11       ` [PATCH v3 06/10] drm/nouveau: Use supplied HDMI InfoFrames on GT215 hardware Alastair Bridgewater
2017-04-11 17:11       ` [PATCH v3 07/10] drm/nouveau: Use supplied HDMI InfoFrames on GF119 hardware Alastair Bridgewater
2017-04-11 17:11       ` [PATCH v3 08/10] drm/nouveau: Use supplied HDMI InfoFrames on GK104 hardware Alastair Bridgewater
2017-04-11 17:11       ` [PATCH v3 09/10] drm/nouveau: Handle frame-packing mode geometry and timing effects Alastair Bridgewater
2017-04-11 17:11       ` [PATCH v3 10/10] drm/nouveau: Enable stereoscopic 3D output over HDMI Alastair Bridgewater
2017-04-11 17:32         ` [Nouveau] " Ilia Mirkin
     [not found]           ` <CAKb7UvjimkWMZdi1-NwWDf6BK99d1epo+i1dwrONQYrcf+n57A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-12 15:22             ` Alastair Bridgewater
2017-04-13  8:34               ` [Nouveau] " Ben Skeggs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170411171125.10496-2-alastair.bridgewater@gmail.com \
    --to=alastair.bridgewater-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.