Module Name:    xsrc
Committed By:   macallan
Date:           Sat Dec  7 10:48:38 UTC 2024

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

Log Message:
add *very* experimental Visualize FX support


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/xf86-video-ngle/dist/src/ngle.h
cvs rdiff -u -r1.5 -r1.6 \
    xsrc/external/mit/xf86-video-ngle/dist/src/ngle_accel.c
cvs rdiff -u -r1.6 -r1.7 \
    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_accel.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.2 xsrc/external/mit/xf86-video-ngle/dist/src/ngle.h:1.3
--- xsrc/external/mit/xf86-video-ngle/dist/src/ngle.h:1.2	Mon Oct 21 13:40:53 2024
+++ xsrc/external/mit/xf86-video-ngle/dist/src/ngle.h	Sat Dec  7 10:48:38 2024
@@ -53,6 +53,7 @@ typedef struct {
 	unsigned char*		fbmem;
 	size_t			fbmem_len;
 	void			*regs;
+	size_t			reglen;
 	Bool			HWCursor;
 	CloseScreenProcPtr	CloseScreen;
 	CreateScreenResourcesProcPtr CreateScreenResources;
@@ -73,5 +74,34 @@ typedef struct {
 
 Bool NGLESetupCursor(ScreenPtr);
 Bool NGLEInitAccel(ScreenPtr);
+Bool SummitInitAccel(ScreenPtr);
+
+static inline void
+NGLEWrite4(NGLEPtr fPtr, int offset, uint32_t val)
+{
+	volatile uint32_t *ptr = (uint32_t *)((uint8_t *)fPtr->regs + offset);
+	*ptr = val;
+}
+
+static inline void
+NGLEWrite1(NGLEPtr fPtr, int offset, uint8_t val)
+{
+	volatile uint8_t *ptr = (uint8_t *)fPtr->regs + offset;
+	*ptr = val;
+}
+
+static inline uint32_t
+NGLERead4(NGLEPtr fPtr, int offset)
+{
+	volatile uint32_t *ptr = (uint32_t *)((uint8_t *)fPtr->regs + offset);
+	return *ptr;
+}
+
+static inline uint8_t
+NGLERead1(NGLEPtr fPtr, int offset)
+{
+	volatile uint8_t *ptr = (uint8_t *)fPtr->regs + offset;
+	return *ptr;
+}
 
 #endif

Index: xsrc/external/mit/xf86-video-ngle/dist/src/ngle_accel.c
diff -u xsrc/external/mit/xf86-video-ngle/dist/src/ngle_accel.c:1.5 xsrc/external/mit/xf86-video-ngle/dist/src/ngle_accel.c:1.6
--- xsrc/external/mit/xf86-video-ngle/dist/src/ngle_accel.c:1.5	Fri Oct 25 09:20:37 2024
+++ xsrc/external/mit/xf86-video-ngle/dist/src/ngle_accel.c	Sat Dec  7 10:48:38 2024
@@ -21,7 +21,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-/* $NetBSD: ngle_accel.c,v 1.5 2024/10/25 09:20:37 macallan Exp $ */
+/* $NetBSD: ngle_accel.c,v 1.6 2024/12/07 10:48:38 macallan Exp $ */
 
 #include <sys/types.h>
 #include <dev/ic/stireg.h>
@@ -41,34 +41,6 @@
 #define LEAVE
 #endif
 
-static inline void
-NGLEWrite4(NGLEPtr fPtr, int offset, uint32_t val)
-{
-	volatile uint32_t *ptr = (uint32_t *)((uint8_t *)fPtr->regs + offset);
-	*ptr = val;
-}
-
-static inline void
-NGLEWrite1(NGLEPtr fPtr, int offset, uint8_t val)
-{
-	volatile uint8_t *ptr = (uint8_t *)fPtr->regs + offset;
-	*ptr = val;
-}
-
-static inline uint32_t
-NGLERead4(NGLEPtr fPtr, int offset)
-{
-	volatile uint32_t *ptr = (uint32_t *)((uint8_t *)fPtr->regs + offset);
-	return *ptr;
-}
-
-static inline uint8_t
-NGLERead1(NGLEPtr fPtr, int offset)
-{
-	volatile uint8_t *ptr = (uint8_t *)fPtr->regs + offset;
-	return *ptr;
-}
-
 static void
 NGLEWaitMarker(ScreenPtr pScreen, int Marker)
 {

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.6 xsrc/external/mit/xf86-video-ngle/dist/src/ngle_driver.c:1.7
--- xsrc/external/mit/xf86-video-ngle/dist/src/ngle_driver.c:1.6	Sun Oct 27 11:09:37 2024
+++ xsrc/external/mit/xf86-video-ngle/dist/src/ngle_driver.c	Sat Dec  7 10:48:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: ngle_driver.c,v 1.6 2024/10/27 11:09:37 macallan Exp $ */
+/* $NetBSD: ngle_driver.c,v 1.7 2024/12/07 10:48:38 macallan Exp $ */
 /*
  * Copyright (c) 2024 Michael Lorenz
  * All rights reserved.
@@ -107,18 +107,19 @@ DriverRec NGLE = {
 static SymTabRec NGLEChipsets[] = {
 	{ STI_DD_EG, "Visualize EG" },
 	{ STI_DD_HCRX, "HCRX" },
+	{ STI_DD_SUMMIT, "Visualize FX 2/4/6"},
 	{ -1, NULL }
 };
 
 /* Supported options */
 typedef enum {
 	OPTION_HW_CURSOR,
-	OPTION_SW_CURSOR
+	OPTION_DEVICE
 } NGLEOpts;
 
 static const OptionInfoRec NGLEOptions[] = {
-	{ OPTION_SW_CURSOR, "SWcursor",	OPTV_BOOLEAN,	{0}, FALSE },
 	{ OPTION_HW_CURSOR, "HWcursor",	OPTV_BOOLEAN,	{0}, FALSE },
+	{ OPTION_DEVICE,    "Device",   OPTV_ANYSTR,    {0}, FALSE },
 	{ -1, NULL, OPTV_NONE, {0}, FALSE}
 };
 
@@ -373,6 +374,7 @@ NGLEPreInit(ScrnInfoPtr pScrn, int flags
 		case STI_DD_EG:
 			fPtr->buf = BINapp0I;
 			fPtr->fbacc = BA(IndexedDcd, Otc04, Ots08, AddrByte, 0, fPtr->buf, 0);
+			fPtr->reglen = 0x400000;
 			break;
 		case STI_DD_HCRX:
 			/* XXX BINovly if in 8 bit */
@@ -386,7 +388,11 @@ NGLEPreInit(ScrnInfoPtr pScrn, int flags
 			 * fingers
 			 */
 			fPtr->fbi.fbi_fbsize += 8192;
-	break;
+			fPtr->reglen = 0x400000;
+			break;
+		case STI_DD_SUMMIT:
+			fPtr->reglen = 0x1000000;
+			break;
 	}
 	xf86Msg(X_ERROR, "gid %08x fb access %08x\n", fPtr->gid, fPtr->fbacc);		
 
@@ -470,12 +476,10 @@ NGLEPreInit(ScrnInfoPtr pScrn, int flags
 	xf86SetDpi(pScrn, 0, 0);
 
 	from = X_DEFAULT;
-	fPtr->HWCursor = TRUE;
-	if (xf86GetOptValBool(fPtr->Options, OPTION_HW_CURSOR, &fPtr->HWCursor))
+	fPtr->HWCursor = FALSE;
+	if (xf86GetOptValBool(fPtr->Options, OPTION_HW_CURSOR, &fPtr->HWCursor)) {
 		from = X_CONFIG;
-	if (xf86ReturnOptValBool(fPtr->Options, OPTION_SW_CURSOR, FALSE)) {
-		from = X_CONFIG;
-		fPtr->HWCursor = FALSE;
+		fPtr->HWCursor = TRUE;
 	}
 	xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
 		fPtr->HWCursor ? "HW" : "SW");
@@ -489,11 +493,6 @@ NGLEPreInit(ScrnInfoPtr pScrn, int flags
 		NGLEFreeRec(pScrn);
 		return FALSE;
 	}
-
-	if (xf86LoadSubModule(pScrn, "ramdac") == NULL) {
-		NGLEFreeRec(pScrn);
-		return FALSE;
-	}
 	
 	return TRUE;
 }
@@ -525,7 +524,8 @@ NGLEScreenInit(SCREEN_INIT_ARGS_DECL)
 			   strerror(errno));
 		return FALSE;
 	}
-	fPtr->regs = ngle_mmap(0x400000, 0x80000000, fPtr->fd, 0);
+
+	fPtr->regs = ngle_mmap(fPtr->reglen, 0x80000000, fPtr->fd, 0);
 
 	if (fPtr->regs == NULL) {
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -595,7 +595,10 @@ NGLEScreenInit(SCREEN_INIT_ARGS_DECL)
 	xf86SetBackingStore(pScreen);
 
 	if (fPtr) {
-		NGLEInitAccel(pScreen);
+		if (fPtr->gid == STI_DD_SUMMIT) {
+			SummitInitAccel(pScreen);
+		} else
+			NGLEInitAccel(pScreen);
 		xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using acceleration\n");
 	}
 
@@ -642,7 +645,7 @@ NGLECloseScreen(CLOSE_SCREEN_ARGS_DECL)
 
 	if (pScrn->vtSema) {
 		NGLERestore(pScrn);
-		if (munmap(fPtr->regs, 0x40000) == -1) {
+		if (munmap(fPtr->regs, fPtr->reglen) == -1) {
 			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 				   "munmap engine: %s\n", strerror(errno));
 		}

Added files:

Index: xsrc/external/mit/xf86-video-ngle/dist/src/summit_accel.c
diff -u /dev/null xsrc/external/mit/xf86-video-ngle/dist/src/summit_accel.c:1.1
--- /dev/null	Sat Dec  7 10:48:38 2024
+++ xsrc/external/mit/xf86-video-ngle/dist/src/summit_accel.c	Sat Dec  7 10:48:38 2024
@@ -0,0 +1,235 @@
+/*
+ * hardware acceleration for Visualize FX 4
+ *
+ * Copyright (C) 2024 Michael Lorenz
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* $NetBSD: summit_accel.c,v 1.1 2024/12/07 10:48:38 macallan Exp $ */
+
+#include <sys/types.h>
+#include <dev/ic/summitreg.h>
+
+
+#include "ngle.h"
+
+//#define DEBUG
+
+#ifdef DEBUG
+#define ENTER xf86Msg(X_ERROR, "%s\n", __func__)
+#define LEAVE xf86Msg(X_ERROR, "%s done\n", __func__)
+#define DBGMSG xf86Msg
+#else
+#define ENTER
+#define DBGMSG if (0) xf86Msg
+#define LEAVE
+#endif
+
+static void
+SummitWaitMarker(ScreenPtr pScreen, int Marker)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+	NGLEPtr fPtr = NGLEPTR(pScrn);
+	int bail = 10000000, reg;
+	ENTER;
+	
+	do {
+		reg = NGLERead4(fPtr, VISFX_STATUS);
+		bail--;
+		if (bail == 0) {
+			xf86Msg(X_ERROR, "%s status %08x\n", __func__, reg);
+			return;
+		}
+	} while (reg != 0);
+	LEAVE;
+}
+
+static Bool
+SummitPrepareCopy
+(
+    PixmapPtr pSrcPixmap,
+    PixmapPtr pDstPixmap,
+    int       xdir,
+    int       ydir,
+    int       alu,
+    Pixel     planemask
+)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+	NGLEPtr fPtr = NGLEPTR(pScrn);
+	int srcpitch = exaGetPixmapPitch(pSrcPixmap);
+	int srcoff = exaGetPixmapOffset(pSrcPixmap);
+
+	ENTER;
+
+	DBGMSG(X_ERROR, "%s %d %d\n", __func__, srcoff, srcpitch);
+	if (alu != GXcopy) return FALSE;
+	fPtr->offset = srcoff / srcpitch;
+	if (fPtr->hwmode != HW_BLIT) {
+		SummitWaitMarker(pSrcPixmap->drawable.pScreen, 0);
+		NGLEWrite4(fPtr, VISFX_VRAM_WRITE_MODE, VISFX_WRITE_MODE_PLAIN);
+		NGLEWrite4(fPtr, VISFX_VRAM_READ_MODE, VISFX_READ_MODE_COPY);
+		fPtr->hwmode = HW_BLIT;
+	}
+	NGLEWrite4(fPtr, VISFX_PLANE_MASK, planemask);
+	LEAVE;
+	return TRUE;
+}
+
+static void
+SummitCopy
+(
+    PixmapPtr pDstPixmap,
+    int       xs,
+    int       ys,
+    int       xd,
+    int       yd,
+    int       wi,
+    int       he
+)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+	NGLEPtr fPtr = NGLEPTR(pScrn);
+	int dstpitch = exaGetPixmapPitch(pDstPixmap);
+	int dstoff = exaGetPixmapOffset(pDstPixmap);
+
+	ENTER;
+	SummitWaitMarker(pDstPixmap->drawable.pScreen, 0);
+	NGLEWrite4(fPtr, VISFX_COPY_SRC, (xs << 16) | (ys + fPtr->offset));
+	NGLEWrite4(fPtr, VISFX_COPY_WH, (wi << 16) | he);
+	NGLEWrite4(fPtr, VISFX_COPY_DST, (xd << 16) | (yd + (dstoff / dstpitch)));
+
+	exaMarkSync(pDstPixmap->drawable.pScreen);
+	LEAVE;
+}
+
+static void
+SummitDoneCopy(PixmapPtr pDstPixmap)
+{
+    ENTER;
+    LEAVE;
+}
+
+static Bool
+SummitPrepareSolid(
+    PixmapPtr pPixmap,
+    int alu,
+    Pixel planemask,
+    Pixel fg)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+	NGLEPtr fPtr = NGLEPTR(pScrn);
+
+	ENTER;
+	if (alu != GXcopy) return FALSE;
+	if (fPtr->hwmode != HW_FILL) {
+		SummitWaitMarker(pPixmap->drawable.pScreen, 0);
+		NGLEWrite4(fPtr, VISFX_VRAM_WRITE_MODE, VISFX_WRITE_MODE_FILL);
+		fPtr->hwmode = HW_FILL;
+	}
+	NGLEWrite4(fPtr, VISFX_FG_COLOUR, fg);
+	NGLEWrite4(fPtr, VISFX_PLANE_MASK, planemask);
+	LEAVE;
+	return TRUE;
+}
+
+static void
+SummitSolid(
+    PixmapPtr pPixmap,
+    int x1,
+    int y1,
+    int x2,
+    int y2)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+	NGLEPtr fPtr = NGLEPTR(pScrn);
+	int wi = x2 - x1, he = y2 - y1;
+	int pitch = exaGetPixmapPitch(pPixmap);
+	int offset = exaGetPixmapOffset(pPixmap);
+	uint32_t mask;
+
+	ENTER;
+	
+	y1 += offset / pitch;
+	
+	SummitWaitMarker(pPixmap->drawable.pScreen, 0);
+	NGLEWrite4(fPtr, VISFX_START, (x1 << 16) | y1);
+	NGLEWrite4(fPtr, VISFX_SIZE, (wi << 16) | he);
+
+	exaMarkSync(pPixmap->drawable.pScreen);
+	LEAVE;
+}
+
+Bool
+SummitPrepareAccess(PixmapPtr pPixmap, int index)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+	NGLEPtr fPtr = NGLEPTR(pScrn);
+
+	SummitWaitMarker(pPixmap->drawable.pScreen, 0);
+	NGLEWrite4(fPtr, VISFX_VRAM_WRITE_MODE, VISFX_WRITE_MODE_PLAIN);
+	NGLEWrite4(fPtr, VISFX_VRAM_READ_MODE, VISFX_READ_MODE_COPY);
+	fPtr->hwmode = HW_BLIT;
+	
+	return TRUE;
+}
+Bool
+SummitInitAccel(ScreenPtr pScreen)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+	NGLEPtr fPtr = NGLEPTR(pScrn);
+	ExaDriverPtr pExa;
+	int lines, bpp = pScrn->bitsPerPixel >> 3;
+
+	pExa = exaDriverAlloc();
+	if (!pExa)
+		return FALSE;
+
+	fPtr->pExa = pExa;
+
+	pExa->exa_major = EXA_VERSION_MAJOR;
+	pExa->exa_minor = EXA_VERSION_MINOR;
+
+	pExa->memoryBase = fPtr->fbmem;
+	lines = 1;/* until we figure out how to use more memory */
+	DBGMSG(X_ERROR, "lines %d\n", lines);	
+	pExa->memorySize = fPtr->fbi.fbi_stride * (fPtr->fbi.fbi_height + 1); //fPtr->fbmem_len;
+	pExa->offScreenBase = fPtr->fbi.fbi_stride * fPtr->fbi.fbi_height;
+	pExa->pixmapOffsetAlign = fPtr->fbi.fbi_stride;
+	pExa->pixmapPitchAlign = fPtr->fbi.fbi_stride;
+
+	pExa->flags = EXA_OFFSCREEN_PIXMAPS | EXA_MIXED_PIXMAPS;
+
+	pExa->maxX = 2048;
+	pExa->maxY = 2048;	
+
+	fPtr->hwmode = -1;
+
+	pExa->WaitMarker = SummitWaitMarker;
+	pExa->Solid = SummitSolid;
+	pExa->DoneSolid = SummitDoneCopy;
+	pExa->Copy = SummitCopy;
+	pExa->DoneCopy = SummitDoneCopy;
+	pExa->PrepareCopy = SummitPrepareCopy;
+	pExa->PrepareSolid = SummitPrepareSolid;
+	pExa->PrepareAccess = SummitPrepareAccess;
+	SummitWaitMarker(pScreen, 0);
+
+	return exaDriverInit(pScreen, pExa);
+}

Reply via email to