diff options
author | James Simmons <jsimmons@infradead.org> | 2012-03-29 16:36:26 -0400 |
---|---|---|
committer | James Simmons <jsimmons@infradead.org> | 2012-03-29 16:36:26 -0400 |
commit | c98e98009d95a75d145f8ef3a924c9b0a6a1fcc8 (patch) | |
tree | 336e227645c5128e473523e74d4a83dd6f71d78b | |
parent | dd7566f77e4f56bd4fdf137516d7771968cba5f8 (diff) |
Fixed screen resizing from UMS and KMS.
-rw-r--r-- | src/via_display.c | 46 | ||||
-rw-r--r-- | src/via_driver.c | 109 | ||||
-rw-r--r-- | src/via_exa.c | 41 | ||||
-rw-r--r-- | src/via_kms.c | 13 |
4 files changed, 125 insertions, 84 deletions
diff --git a/src/via_display.c b/src/via_display.c index 9cc3294..6f8c06c 100644 --- a/src/via_display.c +++ b/src/via_display.c @@ -164,48 +164,6 @@ ViaCRTCSetAttributeRegisters(ScrnInfoPtr pScrn) hwp->writeAttr(hwp, 0x14, 0x00); } -static Bool -via_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) -{ - ScreenPtr screen = screenInfo.screens[scrn->scrnIndex]; - PixmapPtr ppix = screen->GetScreenPixmap(screen); - int old_width, old_height, old_pitch, pitch; - VIAPtr pVia = VIAPTR(scrn); - void *shadow = NULL; - - if (scrn->virtualX == width && scrn->virtualY == height) - return TRUE; - - DEBUG(xf86DrvMsg(scrn->scrnIndex, X_INFO, "xf86crtc_resize\n")); - - old_width = scrn->virtualX; - old_height = scrn->virtualY; - scrn->virtualX = width; - scrn->virtualY = height; - - if (pVia->shadowFB) { - pitch = BitmapBytePad(scrn->bitsPerPixel * width); - shadow = malloc(height * pitch); - if (!shadow) - goto fail; - free(pVia->ShadowPtr); - pVia->ShadowPtr = shadow; - screen->ModifyPixmapHeader(ppix, width, height, -1, -1, pitch, - pVia->ShadowPtr); - } - return xf86SetDesiredModes(scrn); - -fail: - scrn->virtualY = old_height; - scrn->virtualX = old_width; - return FALSE; -} - -static const -xf86CrtcConfigFuncsRec via_xf86crtc_config_funcs = { - via_xf86crtc_resize -}; - void VIALoadRgbLut(ScrnInfoPtr pScrn, int start, int numColors, LOCO *colors) { @@ -1800,8 +1758,6 @@ UMSCrtcInit(ScrnInfoPtr pScrn) /* * Now handle the outputs */ - xf86CrtcConfigInit(pScrn, &via_xf86crtc_config_funcs); - iga1_rec = (drmmode_crtc_private_ptr) xnfcalloc(sizeof(drmmode_crtc_private_rec), 1); if (!iga1_rec) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "IGA1 Rec allocation failed.\n"); @@ -1814,6 +1770,7 @@ UMSCrtcInit(ScrnInfoPtr pScrn) free(iga1_rec); return FALSE; } + iga1_rec->drmmode = &pVia->drmmode; iga1_rec->index = 0; iga1->driver_private = iga1_rec; @@ -1831,6 +1788,7 @@ UMSCrtcInit(ScrnInfoPtr pScrn) free(iga2_rec); return FALSE; } + iga2_rec->drmmode = &pVia->drmmode; iga2_rec->index = 1; iga2->driver_private = iga2_rec; diff --git a/src/via_driver.c b/src/via_driver.c index 9280e9e..efb2b92 100644 --- a/src/via_driver.c +++ b/src/via_driver.c @@ -777,6 +777,101 @@ VIAGetRec(ScrnInfoPtr pScrn) } /* VIAGetRec */ static Bool +via_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[0]->driver_private; + drmmode_ptr drmmode = drmmode_crtc->drmmode; + int old_width, old_height, old_dwidth, pitch; + int cpp = (scrn->bitsPerPixel + 7) >> 3; + struct buffer_object *old_front = NULL; + ScreenPtr screen = scrn->pScreen; + VIAPtr pVia = VIAPTR(scrn); + void *new_pixels = NULL; + uint32_t old_fb_id; + PixmapPtr ppix; + + if (scrn->virtualX == width && scrn->virtualY == height) + return TRUE; + + xf86DrvMsg(scrn->scrnIndex, X_INFO, + "Allocate new frame buffer %dx%d stride\n", + width, height); + + old_width = scrn->virtualX; + old_height = scrn->virtualY; + old_dwidth = scrn->displayWidth; + old_fb_id = drmmode->fb_id; + old_front = drmmode->front_bo; + + drmmode->front_bo = drm_bo_alloc_surface(scrn, width * cpp, height, + 0, 16, TTM_PL_FLAG_VRAM); + if (!drmmode->front_bo) + goto fail; + + pitch = drmmode->front_bo->pitch; + + if (pVia->KMS) { + if (drmModeAddFB(drmmode->fd, width, height, scrn->depth, + scrn->bitsPerPixel, pitch, + drmmode->front_bo->handle, + &drmmode->fb_id)) + goto fail; + } + + new_pixels = drm_bo_map(scrn, drmmode->front_bo); + if (!new_pixels) + goto fail; + + if (pVia->shadowFB) { + new_pixels = malloc(height * pitch); + if (!new_pixels) + goto fail; + free(pVia->ShadowPtr); + pVia->ShadowPtr = new_pixels; + } + scrn->virtualX = width; + scrn->virtualY = height; + scrn->displayWidth = pitch / cpp; + + ppix = screen->GetScreenPixmap(screen); + if (!screen->ModifyPixmapHeader(ppix, width, height, -1, -1, pitch, + new_pixels)) + goto fail; + +#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,9,99,1,0) + scrn->pixmapPrivate.ptr = ppix->devPrivate.ptr; +#endif + + if (xf86SetDesiredModes(scrn)) { + if (old_front) { + if (old_fb_id && pVia->KMS) + drmModeRmFB(drmmode->fd, old_fb_id); + drm_bo_unmap(scrn, old_front); + drm_bo_free(scrn, old_front); + } + return TRUE; + } + +fail: + if (drmmode->front_bo) { + drm_bo_unmap(scrn, drmmode->front_bo); + drm_bo_free(scrn, drmmode->front_bo); + } + drmmode->front_bo = old_front; + drmmode->fb_id = old_fb_id; + scrn->virtualY = old_height; + scrn->virtualX = old_width; + scrn->displayWidth = old_dwidth; + return FALSE; +} + +static const +xf86CrtcConfigFuncsRec via_xf86crtc_config_funcs = { + via_xf86crtc_resize +}; + +static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) { EntityInfoPtr pEnt; @@ -1437,6 +1532,8 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags) pVia->I2CDevices &= ~VIA_I2C_BUS2; /* CRTC handling */ + xf86CrtcConfigInit(pScrn, &via_xf86crtc_config_funcs); + if (pVia->KMS) { if (!KMSCrtcInit(pScrn, &pVia->drmmode)) { VIAFreeRec(pScrn); @@ -1569,7 +1666,7 @@ viaShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset, int mode, stride = (pScrn->displayWidth * pScrn->bitsPerPixel) / 8; *size = stride; - return ((uint8_t *)pVia->drmmode.front_bo->ptr + row * stride + offset); + return ((uint8_t *) drm_bo_map(pScrn, pVia->drmmode.front_bo) + row * stride + offset); } static Bool @@ -1585,16 +1682,18 @@ VIACreateScreenResources(ScreenPtr pScreen) return FALSE; pScreen->CreateScreenResources = VIACreateScreenResources; - surface = pVia->drmmode.front_bo->ptr; + rootPixmap = pScreen->GetScreenPixmap(pScreen); + + surface = drm_bo_map(pScrn, pVia->drmmode.front_bo); if (!surface) return FALSE; - rootPixmap = pScreen->GetScreenPixmap(pScreen); - if (pVia->shadowFB) surface = pVia->ShadowPtr; - if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, + if (!pScreen->ModifyPixmapHeader(rootPixmap, pScrn->virtualX, + pScrn->virtualY, -1, -1, + pVia->drmmode.front_bo->pitch, surface)) return FALSE; diff --git a/src/via_exa.c b/src/via_exa.c index a372c4e..60dce0b 100644 --- a/src/via_exa.c +++ b/src/via_exa.c @@ -1187,11 +1187,10 @@ viaExaDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst, int dst_pitch) { ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; - VIAPtr pVia = VIAPTR(pScrn); - unsigned srcPitch = exaGetPixmapPitch(pSrc); unsigned wBytes = (pSrc->drawable.bitsPerPixel * w + 7) >> 3; - unsigned srcOffset; + unsigned srcPitch = exaGetPixmapPitch(pSrc), srcOffset; char *bounceAligned = NULL; + VIAPtr pVia = VIAPTR(pScrn); unsigned totSize; if (!w || !h) @@ -1206,7 +1205,8 @@ viaExaDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, exaWaitSync(pScrn->pScreen); if (totSize < VIA_MIN_DOWNLOAD) { - bounceAligned = (char *)pVia->drmmode.front_bo->ptr + srcOffset; + bounceAligned = (char *) drm_bo_map(pScrn, pVia->drmmode.front_bo) + srcOffset; + while (h--) { memcpy(dst, bounceAligned, wBytes); dst += dst_pitch; @@ -1240,16 +1240,14 @@ viaExaTexUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, int src_pitch) { ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; - VIAPtr pVia = VIAPTR(pScrn); - unsigned dstPitch = exaGetPixmapPitch(pDst); + unsigned dstPitch = exaGetPixmapPitch(pDst), dstOffset; unsigned wBytes = (w * pDst->drawable.bitsPerPixel + 7) >> 3; - unsigned dstOffset; + int i, sync[2], yOffs, bufH, bufOffs, height, format; CARD32 texWidth, texHeight, texPitch; - int format; + VIAPtr pVia = VIAPTR(pScrn); + Via3DState *v3d = &pVia->v3d; char *dst, *texAddr; - int i, sync[2], yOffs, bufH, bufOffs, height; Bool buf; - Via3DState *v3d = &pVia->v3d; if (!w || !h) return TRUE; @@ -1258,8 +1256,10 @@ viaExaTexUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, dstOffset = x * pDst->drawable.bitsPerPixel; if (dstOffset & 3) return FALSE; - dst = (char *)pVia->drmmode.front_bo->ptr + (exaGetPixmapOffset(pDst) + y * dstPitch - + (dstOffset >> 3)); + + dst = (char *) drm_bo_map(pScrn, pVia->drmmode.front_bo) + + (exaGetPixmapOffset(pDst) + y * dstPitch + + (dstOffset >> 3)); exaWaitSync(pScrn->pScreen); while (h--) { @@ -1376,7 +1376,7 @@ viaExaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, dstOffset = exaGetPixmapOffset(pDst) + y * dstPitch + (dstOffset >> 3); if (wBytes * h < VIA_MIN_UPLOAD || wBytes < 65) { - dst = (char *)pVia->drmmode.front_bo->ptr + dstOffset; + dst = (char *) drm_bo_map(pScrn, pVia->drmmode.front_bo) + dstOffset; exaWaitSync(pScrn->pScreen); while (h--) { @@ -1515,7 +1515,7 @@ viaExaIsOffscreen(PixmapPtr pPix) VIAPtr pVia = VIAPTR(pScrn); return ((unsigned long)pPix->devPrivate.ptr - - (unsigned long)pVia->drmmode.front_bo->ptr) < pVia->drmmode.front_bo->size; + (unsigned long) drm_bo_map(pScrn, pVia->drmmode.front_bo)) < pVia->drmmode.front_bo->size; } static Bool @@ -1690,18 +1690,15 @@ viaInitExa(ScreenPtr pScreen) #ifdef XF86DRI if (pVia->directRenderingType == DRI_1) { #ifdef linux - if ((pVia->drmVerMajor > 2) || - ((pVia->drmVerMajor == 2) && (pVia->drmVerMinor >= 7))) { - pExa->DownloadFromScreen = viaExaDownloadFromScreen; - } + pExa->DownloadFromScreen = viaExaDownloadFromScreen; #endif /* linux */ switch (pVia->Chipset) { case VIA_K8M800: case VIA_KM400: - pExa->UploadToScreen = viaExaTexUploadToScreen; + pExa->UploadToScreen = NULL; //viaExaTexUploadToScreen; break; default: - pExa->UploadToScreen = NULL; + pExa->UploadToScreen = NULL; //viaExaUploadToScreen; break; } } @@ -1831,9 +1828,7 @@ UMSAccelSetup(ScrnInfoPtr pScrn) } #endif - if (pVia->NoAccel) - memset(pVia->drmmode.front_bo->ptr, 0x00, pVia->drmmode.front_bo->size); - else + if (!pVia->NoAccel) viaFinishInitAccel(pScreen); } diff --git a/src/via_kms.c b/src/via_kms.c index 47c8c03..16cbac5 100644 --- a/src/via_kms.c +++ b/src/via_kms.c @@ -802,17 +802,6 @@ drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode) } } -static void * -drmmode_map_front_bo(ScrnInfoPtr pScrn, drmmode_ptr drmmode) -{ - int ret; - - if (drmmode->front_bo->ptr) - return drmmode->front_bo->ptr; - - return drm_bo_map(pScrn, drmmode->front_bo); -} - static Bool drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height) { @@ -859,7 +848,7 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height) if (ret) goto fail; - new_pixels = drmmode_map_front_bo(scrn, drmmode); + new_pixels = drm_bo_map(scrn, drmmode->front_bo); if (!new_pixels) goto fail; |