aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIcenowy Zheng <icenowy@aosc.io>2017-05-14 12:30:36 -0400
committerMaxime Ripard <maxime.ripard@free-electrons.com>2017-05-15 05:12:43 -0400
commit7921e1477a5327ff22cc38a0ec74ace5d26dbba9 (patch)
tree42e6feeaff83d427edeeff1948179f5f304de238
parentf23c68a992def240fe46df8517f15171d7bd6ec2 (diff)
drm/sun4i: return only planes for layers created
As we are going to add support for the Allwinner DE2 Mixer in sun4i-drm driver, we will finally have two types of layers. Each layer is bound to a drm_plane that is CRTC-specific, so we create them when initializing CRTC (calling sun4i_layers_init, which will be generalized in next patch). The drm_plane's will be used when creating CRTC, but the CRTC initialization code do not care other properties of the layer, so we let the sun4i_layers_init function return drm_plane's only. As we have no need to trace the layers after the CRTC is properly created, we drop the layers pointer in sun4i_crtc struct. Doing this uncouples the CRTC code from the type of layer (the sun4i_layers_init function name is still hardcoded and will be changed in the next patch), so that we can finally gain support for the mixer in DE2, which has different layers. Signed-off-by: Icenowy Zheng <icenowy@aosc.io> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_crtc.c23
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_crtc.h1
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_layer.c18
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_layer.h4
4 files changed, 24 insertions, 22 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/sun4i_crtc.c
index 3c876c3a356a..708b3543d4e9 100644
--- a/drivers/gpu/drm/sun4i/sun4i_crtc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c
@@ -139,6 +139,7 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm,
139 struct sun4i_tcon *tcon) 139 struct sun4i_tcon *tcon)
140{ 140{
141 struct sun4i_crtc *scrtc; 141 struct sun4i_crtc *scrtc;
142 struct drm_plane **planes;
142 struct drm_plane *primary = NULL, *cursor = NULL; 143 struct drm_plane *primary = NULL, *cursor = NULL;
143 int ret, i; 144 int ret, i;
144 145
@@ -149,22 +150,22 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm,
149 scrtc->tcon = tcon; 150 scrtc->tcon = tcon;
150 151
151 /* Create our layers */ 152 /* Create our layers */
152 scrtc->layers = sun4i_layers_init(drm, scrtc->backend); 153 planes = sun4i_layers_init(drm, scrtc);
153 if (IS_ERR(scrtc->layers)) { 154 if (IS_ERR(planes)) {
154 dev_err(drm->dev, "Couldn't create the planes\n"); 155 dev_err(drm->dev, "Couldn't create the planes\n");
155 return NULL; 156 return NULL;
156 } 157 }
157 158
158 /* find primary and cursor planes for drm_crtc_init_with_planes */ 159 /* find primary and cursor planes for drm_crtc_init_with_planes */
159 for (i = 0; scrtc->layers[i]; i++) { 160 for (i = 0; planes[i]; i++) {
160 struct sun4i_layer *layer = scrtc->layers[i]; 161 struct drm_plane *plane = planes[i];
161 162
162 switch (layer->plane.type) { 163 switch (plane->type) {
163 case DRM_PLANE_TYPE_PRIMARY: 164 case DRM_PLANE_TYPE_PRIMARY:
164 primary = &layer->plane; 165 primary = plane;
165 break; 166 break;
166 case DRM_PLANE_TYPE_CURSOR: 167 case DRM_PLANE_TYPE_CURSOR:
167 cursor = &layer->plane; 168 cursor = plane;
168 break; 169 break;
169 default: 170 default:
170 break; 171 break;
@@ -188,12 +189,12 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm,
188 1); 189 1);
189 190
190 /* Set possible_crtcs to this crtc for overlay planes */ 191 /* Set possible_crtcs to this crtc for overlay planes */
191 for (i = 0; scrtc->layers[i]; i++) { 192 for (i = 0; planes[i]; i++) {
192 uint32_t possible_crtcs = BIT(drm_crtc_index(&scrtc->crtc)); 193 uint32_t possible_crtcs = BIT(drm_crtc_index(&scrtc->crtc));
193 struct sun4i_layer *layer = scrtc->layers[i]; 194 struct drm_plane *plane = planes[i];
194 195
195 if (layer->plane.type == DRM_PLANE_TYPE_OVERLAY) 196 if (plane->type == DRM_PLANE_TYPE_OVERLAY)
196 layer->plane.possible_crtcs = possible_crtcs; 197 plane->possible_crtcs = possible_crtcs;
197 } 198 }
198 199
199 return scrtc; 200 return scrtc;
diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.h b/drivers/gpu/drm/sun4i/sun4i_crtc.h
index 230cb8f0d601..4dae3508424a 100644
--- a/drivers/gpu/drm/sun4i/sun4i_crtc.h
+++ b/drivers/gpu/drm/sun4i/sun4i_crtc.h
@@ -19,7 +19,6 @@ struct sun4i_crtc {
19 19
20 struct sun4i_backend *backend; 20 struct sun4i_backend *backend;
21 struct sun4i_tcon *tcon; 21 struct sun4i_tcon *tcon;
22 struct sun4i_layer **layers;
23}; 22};
24 23
25static inline struct sun4i_crtc *drm_crtc_to_sun4i_crtc(struct drm_crtc *crtc) 24static inline struct sun4i_crtc *drm_crtc_to_sun4i_crtc(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c
index f26bde5b9117..e1f03e1cc0ac 100644
--- a/drivers/gpu/drm/sun4i/sun4i_layer.c
+++ b/drivers/gpu/drm/sun4i/sun4i_layer.c
@@ -16,6 +16,7 @@
16#include <drm/drmP.h> 16#include <drm/drmP.h>
17 17
18#include "sun4i_backend.h" 18#include "sun4i_backend.h"
19#include "sun4i_crtc.h"
19#include "sun4i_layer.h" 20#include "sun4i_layer.h"
20 21
21struct sun4i_plane_desc { 22struct sun4i_plane_desc {
@@ -128,15 +129,16 @@ static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
128 return layer; 129 return layer;
129} 130}
130 131
131struct sun4i_layer **sun4i_layers_init(struct drm_device *drm, 132struct drm_plane **sun4i_layers_init(struct drm_device *drm,
132 struct sun4i_backend *backend) 133 struct sun4i_crtc *crtc)
133{ 134{
134 struct sun4i_layer **layers; 135 struct drm_plane **planes;
136 struct sun4i_backend *backend = crtc->backend;
135 int i; 137 int i;
136 138
137 layers = devm_kcalloc(drm->dev, ARRAY_SIZE(sun4i_backend_planes) + 1, 139 planes = devm_kcalloc(drm->dev, ARRAY_SIZE(sun4i_backend_planes) + 1,
138 sizeof(*layers), GFP_KERNEL); 140 sizeof(*planes), GFP_KERNEL);
139 if (!layers) 141 if (!planes)
140 return ERR_PTR(-ENOMEM); 142 return ERR_PTR(-ENOMEM);
141 143
142 /* 144 /*
@@ -178,8 +180,8 @@ struct sun4i_layer **sun4i_layers_init(struct drm_device *drm,
178 SUN4I_BACKEND_ATTCTL_REG0_LAY_PIPESEL(plane->pipe)); 180 SUN4I_BACKEND_ATTCTL_REG0_LAY_PIPESEL(plane->pipe));
179 181
180 layer->id = i; 182 layer->id = i;
181 layers[i] = layer; 183 planes[i] = &layer->plane;
182 }; 184 };
183 185
184 return layers; 186 return planes;
185} 187}
diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.h b/drivers/gpu/drm/sun4i/sun4i_layer.h
index 4be1f0919df2..5ea5c994d6ea 100644
--- a/drivers/gpu/drm/sun4i/sun4i_layer.h
+++ b/drivers/gpu/drm/sun4i/sun4i_layer.h
@@ -26,7 +26,7 @@ plane_to_sun4i_layer(struct drm_plane *plane)
26 return container_of(plane, struct sun4i_layer, plane); 26 return container_of(plane, struct sun4i_layer, plane);
27} 27}
28 28
29struct sun4i_layer **sun4i_layers_init(struct drm_device *drm, 29struct drm_plane **sun4i_layers_init(struct drm_device *drm,
30 struct sun4i_backend *backend); 30 struct sun4i_crtc *crtc);
31 31
32#endif /* _SUN4I_LAYER_H_ */ 32#endif /* _SUN4I_LAYER_H_ */