i830_rotate.c
来自「是由intel提供的针对intel显卡915以上系列的linux驱动」· C语言 代码 · 共 1,181 行 · 第 1/3 页
C
1,181 行
verts[3][0] = box_x1; verts[3][1] = box_y2; tex[0][0] = box_x1; tex[0][1] = box_y1; tex[1][0] = box_x2; tex[1][1] = box_y1; tex[2][0] = box_x2; tex[2][1] = box_y2; tex[3][0] = box_x1; tex[3][1] = box_y2; /* transform coordinates to rotated versions, but leave texcoords unchanged */ for (j = 0; j < 4; j++) matrix23TransformCoordf(&rotMatrix, &verts[j][0], &verts[j][1]); /* emit vertex buffer */ draw_poly(vb, verts, tex); for (j = 0; j < 32; j++) OUT_RING(vb[j]); ADVANCE_LP_RING(); }#ifdef XF86DRI if (didLock) I830DRIUnlock(pScrn1);#endif}static voidI830UpdateRotate (ScreenPtr pScreen, shadowBufPtr pBuf){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); I830Ptr pI8301 = NULL; ScrnInfoPtr pScrn1 = pScrn; RegionPtr damage = shadowDamage(pBuf); int nbox = REGION_NUM_RECTS (damage); BoxPtr pbox = REGION_RECTS (damage); int box_x1, box_x2, box_y1, box_y2; CARD32 vb[32]; /* 32 dword vertex buffer */ float verts[4][2], tex[4][2]; struct matrix23 rotMatrix; Bool updateInvarient = FALSE; int use_fence; int j;#ifdef XF86DRI drmI830Sarea *sarea = NULL; drm_context_t myContext = 0;#endif Bool didLock = FALSE; if (I830IsPrimary(pScrn)) { pI8301 = pI830; } else { pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); pScrn1 = pI830->entityPrivate->pScrn_1; } switch (pI830->rotation) { case RR_Rotate_90: matrix23Rotate(&rotMatrix, pScreen->width, pScreen->height, 90); break; case RR_Rotate_180: matrix23Rotate(&rotMatrix, pScreen->width, pScreen->height, 180); break; case RR_Rotate_270: matrix23Rotate(&rotMatrix, pScreen->width, pScreen->height, 270); break; default: break; }#ifdef XF86DRI if (pI8301->directRenderingEnabled) { sarea = DRIGetSAREAPrivate(pScrn1->pScreen); myContext = DRIGetContext(pScrn1->pScreen); didLock = I830DRILock(pScrn1); }#endif if (pScrn->scrnIndex != *pI830->used3D) updateInvarient = TRUE; if (sarea->ctxOwner != myContext) updateInvarient = TRUE; if (updateInvarient) { *pI830->used3D = pScrn->scrnIndex;#ifdef XF86DRI if (sarea) sarea->ctxOwner = myContext;#endif BEGIN_LP_RING(48); OUT_RING(0x682008a1); OUT_RING(0x6f402100); OUT_RING(0x62120aa9); OUT_RING(0x76b3ffff); OUT_RING(0x6c818a01); OUT_RING(0x6ba008a1); OUT_RING(0x69802100); OUT_RING(0x63a00aaa); OUT_RING(0x6423070e); OUT_RING(0x66014142); OUT_RING(0x75000000); OUT_RING(0x7d880000); OUT_RING(0x00000000); OUT_RING(0x650001c4); OUT_RING(0x6a000000); OUT_RING(0x7d020000); OUT_RING(0x0000ba98); /* flush map & render cache */ OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); OUT_RING(0x00000000); /* draw rect */ OUT_RING(0x7d800003); OUT_RING(0x00000000); OUT_RING(0x00000000); OUT_RING((pScrn->virtualX - 1) | (pScrn->virtualY - 1) << 16); OUT_RING(0x00000000); OUT_RING(0x00000000); /* front buffer */ OUT_RING(0x7d8e0001); OUT_RING(0x03800000 | (((pI830->displayWidth * pI830->cpp) / 4) << 2)); if (I830IsPrimary(pScrn)) OUT_RING(pI830->FrontBuffer.Start); else OUT_RING(pI8301->FrontBuffer2.Start); OUT_RING(0x7d850000); if (pI830->cpp == 1) OUT_RING(0x00880000); else if (pI830->cpp == 2) OUT_RING(0x00880200); else OUT_RING(0x00880308); /* scissor */ OUT_RING(0x7c800002); OUT_RING(0x7d810001); OUT_RING(0x00000000); OUT_RING(0x00000000); /* stipple */ OUT_RING(0x7d830000); OUT_RING(0x00000000); /* texture blend replace */ OUT_RING(0x7c088088); OUT_RING(0x00000000); OUT_RING(0x6d021181); OUT_RING(0x6d060101); OUT_RING(0x6e008046); OUT_RING(0x6e048046); /* Set the entire frontbuffer up as a texture */ OUT_RING(0x7d030804); if (pI830->disableTiling) use_fence = 0; else use_fence = 2; if (I830IsPrimary(pScrn)) OUT_RING(pI830->RotatedMem.Start | use_fence); else OUT_RING(pI8301->RotatedMem2.Start | use_fence); if (pI830->cpp == 1) OUT_RING(0x00 | (pScreen->height - 1) << 21 | (pScreen->width - 1) << 10); else if (pI830->cpp == 2) OUT_RING(0x40 | (pScreen->height - 1) << 21 | (pScreen->width - 1) << 10); else OUT_RING(0xc0 | (pScreen->height - 1) << 21 | (pScreen->width - 1) << 10); OUT_RING((((pScrn->displayWidth * pI830->cpp / 4) - 1) << 21)); OUT_RING(0x00000000); OUT_RING(0x00000000); ADVANCE_LP_RING(); } { BEGIN_LP_RING(2); /* flush map & render cache */ OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); OUT_RING(0x00000000); ADVANCE_LP_RING(); } while (nbox--) { box_x1 = pbox->x1; box_y1 = pbox->y1; box_x2 = pbox->x2; box_y2 = pbox->y2; pbox++; BEGIN_LP_RING(40); OUT_RING(MI_NOOP); OUT_RING(MI_NOOP); OUT_RING(MI_NOOP); OUT_RING(MI_NOOP); OUT_RING(MI_NOOP); /* vertex data */ OUT_RING(0x7f0c001f); verts[0][0] = box_x1; verts[0][1] = box_y1; verts[1][0] = box_x2; verts[1][1] = box_y1; verts[2][0] = box_x2; verts[2][1] = box_y2; verts[3][0] = box_x1; verts[3][1] = box_y2; tex[0][0] = box_x1; tex[0][1] = box_y1; tex[1][0] = box_x2; tex[1][1] = box_y1; tex[2][0] = box_x2; tex[2][1] = box_y2; tex[3][0] = box_x1; tex[3][1] = box_y2; /* transform coordinates to rotated versions, but leave texcoords unchanged */ for (j = 0; j < 4; j++) matrix23TransformCoordf(&rotMatrix, &verts[j][0], &verts[j][1]); /* emit vertex buffer */ draw_poly(vb, verts, tex); for (j = 0; j < 32; j++) OUT_RING(vb[j]); OUT_RING(0x05000000); OUT_RING(0x00000000); ADVANCE_LP_RING(); } { BEGIN_LP_RING(2); /* flush map & render cache */ OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); OUT_RING(0x00000000); ADVANCE_LP_RING(); }#ifdef XF86DRI if (didLock) I830DRIUnlock(pScrn1);#endif}BoolI830Rotate(ScrnInfoPtr pScrn, DisplayModePtr mode){ I830Ptr pI830 = I830PTR(pScrn); I830Ptr pI8301 = NULL; I830Ptr pI8302 = NULL; ScrnInfoPtr pScrn1 = NULL; ScrnInfoPtr pScrn2 = NULL; void (*func) = NULL; int i; Rotation oldRotation = pI830->rotation; /* save old state */ int displayWidth = pScrn->displayWidth; /* save displayWidth */ Bool reAllocate = TRUE; Bool didLock = FALSE; /* Good pitches to allow tiling. Don't care about pitches < 1024. */ static const int pitches[] = {/* 128 * 2, 128 * 4,*/ 128 * 8, 128 * 16, 128 * 32, 128 * 64, 0 }; if (IS_I9XX(pI830)) func = I915UpdateRotate; else func = I830UpdateRotate; if (I830IsPrimary(pScrn)) { pI8301 = pI830; pScrn1 = pScrn; if (pI830->entityPrivate) { pI8302 = I830PTR(pI830->entityPrivate->pScrn_2); pScrn2 = pI830->entityPrivate->pScrn_2; } } else { pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); pScrn1 = pI830->entityPrivate->pScrn_1; pI8302 = pI830; pScrn2 = pScrn; } if (xf86LoaderCheckSymbol("I830GetRotation")) { Rotation (*I830GetRotation)(ScreenPtr pScreen) = NULL; I830GetRotation = LoaderSymbol("I830GetRotation"); if (I830GetRotation) { pI830->rotation = (*I830GetRotation)(pScrn->pScreen); } } /* Check if we've still got the same orientation, or same mode */ if (pI830->rotation == oldRotation && pI830->currentMode == mode)#if 0 reAllocate = FALSE;#else return TRUE;#endif /* * We grab the DRI lock when reallocating buffers to avoid DRI clients * getting bogus information. */#ifdef XF86DRI if (pI8301->directRenderingEnabled && reAllocate) { didLock = I830DRILock(pScrn1); /* Do heap teardown here */ { drmI830MemDestroyHeap destroy; destroy.region = I830_MEM_REGION_AGP; if (drmCommandWrite(pI8301->drmSubFD, DRM_I830_DESTROY_HEAP, &destroy, sizeof(destroy))) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[dri] I830 destroy heap failed\n"); } } if (pI8301->TexMem.Key != -1) I830UnbindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key); I830FreeVidMem(pScrn1, &(pI8301->TexMem)); if (pI8301->StolenPool.Allocated.Key != -1) { I830UnbindGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key); I830DeallocateGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key); } if (pI8301->DepthBuffer.Key != -1) I830UnbindGARTMemory(pScrn1->scrnIndex, pI8301->DepthBuffer.Key); I830FreeVidMem(pScrn1, &(pI8301->DepthBuffer)); if (pI8301->BackBuffer.Key != -1) I830UnbindGARTMemory(pScrn1->scrnIndex, pI8301->BackBuffer.Key); I830FreeVidMem(pScrn1, &(pI8301->BackBuffer)); }#endif if (reAllocate) { *pI830->used3D |= 1<<31; /* use high bit to denote new rotation occured */ 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; if (pI830->entityPrivate) { if (pI8301->RotatedMem2.Key != -1) I830UnbindGARTMemory(pScrn1->scrnIndex, pI8301->RotatedMem2.Key); I830FreeVidMem(pScrn1, &(pI8301->RotatedMem2)); memset(&(pI8301->RotatedMem2), 0, sizeof(pI8301->RotatedMem2)); pI8301->RotatedMem2.Key = -1; } } switch (pI830->rotation) { case RR_Rotate_0: if (reAllocate) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Rotating Screen to 0 degrees\n"); pScrn->displayWidth = pI830->displayWidth; break; case RR_Rotate_90: if (reAllocate) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Rotating Screen to 90 degrees\n"); pScrn->displayWidth = pScrn->pScreen->width; break; case RR_Rotate_180: if (reAllocate) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Rotating Screen to 180 degrees\n"); pScrn->displayWidth = pI830->displayWidth; break; case RR_Rotate_270:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?