[Spice-devel] [PATCH v2 x11spice 2/4] Apply Spice style to the spice-video-dummy
Frediano Ziglio
fziglio at redhat.com
Thu May 2 11:28:23 UTC 2019
I suppose from IRC chat you used indent tool.
> Signed-off-by: Jeremy White <jwhite at codeweavers.com>
> ---
> spice-video-dummy/src/dummy.h | 9 +-
> spice-video-dummy/src/dummy_cursor.c | 42 +--
> spice-video-dummy/src/dummy_driver.c | 558
> ++++++++++++++++-------------------
> 3 files changed, 281 insertions(+), 328 deletions(-)
>
> diff --git a/spice-video-dummy/src/dummy.h b/spice-video-dummy/src/dummy.h
> index 8e7c43b..0c16591 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 */
I would personally use Bool (*CreateWindow)();
Maybe indent got confused by function declaration?
We don't usually put space(s) between function and parameters.
> 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..ccce442 100644
> --- a/spice-video-dummy/src/dummy_cursor.c
> +++ b/spice-video-dummy/src/dummy_cursor.c
> @@ -11,22 +11,20 @@
> /* Driver specific headers */
> #include "dummy.h"
>
> -static void
> -dummyShowCursor(ScrnInfoPtr pScrn)
> +static void dummyShowCursor(ScrnInfoPtr pScrn)
This was relaxed, we accept both. Can you tell to indent
"don't change this" ?
> {
> DUMMYPtr dPtr = DUMMYPTR(pScrn);
>
> /* turn cursor on */
> - dPtr->DummyHWCursorShown = TRUE;
> + dPtr->DummyHWCursorShown = TRUE;
> }
>
> -static void
> -dummyHideCursor(ScrnInfoPtr pScrn)
> +static void dummyHideCursor(ScrnInfoPtr pScrn)
> {
> DUMMYPtr dPtr = DUMMYPTR(pScrn);
>
> /*
> - * turn cursor off
> + * turn cursor off
> *
> */
> dPtr->DummyHWCursorShown = FALSE;
> @@ -34,8 +32,7 @@ dummyHideCursor(ScrnInfoPtr pScrn)
>
> #define MAX_CURS 64
>
> -static void
> -dummySetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
> +static void dummySetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
> {
> DUMMYPtr dPtr = DUMMYPTR(pScrn);
>
> @@ -43,43 +40,39 @@ dummySetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
> dPtr->cursorY = y;
> }
>
> -static void
> -dummySetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
> +static void dummySetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
> {
> DUMMYPtr dPtr = DUMMYPTR(pScrn);
> -
> +
> dPtr->cursorFG = fg;
> dPtr->cursorBG = bg;
> }
>
> -static void
> -dummyLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
> +static void dummyLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
> {
> }
>
> -static Bool
> -dummyUseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
> +static Bool dummyUseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
> {
> DUMMYPtr dPtr = DUMMYPTR(xf86ScreenToScrn(pScr));
> - return(!dPtr->swCursor);
> + return (!dPtr->swCursor);
> }
>
> #if 0
> -static unsigned char*
> -dummyRealizeCursor(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
> +static unsigned char *dummyRealizeCursor(xf86CursorInfoPtr infoPtr,
> CursorPtr pCurs)
> {
> return NULL;
> }
> #endif
>
> -Bool
> -DUMMYCursorInit(ScreenPtr pScreen)
> +Bool DUMMYCursorInit(ScreenPtr pScreen)
> {
> DUMMYPtr dPtr = DUMMYPTR(xf86ScreenToScrn(pScreen));
>
> xf86CursorInfoPtr infoPtr;
> infoPtr = xf86CreateCursorInfoRec();
> - if(!infoPtr) return FALSE;
> + if (!infoPtr)
> + return FALSE;
>
What we usually want is always brackets for if so
if (!infoPtr) {
return FALSE;
}
(this should be doable using indent, not sure how).
> dPtr->CursorInfo = infoPtr;
>
> @@ -94,9 +87,6 @@ DUMMYCursorInit(ScreenPtr pScreen)
> infoPtr->ShowCursor = dummyShowCursor;
> infoPtr->UseHWCursor = dummyUseHWCursor;
> /* infoPtr->RealizeCursor = dummyRealizeCursor; */
> -
> - return(xf86InitCursor(pScreen, infoPtr));
> -}
> -
> -
>
> + return (xf86InitCursor(pScreen, infoPtr));
I would remove the parenthesis, like
return xf86InitCursor(pScreen, infoPtr);
(not strong)
> +}
> diff --git a/spice-video-dummy/src/dummy_driver.c
> b/spice-video-dummy/src/dummy_driver.c
> index b4b42f7..0696151 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}
> };
>
> /*
> @@ -138,35 +135,35 @@ static XF86ModuleVersionInfo dummyVersRec =
> */
> _X_EXPORT XF86ModuleData dummyModuleData = { &dummyVersRec, dummySetup, NULL
> };
>
> -static pointer
> -dummySetup(pointer module, pointer opts, int *errmaj, int *errmin)
> +static pointer 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().
> - */
> -
> - /*
> - * 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;
> + /*
> + * 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;
> + }
> + else {
Would be
} else {
> + if (errmaj)
> + *errmaj = LDR_ONCEONLY;
> + return NULL;
> }
> }
>
> #endif /* XFree86LOADER */
>
> -static Bool
> -DUMMYGetRec(ScrnInfoPtr pScrn)
> +static Bool DUMMYGetRec(ScrnInfoPtr pScrn)
> {
> /*
> * Allocate a DUMMYRec, and hook it into pScrn->driverPrivate.
> @@ -174,41 +171,36 @@ 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;
> }
>
> -static void
> -DUMMYFreeRec(ScrnInfoPtr pScrn)
> +static void DUMMYFreeRec(ScrnInfoPtr pScrn)
> {
> if (pScrn->driverPrivate == NULL)
> - return;
> + return;
> free(pScrn->driverPrivate);
> pScrn->driverPrivate = NULL;
> }
>
> -static const OptionInfoRec *
> -DUMMYAvailableOptions(int chipid, int busid)
> +static const OptionInfoRec *DUMMYAvailableOptions(int chipid, int busid)
> {
> return DUMMYOptions;
> }
>
> /* Mandatory */
> -static void
> -DUMMYIdentify(int flags)
> +static void DUMMYIdentify(int flags)
> {
> - xf86PrintChipsets(DUMMY_NAME, "Driver for Dummy chipsets",
> - DUMMYChipsets);
> + xf86PrintChipsets(DUMMY_NAME, "Driver for Dummy chipsets",
> DUMMYChipsets);
> }
>
> /* Mandatory */
> -static Bool
> -DUMMYProbe(DriverPtr drv, int flags)
> +static Bool DUMMYProbe(DriverPtr drv, int flags)
> {
> Bool foundScreen = FALSE;
> int numDevSections, numUsed;
> @@ -216,58 +208,55 @@ 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;\
> }
>
> /* Mandatory */
> -Bool
> -DUMMYPreInit(ScrnInfoPtr pScrn, int flags)
> +Bool DUMMYPreInit(ScrnInfoPtr pScrn, int flags)
> {
> ClockRangePtr clockRanges;
> int i;
> @@ -275,103 +264,100 @@ 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:
We usually don't indent cases with switch.
> + 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);
> - } else {
> - pScrn->videoRam = 4096;
> - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "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);
> }
> -
> +
> if (device->dacSpeeds[0] != 0) {
> - 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);
> + 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);
> }
>
> pScrn->progClock = TRUE;
> @@ -379,38 +365,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 +406,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,73 +418,66 @@ 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 */
> -static Bool
> -DUMMYEnterVT(VT_FUNC_ARGS_DECL)
> +static Bool DUMMYEnterVT(VT_FUNC_ARGS_DECL)
> {
> return TRUE;
> }
>
> /* Mandatory */
> -static void
> -DUMMYLeaveVT(VT_FUNC_ARGS_DECL)
> +static void 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;
> - 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;
> - }
> +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;
> + }
>
> }
>
> -static ScrnInfoPtr DUMMYScrn; /* static-globalize it */
> +static ScrnInfoPtr DUMMYScrn; /* static-globalize it */
>
> /* Mandatory */
> -static Bool
> -DUMMYScreenInit(SCREEN_INIT_ARGS_DECL)
> +static Bool DUMMYScreenInit(SCREEN_INIT_ARGS_DECL)
> {
> ScrnInfoPtr pScrn;
> DUMMYPtr dPtr;
> @@ -517,102 +495,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,28 +597,25 @@ 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;
> }
>
> /* Mandatory */
> -Bool
> -DUMMYSwitchMode(SWITCH_MODE_ARGS_DECL)
> +Bool DUMMYSwitchMode(SWITCH_MODE_ARGS_DECL)
> {
> return TRUE;
> }
>
> /* Mandatory */
> -void
> -DUMMYAdjustFrame(ADJUST_FRAME_ARGS_DECL)
> +void DUMMYAdjustFrame(ADJUST_FRAME_ARGS_DECL)
> {
> }
>
> /* Mandatory */
> -static Bool
> -DUMMYCloseScreen(CLOSE_SCREEN_ARGS_DECL)
> +static Bool DUMMYCloseScreen(CLOSE_SCREEN_ARGS_DECL)
> {
> ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
> DUMMYPtr dPtr = DUMMYPTR(pScrn);
> @@ -652,39 +623,35 @@ 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 */
> -static void
> -DUMMYFreeScreen(FREE_SCREEN_ARGS_DECL)
> +static void DUMMYFreeScreen(FREE_SCREEN_ARGS_DECL)
> {
> SCRN_INFO_PTR(arg);
> DUMMYFreeRec(pScrn);
> }
>
> -static Bool
> -DUMMYSaveScreen(ScreenPtr pScreen, int mode)
> +static Bool DUMMYSaveScreen(ScreenPtr pScreen, int mode)
> {
> return TRUE;
> }
>
> /* Optional */
> -static ModeStatus
> -DUMMYValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int
> flags)
> +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
> -DUMMYCreateWindow(WindowPtr pWin)
> +static Bool DUMMYCreateWindow(WindowPtr pWin)
> {
> ScreenPtr pScreen = pWin->drawable.pScreen;
> DUMMYPtr dPtr = DUMMYPTR(DUMMYScrn);
> @@ -696,26 +663,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;
> }
> @@ -724,17 +691,16 @@ DUMMYCreateWindow(WindowPtr pWin)
> #define HW_SKIP_CONSOLE 4
> #endif
>
> -static Bool
> -dummyDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr)
> +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;
> }
> }
Frediano
More information about the Spice-devel
mailing list