Skip to contentSkip to conversation

drm/qxl: fix cursor position with non-zero hotspot

PATCH Applied John Keeping 3 participants 5 messages Nov 18, 2015 – Feb 9, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/qxl: fix cursor position with non-zero hotspot

The SPICE protocol considers the position of a cursor to be the location of its active pixel on the display, so the cursor is drawn with its top-left corner at "(x - hot_spot_x, y - hot_spot_y)" but the DRM cursor position gives the location where the top-left corner should be drawn, with the hotspot being a hint for drivers that need it.

This fixes the location of the window resize cursors when using Fluxbox with the QXL DRM driver and both the QXL and modesetting X drivers.

---
This comes from the discussion in the thread at [1]. My test environment is using:

- X.Org X Server 1.17.4
- xf86-video-qxl 0.1.4
- spice-gtk3 0.30

[1] http://lists.freedesktop.org/archives/dri-devel/2015-November/thread.html#94650

 drivers/gpu/drm/qxl/qxl_display.c | 13 +++++++++----
 drivers/gpu/drm/qxl/qxl_drv.h     |  2 ++
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +9 -4
index 183aea1..5edebf4 100644
@@ -375,10 +375,15 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
 
 	qxl_bo_kunmap(user_bo);
 
+	qcrtc->cur_x += qcrtc->hot_spot_x - hot_x;
+	qcrtc->cur_y += qcrtc->hot_spot_y - hot_y;
+	qcrtc->hot_spot_x = hot_x;
+	qcrtc->hot_spot_y = hot_y;
+
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
 	cmd->type = QXL_CURSOR_SET;
-	cmd->u.set.position.x = qcrtc->cur_x;
-	cmd->u.set.position.y = qcrtc->cur_y;
+	cmd->u.set.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.set.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 
 	cmd->u.set.shape = qxl_bo_physical_address(qdev, cursor_bo, 0);
 
@@ -441,8 +446,8 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
 
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
 	cmd->type = QXL_CURSOR_MOVE;
-	cmd->u.position.x = qcrtc->cur_x;
-	cmd->u.position.y = qcrtc->cur_y;
+	cmd->u.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 	qxl_release_unmap(qdev, release, &cmd->release_info);
 
 	qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
