i830_rotate.c
来自「是由intel提供的针对intel显卡915以上系列的linux驱动」· C语言 代码 · 共 1,181 行 · 第 1/3 页
C
1,181 行
if (reAllocate) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Rotating Screen to 270 degrees\n"); pScrn->displayWidth = pScrn->pScreen->width; break; } /* As DRI doesn't run on the secondary head, we know that disableTiling * is always TRUE. */ if (I830IsPrimary(pScrn) && !pI830->disableTiling) {#if 0 int dWidth = pScrn->displayWidth; /* save current displayWidth */#endif for (i = 0; pitches[i] != 0; i++) { if (pitches[i] >= pScrn->displayWidth) { pScrn->displayWidth = pitches[i]; break; } } /* * If the displayWidth is a tilable pitch, test if there's enough * memory available to enable tiling. */ if (pScrn->displayWidth == pitches[i]) { /* TODO */ } } if (reAllocate) { if (pI830->entityPrivate) { if (pI8302->rotation != RR_Rotate_0) { if (!I830AllocateRotated2Buffer(pScrn1, pI8302->disableTiling ? ALLOC_NO_TILING : 0)) goto BAIL0; I830FixOffset(pScrn1, &(pI8301->RotatedMem2)); if (pI8301->RotatedMem2.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->RotatedMem2.Key, pI8301->RotatedMem2.Offset); } } if (pI8301->rotation != RR_Rotate_0) { if (!I830AllocateRotatedBuffer(pScrn1, pI8301->disableTiling ? ALLOC_NO_TILING : 0)) goto BAIL1; I830FixOffset(pScrn1, &(pI8301->RotatedMem)); if (pI8301->RotatedMem.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->RotatedMem.Key, pI8301->RotatedMem.Offset); } } I830shadowUnset (pScrn->pScreen); if (pI830->rotation != RR_Rotate_0) I830shadowSet (pScrn->pScreen, (*pScrn->pScreen->GetScreenPixmap) (pScrn->pScreen), pI830->noAccel ? I830shadowUpdateRotatePacked : func, I830WindowLinear, pI830->rotation, 0); if (I830IsPrimary(pScrn)) { if (pI830->rotation != RR_Rotate_0) pScrn->fbOffset = pI830->RotatedMem.Start; else pScrn->fbOffset = pI830->FrontBuffer.Start; if (pI830->entityPrivate) { if (pI8302->rotation != RR_Rotate_0) pScrn2->fbOffset = pI8301->RotatedMem2.Start; else pScrn2->fbOffset = pI8301->FrontBuffer2.Start; I830SelectBuffer(pScrn2, I830_SELECT_FRONT); } } else { if (pI830->rotation != RR_Rotate_0) pScrn->fbOffset = pI8301->RotatedMem2.Start; else pScrn->fbOffset = pI8301->FrontBuffer2.Start; if (pI8301->rotation != RR_Rotate_0) pScrn1->fbOffset = pI8301->RotatedMem.Start; else pScrn1->fbOffset = pI8301->FrontBuffer.Start; I830SelectBuffer(pScrn1, I830_SELECT_FRONT); } I830SelectBuffer(pScrn, I830_SELECT_FRONT);#ifdef XF86DRI if (pI8301->directRenderingEnabled && reAllocate) { if (!I830AllocateBackBuffer(pScrn1, pI8301->disableTiling ? ALLOC_NO_TILING : 0)) goto BAIL2; if (!I830AllocateDepthBuffer(pScrn1, pI8301->disableTiling ? ALLOC_NO_TILING : 0)) goto BAIL3; if (!I830AllocateTextureMemory(pScrn1, pI8301->disableTiling ? ALLOC_NO_TILING : 0)) goto BAIL4; I830DoPoolAllocation(pScrn1, &(pI8301->StolenPool)); I830FixOffset(pScrn1, &(pI8301->BackBuffer)); I830FixOffset(pScrn1, &(pI8301->DepthBuffer)); if (pI8301->BackBuffer.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->BackBuffer.Key, pI8301->BackBuffer.Offset); if (pI8301->DepthBuffer.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->DepthBuffer.Key, pI8301->DepthBuffer.Offset); if (pI8301->StolenPool.Allocated.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key, pI8301->StolenPool.Allocated.Offset); if (pI8301->TexMem.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key, pI8301->TexMem.Offset); I830SetupMemoryTiling(pScrn1); /* update fence registers */ for (i = 0; i < 8; i++) OUTREG(FENCE + i * 4, pI8301->ModeReg.Fence[i]); { drmI830Sarea *sarea = DRIGetSAREAPrivate(pScrn1->pScreen); I830UpdateDRIBuffers(pScrn1, sarea ); } if (didLock) I830DRIUnlock(pScrn1); }#endif#if 0 if (I830IsPrimary(pScrn)) { pI830->xoffset = (pI830->FrontBuffer.Start / pI830->cpp) % pI830->displayWidth; pI830->yoffset = (pI830->FrontBuffer.Start / pI830->cpp) / pI830->displayWidth; } else { I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); pI830->xoffset = (pI8301->FrontBuffer2.Start / pI830->cpp) % pI830->displayWidth; pI830->yoffset = (pI8301->FrontBuffer2.Start / pI830->cpp) / pI830->displayWidth; }#endif pScrn->pScreen->ModifyPixmapHeader((*pScrn->pScreen->GetScreenPixmap)(pScrn->pScreen), pScrn->pScreen->width, pScrn->pScreen->height, pScrn->pScreen->rootDepth, pScrn->bitsPerPixel, PixmapBytePad(pScrn->displayWidth, pScrn->pScreen->rootDepth), (pointer)(pI8301->FbBase + pScrn->fbOffset)); if (pI830->entityPrivate) { if (I830IsPrimary(pScrn)) { if (!pI830->starting) { pScrn2->pScreen->ModifyPixmapHeader((*pScrn2->pScreen->GetScreenPixmap)(pScrn2->pScreen), pScrn2->pScreen->width, pScrn2->pScreen->height, pScrn2->pScreen->rootDepth, pScrn2->bitsPerPixel, PixmapBytePad(pScrn2->displayWidth, pScrn2->pScreen->rootDepth), (pointer)(pI8301->FbBase + pScrn2->fbOffset)); /* Repaint the second head */ (*pScrn2->EnableDisableFBAccess) (pScrn2->pScreen->myNum, FALSE); (*pScrn2->EnableDisableFBAccess) (pScrn2->pScreen->myNum, TRUE); } } else { if (!pI830->starting) { pScrn1->pScreen->ModifyPixmapHeader((*pScrn1->pScreen->GetScreenPixmap)(pScrn1->pScreen), pScrn1->pScreen->width, pScrn1->pScreen->height, pScrn1->pScreen->rootDepth, pScrn1->bitsPerPixel, PixmapBytePad(pScrn1->displayWidth, pScrn1->pScreen->rootDepth), (pointer)(pI8301->FbBase + pScrn1->fbOffset)); /* Repaint the first head */ (*pScrn1->EnableDisableFBAccess) (pScrn1->pScreen->myNum, FALSE); (*pScrn1->EnableDisableFBAccess) (pScrn1->pScreen->myNum, TRUE); } } } /* Don't allow pixmap cache or offscreen pixmaps when rotated */ /* XAA needs some serious fixing for this to happen */ if (pI830->rotation == RR_Rotate_0) { pI830->AccelInfoRec->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS | PIXMAP_CACHE; pI830->AccelInfoRec->UsingPixmapCache = TRUE; /* funny as it seems this will enable XAA's createpixmap */ pI830->AccelInfoRec->maxOffPixWidth = 0; pI830->AccelInfoRec->maxOffPixHeight = 0; } else { pI830->AccelInfoRec->Flags = LINEAR_FRAMEBUFFER; pI830->AccelInfoRec->UsingPixmapCache = FALSE; /* funny as it seems this will disable XAA's createpixmap */ pI830->AccelInfoRec->maxOffPixWidth = 1; pI830->AccelInfoRec->maxOffPixHeight = 1; } return TRUE;BAIL4:#ifdef XF86DRI if (pI8301->directRenderingEnabled) I830FreeVidMem(pScrn1, &(pI8301->DepthBuffer));#endifBAIL3:#ifdef XF86DRI if (pI8301->directRenderingEnabled) I830FreeVidMem(pScrn1, &(pI8301->BackBuffer));#endifBAIL2: if (pI8301->rotation != RR_Rotate_0) { if (pI8301->RotatedMem.Key != -1) I830UnbindGARTMemory(pScrn1->scrnIndex, pI8301->RotatedMem.Key); I830FreeVidMem(pScrn1, &(pI8301->RotatedMem)); memset(&(pI8301->RotatedMem), 0, sizeof(pI8301->RotatedMem)); pI8301->RotatedMem.Key = -1; }BAIL1: if (pI830->entityPrivate) { if (pI8302->rotation != RR_Rotate_0) { if (pI8301->RotatedMem.Key != -1) I830UnbindGARTMemory(pScrn1->scrnIndex, pI8301->RotatedMem.Key); I830FreeVidMem(pScrn1, &(pI8301->RotatedMem)); memset(&(pI8301->RotatedMem), 0, sizeof(pI8301->RotatedMem)); pI8301->RotatedMem.Key = -1; } }BAIL0: pScrn->displayWidth = displayWidth; /* must flip mmWidth & mmHeight */ if ( ((oldRotation & (RR_Rotate_90 | RR_Rotate_270)) && (pI830->rotation & (RR_Rotate_0 | RR_Rotate_180))) || ((oldRotation & (RR_Rotate_0 | RR_Rotate_180)) && (pI830->rotation & (RR_Rotate_90 | RR_Rotate_270))) ) { int tmp = pScrn->pScreen->mmWidth; pScrn->pScreen->mmWidth = pScrn->pScreen->mmHeight; pScrn->pScreen->mmHeight = tmp; } if (oldRotation & (RR_Rotate_0 | RR_Rotate_180)) { pScrn->pScreen->width = pScrn->virtualX; pScrn->pScreen->height = pScrn->virtualY; } else { pScrn->pScreen->width = pScrn->virtualY; pScrn->pScreen->height = pScrn->virtualX; } pI830->rotation = oldRotation; if (pI830->entityPrivate) { if (pI8302->rotation != RR_Rotate_0) { if (!I830AllocateRotated2Buffer(pScrn1, pI8302->disableTiling ? ALLOC_NO_TILING : 0)) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Oh dear, the rotated2 buffer failed - badness\n"); I830FixOffset(pScrn1, &(pI8301->RotatedMem2)); if (pI8301->RotatedMem2.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->RotatedMem2.Key, pI8301->RotatedMem2.Offset); } } if (pI8301->rotation != RR_Rotate_0) { if (!I830AllocateRotatedBuffer(pScrn1, pI8301->disableTiling ? ALLOC_NO_TILING : 0)) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Oh dear, the rotated buffer failed - badness\n"); I830FixOffset(pScrn1, &(pI8301->RotatedMem)); if (pI8301->RotatedMem.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->RotatedMem.Key, pI8301->RotatedMem.Offset); } I830shadowUnset (pScrn->pScreen); if (pI830->rotation != RR_Rotate_0) I830shadowSet (pScrn->pScreen, (*pScrn->pScreen->GetScreenPixmap) (pScrn->pScreen), pI830->noAccel ? I830shadowUpdateRotatePacked : func, I830WindowLinear, pI830->rotation, 0); if (I830IsPrimary(pScrn)) { if (pI830->rotation != RR_Rotate_0) pScrn->fbOffset = pI830->RotatedMem.Start; else pScrn->fbOffset = pI830->FrontBuffer.Start; if (pI830->entityPrivate) { if (pI8302->rotation != RR_Rotate_0) pScrn2->fbOffset = pI8301->RotatedMem2.Start; else pScrn2->fbOffset = pI8301->FrontBuffer2.Start; I830SelectBuffer(pScrn2, I830_SELECT_FRONT); } } else { if (pI830->rotation != RR_Rotate_0) pScrn->fbOffset = pI8301->RotatedMem2.Start; else pScrn->fbOffset = pI8301->FrontBuffer2.Start; if (pI8301->rotation != RR_Rotate_0) pScrn1->fbOffset = pI8301->RotatedMem.Start; else pScrn1->fbOffset = pI8301->FrontBuffer.Start; I830SelectBuffer(pScrn1, I830_SELECT_FRONT); } I830SelectBuffer(pScrn, I830_SELECT_FRONT); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Reverting to previous configured mode\n"); switch (oldRotation) { case RR_Rotate_0: xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Rotating Screen back to 0 degrees\n"); break; case RR_Rotate_90: xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Rotating Screen back to 90 degrees\n"); break; case RR_Rotate_180: xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Rotating Screen back to 180 degrees\n"); break; case RR_Rotate_270: xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Rotating Screen back to 270 degrees\n"); break; }#ifdef XF86DRI if (pI8301->directRenderingEnabled) { if (!I830AllocateBackBuffer(pScrn1, pI8301->disableTiling ? ALLOC_NO_TILING : 0)) xf86DrvMsg(pScrn1->scrnIndex, X_INFO, "Oh dear, the back buffer failed - badness\n"); if (!I830AllocateDepthBuffer(pScrn1, pI8301->disableTiling ? ALLOC_NO_TILING : 0)) xf86DrvMsg(pScrn1->scrnIndex, X_INFO, "Oh dear, the depth buffer failed - badness\n"); if (!I830AllocateTextureMemory(pScrn1, pI8301->disableTiling ? ALLOC_NO_TILING : 0)) xf86DrvMsg(pScrn1->scrnIndex, X_INFO, "Oh dear, the texture cache failed - badness\n"); I830DoPoolAllocation(pScrn1, &(pI8301->StolenPool)); I830FixOffset(pScrn1, &(pI8301->BackBuffer)); I830FixOffset(pScrn1, &(pI8301->DepthBuffer)); if (pI8301->BackBuffer.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->BackBuffer.Key, pI8301->BackBuffer.Offset); if (pI8301->DepthBuffer.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->DepthBuffer.Key, pI8301->DepthBuffer.Offset); if (pI8301->StolenPool.Allocated.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key, pI8301->StolenPool.Allocated.Offset); if (pI8301->TexMem.Key != -1) I830BindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key, pI8301->TexMem.Offset); I830SetupMemoryTiling(pScrn1); /* update fence registers */ for (i = 0; i < 8; i++) OUTREG(FENCE + i * 4, pI8301->ModeReg.Fence[i]); { drmI830Sarea *sarea = DRIGetSAREAPrivate(pScrn1->pScreen); I830UpdateDRIBuffers(pScrn1, sarea ); } if (didLock) I830DRIUnlock(pScrn1); }#endif pScrn->pScreen->ModifyPixmapHeader((*pScrn->pScreen->GetScreenPixmap)(pScrn->pScreen), pScrn->pScreen->width, pScrn->pScreen->height, pScrn->pScreen->rootDepth, pScrn->bitsPerPixel, PixmapBytePad(pScrn->displayWidth, pScrn->pScreen->rootDepth), (pointer)(pI8301->FbBase + pScrn->fbOffset)); if (pI830->entityPrivate) { if (I830IsPrimary(pScrn)) { pScrn2->pScreen->ModifyPixmapHeader((*pScrn2->pScreen->GetScreenPixmap)(pScrn2->pScreen), pScrn2->pScreen->width, pScrn2->pScreen->height, pScrn2->pScreen->rootDepth, pScrn2->bitsPerPixel, PixmapBytePad(pScrn2->displayWidth, pScrn2->pScreen->rootDepth), (pointer)(pI8301->FbBase + pScrn2->fbOffset)); /* Repaint the second head */ (*pScrn2->EnableDisableFBAccess) (pScrn2->pScreen->myNum, FALSE); (*pScrn2->EnableDisableFBAccess) (pScrn2->pScreen->myNum, TRUE); } else { pScrn1->pScreen->ModifyPixmapHeader((*pScrn1->pScreen->GetScreenPixmap)(pScrn1->pScreen), pScrn1->pScreen->width, pScrn1->pScreen->height, pScrn1->pScreen->rootDepth, pScrn1->bitsPerPixel, PixmapBytePad(pScrn1->displayWidth, pScrn1->pScreen->rootDepth), (pointer)(pI8301->FbBase + pScrn1->fbOffset)); /* Repaint the first head */ (*pScrn1->EnableDisableFBAccess) (pScrn1->pScreen->myNum, FALSE); (*pScrn1->EnableDisableFBAccess) (pScrn1->pScreen->myNum, TRUE); } } return FALSE;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?