aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix')
-rw-r--r--xorg-server/dix/dispatch.c113
-rw-r--r--xorg-server/dix/dixutils.c6
-rw-r--r--xorg-server/dix/main.c15
-rw-r--r--xorg-server/dix/privates.c4
4 files changed, 121 insertions, 17 deletions
diff --git a/xorg-server/dix/dispatch.c b/xorg-server/dix/dispatch.c
index 7d2d3b727..fa397285c 100644
--- a/xorg-server/dix/dispatch.c
+++ b/xorg-server/dix/dispatch.c
@@ -3724,32 +3724,20 @@ 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, Bool gpu)
{
-
- 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;
+ if (gpu) {
+ pScreen->myNum += GPU_SCREEN_OFFSET;
+ pScreen->isGPU = TRUE;
+ }
pScreen->totalPixmapSize = 0; /* computed in CreateScratchPixmapForScreen */
pScreen->ClipNotify = 0; /* for R4 ddx compatibility */
pScreen->CreateScreenResources = 0;
@@ -3784,7 +3772,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, FALSE);
+ 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
@@ -3810,3 +3824,68 @@ AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ ,
return i;
}
+
+int
+AddGPUScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ ,
+ int /*argc */ ,
+ char ** /*argv */
+ ),
+ int argc, char **argv)
+{
+ int i;
+ ScreenPtr pScreen;
+ Bool ret;
+
+ i = screenInfo.numGPUScreens;
+ if (i == MAXGPUSCREENS)
+ return -1;
+
+ pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec));
+ if (!pScreen)
+ return -1;
+
+ ret = init_screen(pScreen, i, TRUE);
+ 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
+ also pixel values for blackPixel, whitePixel, and the cursor
+ Note that InitScreen is NOT allowed to modify argc, argv, or
+ any of the strings pointed to by argv. They may be passed to
+ multiple screens.
+ */
+ screenInfo.gpuscreens[i] = pScreen;
+ screenInfo.numGPUScreens++;
+ if (!(*pfnInit) (pScreen, argc, argv)) {
+ dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
+ free(pScreen);
+ screenInfo.numGPUScreens--;
+ return -1;
+ }
+
+ update_desktop_dimensions();
+
+ return i;
+}
+
+void
+RemoveGPUScreen(ScreenPtr pScreen)
+{
+ int idx, j;
+ if (!pScreen->isGPU)
+ return;
+
+ idx = pScreen->myNum - GPU_SCREEN_OFFSET;
+ for (j = idx; j < screenInfo.numGPUScreens - 1; j++) {
+ screenInfo.gpuscreens[j] = screenInfo.gpuscreens[j + 1];
+ screenInfo.gpuscreens[j]->myNum = j + GPU_SCREEN_OFFSET;
+ }
+ screenInfo.numGPUScreens--;
+
+ free(pScreen);
+
+}
diff --git a/xorg-server/dix/dixutils.c b/xorg-server/dix/dixutils.c
index b249a810b..3f24629b4 100644
--- a/xorg-server/dix/dixutils.c
+++ b/xorg-server/dix/dixutils.c
@@ -386,6 +386,9 @@ BlockHandler(pointer pTimeout, pointer pReadmask)
for (i = 0; i < screenInfo.numScreens; i++)
(*screenInfo.screens[i]->BlockHandler) (screenInfo.screens[i],
pTimeout, pReadmask);
+ for (i = 0; i < screenInfo.numGPUScreens; i++)
+ (*screenInfo.gpuscreens[i]->BlockHandler) (screenInfo.gpuscreens[i],
+ pTimeout, pReadmask);
for (i = 0; i < numHandlers; i++)
if (!handlers[i].deleted)
(*handlers[i].BlockHandler) (handlers[i].blockData,
@@ -422,6 +425,9 @@ WakeupHandler(int result, pointer pReadmask)
for (i = 0; i < screenInfo.numScreens; i++)
(*screenInfo.screens[i]->WakeupHandler) (screenInfo.screens[i],
result, pReadmask);
+ for (i = 0; i < screenInfo.numGPUScreens; i++)
+ (*screenInfo.gpuscreens[i]->WakeupHandler) (screenInfo.gpuscreens[i],
+ result, pReadmask);
if (handlerDeleted) {
for (i = 0; i < numHandlers;)
if (handlers[i].deleted) {
diff --git a/xorg-server/dix/main.c b/xorg-server/dix/main.c
index 9524189d0..42f517dfd 100644
--- a/xorg-server/dix/main.c
+++ b/xorg-server/dix/main.c
@@ -207,6 +207,12 @@ main(int argc, char *argv[], char *envp[])
FatalError("no screens found");
InitExtensions(argc, argv);
+ for (i = 0; i < screenInfo.numGPUScreens; i++) {
+ ScreenPtr pScreen = screenInfo.gpuscreens[i];
+ if (!CreateScratchPixmapsForScreen(pScreen))
+ FatalError("failed to create scratch pixmaps");
+ }
+
for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i];
@@ -336,6 +342,15 @@ main(int argc, char *argv[], char *envp[])
screenInfo.numScreens = i;
}
+ for (i = screenInfo.numGPUScreens - 1; i >= 0; i--) {
+ ScreenPtr pScreen = screenInfo.gpuscreens[i];
+ FreeScratchPixmapsForScreen(pScreen);
+ (*pScreen->CloseScreen) (pScreen);
+ dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
+ free(pScreen);
+ screenInfo.numGPUScreens = i;
+ }
+
ReleaseClientIds(serverClient);
dixFreePrivates(serverClient->devPrivates, PRIVATE_CLIENT);
serverClient->devPrivates = NULL;
diff --git a/xorg-server/dix/privates.c b/xorg-server/dix/privates.c
index b58085ffd..740ead739 100644
--- a/xorg-server/dix/privates.c
+++ b/xorg-server/dix/privates.c
@@ -222,6 +222,10 @@ fixupScreens(FixupFunc fixup, unsigned bytes)
for (s = 0; s < screenInfo.numScreens; s++)
if (!fixupOneScreen (screenInfo.screens[s], fixup, bytes))
return FALSE;
+
+ for (s = 0; s < screenInfo.numGPUScreens; s++)
+ if (!fixupOneScreen (screenInfo.gpuscreens[s], fixup, bytes))
+ return FALSE;
return TRUE;
}