From a7bbd0cbf4b7a7331bb441c9c744c148435b5155 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 9 Jan 2013 12:51:55 +1000 Subject: [PATCH] gpu screen: upstream fixes dix/gpu: remove asserts for output/offload from same slave xf86crtc: don't use scrn->display for gpu screens dix: allow pixmap dirty helper to be used for non-shared pixmaps gpu: call CreateScreenResources for GPU screens xfree86: don't enable anything in xf86InitialConfiguration for GPU screens Signed-off-by: Dave Airlie --- dix/dispatch.c | 2 -- dix/main.c | 3 +++ dix/pixmap.c | 2 ++ fb/fbpixmap.c | 1 + hw/xfree86/common/xf86platformBus.c | 8 ++++++++ hw/xfree86/modes/xf86Crtc.c | 34 ++++++++++++++++++++++++---------- 6 files changed, 38 insertions(+), 12 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 8d61735..90b6c7c 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3942,7 +3942,6 @@ void AttachOutputGPU(ScreenPtr pScreen, ScreenPtr new) { assert(new->isGPU); - assert(!new->current_master); xorg_list_add(&new->output_head, &pScreen->output_slave_list); new->current_master = pScreen; } @@ -3959,7 +3958,6 @@ void AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr new) { assert(new->isGPU); - assert(!new->current_master); xorg_list_add(&new->offload_head, &pScreen->offload_slave_list); new->current_master = pScreen; } diff --git a/dix/main.c b/dix/main.c index fb935c9..e558d70 100644 --- a/dix/main.c +++ b/dix/main.c @@ -211,6 +211,9 @@ main(int argc, char *argv[], char *envp[]) ScreenPtr pScreen = screenInfo.gpuscreens[i]; if (!CreateScratchPixmapsForScreen(pScreen)) FatalError("failed to create scratch pixmaps"); + if (pScreen->CreateScreenResources && + !(*pScreen->CreateScreenResources) (pScreen)) + FatalError("failed to create screen resources"); } for (i = 0; i < screenInfo.numScreens; i++) { diff --git a/dix/pixmap.c b/dix/pixmap.c index 2418812..fe92147 100644 --- a/dix/pixmap.c +++ b/dix/pixmap.c @@ -243,6 +243,8 @@ Bool PixmapSyncDirtyHelper(PixmapDirtyUpdatePtr dirty, RegionPtr dirty_region) } dst = dirty->slave_dst->master_pixmap; + if (!dst) + dst = dirty->slave_dst; RegionTranslate(dirty_region, -dirty->x, -dirty->y); n = RegionNumRects(dirty_region); diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c index fbcdca9..0824b64 100644 --- a/fb/fbpixmap.c +++ b/fb/fbpixmap.c @@ -67,6 +67,7 @@ fbCreatePixmapBpp(ScreenPtr pScreen, int width, int height, int depth, int bpp, pPixmap->devKind = paddedWidth; pPixmap->refcnt = 1; pPixmap->devPrivate.ptr = (pointer) ((char *) pPixmap + base + adjust); + pPixmap->master_pixmap = NULL; #ifdef FB_DEBUG pPixmap->devPrivate.ptr = diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c index bcb65ff..e368dee 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -455,6 +455,14 @@ xf86platformAddDevice(int index) CreateScratchPixmapsForScreen(xf86GPUScreens[i]->pScreen); + if (xf86GPUScreens[i]->pScreen->CreateScreenResources && + !(*xf86GPUScreens[i]->pScreen->CreateScreenResources) (xf86GPUScreens[i]->pScreen)) { + RemoveGPUScreen(xf86GPUScreens[i]->pScreen); + xf86DeleteScreen(xf86GPUScreens[i]); + xf86UnclaimPlatformSlot(&xf86_platform_devices[index], NULL); + xf86NumGPUScreens = old_screens; + return -1; + } /* attach unbound to 0 protocol screen */ AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen); diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 7d55f60..989595f 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1908,6 +1908,14 @@ xf86CollectEnabledOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, Bool any_enabled = FALSE; int o; + /* + * Don't bother enabling outputs on GPU screens: a client needs to attach + * it to a source provider before setting a mode that scans out a shared + * pixmap. + */ + if (scrn->is_gpu) + return FALSE; + for (o = 0; o < config->num_output; o++) any_enabled |= enabled[o] = xf86OutputEnabled(config->output[o], TRUE); @@ -2360,11 +2368,11 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow) config->debug_modes = xf86ReturnOptValBool(config->options, OPTION_MODEDEBUG, FALSE); - if (scrn->display->virtualX) + if (scrn->display->virtualX && !scrn->is_gpu) width = scrn->display->virtualX; else width = config->maxWidth; - if (scrn->display->virtualY) + if (scrn->display->virtualY && !scrn->is_gpu) height = scrn->display->virtualY; else height = config->maxHeight; @@ -2377,9 +2385,11 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow) ret = xf86CollectEnabledOutputs(scrn, config, enabled); if (ret == FALSE && canGrow) { - xf86DrvMsg(i, X_WARNING, - "Unable to find connected outputs - setting %dx%d initial framebuffer\n", - NO_OUTPUT_DEFAULT_WIDTH, NO_OUTPUT_DEFAULT_HEIGHT); + if (!scrn->is_gpu) + xf86DrvMsg(i, X_WARNING, + "Unable to find connected outputs - setting %dx%d " + "initial framebuffer\n", + NO_OUTPUT_DEFAULT_WIDTH, NO_OUTPUT_DEFAULT_HEIGHT); have_outputs = FALSE; } else { @@ -2428,8 +2438,10 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow) /* XXX override xf86 common frame computation code */ - scrn->display->frameX0 = 0; - scrn->display->frameY0 = 0; + if (!scrn->is_gpu) { + scrn->display->frameX0 = 0; + scrn->display->frameY0 = 0; + } for (c = 0; c < config->num_crtc; c++) { xf86CrtcPtr crtc = config->crtc[c]; @@ -2477,7 +2489,7 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow) } } - if (scrn->display->virtualX == 0) { + if (scrn->display->virtualX == 0 || scrn->is_gpu) { /* * Expand virtual size to cover the current config and potential mode * switches, if the driver can't enlarge the screen later. @@ -2492,8 +2504,10 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow) } } - scrn->display->virtualX = width; - scrn->display->virtualY = height; + if (!scrn->is_gpu) { + scrn->display->virtualX = width; + scrn->display->virtualY = height; + } } if (width > scrn->virtualX) -- 1.8.2