diff options
author | Luc Verhaegen <libv@skynet.be> | 2005-09-07 23:02:51 +0000 |
---|---|---|
committer | Luc Verhaegen <libv@skynet.be> | 2005-09-07 23:02:51 +0000 |
commit | d65ee9804958779f5beb0c0c07ddc8a336973198 (patch) | |
tree | 85d08906cb97d317a58609aa1696e3ae758e3e84 | |
parent | 0a915a18f9938d0d5028d1ff7ee8e9ef2c410b2d (diff) |
[devel-swov_enableflipfire]
- Move SwovInitControl to HQVInit, move setting Video3Control up.
- Clean up waiting for the HQV to get idle and V3 fire to be completed.
Move out to its own function.
- Properly wait for flipping to end at HQVFlip.
- Depend on Swov->Active for the Status wait.
- Move X_ERRORs to X_WARNINGs and stop throwing in the towel when something
fails to happen (HQVFlip mainly).
- Set up FIFO at the start of PutImage when !Swov->Active instead of at
VideoInit.
-rw-r--r-- | src/via_video.c | 134 |
1 files changed, 65 insertions, 69 deletions
diff --git a/src/via_video.c b/src/via_video.c index f60b3c6..bd26444 100644 --- a/src/via_video.c +++ b/src/via_video.c @@ -569,12 +569,10 @@ ViaSwovChromaKey(struct ViaSwov *Swov, CARD32 chromaLow, CARD32 chromaHigh) #endif /* UNUSED */ static void -ViaSwovInitControl(struct ViaSwov *Swov) +ViaHQVInit(struct ViaSwov *Swov) { struct ViaXvPort *Port = Swov->Port; - Swov->Video->Video3Control = V3_ENABLE | V3_COLORSPACE_SIGN; - Swov->HQV->Control = HQV_SRC_SW; /* not CLE266Ax could need |= HQV_ENABLE | HQV_SW_FLIP */ @@ -589,14 +587,38 @@ ViaSwovInitControl(struct ViaSwov *Swov) Swov->HQV->Control |= HQV_TRIPLE_BUFF | HQV_FLIP_STATUS; } - Swov->Video->Video3Control |= V3_YUV422 | V3_SWAP_HW_HQV; - /* For DCT450 test-BOB INTERLEAVE */ - if ((Swov->Port->Deinterlace & VIA_DEINT_BOB)) { + if ((Port->Deinterlace & VIA_DEINT_BOB)) { Swov->HQV->Control |= HQV_FIELD_2_FRAME | HQV_DEINTERLACE; - if ((Swov->Port->Deinterlace & VIA_DEINT_INTERLEAVE)) + if ((Port->Deinterlace & VIA_DEINT_INTERLEAVE)) Swov->HQV->Control |= HQV_FRAME_2_FIELD; } + + Swov->HQV->Control |= HQV_ENABLE; +} + +static void +ViaHQVSwovIdle(struct ViaSwov *Swov) +{ + int i; + + for (i = 0; i < 10; i++) + if (!(Swov->Video->Compose & V3_COMMAND_FIRE) && + (Swov->HQV->Control & HQV_IDLE)) + break; + else + usleep(1); + + if (i) { + ViaDebug(Swov->scrnIndex, "%s: idle/fire wait: %d.\n", __FUNCTION__, i); + if (!(Swov->HQV->Control & HQV_IDLE)) + xf86DrvMsg(Swov->scrnIndex, X_WARNING, "%s: HQV not idle.\n", + __FUNCTION__); + if ((Swov->Video->Compose & V3_COMMAND_FIRE)) + xf86DrvMsg(Swov->scrnIndex, X_WARNING, "%s: Video3 still firing.\n", + __FUNCTION__); + } + } /* @@ -827,26 +849,24 @@ ViaSwovStartAddress(struct ViaSwov *Swov, struct ViaXvPort *Port) } /* - * Maybe we want to split this up to reduce the startup delay. - * - HQV_ENABLE shortly after surface creation and before V3 config and copy. - * - HQV_SW_FLIP | HQV_FLIP_STATUS after V3 config and Copy. - * - V3_FIRE. * - * A further change would be would be (after HQV_ENABLE): - * - Zoom (minify is still HQV). - * - Copy and HQV_SW_FLIP | HQV_FLIP_STATUS - * - further V3 config. - * - wait STATUS (when needed). - * - V3_FIRE (when needed). */ -static Bool +static void ViaHQVFlip(struct ViaSwov *Swov, struct ViaXvPort *Port) { - /* if ((Swov->HQV->Control & | HQV_ENABLE)) { first perhaps? -- libv */ - if ((Swov->HQV->Control & HQV_SW_FLIP)) { - xf86DrvMsg(Swov->scrnIndex, X_ERROR, "%s: HQV is still not idle!\n", - __FUNCTION__); - return FALSE; + int i; + + for (i = 0; i < 15; i++) + if (!(Swov->HQV->Control & HQV_SW_FLIP)) + break; + else + usleep(1); + + if (i) { + ViaDebug(Swov->scrnIndex, "%s: flip wait: %d.\n", __FUNCTION__, i); + if ((Swov->HQV->Control & HQV_SW_FLIP)) + xf86DrvMsg(Swov->scrnIndex, X_WARNING, "%s: HQV is still flipping.\n", + __FUNCTION__); } if (Port->FrameNum & 1) { @@ -865,43 +885,22 @@ ViaHQVFlip(struct ViaSwov *Swov, struct ViaXvPort *Port) } } - if (!(Swov->HQV->Control & HQV_ENABLE)) { - int i; - - /* Wait until the HQV is fully idle first. */ /* when !HQV_ENABLE ? -- libv */ - for (i = 0; i < 50; i++) - if (Swov->HQV->Control & HQV_IDLE) - break; - - ViaDebug(Swov->scrnIndex, "%s: idle wait: %d.\n", __FUNCTION__, i); - if (i >= 50) { - xf86DrvMsg(Swov->scrnIndex, X_ERROR, "%s: Unable to initialise the" - " HQV. (not idle)\n", __FUNCTION__); - return FALSE; - } - - Swov->HQV->Control |= HQV_ENABLE; - usleep(1); - Swov->HQV->Control |= HQV_SW_FLIP | HQV_FLIP_STATUS; + Swov->HQV->Control |= HQV_SW_FLIP | HQV_FLIP_STATUS; + /* Before we fire V3 for the first time, wait. */ + if (!Swov->Active) { for (i = 0; i < 15; i++) - if (Swov->HQV->Control & HQV_FLIP_STATUS) + if ((Swov->HQV->Control & HQV_FLIP_STATUS)) break; else usleep(1); - - ViaDebug(Swov->scrnIndex, "%s: status wait: %d.\n", __FUNCTION__, i); - if (i >= 15) { - xf86DrvMsg(Swov->scrnIndex, X_ERROR, "%s: Unable to initialise" - " the HQV. (Status still not set)\n", __FUNCTION__); - return FALSE; + if (i) { + ViaDebug(Swov->scrnIndex, "%s: status wait: %d.\n", __FUNCTION__, i); + if (!(Swov->HQV->Control & HQV_FLIP_STATUS)) + xf86DrvMsg(Swov->scrnIndex, X_WARNING, "%s: Unable to initialise" + " the HQV. (Status still not set)\n", __FUNCTION__); } - } else { - Swov->HQV->Control &= ~HQV_FLIP_ODD; - Swov->HQV->Control |= HQV_SW_FLIP | HQV_FLIP_STATUS; } - - return TRUE; } /* @@ -913,6 +912,8 @@ ViaSwovStop(ScrnInfoPtr pScrn) struct ViaSwov *Swov = VIAPTR(pScrn)->Swov; vgaHWPtr hwp = VGAHWPTR(pScrn); + VIAFUNC(pScrn->scrnIndex); + if (Swov->HQVDisablePatch) ViaSeqMask(hwp, 0x2E, 0x00, 0x10); @@ -926,7 +927,7 @@ ViaSwovStop(ScrnInfoPtr pScrn) if (Swov->HQVDisablePatch) ViaSeqMask(hwp, 0x2E, 0x10, 0x10); - + Swov->Active = FALSE; } @@ -999,9 +1000,6 @@ ViaSwovInit(VIAPtr pVia) xf86DrvMsg(pVia->scrnIndex, X_ERROR, "%s: Unhandled ChipSet.\n", __FUNCTION__); } - - /* Set up the FIFO now, since we're not immediately touching this later */ - ViaSwovFIFO(pVia, Swov); } /* @@ -1578,13 +1576,10 @@ viaPutImage(ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x, /* get Frame position as we're not tracking that when !Swov->Active */ ViaVideoGetFrame(pScrn); Port->FrameNum = 0; - } else { - /* Before we do something, check if we are allowed to do anything */ - while ((Swov->Video->Compose & (V1_COMMAND_FIRE | V3_COMMAND_FIRE)) - || !(Swov->HQV->Control & HQV_IDLE)) - ; } + ViaHQVSwovIdle(Swov); + /* create HQV and Video3 surfaces when needed */ if (!Port->SwovSurface[0] || (Port->Width != width) || (Port->Height != height)) { if (Port->SwovSurface[0]) @@ -1601,9 +1596,11 @@ viaPutImage(ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x, } if (!Swov->Active) { + ViaHQVInit(Swov); + Video3Touched = TRUE; Swov->Video->Compose = V_COMMAND_LOAD_VBI | ALWAYS_SELECT_VIDEO; - ViaSwovInitControl(Swov); + Swov->Video->Video3Control = V3_COLORSPACE_SIGN | V3_YUV422 | V3_SWAP_HW_HQV; if (pScrn->bitsPerPixel == 8) ViaSwovColorKey(Swov, Port->colorKey & 0xff, 0); @@ -1613,6 +1610,7 @@ viaPutImage(ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x, #ifdef UNUSED ViaSwovChromaKey(Swov, 0, 0); #endif + ViaSwovFIFO(pVia, Swov); } /* redraw colorkey when needed */ @@ -1620,14 +1618,14 @@ viaPutImage(ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x, REGION_COPY(pScrn->pScreen, &Port->clip, clipBoxes); if (Port->autoPaint) xf86XVFillKeyHelper(pScrn->pScreen, Port->colorKey, clipBoxes); - } + } if ((Port->Src_W != src_w) || (Port->Drw_W != drw_w)) { HorizontalTouched = TRUE; Port->Src_W = src_w; Port->Drw_W = drw_w; ViaSwovZoomH(Swov, Port); - } + } if (HorizontalTouched || (Port->Src_X != src_x) || (Port->Drw_X != drw_x)) { HorizontalTouched = TRUE; @@ -1648,7 +1646,7 @@ viaPutImage(ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x, Port->Src_Y = src_y; Port->Drw_Y = drw_y; VVisible = ViaSwovVisibleV(pScrn, Port); - } + } if (HVisible && VVisible) Swov->Video->Video3Control |= V3_ENABLE; @@ -1659,9 +1657,7 @@ viaPutImage(ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x, ViaSwovStartAddress(Swov, Port); ViaSwovCopy(pVia, buf); - - if (!ViaHQVFlip(Swov, Port)) - return BadImplementation; + ViaHQVFlip(Swov, Port); if (Video3Touched || HorizontalTouched || VerticalTouched) Swov->Video->Compose |= V3_COMMAND_FIRE; |