7c3c4708498b92ad6afc38268cb40ef7d7403199
[openwrt/openwrt.git] /
1 From ac2c812856c3a496354b9f19d0a43458e108844d Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Thu, 6 Feb 2020 14:32:57 +0100
4 Subject: [PATCH] drm/vc4: plane: Move planes creation to its own
5 function
6
7 The planes so far were created as part of the CRTC binding code with
8 each planes created associated only to one CRTC. However, the hardware
9 in the vc4 doesn't really have such constraint and can be used with any
10 CRTC.
11
12 In order to rework this, let's first move the overlay and cursor planes
13 creation to a function of its own.
14
15 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
16 ---
17 drivers/gpu/drm/vc4/vc4_crtc.c | 33 ++++------------------------
18 drivers/gpu/drm/vc4/vc4_drv.h | 2 ++
19 drivers/gpu/drm/vc4/vc4_plane.c | 38 +++++++++++++++++++++++++++++++++
20 3 files changed, 44 insertions(+), 29 deletions(-)
21
22 --- a/drivers/gpu/drm/vc4/vc4_crtc.c
23 +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
24 @@ -1142,7 +1142,7 @@ static int vc4_crtc_bind(struct device *
25 struct drm_device *drm = dev_get_drvdata(master);
26 struct vc4_crtc *vc4_crtc;
27 struct drm_crtc *crtc;
28 - struct drm_plane *primary_plane, *cursor_plane, *destroy_plane, *temp;
29 + struct drm_plane *primary_plane, *destroy_plane, *temp;
30 const struct of_device_id *match;
31 int ret, i;
32
33 @@ -1190,34 +1190,9 @@ static int vc4_crtc_bind(struct device *
34 */
35 drm_crtc_enable_color_mgmt(crtc, 0, true, crtc->gamma_size);
36
37 - /* Set up some arbitrary number of planes. We're not limited
38 - * by a set number of physical registers, just the space in
39 - * the HVS (16k) and how small an plane can be (28 bytes).
40 - * However, each plane we set up takes up some memory, and
41 - * increases the cost of looping over planes, which atomic
42 - * modesetting does quite a bit. As a result, we pick a
43 - * modest number of planes to expose, that should hopefully
44 - * still cover any sane usecase.
45 - */
46 - for (i = 0; i < 8; i++) {
47 - struct drm_plane *plane =
48 - vc4_plane_init(drm, DRM_PLANE_TYPE_OVERLAY);
49 -
50 - if (IS_ERR(plane))
51 - continue;
52 -
53 - plane->possible_crtcs = drm_crtc_mask(crtc);
54 - }
55 -
56 - /* Set up the legacy cursor after overlay initialization,
57 - * since we overlay planes on the CRTC in the order they were
58 - * initialized.
59 - */
60 - cursor_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_CURSOR);
61 - if (!IS_ERR(cursor_plane)) {
62 - cursor_plane->possible_crtcs = drm_crtc_mask(crtc);
63 - crtc->cursor = cursor_plane;
64 - }
65 + ret = vc4_plane_create_additional_planes(drm, crtc);
66 + if (ret)
67 + goto err_destroy_planes;
68
69 vc4_crtc_get_cob_allocation(vc4_crtc);
70
71 --- a/drivers/gpu/drm/vc4/vc4_drv.h
72 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
73 @@ -855,6 +855,8 @@ int vc4_kms_load(struct drm_device *dev)
74 /* vc4_plane.c */
75 struct drm_plane *vc4_plane_init(struct drm_device *dev,
76 enum drm_plane_type type);
77 +int vc4_plane_create_additional_planes(struct drm_device *dev,
78 + struct drm_crtc *crtc);
79 u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist);
80 u32 vc4_plane_dlist_size(const struct drm_plane_state *state);
81 void vc4_plane_async_set_fb(struct drm_plane *plane,
82 --- a/drivers/gpu/drm/vc4/vc4_plane.c
83 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
84 @@ -1437,3 +1437,41 @@ struct drm_plane *vc4_plane_init(struct
85
86 return plane;
87 }
88 +
89 +int vc4_plane_create_additional_planes(struct drm_device *drm,
90 + struct drm_crtc *crtc)
91 +{
92 + struct drm_plane *cursor_plane;
93 + unsigned int i;
94 +
95 + /* Set up some arbitrary number of planes. We're not limited
96 + * by a set number of physical registers, just the space in
97 + * the HVS (16k) and how small an plane can be (28 bytes).
98 + * However, each plane we set up takes up some memory, and
99 + * increases the cost of looping over planes, which atomic
100 + * modesetting does quite a bit. As a result, we pick a
101 + * modest number of planes to expose, that should hopefully
102 + * still cover any sane usecase.
103 + */
104 + for (i = 0; i < 8; i++) {
105 + struct drm_plane *plane =
106 + vc4_plane_init(drm, DRM_PLANE_TYPE_OVERLAY);
107 +
108 + if (IS_ERR(plane))
109 + continue;
110 +
111 + plane->possible_crtcs = drm_crtc_mask(crtc);
112 + }
113 +
114 + /* Set up the legacy cursor after overlay initialization,
115 + * since we overlay planes on the CRTC in the order they were
116 + * initialized.
117 + */
118 + cursor_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_CURSOR);
119 + if (!IS_ERR(cursor_plane)) {
120 + cursor_plane->possible_crtcs = drm_crtc_mask(crtc);
121 + crtc->cursor = cursor_plane;
122 + }
123 +
124 + return 0;
125 +}