Do this using the spice_indent script which uses indent to apply current Spice styles (as per Frediano Ziglio on 2019-05-01. Signed-off-by: Jeremy White <jwhite@xxxxxxxxxxxxxxx> --- v2: Original version v3: Revised to have case indent at 0, cuddle else, fix functions returning Bool, and preserve Xorg function declaration style --- doc/spice_indent | 26 +- spice-video-dummy/src/dummy.h | 9 +- spice-video-dummy/src/dummy_cursor.c | 20 +- spice-video-dummy/src/dummy_driver.c | 490 +++++++++++++++++------------------ 4 files changed, 270 insertions(+), 275 deletions(-) diff --git a/doc/spice_indent b/doc/spice_indent index 08595d5..5d7e29a 100755 --- a/doc/spice_indent +++ b/doc/spice_indent @@ -5,21 +5,38 @@ # x11spice code largely conform to the Spice Project Coding Style. # It's preserved here as a form of documentation. +# Note: Spice is now relaxed about function declarations, +# and allow either style, e.g. +# char *func(){ or +# +# char * +# fund(){ +# That requires calling indent with some thoughtfulness +# By default, it will break procedure types onto newlines +# if you have a file that does not do that, you may want +# to add +# --dont-break-procedure-type +# to your invocation. + + if [ ! -f "$1" ] ; then echo Error: specify a filename to process with indent + echo Usage: + echo 'spice_indent <filename> [ extra-options ]' exit 1 fi +fname="$1" +shift -indent "$1" \ +indent "$fname" \ --no-space-after-function-call-names \ - --dont-break-procedure-type \ --braces-after-func-def-line \ --braces-on-if-line \ --braces-on-struct-decl-line \ --line-length 100 \ --no-space-after-parentheses \ --no-tabs \ - --case-indentation 4 \ + --case-indentation 0 \ --tab-size 4\ --indent-label 0\ --indent-level 4\ @@ -28,6 +45,7 @@ indent "$1" \ --space-after-while \ --space-after-casts \ --space-after-if \ + --cuddle-else \ -T agent_t \ -T SpiceCharDeviceInstance \ -T SpiceChannelEventInfo \ @@ -64,3 +82,5 @@ indent "$1" \ -T xdummy_t \ -T x11spice_server_t \ -T test_t \ + -T Bool \ + $@ diff --git a/spice-video-dummy/src/dummy.h b/spice-video-dummy/src/dummy.h index 8e7c43b..65710ef 100644 --- a/spice-video-dummy/src/dummy.h +++ b/spice-video-dummy/src/dummy.h @@ -29,15 +29,13 @@ extern void DUMMYShowCursor(ScrnInfoPtr pScrn); extern void DUMMYHideCursor(ScrnInfoPtr pScrn); /* globals */ -typedef struct _color -{ +typedef struct _color { int red; int green; int blue; } dummy_colors; -typedef struct dummyRec -{ +typedef struct dummyRec { /* options */ OptionInfoPtr Options; Bool swCursor; @@ -50,10 +48,9 @@ typedef struct dummyRec int cursorFG, cursorBG; dummy_colors colors[1024]; - Bool (*CreateWindow)() ; /* wrapped CreateWindow */ + Bool (*CreateWindow) (); /* wrapped CreateWindow */ Bool prop; } DUMMYRec, *DUMMYPtr; /* The privates of the DUMMY driver */ #define DUMMYPTR(p) ((DUMMYPtr)((p)->driverPrivate)) - diff --git a/spice-video-dummy/src/dummy_cursor.c b/spice-video-dummy/src/dummy_cursor.c index d7c67c6..f38ac53 100644 --- a/spice-video-dummy/src/dummy_cursor.c +++ b/spice-video-dummy/src/dummy_cursor.c @@ -17,7 +17,7 @@ dummyShowCursor(ScrnInfoPtr pScrn) DUMMYPtr dPtr = DUMMYPTR(pScrn); /* turn cursor on */ - dPtr->DummyHWCursorShown = TRUE; + dPtr->DummyHWCursorShown = TRUE; } static void @@ -26,7 +26,7 @@ dummyHideCursor(ScrnInfoPtr pScrn) DUMMYPtr dPtr = DUMMYPTR(pScrn); /* - * turn cursor off + * turn cursor off * */ dPtr->DummyHWCursorShown = FALSE; @@ -47,7 +47,7 @@ static void dummySetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) { DUMMYPtr dPtr = DUMMYPTR(pScrn); - + dPtr->cursorFG = fg; dPtr->cursorBG = bg; } @@ -61,11 +61,11 @@ static Bool dummyUseHWCursor(ScreenPtr pScr, CursorPtr pCurs) { DUMMYPtr dPtr = DUMMYPTR(xf86ScreenToScrn(pScr)); - return(!dPtr->swCursor); + return (!dPtr->swCursor); } #if 0 -static unsigned char* +static unsigned char * dummyRealizeCursor(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) { return NULL; @@ -79,7 +79,8 @@ DUMMYCursorInit(ScreenPtr pScreen) xf86CursorInfoPtr infoPtr; infoPtr = xf86CreateCursorInfoRec(); - if(!infoPtr) return FALSE; + if (!infoPtr) + return FALSE; dPtr->CursorInfo = infoPtr; @@ -94,9 +95,6 @@ DUMMYCursorInit(ScreenPtr pScreen) infoPtr->ShowCursor = dummyShowCursor; infoPtr->UseHWCursor = dummyUseHWCursor; /* infoPtr->RealizeCursor = dummyRealizeCursor; */ - - return(xf86InitCursor(pScreen, infoPtr)); -} - - + return (xf86InitCursor(pScreen, infoPtr)); +} diff --git a/spice-video-dummy/src/dummy_driver.c b/spice-video-dummy/src/dummy_driver.c index b4b42f7..46cde90 100644 --- a/spice-video-dummy/src/dummy_driver.c +++ b/spice-video-dummy/src/dummy_driver.c @@ -41,23 +41,21 @@ #include "servermd.h" /* Mandatory functions */ -static const OptionInfoRec * DUMMYAvailableOptions(int chipid, int busid); -static void DUMMYIdentify(int flags); -static Bool DUMMYProbe(DriverPtr drv, int flags); -static Bool DUMMYPreInit(ScrnInfoPtr pScrn, int flags); -static Bool DUMMYScreenInit(SCREEN_INIT_ARGS_DECL); -static Bool DUMMYEnterVT(VT_FUNC_ARGS_DECL); -static void DUMMYLeaveVT(VT_FUNC_ARGS_DECL); -static Bool DUMMYCloseScreen(CLOSE_SCREEN_ARGS_DECL); -static Bool DUMMYCreateWindow(WindowPtr pWin); -static void DUMMYFreeScreen(FREE_SCREEN_ARGS_DECL); -static ModeStatus DUMMYValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, - Bool verbose, int flags); -static Bool DUMMYSaveScreen(ScreenPtr pScreen, int mode); +static const OptionInfoRec *DUMMYAvailableOptions(int chipid, int busid); +static void DUMMYIdentify(int flags); +static Bool DUMMYProbe(DriverPtr drv, int flags); +static Bool DUMMYPreInit(ScrnInfoPtr pScrn, int flags); +static Bool DUMMYScreenInit(SCREEN_INIT_ARGS_DECL); +static Bool DUMMYEnterVT(VT_FUNC_ARGS_DECL); +static void DUMMYLeaveVT(VT_FUNC_ARGS_DECL); +static Bool DUMMYCloseScreen(CLOSE_SCREEN_ARGS_DECL); +static Bool DUMMYCreateWindow(WindowPtr pWin); +static void DUMMYFreeScreen(FREE_SCREEN_ARGS_DECL); +static ModeStatus DUMMYValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags); +static Bool DUMMYSaveScreen(ScreenPtr pScreen, int mode); /* Internally used functions */ -static Bool dummyDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, - pointer ptr); +static Bool dummyDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr); /* static void DUMMYDisplayPowerManagementSet(ScrnInfoPtr pScrn, */ @@ -101,8 +99,8 @@ _X_EXPORT DriverRec DUMMY = { }; static SymTabRec DUMMYChipsets[] = { - { DUMMY_CHIP, "dummy" }, - { -1, NULL } + {DUMMY_CHIP, "dummy"}, + {-1, NULL} }; typedef enum { @@ -110,26 +108,25 @@ typedef enum { } DUMMYOpts; static const OptionInfoRec DUMMYOptions[] = { - { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, - { -1, NULL, OPTV_NONE, {0}, FALSE } + {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, + {-1, NULL, OPTV_NONE, {0}, FALSE} }; #ifdef XFree86LOADER static MODULESETUPPROTO(dummySetup); -static XF86ModuleVersionInfo dummyVersRec = -{ - "dummy", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - DUMMY_MAJOR_VERSION, DUMMY_MINOR_VERSION, DUMMY_PATCHLEVEL, - ABI_CLASS_VIDEODRV, - ABI_VIDEODRV_VERSION, - MOD_CLASS_VIDEODRV, - {0,0,0,0} +static XF86ModuleVersionInfo dummyVersRec = { + "dummy", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + DUMMY_MAJOR_VERSION, DUMMY_MINOR_VERSION, DUMMY_PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} }; /* @@ -144,22 +141,23 @@ dummySetup(pointer module, pointer opts, int *errmaj, int *errmin) static Bool setupDone = FALSE; if (!setupDone) { - setupDone = TRUE; + setupDone = TRUE; xf86AddDriver(&DUMMY, module, HaveDriverFuncs); - /* - * Modules that this driver always requires can be loaded here - * by calling LoadSubModule(). - */ + /* + * Modules that this driver always requires can be loaded here + * by calling LoadSubModule(). + */ - /* - * The return value must be non-NULL on success even though there - * is no TearDownProc. - */ - return (pointer)1; + /* + * The return value must be non-NULL on success even though there + * is no TearDownProc. + */ + return (pointer) 1; } else { - if (errmaj) *errmaj = LDR_ONCEONLY; - return NULL; + if (errmaj) + *errmaj = LDR_ONCEONLY; + return NULL; } } @@ -174,12 +172,12 @@ DUMMYGetRec(ScrnInfoPtr pScrn) * the allocation has already been done. */ if (pScrn->driverPrivate != NULL) - return TRUE; + return TRUE; pScrn->driverPrivate = xnfcalloc(sizeof(DUMMYRec), 1); if (pScrn->driverPrivate == NULL) - return FALSE; + return FALSE; return TRUE; } @@ -187,7 +185,7 @@ static void DUMMYFreeRec(ScrnInfoPtr pScrn) { if (pScrn->driverPrivate == NULL) - return; + return; free(pScrn->driverPrivate); pScrn->driverPrivate = NULL; } @@ -202,8 +200,7 @@ DUMMYAvailableOptions(int chipid, int busid) static void DUMMYIdentify(int flags) { - xf86PrintChipsets(DUMMY_NAME, "Driver for Dummy chipsets", - DUMMYChipsets); + xf86PrintChipsets(DUMMY_NAME, "Driver for Dummy chipsets", DUMMYChipsets); } /* Mandatory */ @@ -216,51 +213,49 @@ DUMMYProbe(DriverPtr drv, int flags) int i; if (flags & PROBE_DETECT) - return FALSE; + return FALSE; /* * Find the config file Device sections that match this * driver, and return if there are none. */ - if ((numDevSections = xf86MatchDevice(DUMMY_DRIVER_NAME, - &devSections)) <= 0) { - return FALSE; + if ((numDevSections = xf86MatchDevice(DUMMY_DRIVER_NAME, &devSections)) <= 0) { + return FALSE; } numUsed = numDevSections; if (numUsed > 0) { - for (i = 0; i < numUsed; i++) { - ScrnInfoPtr pScrn = NULL; - int entityIndex = - xf86ClaimNoSlot(drv,DUMMY_CHIP,devSections[i],TRUE); - /* Allocate a ScrnInfoRec and claim the slot */ - if ((pScrn = xf86AllocateScreen(drv,0 ))) { - xf86AddEntityToScreen(pScrn,entityIndex); - pScrn->driverVersion = DUMMY_VERSION; - pScrn->driverName = DUMMY_DRIVER_NAME; - pScrn->name = DUMMY_NAME; - pScrn->Probe = DUMMYProbe; - pScrn->PreInit = DUMMYPreInit; - pScrn->ScreenInit = DUMMYScreenInit; - pScrn->SwitchMode = DUMMYSwitchMode; - pScrn->AdjustFrame = DUMMYAdjustFrame; - pScrn->EnterVT = DUMMYEnterVT; - pScrn->LeaveVT = DUMMYLeaveVT; - pScrn->FreeScreen = DUMMYFreeScreen; - pScrn->ValidMode = DUMMYValidMode; - - foundScreen = TRUE; - } - } - } + for (i = 0; i < numUsed; i++) { + ScrnInfoPtr pScrn = NULL; + int entityIndex = xf86ClaimNoSlot(drv, DUMMY_CHIP, devSections[i], TRUE); + /* Allocate a ScrnInfoRec and claim the slot */ + if ((pScrn = xf86AllocateScreen(drv, 0))) { + xf86AddEntityToScreen(pScrn, entityIndex); + pScrn->driverVersion = DUMMY_VERSION; + pScrn->driverName = DUMMY_DRIVER_NAME; + pScrn->name = DUMMY_NAME; + pScrn->Probe = DUMMYProbe; + pScrn->PreInit = DUMMYPreInit; + pScrn->ScreenInit = DUMMYScreenInit; + pScrn->SwitchMode = DUMMYSwitchMode; + pScrn->AdjustFrame = DUMMYAdjustFrame; + pScrn->EnterVT = DUMMYEnterVT; + pScrn->LeaveVT = DUMMYLeaveVT; + pScrn->FreeScreen = DUMMYFreeScreen; + pScrn->ValidMode = DUMMYValidMode; + + foundScreen = TRUE; + } + } + } free(devSections); return foundScreen; } -# define RETURN \ +#define RETURN \ { DUMMYFreeRec(pScrn);\ return FALSE;\ } @@ -275,103 +270,97 @@ DUMMYPreInit(ScrnInfoPtr pScrn, int flags) int maxClock = 300000; GDevPtr device = xf86GetEntityInfo(pScrn->entityList[0])->device; - if (flags & PROBE_DETECT) - return TRUE; - + if (flags & PROBE_DETECT) + return TRUE; + /* Allocate the DummyRec driverPrivate */ if (!DUMMYGetRec(pScrn)) { - return FALSE; + return FALSE; } - + dPtr = DUMMYPTR(pScrn); - pScrn->chipset = (char *)xf86TokenToString(DUMMYChipsets, - DUMMY_CHIP); + pScrn->chipset = (char *) xf86TokenToString(DUMMYChipsets, DUMMY_CHIP); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Chipset is a DUMMY\n"); - + pScrn->monitor = pScrn->confScreen->monitor; - if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb)) - return FALSE; + if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb)) + return FALSE; else { - /* Check that the returned depth is one we support */ - switch (pScrn->depth) { - case 8: - case 15: - case 16: - case 24: - case 30: - break; - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Given depth (%d) is not supported by this driver\n", - pScrn->depth); - return FALSE; - } + /* Check that the returned depth is one we support */ + switch (pScrn->depth) { + case 8: + case 15: + case 16: + case 24: + case 30: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by this driver\n", pScrn->depth); + return FALSE; + } } xf86PrintDepthBpp(pScrn); if (pScrn->depth == 8) - pScrn->rgbBits = 8; + pScrn->rgbBits = 8; /* Get the depth24 pixmap format */ if (pScrn->depth == 24 && pix24bpp == 0) - pix24bpp = xf86GetBppFromDepth(pScrn, 24); + pix24bpp = xf86GetBppFromDepth(pScrn, 24); /* * This must happen after pScrn->display has been set because * xf86SetWeight references it. */ if (pScrn->depth > 8) { - /* The defaults are OK for us */ - rgb zeros = {0, 0, 0}; - - if (!xf86SetWeight(pScrn, zeros, zeros)) { - return FALSE; - } else { - /* XXX check that weight returned is supported */ - ; - } + /* The defaults are OK for us */ + rgb zeros = { 0, 0, 0 }; + + if (!xf86SetWeight(pScrn, zeros, zeros)) { + return FALSE; + } else { + /* XXX check that weight returned is supported */ + ; + } } - if (!xf86SetDefaultVisual(pScrn, -1)) - return FALSE; + if (!xf86SetDefaultVisual(pScrn, -1)) + return FALSE; if (pScrn->depth > 1) { - Gamma zeros = {0.0, 0.0, 0.0}; + Gamma zeros = { 0.0, 0.0, 0.0 }; - if (!xf86SetGamma(pScrn, zeros)) - return FALSE; + if (!xf86SetGamma(pScrn, zeros)) + return FALSE; } xf86CollectOptions(pScrn, device->options); /* Process the options */ if (!(dPtr->Options = malloc(sizeof(DUMMYOptions)))) - return FALSE; + return FALSE; memcpy(dPtr->Options, DUMMYOptions, sizeof(DUMMYOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, dPtr->Options); - xf86GetOptValBool(dPtr->Options, OPTION_SW_CURSOR,&dPtr->swCursor); + xf86GetOptValBool(dPtr->Options, OPTION_SW_CURSOR, &dPtr->swCursor); if (device->videoRam != 0) { - pScrn->videoRam = device->videoRam; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VideoRAM: %d kByte\n", - pScrn->videoRam); + pScrn->videoRam = device->videoRam; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VideoRAM: %d kByte\n", pScrn->videoRam); } else { - pScrn->videoRam = 4096; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "VideoRAM: %d kByte\n", - pScrn->videoRam); + pScrn->videoRam = 4096; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "VideoRAM: %d kByte\n", pScrn->videoRam); } - + if (device->dacSpeeds[0] != 0) { - maxClock = device->dacSpeeds[0]; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Max Clock: %d kHz\n", - maxClock); + maxClock = device->dacSpeeds[0]; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Max Clock: %d kHz\n", maxClock); } else { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Max Clock: %d kHz\n", - maxClock); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Max Clock: %d kHz\n", maxClock); } pScrn->progClock = TRUE; @@ -379,38 +368,37 @@ DUMMYPreInit(ScrnInfoPtr pScrn, int flags) * Setup the ClockRanges, which describe what clock ranges are available, * and what sort of modes they can be used for. */ - clockRanges = (ClockRangePtr)xnfcalloc(sizeof(ClockRange), 1); + clockRanges = (ClockRangePtr) xnfcalloc(sizeof(ClockRange), 1); clockRanges->next = NULL; clockRanges->ClockMulFactor = 1; - clockRanges->minClock = 11000; /* guessed §§§ */ + clockRanges->minClock = 11000; /* guessed §§§ */ clockRanges->maxClock = maxClock; - clockRanges->clockIndex = -1; /* programmable */ - clockRanges->interlaceAllowed = TRUE; + clockRanges->clockIndex = -1; /* programmable */ + clockRanges->interlaceAllowed = TRUE; clockRanges->doubleScanAllowed = TRUE; /* Subtract memory for HW cursor */ { - int apertureSize = (pScrn->videoRam * 1024); - i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, - pScrn->display->modes, clockRanges, - NULL, 256, DUMMY_MAX_WIDTH, - (8 * pScrn->bitsPerPixel), - 128, DUMMY_MAX_HEIGHT, pScrn->display->virtualX, - pScrn->display->virtualY, apertureSize, - LOOKUP_BEST_REFRESH); - - if (i == -1) - RETURN; + int apertureSize = (pScrn->videoRam * 1024); + i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, + pScrn->display->modes, clockRanges, + NULL, 256, DUMMY_MAX_WIDTH, + (8 * pScrn->bitsPerPixel), + 128, DUMMY_MAX_HEIGHT, pScrn->display->virtualX, + pScrn->display->virtualY, apertureSize, LOOKUP_BEST_REFRESH); + + if (i == -1) + RETURN; } /* Prune the modes marked as invalid */ xf86PruneDriverModes(pScrn); if (i == 0 || pScrn->modes == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); - RETURN; + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + RETURN; } /* @@ -421,8 +409,8 @@ DUMMYPreInit(ScrnInfoPtr pScrn, int flags) * driver and if the driver doesn't provide code to set them. They * are not pre-initialised at all. */ - xf86SetCrtcForModes(pScrn, 0); - + xf86SetCrtcForModes(pScrn, 0); + /* Set the current mode to the first in the list */ pScrn->currentMode = pScrn->modes; @@ -433,20 +421,21 @@ DUMMYPreInit(ScrnInfoPtr pScrn, int flags) xf86SetDpi(pScrn, 0, 0); if (xf86LoadSubModule(pScrn, "fb") == NULL) { - RETURN; + RETURN; } if (!dPtr->swCursor) { - if (!xf86LoadSubModule(pScrn, "ramdac")) - RETURN; + if (!xf86LoadSubModule(pScrn, "ramdac")) + RETURN; } - + /* We have no contiguous physical fb in physical memory */ pScrn->memPhysBase = 0; pScrn->fbOffset = 0; return TRUE; } + #undef RETURN /* Mandatory */ @@ -463,39 +452,34 @@ DUMMYLeaveVT(VT_FUNC_ARGS_DECL) } static void -DUMMYLoadPalette( - ScrnInfoPtr pScrn, - int numColors, - int *indices, - LOCO *colors, - VisualPtr pVisual -){ - int i, index, shift, Gshift; - DUMMYPtr dPtr = DUMMYPTR(pScrn); - - switch(pScrn->depth) { - case 15: - shift = Gshift = 1; - break; - case 16: - shift = 0; +DUMMYLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO * colors, VisualPtr pVisual) +{ + int i, index, shift, Gshift; + DUMMYPtr dPtr = DUMMYPTR(pScrn); + + switch (pScrn->depth) { + case 15: + shift = Gshift = 1; + break; + case 16: + shift = 0; Gshift = 0; - break; - default: - shift = Gshift = 0; - break; - } - - for(i = 0; i < numColors; i++) { - index = indices[i]; - dPtr->colors[index].red = colors[index].red << shift; - dPtr->colors[index].green = colors[index].green << Gshift; - dPtr->colors[index].blue = colors[index].blue << shift; - } + break; + default: + shift = Gshift = 0; + break; + } + + for (i = 0; i < numColors; i++) { + index = indices[i]; + dPtr->colors[index].red = colors[index].red << shift; + dPtr->colors[index].green = colors[index].green << Gshift; + dPtr->colors[index].blue = colors[index].blue << shift; + } } -static ScrnInfoPtr DUMMYScrn; /* static-globalize it */ +static ScrnInfoPtr DUMMYScrn; /* static-globalize it */ /* Mandatory */ static Bool @@ -517,102 +501,98 @@ DUMMYScreenInit(SCREEN_INIT_ARGS_DECL) if (!(pixels = malloc(pScrn->videoRam * 1024))) - return FALSE; + return FALSE; /* * Reset visual list. */ miClearVisualTypes(); - + /* Setup the visuals we support. */ - + if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; - if (!miSetPixmapDepths ()) return FALSE; + if (!miSetPixmapDepths()) + return FALSE; /* * Call the framebuffer layer's ScreenInit function, and fill in other * pScreen fields. */ ret = fbScreenInit(pScreen, pixels, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth, pScrn->bitsPerPixel); + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, pScrn->bitsPerPixel); if (!ret) - return FALSE; + return FALSE; if (pScrn->depth > 8) { /* Fixup RGB ordering */ visual = pScreen->visuals + pScreen->numVisuals; while (--visual >= pScreen->visuals) { - if ((visual->class | DynamicClass) == DirectColor) { - visual->offsetRed = pScrn->offset.red; - visual->offsetGreen = pScrn->offset.green; - visual->offsetBlue = pScrn->offset.blue; - visual->redMask = pScrn->mask.red; - visual->greenMask = pScrn->mask.green; - visual->blueMask = pScrn->mask.blue; - } - } + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } } - + /* must be after RGB ordering fixed */ fbPictureInit(pScreen, 0, 0); xf86SetBlackWhitePixels(pScreen); if (dPtr->swCursor) - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using Software Cursor.\n"); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using Software Cursor.\n"); { - - BoxRec AvailFBArea; - int lines = pScrn->videoRam * 1024 / - (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); - AvailFBArea.x1 = 0; - AvailFBArea.y1 = 0; - AvailFBArea.x2 = pScrn->displayWidth; - AvailFBArea.y2 = lines; - xf86InitFBManager(pScreen, &AvailFBArea); - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using %i scanlines of offscreen memory \n" - , lines - pScrn->virtualY); + + BoxRec AvailFBArea; + int lines = pScrn->videoRam * 1024 / (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); + AvailFBArea.x1 = 0; + AvailFBArea.y1 = 0; + AvailFBArea.x2 = pScrn->displayWidth; + AvailFBArea.y2 = lines; + xf86InitFBManager(pScreen, &AvailFBArea); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %i scanlines of offscreen memory \n", lines - pScrn->virtualY); } xf86SetBackingStore(pScreen); xf86SetSilkenMouse(pScreen); - + /* Initialise cursor functions */ - miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); if (!dPtr->swCursor) { - /* HW cursor functions */ - if (!DUMMYCursorInit(pScreen)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Hardware cursor initialization failed\n"); - return FALSE; - } + /* HW cursor functions */ + if (!DUMMYCursorInit(pScreen)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Hardware cursor initialization failed\n"); + return FALSE; + } } - + /* Initialise default colourmap */ - if(!miCreateDefColormap(pScreen)) - return FALSE; + if (!miCreateDefColormap(pScreen)) + return FALSE; if (!xf86HandleColormaps(pScreen, 1024, pScrn->rgbBits, - DUMMYLoadPalette, NULL, - CMAP_PALETTED_TRUECOLOR - | CMAP_RELOAD_ON_MODE_SWITCH)) - return FALSE; + DUMMYLoadPalette, NULL, + CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) + return FALSE; pScreen->SaveScreen = DUMMYSaveScreen; - + /* Wrap the current CloseScreen function */ dPtr->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = DUMMYCloseScreen; @@ -623,7 +603,7 @@ DUMMYScreenInit(SCREEN_INIT_ARGS_DECL) /* Report any unused options (only for the first generation) */ if (serverGeneration == 1) { - xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); } return TRUE; @@ -652,11 +632,11 @@ DUMMYCloseScreen(CLOSE_SCREEN_ARGS_DECL) free(pScreen->GetScreenPixmap(pScreen)->devPrivate.ptr); if (dPtr->CursorInfo) - xf86DestroyCursorInfoRec(dPtr->CursorInfo); + xf86DestroyCursorInfoRec(dPtr->CursorInfo); pScrn->vtSema = FALSE; pScreen->CloseScreen = dPtr->CloseScreen; - return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); + return (*pScreen->CloseScreen) (CLOSE_SCREEN_ARGS); } /* Optional */ @@ -677,10 +657,10 @@ DUMMYSaveScreen(ScreenPtr pScreen, int mode) static ModeStatus DUMMYValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags) { - return(MODE_OK); + return (MODE_OK); } -Atom VFB_PROP = 0; +Atom VFB_PROP = 0; #define VFB_PROP_NAME "VFB_IDENT" static Bool @@ -696,26 +676,26 @@ DUMMYCreateWindow(WindowPtr pWin) dPtr->CreateWindow = pScreen->CreateWindow; pScreen->CreateWindow = DUMMYCreateWindow; - if(ret != TRUE) - return(ret); - - if(dPtr->prop == FALSE) { + if (ret != TRUE) + return (ret); + + if (dPtr->prop == FALSE) { #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 8 pWinRoot = WindowTable[DUMMYScrn->pScreen->myNum]; #else pWinRoot = DUMMYScrn->pScreen->root; #endif - if (! ValidAtom(VFB_PROP)) + if (!ValidAtom(VFB_PROP)) VFB_PROP = MakeAtom(VFB_PROP_NAME, strlen(VFB_PROP_NAME), 1); ret = dixChangeWindowProperty(serverClient, pWinRoot, VFB_PROP, XA_STRING, 8, PropModeReplace, - (int)4, (pointer)"TRUE", FALSE); - if( ret != Success) - ErrorF("Could not set VFB root window property"); + (int) 4, (pointer) "TRUE", FALSE); + if (ret != Success) + ErrorF("Could not set VFB root window property"); dPtr->prop = TRUE; - return TRUE; + return TRUE; } return TRUE; } @@ -728,13 +708,13 @@ static Bool dummyDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr) { CARD32 *flag; - + switch (op) { - case GET_REQUIRED_HW_INTERFACES: - flag = (CARD32*)ptr; - (*flag) = HW_SKIP_CONSOLE; - return TRUE; - default: - return FALSE; + case GET_REQUIRED_HW_INTERFACES: + flag = (CARD32 *) ptr; + (*flag) = HW_SKIP_CONSOLE; + return TRUE; + default: + return FALSE; } } -- 2.11.0 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel