[openchrome-devel] xf86-video-openchrome: 2 commits - configure.ac src/via_display.c src/via_driver.c src/via_driver.h

Kevin Brace kevinbrace at kemper.freedesktop.org
Fri Apr 3 18:09:43 UTC 2020


 configure.ac      |    2 
 src/via_display.c |  244 ++++++++++++++++++++++++++++--------------------------
 src/via_driver.c  |   31 +++++-
 src/via_driver.h  |    2 
 4 files changed, 156 insertions(+), 123 deletions(-)

New commits:
commit 84845494a0793c625253f7fd27245f7d0ff6fd05
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri Apr 3 11:09:14 2020 -0700

    Version bumped to 0.6.223
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/configure.ac b/configure.ac
index ea0cc47..97bdb4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-video-openchrome],
-        [0.6.222],
+        [0.6.223],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/openchrome],
         [xf86-video-openchrome])
 
diff --git a/src/via_display.c b/src/via_display.c
index 696251f..a26965e 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -175,6 +175,66 @@ viaIGA1SetGamma(ScrnInfoPtr pScrn, CARD8 gammaCorrection)
                         "Exiting viaIGA1SetGamma.\n"));
 }
 
+/*
+ * 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;
+
+    /*
+     * 64x64 hardware cursor
+     */
+    temp &= 0xFFFFFFFD;
+
+    /*
+     * 32x32 hardware cursor
+     */
+//  temp |= 0x00000002;
+
+    /* 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;
+
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+               "offset: %lx\n", iga->cursor_bo->offset);
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+               "temp: %x\n", temp);
+    /*
+     * 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
 viaIGA1InitHI(ScrnInfoPtr pScrn)
 {
@@ -3411,6 +3471,7 @@ iga_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;
@@ -3487,6 +3548,20 @@ iga_crtc_hide_cursor(xf86CrtcPtr crtc)
     }
 }
 
+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
 iga_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
 {
@@ -3533,6 +3608,7 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .set_cursor_position    = iga_crtc_set_cursor_position,
     .show_cursor            = iga_crtc_show_cursor,
     .hide_cursor            = iga_crtc_hide_cursor,
+    .load_cursor_image      = iga_crtc_load_cursor_image,
     .load_cursor_argb       = iga_crtc_load_cursor_argb,
 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 2
     .set_origin             = iga1_crtc_set_origin,
@@ -3846,6 +3922,7 @@ const xf86CrtcFuncsRec iga2_crtc_funcs = {
     .set_cursor_position    = iga_crtc_set_cursor_position,
     .show_cursor            = iga_crtc_show_cursor,
     .hide_cursor            = iga_crtc_hide_cursor,
+    .load_cursor_image      = iga_crtc_load_cursor_image,
     .load_cursor_argb       = iga_crtc_load_cursor_argb,
 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 2
     .set_origin             = iga2_crtc_set_origin,
diff --git a/src/via_driver.c b/src/via_driver.c
index 55e40e6..034b34c 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -1533,13 +1533,30 @@ VIAScreenInit(SCREEN_INIT_ARGS_DECL)
     if (pVia->drmmode.hwcursor) {
         xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 
-        cursorWidth = cursorHeight = 64;
-        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);
-        alignment = 1024;
+        switch (pVia->Chipset) {
+        case VIA_CLE266:
+        case VIA_KM400:
+        case VIA_P4M800PRO:
+            cursorWidth = cursorHeight = 64;
+            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;
+            alignment = 1024;
+            pVia->useHardwareCursor = TRUE;
+            break;
+        default:
+            cursorWidth = cursorHeight = 64;
+            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);
+            alignment = 1024;
+            break;
+        }
 
         /*
          * Set cursor location in frame buffer.
diff --git a/src/via_driver.h b/src/via_driver.h
index 011ede7..a443454 100644
--- a/src/via_driver.h
+++ b/src/via_driver.h
@@ -328,6 +328,8 @@ typedef struct _VIA {
     void                *displayMap;
     CARD32              displayOffset;
 
+    Bool                useHardwareCursor;
+
 #ifdef HAVE_DEBUG
     Bool                disableXvBWCheck;
     Bool                DumpVGAROM;
commit 819dfa747e73ba125ca0b939429ee28049d3e99a
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Thu Apr 2 11:04:24 2020 -0700

    Unify IGA1 and IGA2 HI (Hardware Icon) cursor callbacks
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index 53dbd33..696251f 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3406,28 +3406,38 @@ iga1_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
     and in all other bpps the fg and bg are in 8-8-8 RGB format.
 */
 static void
