Last active
November 12, 2023 12:14
-
-
Save ao-kenji/127d8b30253db84c040fc1008c1657d5 to your computer and use it in GitHub Desktop.
[Merged into the main tree] Work-in-progress diff for OpenBSD/luna88k 256-color X server on 8bpp framebuffer. You also need to apply small diff on luna88k/dev/lunafb.c.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: driver/xf86-video-wsfb/src/wsfb_driver.c | |
=================================================================== | |
RCS file: /cvs/xenocara/driver/xf86-video-wsfb/src/wsfb_driver.c,v | |
retrieving revision 1.43 | |
diff -u -r1.43 wsfb_driver.c | |
--- driver/xf86-video-wsfb/src/wsfb_driver.c 10 Nov 2022 17:38:58 -0000 1.43 | |
+++ driver/xf86-video-wsfb/src/wsfb_driver.c 6 Jul 2023 12:34:04 -0000 | |
@@ -114,6 +114,8 @@ | |
static Bool WsfbCloseScreen(CLOSE_SCREEN_ARGS_DECL); | |
static void *WsfbWindowLinear(ScreenPtr, CARD32, CARD32, int, CARD32 *, | |
void *); | |
+static void *WsfbWindowAfb(ScreenPtr, CARD32, CARD32, int, CARD32 *, | |
+ void *); | |
static void WsfbPointerMoved(SCRN_ARG_TYPE, int, int); | |
static Bool WsfbEnterVT(VT_FUNC_ARGS_DECL); | |
static void WsfbLeaveVT(VT_FUNC_ARGS_DECL); | |
@@ -238,6 +240,7 @@ | |
size_t fbmem_len; | |
int rotate; | |
Bool shadowFB; | |
+ Bool planarAfb; | |
void * shadow; | |
CloseScreenProcPtr CloseScreen; | |
CreateScreenResourcesProcPtr CreateScreenResources; | |
@@ -534,18 +537,33 @@ | |
return FALSE; | |
} | |
- /* Quirk for LUNA: now X supports 1bpp only, so force to set 1bpp */ | |
+ /* | |
+ * Quirk for LUNA: LUNA's video memory is organized in bitplanes. | |
+ */ | |
if (fPtr->wstype == WSDISPLAY_TYPE_LUNA) { | |
- struct wsdisplay_gfx_mode gfxmode; | |
- gfxmode.width = fPtr->info.width; | |
- gfxmode.height = fPtr->info.height; | |
- gfxmode.depth = fPtr->info.depth = 1; | |
- | |
- if (ioctl(fPtr->fd, WSDISPLAYIO_SETGFXMODE, &gfxmode) == -1) { | |
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | |
- "ioctl WSDISPLAY_SETGFXMODE: %s\n", | |
- strerror(errno)); | |
- return FALSE; | |
+ if ((fPtr->info.depth == 8) && (pScrn->depth == 8)) { | |
+ /* | |
+ * With 8bpp conversion to bitplane format | |
+ * is done in shadow update proc. | |
+ */ | |
+ fPtr->planarAfb = TRUE; | |
+ } else { | |
+ /* | |
+ * Otherwise, current X supports 1bpp only. | |
+ * So force to set 1bpp. | |
+ */ | |
+ struct wsdisplay_gfx_mode gfxmode; | |
+ gfxmode.width = fPtr->info.width; | |
+ gfxmode.height = fPtr->info.height; | |
+ gfxmode.depth = fPtr->info.depth = 1; | |
+ | |
+ if (ioctl(fPtr->fd, WSDISPLAYIO_SETGFXMODE, | |
+ &gfxmode) == -1) { | |
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | |
+ "ioctl WSDISPLAY_SETGFXMODE: %s\n", | |
+ strerror(errno)); | |
+ return FALSE; | |
+ } | |
} | |
} | |
@@ -792,6 +810,12 @@ | |
shadowUpdatePacked(pScreen, pBuf); | |
} | |
+static void | |
+wsfbUpdateAfb8(ScreenPtr pScreen, shadowBufPtr pBuf) | |
+{ | |
+ shadowUpdateAfb8(pScreen, pBuf); | |
+} | |
+ | |
static Bool | |
WsfbCreateScreenResources(ScreenPtr pScreen) | |
{ | |
@@ -799,6 +823,8 @@ | |
WsfbPtr fPtr = WSFBPTR(pScrn); | |
PixmapPtr pPixmap; | |
Bool ret; | |
+ void (*shadowproc)(ScreenPtr, shadowBufPtr); | |
+ ShadowWindowProc windowproc; | |
pScreen->CreateScreenResources = fPtr->CreateScreenResources; | |
ret = pScreen->CreateScreenResources(pScreen); | |
@@ -809,9 +835,17 @@ | |
pPixmap = pScreen->GetScreenPixmap(pScreen); | |
- if (!shadowAdd(pScreen, pPixmap, fPtr->rotate ? | |
- wsfbUpdateRotatePacked : wsfbUpdatePacked, | |
- WsfbWindowLinear, fPtr->rotate, NULL)) { | |
+ shadowproc = fPtr->rotate ? | |
+ wsfbUpdateRotatePacked : wsfbUpdatePacked ; | |
+ windowproc = WsfbWindowLinear; | |
+ | |
+ if (fPtr->planarAfb) { | |
+ shadowproc = wsfbUpdateAfb8; | |
+ windowproc = WsfbWindowAfb; | |
+ } | |
+ | |
+ if (!shadowAdd(pScreen, pPixmap, shadowproc, | |
+ windowproc, fPtr->rotate, NULL)) { | |
return FALSE; | |
} | |
return TRUE; | |
@@ -857,6 +891,9 @@ | |
case 4: | |
case 8: | |
len = fPtr->linebytes*fPtr->info.height; | |
+ /* LUNA planar framebuffer needs some modification */ | |
+ if ((fPtr->wstype == WSDISPLAY_TYPE_LUNA) && (fPtr->planarAfb)) | |
+ len *= fPtr->info.depth; | |
break; | |
case 16: | |
if (fPtr->linebytes == fPtr->info.width) { | |
@@ -932,8 +969,14 @@ | |
fPtr->fbstart = fPtr->fbmem + fPtr->info.offset; | |
if (fPtr->shadowFB) { | |
- fPtr->shadow = calloc(1, pScrn->virtualX * pScrn->virtualY * | |
- pScrn->bitsPerPixel/8); | |
+ len = pScrn->virtualX * pScrn->virtualY * | |
+ pScrn->bitsPerPixel/8; | |
+ | |
+ /* LUNA planar framebuffer needs some modification */ | |
+ if ((fPtr->wstype == WSDISPLAY_TYPE_LUNA) && fPtr->planarAfb) | |
+ len = pScrn->displayWidth * pScrn->virtualY; | |
+ | |
+ fPtr->shadow = calloc(1, len); | |
if (!fPtr->shadow) { | |
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | |
@@ -1113,6 +1156,18 @@ | |
return ((CARD8 *)fPtr->fbstart + row *fPtr->linebytes + offset); | |
} | |
+static void * | |
+WsfbWindowAfb(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, | |
+ CARD32 *size, void *closure) | |
+{ | |
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); | |
+ WsfbPtr fPtr = WSFBPTR(pScrn); | |
+ | |
+ /* size is offset from start of bitplane to next bitplane */ | |
+ *size = fPtr->linebytes * fPtr->info.height; | |
+ return ((CARD8 *)fPtr->fbstart + row * fPtr->linebytes + offset); | |
+} | |
+ | |
static void | |
WsfbPointerMoved(SCRN_ARG_TYPE arg, int x, int y) | |
{ | |
@@ -1467,6 +1522,10 @@ | |
pDGAMode->pixmapHeight = pDGAMode->imageHeight; | |
pDGAMode->maxViewportX = pScrn->virtualX - | |
pDGAMode->viewportWidth; | |
+ /* XXX: LUNA planar framebuffer needs some modification? */ | |
+ if ((fPtr->wstype == WSDISPLAY_TYPE_LUNA) && (fPtr->planarAfb)) | |
+ pDGAMode->maxViewportX = pScrn->displayWidth - | |
+ pDGAMode->viewportWidth; | |
pDGAMode->maxViewportY = pScrn->virtualY - | |
pDGAMode->viewportHeight; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment