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