BACKPORT: drm/exynos: add property for plane zpos
authorJoonyoung Shim <jy0922.shim@samsung.com>
Wed, 27 Jun 2012 05:27:06 +0000 (14:27 +0900)
committerChromeBot <chrome-bot@google.com>
Sat, 30 Mar 2013 05:37:13 +0000 (22:37 -0700)
The exynos drm driver used a specific ioctl - DRM_EXYNOS_PLANE_SET_ZPOS
to set zpos of plane. It can be substitute to property of plane. This
patch adds a property for plane zpos and removes
DRM_EXYNOS_PLANE_SET_ZPOS ioctl.

BUG=chromium:222980
TEST=Verified that cursor works when using property to set zpos.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
(cherry picked from commit 00ae67cf26fad3889e71e3bdbec012b1f938dc0e)

Change-Id: I018b6475916f6bbff416d0313fe0c7c3c68217b8
Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46957
Reviewed-by: John Sheu <sheu@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
drivers/gpu/drm/exynos/exynos_drm_drv.c
drivers/gpu/drm/exynos/exynos_drm_drv.h
drivers/gpu/drm/exynos/exynos_drm_plane.c
drivers/gpu/drm/exynos/exynos_drm_plane.h
include/drm/exynos_drm.h

index 1500edf..7dfe412 100644 (file)
@@ -312,8 +312,6 @@ static struct drm_ioctl_desc exynos_ioctls[] = {
                        DRM_AUTH),
        DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MMAP,
                        exynos_drm_gem_mmap_ioctl, DRM_UNLOCKED | DRM_AUTH),
-       DRM_IOCTL_DEF_DRV(EXYNOS_PLANE_SET_ZPOS, exynos_plane_set_zpos_ioctl,
-                       DRM_UNLOCKED | DRM_AUTH),
        DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION,
                        vidi_connection_ioctl, DRM_UNLOCKED | DRM_AUTH),
        DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CPU_ACQUIRE,
index 7d6accf..229bc53 100644 (file)
@@ -146,6 +146,7 @@ struct exynos_drm_private {
         * this array is used to be aware of which crtc did it request vblank.
         */
        struct drm_crtc *crtc[EXYNOS_DRM_DISPLAY_NUM_DISPLAYS];
+       struct drm_property *plane_zpos_property;
 
 #ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
        struct kds_callback kds_cb;
index 63a8548..e430fbc 100644 (file)
@@ -101,12 +101,52 @@ static void exynos_plane_destroy(struct drm_plane *plane)
        kfree(exynos_plane);
 }
 
+static int exynos_plane_set_property(struct drm_plane *plane,
+                                    struct drm_property *property,
+                                    uint64_t val)
+{
+       struct drm_device *dev = plane->dev;
+       struct exynos_plane *exynos_plane = to_exynos_plane(plane);
+       struct exynos_drm_private *dev_priv = dev->dev_private;
+
+       DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
+
+       if (property == dev_priv->plane_zpos_property) {
+               exynos_plane->overlay.zpos = val;
+               return 0;
+       }
+
+       return -EINVAL;
+}
+
 static struct drm_plane_funcs exynos_plane_funcs = {
        .update_plane   = exynos_update_plane,
        .disable_plane  = exynos_disable_plane,
        .destroy        = exynos_plane_destroy,
+       .set_property   = exynos_plane_set_property,
 };
 
