]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
drm: add hotspot support for cursors.
authorDave Airlie <airlied@redhat.com>
Thu, 20 Jun 2013 01:48:52 +0000 (11:48 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 27 Jun 2013 23:13:39 +0000 (09:13 +1000)
So it looks like for virtual hw cursors on QXL we need to inform
the "hw" device what the cursor hotspot parameters are. This
makes sense if you think the host has to draw the cursor and interpret
clicks from it. However the current modesetting interface doesn't support
passing the hotspot information from userspace.

This implements a new cursor ioctl, that takes the hotspot info as well,
userspace can try calling the new interface and if it gets -ENOSYS it means
its on an older kernel and can just fallback.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_drv.c
include/drm/drm_crtc.h
include/uapi/drm/drm.h
include/uapi/drm/drm_mode.h

index 02838e66af76e8578806d956939492fe2b47bf5e..fc83bb9eb51459cbdf5a1288fad6fa1c77d25b41 100644 (file)
@@ -2178,10 +2178,10 @@ out:
        return ret;
 }
 
-int drm_mode_cursor_ioctl(struct drm_device *dev,
-                       void *data, struct drm_file *file_priv)
+static int drm_mode_cursor_common(struct drm_device *dev,
+                                 struct drm_mode_cursor2 *req,
+                                 struct drm_file *file_priv)
 {
-       struct drm_mode_cursor *req = data;
        struct drm_mode_object *obj;
        struct drm_crtc *crtc;
        int ret = 0;
@@ -2201,13 +2201,17 @@ int drm_mode_cursor_ioctl(struct drm_device *dev,
 
        mutex_lock(&crtc->mutex);
        if (req->flags & DRM_MODE_CURSOR_BO) {
-               if (!crtc->funcs->cursor_set) {
+               if (!crtc->funcs->cursor_set && !crtc->funcs->cursor_set2) {
                        ret = -ENXIO;
                        goto out;
                }
                /* Turns off the cursor if handle is 0 */
-               ret = crtc->funcs->cursor_set(crtc, file_priv, req->handle,
-                                             req->width, req->height);
+               if (crtc->funcs->cursor_set2)
+                       ret = crtc->funcs->cursor_set2(crtc, file_priv, req->handle,
+                                                     req->width, req->height, req->hot_x, req->hot_y);
+               else
+                       ret = crtc->funcs->cursor_set(crtc, file_priv, req->handle,
+                                                     req->width, req->height);
        }
 
        if (req->flags & DRM_MODE_CURSOR_MOVE) {
@@ -2222,6 +2226,25 @@ out:
        mutex_unlock(&crtc->mutex);
 
        return ret;
+
+}
+int drm_mode_cursor_ioctl(struct drm_device *dev,
+                       void *data, struct drm_file *file_priv)
+{
+       struct drm_mode_cursor *req = data;
+       struct drm_mode_cursor2 new_req;
+
+       memcpy(&new_req, req, sizeof(struct drm_mode_cursor));
+       new_req.hot_x = new_req.hot_y = 0;
+
+       return drm_mode_cursor_common(dev, &new_req, file_priv);
+}
+
+int drm_mode_cursor2_ioctl(struct drm_device *dev,
+                          void *data, struct drm_file *file_priv)
+{
+       struct drm_mode_cursor2 *req = data;
+       return drm_mode_cursor_common(dev, req, file_priv);
 }
 
 /* Original addfb only supported RGB formats, so figure out which one */
index 9cc247f555028f41046cbacd57a6b31cdf8f5e20..99fcd7c32ea2dea50c652576646446a1fd5cab37 100644 (file)
@@ -166,6 +166,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
        DRM_IOCTL_DEF(DRM_IOCTL_MODE_DESTROY_DUMB, drm_mode_destroy_dumb_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
        DRM_IOCTL_DEF(DRM_IOCTL_MODE_OBJ_GETPROPERTIES, drm_mode_obj_get_properties_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
        DRM_IOCTL_DEF(DRM_IOCTL_MODE_OBJ_SETPROPERTY, drm_mode_obj_set_property_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_IOCTL_MODE_CURSOR2, drm_mode_cursor2_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 };
 
 #define DRM_CORE_IOCTL_COUNT   ARRAY_SIZE( drm_ioctls )
index 0fd007af8de9e3d24a9a5e2f7cfff9cd6f6a81de..663c3ab47752151aac0456b77097262690b27749 100644 (file)
@@ -339,6 +339,9 @@ struct drm_crtc_funcs {
        /* cursor controls */
        int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
                          uint32_t handle, uint32_t width, uint32_t height);
+       int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv,
+                          uint32_t handle, uint32_t width, uint32_t height,
+                          int32_t hot_x, int32_t hot_y);
        int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
 
        /* Set gamma on the CRTC */
@@ -1018,6 +1021,8 @@ extern int drm_mode_setplane(struct drm_device *dev,
                               void *data, struct drm_file *file_priv);
 extern int drm_mode_cursor_ioctl(struct drm_device *dev,
                                void *data, struct drm_file *file_priv);
+extern int drm_mode_cursor2_ioctl(struct drm_device *dev,
+                               void *data, struct drm_file *file_priv);
 extern int drm_mode_addfb(struct drm_device *dev,
                          void *data, struct drm_file *file_priv);
 extern int drm_mode_addfb2(struct drm_device *dev,
index 5a57be68bab70da62e2f3218bdf34d87b72a2d6e..238a166b9fe6091935d8357f5898510fe220ad4d 100644 (file)
@@ -732,6 +732,7 @@ struct drm_prime_handle {
 #define DRM_IOCTL_MODE_ADDFB2          DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)
 #define DRM_IOCTL_MODE_OBJ_GETPROPERTIES       DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)
 #define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_set_property)
+#define DRM_IOCTL_MODE_CURSOR2         DRM_IOWR(0xBB, struct drm_mode_cursor2)
 
 /**
  * Device specific ioctls should only be in their respective headers
index 090e5331ab7eabe0c6c779d4eb44d02ff558f78d..53db7cea373bedfb5aebe9ec4bda9ed9c9a2cb26 100644 (file)
@@ -388,6 +388,19 @@ struct drm_mode_cursor {
        __u32 handle;
 };
 
+struct drm_mode_cursor2 {
+       __u32 flags;
+       __u32 crtc_id;
+       __s32 x;
+       __s32 y;
+       __u32 width;
+       __u32 height;
+       /* driver specific handle */
+       __u32 handle;
+       __s32 hot_x;
+       __s32 hot_y;
+};
+
 struct drm_mode_crtc_lut {
        __u32 crtc_id;
        __u32 gamma_size;