0518-drm-vc4-Enable-precise-vblank-timestamping-for-inter.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From f2494f314f8c71e41ddd6798315685ecb6fc7814 Mon Sep 17 00:00:00 2001
  2. From: Mario Kleiner <mario.kleiner.de@gmail.com>
  3. Date: Tue, 19 Jul 2016 20:59:00 +0200
  4. Subject: [PATCH] drm/vc4: Enable precise vblank timestamping for interlaced
  5. modes.
  6. On top of the interlaced video mode fix and with some additional
  7. adjustments, this now works well. It has almost the same accuracy
  8. as on regular progressive scan modes.
  9. Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
  10. Signed-off-by: Eric Anholt <eric@anholt.net>
  11. ---
  12. drivers/gpu/drm/vc4/vc4_crtc.c | 21 ++++++++-------------
  13. 1 file changed, 8 insertions(+), 13 deletions(-)
  14. --- a/drivers/gpu/drm/vc4/vc4_crtc.c
  15. +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
  16. @@ -154,14 +154,6 @@ int vc4_crtc_get_scanoutpos(struct drm_d
  17. if (vc4->firmware_kms)
  18. return 0;
  19. - /*
  20. - * XXX Doesn't work well in interlaced mode yet, partially due
  21. - * to problems in vc4 kms or drm core interlaced mode handling,
  22. - * so disable for now in interlaced mode.
  23. - */
  24. - if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  25. - return ret;
  26. -
  27. /* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
  28. /* Get optional system timestamp before query. */
  29. @@ -182,10 +174,15 @@ int vc4_crtc_get_scanoutpos(struct drm_d
  30. /* Vertical position of hvs composed scanline. */
  31. *vpos = VC4_GET_FIELD(val, SCALER_DISPSTATX_LINE);
  32. + *hpos = 0;
  33. +
  34. + if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
  35. + *vpos /= 2;
  36. - /* No hpos info available. */
  37. - if (hpos)
  38. - *hpos = 0;
  39. + /* Use hpos to correct for field offset in interlaced mode. */
  40. + if (VC4_GET_FIELD(val, SCALER_DISPSTATX_FRAME_COUNT) % 2)
  41. + *hpos += mode->crtc_htotal / 2;
  42. + }
  43. /* This is the offset we need for translating hvs -> pv scanout pos. */
  44. fifo_lines = vc4_crtc->cob_size / mode->crtc_hdisplay;
  45. @@ -208,8 +205,6 @@ int vc4_crtc_get_scanoutpos(struct drm_d
  46. * position of the PV.
  47. */
  48. *vpos -= fifo_lines + 1;
  49. - if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  50. - *vpos /= 2;
  51. ret |= DRM_SCANOUTPOS_ACCURATE;
  52. return ret;