-iga1_crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg)
+iga_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);
 
     if (xf86_config->cursor_fg)
         return;
 
-    /* Don't recolour the image if we don't have to. */
-    if (fg == xf86_config->cursor_fg && bg == xf86_config->cursor_bg)
+    /*
+     * Don't recolour the image if we don't have to.
+     */
+    if ((fg == xf86_config->cursor_fg) &&
+        (bg == xf86_config->cursor_bg)) {
         return;
+    }
 
-    viaIGA1DisplayHI(pScrn, FALSE);
+    if (!iga->index) {
+        viaIGA1DisplayHI(pScrn, FALSE);
+    } else {
+        viaIGA2DisplayHI(pScrn, FALSE);
+    }
 
     xf86_config->cursor_fg = fg;
     xf86_config->cursor_bg = bg;
 }
 
 static void
-iga1_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
+iga_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
+    drmmode_crtc_private_ptr iga = crtc->driver_private;
     unsigned xoff, yoff;
 
     if (x < 0) {
@@ -3444,30 +3454,44 @@ iga1_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
         yoff = 0;
     }
 
-    viaIGA1SetHIDisplayLocation(pScrn, x, xoff, y, yoff);
+    if (!iga->index) {
+        viaIGA1SetHIDisplayLocation(pScrn, x, xoff, y, yoff);
+    } else {
+        viaIGA2SetHIDisplayLocation(pScrn, x, xoff, y, yoff);
+    }
 }
 
 static void
-iga1_crtc_show_cursor(xf86CrtcPtr crtc)
+iga_crtc_show_cursor(xf86CrtcPtr crtc)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
+    drmmode_crtc_private_ptr iga = crtc->driver_private;
 
-    viaIGA1DisplayHI(pScrn, TRUE);
+    if (!iga->index) {
+        viaIGA1DisplayHI(pScrn, TRUE);
+    } else {
+        viaIGA2DisplayHI(pScrn, TRUE);
+    }
 }
 
 static void
-iga1_crtc_hide_cursor(xf86CrtcPtr crtc)
+iga_crtc_hide_cursor(xf86CrtcPtr crtc)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
+    drmmode_crtc_private_ptr iga = crtc->driver_private;
 
-    viaIGA1DisplayHI(pScrn, FALSE);
+    if (!iga->index) {
+        viaIGA1DisplayHI(pScrn, FALSE);
+    } else {
+        viaIGA2DisplayHI(pScrn, FALSE);
+    }
 }
 
 static void
-iga1_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
+iga_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
 {
-    drmmode_crtc_private_ptr iga = crtc->driver_private;
     ScrnInfoPtr pScrn = crtc->scrn;
+    drmmode_crtc_private_ptr iga = crtc->driver_private;
     void *dst;
 
     dst = drm_bo_map(pScrn, iga->cursor_bo);
@@ -3475,8 +3499,13 @@ iga1_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
     memcpy(dst, image, iga->cursor_bo->size);
     drm_bo_unmap(pScrn, iga->cursor_bo);
 
-    viaIGA1InitHI(pScrn);
-    viaIGA1SetHIStartingAddress(crtc);
+    if (!iga->index) {
+        viaIGA1InitHI(pScrn);
+        viaIGA1SetHIStartingAddress(crtc);
+    } else {
+        viaIGA2InitHI(pScrn);
+        viaIGA2SetHIStartingAddress(crtc);
+    }
 }
 
 static void
@@ -3500,11 +3529,11 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .shadow_create          = iga1_crtc_shadow_create,
     .shadow_allocate        = iga1_crtc_shadow_allocate,
     .shadow_destroy         = iga1_crtc_shadow_destroy,
-    .set_cursor_colors      = iga1_crtc_set_cursor_colors,
-    .set_cursor_position    = iga1_crtc_set_cursor_position,
-    .show_cursor            = iga1_crtc_show_cursor,
-    .hide_cursor            = iga1_crtc_hide_cursor,
-    .load_cursor_argb       = iga1_crtc_load_cursor_argb,
+    .set_cursor_colors      = iga_crtc_set_cursor_colors,
+    .set_cursor_position    = iga_crtc_set_cursor_position,
+    .show_cursor            = iga_crtc_show_cursor,
+    .hide_cursor            = iga_crtc_hide_cursor,
+    .load_cursor_argb       = iga_crtc_load_cursor_argb,
 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 2
     .set_origin             = iga1_crtc_set_origin,
 #endif
