VIGS: Implement plane flip/rotate 16/26416/1
authorStanislav Vorobiov <s.vorobiov@samsung.com>
Fri, 22 Aug 2014 06:53:21 +0000 (10:53 +0400)
committerStanislav Vorobiov <s.vorobiov@samsung.com>
Fri, 22 Aug 2014 06:53:39 +0000 (10:53 +0400)
Planes can now be horizontally/vertically flipped
and rotated by 90, 180 or 270 degrees

Change-Id: Ic127028b25fcb4f83ef4edb488c49c2da71cf8ec
Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com>
drivers/gpu/drm/vigs/vigs_comm.c
drivers/gpu/drm/vigs/vigs_comm.h
drivers/gpu/drm/vigs/vigs_driver.c
drivers/gpu/drm/vigs/vigs_plane.c
drivers/gpu/drm/vigs/vigs_plane.h
drivers/gpu/drm/vigs/vigs_protocol.h
include/drm/vigs_drm.h

index 758786f2f124d411f265029628c0033ae14fb023..1171cfe0b8890fc88d6355258efb57cc5b5d5d70 100644 (file)
@@ -433,14 +433,18 @@ int vigs_comm_set_plane(struct vigs_comm *comm,
                         int dst_y,
                         unsigned int dst_w,
                         unsigned int dst_h,
-                        int z_pos)
+                        int z_pos,
+                        int hflip,
+                        int vflip,
+                        int rotation)
 {
     int ret;
     struct vigsp_cmd_set_plane_request *request;
 
-    DRM_DEBUG_DRIVER("plane = %u, src_x = %u, src_y = %u, src_w = %u, src_h = %u, dst_x = %d, dst_y = %d, dst_w = %u, dst_h = %u, z_pos = %d\n",
+    DRM_DEBUG_DRIVER("plane = %u, src_x = %u, src_y = %u, src_w = %u, src_h = %u, dst_x = %d, dst_y = %d, dst_w = %u, dst_h = %u, z_pos = %d, hflip = %d, vflip = %d, rotation = %d\n",
                      plane, src_x, src_y, src_w, src_h,
-                     dst_x, dst_y, dst_w, dst_h, z_pos);
+                     dst_x, dst_y, dst_w, dst_h, z_pos, hflip, vflip,
+                     rotation);
 
     mutex_lock(&comm->mutex);
 
@@ -464,6 +468,9 @@ int vigs_comm_set_plane(struct vigs_comm *comm,
         request->dst_size.w = dst_w;
         request->dst_size.h = dst_h;
         request->z_pos = z_pos;
+        request->hflip = hflip;
+        request->vflip = vflip;
+        request->rotation = rotation;
 
         vigs_comm_exec_internal(comm, comm->execbuffer);
     }
index 1242e9c97a999f2f3ea472cf9e771fd68294a17f..9b87e94ae781dc8ee192807a15c74e5640c9ee80 100644 (file)
@@ -79,7 +79,10 @@ int vigs_comm_set_plane(struct vigs_comm *comm,
                         int dst_y,
                         unsigned int dst_w,
                         unsigned int dst_h,
-                        int z_pos);
+                        int z_pos,
+                        int hflip,
+                        int vflip,
+                        int rotation);
 
 int vigs_comm_fence(struct vigs_comm *comm, struct vigs_fence *fence);
 
index 07cd0e68aa86b5926e2dfc84cf0a1509de3b373f..ab50effa44f14dff49dc6b3a2e63954cc613182d 100644 (file)
@@ -68,6 +68,8 @@ static struct drm_ioctl_desc vigs_drm_ioctls[] =
                                         DRM_UNLOCKED | DRM_AUTH),
     DRM_IOCTL_DEF_DRV(VIGS_PLANE_SET_ZPOS, vigs_plane_set_zpos_ioctl,
                                            DRM_UNLOCKED | DRM_AUTH),
+    DRM_IOCTL_DEF_DRV(VIGS_PLANE_SET_TRANSFORM, vigs_plane_set_transform_ioctl,
+                                                DRM_UNLOCKED | DRM_AUTH),
 
     DRM_IOCTL_DEF_DRV(VIGS_DP_CREATE_SURFACE, vigs_dp_surface_create_ioctl,
                                               DRM_UNLOCKED | DRM_AUTH),
index 9c6b249f9ba4b01d1edb01cce9b3ff147e961d4f..74d1a8c15f79b6fbb9019e385dd6d69036332fea 100644 (file)
@@ -98,7 +98,10 @@ static int vigs_plane_update(struct drm_plane *plane,
                               crtc_y,
                               crtc_w,
                               crtc_h,
-                              vigs_plane->z_pos);
+                              vigs_plane->z_pos,
+                              vigs_plane->hflip,
+                              vigs_plane->vflip,
+                              vigs_plane->rotation);
 
     if (ret == 0) {
         vigs_plane->src_x = src_x;
@@ -144,6 +147,9 @@ static int vigs_plane_disable(struct drm_plane *plane)
                               0,
                               0,
                               0,
+                              0,
+                              0,
+                              0,
                               0);
 
     if (ret == 0) {
@@ -243,3 +249,38 @@ out:
 
     return ret;
 }
