Mailinglist Archive: radeonhd (427 mails)

< Previous Next >
[radeonhd] Re: [PATCH] refactored RandR cursor code plus fix for bug #13405
  • From: Yang Zhao <yang@xxxxxxxxxx>
  • Date: Mon, 4 May 2009 15:27:00 -0700
  • Message-id: <40a7b1aa0905041527i16249ca1ma1e1e571475d3c98@xxxxxxxxxxxxxx>
Round 2.

Alex managed to find the root of the easy cursor corruption issue: the
cursor mode should be the same for both CRTCs even when disabled. This
is 0001.

0002 is the refactoring. It's almost trivial now that we don't need
the logic to keep the cursor enabled on both CRTCs.

0003 contains the multiple-of-128px and outside-viewport code with
some tweaks, and is thus different from radeon. My system that's set
up with dual-screen doesn't seem to be panning capable, so the
viewport part is untested; please scrutinize 0003 with extra
attention.

--
Yang Zhao
http://yangman.ca
From 509804345a480205075b2016e833cd141e1541d2 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Mon, 4 May 2009 13:31:42 -0700
Subject: [PATCH] Cursor: Do not change cursor mode when disabling; fixes bug
#13405

Alex finally found the real cause of the cursor corruption issue. Yay!

Signed-off-by: Yang Zhao <yang@xxxxxxxxxx>
---
src/rhd_cursor.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/rhd_cursor.c b/src/rhd_cursor.c
index eb4a948..3a0c7a9 100644
--- a/src/rhd_cursor.c
+++ b/src/rhd_cursor.c
@@ -100,11 +100,12 @@ setCursorSize(struct rhdCursor *Cursor, CARD32 width,
CARD32 height)
static void
enableCursor(struct rhdCursor *Cursor, Bool Enable)
{
+ /* Make sure mode stays the same even when disabled; bug #13405 */
if (Enable)
/* pre-multiplied ARGB, Enable */
RHDRegWrite(Cursor, Cursor->RegOffset + D1CUR_CONTROL, 0x00000201);
else
- RHDRegWrite(Cursor, Cursor->RegOffset + D1CUR_CONTROL, 0);
+ RHDRegWrite(Cursor, Cursor->RegOffset + D1CUR_CONTROL, 0x00000200);
}

/* Activate already uploaded cursor image. */
--
1.6.0.6

From 4cf6897e9449ad025f40844d0305620fac221374 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Sun, 26 Apr 2009 15:31:29 -0700
Subject: [PATCH] Cursor: refactor RandR cursor code

Eliminate calls to displayCursor() and generally reduce the number of
register writes.

Signed-off-by: Yang Zhao <yang@xxxxxxxxxx>
---
src/rhd_cursor.c | 33 ++++++++++++++++++++++++---------
1 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/src/rhd_cursor.c b/src/rhd_cursor.c
index 3a0c7a9..a2b52b1 100644
--- a/src/rhd_cursor.c
+++ b/src/rhd_cursor.c
@@ -625,10 +625,9 @@ void
rhdCrtcShowCursor(struct rhdCrtc *Crtc)
{
struct rhdCursor *Cursor = Crtc->Cursor;
-
- lockCursor (Cursor, TRUE);
- displayCursor(Crtc, TRUE);
- lockCursor (Cursor, FALSE);
+ lockCursor(Cursor, TRUE);
+ enableCursor(Cursor, TRUE);
+ lockCursor(Cursor, FALSE);
}

