Module Name:    xsrc
Committed By:   tsutsui
Date:           Tue Aug 30 15:05:21 UTC 2022

Modified Files:
        xsrc/external/mit/xf86-video-wsfb/dist/src: wsfb.h wsfb_driver.c

Log Message:
wsfb: reorganize implementation of Afb support.

- use XORG_VERSION_NUMERIC() to check if Afb is avaiable and
  define and use explicit HAVE_SHADOW_AFB macro
- disable all Afb references if it is not available

Reviewed on tech-x11@:
 https://mail-index.netbsd.org/tech-x11/2022/08/23/msg002311.html

"Looks like good improvement" from jandberg@ and also confirmed by rin@.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb.h
cvs rdiff -u -r1.42 -r1.43 \
    xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.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-wsfb/dist/src/wsfb.h
diff -u xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb.h:1.8 xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb.h:1.9
--- xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb.h:1.8	Fri Jul 15 04:13:16 2022
+++ xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb.h	Tue Aug 30 15:05:21 2022
@@ -41,6 +41,8 @@
 #include <sys/time.h>
 #include <dev/wscons/wsconsio.h>
 
+#include "xorgVersion.h"
+
 #include "compat-api.h"
 
 #include "xf86.h"
@@ -55,6 +57,10 @@
 #ifndef WSFB_H
 #define WSFB_H
 
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,14,99,2,0)
+#define HAVE_SHADOW_AFB
+#endif
+
 /* private data */
 typedef struct {
 	int			fd; /* file descriptor of open device */
@@ -67,7 +73,9 @@ typedef struct {
 	Bool			shadowFB;
 	Bool			HWCursor;
 	Bool			useSwap32;
+#ifdef HAVE_SHADOW_AFB
 	Bool			planarAfb;
+#endif
 	CloseScreenProcPtr	CloseScreen;
 	CreateScreenResourcesProcPtr CreateScreenResources;
 	void                    (*PointerMoved)(SCRN_ARG_TYPE, int, int);

Index: xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c
diff -u xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c:1.42 xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c:1.43
--- xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c:1.42	Thu Jul  7 13:51:06 2022
+++ xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c	Tue Aug 30 15:05:21 2022
@@ -121,8 +121,10 @@ static Bool WsfbScreenInit(SCREEN_INIT_A
 static Bool WsfbCloseScreen(CLOSE_SCREEN_ARGS_DECL);
 static void *WsfbWindowLinear(ScreenPtr, CARD32, CARD32, int, CARD32 *,
 			      void *);
+#ifdef HAVE_SHADOW_AFB
 static void *WsfbWindowAfb(ScreenPtr, CARD32, CARD32, int, CARD32 *,
 			      void *);
+#endif
 static void WsfbPointerMoved(SCRN_ARG_TYPE, int, int);
 static Bool WsfbEnterVT(VT_FUNC_ARGS_DECL);
 static void WsfbLeaveVT(VT_FUNC_ARGS_DECL);
@@ -213,7 +215,7 @@ static const char *shadowSymbols[] = {
 	"shadowUpdatePackedWeak",
 	"shadowUpdateRotatePacked",
 	"shadowUpdateRotatePackedWeak",
-#if XORG_VERSION_CURRENT >= (1) * 10000000 + (20) * 100000
+#ifdef HAVE_SHADOW_AFB
 	"shadowUpdateAfb8",
 #endif
 	NULL
@@ -581,7 +583,6 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags
 #endif
 #ifdef WSDISPLAY_TYPE_AMIGACC
 	if (wstype == WSDISPLAY_TYPE_AMIGACC) {
-#  if XORG_VERSION_CURRENT >= (1) * 10000000 + (20) * 100000
 		/*
 		 * Video memory is organized in bitplanes.
 		 * 8bpp or 1bpp supported in this driver.
@@ -589,10 +590,11 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags
 		 * is done in shadow update proc.
 		 * With 1bpp no conversion needed.
 		 */
+#ifdef HAVE_SHADOW_AFB
 		if (bitsperpixel == 8) {
 			fPtr->planarAfb = TRUE;
 		} else
-#  endif
+#endif
 		{
 			default_depth = 1;
 			bitsperpixel = 1;
@@ -869,17 +871,16 @@ WsfbCreateScreenResources(ScreenPtr pScr
 		shadowproc = WsfbShadowUpdateSwap32;
 	} else if (fPtr->rotate) {
 		shadowproc = shadowUpdateRotatePacked;
-	} else if (fPtr->planarAfb) {
-#if XORG_VERSION_CURRENT >= (1) * 10000000 + (20) * 100000
+	} else
+#ifdef HAVE_SHADOW_AFB
+	if (fPtr->planarAfb) {
 		shadowproc = shadowUpdateAfb8;
-#else
-		xf86Msg(X_ERROR,
-		    "Planar fb requires xorg-server 1.20 or higher.");
-		return FALSE;
-#endif
 		windowproc = WsfbWindowAfb;
 	} else
+#endif
+	{
 		shadowproc = shadowUpdatePacked;
+	}
 	
 	if (!shadowAdd(pScreen, pPixmap, shadowproc,
 		windowproc, fPtr->rotate, NULL)) {
@@ -1024,10 +1025,14 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
 			 */
 			len = pScrn->virtualX * pScrn->virtualY *
 			    (pScrn->bitsPerPixel >> 3);
-		} else if (fPtr->planarAfb) {
+		} else
+#ifdef HAVE_SHADOW_AFB
+		if (fPtr->planarAfb) {
 			/* always 8bpp */
 			len = pScrn->virtualX * pScrn->virtualY;
-		} else {
+		} else
+#endif
+		{
 			len = fPtr->fbi.fbi_stride * pScrn->virtualY;
 		}
 		fPtr->shadow = calloc(1, len);
@@ -1046,9 +1051,13 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
 	 */
 	if (fPtr->rotate) {
 		width = pScrn->displayWidth;
-	} else if (fPtr->planarAfb) {
+	} else
+#ifdef HAVE_SHADOW_AFB
+	if (fPtr->planarAfb) {
 		width = pScrn->displayWidth;
-	} else {
+	} else
+#endif
+	{
 		if (pScrn->bitsPerPixel > 8) {
 			width =
 			    fPtr->fbi.fbi_stride / (pScrn->bitsPerPixel >> 3);
@@ -1274,6 +1283,7 @@ WsfbWindowLinear(ScreenPtr pScreen, CARD
 	return ((CARD8 *)fPtr->fbstart + row * fPtr->fbi.fbi_stride + offset);
 }
 
+#ifdef HAVE_SHADOW_AFB
 /*
  * For use with shadowUpdateAfb8
  *
@@ -1290,6 +1300,7 @@ WsfbWindowAfb(ScreenPtr pScreen, CARD32 
 	*size = fPtr->fbi.fbi_stride * fPtr->fbi.fbi_height;
 	return ((CARD8 *)fPtr->fbstart + row * fPtr->fbi.fbi_stride + offset);
 }
+#endif
 
 static void
 WsfbPointerMoved(SCRN_ARG_TYPE arg, int x, int y)

Reply via email to