aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2017-02-23 03:05:38 -0500
committerMaxime Ripard <maxime.ripard@free-electrons.com>2017-03-07 16:18:23 -0500
commitdcd215801b0279f0a021516526cf7c0b67d5302e (patch)
treefd3463cb32215a5aa15b10b974953b03aa0fac53
parent46cce6dac316a707309b374d9b6786b4269e7274 (diff)
drm/sun4i: Drop primary layer pointer from sun4i_drv
The current layer init code keeps a pointer to the primary plane layer in sun4i_drv. When we eventually support multiple display pipelines, this would force us to keep track of primary planes for all crtcs. And these pointers only get used at bind time. Instead, have the crtc init code iterate through the returned layers to find the primary and cursor layers. And drop the pointer from the sun4i_drv structure. Signed-off-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.c25
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_drv.h1
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_layer.c3
3 files changed, 21 insertions, 8 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/sun4i_crtc.c
index bcc1c9533d67..81dcd5eee003 100644
--- a/drivers/gpu/drm/sun4i/sun4i_crtc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c
@@ -143,7 +143,8 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm)
143{ 143{
144 struct sun4i_drv *drv = drm->dev_private; 144 struct sun4i_drv *drv = drm->dev_private;
145 struct sun4i_crtc *scrtc; 145 struct sun4i_crtc *scrtc;
146 int ret; 146 struct drm_plane *primary = NULL, *cursor = NULL;
147 int ret, i;
147 148
148 scrtc = devm_kzalloc(drm->dev, sizeof(*scrtc), GFP_KERNEL); 149 scrtc = devm_kzalloc(drm->dev, sizeof(*scrtc), GFP_KERNEL);
149 if (!scrtc) 150 if (!scrtc)
@@ -154,12 +155,28 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm)
154 scrtc->layers = sun4i_layers_init(drm); 155 scrtc->layers = sun4i_layers_init(drm);
155 if (IS_ERR(scrtc->layers)) { 156 if (IS_ERR(scrtc->layers)) {
156 dev_err(drm->dev, "Couldn't create the planes\n"); 157 dev_err(drm->dev, "Couldn't create the planes\n");
157 return ERR_CAST(scrtc->layers); 158 return NULL;
159 }
160
161 /* find primary and cursor planes for drm_crtc_init_with_planes */
162 for (i = 0; scrtc->layers[i]; i++) {
163 struct sun4i_layer *layer = scrtc->layers[i];
164
165 switch (layer->plane.type) {
166 case DRM_PLANE_TYPE_PRIMARY:
167 primary = &layer->plane;
168 break;
169 case DRM_PLANE_TYPE_CURSOR:
170 cursor = &layer->plane;
171 break;
172 default:
173 break;
174 }
158 } 175 }
159 176
160 ret = drm_crtc_init_with_planes(drm, &scrtc->crtc, 177 ret = drm_crtc_init_with_planes(drm, &scrtc->crtc,
161 drv->primary, 178 primary,
162 NULL, 179 cursor,
163 &sun4i_crtc_funcs, 180 &sun4i_crtc_funcs,
164 NULL); 181 NULL);
165 if (ret) { 182 if (ret) {
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.h b/drivers/gpu/drm/sun4i/sun4i_drv.h
index 7a3345b7b6d1..5df50126ff52 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.h
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.h
@@ -20,7 +20,6 @@ struct sun4i_drv {
20 struct sun4i_backend *backend; 20 struct sun4i_backend *backend;
21 struct sun4i_tcon *tcon; 21 struct sun4i_tcon *tcon;
22 22
23 struct drm_plane *primary;
24 struct drm_fbdev_cma *fbdev; 23 struct drm_fbdev_cma *fbdev;
25}; 24};
26 25
diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c
index 0b703fb02656..9c0baee25fae 100644
--- a/drivers/gpu/drm/sun4i/sun4i_layer.c
+++ b/drivers/gpu/drm/sun4i/sun4i_layer.c
@@ -127,9 +127,6 @@ static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
127 &sun4i_backend_layer_helper_funcs); 127 &sun4i_backend_layer_helper_funcs);
128 layer->drv = drv; 128 layer->drv = drv;
129 129
130 if (plane->type == DRM_PLANE_TYPE_PRIMARY)
131 drv->primary = &layer->plane;
132
133 return layer; 130 return layer;
134} 131}
135 132