Module Name:    xsrc
Committed By:   macallan
Date:           Wed Jan 22 12:55:06 UTC 2025

Modified Files:
        xsrc/external/mit/xf86-video-ngle/dist/src: ngle.h ngle_driver.c
Added Files:
        xsrc/external/mit/xf86-video-ngle/dist/src: summit_cursor.c

Log Message:
add direct support for hardware cursor on Summit


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 xsrc/external/mit/xf86-video-ngle/dist/src/ngle.h
cvs rdiff -u -r1.9 -r1.10 \
    xsrc/external/mit/xf86-video-ngle/dist/src/ngle_driver.c
cvs rdiff -u -r0 -r1.1 \
    xsrc/external/mit/xf86-video-ngle/dist/src/summit_cursor.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xf86-video-ngle/dist/src/ngle.h
diff -u xsrc/external/mit/xf86-video-ngle/dist/src/ngle.h:1.5 xsrc/external/mit/xf86-video-ngle/dist/src/ngle.h:1.6
--- xsrc/external/mit/xf86-video-ngle/dist/src/ngle.h:1.5	Wed Jan 15 08:21:06 2025
+++ xsrc/external/mit/xf86-video-ngle/dist/src/ngle.h	Wed Jan 22 12:55:06 2025
@@ -63,7 +63,7 @@ typedef struct {
 	xf86CursorInfoPtr	CursorInfoRec;
 	OptionInfoPtr		Options;
 	ExaDriverPtr		pExa;
-	uint32_t		gid, buf, fbacc;
+	uint32_t		gid, buf, fbacc, creg;
 	int 			offset, hwmode, offsetd;
 #define HW_FB	0
 #define HW_FILL	1
@@ -76,6 +76,7 @@ typedef struct {
 
 Bool NGLESetupCursor(ScreenPtr);
 Bool NGLEInitAccel(ScreenPtr);
+Bool SummitSetupCursor(ScreenPtr);
 Bool SummitInitAccel(ScreenPtr);
 
 static inline void

Index: xsrc/external/mit/xf86-video-ngle/dist/src/ngle_driver.c
diff -u xsrc/external/mit/xf86-video-ngle/dist/src/ngle_driver.c:1.9 xsrc/external/mit/xf86-video-ngle/dist/src/ngle_driver.c:1.10
--- xsrc/external/mit/xf86-video-ngle/dist/src/ngle_driver.c:1.9	Tue Dec 10 10:13:19 2024
+++ xsrc/external/mit/xf86-video-ngle/dist/src/ngle_driver.c	Wed Jan 22 12:55:06 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: ngle_driver.c,v 1.9 2024/12/10 10:13:19 macallan Exp $ */
+/* $NetBSD: ngle_driver.c,v 1.10 2025/01/22 12:55:06 macallan Exp $ */
 /*
  * Copyright (c) 2024 Michael Lorenz
  * All rights reserved.
@@ -118,7 +118,7 @@ typedef enum {
 } NGLEOpts;
 
 static const OptionInfoRec NGLEOptions[] = {
-	{ OPTION_HW_CURSOR, "HWcursor",	OPTV_BOOLEAN,	{0}, FALSE },
+	{ OPTION_HW_CURSOR, "HWcursor",	OPTV_BOOLEAN,	{0}, TRUE },
 	{ OPTION_DEVICE,    "Device",   OPTV_ANYSTR,    {0}, FALSE },
 	{ -1, NULL, OPTV_NONE, {0}, FALSE}
 };
@@ -601,7 +601,10 @@ NGLEScreenInit(SCREEN_INIT_ARGS_DECL)
 	miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
 
 	/* check for hardware cursor support */
-	NGLESetupCursor(pScreen);
+	if (fPtr->gid == STI_DD_SUMMIT) {
+		SummitSetupCursor(pScreen);
+	} else
+		NGLESetupCursor(pScreen);
 	
 	/* colormap */
 	if (!miCreateDefColormap(pScreen))

Added files:

Index: xsrc/external/mit/xf86-video-ngle/dist/src/summit_cursor.c
diff -u /dev/null xsrc/external/mit/xf86-video-ngle/dist/src/summit_cursor.c:1.1
--- /dev/null	Wed Jan 22 12:55:06 2025
+++ xsrc/external/mit/xf86-video-ngle/dist/src/summit_cursor.c	Wed Jan 22 12:55:06 2025
@@ -0,0 +1,137 @@
+/* $NetBSD: summit_cursor.c,v 1.1 2025/01/22 12:55:06 macallan Exp $ */
+/*
+ * Copyright (c) 2025 Michael Lorenz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    - Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    - Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials provided
+ *      with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <sys/types.h>
+#include <dev/ic/summitreg.h>
+#include "ngle.h"
+
+static void SummitLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
+static void SummitSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
+static void SummitSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
+
+static void
+SummitLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+	NGLEPtr pNGLE = NGLEPTR(pScrn);
+	uint32_t latch;
+	int i;
+
+	/* image first */
+	NGLEWrite4(pNGLE, VISFX_CURSOR_INDEX, 0x80);
+	for (i = 0; i < 128; i++) {
+		memcpy(&latch, src, 4);
+		NGLEWrite4(pNGLE, VISFX_CURSOR_DATA, latch);
+		src += 4;
+	}
+
+	/* and now the mask */
+	NGLEWrite4(pNGLE, VISFX_CURSOR_INDEX, 0);
+	for (i = 0; i < 128; i++) {
+		memcpy(&latch, src, 4);
+		NGLEWrite4(pNGLE, VISFX_CURSOR_DATA, latch);
+		src += 4;
+	}
+}
+
+void 
+SummitShowCursor(ScrnInfoPtr pScrn)
+{
+	NGLEPtr pNGLE = NGLEPTR(pScrn);
+
+	pNGLE->cursor.enable = 1;
+	NGLEWrite4(pNGLE, VISFX_CURSOR_POS, pNGLE->creg | VISFX_CURSOR_ENABLE);
+}
+
+void
+SummitHideCursor(ScrnInfoPtr pScrn)
+{
+	NGLEPtr pNGLE = NGLEPTR(pScrn);
+
+	pNGLE->cursor.enable = 0;
+	NGLEWrite4(pNGLE, VISFX_CURSOR_POS, pNGLE->creg);
+}
+
+static void
+SummitSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+	NGLEPtr pNGLE = NGLEPTR(pScrn);
+
+	if (x < 0)
+		x = 0x1000 - x;
+	if (y < 0)
+		y = 0x1000 - y;
+	pNGLE->creg = (x << 16) | y;
+	NGLEWrite4(pNGLE, VISFX_CURSOR_POS, pNGLE->creg |
+	    (pNGLE->cursor.enable ? VISFX_CURSOR_ENABLE : 0));
+}
+
+static void
+SummitSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+	NGLEPtr pNGLE = NGLEPTR(pScrn);
+
+	NGLEWrite4(pNGLE, VISFX_CURSOR_FG, fg);
+	NGLEWrite4(pNGLE, VISFX_CURSOR_BG, bg);
+}
+
+Bool 
+SummitSetupCursor(ScreenPtr pScreen)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+	NGLEPtr pNGLE = NGLEPTR(pScrn);
+	xf86CursorInfoPtr infoPtr;
+	
+	pNGLE->cursor.enable = 0;
+	pNGLE->creg = 0;
+
+	infoPtr = xf86CreateCursorInfoRec();
+	if(!infoPtr) return FALSE;
+    
+	pNGLE->CursorInfoRec = infoPtr;
+		
+	xf86Msg(X_INFO, "Summit HW cursor enabled\n");
+
+	infoPtr->MaxWidth = 64;
+	infoPtr->MaxHeight = 64;
+	pNGLE->maskoffset = 8 * 64;
+	
+	infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+	    HARDWARE_CURSOR_TRUECOLOR_AT_8BPP;
+
+	infoPtr->SetCursorColors = SummitSetCursorColors;
+	infoPtr->SetCursorPosition = SummitSetCursorPosition;
+	infoPtr->LoadCursorImage = SummitLoadCursorImage;
+	infoPtr->HideCursor = SummitHideCursor;
+	infoPtr->ShowCursor = SummitShowCursor;
+	infoPtr->UseHWCursor = NULL;
+
+	return xf86InitCursor(pScreen, infoPtr);
+}

Reply via email to