+static void exynos_plane_attach_zpos_property(struct drm_plane *plane)
+{
+       struct drm_device *dev = plane->dev;
+       struct exynos_drm_private *dev_priv = dev->dev_private;
+       struct drm_property *prop;
+
+       DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
+
+       prop = dev_priv->plane_zpos_property;
+       if (!prop) {
+               prop = drm_property_create_range(dev, 0, "zpos", 0,
+                                                MAX_PLANE - 1);
+               if (!prop)
+                       return;
+
+               dev_priv->plane_zpos_property = prop;
+       }
+
+       drm_object_attach_property(&plane->base, prop, 0);
+}
+
 struct drm_plane *exynos_plane_init(struct drm_device *dev,
                                    unsigned int possible_crtcs, bool priv)
 {
@@ -121,8 +161,6 @@ struct drm_plane *exynos_plane_init(struct drm_device *dev,
                return NULL;
        }
 
-       exynos_plane->overlay.zpos = DEFAULT_ZPOS;
-
        err = drm_plane_init(dev, &exynos_plane->base, possible_crtcs,
                              &exynos_plane_funcs, formats, ARRAY_SIZE(formats),
                              priv);
@@ -132,50 +170,12 @@ struct drm_plane *exynos_plane_init(struct drm_device *dev,
                return NULL;
        }
 
-       return &exynos_plane->base;
-}
-
-int exynos_plane_set_zpos_ioctl(struct drm_device *dev, void *data,
-                               struct drm_file *file_priv)
-{
-       struct drm_exynos_plane_set_zpos *zpos_req = data;
-       struct drm_mode_object *obj;
-       struct drm_plane *plane;
-       struct exynos_plane *exynos_plane;
-       int ret = 0;
-
-       if (!drm_core_check_feature(dev, DRIVER_MODESET))
-               return -EINVAL;
-
-       DRM_DEBUG_KMS("[DEV:%s] [PLANE:%d] zpos: %d\n", dev->devname,
-                       zpos_req->plane_id, zpos_req->zpos);
-
-       if (zpos_req->zpos < 0 || zpos_req->zpos >= MAX_PLANE) {
-               if (zpos_req->zpos != DEFAULT_ZPOS) {
-                       DRM_ERROR("zpos not within limits\n");
-                       return -EINVAL;
-               }
-       }
-
-       mutex_lock(&dev->mode_config.mutex);
-
-       obj = drm_mode_object_find(dev, zpos_req->plane_id,
-                       DRM_MODE_OBJECT_PLANE);
-       if (!obj) {
-               DRM_DEBUG_KMS("Unknown plane ID %d\n",
-                             zpos_req->plane_id);
-               ret = -EINVAL;
-               goto out;
-       }
-
-       plane = obj_to_plane(obj);
-       exynos_plane = container_of(plane, struct exynos_plane, base);
+       if (priv)
+               exynos_plane->overlay.zpos = DEFAULT_ZPOS;
+       else
+               exynos_plane_attach_zpos_property(&exynos_plane->base);
 
-       exynos_plane->overlay.zpos = zpos_req->zpos;
-
-out:
-       mutex_unlock(&dev->mode_config.mutex);
-       return ret;
+       return &exynos_plane->base;
 }
 
 struct exynos_drm_overlay *get_exynos_drm_overlay(struct drm_plane *plane)
index d052918..6e2ac5d 100644 (file)
@@ -11,6 +11,4 @@
 
 struct drm_plane *exynos_plane_init(struct drm_device *dev,
                                    unsigned int possible_crtcs, bool priv);
-int exynos_plane_set_zpos_ioctl(struct drm_device *dev, void *data,
-                               struct drm_file *file_priv);
 struct exynos_drm_overlay *get_exynos_drm_overlay(struct drm_plane *plane);
index dc01f66..4f5d32d 100644 (file)
@@ -74,11 +74,6 @@ struct drm_exynos_gem_mmap {
        uint64_t mapped;
 };
 
-struct drm_exynos_plane_set_zpos {
-       __u32 plane_id;
-       __s32 zpos;
-};
-
 /**
  * A structure for user connection request of virtual display.
  *
@@ -129,7 +124,6 @@ enum drm_exynos_gem_mem_type {
 #define DRM_EXYNOS_GEM_MAP_OFFSET      0x01
 #define DRM_EXYNOS_GEM_MMAP            0x02
 /* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */
-#define DRM_EXYNOS_PLANE_SET_ZPOS      0x06
 #define DRM_EXYNOS_VIDI_CONNECTION     0x07
 #define DRM_EXYNOS_GEM_CPU_ACQUIRE     0x08
 #define DRM_EXYNOS_GEM_CPU_RELEASE     0x09
@@ -143,9 +137,6 @@ enum drm_exynos_gem_mem_type {
 #define DRM_IOCTL_EXYNOS_GEM_MMAP      DRM_IOWR(DRM_COMMAND_BASE + \
                DRM_EXYNOS_GEM_MMAP, struct drm_exynos_gem_mmap)
 
-#define DRM_IOCTL_EXYNOS_PLANE_SET_ZPOS        DRM_IOWR(DRM_COMMAND_BASE + \
-               DRM_EXYNOS_PLANE_SET_ZPOS, struct drm_exynos_plane_set_zpos)
-
 #define DRM_IOCTL_EXYNOS_VIDI_CONNECTION       DRM_IOWR(DRM_COMMAND_BASE + \
                DRM_EXYNOS_VIDI_CONNECTION, struct drm_exynos_vidi_connection)