aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.4/950-0936-drm-vc4-Increase-the-number-of-planes-per-crtc-in-FK.patch
blob: b2b1e7f46ddbe5842cb2e2af1b1046b546dcad9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
From 078e6dfcff1fc4ef0ee3b29a5f94403624c2e7ac Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Mon, 20 Jul 2020 16:42:57 +0100
Subject: [PATCH] drm/vc4: Increase the number of planes per crtc in
 FKMS.

The number assigned was arbitrary as one primary, one overlay,
and one cursor.
The number has to be below the DRM limit of 32 planes total,
and the current firmware API limit of 16 planes total.

Increase the number to 8 planes per crtc (1 primary,
6 overlay, and a cursor).

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/gpu/drm/vc4/vc4_firmware_kms.c | 54 ++++++++++----------------
 1 file changed, 21 insertions(+), 33 deletions(-)

--- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
@@ -48,7 +48,7 @@ struct vc4_fkms {
 	bool bcm2711;
 };
 
-#define PLANES_PER_CRTC		3
+#define PLANES_PER_CRTC		8
 
 struct set_plane {
 	u8 display;
@@ -1742,7 +1742,6 @@ static int vc4_fkms_create_screen(struct
 	struct vc4_crtc *vc4_crtc;
 	struct vc4_fkms_encoder *vc4_encoder;
 	struct drm_crtc *crtc;
-	struct drm_plane *primary_plane, *overlay_plane, *cursor_plane;
 	struct drm_plane *destroy_plane, *temp;
 	struct mailbox_blank_display blank = {
 		.tag1 = {RPI_FIRMWARE_FRAMEBUFFER_SET_DISPLAY_NUM, 4, 0, },
@@ -1750,7 +1749,8 @@ static int vc4_fkms_create_screen(struct
 		.tag2 = { RPI_FIRMWARE_FRAMEBUFFER_BLANK, 4, 0, },
 		.blank = 1,
 	};
-	int ret;
+	struct drm_plane *planes[PLANES_PER_CRTC];
+	int ret, i;
 
 	vc4_crtc = devm_kzalloc(dev, sizeof(*vc4_crtc), GFP_KERNEL);
 	if (!vc4_crtc)
@@ -1763,38 +1763,26 @@ static int vc4_fkms_create_screen(struct
 	/* Blank the firmware provided framebuffer */
 	rpi_firmware_property_list(vc4->firmware, &blank, sizeof(blank));
 
-	primary_plane = vc4_fkms_plane_init(drm, DRM_PLANE_TYPE_PRIMARY,
-					    display_ref,
-					    0 + (display_idx * PLANES_PER_CRTC)
-					   );
-	if (IS_ERR(primary_plane)) {
-		dev_err(dev, "failed to construct primary plane\n");
-		ret = PTR_ERR(primary_plane);
-		goto err;
-	}
-
-	overlay_plane = vc4_fkms_plane_init(drm, DRM_PLANE_TYPE_OVERLAY,
-					    display_ref,
-					    1 + (display_idx * PLANES_PER_CRTC)
-					   );
-	if (IS_ERR(overlay_plane)) {
-		dev_err(dev, "failed to construct overlay plane\n");
-		ret = PTR_ERR(overlay_plane);
-		goto err;
-	}
-
-	cursor_plane = vc4_fkms_plane_init(drm, DRM_PLANE_TYPE_CURSOR,
-					   display_ref,
-					   2 + (display_idx * PLANES_PER_CRTC)
-					  );
-	if (IS_ERR(cursor_plane)) {
-		dev_err(dev, "failed to construct cursor plane\n");
-		ret = PTR_ERR(cursor_plane);
-		goto err;
+	for (i = 0; i < PLANES_PER_CRTC; i++) {
+		planes[i] = vc4_fkms_plane_init(drm,
+						(i == 0) ?
+						  DRM_PLANE_TYPE_PRIMARY :
+						  (i == PLANES_PER_CRTC - 1) ?
+							DRM_PLANE_TYPE_CURSOR :
+							DRM_PLANE_TYPE_OVERLAY,
+						display_ref,
+						i + (display_idx * PLANES_PER_CRTC)
+					       );
+		if (IS_ERR(planes[i])) {
+			dev_err(dev, "failed to construct plane %u\n", i);
+			ret = PTR_ERR(planes[i]);
+			goto err;
+		}
 	}
 
-	drm_crtc_init_with_planes(drm, crtc, primary_plane, cursor_plane,
-				  &vc4_crtc_funcs, NULL);
+	drm_crtc_init_with_planes(drm, crtc, planes[0],
+				  planes[PLANES_PER_CRTC - 1], &vc4_crtc_funcs,
+				  NULL);
 	drm_crtc_helper_add(crtc, &vc4_crtc_helper_funcs);
 
 	vc4_encoder = devm_kzalloc(dev, sizeof(*vc4_encoder), GFP_KERNEL);