@@ -3799,98 +3828,6 @@ iga2_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
 {
 }
 
-/*
-    Set the cursor foreground and background colors.  In 8bpp, fg and
-    bg are indices into the current colormap unless the
-    HARDWARE_CURSOR_TRUECOLOR_AT_8BPP flag is set.  In that case
-    and in all other bpps the fg and bg are in 8-8-8 RGB format.
-*/
-static void
-iga2_crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg)
-{
-    drmmode_crtc_private_ptr iga = crtc->driver_private;
-    ScrnInfoPtr pScrn = crtc->scrn;
-    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-    int height = 64, width = 64, i;
-    CARD32 pixel, *dst;
-
-    if (xf86_config->cursor_fg)
-        return;
-
-    fg |= 0xff000000;
-    bg |= 0xff000000;
-
-    /* Don't recolour the image if we don't have to. */
-    if (fg == xf86_config->cursor_fg && bg == xf86_config->cursor_bg)
-        return;
-
-    viaIGA2DisplayHI(pScrn, FALSE);
-
-    dst = drm_bo_map(pScrn, iga->cursor_bo);
-    for (i = 0; i < width * height; i++, dst++)
-        if ((pixel = *dst))
-            *dst = (pixel == xf86_config->cursor_fg) ? fg : bg;
-    drm_bo_unmap(pScrn, iga->cursor_bo);
-
-    xf86_config->cursor_fg = fg;
-    xf86_config->cursor_bg = bg;
-}
-
-static void
-iga2_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-    unsigned xoff, yoff;
-
-    if (x < 0) {
-        xoff = ((-x) & 0xFE);
-        x = 0;
-    } else {
-        xoff = 0;
-    }
-
-    if (y < 0) {
-        yoff = ((-y) & 0xFE);
-        y = 0;
-    } else {
-        yoff = 0;
-    }
-
-    viaIGA2SetHIDisplayLocation(pScrn, x, xoff, y, yoff);
-}
-
-static void
-iga2_crtc_show_cursor(xf86CrtcPtr crtc)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-
-    viaIGA2DisplayHI(pScrn, TRUE);
-}
-
-static void
-iga2_crtc_hide_cursor(xf86CrtcPtr crtc)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-
-    viaIGA2DisplayHI(pScrn, FALSE);
-}
-
-static void
-iga2_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
-{
-    drmmode_crtc_private_ptr iga = crtc->driver_private;
-    ScrnInfoPtr pScrn = crtc->scrn;
-    void *dst;
-
-    dst = drm_bo_map(pScrn, iga->cursor_bo);
-    memset(dst, 0x00, iga->cursor_bo->size);
-    memcpy(dst, image, iga->cursor_bo->size);
-    drm_bo_unmap(pScrn, iga->cursor_bo);
-
-    viaIGA2InitHI(pScrn);
-    viaIGA2SetHIStartingAddress(crtc);
-}
-
 const xf86CrtcFuncsRec iga2_crtc_funcs = {
     .dpms                   = iga2_crtc_dpms,
     .save                   = iga2_crtc_save,
@@ -3905,11 +3842,11 @@ const xf86CrtcFuncsRec iga2_crtc_funcs = {
     .shadow_create          = iga2_crtc_shadow_create,
     .shadow_allocate        = iga2_crtc_shadow_allocate,
     .shadow_destroy         = iga2_crtc_shadow_destroy,
-    .set_cursor_colors      = iga2_crtc_set_cursor_colors,
-    .set_cursor_position    = iga2_crtc_set_cursor_position,
-    .show_cursor            = iga2_crtc_show_cursor,
-    .hide_cursor            = iga2_crtc_hide_cursor,
-    .load_cursor_argb       = iga2_crtc_load_cursor_argb,
+    .set_cursor_colors      = iga_crtc_set_cursor_colors,
+    .set_cursor_position    = iga_crtc_set_cursor_position,
+    .show_cursor            = iga_crtc_show_cursor,
+    .hide_cursor            = iga_crtc_hide_cursor,
+    .load_cursor_argb       = iga_crtc_load_cursor_argb,
 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 2
     .set_origin             = iga2_crtc_set_origin,
 #endif


More information about the openchrome-devel mailing list