diff mbox series

fix gvtg cursor position if it is negative

Message ID SYZP282MB32524DE09ADA28D4E4205D49C9F39@SYZP282MB3252.AUSP282.PROD.OUTLOOK.COM (mailing list archive)
State New, archived
Headers show
Series fix gvtg cursor position if it is negative | expand

Commit Message

qi zhou Dec. 29, 2022, 1:19 p.m. UTC
From 4f14d6216d3f05f01ffe419ff0baeebe416a3e58 Mon Sep 17 00:00:00 2001
From: Qi Zhou <atmgnd@outlook.com>
Date: Thu, 29 Dec 2022 20:25:06 +0800
Subject: [PATCH] fix gvtg cursor position if it is negative

It is valid if position of cursor is negative(not hotspot coordinates). for
example: precision section, resize, move, north east arrow...

Signed-off-by: Qi Zhou <atmgnd@outlook.com>
---
 include/hw/vfio/vfio-common.h | 6 ++++--
 include/ui/console.h          | 4 ++--
 include/ui/gtk.h              | 2 +-
 linux-headers/linux/vfio.h    | 4 ++--
 ui/console.c                  | 2 +-
 ui/dbus-listener.c            | 2 +-
 ui/egl-headless.c             | 2 +-
 ui/gtk-egl.c                  | 2 +-
 ui/spice-display.c            | 2 +-
 9 files changed, 14 insertions(+), 12 deletions(-)

Comments

qi zhou Dec. 29, 2022, 1:30 p.m. UTC | #1
To test, you need patch linux kernel too, I paste it here for convenience, and it have been sent to kernel devel mailling list

also I have record two video for this patch, see https://1drv.ms/u/s!As-Ec5SPH0fuiy6ejq7TXOl8QenV?e=Lzh97y

From 8d2a0c2c265119cb481deab825ea59c9605f3bd8 Mon Sep 17 00:00:00 2001
From: Qi Zhou <atmgnd@outlook.com>
Date: Thu, 29 Dec 2022 20:15:51 +0800
Subject: [PATCH] fix gvtg cursor position if it is negative

It is valid if position of cursor is negative(not hotspot coordinates). for
example: precision section, resize, move, north east arrow...

