public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Imre Deak <imre.deak@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 7/5] drm/i915: Improve gen3/4 frame counter
Date: Tue, 18 Feb 2014 16:41:02 +0200	[thread overview]
Message-ID: <20140218144102.GT3852@intel.com> (raw)
In-Reply-To: <1392732960.13243.5.camel@intelbox>

On Tue, Feb 18, 2014 at 04:16:00PM +0200, Imre Deak wrote:
> On Tue, 2014-02-18 at 14:04 +0200, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Currently the logic to fix up the frame counter on gen3/4 assumes that
> > start of vblank occurs at vblank_start*htotal pixels, when in fact
> > it occurs htotal-hsync_start pixels earlier. Apply the appropriate
> > adjustment to make the frame counter more accurate.
> > 
> > Also fix the vblank start position for interlaced display modes.
> > 
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_irq.c | 21 ++++++++++++++++-----
> >  1 file changed, 16 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> > index 9f1c449..fc49fb6 100644
> > --- a/drivers/gpu/drm/i915/i915_irq.c
> > +++ b/drivers/gpu/drm/i915/i915_irq.c
> > @@ -639,7 +639,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
> >  	drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
> >  	unsigned long high_frame;
> >  	unsigned long low_frame;
> > -	u32 high1, high2, low, pixel, vbl_start;
> > +	u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal;
> >  
> >  	if (!i915_pipe_enabled(dev, pipe)) {
> >  		DRM_DEBUG_DRIVER("trying to get vblank count for disabled "
> > @@ -653,17 +653,28 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
> >  		const struct drm_display_mode *mode =
> >  			&intel_crtc->config.adjusted_mode;
> >  
> > -		vbl_start = mode->crtc_vblank_start * mode->crtc_htotal;
> > +		htotal = mode->crtc_htotal;
> > +		hsync_start = mode->crtc_hsync_start;
> > +		vbl_start = mode->crtc_vblank_start;
> > +		if (mode->flags & DRM_MODE_FLAG_INTERLACE)
> > +			vbl_start = DIV_ROUND_UP(vbl_start, 2);
> 
> The adjustment for interlace mode is already done in drm_mode_setcrtc,
> so I think we don't need it here.

We throw away the values filled in by drm_mode_setcrtc(). Which is a
good thing since it rounds the result the wrong way (for our hardware
at least). The values we see here are filled in by
intel_modeset_pipe_config() which doesn't pass the
CRTC_INTERLACE_HALVE_V flag to drm_mode_set_crtcinfo().

> Otherwise this patch makes sense to me
> based on the signal chart you drew on this, so:
> 
> Reviewed-by: Imre Deak <imre.deak@intel.com>
> 
> >  	} else {
> >  		enum transcoder cpu_transcoder = (enum transcoder) pipe;
> > -		u32 htotal;
> >  
> >  		htotal = ((I915_READ(HTOTAL(cpu_transcoder)) >> 16) & 0x1fff) + 1;
> > +		hsync_start = (I915_READ(HSYNC(cpu_transcoder))  & 0x1fff) + 1;
> >  		vbl_start = (I915_READ(VBLANK(cpu_transcoder)) & 0x1fff) + 1;
> > -
> > -		vbl_start *= htotal;
> > +		if ((I915_READ(PIPECONF(cpu_transcoder)) &
> > +		     PIPECONF_INTERLACE_MASK) != PIPECONF_PROGRESSIVE)
> > +			vbl_start = DIV_ROUND_UP(vbl_start, 2);
> >  	}
> >  
> > +	/* Convert to pixel count */
> > +	vbl_start *= htotal;
> > +
> > +	/* Start of vblank event occurs at start of hsync */
> > +	vbl_start -= htotal - hsync_start;
> > +
> >  	high_frame = PIPEFRAME(pipe);
> >  	low_frame = PIPEFRAMEPIXEL(pipe);
> >  
> 



-- 
Ville Syrjälä
Intel OTC

  reply	other threads:[~2014-02-18 14:41 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13 15:42 [PATCH v3 0/5] drm/i915: Atomic sprites v3 ville.syrjala
2014-02-13 15:42 ` [PATCH 1/5] drm/i915: Fix scanout position for real ville.syrjala
2014-03-14  6:16   ` akash goel
2014-04-01 10:36     ` Ville Syrjälä
2014-02-13 15:42 ` [PATCH v3 2/5] drm/i915: Add intel_get_crtc_scanline() ville.syrjala
2014-02-14 12:05   ` [PATCH v4 " ville.syrjala
2014-02-13 15:42 ` [PATCH v4 3/5] drm/i915: Make sprite updates atomic ville.syrjala
2014-02-13 16:01   ` Chris Wilson
2014-02-13 16:43     ` Ville Syrjälä
2014-02-13 19:42     ` [PATCH v5 " ville.syrjala
2014-02-14 12:06       ` [PATCH v6 " ville.syrjala
2014-02-14 12:50         ` [PATCH v7 " ville.syrjala
2014-03-07 13:42           ` [PATCH v8 " ville.syrjala
2014-03-07 15:57             ` Jesse Barnes
2014-02-13 15:42 ` [PATCH v2 4/5] drm/i915: Perform primary enable/disable atomically with sprite updates ville.syrjala
2014-02-13 15:42 ` [PATCH v3 5/5] drm/i915: Add pipe update trace points ville.syrjala
2014-02-13 19:43   ` [PATCH v4 " ville.syrjala
2014-02-14 12:07 ` [PATCH 6/5] drm/i915: Add a small adjustment to the pixel counter on interlaced modes ville.syrjala
2014-02-18 12:04 ` [PATCH 7/5] drm/i915: Improve gen3/4 frame counter ville.syrjala
2014-02-18 12:04   ` [PATCH 8/5] drm/i915: Fix gen2 scanline counter ville.syrjala
2014-02-20 11:12     ` [PATCH v2 " ville.syrjala
2014-02-18 12:04   ` [PATCH 9/5] drm/i915: Draw a picture about video timings ville.syrjala
2014-02-20 11:14     ` [PATCH v2 " ville.syrjala
2014-02-20 13:42       ` Imre Deak
2014-02-18 14:16   ` [PATCH 7/5] drm/i915: Improve gen3/4 frame counter Imre Deak
2014-02-18 14:41     ` Ville Syrjälä [this message]
2014-02-18 15:11       ` Imre Deak
2014-04-09 15:03 ` [PATCH v3 0/5] drm/i915: Atomic sprites v3 sourab gupta
2014-04-09 15:08 ` akash goel

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=20140218144102.GT3852@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox