diff --git a/drivers/staging/sm7xx/Kconfig b/drivers/staging/sm7xx/Kconfig index 204dbfc3c38b..315102c7fed1 100644 --- a/drivers/staging/sm7xx/Kconfig +++ b/drivers/staging/sm7xx/Kconfig @@ -6,10 +6,3 @@ config FB_SM7XX select FB_CFB_IMAGEBLIT help Frame Buffer driver for the Silicon Motion SM7XX serial graphic card. - -config FB_SM7XX_ACCEL - bool "Siliconmotion Acceleration functions (EXPERIMENTAL)" - depends on FB_SM7XX && EXPERIMENTAL - help - This will compile the Trident frame buffer device with - acceleration functions. diff --git a/drivers/staging/sm7xx/TODO b/drivers/staging/sm7xx/TODO index 1f61f5e11cf5..a66d9e406497 100644 --- a/drivers/staging/sm7xx/TODO +++ b/drivers/staging/sm7xx/TODO @@ -1,5 +1,6 @@ TODO: - Dual head support +- 2D acceleration support - use kernel coding style - checkpatch.pl clean - refine the code and remove unused code diff --git a/drivers/staging/sm7xx/smtc2d.c b/drivers/staging/sm7xx/smtc2d.c deleted file mode 100644 index 133b86c6a678..000000000000 --- a/drivers/staging/sm7xx/smtc2d.c +++ /dev/null @@ -1,979 +0,0 @@ -/* - * Silicon Motion SM7XX 2D drawing engine functions. - * - * Copyright (C) 2006 Silicon Motion Technology Corp. - * Author: Boyod boyod.yang@siliconmotion.com.cn - * - * Copyright (C) 2009 Lemote, Inc. - * Author: Wu Zhangjin, wuzj@lemote.com - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of this archive for - * more details. - * - * Version 0.10.26192.21.01 - * - Add PowerPC support - * - Add 2D support for Lynx - - * Verified on 2.6.19.2 - * Boyod.yang - */ - -unsigned char smtc_de_busy; - -void SMTC_write2Dreg(unsigned long nOffset, unsigned long nData) -{ - writel(nData, smtc_2DBaseAddress + nOffset); -} - -unsigned long SMTC_read2Dreg(unsigned long nOffset) -{ - return readl(smtc_2DBaseAddress + nOffset); -} - -void SMTC_write2Ddataport(unsigned long nOffset, unsigned long nData) -{ - writel(nData, smtc_2Ddataport + nOffset); -} - -/********************************************************************** - * - * deInit - * - * Purpose - * Drawing engine initialization. - * - **********************************************************************/ - -void deInit(unsigned int nModeWidth, unsigned int nModeHeight, - unsigned int bpp) -{ - /* Get current power configuration. */ - unsigned char clock; - clock = smtc_seqr(0x21); - - /* initialize global 'mutex lock' variable */ - smtc_de_busy = 0; - - /* Enable 2D Drawing Engine */ - smtc_seqw(0x21, clock & 0xF8); - - SMTC_write2Dreg(DE_CLIP_TL, - FIELD_VALUE(0, DE_CLIP_TL, TOP, 0) | - FIELD_SET(0, DE_CLIP_TL, STATUS, DISABLE) | - FIELD_SET(0, DE_CLIP_TL, INHIBIT, OUTSIDE) | - FIELD_VALUE(0, DE_CLIP_TL, LEFT, 0)); - - if (bpp >= 24) { - SMTC_write2Dreg(DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, - nModeWidth * 3) | FIELD_VALUE(0, - DE_PITCH, - SOURCE, - nModeWidth - * 3)); - } else { - SMTC_write2Dreg(DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, - nModeWidth) | FIELD_VALUE(0, - DE_PITCH, - SOURCE, - nModeWidth)); - } - - SMTC_write2Dreg(DE_WINDOW_WIDTH, - FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, - nModeWidth) | FIELD_VALUE(0, - DE_WINDOW_WIDTH, - SOURCE, - nModeWidth)); - - switch (bpp) { - case 8: - SMTC_write2Dreg(DE_STRETCH_FORMAT, - FIELD_SET(0, DE_STRETCH_FORMAT, PATTERN_XY, - NORMAL) | FIELD_VALUE(0, - DE_STRETCH_FORMAT, - PATTERN_Y, - 0) | - FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_X, - 0) | FIELD_SET(0, DE_STRETCH_FORMAT, - PIXEL_FORMAT, - 8) | FIELD_SET(0, - DE_STRETCH_FORMAT, - ADDRESSING, - XY) | - FIELD_VALUE(0, DE_STRETCH_FORMAT, - SOURCE_HEIGHT, 3)); - break; - case 24: - SMTC_write2Dreg(DE_STRETCH_FORMAT, - FIELD_SET(0, DE_STRETCH_FORMAT, PATTERN_XY, - NORMAL) | FIELD_VALUE(0, - DE_STRETCH_FORMAT, - PATTERN_Y, - 0) | - FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_X, - 0) | FIELD_SET(0, DE_STRETCH_FORMAT, - PIXEL_FORMAT, - 24) | FIELD_SET(0, - DE_STRETCH_FORMAT, - ADDRESSING, - XY) | - FIELD_VALUE(0, DE_STRETCH_FORMAT, - SOURCE_HEIGHT, 3)); - break; - case 16: - default: - SMTC_write2Dreg(DE_STRETCH_FORMAT, - FIELD_SET(0, DE_STRETCH_FORMAT, PATTERN_XY, - NORMAL) | FIELD_VALUE(0, - DE_STRETCH_FORMAT, - PATTERN_Y, - 0) | - FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_X, - 0) | FIELD_SET(0, DE_STRETCH_FORMAT, - PIXEL_FORMAT, - 16) | FIELD_SET(0, - DE_STRETCH_FORMAT, - ADDRESSING, - XY) | - FIELD_VALUE(0, DE_STRETCH_FORMAT, - SOURCE_HEIGHT, 3)); - break; - } - - SMTC_write2Dreg(DE_MASKS, - FIELD_VALUE(0, DE_MASKS, BYTE_MASK, 0xFFFF) | - FIELD_VALUE(0, DE_MASKS, BIT_MASK, 0xFFFF)); - SMTC_write2Dreg(DE_COLOR_COMPARE_MASK, - FIELD_VALUE(0, DE_COLOR_COMPARE_MASK, MASKS, \ - 0xFFFFFF)); - SMTC_write2Dreg(DE_COLOR_COMPARE, - FIELD_VALUE(0, DE_COLOR_COMPARE, COLOR, 0xFFFFFF)); -} - -void deVerticalLine(unsigned long dst_base, - unsigned long dst_pitch, - unsigned long nX, - unsigned long nY, - unsigned long dst_height, unsigned long nColor) -{ - deWaitForNotBusy(); - - SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE, - FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE, ADDRESS, - dst_base)); - - SMTC_write2Dreg(DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, dst_pitch) | - FIELD_VALUE(0, DE_PITCH, SOURCE, dst_pitch)); - - SMTC_write2Dreg(DE_WINDOW_WIDTH, - FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, - dst_pitch) | FIELD_VALUE(0, DE_WINDOW_WIDTH, - SOURCE, - dst_pitch)); - - SMTC_write2Dreg(DE_FOREGROUND, - FIELD_VALUE(0, DE_FOREGROUND, COLOR, nColor)); - - SMTC_write2Dreg(DE_DESTINATION, - FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) | - FIELD_VALUE(0, DE_DESTINATION, X, nX) | - FIELD_VALUE(0, DE_DESTINATION, Y, nY)); - - SMTC_write2Dreg(DE_DIMENSION, - FIELD_VALUE(0, DE_DIMENSION, X, 1) | - FIELD_VALUE(0, DE_DIMENSION, Y_ET, dst_height)); - - SMTC_write2Dreg(DE_CONTROL, - FIELD_SET(0, DE_CONTROL, STATUS, START) | - FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT) | - FIELD_SET(0, DE_CONTROL, MAJOR, Y) | - FIELD_SET(0, DE_CONTROL, STEP_X, NEGATIVE) | - FIELD_SET(0, DE_CONTROL, STEP_Y, POSITIVE) | - FIELD_SET(0, DE_CONTROL, LAST_PIXEL, OFF) | - FIELD_SET(0, DE_CONTROL, COMMAND, SHORT_STROKE) | - FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) | - FIELD_VALUE(0, DE_CONTROL, ROP, 0x0C)); - - smtc_de_busy = 1; -} - -void deHorizontalLine(unsigned long dst_base, - unsigned long dst_pitch, - unsigned long nX, - unsigned long nY, - unsigned long dst_width, unsigned long nColor) -{ - deWaitForNotBusy(); - - SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE, - FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE, ADDRESS, - dst_base)); - - SMTC_write2Dreg(DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, dst_pitch) | - FIELD_VALUE(0, DE_PITCH, SOURCE, dst_pitch)); - - SMTC_write2Dreg(DE_WINDOW_WIDTH, - FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, - dst_pitch) | FIELD_VALUE(0, DE_WINDOW_WIDTH, - SOURCE, - dst_pitch)); - SMTC_write2Dreg(DE_FOREGROUND, - FIELD_VALUE(0, DE_FOREGROUND, COLOR, nColor)); - SMTC_write2Dreg(DE_DESTINATION, - FIELD_SET(0, DE_DESTINATION, WRAP, - DISABLE) | FIELD_VALUE(0, DE_DESTINATION, X, - nX) | FIELD_VALUE(0, - DE_DESTINATION, - Y, - nY)); - SMTC_write2Dreg(DE_DIMENSION, - FIELD_VALUE(0, DE_DIMENSION, X, - dst_width) | FIELD_VALUE(0, DE_DIMENSION, - Y_ET, 1)); - SMTC_write2Dreg(DE_CONTROL, - FIELD_SET(0, DE_CONTROL, STATUS, START) | FIELD_SET(0, - DE_CONTROL, - DIRECTION, - RIGHT_TO_LEFT) - | FIELD_SET(0, DE_CONTROL, MAJOR, X) | FIELD_SET(0, - DE_CONTROL, - STEP_X, - POSITIVE) - | FIELD_SET(0, DE_CONTROL, STEP_Y, - NEGATIVE) | FIELD_SET(0, DE_CONTROL, - LAST_PIXEL, - OFF) | FIELD_SET(0, - DE_CONTROL, - COMMAND, - SHORT_STROKE) - | FIELD_SET(0, DE_CONTROL, ROP_SELECT, - ROP2) | FIELD_VALUE(0, DE_CONTROL, ROP, - 0x0C)); - - smtc_de_busy = 1; -} - -void deLine(unsigned long dst_base, - unsigned long dst_pitch, - unsigned long nX1, - unsigned long nY1, - unsigned long nX2, unsigned long nY2, unsigned long nColor) -{ - unsigned long nCommand = - FIELD_SET(0, DE_CONTROL, STATUS, START) | - FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT) | - FIELD_SET(0, DE_CONTROL, MAJOR, X) | - FIELD_SET(0, DE_CONTROL, STEP_X, POSITIVE) | - FIELD_SET(0, DE_CONTROL, STEP_Y, POSITIVE) | - FIELD_SET(0, DE_CONTROL, LAST_PIXEL, OFF) | - FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) | - FIELD_VALUE(0, DE_CONTROL, ROP, 0x0C); - unsigned long DeltaX; - unsigned long DeltaY; - - /* Calculate delta X */ - if (nX1 <= nX2) - DeltaX = nX2 - nX1; - else { - DeltaX = nX1 - nX2; - nCommand = FIELD_SET(nCommand, DE_CONTROL, STEP_X, NEGATIVE); - } - - /* Calculate delta Y */ - if (nY1 <= nY2) - DeltaY = nY2 - nY1; - else { - DeltaY = nY1 - nY2; - nCommand = FIELD_SET(nCommand, DE_CONTROL, STEP_Y, NEGATIVE); - } - - /* Determine the major axis */ - if (DeltaX < DeltaY) - nCommand = FIELD_SET(nCommand, DE_CONTROL, MAJOR, Y); - - /* Vertical line? */ - if (nX1 == nX2) - deVerticalLine(dst_base, dst_pitch, nX1, nY1, DeltaY, nColor); - - /* Horizontal line? */ - else if (nY1 == nY2) - deHorizontalLine(dst_base, dst_pitch, nX1, nY1, \ - DeltaX, nColor); - - /* Diagonal line? */ - else if (DeltaX == DeltaY) { - deWaitForNotBusy(); - - SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE, - FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE, - ADDRESS, dst_base)); - - SMTC_write2Dreg(DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, - dst_pitch) | FIELD_VALUE(0, - DE_PITCH, - SOURCE, - dst_pitch)); - - SMTC_write2Dreg(DE_WINDOW_WIDTH, - FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, - dst_pitch) | FIELD_VALUE(0, - DE_WINDOW_WIDTH, - SOURCE, - dst_pitch)); - - SMTC_write2Dreg(DE_FOREGROUND, - FIELD_VALUE(0, DE_FOREGROUND, COLOR, nColor)); - - SMTC_write2Dreg(DE_DESTINATION, - FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) | - FIELD_VALUE(0, DE_DESTINATION, X, 1) | - FIELD_VALUE(0, DE_DESTINATION, Y, nY1)); - - SMTC_write2Dreg(DE_DIMENSION, - FIELD_VALUE(0, DE_DIMENSION, X, 1) | - FIELD_VALUE(0, DE_DIMENSION, Y_ET, DeltaX)); - - SMTC_write2Dreg(DE_CONTROL, - FIELD_SET(nCommand, DE_CONTROL, COMMAND, - SHORT_STROKE)); - } - - /* Generic line */ - else { - unsigned int k1, k2, et, w; - if (DeltaX < DeltaY) { - k1 = 2 * DeltaX; - et = k1 - DeltaY; - k2 = et - DeltaY; - w = DeltaY + 1; - } else { - k1 = 2 * DeltaY; - et = k1 - DeltaX; - k2 = et - DeltaX; - w = DeltaX + 1; - } - - deWaitForNotBusy(); - - SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE, - FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE, - ADDRESS, dst_base)); - - SMTC_write2Dreg(DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, - dst_pitch) | FIELD_VALUE(0, - DE_PITCH, - SOURCE, - dst_pitch)); - - SMTC_write2Dreg(DE_WINDOW_WIDTH, - FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, - dst_pitch) | FIELD_VALUE(0, - DE_WINDOW_WIDTH, - SOURCE, - dst_pitch)); - - SMTC_write2Dreg(DE_FOREGROUND, - FIELD_VALUE(0, DE_FOREGROUND, COLOR, nColor)); - - SMTC_write2Dreg(DE_SOURCE, - FIELD_SET(0, DE_SOURCE, WRAP, DISABLE) | - FIELD_VALUE(0, DE_SOURCE, X_K1, k1) | - FIELD_VALUE(0, DE_SOURCE, Y_K2, k2)); - - SMTC_write2Dreg(DE_DESTINATION, - FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) | - FIELD_VALUE(0, DE_DESTINATION, X, nX1) | - FIELD_VALUE(0, DE_DESTINATION, Y, nY1)); - - SMTC_write2Dreg(DE_DIMENSION, - FIELD_VALUE(0, DE_DIMENSION, X, w) | - FIELD_VALUE(0, DE_DIMENSION, Y_ET, et)); - - SMTC_write2Dreg(DE_CONTROL, - FIELD_SET(nCommand, DE_CONTROL, COMMAND, - LINE_DRAW)); - } - - smtc_de_busy = 1; -} - -void deFillRect(unsigned long dst_base, - unsigned long dst_pitch, - unsigned long dst_X, - unsigned long dst_Y, - unsigned long dst_width, - unsigned long dst_height, unsigned long nColor) -{ - deWaitForNotBusy(); - - SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE, - FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE, ADDRESS, - dst_base)); - - if (dst_pitch) { - SMTC_write2Dreg(DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, - dst_pitch) | FIELD_VALUE(0, - DE_PITCH, - SOURCE, - dst_pitch)); - - SMTC_write2Dreg(DE_WINDOW_WIDTH, - FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, - dst_pitch) | FIELD_VALUE(0, - DE_WINDOW_WIDTH, - SOURCE, - dst_pitch)); - } - - SMTC_write2Dreg(DE_FOREGROUND, - FIELD_VALUE(0, DE_FOREGROUND, COLOR, nColor)); - - SMTC_write2Dreg(DE_DESTINATION, - FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) | - FIELD_VALUE(0, DE_DESTINATION, X, dst_X) | - FIELD_VALUE(0, DE_DESTINATION, Y, dst_Y)); - - SMTC_write2Dreg(DE_DIMENSION, - FIELD_VALUE(0, DE_DIMENSION, X, dst_width) | - FIELD_VALUE(0, DE_DIMENSION, Y_ET, dst_height)); - - SMTC_write2Dreg(DE_CONTROL, - FIELD_SET(0, DE_CONTROL, STATUS, START) | - FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT) | - FIELD_SET(0, DE_CONTROL, LAST_PIXEL, OFF) | - FIELD_SET(0, DE_CONTROL, COMMAND, RECTANGLE_FILL) | - FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) | - FIELD_VALUE(0, DE_CONTROL, ROP, 0x0C)); - - smtc_de_busy = 1; -} - -/********************************************************************** - * - * deRotatePattern - * - * Purpose - * Rotate the given pattern if necessary - * - * Parameters - * [in] - * pPattern - Pointer to DE_SURFACE structure containing - * pattern attributes - * patternX - X position (0-7) of pattern origin - * patternY - Y position (0-7) of pattern origin - * - * [out] - * pattern_dstaddr - Pointer to pre-allocated buffer containing - * rotated pattern - * - **********************************************************************/ -void deRotatePattern(unsigned char *pattern_dstaddr, - unsigned long pattern_src_addr, - unsigned long pattern_BPP, - unsigned long pattern_stride, int patternX, int patternY) -{ - unsigned int i; - unsigned long pattern[PATTERN_WIDTH * PATTERN_HEIGHT]; - unsigned int x, y; - unsigned char *pjPatByte; - - if (pattern_dstaddr != NULL) { - deWaitForNotBusy(); - - if (patternX || patternY) { - /* Rotate pattern */ - pjPatByte = (unsigned char *)pattern; - - switch (pattern_BPP) { - case 8: - { - for (y = 0; y < 8; y++) { - unsigned char *pjBuffer = - pattern_dstaddr + - ((patternY + y) & 7) * 8; - for (x = 0; x < 8; x++) { - pjBuffer[(patternX + - x) & 7] = - pjPatByte[x]; - } - pjPatByte += pattern_stride; - } - break; - } - - case 16: - { - for (y = 0; y < 8; y++) { - unsigned short *pjBuffer = - (unsigned short *) - pattern_dstaddr + - ((patternY + y) & 7) * 8; - for (x = 0; x < 8; x++) { - pjBuffer[(patternX + - x) & 7] = - ((unsigned short *) - pjPatByte)[x]; - } - pjPatByte += pattern_stride; - } - break; - } - - case 32: - { - for (y = 0; y < 8; y++) { - unsigned long *pjBuffer = - (unsigned long *) - pattern_dstaddr + - ((patternY + y) & 7) * 8; - for (x = 0; x < 8; x++) { - pjBuffer[(patternX + - x) & 7] = - ((unsigned long *) - pjPatByte)[x]; - } - pjPatByte += pattern_stride; - } - break; - } - } - } else { - /*Don't rotate,just copy pattern into pattern_dstaddr*/ - for (i = 0; i < (pattern_BPP * 2); i++) { - ((unsigned long *)pattern_dstaddr)[i] = - pattern[i]; - } - } - - } -} - -/********************************************************************** - * - * deCopy - * - * Purpose - * Copy a rectangular area of the source surface to a destination surface - * - * Remarks - * Source bitmap must have the same color depth (BPP) as the destination - * bitmap. - * -**********************************************************************/ -void deCopy(unsigned long dst_base, - unsigned long dst_pitch, - unsigned long dst_BPP, - unsigned long dst_X, - unsigned long dst_Y, - unsigned long dst_width, - unsigned long dst_height, - unsigned long src_base, - unsigned long src_pitch, - unsigned long src_X, - unsigned long src_Y, pTransparent pTransp, unsigned char nROP2) -{ - unsigned long nDirection = 0; - unsigned long nTransparent = 0; - /* Direction of ROP2 operation: - * 1 = Left to Right, - * (-1) = Right to Left - */ - unsigned long opSign = 1; - /* xWidth is in pixels */ - unsigned long xWidth = 192 / (dst_BPP / 8); - unsigned long de_ctrl = 0; - - deWaitForNotBusy(); - - SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE, - FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE, ADDRESS, - dst_base)); - - SMTC_write2Dreg(DE_WINDOW_SOURCE_BASE, - FIELD_VALUE(0, DE_WINDOW_SOURCE_BASE, ADDRESS, - src_base)); - - if (dst_pitch && src_pitch) { - SMTC_write2Dreg(DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, - dst_pitch) | FIELD_VALUE(0, - DE_PITCH, - SOURCE, - src_pitch)); - - SMTC_write2Dreg(DE_WINDOW_WIDTH, - FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, - dst_pitch) | FIELD_VALUE(0, - DE_WINDOW_WIDTH, - SOURCE, - src_pitch)); - } - - /* Set transparent bits if necessary */ - if (pTransp != NULL) { - nTransparent = - pTransp->match | pTransp->select | pTransp->control; - - /* Set color compare register */ - SMTC_write2Dreg(DE_COLOR_COMPARE, - FIELD_VALUE(0, DE_COLOR_COMPARE, COLOR, - pTransp->color)); - } - - /* Determine direction of operation */ - if (src_Y < dst_Y) { - /* +----------+ - |S | - | +----------+ - | | | | - | | | | - +---|------+ | - | D | - +----------+ */ - - nDirection = BOTTOM_TO_TOP; - } else if (src_Y > dst_Y) { - /* +----------+ - |D | - | +----------+ - | | | | - | | | | - +---|------+ | - | S | - +----------+ */ - - nDirection = TOP_TO_BOTTOM; - } else { - /* src_Y == dst_Y */ - - if (src_X <= dst_X) { - /* +------+---+------+ - |S | | D| - | | | | - | | | | - | | | | - +------+---+------+ */ - - nDirection = RIGHT_TO_LEFT; - } else { - /* src_X > dst_X */ - - /* +------+---+------+ - |D | | S| - | | | | - | | | | - | | | | - +------+---+------+ */ - - nDirection = LEFT_TO_RIGHT; - } - } - - if ((nDirection == BOTTOM_TO_TOP) || (nDirection == RIGHT_TO_LEFT)) { - src_X += dst_width - 1; - src_Y += dst_height - 1; - dst_X += dst_width - 1; - dst_Y += dst_height - 1; - opSign = (-1); - } - - if (dst_BPP >= 24) { - src_X *= 3; - src_Y *= 3; - dst_X *= 3; - dst_Y *= 3; - dst_width *= 3; - if ((nDirection == BOTTOM_TO_TOP) - || (nDirection == RIGHT_TO_LEFT)) { - src_X += 2; - dst_X += 2; - } - } - - /* Workaround for 192 byte hw bug */ - if ((nROP2 != 0x0C) && ((dst_width * (dst_BPP / 8)) >= 192)) { - /* - * Perform the ROP2 operation in chunks of (xWidth * - * dst_height) - */ - while (1) { - deWaitForNotBusy(); - - SMTC_write2Dreg(DE_SOURCE, - FIELD_SET(0, DE_SOURCE, WRAP, DISABLE) | - FIELD_VALUE(0, DE_SOURCE, X_K1, src_X) | - FIELD_VALUE(0, DE_SOURCE, Y_K2, src_Y)); - - SMTC_write2Dreg(DE_DESTINATION, - FIELD_SET(0, DE_DESTINATION, WRAP, - DISABLE) | FIELD_VALUE(0, - DE_DESTINATION, - X, - dst_X) - | FIELD_VALUE(0, DE_DESTINATION, Y, - dst_Y)); - - SMTC_write2Dreg(DE_DIMENSION, - FIELD_VALUE(0, DE_DIMENSION, X, - xWidth) | FIELD_VALUE(0, - DE_DIMENSION, - Y_ET, - dst_height)); - - de_ctrl = - FIELD_VALUE(0, DE_CONTROL, ROP, - nROP2) | nTransparent | FIELD_SET(0, - DE_CONTROL, - ROP_SELECT, - ROP2) - | FIELD_SET(0, DE_CONTROL, COMMAND, - BITBLT) | ((nDirection == - 1) ? FIELD_SET(0, - DE_CONTROL, - DIRECTION, - RIGHT_TO_LEFT) - : FIELD_SET(0, DE_CONTROL, - DIRECTION, - LEFT_TO_RIGHT)) | - FIELD_SET(0, DE_CONTROL, STATUS, START); - - SMTC_write2Dreg(DE_CONTROL, de_ctrl); - - src_X += (opSign * xWidth); - dst_X += (opSign * xWidth); - dst_width -= xWidth; - - if (dst_width <= 0) { - /* ROP2 operation is complete */ - break; - } - - if (xWidth > dst_width) - xWidth = dst_width; - } - } else { - deWaitForNotBusy(); - SMTC_write2Dreg(DE_SOURCE, - FIELD_SET(0, DE_SOURCE, WRAP, DISABLE) | - FIELD_VALUE(0, DE_SOURCE, X_K1, src_X) | - FIELD_VALUE(0, DE_SOURCE, Y_K2, src_Y)); - - SMTC_write2Dreg(DE_DESTINATION, - FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) | - FIELD_VALUE(0, DE_DESTINATION, X, dst_X) | - FIELD_VALUE(0, DE_DESTINATION, Y, dst_Y)); - - SMTC_write2Dreg(DE_DIMENSION, - FIELD_VALUE(0, DE_DIMENSION, X, dst_width) | - FIELD_VALUE(0, DE_DIMENSION, Y_ET, dst_height)); - - de_ctrl = FIELD_VALUE(0, DE_CONTROL, ROP, nROP2) | - nTransparent | - FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) | - FIELD_SET(0, DE_CONTROL, COMMAND, BITBLT) | - ((nDirection == 1) ? FIELD_SET(0, DE_CONTROL, DIRECTION, - RIGHT_TO_LEFT) - : FIELD_SET(0, DE_CONTROL, DIRECTION, - LEFT_TO_RIGHT)) | FIELD_SET(0, DE_CONTROL, - STATUS, START); - SMTC_write2Dreg(DE_CONTROL, de_ctrl); - } - - smtc_de_busy = 1; -} - -/* - * This function sets the pixel format that will apply to the 2D Engine. - */ -void deSetPixelFormat(unsigned long bpp) -{ - unsigned long de_format; - - de_format = SMTC_read2Dreg(DE_STRETCH_FORMAT); - - switch (bpp) { - case 8: - de_format = - FIELD_SET(de_format, DE_STRETCH_FORMAT, PIXEL_FORMAT, 8); - break; - default: - case 16: - de_format = - FIELD_SET(de_format, DE_STRETCH_FORMAT, PIXEL_FORMAT, 16); - break; - case 32: - de_format = - FIELD_SET(de_format, DE_STRETCH_FORMAT, PIXEL_FORMAT, 32); - break; - } - - SMTC_write2Dreg(DE_STRETCH_FORMAT, de_format); -} - -/* - * System memory to Video memory monochrome expansion. - * - * Source is monochrome image in system memory. This function expands the - * monochrome data to color image in video memory. - */ - -long deSystemMem2VideoMemMonoBlt(const char *pSrcbuf, - long srcDelta, - unsigned long startBit, - unsigned long dBase, - unsigned long dPitch, - unsigned long bpp, - unsigned long dx, unsigned long dy, - unsigned long width, unsigned long height, - unsigned long fColor, - unsigned long bColor, - unsigned long rop2) { - unsigned long bytePerPixel; - unsigned long ulBytesPerScan; - unsigned long ul4BytesPerScan; - unsigned long ulBytesRemain; - unsigned long de_ctrl = 0; - unsigned char ajRemain[4]; - long i, j; - - bytePerPixel = bpp / 8; - - /* Just make sure the start bit is within legal range */ - startBit &= 7; - - ulBytesPerScan = (width + startBit + 7) / 8; - ul4BytesPerScan = ulBytesPerScan & ~3; - ulBytesRemain = ulBytesPerScan & 3; - - if (smtc_de_busy) - deWaitForNotBusy(); - - /* - * 2D Source Base. Use 0 for HOST Blt. - */ - - SMTC_write2Dreg(DE_WINDOW_SOURCE_BASE, 0); - - /* - * 2D Destination Base. - * - * It is an address offset (128 bit aligned) from the beginning of - * frame buffer. - */ - - SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE, dBase); - - if (dPitch) { - - /* - * Program pitch (distance between the 1st points of two - * adjacent lines). - * - * Note that input pitch is BYTE value, but the 2D Pitch - * register uses pixel values. Need Byte to pixel convertion. - */ - - SMTC_write2Dreg(DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, - dPitch / - bytePerPixel) | FIELD_VALUE(0, - DE_PITCH, - SOURCE, - dPitch / - bytePerPixel)); - - /* Screen Window width in Pixels. - * - * 2D engine uses this value to calculate the linear address in - * frame buffer for a given point. - */ - - SMTC_write2Dreg(DE_WINDOW_WIDTH, - FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, - (dPitch / - bytePerPixel)) | FIELD_VALUE(0, - DE_WINDOW_WIDTH, - SOURCE, - (dPitch - / - bytePerPixel))); - } - /* Note: For 2D Source in Host Write, only X_K1 field is needed, and - * Y_K2 field is not used. For mono bitmap, use startBit for X_K1. - */ - - SMTC_write2Dreg(DE_SOURCE, - FIELD_SET(0, DE_SOURCE, WRAP, DISABLE) | - FIELD_VALUE(0, DE_SOURCE, X_K1, startBit) | - FIELD_VALUE(0, DE_SOURCE, Y_K2, 0)); - - SMTC_write2Dreg(DE_DESTINATION, - FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) | - FIELD_VALUE(0, DE_DESTINATION, X, dx) | - FIELD_VALUE(0, DE_DESTINATION, Y, dy)); - - SMTC_write2Dreg(DE_DIMENSION, - FIELD_VALUE(0, DE_DIMENSION, X, width) | - FIELD_VALUE(0, DE_DIMENSION, Y_ET, height)); - - SMTC_write2Dreg(DE_FOREGROUND, fColor); - SMTC_write2Dreg(DE_BACKGROUND, bColor); - - if (bpp) - deSetPixelFormat(bpp); - /* Set the pixel format of the destination */ - - de_ctrl = FIELD_VALUE(0, DE_CONTROL, ROP, rop2) | - FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) | - FIELD_SET(0, DE_CONTROL, COMMAND, HOST_WRITE) | - FIELD_SET(0, DE_CONTROL, HOST, MONO) | - FIELD_SET(0, DE_CONTROL, STATUS, START); - - SMTC_write2Dreg(DE_CONTROL, de_ctrl | deGetTransparency()); - - /* Write MONO data (line by line) to 2D Engine data port */ - for (i = 0; i < height; i++) { - /* For each line, send the data in chunks of 4 bytes */ - for (j = 0; j < (ul4BytesPerScan / 4); j++) - SMTC_write2Ddataport(0, - *(unsigned long *)(pSrcbuf + - (j * 4))); - - if (ulBytesRemain) { - memcpy(ajRemain, pSrcbuf + ul4BytesPerScan, - ulBytesRemain); - SMTC_write2Ddataport(0, *(unsigned long *)ajRemain); - } - - pSrcbuf += srcDelta; - } - smtc_de_busy = 1; - - return 0; -} - -/* - * This function gets the transparency status from DE_CONTROL register. - * It returns a double word with the transparent fields properly set, - * while other fields are 0. - */ -unsigned long deGetTransparency(void) -{ - unsigned long de_ctrl; - - de_ctrl = SMTC_read2Dreg(DE_CONTROL); - - de_ctrl &= - FIELD_MASK(DE_CONTROL_TRANSPARENCY_MATCH) | - FIELD_MASK(DE_CONTROL_TRANSPARENCY_SELECT) | - FIELD_MASK(DE_CONTROL_TRANSPARENCY); - - return de_ctrl; -} diff --git a/drivers/staging/sm7xx/smtc2d.h b/drivers/staging/sm7xx/smtc2d.h deleted file mode 100644 index 38d0c335322b..000000000000 --- a/drivers/staging/sm7xx/smtc2d.h +++ /dev/null @@ -1,530 +0,0 @@ -/* - * Silicon Motion SM712 2D drawing engine functions. - * - * Copyright (C) 2006 Silicon Motion Technology Corp. - * Author: Ge Wang, gewang@siliconmotion.com - * - * Copyright (C) 2009 Lemote, Inc. - * Author: Wu Zhangjin, wuzj@lemote.com - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of this archive for - * more details. - */ - -#ifndef NULL -#define NULL 0 -#endif - -/* Internal macros */ - -#define _F_START(f) (0 ? f) -#define _F_END(f) (1 ? f) -#define _F_SIZE(f) (1 + _F_END(f) - _F_START(f)) -#define _F_MASK(f) (((1ULL << _F_SIZE(f)) - 1) << _F_START(f)) -#define _F_NORMALIZE(v, f) (((v) & _F_MASK(f)) >> _F_START(f)) -#define _F_DENORMALIZE(v, f) (((v) << _F_START(f)) & _F_MASK(f)) - -/* Global macros */ - -#define FIELD_GET(x, reg, field) \ -( \ - _F_NORMALIZE((x), reg ## _ ## field) \ -) - -#define FIELD_SET(x, reg, field, value) \ -( \ - (x & ~_F_MASK(reg ## _ ## field)) \ - | _F_DENORMALIZE(reg ## _ ## field ## _ ## value, reg ## _ ## field) \ -) - -#define FIELD_VALUE(x, reg, field, value) \ -( \ - (x & ~_F_MASK(reg ## _ ## field)) \ - | _F_DENORMALIZE(value, reg ## _ ## field) \ -) - -#define FIELD_CLEAR(reg, field) \ -( \ - ~_F_MASK(reg ## _ ## field) \ -) - -/* Field Macros */ - -#define FIELD_START(field) (0 ? field) -#define FIELD_END(field) (1 ? field) -#define FIELD_SIZE(field) \ - (1 + FIELD_END(field) - FIELD_START(field)) - -#define FIELD_MASK(field) \ - (((1 << (FIELD_SIZE(field)-1)) \ - | ((1 << (FIELD_SIZE(field)-1)) - 1)) \ - << FIELD_START(field)) - -#define FIELD_NORMALIZE(reg, field) \ - (((reg) & FIELD_MASK(field)) >> FIELD_START(field)) - -#define FIELD_DENORMALIZE(field, value) \ - (((value) << FIELD_START(field)) & FIELD_MASK(field)) - -#define FIELD_INIT(reg, field, value) \ - FIELD_DENORMALIZE(reg ## _ ## field, \ - reg ## _ ## field ## _ ## value) - -#define FIELD_INIT_VAL(reg, field, value) \ - (FIELD_DENORMALIZE(reg ## _ ## field, value)) - -#define FIELD_VAL_SET(x, r, f, v) ({ \ - x = (x & ~FIELD_MASK(r ## _ ## f)) \ - | FIELD_DENORMALIZE(r ## _ ## f, r ## _ ## f ## _ ## v) \ -}) - -#define RGB(r, g, b) ((unsigned long)(((r) << 16) | ((g) << 8) | (b))) - -/* Transparent info definition */ -typedef struct { - unsigned long match; /* Matching pixel is OPAQUE/TRANSPARENT */ - unsigned long select; /* Transparency controlled by SRC/DST */ - unsigned long control; /* ENABLE/DISABLE transparency */ - unsigned long color; /* Transparent color */ -} Transparent, *pTransparent; - -#define PIXEL_DEPTH_1_BP 0 /* 1 bit per pixel */ -#define PIXEL_DEPTH_8_BPP 1 /* 8 bits per pixel */ -#define PIXEL_DEPTH_16_BPP 2 /* 16 bits per pixel */ -#define PIXEL_DEPTH_32_BPP 3 /* 32 bits per pixel */ -#define PIXEL_DEPTH_YUV422 8 /* 16 bits per pixel YUV422 */ -#define PIXEL_DEPTH_YUV420 9 /* 16 bits per pixel YUV420 */ - -#define PATTERN_WIDTH 8 -#define PATTERN_HEIGHT 8 - -#define TOP_TO_BOTTOM 0 -#define BOTTOM_TO_TOP 1 -#define RIGHT_TO_LEFT BOTTOM_TO_TOP -#define LEFT_TO_RIGHT TOP_TO_BOTTOM - -/* Constants used in Transparent structure */ -#define MATCH_OPAQUE 0x00000000 -#define MATCH_TRANSPARENT 0x00000400 -#define SOURCE 0x00000000 -#define DESTINATION 0x00000200 - -/* 2D registers. */ - -#define DE_SOURCE 0x000000 -#define DE_SOURCE_WRAP 31 : 31 -#define DE_SOURCE_WRAP_DISABLE 0 -#define DE_SOURCE_WRAP_ENABLE 1 -#define DE_SOURCE_X_K1 29 : 16 -#define DE_SOURCE_Y_K2 15 : 0 - -#define DE_DESTINATION 0x000004 -#define DE_DESTINATION_WRAP 31 : 31 -#define DE_DESTINATION_WRAP_DISABLE 0 -#define DE_DESTINATION_WRAP_ENABLE 1 -#define DE_DESTINATION_X 28 : 16 -#define DE_DESTINATION_Y 15 : 0 - -#define DE_DIMENSION 0x000008 -#define DE_DIMENSION_X 28 : 16 -#define DE_DIMENSION_Y_ET 15 : 0 - -#define DE_CONTROL 0x00000C -#define DE_CONTROL_STATUS 31 : 31 -#define DE_CONTROL_STATUS_STOP 0 -#define DE_CONTROL_STATUS_START 1 -#define DE_CONTROL_PATTERN 30 : 30 -#define DE_CONTROL_PATTERN_MONO 0 -#define DE_CONTROL_PATTERN_COLOR 1 -#define DE_CONTROL_UPDATE_DESTINATION_X 29 : 29 -#define DE_CONTROL_UPDATE_DESTINATION_X_DISABLE 0 -#define DE_CONTROL_UPDATE_DESTINATION_X_ENABLE 1 -#define DE_CONTROL_QUICK_START 28 : 28 -#define DE_CONTROL_QUICK_START_DISABLE 0 -#define DE_CONTROL_QUICK_START_ENABLE 1 -#define DE_CONTROL_DIRECTION 27 : 27 -#define DE_CONTROL_DIRECTION_LEFT_TO_RIGHT 0 -#define DE_CONTROL_DIRECTION_RIGHT_TO_LEFT 1 -#define DE_CONTROL_MAJOR 26 : 26 -#define DE_CONTROL_MAJOR_X 0 -#define DE_CONTROL_MAJOR_Y 1 -#define DE_CONTROL_STEP_X 25 : 25 -#define DE_CONTROL_STEP_X_POSITIVE 1 -#define DE_CONTROL_STEP_X_NEGATIVE 0 -#define DE_CONTROL_STEP_Y 24 : 24 -#define DE_CONTROL_STEP_Y_POSITIVE 1 -#define DE_CONTROL_STEP_Y_NEGATIVE 0 -#define DE_CONTROL_STRETCH 23 : 23 -#define DE_CONTROL_STRETCH_DISABLE 0 -#define DE_CONTROL_STRETCH_ENABLE 1 -#define DE_CONTROL_HOST 22 : 22 -#define DE_CONTROL_HOST_COLOR 0 -#define DE_CONTROL_HOST_MONO 1 -#define DE_CONTROL_LAST_PIXEL 21 : 21 -#define DE_CONTROL_LAST_PIXEL_OFF 0 -#define DE_CONTROL_LAST_PIXEL_ON 1 -#define DE_CONTROL_COMMAND 20 : 16 -#define DE_CONTROL_COMMAND_BITBLT 0 -#define DE_CONTROL_COMMAND_RECTANGLE_FILL 1 -#define DE_CONTROL_COMMAND_DE_TILE 2 -#define DE_CONTROL_COMMAND_TRAPEZOID_FILL 3 -#define DE_CONTROL_COMMAND_ALPHA_BLEND 4 -#define DE_CONTROL_COMMAND_RLE_STRIP 5 -#define DE_CONTROL_COMMAND_SHORT_STROKE 6 -#define DE_CONTROL_COMMAND_LINE_DRAW 7 -#define DE_CONTROL_COMMAND_HOST_WRITE 8 -#define DE_CONTROL_COMMAND_HOST_READ 9 -#define DE_CONTROL_COMMAND_HOST_WRITE_BOTTOM_UP 10 -#define DE_CONTROL_COMMAND_ROTATE 11 -#define DE_CONTROL_COMMAND_FONT 12 -#define DE_CONTROL_COMMAND_TEXTURE_LOAD 15 -#define DE_CONTROL_ROP_SELECT 15 : 15 -#define DE_CONTROL_ROP_SELECT_ROP3 0 -#define DE_CONTROL_ROP_SELECT_ROP2 1 -#define DE_CONTROL_ROP2_SOURCE 14 : 14 -#define DE_CONTROL_ROP2_SOURCE_BITMAP 0 -#define DE_CONTROL_ROP2_SOURCE_PATTERN 1 -#define DE_CONTROL_MONO_DATA 13 : 12 -#define DE_CONTROL_MONO_DATA_NOT_PACKED 0 -#define DE_CONTROL_MONO_DATA_8_PACKED 1 -#define DE_CONTROL_MONO_DATA_16_PACKED 2 -#define DE_CONTROL_MONO_DATA_32_PACKED 3 -#define DE_CONTROL_REPEAT_ROTATE 11 : 11 -#define DE_CONTROL_REPEAT_ROTATE_DISABLE 0 -#define DE_CONTROL_REPEAT_ROTATE_ENABLE 1 -#define DE_CONTROL_TRANSPARENCY_MATCH 10 : 10 -#define DE_CONTROL_TRANSPARENCY_MATCH_OPAQUE 0 -#define DE_CONTROL_TRANSPARENCY_MATCH_TRANSPARENT 1 -#define DE_CONTROL_TRANSPARENCY_SELECT 9 : 9 -#define DE_CONTROL_TRANSPARENCY_SELECT_SOURCE 0 -#define DE_CONTROL_TRANSPARENCY_SELECT_DESTINATION 1 -#define DE_CONTROL_TRANSPARENCY 8 : 8 -#define DE_CONTROL_TRANSPARENCY_DISABLE 0 -#define DE_CONTROL_TRANSPARENCY_ENABLE 1 -#define DE_CONTROL_ROP 7 : 0 - -/* Pseudo fields. */ - -#define DE_CONTROL_SHORT_STROKE_DIR 27 : 24 -#define DE_CONTROL_SHORT_STROKE_DIR_225 0 -#define DE_CONTROL_SHORT_STROKE_DIR_135 1 -#define DE_CONTROL_SHORT_STROKE_DIR_315 2 -#define DE_CONTROL_SHORT_STROKE_DIR_45 3 -#define DE_CONTROL_SHORT_STROKE_DIR_270 4 -#define DE_CONTROL_SHORT_STROKE_DIR_90 5 -#define DE_CONTROL_SHORT_STROKE_DIR_180 8 -#define DE_CONTROL_SHORT_STROKE_DIR_0 10 -#define DE_CONTROL_ROTATION 25 : 24 -#define DE_CONTROL_ROTATION_0 0 -#define DE_CONTROL_ROTATION_270 1 -#define DE_CONTROL_ROTATION_90 2 -#define DE_CONTROL_ROTATION_180 3 - -#define DE_PITCH 0x000010 -#define DE_PITCH_DESTINATION 28 : 16 -#define DE_PITCH_SOURCE 12 : 0 - -#define DE_FOREGROUND 0x000014 -#define DE_FOREGROUND_COLOR 31 : 0 - -#define DE_BACKGROUND 0x000018 -#define DE_BACKGROUND_COLOR 31 : 0 - -#define DE_STRETCH_FORMAT 0x00001C -#define DE_STRETCH_FORMAT_PATTERN_XY 30 : 30 -#define DE_STRETCH_FORMAT_PATTERN_XY_NORMAL 0 -#define DE_STRETCH_FORMAT_PATTERN_XY_OVERWRITE 1 -#define DE_STRETCH_FORMAT_PATTERN_Y 29 : 27 -#define DE_STRETCH_FORMAT_PATTERN_X 25 : 23 -#define DE_STRETCH_FORMAT_PIXEL_FORMAT 21 : 20 -#define DE_STRETCH_FORMAT_PIXEL_FORMAT_8 0 -#define DE_STRETCH_FORMAT_PIXEL_FORMAT_16 1 -#define DE_STRETCH_FORMAT_PIXEL_FORMAT_24 3 -#define DE_STRETCH_FORMAT_PIXEL_FORMAT_32 2 -#define DE_STRETCH_FORMAT_ADDRESSING 19 : 16 -#define DE_STRETCH_FORMAT_ADDRESSING_XY 0 -#define DE_STRETCH_FORMAT_ADDRESSING_LINEAR 15 -#define DE_STRETCH_FORMAT_SOURCE_HEIGHT 11 : 0 - -#define DE_COLOR_COMPARE 0x000020 -#define DE_COLOR_COMPARE_COLOR 23 : 0 - -#define DE_COLOR_COMPARE_MASK 0x000024 -#define DE_COLOR_COMPARE_MASK_MASKS 23 : 0 - -#define DE_MASKS 0x000028 -#define DE_MASKS_BYTE_MASK 31 : 16 -#define DE_MASKS_BIT_MASK 15 : 0 - -#define DE_CLIP_TL 0x00002C -#define DE_CLIP_TL_TOP 31 : 16 -#define DE_CLIP_TL_STATUS 13 : 13 -#define DE_CLIP_TL_STATUS_DISABLE 0 -#define DE_CLIP_TL_STATUS_ENABLE 1 -#define DE_CLIP_TL_INHIBIT 12 : 12 -#define DE_CLIP_TL_INHIBIT_OUTSIDE 0 -#define DE_CLIP_TL_INHIBIT_INSIDE 1 -#define DE_CLIP_TL_LEFT 11 : 0 - -#define DE_CLIP_BR 0x000030 -#define DE_CLIP_BR_BOTTOM 31 : 16 -#define DE_CLIP_BR_RIGHT 12 : 0 - -#define DE_MONO_PATTERN_LOW 0x000034 -#define DE_MONO_PATTERN_LOW_PATTERN 31 : 0 - -#define DE_MONO_PATTERN_HIGH 0x000038 -#define DE_MONO_PATTERN_HIGH_PATTERN 31 : 0 - -#define DE_WINDOW_WIDTH 0x00003C -#define DE_WINDOW_WIDTH_DESTINATION 28 : 16 -#define DE_WINDOW_WIDTH_SOURCE 12 : 0 - -#define DE_WINDOW_SOURCE_BASE 0x000040 -#define DE_WINDOW_SOURCE_BASE_EXT 27 : 27 -#define DE_WINDOW_SOURCE_BASE_EXT_LOCAL 0 -#define DE_WINDOW_SOURCE_BASE_EXT_EXTERNAL 1 -#define DE_WINDOW_SOURCE_BASE_CS 26 : 26 -#define DE_WINDOW_SOURCE_BASE_CS_0 0 -#define DE_WINDOW_SOURCE_BASE_CS_1 1 -#define DE_WINDOW_SOURCE_BASE_ADDRESS 25 : 0 - -#define DE_WINDOW_DESTINATION_BASE 0x000044 -#define DE_WINDOW_DESTINATION_BASE_EXT 27 : 27 -#define DE_WINDOW_DESTINATION_BASE_EXT_LOCAL 0 -#define DE_WINDOW_DESTINATION_BASE_EXT_EXTERNAL 1 -#define DE_WINDOW_DESTINATION_BASE_CS 26 : 26 -#define DE_WINDOW_DESTINATION_BASE_CS_0 0 -#define DE_WINDOW_DESTINATION_BASE_CS_1 1 -#define DE_WINDOW_DESTINATION_BASE_ADDRESS 25 : 0 - -#define DE_ALPHA 0x000048 -#define DE_ALPHA_VALUE 7 : 0 - -#define DE_WRAP 0x00004C -#define DE_WRAP_X 31 : 16 -#define DE_WRAP_Y 15 : 0 - -#define DE_STATUS 0x000050 -#define DE_STATUS_CSC 1 : 1 -#define DE_STATUS_CSC_CLEAR 0 -#define DE_STATUS_CSC_NOT_ACTIVE 0 -#define DE_STATUS_CSC_ACTIVE 1 -#define DE_STATUS_2D 0 : 0 -#define DE_STATUS_2D_CLEAR 0 -#define DE_STATUS_2D_NOT_ACTIVE 0 -#define DE_STATUS_2D_ACTIVE 1 - -/* Color Space Conversion registers. */ - -#define CSC_Y_SOURCE_BASE 0x0000C8 -#define CSC_Y_SOURCE_BASE_EXT 27 : 27 -#define CSC_Y_SOURCE_BASE_EXT_LOCAL 0 -#define CSC_Y_SOURCE_BASE_EXT_EXTERNAL 1 -#define CSC_Y_SOURCE_BASE_CS 26 : 26 -#define CSC_Y_SOURCE_BASE_CS_0 0 -#define CSC_Y_SOURCE_BASE_CS_1 1 -#define CSC_Y_SOURCE_BASE_ADDRESS 25 : 0 - -#define CSC_CONSTANTS 0x0000CC -#define CSC_CONSTANTS_Y 31 : 24 -#define CSC_CONSTANTS_R 23 : 16 -#define CSC_CONSTANTS_G 15 : 8 -#define CSC_CONSTANTS_B 7 : 0 - -#define CSC_Y_SOURCE_X 0x0000D0 -#define CSC_Y_SOURCE_X_INTEGER 26 : 16 -#define CSC_Y_SOURCE_X_FRACTION 15 : 3 - -#define CSC_Y_SOURCE_Y 0x0000D4 -#define CSC_Y_SOURCE_Y_INTEGER 27 : 16 -#define CSC_Y_SOURCE_Y_FRACTION 15 : 3 - -#define CSC_U_SOURCE_BASE 0x0000D8 -#define CSC_U_SOURCE_BASE_EXT 27 : 27 -#define CSC_U_SOURCE_BASE_EXT_LOCAL 0 -#define CSC_U_SOURCE_BASE_EXT_EXTERNAL 1 -#define CSC_U_SOURCE_BASE_CS 26 : 26 -#define CSC_U_SOURCE_BASE_CS_0 0 -#define CSC_U_SOURCE_BASE_CS_1 1 -#define CSC_U_SOURCE_BASE_ADDRESS 25 : 0 - -#define CSC_V_SOURCE_BASE 0x0000DC -#define CSC_V_SOURCE_BASE_EXT 27 : 27 -#define CSC_V_SOURCE_BASE_EXT_LOCAL 0 -#define CSC_V_SOURCE_BASE_EXT_EXTERNAL 1 -#define CSC_V_SOURCE_BASE_CS 26 : 26 -#define CSC_V_SOURCE_BASE_CS_0 0 -#define CSC_V_SOURCE_BASE_CS_1 1 -#define CSC_V_SOURCE_BASE_ADDRESS 25 : 0 - -#define CSC_SOURCE_DIMENSION 0x0000E0 -#define CSC_SOURCE_DIMENSION_X 31 : 16 -#define CSC_SOURCE_DIMENSION_Y 15 : 0 - -#define CSC_SOURCE_PITCH 0x0000E4 -#define CSC_SOURCE_PITCH_Y 31 : 16 -#define CSC_SOURCE_PITCH_UV 15 : 0 - -#define CSC_DESTINATION 0x0000E8 -#define CSC_DESTINATION_WRAP 31 : 31 -#define CSC_DESTINATION_WRAP_DISABLE 0 -#define CSC_DESTINATION_WRAP_ENABLE 1 -#define CSC_DESTINATION_X 27 : 16 -#define CSC_DESTINATION_Y 11 : 0 - -#define CSC_DESTINATION_DIMENSION 0x0000EC -#define CSC_DESTINATION_DIMENSION_X 31 : 16 -#define CSC_DESTINATION_DIMENSION_Y 15 : 0 - -#define CSC_DESTINATION_PITCH 0x0000F0 -#define CSC_DESTINATION_PITCH_X 31 : 16 -#define CSC_DESTINATION_PITCH_Y 15 : 0 - -#define CSC_SCALE_FACTOR 0x0000F4 -#define CSC_SCALE_FACTOR_HORIZONTAL 31 : 16 -#define CSC_SCALE_FACTOR_VERTICAL 15 : 0 - -#define CSC_DESTINATION_BASE 0x0000F8 -#define CSC_DESTINATION_BASE_EXT 27 : 27 -#define CSC_DESTINATION_BASE_EXT_LOCAL 0 -#define CSC_DESTINATION_BASE_EXT_EXTERNAL 1 -#define CSC_DESTINATION_BASE_CS 26 : 26 -#define CSC_DESTINATION_BASE_CS_0 0 -#define CSC_DESTINATION_BASE_CS_1 1 -#define CSC_DESTINATION_BASE_ADDRESS 25 : 0 - -#define CSC_CONTROL 0x0000FC -#define CSC_CONTROL_STATUS 31 : 31 -#define CSC_CONTROL_STATUS_STOP 0 -#define CSC_CONTROL_STATUS_START 1 -#define CSC_CONTROL_SOURCE_FORMAT 30 : 28 -#define CSC_CONTROL_SOURCE_FORMAT_YUV422 0 -#define CSC_CONTROL_SOURCE_FORMAT_YUV420I 1 -#define CSC_CONTROL_SOURCE_FORMAT_YUV420 2 -#define CSC_CONTROL_SOURCE_FORMAT_YVU9 3 -#define CSC_CONTROL_SOURCE_FORMAT_IYU1 4 -#define CSC_CONTROL_SOURCE_FORMAT_IYU2 5 -#define CSC_CONTROL_SOURCE_FORMAT_RGB565 6 -#define CSC_CONTROL_SOURCE_FORMAT_RGB8888 7 -#define CSC_CONTROL_DESTINATION_FORMAT 27 : 26 -#define CSC_CONTROL_DESTINATION_FORMAT_RGB565 0 -#define CSC_CONTROL_DESTINATION_FORMAT_RGB8888 1 -#define CSC_CONTROL_HORIZONTAL_FILTER 25 : 25 -#define CSC_CONTROL_HORIZONTAL_FILTER_DISABLE 0 -#define CSC_CONTROL_HORIZONTAL_FILTER_ENABLE 1 -#define CSC_CONTROL_VERTICAL_FILTER 24 : 24 -#define CSC_CONTROL_VERTICAL_FILTER_DISABLE 0 -#define CSC_CONTROL_VERTICAL_FILTER_ENABLE 1 -#define CSC_CONTROL_BYTE_ORDER 23 : 23 -#define CSC_CONTROL_BYTE_ORDER_YUYV 0 -#define CSC_CONTROL_BYTE_ORDER_UYVY 1 - -#define DE_DATA_PORT_501 0x110000 -#define DE_DATA_PORT_712 0x400000 -#define DE_DATA_PORT_722 0x6000 - -/* point to virtual Memory Map IO starting address */ -extern char *smtc_RegBaseAddress; -/* point to virtual video memory starting address */ -extern char *smtc_VRAMBaseAddress; -extern unsigned char smtc_de_busy; - -extern unsigned long memRead32(unsigned long nOffset); -extern void memWrite32(unsigned long nOffset, unsigned long nData); -extern unsigned long SMTC_read2Dreg(unsigned long nOffset); - -/* 2D functions */ -extern void deInit(unsigned int nModeWidth, unsigned int nModeHeight, - unsigned int bpp); - -extern void deWaitForNotBusy(void); - -extern void deVerticalLine(unsigned long dst_base, - unsigned long dst_pitch, - unsigned long nX, - unsigned long nY, - unsigned long dst_height, - unsigned long nColor); - -extern void deHorizontalLine(unsigned long dst_base, - unsigned long dst_pitch, - unsigned long nX, - unsigned long nY, - unsigned long dst_width, - unsigned long nColor); - -extern void deLine(unsigned long dst_base, - unsigned long dst_pitch, - unsigned long nX1, - unsigned long nY1, - unsigned long nX2, - unsigned long nY2, - unsigned long nColor); - -extern void deFillRect(unsigned long dst_base, - unsigned long dst_pitch, - unsigned long dst_X, - unsigned long dst_Y, - unsigned long dst_width, - unsigned long dst_height, - unsigned long nColor); - -extern void deRotatePattern(unsigned char *pattern_dstaddr, - unsigned long pattern_src_addr, - unsigned long pattern_BPP, - unsigned long pattern_stride, - int patternX, - int patternY); - -extern void deCopy(unsigned long dst_base, - unsigned long dst_pitch, - unsigned long dst_BPP, - unsigned long dst_X, - unsigned long dst_Y, - unsigned long dst_width, - unsigned long dst_height, - unsigned long src_base, - unsigned long src_pitch, - unsigned long src_X, - unsigned long src_Y, - pTransparent pTransp, - unsigned char nROP2); - -/* - * System memory to Video memory monochrome expansion. - * - * Source is monochrome image in system memory. This function expands the - * monochrome data to color image in video memory. - * - * @pSrcbuf: pointer to start of source buffer in system memory - * @srcDelta: Pitch value (in bytes) of the source buffer, +ive means top - * down and -ive mean button up - * @startBit: Mono data can start at any bit in a byte, this value should - * be 0 to 7 - * @dBase: Address of destination : offset in frame buffer - * @dPitch: Pitch value of destination surface in BYTE - * @bpp: Color depth of destination surface - * @dx, dy: Starting coordinate of destination surface - * @width, height: width and height of rectange in pixel value - * @fColor,bColor: Foreground, Background color (corresponding to a 1, 0 in - * the monochrome data) - * @rop2: ROP value - */ - -extern long deSystemMem2VideoMemMonoBlt( - const char *pSrcbuf, - long srcDelta, - unsigned long startBit, - unsigned long dBase, - unsigned long dPitch, - unsigned long bpp, - unsigned long dx, unsigned long dy, - unsigned long width, unsigned long height, - unsigned long fColor, - unsigned long bColor, - unsigned long rop2); - -extern unsigned long deGetTransparency(void); -extern void deSetPixelFormat(unsigned long bpp); diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c index 080b51a6e553..863df038f0d6 100644 --- a/drivers/staging/sm7xx/smtcfb.c +++ b/drivers/staging/sm7xx/smtcfb.c @@ -45,7 +45,6 @@ struct screen_info smtc_screen_info; #include "smtcfb.h" -#include "smtc2d.h" #ifdef DEBUG #define smdbg(format, arg...) printk(KERN_DEBUG format , ## arg) @@ -120,10 +119,6 @@ static struct vesa_mode_table vesa_mode[] = { char __iomem *smtc_RegBaseAddress; /* Memory Map IO starting address */ char __iomem *smtc_VRAMBaseAddress; /* video memory starting address */ -char *smtc_2DBaseAddress; /* 2D engine starting address */ -char *smtc_2Ddataport; /* 2D data port offset */ -short smtc_2Dacceleration; - static u32 colreg[17]; static struct par_info hw; /* hardware information */ @@ -135,16 +130,6 @@ u16 smtc_ChipIDs[] = { #define numSMTCchipIDs (sizeof(smtc_ChipIDs) / sizeof(u16)) -void deWaitForNotBusy(void) -{ - unsigned long i = 0x1000000; - while (i--) { - if ((smtc_seqr(0x16) & 0x18) == 0x10) - break; - } - smtc_de_busy = 0; -} - static void sm712_set_timing(struct smtcfb_info *sfb, struct par_info *ppar_info) { @@ -324,7 +309,7 @@ static inline unsigned int chan_to_field(unsigned int chan, return chan << bf->offset; } -static int smtcfb_blank(int blank_mode, struct fb_info *info) +static int cfb_blank(int blank_mode, struct fb_info *info) { /* clear DPMS setting */ switch (blank_mode) { @@ -622,93 +607,13 @@ smtcfb_write(struct fb_info *info, const char __user *buf, size_t count, } #endif /* ! __BIG_ENDIAN */ -#include "smtc2d.c" - -void smtcfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) -{ - struct par_info *p = (struct par_info *)info->par; - - if (smtc_2Dacceleration) { - if (!area->width || !area->height) - return; - - deCopy(p->BaseAddressInVRAM, 0, info->var.bits_per_pixel, - area->dx, area->dy, area->width, area->height, - p->BaseAddressInVRAM, 0, area->sx, area->sy, 0, 0xC); - - } else - cfb_copyarea(info, area); -} - -void smtcfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) -{ - struct par_info *p = (struct par_info *)info->par; - - if (smtc_2Dacceleration) { - if (!rect->width || !rect->height) - return; - if (info->var.bits_per_pixel >= 24) - deFillRect(p->BaseAddressInVRAM, 0, rect->dx * 3, - rect->dy * 3, rect->width * 3, rect->height, - rect->color); - else - deFillRect(p->BaseAddressInVRAM, 0, rect->dx, rect->dy, - rect->width, rect->height, rect->color); - } else - cfb_fillrect(info, rect); -} - -void smtcfb_imageblit(struct fb_info *info, const struct fb_image *image) -{ - struct par_info *p = (struct par_info *)info->par; - u32 bg_col = 0, fg_col = 0; - - if ((smtc_2Dacceleration) && (image->depth == 1)) { - if (smtc_de_busy) - deWaitForNotBusy(); - - switch (info->var.bits_per_pixel) { - case 8: - bg_col = image->bg_color; - fg_col = image->fg_color; - break; - case 16: - bg_col = - ((u32 *) (info->pseudo_palette))[image->bg_color]; - fg_col = - ((u32 *) (info->pseudo_palette))[image->fg_color]; - break; - case 32: - bg_col = - ((u32 *) (info->pseudo_palette))[image->bg_color]; - fg_col = - ((u32 *) (info->pseudo_palette))[image->fg_color]; - break; - } - - deSystemMem2VideoMemMonoBlt( - image->data, - image->width / 8, - 0, - p->BaseAddressInVRAM, - 0, - 0, - image->dx, image->dy, - image->width, image->height, - fg_col, bg_col, - 0x0C); - - } else - cfb_imageblit(info, image); -} - static struct fb_ops smtcfb_ops = { .owner = THIS_MODULE, .fb_setcolreg = smtc_setcolreg, - .fb_blank = smtcfb_blank, - .fb_fillrect = smtcfb_fillrect, - .fb_imageblit = smtcfb_imageblit, - .fb_copyarea = smtcfb_copyarea, + .fb_blank = cfb_blank, + .fb_fillrect = cfb_fillrect, + .fb_imageblit = cfb_imageblit, + .fb_copyarea = cfb_copyarea, #ifdef __BIG_ENDIAN .fb_read = smtcfb_read, .fb_write = smtcfb_write, @@ -772,12 +677,6 @@ void smtcfb_setmode(struct smtcfb_info *sfb) hw.height = sfb->fb.var.yres; hw.hz = 60; smtc_set_timing(sfb, &hw); - if (smtc_2Dacceleration) { - printk("2D acceleration enabled!\n"); - /* Init smtc drawing engine */ - deInit(sfb->fb.var.xres, sfb->fb.var.yres, - sfb->fb.var.bits_per_pixel); - } } /* @@ -1004,9 +903,7 @@ static int __init smtcfb_pci_probe(struct pci_dev *pdev, #endif hw.m_pMMIO = (smtc_RegBaseAddress = smtc_VRAMBaseAddress + 0x00700000); - smtc_2DBaseAddress = (hw.m_pDPR = - smtc_VRAMBaseAddress + 0x00408000); - smtc_2Ddataport = smtc_VRAMBaseAddress + DE_DATA_PORT_712; + hw.m_pDPR = smtc_VRAMBaseAddress + 0x00408000; hw.m_pVPR = hw.m_pLFB + 0x0040c000; #ifdef __BIG_ENDIAN if (sfb->fb.var.bits_per_pixel == 32) { @@ -1034,28 +931,22 @@ static int __init smtcfb_pci_probe(struct pci_dev *pdev, #ifdef __BIG_ENDIAN if (sfb->fb.var.bits_per_pixel == 32) smtc_seqw(0x17, 0x30); -#endif -#ifdef CONFIG_FB_SM7XX_ACCEL - smtc_2Dacceleration = 1; #endif break; case 0x720: sfb->fb.fix.mmio_start = pFramebufferPhysical; sfb->fb.fix.mmio_len = 0x00200000; smem_size = SM722_VIDEOMEMORYSIZE; - smtc_2DBaseAddress = (hw.m_pDPR = - ioremap(pFramebufferPhysical, 0x00a00000)); + hw.m_pDPR = ioremap(pFramebufferPhysical, 0x00a00000); hw.m_pLFB = (smtc_VRAMBaseAddress = - smtc_2DBaseAddress + 0x00200000); + hw.m_pDPR + 0x00200000); hw.m_pMMIO = (smtc_RegBaseAddress = - smtc_2DBaseAddress + 0x000c0000); - smtc_2Ddataport = smtc_2DBaseAddress + DE_DATA_PORT_722; - hw.m_pVPR = smtc_2DBaseAddress + 0x800; + hw.m_pDPR + 0x000c0000); + hw.m_pVPR = hw.m_pDPR + 0x800; smtc_seqw(0x62, 0xff); smtc_seqw(0x6a, 0x0d); smtc_seqw(0x6b, 0x02); - smtc_2Dacceleration = 0; break; default: printk(KERN_INFO