MLK-22600-3 drm/imx: dpu: plane: Support full zpos range for planes
authorLiu Ying <victor.liu@nxp.com>
Thu, 12 Sep 2019 06:29:27 +0000 (14:29 +0800)
committerLiu Ying <victor.liu@nxp.com>
Fri, 20 Sep 2019 02:01:32 +0000 (10:01 +0800)
DPU has no limitations on the plane's zpos, so we don't
have to limit the primary plane zpos to be zero and the
overlay plane zpos to be non-zero.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
(cherry picked from commit 4487aca4ab19623e1995322871e6f14d48bfef74)

drivers/gpu/drm/imx/dpu/dpu-kms.c
drivers/gpu/drm/imx/dpu/dpu-plane.c

index e61013a..2dfc43a 100644 (file)
@@ -672,12 +672,6 @@ static int dpu_drm_atomic_check(struct drm_device *dev,
                        continue;
                }
 
-               /* 'zpos = 0' means primary plane */
-               if (states[0]->plane->type != DRM_PLANE_TYPE_PRIMARY) {
-                       kfree(states);
-                       return -EINVAL;
-               }
-
                if (use_pc[dpu_crtc->crtc_grp_id])
                        dpu_atomic_compute_plane_lrx_per_crtc(crtc_state,
                                                                states, n);
index c07ea06..f000838 100644 (file)
@@ -66,6 +66,16 @@ static const uint64_t dpu_format_modifiers[] = {
        DRM_FORMAT_MOD_INVALID,
 };
 
+static unsigned int dpu_plane_get_default_zpos(enum drm_plane_type type)
+{
+       if (type == DRM_PLANE_TYPE_PRIMARY)
+               return 0;
+       else if (type == DRM_PLANE_TYPE_OVERLAY)
+               return 1;
+
+       return 0;
+}
+
 static void dpu_plane_destroy(struct drm_plane *plane)
 {
        struct dpu_plane *dpu_plane = to_dpu_plane(plane);
@@ -88,11 +98,10 @@ static void dpu_plane_reset(struct drm_plane *plane)
        if (!state)
                return;
 
-       state->base.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
-
        plane->state = &state->base;
        plane->state->plane = plane;
        plane->state->rotation = DRM_MODE_ROTATE_0;
+       plane->state->zpos = dpu_plane_get_default_zpos(plane->type);
 }
 
 static struct drm_plane_state *
@@ -526,7 +535,6 @@ static void dpu_plane_atomic_update(struct drm_plane *plane,
        bool update_aux_source = false;
        bool use_prefetch;
        bool need_modeset;
-       bool is_overlay = plane->type == DRM_PLANE_TYPE_OVERLAY;
        bool fb_is_interlaced;
 
        /*
@@ -785,7 +793,7 @@ again:
                if (prefetch_start || uv_prefetch_start) {
                        dprc_first_frame_handle(dprc);
 
-                       if (!need_modeset && is_overlay)
+                       if (!need_modeset && state->normalized_zpos != 0)
                                framegen_wait_for_frame_counter_moving(fg);
                }
 
@@ -855,7 +863,7 @@ struct dpu_plane *dpu_plane_init(struct drm_device *drm,
 {
        struct dpu_plane *dpu_plane;
        struct drm_plane *plane;
-       unsigned int ov_num;
+       unsigned int zpos = dpu_plane_get_default_zpos(type);
        int ret;
 
        dpu_plane = kzalloc(sizeof(*dpu_plane), GFP_KERNEL);
@@ -886,20 +894,8 @@ struct dpu_plane *dpu_plane_init(struct drm_device *drm,
 
        drm_plane_helper_add(plane, &dpu_plane_helper_funcs);
 
-       switch (type) {
-       case DRM_PLANE_TYPE_PRIMARY:
-               ret = drm_plane_create_zpos_immutable_property(plane, 0);
-               break;
-       case DRM_PLANE_TYPE_OVERLAY:
-               /* filter out the primary plane */
-               ov_num = grp->hw_plane_num - 1;
-
-               ret = drm_plane_create_zpos_property(plane, 1, 1, ov_num);
-               break;
-       default:
-               ret = -EINVAL;
-       }
-
+       ret = drm_plane_create_zpos_property(plane,
+                                            zpos, 0, grp->hw_plane_num - 1);
        if (ret)
                goto err;