[openchrome-devel] xf86-video-openchrome: Branch 'main' - 2 commits - configure.ac src/via_display.c src/via_driver.c src/via_driver.h
Kevin Brace
kevinbrace at kemper.freedesktop.org
Wed Jul 14 22:56:39 UTC 2021
configure.ac | 2
src/via_display.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++-----
src/via_driver.c | 10 +++
src/via_driver.h | 2
4 files changed, 139 insertions(+), 15 deletions(-)
New commits:
commit b33b9b20d0e043c6bec2074181f75d3ff585b6ce
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Wed Jul 14 17:54:09 2021 -0500
Version bumped to 0.6.405
Use bi-color hardware cursor on CLE266 and KM400 chipsets. Note
that due to hardware limitation, only one CRTC (IGA1 or IGA2) can
display the cursor.
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/configure.ac b/configure.ac
index f2f4086..b85e64d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xf86-video-openchrome],
- [0.6.404],
+ [0.6.405],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/openchrome],
[xf86-video-openchrome])
commit 9dec320b2868a42765bc9467970b8372a3fd2897
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Wed Jul 14 17:37:47 2021 -0500
Activate hardware cursor for CLE266 and KM400 chipsets
Unfortunately, the current HI (Hardware Icon) based overlay cursor
code does not work properly on CLE266 and KM400 chipsets. Instead,
use bi-color hardware cursor on these platforms. The limitation
of the code is that it can only display the hardware cursor on one
CRTC (IGA1 or IGA2). This is due to hardware limitation.
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/src/via_display.c b/src/via_display.c
index 66d6142..ae4fb54 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -175,6 +175,83 @@ viaIGA1SetGamma(ScrnInfoPtr pScrn, CARD8 gammaCorrection)
"Exiting viaIGA1SetGamma.\n"));
}
+/*
+ * This function displays or hides hardware cursor (HC).
+ */
+static void
+viaSelectIGAHC(ScrnInfoPtr pScrn, Bool igaSelect)
+{
+ VIAPtr pVia = VIAPTR(pScrn);
+ uint32_t temp;
+
+ temp = VIAGETREG(VIA_REG_CURSOR_MODE);
+ temp &= 0x7FFFFFFF;
+ temp |= igaSelect ? 0x80000000 : 0x00000000;
+
+ /* VIA_REG_CURSOR_MODE[31] - Hardware cursor display path */
+ VIASETREG(VIA_REG_CURSOR_MODE, temp);
+}
+
+/*
+ * This function displays or hides hardware cursor (HC).
+ */
+static void
+viaDisplayHC(ScrnInfoPtr pScrn, Bool hcStatus)
+{
+ VIAPtr pVia = VIAPTR(pScrn);
+ uint32_t temp;
+
+ temp = VIAGETREG(VIA_REG_CURSOR_MODE);
+ temp &= 0xFFFFFFFE;
+ temp |= hcStatus ? 0x00000001 : 0x00000000;
+
+ /* VIA_REG_CURSOR_MODE[0] - Hardware Cursor Enable */
+ VIASETREG(VIA_REG_CURSOR_MODE, temp);
+}
+
+static void
+viaSetHCStartingAddress(xf86CrtcPtr crtc)
+{
+ drmmode_crtc_private_ptr iga = crtc->driver_private;
+ ScrnInfoPtr pScrn = crtc->scrn;
+ VIAPtr pVia = VIAPTR(pScrn);
+ uint32_t temp;
+
+ temp = VIAGETREG(VIA_REG_CURSOR_MODE);
+ temp &= 0xFC0000FF;
+ temp |= iga->cursor_bo->offset;
+
+ /*
+ * 64x64 hardware cursor
+ */
+ temp &= 0xFFFFFFFD;
+
+ /*
+ * VIA_REG_CURSOR_MODE[25:8] - Hardware Cursor Base Address
+ */
+ VIASETREG(VIA_REG_CURSOR_MODE, temp);
+}
+
+static void
+viaSetHCLocation(ScrnInfoPtr pScrn,
+ int x, unsigned int xoff,
+ int y, unsigned int yoff)
+{
+ VIAPtr pVia = VIAPTR(pScrn);
+
+ VIASETREG(VIA_REG_CURSOR_POS, ((x << 16) | (y & 0x07ff)));
+ VIASETREG(VIA_REG_CURSOR_ORG, ((xoff << 16) | (yoff & 0x07ff)));
+}
+
+static void
+viaSetHCColor(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ VIAPtr pVia = VIAPTR(pScrn);
+
+ VIASETREG(VIA_REG_CURSOR_BG, bg);
+ VIASETREG(VIA_REG_CURSOR_FG, fg);
+}
+
static void
viaIGA1InitHI(ScrnInfoPtr pScrn)
{
@@ -3412,6 +3489,7 @@ via_crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg)
ScrnInfoPtr pScrn = crtc->scrn;
drmmode_crtc_private_ptr iga = crtc->driver_private;
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ VIAPtr pVia = VIAPTR(pScrn);
if (xf86_config->cursor_fg)
return;
@@ -3424,10 +3502,14 @@ via_crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg)
return;
}
- if (!iga->index) {
- viaIGA1DisplayHI(pScrn, FALSE);
+ if (pVia->useHardwareCursor) {
+ viaSetHCColor(pScrn, bg, fg);
} else {
- viaIGA2DisplayHI(pScrn, FALSE);
+ if (!iga->index) {
+ viaIGA1DisplayHI(pScrn, FALSE);
+ } else {
+ viaIGA2DisplayHI(pScrn, FALSE);
+ }
}
xf86_config->cursor_fg = fg;
@@ -3439,6 +3521,7 @@ via_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
{
ScrnInfoPtr pScrn = crtc->scrn;
drmmode_crtc_private_ptr iga = crtc->driver_private;
+ VIAPtr pVia = VIAPTR(pScrn);
unsigned xoff, yoff;
if (x < 0) {
@@ -3455,10 +3538,14 @@ via_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
yoff = 0;
}
- if (!iga->index) {
- viaIGA1SetHIDisplayLocation(pScrn, x, xoff, y, yoff);
+ if (pVia->useHardwareCursor) {
+ viaSetHCLocation(pScrn, x, xoff, y, yoff);
} else {
- viaIGA2SetHIDisplayLocation(pScrn, x, xoff, y, yoff);
+ if (!iga->index) {
+ viaIGA1SetHIDisplayLocation(pScrn, x, xoff, y, yoff);
+ } else {
+ viaIGA2SetHIDisplayLocation(pScrn, x, xoff, y, yoff);
+ }
}
}
@@ -3467,11 +3554,18 @@ via_crtc_show_cursor(xf86CrtcPtr crtc)
{
ScrnInfoPtr pScrn = crtc->scrn;
drmmode_crtc_private_ptr iga = crtc->driver_private;
+ VIAPtr pVia = VIAPTR(pScrn);
- if (!iga->index) {
- viaIGA1DisplayHI(pScrn, TRUE);
+ if (pVia->useHardwareCursor) {
+ viaSelectIGAHC(pScrn,
+ iga->index ? TRUE : FALSE);
+ viaDisplayHC(pScrn, TRUE);
} else {
- viaIGA2DisplayHI(pScrn, TRUE);
+ if (!iga->index) {
+ viaIGA1DisplayHI(pScrn, TRUE);
+ } else {
+ viaIGA2DisplayHI(pScrn, TRUE);
+ }
}
}
@@ -3480,14 +3574,35 @@ via_crtc_hide_cursor(xf86CrtcPtr crtc)
{
ScrnInfoPtr pScrn = crtc->scrn;
drmmode_crtc_private_ptr iga = crtc->driver_private;
+ VIAPtr pVia = VIAPTR(pScrn);
- if (!iga->index) {
- viaIGA1DisplayHI(pScrn, FALSE);
+ if (pVia->useHardwareCursor) {
+ viaSelectIGAHC(pScrn,
+ iga->index ? TRUE : FALSE);
+ viaDisplayHC(pScrn, FALSE);
} else {
- viaIGA2DisplayHI(pScrn, FALSE);
+ if (!iga->index) {
+ viaIGA1DisplayHI(pScrn, FALSE);
+ } else {
+ viaIGA2DisplayHI(pScrn, FALSE);
+ }
}
}
+static void
+iga_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *image)
+{
+ drmmode_crtc_private_ptr iga = crtc->driver_private;
+ ScrnInfoPtr pScrn = crtc->scrn;
+ void *dst;
+
+ dst = drm_bo_map(pScrn, iga->cursor_bo);
+ memcpy(dst, image, iga->cursor_bo->size);
+ drm_bo_unmap(pScrn, iga->cursor_bo);
+
+ viaSetHCStartingAddress(crtc);
+}
+
static void
via_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
{
@@ -3562,6 +3677,7 @@ const xf86CrtcFuncsRec via_crtc_funcs = {
.set_cursor_position = via_crtc_set_cursor_position,
.show_cursor = via_crtc_show_cursor,
.hide_cursor = via_crtc_hide_cursor,
+ .load_cursor_image = iga_crtc_load_cursor_image,
.load_cursor_argb = via_crtc_load_cursor_argb,
.destroy = via_crtc_destroy,
#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 2
diff --git a/src/via_driver.c b/src/via_driver.c
index e50cbfd..eb5ec09 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -1591,17 +1591,23 @@ VIAScreenInit(SCREEN_INIT_ARGS_DECL)
switch (pVia->Chipset) {
case VIA_CLE266:
case VIA_KM400:
- flags = 0;
+ flags = HARDWARE_CURSOR_INVERT_MASK |
+ HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
+ HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_BIT_ORDER_MSBFIRST;
+ cursorSize = ((cursorWidth * cursorHeight) / 8) * 2;
+ pVia->useHardwareCursor = TRUE;
break;
default:
flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
HARDWARE_CURSOR_ARGB;
+ cursorSize = (cursorWidth * cursorHeight) * (32 / 8);
break;
}
- cursorSize = (cursorWidth * cursorHeight) * (32 / 8);
alignment = 1024;
/*
diff --git a/src/via_driver.h b/src/via_driver.h
index d175069..2431cd9 100644
--- a/src/via_driver.h
+++ b/src/via_driver.h
@@ -358,6 +358,8 @@ typedef struct _VIA {
void *displayMap;
CARD32 displayOffset;
+ Bool useHardwareCursor;
+
#ifdef HAVE_DEBUG
Bool disableXvBWCheck;
Bool DumpVGAROM;
More information about the openchrome-devel
mailing list