764edb66ff6051804349d68799a66e1214a3ad59
[openwrt/staging/981213.git] /
1 From 5ef3d566615961b75f85868b028193bb54727140 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Tue, 18 Apr 2017 21:43:46 +0100
4 Subject: [PATCH] vc4_fkms: Apply firmware overscan offset to hardware
5 cursor
6
7 ---
8 drivers/gpu/drm/vc4/vc4_firmware_kms.c | 17 +++++++++++++++++
9 1 file changed, 17 insertions(+)
10
11 --- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
12 +++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
13 @@ -42,6 +42,7 @@ struct vc4_crtc {
14 void __iomem *regs;
15
16 struct drm_pending_vblank_event *event;
17 + u32 overscan[4];
18 };
19
20 static inline struct vc4_crtc *to_vc4_crtc(struct drm_crtc *crtc)
21 @@ -191,6 +192,7 @@ static void vc4_cursor_plane_atomic_upda
22 struct drm_plane_state *old_state)
23 {
24 struct vc4_dev *vc4 = to_vc4_dev(plane->dev);
25 + struct vc4_crtc *vc4_crtc = to_vc4_crtc(plane->crtc);
26 struct drm_plane_state *state = plane->state;
27 struct drm_framebuffer *fb = state->fb;
28 struct drm_gem_cma_object *bo = drm_fb_cma_get_gem_obj(fb, 0);
29 @@ -216,6 +218,12 @@ static void vc4_cursor_plane_atomic_upda
30 bo->paddr + fb->offsets[0],
31 fb->pitches[0]);
32
33 + /* add on the top/left offsets when overscan is active */
34 + if (vc4_crtc) {
35 + packet_state[1] += vc4_crtc->overscan[0];
36 + packet_state[2] += vc4_crtc->overscan[1];
37 + }
38 +
39 ret = rpi_firmware_property(vc4->firmware,
40 RPI_FIRMWARE_SET_CURSOR_STATE,
41 &packet_state,
42 @@ -695,6 +703,15 @@ static int vc4_fkms_bind(struct device *
43 if (ret)
44 goto err_destroy_connector;
45
46 + ret = rpi_firmware_property(vc4->firmware,
47 + RPI_FIRMWARE_FRAMEBUFFER_GET_OVERSCAN,
48 + &vc4_crtc->overscan,
49 + sizeof(vc4_crtc->overscan));
50 + if (ret) {
51 + DRM_ERROR("Failed to get overscan state: 0x%08x\n", vc4_crtc->overscan[0]);
52 + memset(&vc4_crtc->overscan, 0, sizeof(vc4_crtc->overscan));
53 + }
54 +
55 platform_set_drvdata(pdev, vc4_crtc);
56
57 return 0;