--- ./xorg-server-1.1.0/hw/xfree86/xf1bpp/xf1bpp.c.xf1bpp 2006-06-08 14:14:35.000000000 -0400 +++ ./xorg-server-1.1.0/hw/xfree86/xf1bpp/xf1bpp.c 2006-06-08 15:15:00.000000000 -0400 @@ -0,0 +1,184 @@ +/* + * Copyright 2005 Adam Jackson. + * + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS 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. + */ + +/* + * xf1bpp is for when hardware bit order doesn't match hardware byte order. + * We used to do this by subclassing mfb, but shadowfb is simpler, and + * faster if you have the RAM. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include "xorg-config.h" +#endif + +#include "xf86.h" +#include "xf86Module.h" +#include "os.h" +#include "fb.h" +#include "shadowfb.h" +#include "xf1bpp.h" + +/* this whole thing assumes that sizeof(int) == 4 */ + +typedef struct { + unsigned int *fb; + unsigned int *shadow; + int x; + int y; + int width; + CloseScreenProcPtr CloseScreen; +} xf1bppScreenPrivateRec; + +static int xf1Generation = 0; +static int xf1ScreenPrivateIndex = 0; + +static unsigned int +flip_word(unsigned int i) +{ + /* sneaky */ + i = ((i >> 1) & 0x55555555) | ((i << 1) & 0xaaaaaaaa); + i = ((i >> 2) & 0x33333333) | ((i << 2) & 0xcccccccc); + i = ((i >> 4) & 0x0f0f0f0f) | ((i << 4) & 0xf0f0f0f0); + return i; +} + +static void +refreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + xf1bppScreenPrivateRec *priv; + BoxRec b; + int i, j, start; + CARD32 *src, *dst; + priv = pScrn->pScreen->devPrivates[xf1ScreenPrivateIndex].ptr; + + /* + * this will copy slightly more than each box, because we can't really + * do bit writes. + */ + while (num--) { + b = *pbox; + b.x1 &= ~3; + b.x2 = (b.x2 + 3) & ~3; + for (i = b.y1; i < b.y2; i++) { + start = priv->width * b.y1 / 8; + src = priv->shadow + start; + dst = priv->fb + start; + for (j = b.x1; j < b.x2; j++) + dst[j] = flip_word(src[j]); + } + pbox++; + } +} + +static Bool +xf1bppCloseScreen(int index, ScreenPtr pScreen) +{ + xf1bppScreenPrivateRec *priv; + CloseScreenProcPtr CloseScreen; + + if (!xf1ScreenPrivateIndex) + return TRUE; + + priv = pScreen->devPrivates[xf1ScreenPrivateIndex].ptr; + if (priv) { + CloseScreen = priv->CloseScreen; + if (priv->shadow) + xfree(priv->shadow); + xfree(priv); + if (CloseScreen) + return CloseScreen(index, pScreen); + } + + return TRUE; +} + +_X_EXPORT Bool +xf1bppScreenInit(ScreenPtr pScreen, pointer pbits, int x, int y, + int dpix, int dpiy, int width) +{ + xf1bppScreenPrivateRec *priv = NULL; + + if (xf1Generation != serverGeneration) { + xf1ScreenPrivateIndex = AllocateScreenPrivateIndex(); + if (xf1ScreenPrivateIndex == -1) + return FALSE; + priv = xcalloc(1, sizeof(xf1bppScreenPrivateRec)); + if (!priv) + return FALSE; + + xf1Generation = serverGeneration; + pScreen->devPrivates[xf1ScreenPrivateIndex].ptr = priv; + } else { + priv = pScreen->devPrivates[xf1ScreenPrivateIndex].ptr; + } + + /* the size here is a WAG */ + if (!priv->shadow && !(priv->shadow = xcalloc(1, (width * y + 7) / 8))) { + xfree(priv); + return FALSE; + } + + ShadowFBInit(pScreen, refreshArea); + + priv->fb = pbits; + priv->x = x; + priv->y = y; + priv->width = width; + + priv->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = xf1bppCloseScreen; + + if (!fbScreenInit(pScreen, priv->shadow, x, y, dpix, dpiy, width, 1)) { + xfree(priv->shadow); + xfree(priv); + return FALSE; + } + + return TRUE; +} + +static XF86ModuleVersionInfo xf1mvi = +{ + "xf1bpp", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 2, 0, 0, + ABI_CLASS_ANSIC, + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0, 0, 0, 0} +}; + +static MODULESETUPPROTO(xf1bppSetup); + +_X_EXPORT XF86ModuleData xf1bppModuleData = { &xf1mvi, xf1bppSetup, NULL }; + +static pointer +xf1bppSetup(pointer module, pointer opts, int *maj, int *min) +{ + pointer one, two; + one = LoadSubModule(module, "fb", NULL, NULL, NULL, NULL, maj, min); + two = LoadSubModule(module, "shadowfb", NULL, NULL, NULL, NULL, maj, min); + return (pointer)(one != NULL && two != NULL); +} --- ./xorg-server-1.1.0/hw/xfree86/xf1bpp/xf1bpp.h.xf1bpp 2006-06-08 14:10:40.000000000 -0400 +++ ./xorg-server-1.1.0/hw/xfree86/xf1bpp/xf1bpp.h 2006-06-08 14:14:40.000000000 -0400 @@ -28,10 +28,14 @@ #ifndef __XF1BPP_H__ #define __XF1BPP_H__ -#define MFB_PROTOTYPES_ONLY -#include "mfbmap.h" -#include "mfb.h" -#include "mfbunmap.h" -#undef MFB_PROTOTYPES_ONLY +extern Bool xf1bppScreenInit( + ScreenPtr pScreen, + pointer pbits, + int x, + int y, + int dpix, + int dpiy, + int width +); #endif --- ./xorg-server-1.1.0/hw/xfree86/xf1bpp/Makefile.am.xf1bpp 2006-06-08 14:10:46.000000000 -0400 +++ ./xorg-server-1.1.0/hw/xfree86/xf1bpp/Makefile.am 2006-06-08 14:22:43.000000000 -0400 @@ -1,155 +1,13 @@ module_LTLIBRARIES = libxf1bpp.la -sdk_HEADERS = xf1bpp.h mfbmap.h mfbunmap.h +sdk_HEADERS = xf1bpp.h libxf1bpp_la_LDFLAGS = -avoid-version -libxf1bppgen_a_SOURCES = \ - mfbseg.c \ - mfbpgbwht.c \ - mfbpgbblak.c \ - mfbpgbinv.c \ - mfbigbwht.c \ - mfbigbblak.c \ - mfbpawhite.c \ - mfbpablack.c \ - mfbpainv.c \ - mfbtewhite.c \ - mfbteblack.c \ - mfbplywhite.c \ - mfbplyblack.c \ - mfbplyinv.c \ - mfbbltC.c \ - mfbbltX.c \ - mfbbltCI.c \ - mfbbltO.c \ - mfbbltG.c \ - mfbtileC.c \ - mfbtileG.c +libxf1bpp_la_SOURCES = xf1bpp.c -DISTCLEANFILES = $(libxf1bppgen_a_SOURCES) - -libxf1bppmfb_a_SOURCES = \ - $(top_srcdir)/mfb/maskbits.c \ - $(top_srcdir)/mfb/mfbbitblt.c \ - $(top_srcdir)/mfb/mfbbres.c \ - $(top_srcdir)/mfb/mfbbresd.c \ - $(top_srcdir)/mfb/mfbbstore.c \ - $(top_srcdir)/mfb/mfbclip.c \ - $(top_srcdir)/mfb/mfbcmap.c \ - $(top_srcdir)/mfb/mfbfillarc.c \ - $(top_srcdir)/mfb/mfbfillrct.c \ - $(top_srcdir)/mfb/mfbfillsp.c \ - $(top_srcdir)/mfb/mfbfont.c \ - $(top_srcdir)/mfb/mfbgc.c \ - $(top_srcdir)/mfb/mfbgetsp.c \ - $(top_srcdir)/mfb/mfbhrzvert.c \ - $(top_srcdir)/mfb/mfbimage.c \ - $(top_srcdir)/mfb/mfbline.c \ - $(top_srcdir)/mfb/mfbmisc.c \ - $(top_srcdir)/mfb/mfbpixmap.c \ - $(top_srcdir)/mfb/mfbpntwin.c \ - $(top_srcdir)/mfb/mfbpolypnt.c \ - $(top_srcdir)/mfb/mfbpushpxl.c \ - $(top_srcdir)/mfb/mfbscrclse.c \ - $(top_srcdir)/mfb/mfbscrinit.c \ - $(top_srcdir)/mfb/mfbsetsp.c \ - $(top_srcdir)/mfb/mfbwindow.c \ - $(top_srcdir)/mfb/mfbzerarc.c \ - mfbmodule.c - -libxf1bpp_la_SOURCES = $(libxf1bppmfb_a_SOURCES) $(libxf1bppgen_a_SOURCES) - -AM_CFLAGS = -DXF86MONO -include mfbmap.h $(DIX_CFLAGS) $(XORG_CFLAGS) \ - @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -INCLUDES = $(XORG_INCS) -I$(top_srcdir)/mfb - -mfbseg.c: - echo "#define POLYSEGMENT" > $@ - echo "#include \"$(top_srcdir)/mfb/mfbline.c\"" >> $@ -mfbpgbwht.c: - echo "#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltWhite" > $@ - echo "#define OPEQ |=" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbplygblt.c\"" >> $@ -mfbpgbblak.c: - echo "#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltBlack" > $@ - echo "#define OPEQ &=~" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbplygblt.c\"" >> $@ -mfbpgbinv.c: - echo "#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltInvert" > $@ - echo "#define OPEQ ^=" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbplygblt.c\"" >> $@ -mfbigbwht.c: - echo "#define MFBIMAGEGLYPHBLT xf1bppImageGlyphBltWhite" > $@ - echo "#define OPEQ |=" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbimggblt.c\"" >> $@ -mfbigbblak.c: - echo "#define MFBIMAGEGLYPHBLT xf1bppImageGlyphBltBlack" > $@ - echo "#define OPEQ &=~" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbimggblt.c\"" >> $@ -mfbpawhite.c: - echo "#define MFBSOLIDFILLAREA xf1bppSolidWhiteArea" > $@ - echo "#define MFBSTIPPLEFILLAREA xf1bppStippleWhiteArea" >> $@ - echo "#define OPEQ |=" >> $@ - echo "#define EQWHOLEWORD =~0" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbpntarea.c\"" >> $@ -mfbpablack.c: - echo "#define MFBSOLIDFILLAREA xf1bppSolidBlackArea" > $@ - echo "#define MFBSTIPPLEFILLAREA xf1bppStippleBlackArea" >> $@ - echo "#define OPEQ &=~" >> $@ - echo "#define EQWHOLEWORD =0" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbpntarea.c\"" >> $@ -mfbpainv.c: - echo "#define MFBSOLIDFILLAREA xf1bppSolidInvertArea" > $@ - echo "#define MFBSTIPPLEFILLAREA xf1bppStippleInvertArea" >> $@ - echo "#define OPEQ ^=" >> $@ - echo "#define EQWHOLEWORD ^=~0" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbpntarea.c\"" >> $@ -mfbtewhite.c: - echo "#define OP" > $@ - echo "#define CLIPTETEXT xf1bppImageGlyphBltWhite" >> $@ - echo "#define MFBTEGLYPHBLT xf1bppTEGlyphBltWhite" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbtegblt.c\"" >> $@ -mfbteblack.c: - echo "#define OP ~" > $@ - echo "#define CLIPTETEXT xf1bppImageGlyphBltBlack" >> $@ - echo "#define MFBTEGLYPHBLT xf1bppTEGlyphBltBlack" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbtegblt.c\"" >> $@ -mfbplywhite.c: - echo "#define MFBFILLPOLY1RECT xf1bppFillPolyWhite" > $@ - echo "#define OPEQ |=" >> $@ - echo "#define EQWHOLEWORD =~0" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbply1rct.c\"" >> $@ -mfbplyblack.c: - echo "#define MFBFILLPOLY1RECT xf1bppFillPolyBlack" > $@ - echo "#define OPEQ &=~" >> $@ - echo "#define EQWHOLEWORD =0" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbply1rct.c\"" >> $@ -mfbplyinv.c: - echo "#define MFBFILLPOLY1RECT xf1bppFillPolyInvert" > $@ - echo "#define OPEQ ^=" >> $@ - echo "#define EQWHOLEWORD ^=~0" >> $@ - echo "#include \"$(top_srcdir)/mfb/mfbply1rct.c\"" >> $@ -mfbbltC.c: - echo "#define MROP Mcopy" > $@ - echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ -mfbbltX.c: - echo "#define MROP Mxor" > $@ - echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ -mfbbltCI.c: - echo "#define MROP McopyInverted" > $@ - echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ -mfbbltO.c: - echo "#define MROP Mor" > $@ - echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ -mfbbltG.c: - echo "#define MROP M0" > $@ - echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ -mfbtileC.c: - echo "#define MROP Mcopy" > $@ - echo "#include \"$(top_srcdir)/mfb/mfbtile.c\"" >> $@ -mfbtileG.c: - echo "#define MRop M0" > $@ - echo "#include \"$(top_srcdir)/mfb/mfbtile.c\"" >> $@ - -EXTRA_DIST = mfbmap.sh mfbunmap.sh +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) \ + @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ +INCLUDES = $(XORG_INCS) \ + -I$(top_srcdir)/fb \ + -I$(top_srcdir)/hw/xfree86/shadowfb