Signed-off-by: Qi Zhou <atmgnd@outlook.com>
---
 drivers/gpu/drm/i915/gvt/dmabuf.c | 5 ++---
 drivers/gpu/drm/i915/gvt/dmabuf.h | 4 ++--
 include/uapi/linux/vfio.h         | 4 ++--
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c b/drivers/gpu/drm/i915/gvt/dmabuf.c
index 355f1c0e8664..b91122b33222 100644
--- a/drivers/gpu/drm/i915/gvt/dmabuf.c
+++ b/drivers/gpu/drm/i915/gvt/dmabuf.c
@@ -299,9 +299,8 @@ static int vgpu_get_plane_info(struct drm_device *dev,
 		info->stride = c.width * (c.bpp / 8);
 		info->drm_format = c.drm_format;
 		info->drm_format_mod = 0;
-		info->x_pos = c.x_pos;
-		info->y_pos = c.y_pos;
-
+		info->x_pos = c.x_sign ? -c.x_pos : c.x_pos;
+		info->y_pos = c.y_sign ? -c.y_pos : c.y_pos;
 		if (validate_hotspot(&c)) {
 			info->x_hot = c.x_hot;
 			info->y_hot = c.y_hot;
diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.h b/drivers/gpu/drm/i915/gvt/dmabuf.h
index 3dcdb6570eda..4103106d7cc2 100644
--- a/drivers/gpu/drm/i915/gvt/dmabuf.h
+++ b/drivers/gpu/drm/i915/gvt/dmabuf.h
@@ -41,8 +41,8 @@ struct intel_vgpu_fb_info {
 	__u32 height;	/* height of plane */
 	__u32 stride;	/* stride of plane */
 	__u32 size;	/* size of plane in bytes, align on page */
-	__u32 x_pos;	/* horizontal position of cursor plane */
-	__u32 y_pos;	/* vertical position of cursor plane */
+	__s32 x_pos;	/* horizontal position of cursor plane */
+	__s32 y_pos;	/* vertical position of cursor plane */
 	__u32 x_hot;    /* horizontal position of cursor hotspot */
 	__u32 y_hot;    /* vertical position of cursor hotspot */
 	struct intel_vgpu_dmabuf_obj *obj;
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 23105eb036fa..a9b93251ac7f 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -720,8 +720,8 @@ struct vfio_device_gfx_plane_info {
 	__u32 height;	/* height of plane */
 	__u32 stride;	/* stride of plane */
 	__u32 size;	/* size of plane in bytes, align on page*/
-	__u32 x_pos;	/* horizontal position of cursor plane */
-	__u32 y_pos;	/* vertical position of cursor plane*/
+	__s32 x_pos;	/* horizontal position of cursor plane */
+	__s32 y_pos;	/* vertical position of cursor plane*/
 	__u32 x_hot;    /* horizontal position of cursor hotspot */
 	__u32 y_hot;    /* vertical position of cursor hotspot */
 	union {
diff mbox series

Patch

diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index e573f5a9f1..8048816176 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -166,8 +166,10 @@  typedef struct VFIOGroup {
 
 typedef struct VFIODMABuf {
     QemuDmaBuf buf;
-    uint32_t pos_x, pos_y, pos_updates;
-    uint32_t hot_x, hot_y, hot_updates;
+    int32_t pos_x, pos_y;
+    uint32_t pos_updates;
+    uint32_t hot_x, hot_y;
+    uint32_t hot_updates;
     int dmabuf_id;
     QTAILQ_ENTRY(VFIODMABuf) next;
 } VFIODMABuf;
diff --git a/include/ui/console.h b/include/ui/console.h
index e400ee9fa7..589d0fd621 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -264,7 +264,7 @@  typedef struct DisplayChangeListenerOps {
                                  uint32_t hot_x, uint32_t hot_y);
     /* optional */
     void (*dpy_gl_cursor_position)(DisplayChangeListener *dcl,
-                                   uint32_t pos_x, uint32_t pos_y);
+                                   int32_t pos_x, int32_t pos_y);
     /* optional */
     void (*dpy_gl_release_dmabuf)(DisplayChangeListener *dcl,
                                   QemuDmaBuf *dmabuf);
@@ -362,7 +362,7 @@  void dpy_gl_scanout_dmabuf(QemuConsole *con,
 void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf,
                           bool have_hot, uint32_t hot_x, uint32_t hot_y);
 void dpy_gl_cursor_position(QemuConsole *con,
-                            uint32_t pos_x, uint32_t pos_y);
+                            int32_t pos_x, int32_t pos_y);
 void dpy_gl_release_dmabuf(QemuConsole *con,
                            QemuDmaBuf *dmabuf);
 void dpy_gl_update(QemuConsole *con,
diff --git a/include/ui/gtk.h b/include/ui/gtk.h
index ae0f53740d..bb28360185 100644
--- a/include/ui/gtk.h
+++ b/include/ui/gtk.h
@@ -182,7 +182,7 @@  void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl,
                           QemuDmaBuf *dmabuf, bool have_hot,
                           uint32_t hot_x, uint32_t hot_y);
 void gd_egl_cursor_position(DisplayChangeListener *dcl,
-                            uint32_t pos_x, uint32_t pos_y);
+                            int32_t pos_x, int32_t pos_y);
 void gd_egl_flush(DisplayChangeListener *dcl,
                   uint32_t x, uint32_t y, uint32_t w, uint32_t h);
 void gd_egl_scanout_flush(DisplayChangeListener *dcl,
diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
index ede44b5572..646db069b8 100644
--- a/linux-headers/linux/vfio.h
+++ b/linux-headers/linux/vfio.h
@@ -720,8 +720,8 @@  struct vfio_device_gfx_plane_info {
 	__u32 height;	/* height of plane */
 	__u32 stride;	/* stride of plane */
 	__u32 size;	/* size of plane in bytes, align on page*/
-	__u32 x_pos;	/* horizontal position of cursor plane */
-	__u32 y_pos;	/* vertical position of cursor plane*/
+	__s32 x_pos;	/* horizontal position of cursor plane */
+	__s32 y_pos;	/* vertical position of cursor plane*/
 	__u32 x_hot;    /* horizontal position of cursor hotspot */
 	__u32 y_hot;    /* vertical position of cursor hotspot */
 	union {
diff --git a/ui/console.c b/ui/console.c
index 9ff9217f9b..8dffacf07d 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2049,7 +2049,7 @@  void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf,
 }
 
 void dpy_gl_cursor_position(QemuConsole *con,
-                            uint32_t pos_x, uint32_t pos_y)
+                            int32_t pos_x, int32_t pos_y)
 {
     DisplayState *s = con->ds;
     DisplayChangeListener *dcl;
diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c
index f9fc8eda51..43c00b7a75 100644
--- a/ui/dbus-listener.c
+++ b/ui/dbus-listener.c
@@ -188,7 +188,7 @@  static void dbus_cursor_dmabuf(DisplayChangeListener *dcl,
 }
 
 static void dbus_cursor_position(DisplayChangeListener *dcl,
-                                 uint32_t pos_x, uint32_t pos_y)
+                                 int32_t pos_x, int32_t pos_y)
 {
     DBusDisplayListener *ddl = container_of(dcl, DBusDisplayListener, dcl);
 
diff --git a/ui/egl-headless.c b/ui/egl-headless.c
index 7a30fd9777..7a03b08d46 100644
--- a/ui/egl-headless.c
+++ b/ui/egl-headless.c
@@ -110,7 +110,7 @@  static void egl_cursor_dmabuf(DisplayChangeListener *dcl,
 }
 
 static void egl_cursor_position(DisplayChangeListener *dcl,
-                                uint32_t pos_x, uint32_t pos_y)
+                                int32_t pos_x, int32_t pos_y)
 {
     egl_dpy *edpy = container_of(dcl, egl_dpy, dcl);
 
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index e84431790c..a454402212 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -286,7 +286,7 @@  void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl,
 }
 
 void gd_egl_cursor_position(DisplayChangeListener *dcl,
-                            uint32_t pos_x, uint32_t pos_y)
+                            int32_t pos_x, int32_t pos_y)
 {
     VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
 
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 494168e7fe..347c3917bf 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -1002,7 +1002,7 @@  static void qemu_spice_gl_cursor_dmabuf(DisplayChangeListener *dcl,
 }
 
 static void qemu_spice_gl_cursor_position(DisplayChangeListener *dcl,
-                                          uint32_t pos_x, uint32_t pos_y)
+                                          int32_t pos_x, int32_t pos_y)
 {
     SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);