From: Mario Kleiner <mario.kleiner.de@gmail.com>
To: ville.syrjala@linux.intel.com, intel-gfx@lists.freedesktop.org,
Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Subject: Re: [PATCH 2/3] drm/i915: Fix scanoutpos calculations
Date: Fri, 11 Oct 2013 16:31:38 +0200 [thread overview]
Message-ID: <52580BCA.6080409@gmail.com> (raw)
In-Reply-To: <1379930527-19714-3-git-send-email-ville.syrjala@linux.intel.com>
Daniel, Ville,
i tested Ville's patch series for the scanoutpos improvements on a
GMA-950, on top of airlied's current drm-next branch.
There's one issue: The variable "position" in i915_get_crtc_scanoutpos()
must be turned from a u32 into a int, otherwise funny sign errors happen
and we end up with *vpos being off by multiple million scanlines and
timestamps being off by over 60 seconds.
Other than that looks good. Execution time is now better:
Before uncore.lock addition: 3-4 usecs execution time for the scanoutpos
query on my machine. After uncore.lock addition (3.12.0-rc3) 9-20 usecs,
sometimes repetition of the timing loop triggered. After Ville's patches
down to typically 3-8 usecs, occassionally spiking to almost 20 usecs.
I'll make my patches for the realtime kernel + increased accuracy on top
of drm-next + Ville's patches.
thanks,
-mario
On 09/23/2013 12:02 PM, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> The reported scanout position must be relative to the end of vblank.
> Currently we manage to fumble that in a few ways.
>
> First we don't consider the case when vtotal != vbl_end. While that
> isn't very common (happens maybe only w/ old panel fitting hardware),
> we can fix it easily enough.
>
> The second issue is that on pre-CTG hardware we convert the pixel count
> to horizontal/vertical components at the very beginning, and then forget
> to adjust the horizontal component to be relative to vbl_end. So instead
> we should keep our numbers in the pixel count domain while we're
> adjusting the position to be relative to vbl_end. Then when we do the
> conversion in the end, both vertical _and_ horizontal components will
> come out correct.
>
> Cc: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_irq.c | 37 ++++++++++++++++++++++++-------------
> 1 file changed, 24 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 697d62c..4f74f0c 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -615,13 +615,7 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
> /* No obvious pixelcount register. Only query vertical
> * scanout position from Display scan line register.
> */
> - position = I915_READ(PIPEDSL(pipe));
> -
> - /* Decode into vertical scanout position. Don't have
> - * horizontal scanout position.
> - */
> - *vpos = position & 0x1fff;
> - *hpos = 0;
> + position = I915_READ(PIPEDSL(pipe)) & 0x1fff;
> } else {
> /* Have access to pixelcount since start of frame.
> * We can split this into vertical and horizontal
> @@ -629,15 +623,32 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
> */
> position = (I915_READ(PIPEFRAMEPIXEL(pipe)) & PIPE_PIXEL_MASK) >> PIPE_PIXEL_SHIFT;
>
> - *vpos = position / htotal;
> - *hpos = position - (*vpos * htotal);
> + /* convert to pixel counts */
> + vbl_start *= htotal;
> + vbl_end *= htotal;
> + vtotal *= htotal;
> }
>
> - in_vbl = *vpos >= vbl_start && *vpos < vbl_end;
> + in_vbl = position >= vbl_start && position < vbl_end;
>
> - /* Inside "upper part" of vblank area? Apply corrective offset: */
> - if (in_vbl && (*vpos >= vbl_start))
> - *vpos = *vpos - vtotal;
> + /*
> + * While in vblank, position will be negative
> + * counting up towards 0 at vbl_end. And outside
> + * vblank, position will be positive counting
> + * up since vbl_end.
> + */
> + if (position >= vbl_start)
> + position -= vbl_end;
> + else
> + position += vtotal - vbl_end;
> +
> + if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) {
> + *vpos = position;
> + *hpos = 0;
> + } else {
> + *vpos = position / htotal;
> + *hpos = position - (*vpos * htotal);
> + }
>
> /* In vblank? */
> if (in_vbl)
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2013-10-11 14:31 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-23 10:02 [PATCH 0/3] drm/i915: i915_get_crtc_scanoutpos improvements ville.syrjala
2013-09-23 10:02 ` [PATCH 1/3] drm/i915: Skip register reads in i915_get_crtc_scanoutpos() ville.syrjala
2013-09-23 10:30 ` Chris Wilson
2013-09-23 11:48 ` [PATCH v2 " ville.syrjala
2013-09-24 9:11 ` Daniel Vetter
2013-09-25 4:45 ` Mario Kleiner
2013-09-25 7:52 ` Daniel Vetter
2013-09-25 2:35 ` Mario Kleiner
2013-09-25 8:14 ` Ville Syrjälä
2013-09-26 16:12 ` Mario Kleiner
2013-09-23 10:02 ` [PATCH 2/3] drm/i915: Fix scanoutpos calculations ville.syrjala
2013-09-25 2:39 ` Mario Kleiner
2013-10-11 14:31 ` Mario Kleiner [this message]
2013-10-11 16:10 ` [PATCH v2 " ville.syrjala
2013-10-11 23:19 ` [PATCH " Daniel Vetter
2013-10-11 23:22 ` Mario Kleiner
2013-10-14 15:13 ` Daniel Vetter
2013-09-23 10:02 ` [PATCH 3/3] drm/i915: Improve the accuracy of get_scanout_pos on CTG+ ville.syrjala
2013-09-25 3:12 ` Mario Kleiner
2013-09-25 8:11 ` Ville Syrjälä
2013-09-25 8:46 ` Daniel Vetter
2013-09-26 17:04 ` Mario Kleiner
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=52580BCA.6080409@gmail.com \
--to=mario.kleiner.de@gmail.com \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mario.kleiner@tuebingen.mpg.de \
--cc=ville.syrjala@linux.intel.com \
/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.