/*
@@ -638,10 +637,9 @@ void
rhdCrtcHideCursor(struct rhdCrtc *Crtc)
{
struct rhdCursor *Cursor = Crtc->Cursor;
-
- lockCursor (Cursor, TRUE);
+ lockCursor(Cursor, TRUE);
enableCursor(Cursor, FALSE);
- lockCursor (Cursor, FALSE);
+ lockCursor(Cursor, FALSE);
}

/*
@@ -651,11 +649,27 @@ void
rhdCrtcSetCursorPosition(struct rhdCrtc *Crtc, int x, int y)
{
struct rhdCursor *Cursor = Crtc->Cursor;
+ int hotx, hoty;
+
Cursor->X = x;
Cursor->Y = y;

+ hotx = 0;
+ hoty = 0;
+
+ /* Hardware doesn't allow negative cursor pos; compensate using hotspot */
+ if (x < 0) {
+ hotx = -x;
+ x = 0;
+ }
+ if (y < 0) {
+ hoty = -y;
+ y = 0;
+ }
+
lockCursor (Cursor, TRUE);
- displayCursor(Crtc, TRUE);
+ RHDRegWrite(Cursor, Cursor->RegOffset + D1CUR_POSITION, x << 16 | y);
+ RHDRegWrite(Cursor, Cursor->RegOffset + D1CUR_HOT_SPOT, hotx << 16 | hoty);
lockCursor (Cursor, FALSE);
}

@@ -679,13 +693,14 @@ rhdCrtcLoadCursorARGB(struct rhdCrtc *Crtc, CARD32 *Image)
{
struct rhdCursor *Cursor = Crtc->Cursor;

+ /* X server always loads cursors that are the maximum allowed size */
Cursor->Width = MAX_CURSOR_WIDTH;
Cursor->Height = MAX_CURSOR_HEIGHT;

lockCursor (Cursor, TRUE);
uploadCursorImage(Cursor, Image);
setCursorImage (Cursor);
- displayCursor (Crtc, Crtc->Active);
+ setCursorSize(Cursor, Cursor->Width, Cursor->Height);
lockCursor (Cursor, FALSE);
}

--
1.6.0.6

From 6c61f570e0e1812e37873145e3029f61b723a15e Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Mon, 4 May 2009 13:38:27 -0700
Subject: [PATCH] Cursor: Fix remaning corruption cases

Port of f668cc06cd7f338888a7dce1507026af0e9e36ad to new code

Found by Alex:
Apparently the cursor image cannot end on a multiple of 128 pixels.
Also, for panning, the end of the cursor image cannot extend past
the end of the viewport.

Signed-off-by: Yang Zhao <yang@xxxxxxxxxx>
---
src/rhd_cursor.c | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/src/rhd_cursor.c b/src/rhd_cursor.c
index a2b52b1..c9823ff 100644
--- a/src/rhd_cursor.c
+++ b/src/rhd_cursor.c
@@ -649,7 +649,7 @@ void
rhdCrtcSetCursorPosition(struct rhdCrtc *Crtc, int x, int y)
{
struct rhdCursor *Cursor = Crtc->Cursor;
- int hotx, hoty;
+ int hotx, hoty, width, cursor_end, frame_end;

Cursor->X = x;
Cursor->Y = y;
@@ -667,7 +667,33 @@ rhdCrtcSetCursorPosition(struct rhdCrtc *Crtc, int x, int
y)
y = 0;
}

+ /* Work around rare corruption cases by adjusting cursor size;
+ * related to bug #13405
+ * - Cursor's right-edge must not end on multiples of 128px.
+ * - For panning, cursor image cannot horizontally extend past end of
viewport.
+ */
+ width = Cursor->Width;
+ cursor_end = x + width;
+ frame_end = Crtc->X + Crtc->Width;
+
+ if (cursor_end > frame_end) {
+ width -= cursor_end - frame_end;
+ cursor_end = x + width;
+ }
+ if (! (cursor_end & 0x7f)) {
+ width--;
+ }
+ /* If the cursor is effectively invisible, move it out of visible area */
+ if (width <= 0) {
+ width = 1;
+ x = 0;
+ y = Crtc->Y + Crtc->Height;
+ hotx = 0;
+ hoty = 0;
+ }
+
lockCursor (Cursor, TRUE);
+ setCursorSize(Cursor, width, Cursor->Height);
RHDRegWrite(Cursor, Cursor->RegOffset + D1CUR_POSITION, x << 16 | y);
RHDRegWrite(Cursor, Cursor->RegOffset + D1CUR_HOT_SPOT, hotx << 16 | hoty);
lockCursor (Cursor, FALSE);
--
1.6.0.6

< Previous Next >