drivers/gpu/drm/qxl/qxl_drv.h +2 -0
index 01a8694..3ab9017 100644
@@ -135,6 +135,8 @@ struct qxl_crtc {
 	int index;
 	int cur_x;
 	int cur_y;
+	int hot_spot_x;
+	int hot_spot_y;
 };
 
 struct qxl_output {
Signature · 6 lines
2.6.3.462.gbe2c914

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · John Keeping

The SPICE protocol considers the position of a cursor to be the location of its active pixel on the display, so the cursor is drawn with its top-left corner at "(x - hot_spot_x, y - hot_spot_y)" but the DRM cursor position gives the location where the top-left corner should be drawn, with the hotspot being a hint for drivers that need it.

This fixes the location of the window resize cursors when using Fluxbox with the QXL DRM driver and both the QXL and modesetting X drivers.

---
This comes from the discussion in the thread at [1]. My test environment is using:

- X.Org X Server 1.17.4
- xf86-video-qxl 0.1.4
- spice-gtk3 0.30

[1] http://lists.freedesktop.org/archives/dri-devel/2015-November/thread.html#94650

 drivers/gpu/drm/qxl/qxl_display.c | 13 +++++++++----
 drivers/gpu/drm/qxl/qxl_drv.h     |  2 ++
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +0 -0
index 183aea1..5edebf4 100644

drivers/gpu/drm/qxl/qxl_display.c static int qxl_crtc_cursor_set2(struct drm_crtc *crtc, · line 381

Quoted 7 lines
drivers/gpu/drm/qxl/qxl_display.c +4 -0
@@ -375,10 +375,15 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
 
 	qxl_bo_kunmap(user_bo);
 
+	qcrtc->cur_x += qcrtc->hot_spot_x - hot_x;
+	qcrtc->cur_y += qcrtc->hot_spot_y - hot_y;
+	qcrtc->hot_spot_x = hot_x;
+	qcrtc->hot_spot_y = hot_y;

Yay for the artificial split of the legacy driver interface for cursors.

Dave, can you pls pick this up if you agree?

Thanks, Daniel

Quoted 37 lines
drivers/gpu/drm/qxl/qxl_display.c +5 -4
+
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
 	cmd->type = QXL_CURSOR_SET;
-	cmd->u.set.position.x = qcrtc->cur_x;
-	cmd->u.set.position.y = qcrtc->cur_y;
+	cmd->u.set.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.set.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 
 	cmd->u.set.shape = qxl_bo_physical_address(qdev, cursor_bo, 0);
 
@@ -441,8 +446,8 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
 
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
 	cmd->type = QXL_CURSOR_MOVE;
-	cmd->u.position.x = qcrtc->cur_x;
-	cmd->u.position.y = qcrtc->cur_y;
+	cmd->u.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 	qxl_release_unmap(qdev, release, &cmd->release_info);
 
 	qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
drivers/gpu/drm/qxl/qxl_drv.h +2 -0
index 01a8694..3ab9017 100644
@@ -135,6 +135,8 @@ struct qxl_crtc {
 	int index;
 	int cur_x;
 	int cur_y;
+	int hot_spot_x;
+	int hot_spot_y;
 };
 
 struct qxl_output {
Signature · 1 line
2.6.3.462.gbe2c914
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 44 lines · Daniel Vetter
Quoted 32 lines · John Keeping

The SPICE protocol considers the position of a cursor to be the location of its active pixel on the display, so the cursor is drawn with its top-left corner at "(x - hot_spot_x, y - hot_spot_y)" but the DRM cursor position gives the location where the top-left corner should be drawn, with the hotspot being a hint for drivers that need it.

This fixes the location of the window resize cursors when using Fluxbox with the QXL DRM driver and both the QXL and modesetting X drivers.

---
This comes from the discussion in the thread at [1]. My test environment is using:

- X.Org X Server 1.17.4
- xf86-video-qxl 0.1.4
- spice-gtk3 0.30

[1]
http://lists.freedesktop.org/archives/dri-devel/2015-November/thread.html#94650

 drivers/gpu/drm/qxl/qxl_display.c | 13 +++++++++----
 drivers/gpu/drm/qxl/qxl_drv.h     |  2 ++
 2 files changed, 11 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/qxl/qxl_display.c index 183aea1..5edebf4 100644

drivers/gpu/drm/qxl/qxl_display.c static int qxl_crtc_cursor_set2(struct · line 381

Quoted 7 lines
drivers/gpu/drm/qxl/qxl_display.c +4 -0
@@ -375,10 +375,15 @@ static int qxl_crtc_cursor_set2(struct
 drm_crtc *crtc, 
 	qxl_bo_kunmap(user_bo);
 
+	qcrtc->cur_x += qcrtc->hot_spot_x - hot_x;
+	qcrtc->cur_y += qcrtc->hot_spot_y - hot_y;
+	qcrtc->hot_spot_x = hot_x;
+	qcrtc->hot_spot_y = hot_y;  

Yay for the artificial split of the legacy driver interface for cursors.

Quoted 4 lines

Dave, can you pls pick this up if you agree?

Ping?

Quoted 33 lines
Quoted 33 lines
drivers/gpu/drm/qxl/qxl_display.c +5 -4
+
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev,
 release); cmd->type = QXL_CURSOR_SET;
-	cmd->u.set.position.x = qcrtc->cur_x;
-	cmd->u.set.position.y = qcrtc->cur_y;
+	cmd->u.set.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.set.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 
 	cmd->u.set.shape = qxl_bo_physical_address(qdev,
 cursor_bo, 0); 
@@ -441,8 +446,8 @@ static int qxl_crtc_cursor_move(struct drm_crtc
 *crtc, 
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev,
 release); cmd->type = QXL_CURSOR_MOVE;
-	cmd->u.position.x = qcrtc->cur_x;
-	cmd->u.position.y = qcrtc->cur_y;
+	cmd->u.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 	qxl_release_unmap(qdev, release, &cmd->release_info);
 
 	qxl_push_cursor_ring_release(qdev, release,

QXL_CMD_CURSOR, false); diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h index 01a8694..3ab9017 100644

drivers/gpu/drm/qxl/qxl_drv.h +2 -0
@@ -135,6 +135,8 @@ struct qxl_crtc {
 	int index;
 	int cur_x;
 	int cur_y;
+	int hot_spot_x;
+	int hot_spot_y;
 };
 
Quoted 5 lines
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.h +0 -0
 struct qxl_output {
Signature · 1 line
2.6.3.462.gbe2c914

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

I haven't seen this get picked up. Is there something wrong with the patch or was it just lost in the noise?

Quoted 46 lines · On Thu, 3 Dec 2015 10:46:07 +0000 John Keeping wrote:
Quoted 44 lines · Daniel Vetter
Quoted 32 lines · John Keeping

The SPICE protocol considers the position of a cursor to be the location of its active pixel on the display, so the cursor is drawn with its top-left corner at "(x - hot_spot_x, y - hot_spot_y)" but the DRM cursor position gives the location where the top-left corner should be drawn, with the hotspot being a hint for drivers that need it.

This fixes the location of the window resize cursors when using Fluxbox with the QXL DRM driver and both the QXL and modesetting X drivers.

---
This comes from the discussion in the thread at [1]. My test environment is using:

- X.Org X Server 1.17.4
- xf86-video-qxl 0.1.4
- spice-gtk3 0.30

[1]
http://lists.freedesktop.org/archives/dri-devel/2015-November/thread.html#94650

 drivers/gpu/drm/qxl/qxl_display.c | 13 +++++++++----
 drivers/gpu/drm/qxl/qxl_drv.h     |  2 ++
 2 files changed, 11 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/qxl/qxl_display.c index 183aea1..5edebf4 100644

drivers/gpu/drm/qxl/qxl_display.c static int qxl_crtc_cursor_set2(struct · line 381

Quoted 7 lines
drivers/gpu/drm/qxl/qxl_display.c +4 -0
@@ -375,10 +375,15 @@ static int qxl_crtc_cursor_set2(struct
 drm_crtc *crtc, 
 	qxl_bo_kunmap(user_bo);
 
+	qcrtc->cur_x += qcrtc->hot_spot_x - hot_x;
+	qcrtc->cur_y += qcrtc->hot_spot_y - hot_y;
+	qcrtc->hot_spot_x = hot_x;
+	qcrtc->hot_spot_y = hot_y;    

Yay for the artificial split of the legacy driver interface for cursors.

Quoted 45 lines
Quoted 4 lines

Dave, can you pls pick this up if you agree?

Ping?

Quoted 38 lines
Quoted 37 lines
drivers/gpu/drm/qxl/qxl_display.c +5 -4
+
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev,
 release); cmd->type = QXL_CURSOR_SET;
-	cmd->u.set.position.x = qcrtc->cur_x;
-	cmd->u.set.position.y = qcrtc->cur_y;
+	cmd->u.set.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.set.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 
 	cmd->u.set.shape = qxl_bo_physical_address(qdev,
 cursor_bo, 0); 
@@ -441,8 +446,8 @@ static int qxl_crtc_cursor_move(struct drm_crtc
 *crtc, 
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev,
 release); cmd->type = QXL_CURSOR_MOVE;
-	cmd->u.position.x = qcrtc->cur_x;
-	cmd->u.position.y = qcrtc->cur_y;
+	cmd->u.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 	qxl_release_unmap(qdev, release, &cmd->release_info);
 
 	qxl_push_cursor_ring_release(qdev, release,

QXL_CMD_CURSOR, false); diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h index 01a8694..3ab9017 100644

drivers/gpu/drm/qxl/qxl_drv.h +2 -0
@@ -135,6 +135,8 @@ struct qxl_crtc {
 	int index;
 	int cur_x;
 	int cur_y;
+	int hot_spot_x;
+	int hot_spot_y;
 };
 
 struct qxl_output {
Signature · 1 line
2.6.3.462.gbe2c914

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Applied
#4 lore raw
Quoted 2 lines · John Keeping

I haven't seen this get picked up. Is there something wrong with the patch or was it just lost in the noise?

I picked this up in our drm-fixes branch, and will send it on to Dave.

BR,
Jani.

Quoted 99 lines · On Thu, 3 Dec 2015 10:46:07 +0000 John Keeping wrote:
Quoted 47 lines · Daniel Vetter
Quoted 45 lines · John Keeping
Quoted 32 lines

The SPICE protocol considers the position of a cursor to be the location of its active pixel on the display, so the cursor is drawn with its top-left corner at "(x - hot_spot_x, y - hot_spot_y)" but the DRM cursor position gives the location where the top-left corner should be drawn, with the hotspot being a hint for drivers that need it.

This fixes the location of the window resize cursors when using Fluxbox with the QXL DRM driver and both the QXL and modesetting X drivers.

---
This comes from the discussion in the thread at [1]. My test environment is using:

- X.Org X Server 1.17.4
- xf86-video-qxl 0.1.4
- spice-gtk3 0.30

[1]
http://lists.freedesktop.org/archives/dri-devel/2015-November/thread.html#94650

 drivers/gpu/drm/qxl/qxl_display.c | 13 +++++++++----
 drivers/gpu/drm/qxl/qxl_drv.h     |  2 ++
 2 files changed, 11 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/qxl/qxl_display.c index 183aea1..5edebf4 100644

drivers/gpu/drm/qxl/qxl_display.c static int qxl_crtc_cursor_set2(struct · line 381

Quoted 7 lines
drivers/gpu/drm/qxl/qxl_display.c +4 -0
@@ -375,10 +375,15 @@ static int qxl_crtc_cursor_set2(struct
 drm_crtc *crtc, 
 	qxl_bo_kunmap(user_bo);
 
+	qcrtc->cur_x += qcrtc->hot_spot_x - hot_x;
+	qcrtc->cur_y += qcrtc->hot_spot_y - hot_y;
+	qcrtc->hot_spot_x = hot_x;
+	qcrtc->hot_spot_y = hot_y;    

Yay for the artificial split of the legacy driver interface for cursors.

Quoted 45 lines
Quoted 4 lines

Dave, can you pls pick this up if you agree?

Ping?

Quoted 38 lines
Quoted 37 lines
drivers/gpu/drm/qxl/qxl_display.c +5 -4
+
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev,
 release); cmd->type = QXL_CURSOR_SET;
-	cmd->u.set.position.x = qcrtc->cur_x;
-	cmd->u.set.position.y = qcrtc->cur_y;
+	cmd->u.set.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.set.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 
 	cmd->u.set.shape = qxl_bo_physical_address(qdev,
 cursor_bo, 0); 
@@ -441,8 +446,8 @@ static int qxl_crtc_cursor_move(struct drm_crtc
 *crtc, 
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev,
 release); cmd->type = QXL_CURSOR_MOVE;
-	cmd->u.position.x = qcrtc->cur_x;
-	cmd->u.position.y = qcrtc->cur_y;
+	cmd->u.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 	qxl_release_unmap(qdev, release, &cmd->release_info);
 
 	qxl_push_cursor_ring_release(qdev, release,

QXL_CMD_CURSOR, false); diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h index 01a8694..3ab9017 100644

drivers/gpu/drm/qxl/qxl_drv.h +2 -0
@@ -135,6 +135,8 @@ struct qxl_crtc {
 	int index;
 	int cur_x;
 	int cur_y;
+	int hot_spot_x;
+	int hot_spot_y;
 };
 
 struct qxl_output {
Signature · 1 line
2.6.3.462.gbe2c914

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel