<font face="Times New Roman" size="3">
</font><div class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt">Hi,</span></div><div class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt"></span> </div>
<div class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt">We have reviewed the patch & overall it seems to be fine.</span></div><div class="MsoNormal" style="margin:0in 0in 0pt">
<span style="font-family:"Calibri","sans-serif";font-size:11pt">Although this patch has really simplified the scan-out calculation, but we do have few doubts/opens. </span></div><font face="Times New Roman" size="3">
</font><p class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt">There is a particular change :-</span></p><font face="Times New Roman" size="3">
</font><p class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt"> </span></p><font face="Times New Roman" size="3">
</font><p class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt">
<i>position = (position + htotal - hsync_start) % vtotal;</i></span></p><font face="Times New Roman" size="3">
</font><p class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt"> </span></p><font face="Times New Roman" size="3">
</font><div class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt">This adjustment could although lead
to more accurate estimation of 'Vblank' interval, but will compromise with the
accuracy of 'hpos'. <br>Should we be avoiding the latter & preserve the
original value of ‘hpos’ returned by pixel counter ?</span></div><div class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt"></span> </div><font face="Times New Roman" size="3">
</font><div class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt">Also we couldn’t fully understand
the comments related to Scanline counter increment in the commit message &
under the ‘</span><span style="font-family:"Courier New";font-size:10pt">if (HAS_PCH_SPLIT(dev))‘ </span><span style="font-family:"Calibri","sans-serif";font-size:11pt">condition in the code.<br>
</span></div><font face="Times New Roman" size="3">
</font><div class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt">What we understood is that the scanline counter will increment on a Hsync pulse & when the first active line is being scanned, the counter will return '0' . When the 2nd second active line is being scanned, counter will return '1'. Assuming if there are 10 active lines, so when the last active line is being scanned, the scan line counter will return 9, but on the Hsync pulse of the last active line (which will mark the start of vblank interval also), <br>
counter will increment to 10. And the counter should wraparound to 0, when last line ('vtotal') has been scanned completely. </span></div><div class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt"></span> </div>
<div class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt">Please could you let us know that if there are 10 active lines, the value of '<font face="Arial">vbl_start' </font> will be 10 or 11 ? Actually we are bit confused that whether zero based indexing is being used here or not. Ideally the 'hpos' & 'vpos' shall be calculated with zero based indexing. </span></div>
<div class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt"></span> </div><font face="Times New Roman" size="3">
<span style="color:black;font-family:"Calibri","sans-serif";font-size:11pt"><font face="Times New Roman" size="3">
</font><p class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:"Calibri","sans-serif";font-size:11pt">Sorry but as of now, we mainly have
understanding & visibility from GEN7 Hw onwards, so we could review the
patches from >= GEN7 perspective only. </span></p></span><div> </div><div>Best Regards</div><div>Akash</div></font><div> </div><div> </div><div class="gmail_quote">On Thu, Feb 13, 2014 at 9:12 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">ville.syrjala@linux.intel.com</a>><br>
<br>
Seems I've been a bit dense with regards to the start of vblank<br>
vs. the scanline counter / pixel counter.<br>
<br>
After staring at the pixel counter on gen4 I came to the conclusion<br>
that the start of vblank interrupt and scanline counter increment<br>
happen at the same time. The scanline counter increment is documented<br>
to occur at start of hsync, which means that the start of vblank<br>
interrupt must also trigger there. Looking at the pixel counter value<br>
when the scanline wraps from vtotal-1 to 0 confirms that, as the pixel<br>
counter at that point reads hsync_start. This also clarifies why we see<br>
need the +1 adjustment to the scaline counter. The counter actually<br>
starts counting from vtotal-1 on the first active line.<br>
<br>
I also confirmed that the frame start interrupt happens ~1 line after<br>
the start of vblank, but the frame start occurs at hblank_start instead.<br>
We only use the frame start interrupt on gen2 where the start of vblank<br>
interrupt isn't available. The only important thing to note here is that<br>
frame start occurs after vblank start, so we don't have to play any<br>
additional tricks to fix up the scanline counter.<br>
<br>
The other thing to note is the fact that the pixel counter on gen3-4<br>
starts counting from the start of horizontal active on the first active<br>
line. That means that when we get the start of vblank interrupt, the<br>
pixel counter reads (htotal*(vblank_start-1)+hsync_start). Since we<br>
consider vblank to start at (htotal*vblank_start) we need to add a<br>
constant (htotal-hsync_start) offset to the pixel counter, or else we<br>
risk misdetecting whether we're in vblank or not.<br>
<br>
I talked a bit with Art Runyan about these topics, and he confirmed my<br>
findings. And that the same rules should hold for platforms which don't<br>
have the pixel counter. That's good since without the pixel counter it's<br>
rather difficult to verify the timings to this accuracy.<br>
<br>
So the conclusion is that we can throw away all the ISR tricks I added,<br>
and just increment the scanline counter by one always.<br>
<br>
Signed-off-by: Ville Syrjälä <<a href="mailto:ville.syrjala@linux.intel.com">ville.syrjala@linux.intel.com</a>><br>
---<br>
drivers/gpu/drm/i915/i915_irq.c | 89 +++++++++++------------------------------<br>
1 file changed, 23 insertions(+), 66 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c<br>
index f68aee3..d547994 100644<br>
--- a/drivers/gpu/drm/i915/i915_irq.c<br>
+++ b/drivers/gpu/drm/i915/i915_irq.c<br>
@@ -706,34 +706,6 @@ static u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)<br>
<br>
/* raw reads, only for fast reads of display block, no need for forcewake etc. */<br>
#define __raw_i915_read32(dev_priv__, reg__) readl((dev_priv__)->regs + (reg__))<br>
-#define __raw_i915_read16(dev_priv__, reg__) readw((dev_priv__)->regs + (reg__))<br>
-<br>
-static bool ilk_pipe_in_vblank_locked(struct drm_device *dev, enum pipe pipe)<br>
-{<br>
- struct drm_i915_private *dev_priv = dev->dev_private;<br>
- uint32_t status;<br>
-<br>
- if (INTEL_INFO(dev)->gen < 7) {<br>
- status = pipe == PIPE_A ?<br>
- DE_PIPEA_VBLANK :<br>
- DE_PIPEB_VBLANK;<br>
- } else {<br>
- switch (pipe) {<br>
- default:<br>
- case PIPE_A:<br>
- status = DE_PIPEA_VBLANK_IVB;<br>
- break;<br>
- case PIPE_B:<br>
- status = DE_PIPEB_VBLANK_IVB;<br>
- break;<br>
- case PIPE_C:<br>
- status = DE_PIPEC_VBLANK_IVB;<br>
- break;<br>
- }<br>
- }<br>
-<br>
- return __raw_i915_read32(dev_priv, DEISR) & status;<br>
-}<br>
<br>
static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,<br>
unsigned int flags, int *vpos, int *hpos,<br>
@@ -744,7 +716,7 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,<br>
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);<br>
const struct drm_display_mode *mode = &intel_crtc->config.adjusted_mode;<br>
int position;<br>
- int vbl_start, vbl_end, htotal, vtotal;<br>
+ int vbl_start, vbl_end, hsync_start, htotal, vtotal;<br>
bool in_vbl = true;<br>
int ret = 0;<br>
unsigned long irqflags;<br>
@@ -756,6 +728,7 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,<br>
}<br>
<br>
htotal = mode->crtc_htotal;<br>
+ hsync_start = mode->crtc_hsync_start;<br>
vtotal = mode->crtc_vtotal;<br>
vbl_start = mode->crtc_vblank_start;<br>
vbl_end = mode->crtc_vblank_end;<br>
@@ -774,7 +747,7 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,<br>
* following code must not block on uncore.lock.<br>
*/<br>
spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);<br>
-<br>
+<br>
/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */<br>
<br>
/* Get optional system timestamp before query. */<br>
@@ -790,42 +763,15 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,<br>
else<br>
position = __raw_i915_read32(dev_priv, PIPEDSL(pipe)) & DSL_LINEMASK_GEN3;<br>
<br>
- if (HAS_PCH_SPLIT(dev)) {<br>
- /*<br>
- * The scanline counter increments at the leading edge<br>
- * of hsync, ie. it completely misses the active portion<br>
- * of the line. Fix up the counter at both edges of vblank<br>
- * to get a more accurate picture whether we're in vblank<br>
- * or not.<br>
- */<br>
- in_vbl = ilk_pipe_in_vblank_locked(dev, pipe);<br>
- if ((in_vbl && position == vbl_start - 1) ||<br>
- (!in_vbl && position == vbl_end - 1))<br>
- position = (position + 1) % vtotal;<br>
- } else {<br>
- /*<br>
- * ISR vblank status bits don't work the way we'd want<br>
- * them to work on non-PCH platforms (for<br>
- * ilk_pipe_in_vblank_locked()), and there doesn't<br>
- * appear any other way to determine if we're currently<br>
- * in vblank.<br>
- *<br>
- * Instead let's assume that we're already in vblank if<br>
- * we got called from the vblank interrupt and the<br>
- * scanline counter value indicates that we're on the<br>
- * line just prior to vblank start. This should result<br>
- * in the correct answer, unless the vblank interrupt<br>
- * delivery really got delayed for almost exactly one<br>
- * full frame/field.<br>
- */<br>
- if (flags & DRM_CALLED_FROM_VBLIRQ &&<br>
- position == vbl_start - 1) {<br>
- position = (position + 1) % vtotal;<br>
-<br>
- /* Signal this correction as "applied". */<br>
- ret |= 0x8;<br>
- }<br>
- }<br>
+ /*<br>
+ * Scanline counter increments at leading edge of hsync, and<br>
+ * it starts counting from vtotal-1 on the first active line.<br>
+ * That means the scanline counter value is always one less<br>
+ * than what we would expect. Ie. just after start of vblank,<br>
+ * which also occurs at start of hsync (on the last active line),<br>
+ * the scanline counter will read vblank_start-1.<br>
+ */<br>
+ position = (position + 1) % vtotal;<br>
} else {<br>
/* Have access to pixelcount since start of frame.<br>
* We can split this into vertical and horizontal<br>
@@ -837,6 +783,17 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,<br>
vbl_start *= htotal;<br>
vbl_end *= htotal;<br>
vtotal *= htotal;<br>
+<br>
+ /*<br>
+ * Start of vblank interrupt is triggered at start of hsync,<br>
+ * just prior to the first active line of vblank. However we<br>
+ * consider lines to start at the leading edge of horizontal<br>
+ * active. So, should we get here before we've crossed into<br>
+ * the horizontal active of the first line in vblank, we would<br>
+ * not set the DRM_SCANOUTPOS_INVBL flag. In order to fix that,<br>
+ * always add htotal-hsync_start to the current pixel position.<br>
+ */<br>
+ position = (position + htotal - hsync_start) % vtotal;<br>
}<br>
<br>
/* Get optional system timestamp after query. */<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.2<br>
<br>
_______________________________________________<br>
Intel-gfx mailing list<br>
<a href="mailto:Intel-gfx@lists.freedesktop.org">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>