12 #include <linux/kernel.h>
13 #include <linux/errno.h>
14 #include <linux/types.h>
21 #define STG4000_NO_SCALING 0x800
22 #define STG4000_NO_DECIMATION 0xFFFFFFFF
25 #define STG4000_PRIM_NUM_PIX 5
26 #define STG4000_PRIM_ALIGN 4
27 #define STG4000_PRIM_ADDR_BITS 20
29 #define STG4000_PRIM_MIN_WIDTH 640
30 #define STG4000_PRIM_MAX_WIDTH 1600
31 #define STG4000_PRIM_MIN_HEIGHT 480
32 #define STG4000_PRIM_MAX_HEIGHT 1200
35 #define STG4000_OVRL_NUM_PIX 4
36 #define STG4000_OVRL_ALIGN 2
37 #define STG4000_OVRL_ADDR_BITS 20
38 #define STG4000_OVRL_NUM_MODES 5
40 #define STG4000_OVRL_MIN_WIDTH 0
41 #define STG4000_OVRL_MAX_WIDTH 720
42 #define STG4000_OVRL_MIN_HEIGHT 0
43 #define STG4000_OVRL_MAX_HEIGHT 576
46 static u32 adwDecim8[33] = {
47 0xffffffff, 0xfffeffff, 0xffdffbff, 0xfefefeff, 0xfdf7efbf,
48 0xfbdf7bdf, 0xf7bbddef, 0xeeeeeeef, 0xeeddbb77, 0xedb76db7,
49 0xdb6db6db, 0xdb5b5b5b, 0xdab5ad6b, 0xd5ab55ab, 0xd555aaab,
50 0xaaaaaaab, 0xaaaa5555, 0xaa952a55, 0xa94a5295, 0xa5252525,
51 0xa4924925, 0x92491249, 0x91224489, 0x91111111, 0x90884211,
52 0x88410821, 0x88102041, 0x81010101, 0x80800801, 0x80010001,
53 0x80000001, 0x00000001, 0x00000000
76 static u32 ovlWidth, ovlHeight, ovlStride;
145 u32 * retStride,
u32 * retUVStride)
158 if ((inWidth & 0x7) == 0) {
159 ulStride = (inWidth / 8);
162 ulStride = ((inWidth + 8) / 8);
166 if ((inWidth & 0xf) == 0) {
167 ulStride = (inWidth / 16);
170 ulStride = ((inWidth + 16) / 16);
185 tmp |= (ulOverlayOffset >> 4);
190 (inWidth & 0x1) ? (inWidth + 1 / 2) : (inWidth / 2);
194 if ((uvSize & 0xf) == 0) {
195 uvStride = (uvSize / 16);
198 uvStride = ((uvSize + 16) / 16);
201 ulOffset = ulOverlayOffset + (inHeight * (ulStride * 16));
203 if ((ulOffset & 0x1f) != 0)
204 ulOffset = (ulOffset + 32
L) & 0xffffffE0L;
208 tmp |= (ulOffset >> 4);
211 ulOffset += (inHeight / 2) * (uvStride * 16);
213 if ((ulOffset & 0x1f) != 0)
214 ulOffset = (ulOffset + 32
L) & 0xffffffE0
L;
218 tmp |= (ulOffset >> 4);
221 *retUVStride = uvStride * 16;
234 ovlHeight = inHeight;
235 ovlStride = ulStride;
237 *retStride = ulStride << 4;
244 u32 ulAlpha,
u32 ulColorKey)
255 tmp |= (ulColorKey & 0x00FFFFFF);
260 tmp |= ((ulAlpha & 0xF) << 24);
265 tmp |= (ulColorKey & 0x00FFFFFF);
270 tmp |= (ulColorKey & 0x00FFFFFF);
272 tmp |= ((ulAlpha & 0xF) << 24);
302 static u32 Overlap(
u32 ulBits,
u32 ulPattern)
307 if (!(ulPattern & 1))
310 ulPattern = ulPattern >> 1;
323 u32 ulSrcTop, ulSrcBottom;
325 u32 ulFxScale, ulFxOffset;
326 u32 ulHeight, ulWidth;
328 u32 ulDecimate, ulDecimated;
330 u32 ulDacXScale, ulDacYScale;
333 u32 ulSrcLeft, ulSrcRight;
334 u32 ulScaleLeft, ulScaleRight;
343 u32 ulExcessPixels, ulClip, ulExtraLines;
348 srcDest.
ulSrcX2 = ovlWidth - 1;
349 srcDest.
ulSrcY2 = ovlHeight - 1;
367 ulSrc = ulSrcBottom - ulSrcTop;
376 ulFxScale = (ulDest << 11) / ulSrc;
379 ulSrcBottom = ulSrcBottom - (ulFxOffset / ulFxScale);
380 ulSrc = ulSrcBottom - ulSrcTop;
384 ulPattern = adwDecim8[ulBits];
387 if (ulSrc > ulDest) {
388 ulDecimate = ulSrc - ulDest;
390 ulApplied = ulSrc / 32;
392 while (((ulBits * ulApplied) +
393 Overlap((ulSrc % 32),
394 adwDecim8[ulBits])) < ulDecimate)
397 ulPattern = adwDecim8[ulBits];
399 (ulBits * ulApplied) + Overlap((ulSrc % 32),
401 ulSrc = ulSrc - ulDecimated;
404 if (ulBits && (ulBits != 32)) {
405 ulVertDecFactor = (63 - ulBits) / (32 - ulBits);
410 ulDacYScale = ((ulSrc - 1) * 2048) / (ulDest + 1);
453 ulFxScale = ((ulSrc - 1) << 11) / (ulDest);
456 ulFxOffset = ulFxScale * ((srcDest.
ulDstX1 - srcDest.
lDstX1) + ulClipOff);
460 ulSrcLeft = srcDest.
ulSrcX1 + ulFxOffset;
466 ulSrcRight = srcDest.
ulSrcX2 - ulFxOffset;
472 ulScaleLeft = ulSrcLeft;
473 ulScaleRight = ulSrcRight;
477 ulScale = (((ulSrcRight - ulSrcLeft) - 1) << (11 - ulhDecim)) / (ulRight - ulLeft + 2);
479 while (ulScale > 0x800) {
481 ulScale = (((ulSrcRight - ulSrcLeft) - 1) << (11 - ulhDecim)) / (ulRight - ulLeft + 2);
499 ulSrcRight = (ulSrcRight + 0x1f) & ~0x1f;
507 ulSrcRight = (ulSrcRight + 0x7) & ~0x7;
511 ulWidth = ulSrcRight - ulSrcLeft;
518 ulsVal = ((ulWidth / 8) >> ulhDecim);
520 if ((ulWidth != (ulsVal << ulhDecim) * 8))
524 ulSrc = ulWidth >> ulhDecim;
529 ulExcessPixels = ((((ulScaleLeft - ulSrcLeft)) << (11 - ulhDecim)) / ulScale);
531 ulClip = (ulSrc << 11) / ulScale;
532 ulClip -= (ulRight - ulLeft);
533 ulClip += ulExcessPixels;
541 ulExtraLines = (1 << ulhDecim) * ulVertDecFactor;
543 ulHeight += ulExtraLines;
545 ulDacXScale = ulScale;
556 ulStride = (ulWidth >> (ulhDecim + 3)) + ulsAdd;
557 tmp |= ((ulStride << 16) | (ulDacYScale));
569 (ovlStride | ((ulHeight + 1) << 12) |
570 (((ulWidth / 8) - 1) << 23));
573 (ovlStride | ((ulHeight + 1) << 12) |
574 (((ulWidth / 32) - 1) << 23));
580 tmp = ((ulLeft << 16)) | (srcDest.
ulDstY1);
584 tmp = ((ulRight) << 16) | (srcDest.
ulDstY2);
591 tmp = ((ulExcessPixels << 16) | tmp) & 0x7fffffff;
597 tmp |= ((ulhDecim << 16) | (ulDacXScale));