Skip to content

Commit e538092

Browse files
kleinermanholt
authored andcommitted
drm/vc4: Enable precise vblank timestamping for interlaced modes.
On top of the interlaced video mode fix and with some additional adjustments, this now works well. It has almost the same accuracy as on regular progressive scan modes. Signed-off-by: Mario Kleiner <[email protected]> Signed-off-by: Eric Anholt <[email protected]>
1 parent 3645146 commit e538092

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
163163
int vblank_lines;
164164
int ret = 0;
165165

166-
/*
167-
* XXX Doesn't work well in interlaced mode yet, partially due
168-
* to problems in vc4 kms or drm core interlaced mode handling,
169-
* so disable for now in interlaced mode.
170-
*/
171-
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
172-
return ret;
173-
174166
/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
175167

176168
/* Get optional system timestamp before query. */
@@ -191,10 +183,15 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
191183

192184
/* Vertical position of hvs composed scanline. */
193185
*vpos = VC4_GET_FIELD(val, SCALER_DISPSTATX_LINE);
186+
*hpos = 0;
187+
188+
if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
189+
*vpos /= 2;
194190

195-
/* No hpos info available. */
196-
if (hpos)
197-
*hpos = 0;
191+
/* Use hpos to correct for field offset in interlaced mode. */
192+
if (VC4_GET_FIELD(val, SCALER_DISPSTATX_FRAME_COUNT) % 2)
193+
*hpos += mode->crtc_htotal / 2;
194+
}
198195

199196
/* This is the offset we need for translating hvs -> pv scanout pos. */
200197
fifo_lines = vc4_crtc->cob_size / mode->crtc_hdisplay;
@@ -217,8 +214,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
217214
* position of the PV.
218215
*/
219216
*vpos -= fifo_lines + 1;
220-
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
221-
*vpos /= 2;
222217

223218
ret |= DRM_SCANOUTPOS_ACCURATE;
224219
return ret;

0 commit comments

Comments
 (0)