drm: rcar: use generic code for managing zpos plane property
authorBenjamin Gaignard <benjamin.gaignard@linaro.org>
Fri, 22 Jul 2016 12:28:27 +0000 (14:28 +0200)
committerBenjamin Gaignard <benjamin.gaignard@linaro.org>
Fri, 29 Jul 2016 08:03:10 +0000 (10:03 +0200)
version 6:
rebased patch on top rcar-du changes for zpos

version 4:
fix null pointer issue while setting zpos in plane reset function

This patch replaces zpos property handling custom code in rcar DRM
driver with calls to generic DRM code.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
drivers/gpu/drm/rcar-du/rcar_du_crtc.c
drivers/gpu/drm/rcar-du/rcar_du_drv.h
drivers/gpu/drm/rcar-du/rcar_du_kms.c
drivers/gpu/drm/rcar-du/rcar_du_plane.c
drivers/gpu/drm/rcar-du/rcar_du_plane.h
drivers/gpu/drm/rcar-du/rcar_du_vsp.c

index e39fcef2e033c71dd969294f79420a981944b245..7316fc7fa0bd95a110988b824b23711a94a0d660 100644 (file)
@@ -196,7 +196,7 @@ void rcar_du_crtc_route_output(struct drm_crtc *crtc,
 
 static unsigned int plane_zpos(struct rcar_du_plane *plane)
 {
-       return to_rcar_plane_state(plane->plane.state)->zpos;
+       return plane->plane.state->normalized_zpos;
 }
 
 static const struct rcar_du_format_info *
index ed35467d96cfd568a8668202aa3364ddefeed380..c843c3134498a985b5e56151e1ececbb5bef49eb 100644 (file)
@@ -92,7 +92,6 @@ struct rcar_du_device {
        struct {
                struct drm_property *alpha;
                struct drm_property *colorkey;
-               struct drm_property *zpos;
        } props;
 
        unsigned int dpad0_source;
index 6bb032d8ac6bbd28dcce4df4c4f56374678ebab7..f03eb55318c1cfb3fc3914fd9184f251f245bd41 100644 (file)
@@ -527,11 +527,6 @@ static int rcar_du_properties_init(struct rcar_du_device *rcdu)
        if (rcdu->props.colorkey == NULL)
                return -ENOMEM;
 
-       rcdu->props.zpos =
-               drm_property_create_range(rcdu->ddev, 0, "zpos", 1, 7);
-       if (rcdu->props.zpos == NULL)
-               return -ENOMEM;
-
        return 0;
 }
 
index bfe31ca870cc72173456271020472f7e4936fca0..a74f8ed8ca2e32b9260f8ce5f38baabe023e5f8f 100644 (file)
@@ -652,7 +652,7 @@ static void rcar_du_plane_reset(struct drm_plane *plane)
        state->source = RCAR_DU_PLANE_MEMORY;
        state->alpha = 255;
        state->colorkey = RCAR_DU_COLORKEY_NONE;
-       state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
+       state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 
        plane->state = &state->state;
        plane->state->plane = plane;
@@ -670,8 +670,6 @@ static int rcar_du_plane_atomic_set_property(struct drm_plane *plane,
                rstate->alpha = val;
        else if (property == rcdu->props.colorkey)
                rstate->colorkey = val;
-       else if (property == rcdu->props.zpos)
-               rstate->zpos = val;
        else
                return -EINVAL;
 
@@ -690,8 +688,6 @@ static int rcar_du_plane_atomic_get_property(struct drm_plane *plane,
                *val = rstate->alpha;
        else if (property == rcdu->props.colorkey)
                *val = rstate->colorkey;
-       else if (property == rcdu->props.zpos)
-               *val = rstate->zpos;
        else
                return -EINVAL;
 
@@ -763,8 +759,7 @@ int rcar_du_planes_init(struct rcar_du_group *rgrp)
                drm_object_attach_property(&plane->plane.base,
                                           rcdu->props.colorkey,
                                           RCAR_DU_COLORKEY_NONE);
-               drm_object_attach_property(&plane->plane.base,
-                                          rcdu->props.zpos, 1);
+               drm_plane_create_zpos_property(&plane->plane, 1, 1, 7);
        }
 
        return 0;
index b18b7b25dbface31873a26a89cd41e6df2b5cf8a..8b91dd3a46e44992971a2f5025329bb124136a1e 100644 (file)
@@ -51,7 +51,6 @@ static inline struct rcar_du_plane *to_rcar_plane(struct drm_plane *plane)
  * @hwindex: 0-based hardware plane index, -1 means unused
  * @alpha: value of the plane alpha property
  * @colorkey: value of the plane colorkey property
- * @zpos: value of the plane zpos property
  */
 struct rcar_du_plane_state {
        struct drm_plane_state state;
@@ -62,7 +61,6 @@ struct rcar_du_plane_state {
 
        unsigned int alpha;
        unsigned int colorkey;
-       unsigned int zpos;
 };
 
 static inline struct rcar_du_plane_state *
index 6ac717f2056f1b63dc5e6949a5971fe51f2acffc..83ebd162f3ef5eda15982e7fbe0abca4c8855503 100644 (file)
@@ -43,12 +43,12 @@ void rcar_du_vsp_enable(struct rcar_du_crtc *crtc)
                        .src_y = 0,
                        .src_w = mode->hdisplay << 16,
                        .src_h = mode->vdisplay << 16,
+                       .zpos = 0,
                },
                .format = rcar_du_format_info(DRM_FORMAT_ARGB8888),
                .source = RCAR_DU_PLANE_VSPD1,
                .alpha = 255,
                .colorkey = 0,
-               .zpos = 0,
        };
 
        if (rcdu->info->gen >= 3)
@@ -152,7 +152,7 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
                .pixelformat = 0,
                .pitch = fb->pitches[0],
                .alpha = state->alpha,
-               .zpos = state->zpos,
+               .zpos = state->state.zpos,
        };
        unsigned int i;
 
@@ -267,7 +267,7 @@ static void rcar_du_vsp_plane_reset(struct drm_plane *plane)
                return;
 
        state->alpha = 255;
-       state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
+       state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 
        plane->state = &state->state;
        plane->state->plane = plane;
@@ -282,8 +282,6 @@ static int rcar_du_vsp_plane_atomic_set_property(struct drm_plane *plane,
 
        if (property == rcdu->props.alpha)
                rstate->alpha = val;
-       else if (property == rcdu->props.zpos)
-               rstate->zpos = val;
        else
                return -EINVAL;
 
@@ -300,8 +298,6 @@ static int rcar_du_vsp_plane_atomic_get_property(struct drm_plane *plane,
 
        if (property == rcdu->props.alpha)
                *val = rstate->alpha;
-       else if (property == rcdu->props.zpos)
-               *val = rstate->zpos;
        else
                return -EINVAL;
 
@@ -381,8 +377,8 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp)
 
                drm_object_attach_property(&plane->plane.base,
                                           rcdu->props.alpha, 255);
-               drm_object_attach_property(&plane->plane.base,
-                                          rcdu->props.zpos, 1);
+               drm_plane_create_zpos_property(&plane->plane, 1, 1,
+                                              vsp->num_planes - 1);
        }
 
        return 0;