b2b1e7f46ddbe5842cb2e2af1b1046b546dcad9a
[openwrt/openwrt.git] /
1 From 078e6dfcff1fc4ef0ee3b29a5f94403624c2e7ac Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Mon, 20 Jul 2020 16:42:57 +0100
4 Subject: [PATCH] drm/vc4: Increase the number of planes per crtc in
5 FKMS.
6
7 The number assigned was arbitrary as one primary, one overlay,
8 and one cursor.
9 The number has to be below the DRM limit of 32 planes total,
10 and the current firmware API limit of 16 planes total.
11
12 Increase the number to 8 planes per crtc (1 primary,
13 6 overlay, and a cursor).
14
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
16 ---
17 drivers/gpu/drm/vc4/vc4_firmware_kms.c | 54 ++++++++++----------------
18 1 file changed, 21 insertions(+), 33 deletions(-)
19
20 --- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
21 +++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
22 @@ -48,7 +48,7 @@ struct vc4_fkms {
23 bool bcm2711;
24 };
25
26 -#define PLANES_PER_CRTC 3
27 +#define PLANES_PER_CRTC 8
28
29 struct set_plane {
30 u8 display;
31 @@ -1742,7 +1742,6 @@ static int vc4_fkms_create_screen(struct
32 struct vc4_crtc *vc4_crtc;
33 struct vc4_fkms_encoder *vc4_encoder;
34 struct drm_crtc *crtc;
35 - struct drm_plane *primary_plane, *overlay_plane, *cursor_plane;
36 struct drm_plane *destroy_plane, *temp;
37 struct mailbox_blank_display blank = {
38 .tag1 = {RPI_FIRMWARE_FRAMEBUFFER_SET_DISPLAY_NUM, 4, 0, },
39 @@ -1750,7 +1749,8 @@ static int vc4_fkms_create_screen(struct
40 .tag2 = { RPI_FIRMWARE_FRAMEBUFFER_BLANK, 4, 0, },
41 .blank = 1,
42 };
43 - int ret;
44 + struct drm_plane *planes[PLANES_PER_CRTC];
45 + int ret, i;
46
47 vc4_crtc = devm_kzalloc(dev, sizeof(*vc4_crtc), GFP_KERNEL);
48 if (!vc4_crtc)
49 @@ -1763,38 +1763,26 @@ static int vc4_fkms_create_screen(struct
50 /* Blank the firmware provided framebuffer */
51 rpi_firmware_property_list(vc4->firmware, &blank, sizeof(blank));
52
53 - primary_plane = vc4_fkms_plane_init(drm, DRM_PLANE_TYPE_PRIMARY,
54 - display_ref,
55 - 0 + (display_idx * PLANES_PER_CRTC)
56 - );
57 - if (IS_ERR(primary_plane)) {
58 - dev_err(dev, "failed to construct primary plane\n");
59 - ret = PTR_ERR(primary_plane);
60 - goto err;
61 - }
62 -
63 - overlay_plane = vc4_fkms_plane_init(drm, DRM_PLANE_TYPE_OVERLAY,
64 - display_ref,
65 - 1 + (display_idx * PLANES_PER_CRTC)
66 - );
67 - if (IS_ERR(overlay_plane)) {
68 - dev_err(dev, "failed to construct overlay plane\n");
69 - ret = PTR_ERR(overlay_plane);
70 - goto err;
71 - }
72 -
73 - cursor_plane = vc4_fkms_plane_init(drm, DRM_PLANE_TYPE_CURSOR,
74 - display_ref,
75 - 2 + (display_idx * PLANES_PER_CRTC)
76 - );
77 - if (IS_ERR(cursor_plane)) {
78 - dev_err(dev, "failed to construct cursor plane\n");
79 - ret = PTR_ERR(cursor_plane);
80 - goto err;
81 + for (i = 0; i < PLANES_PER_CRTC; i++) {
82 + planes[i] = vc4_fkms_plane_init(drm,
83 + (i == 0) ?
84 + DRM_PLANE_TYPE_PRIMARY :
85 + (i == PLANES_PER_CRTC - 1) ?
86 + DRM_PLANE_TYPE_CURSOR :
87 + DRM_PLANE_TYPE_OVERLAY,
88 + display_ref,
89 + i + (display_idx * PLANES_PER_CRTC)
90 + );
91 + if (IS_ERR(planes[i])) {
92 + dev_err(dev, "failed to construct plane %u\n", i);
93 + ret = PTR_ERR(planes[i]);
94 + goto err;
95 + }
96 }
97
98 - drm_crtc_init_with_planes(drm, crtc, primary_plane, cursor_plane,
99 - &vc4_crtc_funcs, NULL);
100 + drm_crtc_init_with_planes(drm, crtc, planes[0],
101 + planes[PLANES_PER_CRTC - 1], &vc4_crtc_funcs,
102 + NULL);
103 drm_crtc_helper_add(crtc, &vc4_crtc_helper_funcs);
104
105 vc4_encoder = devm_kzalloc(dev, sizeof(*vc4_encoder), GFP_KERNEL);