diff mbox

drm/fsl-dcu: Add multi layers support

Message ID 1471253427-6260-1-git-send-email-meng.yi@nxp.com (mailing list archive)
State New, archived
Headers show

Commit Message

Meng Yi Aug. 15, 2016, 9:30 a.m. UTC
For DCU support 16 layers(on ls1021a) or 64 layers(on vf610),
add (total_layer - 1) overlay planes.

Signed-off-by: Jianwei Wang <jianwei.wang.chn@gmail.com>
Signed-off-by: Meng Yi <meng.yi@nxp.com>
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
index e50467a..3c2b6b4 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
@@ -235,8 +235,9 @@  void fsl_dcu_drm_init_planes(struct drm_device *dev)
 
 struct drm_plane *fsl_dcu_drm_primary_create_plane(struct drm_device *dev)
 {
-	struct drm_plane *primary;
-	int ret;
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	struct drm_plane *primary, *overlay;
+	int ret, i;
 
 	primary = kzalloc(sizeof(*primary), GFP_KERNEL);
 	if (!primary) {
@@ -256,5 +257,25 @@  struct drm_plane *fsl_dcu_drm_primary_create_plane(struct drm_device *dev)
 	}
 	drm_plane_helper_add(primary, &fsl_dcu_drm_plane_helper_funcs);
 
+	for (i = 0; i < fsl_dev->soc->total_layer - 1; i++) {
+		overlay = kzalloc(sizeof(struct drm_plane), GFP_KERNEL);
+		if (!overlay) {
+			DRM_DEBUG_KMS("Failed to allocate overlay plane\n");
+			continue;
+		}
+
+		ret = drm_universal_plane_init(dev, overlay, 1,
+					       &fsl_dcu_drm_plane_funcs,
+					       fsl_dcu_drm_plane_formats,
+					       ARRAY_SIZE(
+					       fsl_dcu_drm_plane_formats),
+					       DRM_PLANE_TYPE_OVERLAY, NULL);
+		if (ret) {
+			kfree(overlay);
+			continue;
+		}
+		drm_plane_helper_add(overlay, &fsl_dcu_drm_plane_helper_funcs);
+	}
+
 	return primary;
 }