diff options
author | Dave Airlie <airlied@redhat.com> | 2012-06-05 17:01:21 +0100 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-07-06 10:20:19 +0100 |
commit | 3478af3374abffa0c226ee077fda1fcfc0751e74 (patch) | |
tree | 73c7222a2aa4ce07f411522044c44da56b6d4134 /dix/dispatch.c | |
parent | cf66471353ac5899383b573a3cfca407e90d501e (diff) |
screen: split out screen init code. (v2)
This is a precursor for reusing this code to init gpu screens.
v2: fixup int check as per Keith's review.
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'dix/dispatch.c')
-rw-r--r-- | dix/dispatch.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/dix/dispatch.c b/dix/dispatch.c index 7d2d3b727..39d791d4c 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3724,29 +3724,13 @@ with its screen number, a pointer to its ScreenRec, argc, and argv. */ -int -AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , - int /*argc */ , - char ** /*argv */ - ), int argc, char **argv) +static int init_screen(ScreenPtr pScreen, int i) { - - int i; int scanlinepad, format, depth, bitsPerPixel, j, k; - ScreenPtr pScreen; - - i = screenInfo.numScreens; - if (i == MAXSCREENS) - return -1; - - pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec)); - if (!pScreen) - return -1; dixInitScreenSpecificPrivates(pScreen); if (!dixAllocatePrivates(&pScreen->devPrivates, PRIVATE_SCREEN)) { - free(pScreen); return -1; } pScreen->myNum = i; @@ -3784,7 +3768,33 @@ AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , PixmapWidthPaddingInfo[depth].notPower2 = 0; } } + return 0; +} + +int +AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , + int /*argc */ , + char ** /*argv */ + ), int argc, char **argv) +{ + int i; + ScreenPtr pScreen; + Bool ret; + + i = screenInfo.numScreens; + if (i == MAXSCREENS) + return -1; + + pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec)); + if (!pScreen) + return -1; + + ret = init_screen(pScreen, i); + if (ret != 0) { + free(pScreen); + return ret; + } /* This is where screen specific stuff gets initialized. Load the screen structure, call the hardware, whatever. This is also where the default colormap should be allocated and |