1 From bb2b068209d73b320cac7222a3b8ecef9b0dcc9a Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Thu, 6 Feb 2020 14:46:14 +0100
4 Subject: [PATCH] drm/vc4: plane: Register all the planes at once
6 Instead of creating planes for each CRTC, we eventually want to create all
7 the planes for each CRTCs.
9 In order to make that more convenient, let's iterate on the CRTCs in the
10 plane creation function instead of its caller.
12 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
14 drivers/gpu/drm/vc4/vc4_drv.c | 9 ++----
15 drivers/gpu/drm/vc4/vc4_drv.h | 3 +-
16 drivers/gpu/drm/vc4/vc4_plane.c | 54 +++++++++++++++++----------------
17 3 files changed, 32 insertions(+), 34 deletions(-)
19 --- a/drivers/gpu/drm/vc4/vc4_drv.c
20 +++ b/drivers/gpu/drm/vc4/vc4_drv.c
21 @@ -253,7 +253,6 @@ static int vc4_drm_bind(struct device *d
23 struct platform_device *pdev = to_platform_device(dev);
24 struct drm_device *drm;
25 - struct drm_crtc *crtc;
27 struct device_node *node;
29 @@ -292,11 +291,9 @@ static int vc4_drm_bind(struct device *d
33 - drm_for_each_crtc(crtc, drm) {
34 - ret = vc4_plane_create_additional_planes(drm, crtc);
38 + ret = vc4_plane_create_additional_planes(drm);
42 drm_fb_helper_remove_conflicting_framebuffers(NULL, "vc4drmfb", false);
44 --- a/drivers/gpu/drm/vc4/vc4_drv.h
45 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
46 @@ -855,8 +855,7 @@ int vc4_kms_load(struct drm_device *dev)
48 struct drm_plane *vc4_plane_init(struct drm_device *dev,
49 enum drm_plane_type type);
50 -int vc4_plane_create_additional_planes(struct drm_device *dev,
51 - struct drm_crtc *crtc);
52 +int vc4_plane_create_additional_planes(struct drm_device *dev);
53 u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist);
54 u32 vc4_plane_dlist_size(const struct drm_plane_state *state);
55 void vc4_plane_async_set_fb(struct drm_plane *plane,
56 --- a/drivers/gpu/drm/vc4/vc4_plane.c
57 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
58 @@ -1438,39 +1438,41 @@ struct drm_plane *vc4_plane_init(struct
62 -int vc4_plane_create_additional_planes(struct drm_device *drm,
63 - struct drm_crtc *crtc)
64 +int vc4_plane_create_additional_planes(struct drm_device *drm)
66 struct drm_plane *cursor_plane;
67 + struct drm_crtc *crtc;
70 - /* Set up some arbitrary number of planes. We're not limited
71 - * by a set number of physical registers, just the space in
72 - * the HVS (16k) and how small an plane can be (28 bytes).
73 - * However, each plane we set up takes up some memory, and
74 - * increases the cost of looping over planes, which atomic
75 - * modesetting does quite a bit. As a result, we pick a
76 - * modest number of planes to expose, that should hopefully
77 - * still cover any sane usecase.
79 - for (i = 0; i < 8; i++) {
80 - struct drm_plane *plane =
81 - vc4_plane_init(drm, DRM_PLANE_TYPE_OVERLAY);
86 - plane->possible_crtcs = drm_crtc_mask(crtc);
89 - /* Set up the legacy cursor after overlay initialization,
90 - * since we overlay planes on the CRTC in the order they were
93 - cursor_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_CURSOR);
94 - if (!IS_ERR(cursor_plane)) {
95 - cursor_plane->possible_crtcs = drm_crtc_mask(crtc);
96 - crtc->cursor = cursor_plane;
97 + drm_for_each_crtc(crtc, drm) {
98 + /* Set up some arbitrary number of planes. We're not limited
99 + * by a set number of physical registers, just the space in
100 + * the HVS (16k) and how small an plane can be (28 bytes).
101 + * However, each plane we set up takes up some memory, and
102 + * increases the cost of looping over planes, which atomic
103 + * modesetting does quite a bit. As a result, we pick a
104 + * modest number of planes to expose, that should hopefully
105 + * still cover any sane usecase.
107 + for (i = 0; i < 8; i++) {
108 + struct drm_plane *plane =
109 + vc4_plane_init(drm, DRM_PLANE_TYPE_OVERLAY);
114 + plane->possible_crtcs = drm_crtc_mask(crtc);
117 + /* Set up the legacy cursor after overlay initialization,
118 + * since we overlay planes on the CRTC in the order they were
121 + cursor_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_CURSOR);
122 + if (!IS_ERR(cursor_plane)) {
123 + cursor_plane->possible_crtcs = drm_crtc_mask(crtc);
124 + crtc->cursor = cursor_plane;