66f6dc835293b1fd8e4fbb3bc473bfc3f427d0bf
[openwrt/staging/jow.git] /
1 From e7ecdf293b07f35f23684badcab6afa58928257a 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 114/454] 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 @@ -39,6 +39,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 @@ -180,6 +181,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 @@ -200,6 +202,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 @@ -641,6 +649,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;