<div dir="ltr"><p style="margin:0in 0in 0pt"><font size="3"><font color="#000000"><font face="Calibri"></font></font></font> </p><p style="margin:0in 0in 0pt"><font size="3"><font color="#000000"><font face="Calibri">Reviewed the patch & it looks fine. </font></font></font></p>


<font size="3"><font color="#000000"><font face="Calibri"><div style="margin:0in 0in 0pt"> </div><div style="margin:0in 0in 0pt">Reviewed-by: "Akash Goel <<a href="mailto:akash.goels@gmail.com" target="_blank">akash.goels@gmail.com</a>>"<font face="Arial"><br>


</font></div></font></font></font><div class="gmail_extra"><div class="gmail_quote">On Tue, Apr 29, 2014 at 4:05 PM,  <span dir="ltr"><<a href="mailto:ville.syrjala@linux.intel.com" target="_blank">ville.syrjala@linux.intel.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">From: Ville Syrjälä <<a href="mailto:ville.syrjala@linux.intel.com" target="_blank">ville.syrjala@linux.intel.com</a>><br>



<br>
Currently the logic to fix up the frame counter on gen3/4 assumes that<br>
start of vblank occurs at vblank_start*htotal pixels, when in fact<br>
it occurs htotal-hsync_start pixels earlier. Apply the appropriate<br>
adjustment to make the frame counter more accurate.<br>
<br>
Also fix the vblank start position for interlaced display modes.<br>
<br>
Reviewed-by: Imre Deak <<a href="mailto:imre.deak@intel.com" target="_blank">imre.deak@intel.com</a>><br>
Signed-off-by: Ville Syrjälä <<a href="mailto:ville.syrjala@linux.intel.com" target="_blank">ville.syrjala@linux.intel.com</a>><br>
---<br>
 drivers/gpu/drm/i915/i915_irq.c | 21 ++++++++++++++++-----<br>
 1 file changed, 16 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c<br>
index 64cd888..742f276 100644<br>
--- a/drivers/gpu/drm/i915/i915_irq.c<br>
+++ b/drivers/gpu/drm/i915/i915_irq.c<br>
@@ -683,7 +683,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)<br>
        struct drm_i915_private *dev_priv = dev->dev_private;<br>
        unsigned long high_frame;<br>
        unsigned long low_frame;<br>
-       u32 high1, high2, low, pixel, vbl_start;<br>
+       u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal;<br>
<br>
        if (!i915_pipe_enabled(dev, pipe)) {<br>
                DRM_DEBUG_DRIVER("trying to get vblank count for disabled "<br>
@@ -697,17 +697,28 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)<br>
                const struct drm_display_mode *mode =<br>
                        &intel_crtc->config.adjusted_mode;<br>
<br>
-               vbl_start = mode->crtc_vblank_start * mode->crtc_htotal;<br>
+               htotal = mode->crtc_htotal;<br>
+               hsync_start = mode->crtc_hsync_start;<br>
+               vbl_start = mode->crtc_vblank_start;<br>
+               if (mode->flags & DRM_MODE_FLAG_INTERLACE)<br>
+                       vbl_start = DIV_ROUND_UP(vbl_start, 2);<br>
        } else {<br>
                enum transcoder cpu_transcoder = (enum transcoder) pipe;<br>
-               u32 htotal;<br>
<br>
                htotal = ((I915_READ(HTOTAL(cpu_transcoder)) >> 16) & 0x1fff) + 1;<br>
+               hsync_start = (I915_READ(HSYNC(cpu_transcoder))  & 0x1fff) + 1;<br>
                vbl_start = (I915_READ(VBLANK(cpu_transcoder)) & 0x1fff) + 1;<br>
-<br>
-               vbl_start *= htotal;<br>
+               if ((I915_READ(PIPECONF(cpu_transcoder)) &<br>
+                    PIPECONF_INTERLACE_MASK) != PIPECONF_PROGRESSIVE)<br>
+                       vbl_start = DIV_ROUND_UP(vbl_start, 2);<br>
        }<br>
<br>
+       /* Convert to pixel count */<br>
+       vbl_start *= htotal;<br>
+<br>
+       /* Start of vblank event occurs at start of hsync */<br>
+       vbl_start -= htotal - hsync_start;<br>
+<br>
        high_frame = PIPEFRAME(pipe);<br>
        low_frame = PIPEFRAMEPIXEL(pipe);<br>
<span><font color="#888888"><br>
--<br>
1.8.3.2<br>
<br>
_______________________________________________<br>
Intel-gfx mailing list<br>
<a href="mailto:Intel-gfx@lists.freedesktop.org" target="_blank">Intel-gfx@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/intel-gfx" target="_blank">http://lists.freedesktop.org/mailman/listinfo/intel-gfx</a><br>
</font></span></blockquote></div><br></div></div>