diff options
Diffstat (limited to 'driver/xf86-video-siliconmotion/src/smi_shadow.c')
-rw-r--r-- | driver/xf86-video-siliconmotion/src/smi_shadow.c | 529 |
1 files changed, 249 insertions, 280 deletions
diff --git a/driver/xf86-video-siliconmotion/src/smi_shadow.c b/driver/xf86-video-siliconmotion/src/smi_shadow.c index 10cfe4d06..dcfa16a7b 100644 --- a/driver/xf86-video-siliconmotion/src/smi_shadow.c +++ b/driver/xf86-video-siliconmotion/src/smi_shadow.c @@ -26,7 +26,6 @@ Silicon Motion shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the XFree86 Project and Silicon Motion. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_shadow.c,v 1.1 2000/11/28 20:59:20 dawes Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -47,141 +46,128 @@ authorization from the XFree86 Project and Silicon Motion. |*============================================================================= |* |* PARAMETERS: pScrn Pointer to ScrnInfo structure. -|* num Number of boxes to refresh. -|* pbox Pointer to an array of boxes to refresh. +|* num Number of boxes to refresh. +|* pbox Pointer to an array of boxes to refresh. |* |* DESCRIPTION: Refresh a portion of the shadow buffer to the visual screen -|* buffer. This is mainly used for rotation purposes. -|* y +|* buffer. This is mainly used for rotation purposes. +|* |* RETURNS: Nothing. |* \******************************************************************************/ void SMI_RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - SMIPtr pSmi = SMIPTR(pScrn); - int width, height, srcX, srcY, destX, destY; + SMIPtr pSmi = SMIPTR(pScrn); + int width, height, srcX, srcY, destX, destY; - ENTER_PROC("SMI_RefreshArea"); + ENTER_PROC("SMI_RefreshArea"); - /* #671 */ - if (pSmi->polyLines) - { - pSmi->polyLines = FALSE; - return; - } + /* #671 */ + if (pSmi->polyLines) { + pSmi->polyLines = FALSE; + return; + } - if (pSmi->rotate) - { - /* IF we need to do rotation, setup the hardware here. */ - WaitIdleEmpty(); - WRITE_DPR(pSmi, 0x10, pSmi->ShadowPitch); - WRITE_DPR(pSmi, 0x3C, pSmi->ShadowPitch); - WRITE_DPR(pSmi, 0x44, pSmi->FBOffset >> 3); - } + if (pSmi->rotate) { + /* IF we need to do rotation, setup the hardware here. */ + WaitIdleEmpty(); + WRITE_DPR(pSmi, 0x10, pSmi->ShadowPitch); + WRITE_DPR(pSmi, 0x3C, pSmi->ShadowPitch); + WRITE_DPR(pSmi, 0x44, pSmi->FBOffset >> 3); + } - /* #672 */ - if (pSmi->ClipTurnedOn) - { - WaitQueue(1); - WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); - pSmi->ClipTurnedOn = FALSE; - } + /* #672 */ + if (pSmi->ClipTurnedOn) { + WaitQueue(1); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + pSmi->ClipTurnedOn = FALSE; + } - while (num--) - { - /* Get coordinates of the box to refresh. */ - srcX = pbox->x1; - srcY = pbox->y1; - width = pbox->x2 - srcX; - height = pbox->y2 - srcY; - - DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d\n", srcX, srcY, width, height)); - - if ((width > 0) && (height > 0)) - { - switch (pSmi->rotate) - { - case SMI_ROTATE_CW: - /* 90 degrees CW rotation. Calculate destination - coordinates: - - *---+ - | | +-----* - | | | | destX = shadowHeight - srcY - 1 - | | --> | | destY = srcX - | | | | - | | +-----+ - +---+ - */ - destX = pSmi->ShadowHeight - srcY - 1; - destY = srcX; - - WaitQueue(4); - WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); - WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); - WRITE_DPR(pSmi, 0x08, (width << 16) + height); - WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | - SMI_ROTATE_CW | SMI_START_ENGINE); - break; - - case SMI_ROTATE_CCW: - /* 90 degrees CCW rotatation. Calculate destination - coordinates: - - *---+ - | | +-----+ - | | | | destX = srcY - | | --> | | destY = shadowWidth - srcX - 1 - | | | | - | | *-----+ - +---+ - */ - destX = srcY; - destY = pSmi->ShadowWidth - srcX - 1; - - WaitQueue(4); - WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); - WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); - WRITE_DPR(pSmi, 0x08, (width << 16) + height); - WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | - SMI_ROTATE_CCW | SMI_START_ENGINE); - break; - - default: - /* No rotation, perform a normal copy. */ - if (pScrn->bitsPerPixel == 24) - { - srcX *= 3; - width *= 3; - - if (pSmi->Chipset == SMI_LYNX) - { - srcY *= 3; - } - } - - WaitQueue(4); - WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); - WRITE_DPR(pSmi, 0x04, (srcX << 16) + srcY); - WRITE_DPR(pSmi, 0x08, (width << 16) + height); - WRITE_DPR(pSmi, 0x0C, SMI_BITBLT + SMI_START_ENGINE + 0xCC); - break; - } + while (num--) { + /* Get coordinates of the box to refresh. */ + srcX = pbox->x1; + srcY = pbox->y1; + width = pbox->x2 - srcX; + height = pbox->y2 - srcY; + + DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d\n", srcX, srcY, width, height)); + + if ((width > 0) && (height > 0)) { + switch (pSmi->rotate) { + case SMI_ROTATE_CW: + /* 90 degrees CW rotation. Calculate destination coordinates: + + *---+ + | | +-----* + | | | | destX = shadowHeight - srcY - 1 + | | --> | | destY = srcX + | | | | + | | +-----+ + +---+ + */ + destX = pSmi->ShadowHeight - srcY - 1; + destY = srcX; + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CW | SMI_START_ENGINE); + break; + case SMI_ROTATE_CCW: + /* 90 degrees CCW rotatation. Calculate destination coordinates: + + *---+ + | | +-----+ + | | | | destX = srcY + | | --> | | destY = shadowWidth - srcX - 1 + | | | | + | | *-----+ + +---+ + */ + destX = srcY; + destY = pSmi->ShadowWidth - srcX - 1; + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CCW | SMI_START_ENGINE); + break; + default: + /* No rotation, perform a normal copy. */ + if (pScrn->bitsPerPixel == 24) { + srcX *= 3; + width *= 3; + + if (pSmi->Chipset == SMI_LYNX) { + srcY *= 3; + } } - pbox++; + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_BITBLT | SMI_START_ENGINE); + break; + } } - if (pSmi->rotate) - { - /* If we did a rotation, we need to restore the hardware state here. */ - WaitIdleEmpty(); - WRITE_DPR(pSmi, 0x10, (pSmi->Stride << 16) | pSmi->Stride); - WRITE_DPR(pSmi, 0x3C, (pSmi->Stride << 16) | pSmi->Stride); - WRITE_DPR(pSmi, 0x44, 0); - } + pbox++; + } + + if (pSmi->rotate) { + /* If we did a rotation, we need to restore the hardware state here. */ + WaitIdleEmpty(); + WRITE_DPR(pSmi, 0x10, (pSmi->Stride << 16) | pSmi->Stride); + WRITE_DPR(pSmi, 0x3C, (pSmi->Stride << 16) | pSmi->Stride); + WRITE_DPR(pSmi, 0x44, 0); + } - LEAVE_PROC("SMI_RefreshArea"); + LEAVE_PROC("SMI_RefreshArea"); } /* Custom version for the 730 series (Cougar3DR). @@ -189,155 +175,140 @@ void SMI_RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) void SMI_RefreshArea730(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - SMIPtr pSmi = SMIPTR(pScrn); - int width, height, srcX, srcY, destX, destY; - int maxPixels, tempWidth; + SMIPtr pSmi = SMIPTR(pScrn); + int width, height, srcX, srcY, destX, destY; + int maxPixels, tempWidth; - ENTER_PROC("SMI_RefreshArea730"); + ENTER_PROC("SMI_RefreshArea730"); - /* #671 */ - if (pSmi->polyLines) - { - pSmi->polyLines = FALSE; - return; - } + /* #671 */ + if (pSmi->polyLines) { + pSmi->polyLines = FALSE; + return; + } - if (pSmi->rotate) - { - /* IF we need to do rotation, setup the hardware here. */ - WaitIdleEmpty(); - WRITE_DPR(pSmi, 0x10, pSmi->ShadowPitch); - WRITE_DPR(pSmi, 0x3C, pSmi->ShadowPitch); - WRITE_DPR(pSmi, 0x44, pSmi->FBOffset >> 3); - } + if (pSmi->rotate) { + /* IF we need to do rotation, setup the hardware here. */ + WaitIdleEmpty(); + WRITE_DPR(pSmi, 0x10, pSmi->ShadowPitch); + WRITE_DPR(pSmi, 0x3C, pSmi->ShadowPitch); + WRITE_DPR(pSmi, 0x44, pSmi->FBOffset >> 3); + } - /* #672 */ - if (pSmi->ClipTurnedOn) - { - WaitQueue(1); - WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); - pSmi->ClipTurnedOn = FALSE; - } + /* #672 */ + if (pSmi->ClipTurnedOn) { + WaitQueue(1); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + pSmi->ClipTurnedOn = FALSE; + } - /* SM731 cannot rotate-blt more than a certain number of pixels - (based on a calculation from the Windows driver source */ - maxPixels = 1280 / pScrn->bitsPerPixel; - - while (num--) - { - /* Get coordinates of the box to refresh. */ - srcX = pbox->x1; - srcY = pbox->y1; - width = pbox->x2 - srcX; - height = pbox->y2 - srcY; - - DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d\n", srcX, srcY, width, height)); - - if ((width > 0) && (height > 0)) - { - switch (pSmi->rotate) - { - case SMI_ROTATE_CW: - /* 90 degrees CW rotation. Calculate destination - coordinates: - - *---+ - | | +-----* - | | | | destX = shadowHeight - srcY - 1 - | | --> | | destY = srcX - | | | | - | | +-----+ - +---+ - */ - destX = pSmi->ShadowHeight - srcY - 1; - destY = srcX; - - for (tempWidth=width; tempWidth>0;) - { - if (width>maxPixels) - width = maxPixels; - WaitQueue(4); - WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); - WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); - WRITE_DPR(pSmi, 0x08, (width << 16) + height); - WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | - SMI_ROTATE_CW | SMI_START_ENGINE); - destY += maxPixels; - srcX += maxPixels; - tempWidth -= maxPixels; - width = tempWidth; - } - - break; - - case SMI_ROTATE_CCW: - /* 90 degrees CCW rotatation. Calculate destination - coordinates: - - *---+ - | | +-----+ - | | | | destX = srcY - | | --> | | destY = shadowWidth - srcX - 1 - | | | | - | | *-----+ - +---+ - */ - destX = srcY; - destY = pSmi->ShadowWidth - srcX - 1; - - for (tempWidth=width; tempWidth>0;) - { - if (width>maxPixels) - width = maxPixels; - WaitQueue(4); - WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); - WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); - WRITE_DPR(pSmi, 0x08, (width << 16) + height); - WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | - SMI_ROTATE_CCW | SMI_START_ENGINE); - destY -= maxPixels; - srcX += maxPixels; - tempWidth -= maxPixels; - width = tempWidth; - } - - break; - - default: - /* No rotation, perform a normal copy. */ - if (pScrn->bitsPerPixel == 24) - { - srcX *= 3; - width *= 3; - - if (pSmi->Chipset == SMI_LYNX) - { - srcY *= 3; - } - } - - WaitQueue(4); - WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); - WRITE_DPR(pSmi, 0x04, (srcX << 16) + srcY); - WRITE_DPR(pSmi, 0x08, (width << 16) + height); - WRITE_DPR(pSmi, 0x0C, SMI_BITBLT + SMI_START_ENGINE + 0xCC); - break; - } + /* SM731 cannot rotate-blt more than a certain number of pixels + (based on a calculation from the Windows driver source */ + maxPixels = 1280 / pScrn->bitsPerPixel; + + while (num--) { + /* Get coordinates of the box to refresh. */ + srcX = pbox->x1; + srcY = pbox->y1; + width = pbox->x2 - srcX; + height = pbox->y2 - srcY; + + DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d\n", srcX, srcY, width, height)); + + if ((width > 0) && (height > 0)) { + switch (pSmi->rotate) { + case SMI_ROTATE_CW: + /* 90 degrees CW rotation. Calculate destination coordinates: + + *---+ + | | +-----* + | | | | destX = shadowHeight - srcY - 1 + | | --> | | destY = srcX + | | | | + | | +-----+ + +---+ + */ + destX = pSmi->ShadowHeight - srcY - 1; + destY = srcX; + + for (tempWidth=width; tempWidth > 0;) { + if (width>maxPixels) + width = maxPixels; + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CW | SMI_START_ENGINE); + destY += maxPixels; + srcX += maxPixels; + tempWidth -= maxPixels; + width = tempWidth; } - pbox++; - } + break; + case SMI_ROTATE_CCW: + /* 90 degrees CCW rotatation. Calculate destination coordinates: + + *---+ + | | +-----+ + | | | | destX = srcY + | | --> | | destY = shadowWidth - srcX - 1 + | | | | + | | *-----+ + +---+ + */ + destX = srcY; + destY = pSmi->ShadowWidth - srcX - 1; + + for (tempWidth=width; tempWidth > 0;) { + if (width>maxPixels) + width = maxPixels; + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CCW | SMI_START_ENGINE); + destY -= maxPixels; + srcX += maxPixels; + tempWidth -= maxPixels; + width = tempWidth; + } + + break; + default: + /* No rotation, perform a normal copy. */ + if (pScrn->bitsPerPixel == 24) { + srcX *= 3; + width *= 3; - if (pSmi->rotate) - { - /* If we did a rotation, we need to restore the hardware state here. */ - WaitIdleEmpty(); - WRITE_DPR(pSmi, 0x10, (pSmi->Stride << 16) | pSmi->Stride); - WRITE_DPR(pSmi, 0x3C, (pSmi->Stride << 16) | pSmi->Stride); - WRITE_DPR(pSmi, 0x44, 0); + if (pSmi->Chipset == SMI_LYNX) { + srcY *= 3; + } + } + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_BITBLT | SMI_START_ENGINE); + break; + } } - LEAVE_PROC("SMI_RefreshArea730"); + pbox++; + } + + if (pSmi->rotate) { + /* If we did a rotation, we need to restore the hardware state here. */ + WaitIdleEmpty(); + WRITE_DPR(pSmi, 0x10, (pSmi->Stride << 16) | pSmi->Stride); + WRITE_DPR(pSmi, 0x3C, (pSmi->Stride << 16) | pSmi->Stride); + WRITE_DPR(pSmi, 0x44, 0); + } + + LEAVE_PROC("SMI_RefreshArea730"); } /******************************************************************************\ @@ -345,8 +316,8 @@ void SMI_RefreshArea730(ScrnInfoPtr pScrn, int num, BoxPtr pbox) |*============================================================================= |* |* PARAMETERS: index Index of current screen. -|* x X location of pointer. -|* y Y location of pointer. +|* x X location of pointer. +|* y Y location of pointer. |* |* DESCRIPTION: Adjust the pointer location if we are in rotation mode. |* @@ -359,27 +330,25 @@ void SMI_PointerMoved(int index, int x, int y) SMIPtr pSmi = SMIPTR(pScrn); int newX, newY; - switch (pSmi->rotate) - { - case SMI_ROTATE_CW: - /* 90 degrees CW rotation. */ - newX = pScrn->pScreen->height - y - 1; - newY = x; - break; - - case SMI_ROTATE_CCW: - /* 90 degrees CCW rotation. */ - newX = y; - newY = pScrn->pScreen->width - x - 1; - break; - - default: - /* No rotation. */ - newX = x; - newY = y; - break; + switch (pSmi->rotate) { + case SMI_ROTATE_CW: + /* 90 degrees CW rotation. */ + newX = pScrn->pScreen->height - y - 1; + newY = x; + break; + case SMI_ROTATE_CCW: + /* 90 degrees CCW rotation. */ + newX = y; + newY = pScrn->pScreen->width - x - 1; + break; + default: + /* No rotation. */ + newX = x; + newY = y; + break; } - /* Pass adjusted pointer coordinates original PointerMoved function. */ + /* Pass adjusted pointer coordinates original PointerMoved function. */ (*pSmi->PointerMoved)(index, newX, newY); } + |