i830_cursor.c
来自「是由intel提供的针对intel显卡915以上系列的linux驱动」· C语言 代码 · 共 573 行 · 第 1/2 页
C
573 行
if (!image) return; /* XXX can't happen */ #ifdef ARGB_CURSOR pI830->CursorIsARGB = TRUE;#endif w = pCurs->bits->width; h = pCurs->bits->height;switch (pI830->rotation) { case RR_Rotate_90: for (y = 0; y < h; y++) { for (x = 0; x < w; x++) dst[(y) + ((64 - x - 1) * 64)] = *image++; for(; x < 64; x++) dst[(y) + ((64 - x - 1) * 64)] = 0; } for(; y < 64; y++) { for(x = 0; x < 64; x++) dst[(y) + ((64 - x - 1) * 64)] = 0; } return; case RR_Rotate_180: for (y = 0; y < h; y++) { for (x = 0; x < w; x++) dst[(64 - x - 1) + ((64 - y - 1) * 64)] = *image++; for(; x < 64; x++) dst[(64 - x - 1) + ((64 - y - 1) * 64)] = 0; } for(; y < 64; y++) { for(x = 0; x < 64; x++) dst[(64 - x - 1) + ((64 - y - 1) * 64)] = 0; } return; case RR_Rotate_270: for (y = 0; y < h; y++) { for (x = 0; x < w; x++) dst[(64 - y - 1) + (x * 64)] = *image++; for(; x < 64; x++) dst[(64 - y - 1) + (x * 64)] = 0; } for(; y < 64; y++) { for(x = 0; x < 64; x++) dst[(64 - y - 1) + (x * 64)] = 0; } return;} for(y = 0; y < h; y++) { for(x = 0; x < w; x++) *dst++ = *image++; for(; x < 64; x++) *dst++ = 0; } for(; y < 64; y++) { for(x = 0; x < 64; x++) *dst++ = 0; }}#endifstatic voidI830SetCursorPosition(ScrnInfoPtr pScrn, int x, int y){ I830Ptr pI830 = I830PTR(pScrn); CARD32 temp = 0; static Bool outsideViewport = FALSE; Bool hide = FALSE, show = FALSE; int oldx = x, oldy = y; int hotspotx = 0, hotspoty = 0; oldx += pScrn->frameX0; /* undo what xf86HWCurs did */ oldy += pScrn->frameY0; switch (pI830->rotation) { case RR_Rotate_0: x = oldx; y = oldy; break; case RR_Rotate_90: x = oldy; y = pScrn->pScreen->width - oldx; hotspoty = I810_CURSOR_X; break; case RR_Rotate_180: x = pScrn->pScreen->width - oldx; y = pScrn->pScreen->height - oldy; hotspotx = I810_CURSOR_X; hotspoty = I810_CURSOR_Y; break; case RR_Rotate_270: x = pScrn->pScreen->height - oldy; y = oldx; hotspotx = I810_CURSOR_Y; break; } x -= hotspotx; y -= hotspoty; /* Now, readjust */ x -= pScrn->frameX0; y -= pScrn->frameY0; /* Clamp the cursor position to the visible screen area */ if (x >= pScrn->currentMode->HDisplay) x = pScrn->currentMode->HDisplay - 1; if (y >= pScrn->currentMode->VDisplay) y = pScrn->currentMode->VDisplay - 1; if (x <= -I810_CURSOR_X) x = -I810_CURSOR_X + 1; if (y <= -I810_CURSOR_Y) y = -I810_CURSOR_Y + 1;#if 0 /* * There is a screen display problem when the cursor position is set * wholely outside of the viewport. We trap that here, turning the * cursor off when that happens, and back on when it comes back into * the viewport. */ if (x >= pScrn->currentMode->HDisplay || y >= pScrn->currentMode->VDisplay || x <= -I810_CURSOR_X || y <= -I810_CURSOR_Y) { hide = TRUE; outsideViewport = TRUE; } else if (outsideViewport) { show = TRUE; outsideViewport = FALSE; }#endif if (x < 0) { temp |= (CURSOR_POS_SIGN << CURSOR_X_SHIFT); x = -x; } if (y < 0) { temp |= (CURSOR_POS_SIGN << CURSOR_Y_SHIFT); y = -y; } temp |= ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT); temp |= ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT); OUTREG(CURSOR_A_POSITION, temp); if (pI830->Clone) OUTREG(CURSOR_B_POSITION, temp); if (pI830->cursorOn) { if (hide) pI830->CursorInfoRec->HideCursor(pScrn); else if (show) pI830->CursorInfoRec->ShowCursor(pScrn); pI830->cursorOn = TRUE; } /* have to upload the base for the new position */ if (IS_I9XX(pI830)) { if (pI830->CursorIsARGB) OUTREG(CURSOR_A_BASE, pI830->CursorMemARGB->Physical); else OUTREG(CURSOR_A_BASE, pI830->CursorMem->Physical); if (pI830->Clone) { if (pI830->CursorIsARGB) OUTREG(CURSOR_B_BASE, pI830->CursorMemARGB->Physical); else OUTREG(CURSOR_B_BASE, pI830->CursorMem->Physical); } }}static voidI830ShowCursor(ScrnInfoPtr pScrn){ I830Ptr pI830 = I830PTR(pScrn); CARD32 temp; DPRINTF(PFX, "I830ShowCursor\n"); DPRINTF(PFX, "Value of CursorMem->Physical is %x, " " Value of CursorMem->Start is %x ", pI830->CursorMem->Physical, pI830->CursorMem->Start); DPRINTF(PFX, "Value of CursorMemARGB->Physical is %x, " " Value of CursorMemARGB->Start is %x ", pI830->CursorMemARGB->Physical, pI830->CursorMemARGB->Start); pI830->cursorOn = TRUE; if (IS_MOBILE(pI830) || IS_I9XX(pI830)) { temp = INREG(CURSOR_A_CONTROL); temp &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT); if (pI830->CursorIsARGB) temp |= CURSOR_MODE_64_ARGB_AX; else temp |= CURSOR_MODE_64_4C_AX; temp |= (pI830->pipe << 28); /* Connect to correct pipe */ /* Need to set mode, then address. */ OUTREG(CURSOR_A_CONTROL, temp); if (pI830->CursorIsARGB) OUTREG(CURSOR_A_BASE, pI830->CursorMemARGB->Physical); else OUTREG(CURSOR_A_BASE, pI830->CursorMem->Physical); if (pI830->Clone) { temp &= ~MCURSOR_PIPE_SELECT; temp |= (!pI830->pipe << 28); OUTREG(CURSOR_B_CONTROL, temp); if (pI830->CursorIsARGB) OUTREG(CURSOR_B_BASE, pI830->CursorMemARGB->Physical); else OUTREG(CURSOR_B_BASE, pI830->CursorMem->Physical); } } else { temp = INREG(CURSOR_CONTROL); temp &= ~(CURSOR_FORMAT_MASK); temp |= CURSOR_ENABLE; if (pI830->CursorIsARGB) temp |= CURSOR_FORMAT_ARGB; else temp |= CURSOR_FORMAT_3C; OUTREG(CURSOR_CONTROL, temp); if (pI830->CursorIsARGB) OUTREG(CURSOR_BASEADDR, pI830->CursorMemARGB->Start); else OUTREG(CURSOR_BASEADDR, pI830->CursorMem->Start); }}static voidI830HideCursor(ScrnInfoPtr pScrn){ CARD32 temp; I830Ptr pI830 = I830PTR(pScrn); DPRINTF(PFX, "I830HideCursor\n"); pI830->cursorOn = FALSE; if (IS_MOBILE(pI830) || IS_I9XX(pI830)) { temp = INREG(CURSOR_A_CONTROL); temp &= ~CURSOR_MODE; temp |= CURSOR_MODE_DISABLE; OUTREG(CURSOR_A_CONTROL, temp); /* This is needed to flush the above change. */ if (pI830->CursorIsARGB) OUTREG(CURSOR_A_BASE, pI830->CursorMemARGB->Physical); else OUTREG(CURSOR_A_BASE, pI830->CursorMem->Physical); if (pI830->Clone) { OUTREG(CURSOR_B_CONTROL, temp); if (pI830->CursorIsARGB) OUTREG(CURSOR_B_BASE, pI830->CursorMemARGB->Physical); else OUTREG(CURSOR_B_BASE, pI830->CursorMem->Physical); } } else { temp = INREG(CURSOR_CONTROL); temp &= ~CURSOR_ENABLE; OUTREG(CURSOR_CONTROL, temp); }}static voidI830SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg){ I830Ptr pI830 = I830PTR(pScrn);#ifdef ARGB_CURSOR /* Don't recolour cursors set with SetCursorARGB. */ if (pI830->CursorIsARGB) return;#endif DPRINTF(PFX, "I830SetCursorColors\n"); OUTREG(CURSOR_A_PALETTE0, bg & 0x00ffffff); OUTREG(CURSOR_A_PALETTE1, fg & 0x00ffffff); OUTREG(CURSOR_A_PALETTE2, fg & 0x00ffffff); OUTREG(CURSOR_A_PALETTE3, bg & 0x00ffffff); if (pI830->Clone) { OUTREG(CURSOR_B_PALETTE0, bg & 0x00ffffff); OUTREG(CURSOR_B_PALETTE1, fg & 0x00ffffff); OUTREG(CURSOR_B_PALETTE2, fg & 0x00ffffff); OUTREG(CURSOR_B_PALETTE3, bg & 0x00ffffff); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?