+
+int vigs_plane_set_transform_ioctl(struct drm_device *drm_dev,
+                                   void *data,
+                                   struct drm_file *file_priv)
+{
+    struct drm_vigs_plane_set_transform *args = data;
+    struct drm_mode_object *obj;
+    struct drm_plane *plane;
+    struct vigs_plane *vigs_plane;
+    int ret;
+
+    drm_modeset_lock_all(drm_dev);
+
+    obj = drm_mode_object_find(drm_dev,
+                               args->plane_id,
+                               DRM_MODE_OBJECT_PLANE);
+    if (!obj) {
+        ret = -EINVAL;
+        goto out;
+    }
+
+    plane = obj_to_plane(obj);
+    vigs_plane = plane_to_vigs_plane(plane);
+
+    vigs_plane->hflip = args->hflip;
+    vigs_plane->vflip = args->vflip;
+    vigs_plane->rotation = args->rotation;
+
+    ret = 0;
+
+out:
+    drm_modeset_unlock_all(drm_dev);
+
+    return ret;
+}
index bb9e90ed144668fae961b6fd53b489c052b42334..327f55c9ff384e1eb160d71e85a2fac7a98c2777 100644 (file)
@@ -22,6 +22,9 @@ struct vigs_plane
     unsigned int crtc_h;
 
     int z_pos;
+    int hflip;
+    int vflip;
+    int rotation;
 
     bool enabled;
 };
@@ -42,6 +45,10 @@ int vigs_plane_set_zpos_ioctl(struct drm_device *drm_dev,
                               void *data,
                               struct drm_file *file_priv);
 
+int vigs_plane_set_transform_ioctl(struct drm_device *drm_dev,
+                                   void *data,
+                                   struct drm_file *file_priv);
+
 /*
  * @}
  */
index 0ed02ccec62a570fd6355b5e043221e196b321b8..1f18cd66699f4468bf1205fcc937ef10efde0c00 100644 (file)
@@ -8,7 +8,7 @@
 /*
  * Bump this whenever protocol changes.
  */
-#define VIGS_PROTOCOL_VERSION 19
+#define VIGS_PROTOCOL_VERSION 20
 
 #define VIGS_MAX_PLANES 2
 
@@ -74,6 +74,14 @@ typedef enum
     vigsp_plane_yuv420 = 0x5
 } vigsp_plane_format;
 
+typedef enum
+{
+    vigsp_rotation0   = 0x0,
+    vigsp_rotation90  = 0x1,
+    vigsp_rotation180 = 0x2,
+    vigsp_rotation270 = 0x3
+} vigsp_rotation;
+
 #pragma pack(1)
 
 struct vigsp_point
@@ -333,6 +341,9 @@ struct vigsp_cmd_set_plane_request
     vigsp_s32 dst_y;
     struct vigsp_size dst_size;
     vigsp_s32 z_pos;
+    vigsp_bool hflip;
+    vigsp_bool vflip;
+    vigsp_rotation rotation;
 };
 
 /*
index 933fc85cac16b599edcd8806148a0be45fdae741..6f036fb907117dd9d1502219164d60f711abba14 100644 (file)
@@ -8,7 +8,7 @@
 /*
  * Bump this whenever driver interface changes.
  */
-#define DRM_VIGS_DRIVER_VERSION 13
+#define DRM_VIGS_DRIVER_VERSION 14
 
 /*
  * Surface access flags.
 #define DRM_VIGS_DP_FB_Y 2
 #define DRM_VIGS_DP_FB_C 3
 
+/*
+ * Rotations.
+ */
+#define DRM_VIGS_ROTATION_0   0
+#define DRM_VIGS_ROTATION_90  1
+#define DRM_VIGS_ROTATION_180 2
+#define DRM_VIGS_ROTATION_270 3
+
 struct drm_vigs_get_protocol_version
 {
     uint32_t version;
@@ -126,6 +134,14 @@ struct drm_vigs_plane_set_zpos
     int zpos;
 };
 
+struct drm_vigs_plane_set_transform
+{
+    uint32_t plane_id;
+    int hflip;
+    int vflip;
+    int rotation;
+};
+
 struct drm_vigs_dp_create_surface
 {
     uint32_t dp_plane;
@@ -163,6 +179,7 @@ struct drm_vigs_dp_open_surface
 #define DRM_VIGS_FENCE_SIGNALED 0x0C
 #define DRM_VIGS_FENCE_UNREF 0x0D
 #define DRM_VIGS_PLANE_SET_ZPOS 0x0E
+#define DRM_VIGS_PLANE_SET_TRANSFORM 0x0F
 
 #define DRM_VIGS_DP_CREATE_SURFACE 0x20
 #define DRM_VIGS_DP_OPEN_SURFACE 0x21
@@ -197,6 +214,8 @@ struct drm_vigs_dp_open_surface
             DRM_VIGS_FENCE_UNREF, struct drm_vigs_fence_unref)
 #define DRM_IOCTL_VIGS_PLANE_SET_ZPOS DRM_IOW(DRM_COMMAND_BASE + \
             DRM_VIGS_PLANE_SET_ZPOS, struct drm_vigs_plane_set_zpos)
+#define DRM_IOCTL_VIGS_PLANE_SET_TRANSFORM DRM_IOW(DRM_COMMAND_BASE + \
+            DRM_VIGS_PLANE_SET_TRANSFORM, struct drm_vigs_plane_set_transform)
 
 #define DRM_IOCTL_VIGS_DP_CREATE_SURFACE DRM_IOWR(DRM_COMMAND_BASE + \
             DRM_VIGS_DP_CREATE_SURFACE, struct drm_vigs_dp_create_surface)