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
7 The number assigned was arbitrary as one primary, one overlay,
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.
12 Increase the number to 8 planes per crtc (1 primary,
13 6 overlay, and a cursor).
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
17 drivers/gpu/drm/vc4/vc4_firmware_kms.c | 54 ++++++++++----------------
18 1 file changed, 21 insertions(+), 33 deletions(-)
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 {
26 -#define PLANES_PER_CRTC 3
27 +#define PLANES_PER_CRTC 8
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, },
44 + struct drm_plane *planes[PLANES_PER_CRTC];
47 vc4_crtc = devm_kzalloc(dev, sizeof(*vc4_crtc), GFP_KERNEL);
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));
53 - primary_plane = vc4_fkms_plane_init(drm, DRM_PLANE_TYPE_PRIMARY,
55 - 0 + (display_idx * PLANES_PER_CRTC)
57 - if (IS_ERR(primary_plane)) {
58 - dev_err(dev, "failed to construct primary plane\n");
59 - ret = PTR_ERR(primary_plane);
63 - overlay_plane = vc4_fkms_plane_init(drm, DRM_PLANE_TYPE_OVERLAY,
65 - 1 + (display_idx * PLANES_PER_CRTC)
67 - if (IS_ERR(overlay_plane)) {
68 - dev_err(dev, "failed to construct overlay plane\n");
69 - ret = PTR_ERR(overlay_plane);
73 - cursor_plane = vc4_fkms_plane_init(drm, DRM_PLANE_TYPE_CURSOR,
75 - 2 + (display_idx * PLANES_PER_CRTC)
77 - if (IS_ERR(cursor_plane)) {
78 - dev_err(dev, "failed to construct cursor plane\n");
79 - ret = PTR_ERR(cursor_plane);
81 + for (i = 0; i < PLANES_PER_CRTC; i++) {
82 + planes[i] = vc4_fkms_plane_init(drm,
84 + DRM_PLANE_TYPE_PRIMARY :
85 + (i == PLANES_PER_CRTC - 1) ?
86 + DRM_PLANE_TYPE_CURSOR :
87 + DRM_PLANE_TYPE_OVERLAY,
89 + i + (display_idx * PLANES_PER_CRTC)
91 + if (IS_ERR(planes[i])) {
92 + dev_err(dev, "failed to construct plane %u\n", i);
93 + ret = PTR_ERR(planes[i]);
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,
103 drm_crtc_helper_add(crtc, &vc4_crtc_helper_funcs);
105 vc4_encoder = devm_kzalloc(dev, sizeof(*vc4_encoder), GFP_KERNEL);