/* * linux/drivers/video/kyro/STG4000OverlayDevice.c * * Copyright (C) 2000 Imagination Technologies Ltd * Copyright (C) 2002 STMicroelectronics * * 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.
*/
/* Set Overlay format to default value */
tmp = STG_READ_REG(DACPixelFormat);
CLEAR_BITS_FRM_TO(4, 7);
CLEAR_BITS_FRM_TO(16, 22);
STG_WRITE_REG(DACPixelFormat, tmp);
/* Set Vertical scaling to default */
tmp = STG_READ_REG(DACVerticalScal);
CLEAR_BITS_FRM_TO(0, 11);
CLEAR_BITS_FRM_TO(16, 22);
tmp |= STG4000_NO_SCALING; /* Set to no scaling */
STG_WRITE_REG(DACVerticalScal, tmp);
/* Set Horizontal Scaling to default */
tmp = STG_READ_REG(DACHorizontalScal);
CLEAR_BITS_FRM_TO(0, 11);
CLEAR_BITS_FRM_TO(16, 17);
tmp |= STG4000_NO_SCALING; /* Set to no scaling */
STG_WRITE_REG(DACHorizontalScal, tmp);
/* Set Blend mode to Alpha Blend */ /* ????? SG 08/11/2001 Surely this isn't the alpha blend mode, hopefully its overwrite
*/
tmp = STG_READ_REG(DACBlendCtrl);
CLEAR_BITS_FRM_TO(0, 30);
tmp = (GRAPHICS_MODE << 28);
STG_WRITE_REG(DACBlendCtrl, tmp);
/* Stride in 16 byte words - 16Bpp */ if (bLinear) { /* Format is 16bits so num 16 byte words is width/8 */ if ((inWidth & 0x7) == 0) { /* inWidth % 8 */
ulStride = (inWidth / 8);
} else { /* Round up to next 16byte boundary */
ulStride = ((inWidth + 8) / 8);
}
} else { /* Y component is 8bits so num 16 byte words is width/16 */ if ((inWidth & 0xf) == 0) { /* inWidth % 16 */
ulStride = (inWidth / 16);
} else { /* Round up to next 16byte boundary */
ulStride = ((inWidth + 16) / 16);
}
}
/* Set Overlay address and Format mode */
tmp = STG_READ_REG(DACOverlayAddr);
CLEAR_BITS_FRM_TO(0, 20); if (bLinear) {
CLEAR_BIT(31); /* Overlay format to Linear */
} else {
tmp |= SET_BIT(31); /* Overlay format to Planer */
}
/* Only bits 24:4 of the Overlay address */
tmp |= (ulOverlayOffset >> 4);
STG_WRITE_REG(DACOverlayAddr, tmp);
if (!bLinear) {
u32 uvSize =
(inWidth & 0x1) ? (inWidth + 1 / 2) : (inWidth / 2);
u32 uvStride;
u32 ulOffset; /* Y component is 8bits so num 32 byte words is width/32 */ if ((uvSize & 0xf) == 0) { /* inWidth % 16 */
uvStride = (uvSize / 16);
} else { /* Round up to next 32byte boundary */
uvStride = ((uvSize + 16) / 16);
}
ulOffset = ulOverlayOffset + (inHeight * (ulStride * 16)); /* Align U,V data to 32byte boundary */ if ((ulOffset & 0x1f) != 0)
ulOffset = (ulOffset + 32L) & 0xffffffE0L;
/* Set Overlay YUV pixel format * Make sure that LUT not used - ??????
*/
tmp = STG_READ_REG(DACPixelFormat); /* Only support Planer or UYVY linear formats */
CLEAR_BITS_FRM_TO(4, 9);
STG_WRITE_REG(DACPixelFormat, tmp);
/* First work out the position we are to display as offset from the * source of the buffer
*/
ulFxScale = (ulDest << 11) / ulSrc; /* fixed point scale factor */
ulFxOffset = (srcDest.lDstY2 - srcDest.ulDstY2) << 11;
ulPattern = adwDecim8[ulBits];
ulDecimated =
(ulBits * ulApplied) + Overlap((ulSrc % 32),
ulPattern);
ulSrc = ulSrc - ulDecimated; /* the number number of lines that will go into the scaler */
}
/* * Now we handle the horizontal case, this is a simplified version of * the vertical case in that we decimate by factors of 2. as we are * working in words we should always be able to decimate by these * factors. as we always have to have a buffer which is aligned to a * whole number of 128 bit words, we must align the left side to the * lowest to the next lowest 128 bit boundary, and the right hand edge * to the next largets boundary, (in a similar way to how we didi it in * PMX1) as the left and right hand edges are aligned to these * boundaries normally this only becomes an issue when we are chopping * of one of the sides We shall work out vertical stuff first
*/
ulSrc = srcDest.ulSrcX2 - srcDest.ulSrcX1;
ulDest = srcDest.lDstX2 - srcDest.lDstX1; #ifdef _OLDCODE
ulLeft = srcDest.ulDstX1;
ulRight = srcDest.ulDstX2; #else if (srcDest.ulDstX1 > 2) {
ulLeft = srcDest.ulDstX1 + 2;
ulRight = srcDest.ulDstX2 + 1;
} else {
ulLeft = srcDest.ulDstX1;
ulRight = srcDest.ulDstX2 + 1;
} #endif /* first work out the position we are to display as offset from the source of the buffer */
bResult = 1;
do { if (ulDest == 0) return -EINVAL;
/* source pixels per dest pixel <<11 */
ulFxScale = ((ulSrc - 1) << 11) / (ulDest);
/* then number of destination pixels out we are */
ulFxOffset = ulFxScale * ((srcDest.ulDstX1 - srcDest.lDstX1) + ulClipOff);
ulFxOffset >>= 11;
/* this replaces the code which was making a decision as to use either ulFxOffset or ulSrcX1 */
ulSrcLeft = srcDest.ulSrcX1 + ulFxOffset;
/* then number of destination pixels out we are */
ulFxOffset = ulFxScale * (srcDest.lDstX2 - srcDest.ulDstX2);
ulFxOffset >>= 11;
ulSrcRight = srcDest.ulSrcX2 - ulFxOffset;
/* * we must align these to our 128 bit boundaries. we shall * round down the pixel pos to the nearest 8 pixels.
*/
ulScaleLeft = ulSrcLeft;
/* shift fxscale until it is in the range of the scaler */
ulhDecim = 0;
ulScale = (((ulSrcRight - ulSrcLeft) - 1) << (11 - ulhDecim)) / (ulRight - ulLeft + 2);
/* * to try and get the best values We first try and use * src/dwdest for the scale factor, then we move onto src-1 * * we want to check to see if we will need to clip data, if so * then we should clip our source so that we don't need to
*/ if (!ovlLinear) {
ulSrcLeft &= ~0x1f;
/* * we must align the right hand edge to the next 32 * pixel` boundary, must be on a 256 boundary so u, and * v are 128 bit aligned
*/
ulSrcRight = (ulSrcRight + 0x1f) & ~0x1f;
} else {
ulSrcLeft &= ~0x7;
/* * we must align the right hand edge to the next * 8pixel` boundary
*/
ulSrcRight = (ulSrcRight + 0x7) & ~0x7;
}
/* this is the input size line store needs to cope with */
ulWidth = ulSrcRight - ulSrcLeft;
/* * use unclipped value to work out scale factror this is the * scale factor we want we shall now work out the horizonal * decimation and scaling
*/
ulsVal = ((ulWidth / 8) >> ulhDecim);
/* Calculate new output line stride, this is always the number of 422 words in the line buffer, so it doesn't matter if the mode is 420. Then set the vertical scale register.
*/
ulStride = (ulWidth >> (ulhDecim + 3)) + ulsAdd;
tmp |= ((ulStride << 16) | (ulDacYScale)); /* DAC_LS_CTRL = stride */
STG_WRITE_REG(DACVerticalScal, tmp);
/* Now set up the overlay size using the modified width and height from decimate and scaling calculations
*/
tmp = STG_READ_REG(DACOverlaySize);
CLEAR_BITS_FRM_TO(0, 10);
CLEAR_BITS_FRM_TO(12, 31);
/* Set Video Window Start */
tmp = ((ulLeft << 16)) | (srcDest.ulDstY1);
STG_WRITE_REG(DACVidWinStart, tmp);
/* Set Video Window End */
tmp = ((ulRight) << 16) | (srcDest.ulDstY2);
STG_WRITE_REG(DACVidWinEnd, tmp);
/* Finally set up the rest of the overlay regs in the order done in the IMG driver
*/
tmp = STG_READ_REG(DACPixelFormat);
tmp = ((ulExcessPixels << 16) | tmp) & 0x7fffffff;
STG_WRITE_REG(DACPixelFormat, tmp);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.