[PATCH] fix gvtg cursor position if it is negative
From: qi zhou
Date: Thu Dec 29 2022 - 08:17:57 EST
>From 8d2a0c2c265119cb481deab825ea59c9605f3bd8 Mon Sep 17 00:00:00 2001
From: Qi Zhou <atmgnd@xxxxxxxxxxx>
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@xxxxxxxxxxx>
---
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 {
--
2.25.1