summaryrefslogtreecommitdiff
path: root/driver/xf86-video-savage/src/savage_video.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2008-10-12 21:24:22 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2008-10-12 21:24:22 +0000
commita50c49806e148b3083bf3fef0e1dc612316d9d3f (patch)
tree58e212dabe1f85ebe210806545e54620e49e84c9 /driver/xf86-video-savage/src/savage_video.c
parent0b4a9e42bb28f867a14d90d21774ca6bd950ae22 (diff)
xf86-video-savage 2.2.1
Diffstat (limited to 'driver/xf86-video-savage/src/savage_video.c')
-rw-r--r--driver/xf86-video-savage/src/savage_video.c87
1 files changed, 35 insertions, 52 deletions
diff --git a/driver/xf86-video-savage/src/savage_video.c b/driver/xf86-video-savage/src/savage_video.c
index ed45b0f42..a68c19103 100644
--- a/driver/xf86-video-savage/src/savage_video.c
+++ b/driver/xf86-video-savage/src/savage_video.c
@@ -1177,7 +1177,7 @@ SavageCopyPlanarDataBCI(
SavagePtr psav = SAVPTR(pScrn);
/* half of the dest buffer for copying the YVU data to it ??? */
unsigned char *dstCopy = (unsigned char *)(((unsigned long)dst
- + 2 * srcPitch * h
+ + dstPitch * h
+ 0x0f) & ~0x0f);
/* for pixel transfer */
unsigned long offsetY = (unsigned long)dstCopy - (unsigned long)psav->FBBase;
@@ -1189,21 +1189,15 @@ SavageCopyPlanarDataBCI(
BCI_GET_PTR;
/* copy Y planar */
- for (i=0;i<srcPitch * h;i++) {
- dstCopy[i] = srcY[i];
- }
+ memcpy(dstCopy, srcY, srcPitch * h);
/* copy V planar */
dstCopy = dstCopy + srcPitch * h;
- for (i=0;i<srcPitch2 * (h>>1);i++) {
- dstCopy[i] = srcV[i];
- }
+ memcpy(dstCopy, srcV, srcPitch2 * (h>>1));
/* copy U planar */
dstCopy = dstCopy + srcPitch2 * (h>>1);
- for (i=0;i<srcPitch2 * (h>>1);i++) {
- dstCopy[i] = srcU[i];
- }
+ memcpy(dstCopy, srcU, srcPitch2 * (h>>1));
/*
* Transfer pixel data from one memory location to another location
@@ -1253,6 +1247,9 @@ SavageCopyData(
int w
){
w <<= 1;
+ if (w == srcPitch && w == dstPitch) {
+ memcpy(dst, src, w * h);
+ } else
while(h--) {
memcpy(dst, src, w);
src += srcPitch;
@@ -1378,39 +1375,7 @@ SavageAllocateMemory(
}
offset = linear->offset * cpp;
}
-#if 0
- if(area) {
- if((area->box.y2 - area->box.y1) >= numlines)
- return area;
-
- if(xf86ResizeOffscreenArea(area, pScrn->displayWidth, numlines))
- return area;
-
- xf86FreeOffscreenArea(area);
- }
-
- pScreen = screenInfo.screens[pScrn->scrnIndex];
-
- xf86PurgeUnlockedOffscreenAreas(pScreen);
- new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth,
- numlines, 0, NULL, NULL, NULL);
-
- if(!new_area) {
- int max_w, max_h;
-
- xf86QueryLargestOffscreenArea(pScreen, &max_w, &max_h, 0,
- FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME);
-
- if((max_w < pScrn->displayWidth) || (max_h < numlines))
- return NULL;
-
- xf86PurgeUnlockedOffscreenAreas(pScreen);
- new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth,
- numlines, 0, NULL, NULL, NULL);
- }
- return new_area;
-#endif
return offset;
}
@@ -1501,11 +1466,12 @@ SavageDisplayVideoOld(
if( psav->videoFourCC != id )
SavageStreamsOff(pScrn);
- if( !psav->videoFlags & VF_STREAMS_ON )
+ if( !(psav->videoFlags & VF_STREAMS_ON) )
{
SavageSetBlend(pScrn,id);
SavageStreamsOn(pScrn);
SavageResetVideo(pScrn);
+ pPriv->lastKnownPitch = 0;
}
if (S3_MOBILE_TWISTER_SERIES(psav->Chipset)
@@ -1523,31 +1489,42 @@ SavageDisplayVideoOld(
* Process horizontal scaling
* upscaling and downscaling smaller than 2:1 controled by MM8198
* MM8190 controls downscaling mode larger than 2:1
+ * Together MM8190 and MM8198 can set arbitrary downscale up to 64:1
*/
scalratio = 0;
ssControl = 0;
if (src_w >= (drw_w * 2)) {
if (src_w < (drw_w * 4)) {
- scalratio = HSCALING(2,1);
- } else if (src_w < (drw_w * 8)) {
ssControl |= HDSCALE_4;
- } else if (src_w < (drw_w * 16)) {
+ scalratio = HSCALING(src_w,(drw_w*4));
+ } else if (src_w < (drw_w * 8)) {
ssControl |= HDSCALE_8;
- } else if (src_w < (drw_w * 32)) {
+ scalratio = HSCALING(src_w,(drw_w*8));
+ } else if (src_w < (drw_w * 16)) {
ssControl |= HDSCALE_16;
- } else if (src_w < (drw_w * 64)) {
+ scalratio = HSCALING(src_w,(drw_w*16));
+ } else if (src_w < (drw_w * 32)) {
ssControl |= HDSCALE_32;
- } else
+ scalratio = HSCALING(src_w,(drw_w*32));
+ } else if (src_w < (drw_w * 64)) {
+ ssControl |= HDSCALE_64;
+ scalratio = HSCALING(src_w,(drw_w*64));
+ } else {
+ /* Request beyond maximum downscale! */
ssControl |= HDSCALE_64;
+ scalratio = HSCALING(2,1);
+ }
} else
scalratio = HSCALING(src_w,drw_w);
ssControl |= src_w;
/*ssControl |= (1 << 24);*/
ssControl |= (GetBlendForFourCC(psav->videoFourCC) << 24);
+#if 0
/* Wait for VBLANK. */
VerticalRetraceWait();
+#endif
OUTREG(SSTREAM_CONTROL_REG, ssControl);
if (scalratio)
OUTREG(SSTREAM_STRETCH_REG,scalratio);
@@ -1644,11 +1621,12 @@ SavageDisplayVideoNew(
if( psav->videoFourCC != id )
SavageStreamsOff(pScrn);
- if( !psav->videoFlags & VF_STREAMS_ON )
+ if( !(psav->videoFlags & VF_STREAMS_ON) )
{
SavageSetBlend(pScrn,id);
SavageStreamsOn(pScrn);
SavageResetVideo(pScrn);
+ pPriv->lastKnownPitch = 0;
}
/* Calculate horizontal and vertical scale factors. */
@@ -1778,11 +1756,12 @@ SavageDisplayVideo2000(
if( psav->videoFourCC != id )
SavageStreamsOff(pScrn);
- if( !psav->videoFlags & VF_STREAMS_ON )
+ if( !(psav->videoFlags & VF_STREAMS_ON) )
{
SavageSetBlend(pScrn,id);
SavageStreamsOn(pScrn);
SavageResetVideo(pScrn);
+ pPriv->lastKnownPitch = 0;
}
if (src_w > drw_w)
@@ -1944,6 +1923,10 @@ SavagePutImage(
break;
}
+ if (srcPitch2 != 0 && S3_SAVAGE4_SERIES(psav->Chipset) && psav->BCIforXv) {
+ new_size = ((new_size + 0xF) & ~0xF) + srcPitch * height + srcPitch2 * height;
+ }
+
/* if(!(pPriv->area = SavageAllocateMemory(pScrn, pPriv->area, new_h)))
return BadAlloc;*/
pPriv->video_offset = SavageAllocateMemory(pScrn, &pPriv->video_memory,
@@ -1969,7 +1952,7 @@ SavagePutImage(
offsetU += tmp;
offsetV += tmp;
nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
- if (S3_SAVAGE4_SERIES(psav->Chipset) && psav->BCIforXv) {
+ if (S3_SAVAGE4_SERIES(psav->Chipset) && psav->BCIforXv && (npixels & 0xF) == 0) {
SavageCopyPlanarDataBCI(
pScrn,
buf + (top * srcPitch) + (left >> 1),