diff options
author | Gabriel Mansi <gabriel.mansi@gmail.com> | 2007-11-16 10:48:01 +0000 |
---|---|---|
committer | Gabriel Mansi <gabriel.mansi@gmail.com> | 2007-11-16 10:48:01 +0000 |
commit | a3be2d67980acc17c5d65d6b73b0c23c9c812217 (patch) | |
tree | d668495f3d2da25236f8f88419f894f7f5b2cac3 | |
parent | c108364ac08dd43081880680928454313b20807e (diff) |
Native mode setting for P4M900 based laptops
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/via_bandwidth.c | 469 | ||||
-rw-r--r-- | src/via_bios.h | 52 | ||||
-rw-r--r-- | src/via_crtc.c | 199 | ||||
-rw-r--r-- | src/via_cvt.c | 288 | ||||
-rw-r--r-- | src/via_display.c | 117 | ||||
-rw-r--r-- | src/via_driver.c | 1115 | ||||
-rw-r--r-- | src/via_lvds.c | 8 | ||||
-rw-r--r-- | src/via_mode.c | 384 | ||||
-rw-r--r-- | src/via_panel.c | 190 | ||||
-rw-r--r-- | src/via_regs.h | 2 | ||||
-rw-r--r-- | src/via_swov.c | 2479 | ||||
-rw-r--r-- | src/via_vbe.c | 6 | ||||
-rw-r--r-- | src/via_video.c | 1235 |
14 files changed, 3732 insertions, 2814 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index d2b82ec..fdcbf78 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,7 +41,9 @@ openchrome_drv_la_SOURCES = \ via_ch7xxx.h \ via_cursor.c \ via_crtc.c \ + via_cvt.c \ via_dga.c \ + via_display.c \ via_dmabuffer.h \ via_driver.c \ via_driver.h \ diff --git a/src/via_bandwidth.c b/src/via_bandwidth.c index e09ca19..d03276f 100644 --- a/src/via_bandwidth.c +++ b/src/via_bandwidth.c @@ -121,7 +121,7 @@ void ViaSetPrimaryFIFO(ScrnInfoPtr pScrn, DisplayModePtr mode) { vgaHWPtr hwp = VGAHWPTR(pScrn); - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaSetPrimaryFIFO\n")); @@ -129,121 +129,127 @@ ViaSetPrimaryFIFO(ScrnInfoPtr pScrn, DisplayModePtr mode) ViaSeqMask(hwp, 0x17, 0x1F, 0xFF); if (mode->CrtcHDisplay >= 1600) { - ViaSeqMask(hwp, 0x16, 0x0F, 0xBF); - ViaSeqMask(hwp, 0x18, 0x4F, 0xFF); + ViaSeqMask(hwp, 0x16, 0x0F, 0xBF); + ViaSeqMask(hwp, 0x18, 0x4F, 0xFF); } else if (mode->CrtcHDisplay >= 1024) { - ViaSeqMask(hwp, 0x16, 0x0C, 0xBF); - ViaSeqMask(hwp, 0x18, 0x4C, 0xFF); + ViaSeqMask(hwp, 0x16, 0x0C, 0xBF); + ViaSeqMask(hwp, 0x18, 0x4C, 0xFF); } else { - ViaSeqMask(hwp, 0x16, 0x08, 0xBF); - ViaSeqMask(hwp, 0x18, 0x4E, 0xFF); + ViaSeqMask(hwp, 0x16, 0x08, 0xBF); + ViaSeqMask(hwp, 0x18, 0x4E, 0xFF); } - switch(pVia->Chipset) { - case VIA_CLE266: - if (CLE266_REV_IS_CX(pVia->ChipRev)) { - if (pVia->HasSecondary) { /* SAMM or DuoView case */ - if (mode->HDisplay >= 1024) { - ViaSeqMask(hwp, 0x16, 0x1C, 0x3F); /* 28 */ - hwp->writeSeq(hwp, 0x17, 0x3F); /* 63 */ - hwp->writeSeq(hwp, 0x18, 0x57); /* 23 */ - } - } else { /* Single view or Simultaneous case */ + switch (pVia->Chipset) { + case VIA_CLE266: + if (CLE266_REV_IS_CX(pVia->ChipRev)) { + if (pVia->HasSecondary) { /* SAMM or DuoView case */ + if (mode->HDisplay >= 1024) { + ViaSeqMask(hwp, 0x16, 0x1C, 0x3F); /* 28 */ + hwp->writeSeq(hwp, 0x17, 0x3F); /* 63 */ + hwp->writeSeq(hwp, 0x18, 0x57); /* 23 */ + } + } else { /* Single view or Simultaneous case */ #if 0 - if (mode->HDisplay > 1024) { - ViaSeqMask(hwp, 0x16, 0x17, 0x3F); /* 23 */ - hwp->writeSeq(hwp, 0x17, 0x2F); /* 47 */ - hwp->writeSeq(hwp, 0x18, 0x57); /* 23 */ - } + if (mode->HDisplay > 1024) { + ViaSeqMask(hwp, 0x16, 0x17, 0x3F); /* 23 */ + hwp->writeSeq(hwp, 0x17, 0x2F); /* 47 */ + hwp->writeSeq(hwp, 0x18, 0x57); /* 23 */ + } #endif - } - /* originally when setting secondary */ - ViaSetPrimaryExpireNumber(pScrn, mode, CLE266CExpireNumber); - } else { - if ((mode->HDisplay > 1024) && pVia->HasSecondary) { - ViaSetCLE266APrimaryFIFO(pScrn, TRUE); - - ViaSeqMask(hwp, 0x16, 0x17, 0x3F); /* 23 */ - hwp->writeSeq(hwp, 0x17, 0x2F); /* 47 */ - hwp->writeSeq(hwp, 0x18, 0x57); /* 23 */ - } - - /* originally when setting secondary */ - ViaSetPrimaryExpireNumber(pScrn, mode, CLE266AExpireNumber); - } - break; - case VIA_KM400: - if (pVia->HasSecondary) { /* SAMM or DuoView case */ - if ((mode->HDisplay >= 1600) && - (pVia->MemClk <= VIA_MEM_DDR200)) { - ViaSeqMask(hwp, 0x16, 0x09, 0x3F); /* 9 */ - hwp->writeSeq(hwp, 0x17, 0x1C); /* 28 */ + } + /* originally when setting secondary */ + ViaSetPrimaryExpireNumber(pScrn, mode, CLE266CExpireNumber); + } else { + if ((mode->HDisplay > 1024) && pVia->HasSecondary) { + ViaSetCLE266APrimaryFIFO(pScrn, TRUE); + + ViaSeqMask(hwp, 0x16, 0x17, 0x3F); /* 23 */ + hwp->writeSeq(hwp, 0x17, 0x2F); /* 47 */ + hwp->writeSeq(hwp, 0x18, 0x57); /* 23 */ + } + + /* originally when setting secondary */ + ViaSetPrimaryExpireNumber(pScrn, mode, CLE266AExpireNumber); + } + break; + case VIA_KM400: + if (pVia->HasSecondary) { /* SAMM or DuoView case */ + if ((mode->HDisplay >= 1600) + && (pVia->MemClk <= VIA_MEM_DDR200)) { + ViaSeqMask(hwp, 0x16, 0x09, 0x3F); /* 9 */ + hwp->writeSeq(hwp, 0x17, 0x1C); /* 28 */ + } else { + ViaSeqMask(hwp, 0x16, 0x1C, 0x3F); /* 28 */ + hwp->writeSeq(hwp, 0x17, 0x3F); /* 63 */ + } } else { - ViaSeqMask(hwp, 0x16, 0x1C, 0x3F); /* 28 */ - hwp->writeSeq(hwp, 0x17, 0x3F); /* 63 */ + if ((mode->HDisplay > 1280)) + ViaSeqMask(hwp, 0x16, 0x1C, 0x3F); /* 28 */ + else if (mode->HDisplay > 1024) + ViaSeqMask(hwp, 0x16, 0x17, 0x3F); /* 23 */ + else + ViaSeqMask(hwp, 0x16, 0x10, 0x3F); /* 16 */ + hwp->writeSeq(hwp, 0x17, 0x3F); /* 63 */ } - } else { - if ((mode->HDisplay > 1280)) - ViaSeqMask(hwp, 0x16, 0x1C, 0x3F); /* 28 */ - else if (mode->HDisplay > 1024) - ViaSeqMask(hwp, 0x16, 0x17, 0x3F); /* 23 */ + hwp->writeSeq(hwp, 0x18, 0x57); /* 23 */ + + /* originally when setting secondary */ + ViaSetPrimaryExpireNumber(pScrn, mode, KM400ExpireNumber); + break; + case VIA_K8M800: + hwp->writeSeq(hwp, 0x17, 0xBF); /* 384/2 - 1 = 191 (orig via comment: 384/8) */ + ViaSeqMask(hwp, 0x16, 0x92, 0xBF); /* 328/4 = 82 = 0x52*/ + ViaSeqMask(hwp, 0x18, 0x8a, 0xBF); /* 74 */ + + if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) + ViaSeqMask(hwp, 0x22, 0x10, 0x1F); /* 64/4 = 16 */ else - ViaSeqMask(hwp, 0x16, 0x10, 0x3F); /* 16 */ - hwp->writeSeq(hwp, 0x17, 0x3F); /* 63 */ - } - hwp->writeSeq(hwp, 0x18, 0x57); /* 23 */ - - /* originally when setting secondary */ - ViaSetPrimaryExpireNumber(pScrn, mode, KM400ExpireNumber); - break; - case VIA_K8M800: - hwp->writeSeq(hwp, 0x17, 0xBF); /* 384/2 - 1 = 191 (orig via comment: 384/8) */ - ViaSeqMask(hwp, 0x16, 0x92, 0xBF); /* 328/4 = 82 = 0x52*/ - ViaSeqMask(hwp, 0x18, 0x8a, 0xBF); /* 74 */ - - if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) - ViaSeqMask(hwp, 0x22, 0x10, 0x1F); /* 64/4 = 16 */ - else - ViaSeqMask(hwp, 0x22, 0x00, 0x1F); /* 128/4 = overflow = 0 */ - break; - case VIA_PM800: - hwp->writeSeq(hwp, 0x17, 0x5F); /* 95 */ - ViaSeqMask(hwp, 0x16, 0x20, 0xBF); /* 32 */ - ViaSeqMask(hwp, 0x18, 0x10, 0xBF); /* 16 */ - - if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) - ViaSeqMask(hwp, 0x22, 0x10, 0x1F); /* 64/4 = 16 */ - else - ViaSeqMask(hwp, 0x22, 0x1F, 0x1F); /* 31 */ - break; - case VIA_VM800: - hwp->writeSeq(hwp, 0x17, 0x2F); - ViaSeqMask(hwp, 0x16, 0x14, 0xBF); - ViaSeqMask(hwp, 0x18, 0x08, 0xBF); - - if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) - ViaSeqMask(hwp, 0x22, 0x10, 0x1F); - else - ViaSeqMask(hwp, 0x22, 0x00, 0x1F); - break; - case VIA_K8M890: - case VIA_P4M900: - hwp->writeSeq(hwp, 0x16, 0x92); - hwp->writeSeq(hwp, 0x17, 0xB3); - hwp->writeSeq(hwp, 0x18, 0x8A); - break; - case VIA_P4M890: - break; - case VIA_CX700: - hwp->writeSeq(hwp, 0x16, 0x26); - hwp->writeSeq(hwp, 0x17, 0x5F); - hwp->writeSeq(hwp, 0x18, 0x66); - hwp->writeSeq(hwp, 0x22, 0x1F); - break; - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "ViaSetPrimaryFIFO:" - " Chipset %d not implemented\n", pVia->Chipset); - break; + ViaSeqMask(hwp, 0x22, 0x00, 0x1F); /* 128/4 = overflow = 0 */ + break; + case VIA_PM800: + hwp->writeSeq(hwp, 0x17, 0x5F); /* 95 */ + ViaSeqMask(hwp, 0x16, 0x20, 0xBF); /* 32 */ + ViaSeqMask(hwp, 0x18, 0x10, 0xBF); /* 16 */ + + if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) + ViaSeqMask(hwp, 0x22, 0x10, 0x1F); /* 64/4 = 16 */ + else + ViaSeqMask(hwp, 0x22, 0x1F, 0x1F); /* 31 */ + break; + case VIA_VM800: + hwp->writeSeq(hwp, 0x17, 0x2F); + ViaSeqMask(hwp, 0x16, 0x14, 0xBF); + ViaSeqMask(hwp, 0x18, 0x08, 0xBF); + + if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) + ViaSeqMask(hwp, 0x22, 0x10, 0x1F); + else + ViaSeqMask(hwp, 0x22, 0x00, 0x1F); + break; + case VIA_K8M890: + hwp->writeSeq(hwp, 0x16, 0x92); + hwp->writeSeq(hwp, 0x17, 0xB3); + hwp->writeSeq(hwp, 0x18, 0x8A); + break; + case VIA_P4M900: + ViaSeqMask(hwp, 0x17, 0x2F, 0xFF); + ViaSeqMask(hwp, 0x16, 0x13, 0x3F); + ViaSeqMask(hwp, 0x16, 0x00, 0x80); + ViaSeqMask(hwp, 0x18, 0x13, 0x3F); + ViaSeqMask(hwp, 0x18, 0x00, 0x80); + break; + case VIA_P4M890: + break; + case VIA_CX700: + hwp->writeSeq(hwp, 0x16, 0x26); + hwp->writeSeq(hwp, 0x17, 0x5F); + hwp->writeSeq(hwp, 0x18, 0x66); + hwp->writeSeq(hwp, 0x22, 0x1F); + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "ViaSetPrimaryFIFO:" + " Chipset %d not implemented\n", pVia->Chipset); + break; } } @@ -257,129 +263,140 @@ void ViaSetSecondaryFIFO(ScrnInfoPtr pScrn, DisplayModePtr mode) { vgaHWPtr hwp = VGAHWPTR(pScrn); - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaSetSecondaryFIFO\n")); switch (pVia->Chipset) { - case VIA_CLE266: - if (CLE266_REV_IS_CX(pVia->ChipRev)) { - if (mode->HDisplay >= 1024) { - ViaCrtcMask(hwp, 0x6A, 0x20, 0x20); - hwp->writeCrtc(hwp, 0x68, 0xAB); /* depth: 10, threshold: 11 */ - } else { - ViaCrtcMask(hwp, 0x6A, 0x00, 0x20); - hwp->writeCrtc(hwp, 0x68, 0x67); /* depth: 6, threshold: 7 */ - } - } else { - if ((pScrn->bitsPerPixel >= 24) && - (((mode->VDisplay > 768) && (pVia->MemClk <= VIA_MEM_DDR200)) || - ((mode->HDisplay > 1280) && (pVia->MemClk <= VIA_MEM_DDR266)))) { - ViaCrtcMask(hwp, 0x6A, 0x20, 0x20); - hwp->writeCrtc(hwp, 0x68, 0xAB); /* depth: 10, threshold: 11 */ - } else { - ViaCrtcMask(hwp, 0x6A, 0x00, 0x20); - hwp->writeCrtc(hwp, 0x68, 0x67); /* depth: 6, threshold: 7 */ - } - } - break; - case VIA_KM400: - if ((mode->HDisplay >= 1600) && (pVia->MemClk <= VIA_MEM_DDR200)) { - ViaCrtcMask(hwp, 0x6A, 0x20, 0x20); - hwp->writeCrtc(hwp, 0x68, 0xEB); /* depth: 14, threshold: 11 */ - } else if ((pScrn->bitsPerPixel == 32) && - (((mode->HDisplay > 1024) && (pVia->MemClk <= VIA_MEM_DDR333)) || - ((mode->HDisplay >= 1024) && (pVia->MemClk <= VIA_MEM_DDR200)))) { - ViaCrtcMask(hwp, 0x6A, 0x20, 0x20); - hwp->writeCrtc(hwp, 0x68, 0xCA); /* depth: 12, threshold: 10 */ - } else if ((pScrn->bitsPerPixel == 16) && - (((mode->HDisplay > 1280) && (pVia->MemClk <= VIA_MEM_DDR333)) || - ((mode->HDisplay >= 1280) && (pVia->MemClk <= VIA_MEM_DDR200)))) { - ViaCrtcMask(hwp, 0x6A, 0x20, 0x20); - hwp->writeCrtc(hwp, 0x68, 0xAB); /* depth: 10, threshold: 11 */ - } else { - ViaCrtcMask(hwp, 0x6A, 0x00, 0x20); - hwp->writeCrtc(hwp, 0x68, 0x67); /* depth: 6, threshold: 7 */ - } - break; - case VIA_K8M800: - /* depth: (384 /8 -1 -1) = 46 = 0x2E */ - ViaCrtcMask(hwp, 0x68, 0xE0, 0xF0); - ViaCrtcMask(hwp, 0x94, 0x00, 0x80); - ViaCrtcMask(hwp, 0x95, 0x80, 0x80); - - /* threshold: (328/4) = 82 = 0x52 */ - ViaCrtcMask(hwp, 0x68, 0x02, 0x0F); - ViaCrtcMask(hwp, 0x95, 0x50, 0x70); - - /* preq: 74 = 0x4A */ - ViaCrtcMask(hwp, 0x92, 0x0A, 0x0F); - ViaCrtcMask(hwp, 0x95, 0x04, 0x07); - - if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) - ViaCrtcMask(hwp, 0x94, 0x10, 0x7F); /* 64/4 */ - else - ViaCrtcMask(hwp, 0x94, 0x20, 0x7F); /* 128/4 */ - break; - case VIA_PM800: - /* depth: 12 - 1 = 0x0B */ - ViaCrtcMask(hwp, 0x68, 0xB0, 0xF0); - ViaCrtcMask(hwp, 0x94, 0x00, 0x80); - ViaCrtcMask(hwp, 0x95, 0x00, 0x80); - - /* threshold: 16 = 0x10 */ - ViaCrtcMask(hwp, 0x68, 0x00, 0x0F); - ViaCrtcMask(hwp, 0x95, 0x10, 0x70); - - /* preq: 8 = 0x08 */ - ViaCrtcMask(hwp, 0x92, 0x08, 0x0F); - ViaCrtcMask(hwp, 0x95, 0x00, 0x07); - - if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) - ViaCrtcMask(hwp, 0x94, 0x10, 0x7F); /* 64/4 */ - else - ViaCrtcMask(hwp, 0x94, 0x20, 0x7F); /* 128/4 */ - break; - case VIA_VM800: - ViaCrtcMask(hwp, 0x68, 0xA0, 0xF0); - ViaCrtcMask(hwp, 0x94, 0x00, 0x80); - ViaCrtcMask(hwp, 0x95, 0x00, 0x80); - - ViaCrtcMask(hwp, 0x68, 0x04, 0x0F); - ViaCrtcMask(hwp, 0x95, 0x10, 0x70); - - ViaCrtcMask(hwp, 0x92, 0x08, 0x0F); - ViaCrtcMask(hwp, 0x95, 0x00, 0x07); - - if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) - ViaCrtcMask(hwp, 0x94, 0x10, 0x7F); - else - ViaCrtcMask(hwp, 0x94, 0x20, 0x7F); - break; - case VIA_P4M890: - case VIA_K8M890: - case VIA_P4M900: - break; - case VIA_CX700: - ViaCrtcMask(hwp, 0x68, 0xA0, 0xF0); - ViaCrtcMask(hwp, 0x94, 0x00, 0x80); - ViaCrtcMask(hwp, 0x95, 0x00, 0x80); - - ViaCrtcMask(hwp, 0x68, 0x04, 0x0F); - ViaCrtcMask(hwp, 0x95, 0x10, 0x70); - - ViaCrtcMask(hwp, 0x92, 0x08, 0x0F); - ViaCrtcMask(hwp, 0x95, 0x00, 0x07); - - if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) - ViaCrtcMask(hwp, 0x94, 0x10, 0x7F); - else - ViaCrtcMask(hwp, 0x94, 0x20, 0x7F); - break; - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "ViaSetSecondaryFIFO:" - " Chipset %d not implemented\n", pVia->Chipset); - break; + case VIA_CLE266: + if (CLE266_REV_IS_CX(pVia->ChipRev)) { + if (mode->HDisplay >= 1024) { + ViaCrtcMask(hwp, 0x6A, 0x20, 0x20); + hwp->writeCrtc(hwp, 0x68, 0xAB); /* depth: 10, threshold: 11 */ + } else { + ViaCrtcMask(hwp, 0x6A, 0x00, 0x20); + hwp->writeCrtc(hwp, 0x68, 0x67); /* depth: 6, threshold: 7 */ + } + } else { + if ((pScrn->bitsPerPixel >= 24) && (((mode->VDisplay > 768) + && (pVia->MemClk <= VIA_MEM_DDR200)) + || ((mode->HDisplay > 1280) && (pVia->MemClk + <= VIA_MEM_DDR266)))) { + ViaCrtcMask(hwp, 0x6A, 0x20, 0x20); + hwp->writeCrtc(hwp, 0x68, 0xAB); /* depth: 10, threshold: 11 */ + } else { + ViaCrtcMask(hwp, 0x6A, 0x00, 0x20); + hwp->writeCrtc(hwp, 0x68, 0x67); /* depth: 6, threshold: 7 */ + } + } + break; + case VIA_KM400: + if ((mode->HDisplay >= 1600) && (pVia->MemClk <= VIA_MEM_DDR200)) { + ViaCrtcMask(hwp, 0x6A, 0x20, 0x20); + hwp->writeCrtc(hwp, 0x68, 0xEB); /* depth: 14, threshold: 11 */ + } else if ((pScrn->bitsPerPixel == 32) && (((mode->HDisplay > 1024) + && (pVia->MemClk <= VIA_MEM_DDR333)) || ((mode->HDisplay + >= 1024) && (pVia->MemClk <= VIA_MEM_DDR200)))) { + ViaCrtcMask(hwp, 0x6A, 0x20, 0x20); + hwp->writeCrtc(hwp, 0x68, 0xCA); /* depth: 12, threshold: 10 */ + } else if ((pScrn->bitsPerPixel == 16) && (((mode->HDisplay > 1280) + && (pVia->MemClk <= VIA_MEM_DDR333)) || ((mode->HDisplay + >= 1280) && (pVia->MemClk <= VIA_MEM_DDR200)))) { + ViaCrtcMask(hwp, 0x6A, 0x20, 0x20); + hwp->writeCrtc(hwp, 0x68, 0xAB); /* depth: 10, threshold: 11 */ + } else { + ViaCrtcMask(hwp, 0x6A, 0x00, 0x20); + hwp->writeCrtc(hwp, 0x68, 0x67); /* depth: 6, threshold: 7 */ + } + break; + case VIA_K8M800: + /* depth: (384 /8 -1 -1) = 46 = 0x2E */ + ViaCrtcMask(hwp, 0x68, 0xE0, 0xF0); + ViaCrtcMask(hwp, 0x94, 0x00, 0x80); + ViaCrtcMask(hwp, 0x95, 0x80, 0x80); + + /* threshold: (328/4) = 82 = 0x52 */ + ViaCrtcMask(hwp, 0x68, 0x02, 0x0F); + ViaCrtcMask(hwp, 0x95, 0x50, 0x70); + + /* preq: 74 = 0x4A */ + ViaCrtcMask(hwp, 0x92, 0x0A, 0x0F); + ViaCrtcMask(hwp, 0x95, 0x04, 0x07); + + if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) + ViaCrtcMask(hwp, 0x94, 0x10, 0x7F); /* 64/4 */ + else + ViaCrtcMask(hwp, 0x94, 0x20, 0x7F); /* 128/4 */ + break; + case VIA_PM800: + /* depth: 12 - 1 = 0x0B */ + ViaCrtcMask(hwp, 0x68, 0xB0, 0xF0); + ViaCrtcMask(hwp, 0x94, 0x00, 0x80); + ViaCrtcMask(hwp, 0x95, 0x00, 0x80); + + /* threshold: 16 = 0x10 */ + ViaCrtcMask(hwp, 0x68, 0x00, 0x0F); + ViaCrtcMask(hwp, 0x95, 0x10, 0x70); + + /* preq: 8 = 0x08 */ + ViaCrtcMask(hwp, 0x92, 0x08, 0x0F); + ViaCrtcMask(hwp, 0x95, 0x00, 0x07); + + if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) + ViaCrtcMask(hwp, 0x94, 0x10, 0x7F); /* 64/4 */ + else + ViaCrtcMask(hwp, 0x94, 0x20, 0x7F); /* 128/4 */ + break; + case VIA_VM800: + ViaCrtcMask(hwp, 0x68, 0xA0, 0xF0); + ViaCrtcMask(hwp, 0x94, 0x00, 0x80); + ViaCrtcMask(hwp, 0x95, 0x00, 0x80); + + ViaCrtcMask(hwp, 0x68, 0x04, 0x0F); + ViaCrtcMask(hwp, 0x95, 0x10, 0x70); + + ViaCrtcMask(hwp, 0x92, 0x08, 0x0F); + ViaCrtcMask(hwp, 0x95, 0x00, 0x07); + + if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) + ViaCrtcMask(hwp, 0x94, 0x10, 0x7F); + else + ViaCrtcMask(hwp, 0x94, 0x20, 0x7F); + break; + case VIA_P4M890: + case VIA_K8M890: + break; + case VIA_P4M900: + ViaCrtcMask(hwp, 0x68, 0xB0, 0xF0); + ViaCrtcMask(hwp, 0x94, 0x00, 0x80); + ViaCrtcMask(hwp, 0x95, 0x00, 0x80); + + ViaCrtcMask(hwp, 0x68, 0x03, 0x0F); + ViaCrtcMask(hwp, 0x95, 0x10, 0x70); + ViaCrtcMask(hwp, 0x92, 0x03, 0x0F); + ViaCrtcMask(hwp, 0x95, 0x01, 0x07); + ViaCrtcMask(hwp, 0x94, 0x08, 0x7F); + break; + case VIA_CX700: + ViaCrtcMask(hwp, 0x68, 0xA0, 0xF0); + ViaCrtcMask(hwp, 0x94, 0x00, 0x80); + ViaCrtcMask(hwp, 0x95, 0x00, 0x80); + + ViaCrtcMask(hwp, 0x68, 0x04, 0x0F); + ViaCrtcMask(hwp, 0x95, 0x10, 0x70); + + ViaCrtcMask(hwp, 0x92, 0x08, 0x0F); + ViaCrtcMask(hwp, 0x95, 0x00, 0x07); + + if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32)) + ViaCrtcMask(hwp, 0x94, 0x10, 0x7F); + else + ViaCrtcMask(hwp, 0x94, 0x20, 0x7F); + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "ViaSetSecondaryFIFO:" + " Chipset %d not implemented\n", pVia->Chipset); + break; } } diff --git a/src/via_bios.h b/src/via_bios.h index 70d60cd..ef9e45c 100644 --- a/src/via_bios.h +++ b/src/via_bios.h @@ -104,10 +104,21 @@ typedef struct ViaPanelMode { } ViaPanelModeRec, *ViaPanelModePtr ; typedef struct ViaPanelInfo { - Bool IsActive ; - /* current panel native resolution */ + Bool IsActive ; + /* current native resolution */ ViaPanelModePtr NativeMode ; - CARD8 NativeModeIndex; + /* Native resolution index, see via_panel.c */ + CARD8 NativeModeIndex; + /* Generated mode for native resolution */ + DisplayModePtr NativeDisplayMode ; +#if 0 + /* Panel size from configuration */ + char* PanelSizeFromOption; +#endif + /* Center or scale mode */ + Bool Center; + /* Current mode but centered */ + DisplayModePtr CenteredMode ; } ViaPanelInfoRec, *ViaPanelInfoPtr ; typedef struct ViaLVDSInfo { @@ -118,6 +129,10 @@ typedef struct ViaCRTCInfo { Bool IsActive ; } ViaCRTCInfoRec, *ViaCRTCInfoPtr ; +typedef struct ViaSimultaneousInfo { + Bool IsActive ; +} ViaSimultaneousInfoRec, *ViaSimultaneousInfoPtr ; + typedef struct _VIABIOSINFO { int scrnIndex; @@ -133,7 +148,6 @@ typedef struct _VIABIOSINFO { /* Panel/LCD entries */ ViaPanelInfoPtr Panel ; Bool PanelPresent; - Bool PanelActive; Bool ForcePanel; int PanelIndex; Bool Center; @@ -151,6 +165,9 @@ typedef struct _VIABIOSINFO { /* CRTCs */ ViaCRTCInfoPtr FirstCRTC ; ViaCRTCInfoPtr SecondCRTC ; + + /* Simultaneous */ + ViaSimultaneousInfoPtr Simultaneous ; /* TV entries */ int TVEncoder; @@ -192,8 +209,8 @@ Bool ViaOutputsSelect(ScrnInfoPtr pScrn); void ViaModesAttach(ScrnInfoPtr pScrn, MonPtr monitorp); CARD32 ViaGetMemoryBandwidth(ScrnInfoPtr pScrn); ModeStatus ViaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags); -void ViaModePrimary(ScrnInfoPtr pScrn, DisplayModePtr mode); -void ViaModeSecondary(ScrnInfoPtr pScrn, DisplayModePtr mode); +void ViaModePrimaryLegacy(ScrnInfoPtr pScrn, DisplayModePtr mode); +void ViaModeSecondaryLegacy(ScrnInfoPtr pScrn, DisplayModePtr mode); void ViaLCDPower(ScrnInfoPtr pScrn, Bool On); void ViaTVPower(ScrnInfoPtr pScrn, Bool On); void ViaTVSave(ScrnInfoPtr pScrn); @@ -201,6 +218,9 @@ void ViaTVRestore(ScrnInfoPtr pScrn); #ifdef HAVE_DEBUG void ViaTVPrintRegs(ScrnInfoPtr pScrn); #endif +void ViaModeSecondCRTC(ScrnInfoPtr pScrn, DisplayModePtr mode); +void ViaModeFirstCRTC(ScrnInfoPtr pScrn, DisplayModePtr mode); +void ViaModeSet(ScrnInfoPtr pScrn, DisplayModePtr mode); /* via_crtc.c */ void ViaCRTCInit(ScrnInfoPtr pScrn); @@ -210,11 +230,17 @@ void ViaSecondCRTCSetStartingAddress(ScrnInfoPtr pScrn, int x, int y); void ViaSecondCRTCHorizontalOffset(ScrnInfoPtr pScrn); void ViaSecondCRTCHorizontalQWCount(ScrnInfoPtr pScrn, int width); void ViaSecondCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode); +ModeStatus ViaFirstCRTCModeValid(ScrnInfoPtr pScrn, DisplayModePtr mode); +ModeStatus ViaSecondCRTCModeValid(ScrnInfoPtr pScrn, DisplayModePtr mode); +void ViaShadowCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode); /* via_panel.c */ void ViaPanelScale(ScrnInfoPtr pScrn, int resWidth, int resHeight, int panelWidth, int panelHeight ); +void ViaPanelScaleDisable(ScrnInfoPtr pScrn); void ViaPanelGetNativeModeFromScratchPad(ScrnInfoPtr pScrn); void ViaPanelGetNativeModeFromOption(ScrnInfoPtr pScrn, char* name); +void ViaPanelPreInit(ScrnInfoPtr pScrn); +void ViaPanelCenterMode(DisplayModePtr centerMode, DisplayModePtr panelMode, DisplayModePtr mode); /* via_lvds.c */ void ViaLVDSPower(ScrnInfoPtr pScrn, Bool on); @@ -232,4 +258,18 @@ void ViaVT162xInit(ScrnInfoPtr pScrn); I2CDevPtr ViaCH7xxxDetect(ScrnInfoPtr pScrn, I2CBusPtr pBus, CARD8 Address); void ViaCH7xxxInit(ScrnInfoPtr pScrn); +/* via_display.c */ +void ViaSecondDisplayChannelEnable(ScrnInfoPtr pScrn); +void ViaSecondDisplayChannelDisable(ScrnInfoPtr pScrn); +void ViaDisplayInit(ScrnInfoPtr pScrn); +void ViaDisplayEnableSimultaneous(ScrnInfoPtr pScrn); +void ViaDisplayDisableSimultaneous(ScrnInfoPtr pScrn); +void ViaDisplayEnableCRT(ScrnInfoPtr pScrn); +void ViaDisplayDisableCRT(ScrnInfoPtr pScrn); + +/* via_cvt.c */ +DisplayModePtr +ViaCVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced, + Bool Interlaced); + #endif /* _VIA_BIOS_H_ */ diff --git a/src/via_crtc.c b/src/via_crtc.c index 1785c79..5399f23 100644 --- a/src/via_crtc.c +++ b/src/via_crtc.c @@ -145,10 +145,19 @@ ViaFirstCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) break; } - ViaSeqMask(hwp, 0x16, 0x08, 0xBF); - ViaSeqMask(hwp, 0x17, 0x1F, 0xFF); - ViaSeqMask(hwp, 0x18, 0x4E, 0xFF); - ViaSeqMask(hwp, 0x1A, 0x08, 0xFD); + /* FIXME: check if this is really necessary here */ + switch (pVia->ChipId) { + case VIA_K8M890: + case VIA_CX700: + case VIA_P4M900: + break ; + default: + ViaSeqMask(hwp, 0x16, 0x08, 0xBF); + ViaSeqMask(hwp, 0x17, 0x1F, 0xFF); + ViaSeqMask(hwp, 0x18, 0x4E, 0xFF); + ViaSeqMask(hwp, 0x1A, 0x08, 0xFD); + break; + } /* Crtc registers */ /* horizontal total : 4100 */ @@ -234,10 +243,19 @@ ViaFirstCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) temp = mode->CrtcVTotal - 1; hwp->writeCrtc(hwp, 0x16, temp); - /* some leftovers */ - hwp->writeCrtc(hwp, 0x08, 0x00); - ViaCrtcMask(hwp, 0x32, 0, 0xFF); /* ? */ - ViaCrtcMask(hwp, 0x33, 0, 0xC8); + /* FIXME: check if this is really necessary here */ + switch (pVia->ChipId) { + case VIA_K8M890: + case VIA_CX700: + case VIA_P4M900: + break ; + default: + /* some leftovers */ + hwp->writeCrtc(hwp, 0x08, 0x00); + ViaCrtcMask(hwp, 0x32, 0, 0xFF); /* ? */ + ViaCrtcMask(hwp, 0x33, 0, 0xC8); + break; + } /* offset */ temp = (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)) >> 3; @@ -259,26 +277,38 @@ ViaFirstCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) hwp->writeSeq(hwp, 0x1C, (temp >> 1) & 0xFF); ViaSeqMask(hwp, 0x1D, temp >> 9, 0x03); - /* some leftovers */ - ViaCrtcMask(hwp, 0x32, 0, 0xFF); - ViaCrtcMask(hwp, 0x33, 0, 0xC8); + /* FIXME: check if this is really necessary here */ + switch (pVia->ChipId) { + case VIA_K8M890: + case VIA_CX700: + case VIA_P4M900: + break ; + default: + /* some leftovers */ + ViaCrtcMask(hwp, 0x32, 0, 0xFF); + ViaCrtcMask(hwp, 0x33, 0, 0xC8); + break; + } } void ViaFirstCRTCSetStartingAddress(ScrnInfoPtr pScrn, int x, int y) { + + VIAPtr pVia = VIAPTR(pScrn); vgaHWPtr hwp = VGAHWPTR(pScrn); CARD32 Base ; CARD32 tmp ; + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaFirstCRTCSetStartingAddress\n")); + Base = (y * pScrn->displayWidth + x) * (pScrn->bitsPerPixel / 8); Base = Base >> 1; hwp->writeCrtc(hwp, 0x0C, (Base & 0xFF00) >> 8); hwp->writeCrtc(hwp, 0x0D, Base & 0xFF); hwp->writeCrtc(hwp, 0x34, (Base & 0xFF0000) >> 16); -#if 0 - /* The CLE266A doesn't have this implemented, it seems. -- Luc */ - ViaCrtcMask(hwp, 0x48, Base >> 24, 0x03); -#endif + + if (!(pVia->Chipset == VIA_CLE266 && CLE266_REV_IS_AX(pVia->ChipRev))) + ViaCrtcMask(hwp, 0x48, Base >> 24, 0x0F); } @@ -288,6 +318,8 @@ ViaSecondCRTCSetStartingAddress(ScrnInfoPtr pScrn, int x, int y) { CARD32 Base ; CARD32 tmp ; + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaSecondCRTCSetStartingAddress\n")); + Base = (y * pScrn->displayWidth + x) * (pScrn->bitsPerPixel / 8); Base = (Base + pScrn->fbOffset) >> 3; @@ -434,3 +466,140 @@ ViaSecondCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) ViaSecondCRTCHorizontalQWCount(pScrn, mode->CrtcHDisplay); } + +/* + * Checks for limitations imposed by the available VGA timing registers. + * + */ +ModeStatus +ViaFirstCRTCModeValid(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaFirstCRTCModeValid\n")); + + if (mode->CrtcHTotal > 4100) + return MODE_BAD_HVALUE; + + if (mode->CrtcHDisplay > 2048) + return MODE_BAD_HVALUE; + + if (mode->CrtcHBlankStart > 2048) + return MODE_BAD_HVALUE; + + if ((mode->CrtcHBlankEnd - mode->CrtcHBlankStart) > 1025) + return MODE_HBLANK_WIDE; + + if (mode->CrtcHSyncStart > 4095) + return MODE_BAD_HVALUE; + + if ((mode->CrtcHSyncEnd - mode->CrtcHSyncStart) > 256) + return MODE_HSYNC_WIDE; + + if (mode->CrtcVTotal > 2049) + return MODE_BAD_VVALUE; + + if (mode->CrtcVDisplay > 2048) + return MODE_BAD_VVALUE; + + if (mode->CrtcVSyncStart > 2047) + return MODE_BAD_VVALUE; + + if ((mode->CrtcVSyncEnd - mode->CrtcVSyncStart) > 16) + return MODE_VSYNC_WIDE; + + if (mode->CrtcVBlankStart > 2048) + return MODE_BAD_VVALUE; + + if ((mode->CrtcVBlankEnd - mode->CrtcVBlankStart) > 257) + return MODE_VBLANK_WIDE; + + return MODE_OK; +} + +/* + * + */ +ModeStatus +ViaSecondCRTCModeValid(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaSecondCRTCModeValid\n")); + + if (mode->CrtcHTotal > 4096) + return MODE_BAD_HVALUE; + + if (mode->CrtcHDisplay > 2048) + return MODE_BAD_HVALUE; + + if (mode->CrtcHBlankStart > 2048) + return MODE_BAD_HVALUE; + + if (mode->CrtcHBlankEnd > 4096) + return MODE_HBLANK_WIDE; + + if (mode->CrtcHSyncStart > 2047) + return MODE_BAD_HVALUE; + + if ((mode->CrtcHSyncEnd - mode->CrtcHSyncStart) > 512) + return MODE_HSYNC_WIDE; + + if (mode->CrtcVTotal > 2048) + return MODE_BAD_VVALUE; + + if (mode->CrtcVDisplay > 2048) + return MODE_BAD_VVALUE; + + if (mode->CrtcVBlankStart > 2048) + return MODE_BAD_VVALUE; + + if (mode->CrtcVBlankEnd > 2048) + return MODE_VBLANK_WIDE; + + if (mode->CrtcVSyncStart > 2047) + return MODE_BAD_VVALUE; + + if ((mode->CrtcVSyncEnd - mode->CrtcVSyncStart) > 32) + return MODE_VSYNC_WIDE; + + return MODE_OK; +} + +/* + * Not tested yet + */ +void +ViaShadowCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaShadowCRTCSetMode\n")); + + vgaHWPtr hwp = VGAHWPTR(pScrn); + CARD16 temp; + + temp = (mode->CrtcHTotal >> 3) - 5; + hwp->writeCrtc(hwp, 0x6D, temp & 0xFF); + ViaCrtcMask(hwp, 0x71, temp >> 5, 0x08); + + temp = (mode->CrtcHBlankEnd >> 3) - 1; + hwp->writeCrtc(hwp, 0x6E, temp & 0xFF); + + temp = mode->CrtcVTotal - 2; + hwp->writeCrtc(hwp, 0x6F, temp & 0xFF); + ViaCrtcMask(hwp, 0x71, temp >> 8, 0x07); + + temp = mode->CrtcVDisplay - 1; + hwp->writeCrtc(hwp, 0x70, temp & 0xFF); + ViaCrtcMask(hwp, 0x71, temp >> 4, 0x70); + + temp = mode->CrtcVBlankStart - 1; + hwp->writeCrtc(hwp, 0x72, temp & 0xFF); + ViaCrtcMask(hwp, 0x74, temp >> 4, 0x70); + + temp = mode->CrtcVTotal - 1; + hwp->writeCrtc(hwp, 0x73, temp & 0xFF); + ViaCrtcMask(hwp, 0x74, temp >> 8, 0x07); + + ViaCrtcMask(hwp, 0x76, mode->CrtcVSyncEnd, 0x0F); + + temp = mode->CrtcVSyncStart; + hwp->writeCrtc(hwp, 0x75, temp & 0xFF); + ViaCrtcMask(hwp, 0x76, temp >> 4, 0x70); + +}
\ No newline at end of file diff --git a/src/via_cvt.c b/src/via_cvt.c new file mode 100644 index 0000000..b7342c3 --- /dev/null +++ b/src/via_cvt.c @@ -0,0 +1,288 @@ +/* + * Copyright 2004-2007 Luc Verhaegen. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "via_driver.h" +#include "via_vgahw.h" +#include "via_id.h" + +/* + * Generate a CVT standard mode from HDisplay, VDisplay and VRefresh. + * + * These calculations are stolen from the CVT calculation spreadsheet written + * by Graham Loveridge. He seems to be claiming no copyright and there seems to + * be no license attached to this. He apparently just wants to see his name + * mentioned. + * + * This file can be found at http://www.vesa.org/Public/CVT/CVTd6r1.xls + * + * Comments and structure corresponds to the comments and structure of the xls. + * This should ease importing of future changes to the standard (not very + * likely though). + * + * About margins; i'm sure that they are to be the bit between HDisplay and + * HBlankStart, HBlankEnd and HTotal, VDisplay and VBlankStart, VBlankEnd and + * VTotal, where the overscan colour is shown. FB seems to call _all_ blanking + * outside sync "margin" for some reason. Since we prefer seeing proper + * blanking instead of the overscan colour, and since the Crtc* values will + * probably get altered after us, we will disable margins altogether. With + * these calculations, Margins will plainly expand H/VDisplay, and we don't + * want that. -- libv + * + */ +DisplayModePtr +ViaCVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced, + Bool Interlaced) +{ + DisplayModeRec *Mode = malloc(sizeof(DisplayModeRec)); + memset(Mode, 0, sizeof(DisplayModeRec)); + + /* 1) top/bottom margin size (% of height) - default: 1.8 */ +#define CVT_MARGIN_PERCENTAGE 1.8 + + /* 2) character cell horizontal granularity (pixels) - default 8 */ +#define CVT_H_GRANULARITY 8 + + /* 4) Minimum vertical porch (lines) - default 3 */ +#define CVT_MIN_V_PORCH 3 + + /* 4) Minimum number of vertical back porch lines - default 6 */ +#define CVT_MIN_V_BPORCH 6 + + /* Pixel Clock step (kHz) */ +#define CVT_CLOCK_STEP 250 + + Bool Margins = FALSE; + float VFieldRate, HPeriod; + int HDisplayRnd, HMargin; + int VDisplayRnd, VMargin, VSync; + float Interlace; /* Please rename this */ + + memset(Mode, 0, sizeof(DisplayModeRec)); + + /* CVT default is 60.0Hz */ + if (!VRefresh) + VRefresh = 60.0; + + /* 1. Required field rate */ + if (Interlaced) + VFieldRate = VRefresh * 2; + else + VFieldRate = VRefresh; + + /* 2. Horizontal pixels */ + HDisplayRnd = HDisplay - (HDisplay % CVT_H_GRANULARITY); + + /* 3. Determine left and right borders */ + if (Margins) { + /* right margin is actually exactly the same as left */ + HMargin = (((float) HDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0); + HMargin -= HMargin % CVT_H_GRANULARITY; + } else + HMargin = 0; + + /* 4. Find total active pixels */ + Mode->HDisplay = HDisplayRnd + 2*HMargin; + + /* 5. Find number of lines per field */ + if (Interlaced) + VDisplayRnd = VDisplay / 2; + else + VDisplayRnd = VDisplay; + + /* 6. Find top and bottom margins */ + /* nope. */ + if (Margins) + /* top and bottom margins are equal again. */ + VMargin = (((float) VDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0); + else + VMargin = 0; + + Mode->VDisplay = VDisplay + 2*VMargin; + + /* 7. Interlace */ + if (Interlaced) + Interlace = 0.5; + else + Interlace = 0.0; + + /* Determine VSync Width from aspect ratio */ + if (!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay)) + VSync = 4; + else if (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay)) + VSync = 5; + else if (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay)) + VSync = 6; + else if (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay)) + VSync = 7; + else if (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay)) + VSync = 7; + else /* Custom */ + VSync = 10; + + if (!Reduced) { /* simplified GTF calculation */ + + /* 4) Minimum time of vertical sync + back porch interval (�s) + * default 550.0 */ +#define CVT_MIN_VSYNC_BP 550.0 + + /* 3) Nominal HSync width (% of line period) - default 8 */ +#define CVT_HSYNC_PERCENTAGE 8 + + float HBlankPercentage; + int VSyncAndBackPorch, VBackPorch; + int HBlank; + + /* 8. Estimated Horizontal period */ + HPeriod = ((float) (1000000.0 / VFieldRate - CVT_MIN_VSYNC_BP)) / + (VDisplayRnd + 2 * VMargin + CVT_MIN_V_PORCH + Interlace); + + /* 9. Find number of lines in sync + backporch */ + if (((int)(CVT_MIN_VSYNC_BP / HPeriod) + 1) < (VSync + CVT_MIN_V_PORCH)) + VSyncAndBackPorch = VSync + CVT_MIN_V_PORCH; + else + VSyncAndBackPorch = (int)(CVT_MIN_VSYNC_BP / HPeriod) + 1; + + /* 10. Find number of lines in back porch */ + VBackPorch = VSyncAndBackPorch - VSync; + + /* 11. Find total number of lines in vertical field */ + Mode->VTotal = VDisplayRnd + 2 * VMargin + VSyncAndBackPorch + Interlace + + CVT_MIN_V_PORCH; + + /* 5) Definition of Horizontal blanking time limitation */ + /* Gradient (%/kHz) - default 600 */ +#define CVT_M_FACTOR 600 + + /* Offset (%) - default 40 */ +#define CVT_C_FACTOR 40 + + /* Blanking time scaling factor - default 128 */ +#define CVT_K_FACTOR 128 + + /* Scaling factor weighting - default 20 */ +#define CVT_J_FACTOR 20 + +#define CVT_M_PRIME CVT_M_FACTOR * CVT_K_FACTOR / 256 +#define CVT_C_PRIME (CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256 + \ + CVT_J_FACTOR + + /* 12. Find ideal blanking duty cycle from formula */ + HBlankPercentage = CVT_C_PRIME - CVT_M_PRIME * HPeriod/1000.0; + + /* 13. Blanking time */ + if (HBlankPercentage < 20) + HBlankPercentage = 20; + + HBlank = Mode->HDisplay * HBlankPercentage/(100.0 - HBlankPercentage); + HBlank -= HBlank % (2*CVT_H_GRANULARITY); + + /* 14. Find total number of pixels in a line. */ + Mode->HTotal = Mode->HDisplay + HBlank; + + /* Fill in HSync values */ + Mode->HSyncEnd = Mode->HDisplay + HBlank / 2; + + Mode->HSyncStart = Mode->HSyncEnd - + (Mode->HTotal * CVT_HSYNC_PERCENTAGE) / 100; + Mode->HSyncStart += CVT_H_GRANULARITY - + Mode->HSyncStart % CVT_H_GRANULARITY; + + /* Fill in VSync values */ + Mode->VSyncStart = Mode->VDisplay + CVT_MIN_V_PORCH; + Mode->VSyncEnd = Mode->VSyncStart + VSync; + + } else { /* Reduced blanking */ + /* Minimum vertical blanking interval time (�s) - default 460 */ +#define CVT_RB_MIN_VBLANK 460.0 + + /* Fixed number of clocks for horizontal sync */ +#define CVT_RB_H_SYNC 32.0 + + /* Fixed number of clocks for horizontal blanking */ +#define CVT_RB_H_BLANK 160.0 + + /* Fixed number of lines for vertical front porch - default 3 */ +#define CVT_RB_VFPORCH 3 + + int VBILines; + + /* 8. Estimate Horizontal period. */ + HPeriod = ((float) (1000000.0 / VFieldRate - CVT_RB_MIN_VBLANK)) / + (VDisplayRnd + 2*VMargin); + + /* 9. Find number of lines in vertical blanking */ + VBILines = ((float) CVT_RB_MIN_VBLANK) / HPeriod + 1; + + /* 10. Check if vertical blanking is sufficient */ + if (VBILines < (CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH)) + VBILines = CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH; + + /* 11. Find total number of lines in vertical field */ + Mode->VTotal = VDisplayRnd + 2 * VMargin + Interlace + VBILines; + + /* 12. Find total number of pixels in a line */ + Mode->HTotal = Mode->HDisplay + CVT_RB_H_BLANK; + + /* Fill in HSync values */ + Mode->HSyncEnd = Mode->HDisplay + CVT_RB_H_BLANK / 2; + Mode->HSyncStart = Mode->HSyncEnd - CVT_RB_H_SYNC; + + /* Fill in VSync values */ + Mode->VSyncStart = Mode->VDisplay + CVT_RB_VFPORCH; + Mode->VSyncEnd = Mode->VSyncStart + VSync; + } + + /* 15/13. Find pixel clock frequency (kHz for xf86) */ + Mode->Clock = Mode->HTotal * 1000.0 / HPeriod; + Mode->Clock -= Mode->Clock % CVT_CLOCK_STEP; + + /* 16/14. Find actual Horizontal Frequency (kHz) */ + Mode->HSync = ((float) Mode->Clock) / ((float) Mode->HTotal); + + /* 17/15. Find actual Field rate */ + Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / + ((float) (Mode->HTotal * Mode->VTotal)); + + /* 18/16. Find actual vertical frame frequency */ + /* ignore - just set the mode flag for interlaced */ + if (Interlaced) + Mode->VTotal *= 2; + + { + char Name[256]; + Name[0] = 0; + + snprintf(Name, 256, "%dx%d", HDisplay, VDisplay); + Mode->name = strdup(Name); + } + + if (Reduced) + Mode->Flags |= V_PHSYNC | V_NVSYNC; + else + Mode->Flags |= V_NHSYNC | V_PVSYNC; + + if (Interlaced) + Mode->Flags |= V_INTERLACE; + + return Mode; +} diff --git a/src/via_display.c b/src/via_display.c new file mode 100644 index 0000000..85af7c0 --- /dev/null +++ b/src/via_display.c @@ -0,0 +1,117 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "via.h" +#include "via_driver.h" +#include "via_vgahw.h" +#include "via_id.h" + +/** + * Enables the second display channel + */ +void +ViaSecondDisplayChannelEnable(ScrnInfoPtr pScrn) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaSecondDisplayChannelEnable\n")); + ViaCrtcMask(hwp, 0x6A, 0x00, 1 << 6); + ViaCrtcMask(hwp, 0x6A, 1 << 7, 1 << 7); + ViaCrtcMask(hwp, 0x6A, 1 << 6, 1 << 6); +} + +/** + * Disables the second display channel + */ +void +ViaSecondDisplayChannelDisable(ScrnInfoPtr pScrn) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaSecondDisplayChannelDisable\n")); + + ViaCrtcMask(hwp, 0x6A, 0x00, 1 << 6); + ViaCrtcMask(hwp, 0x6A, 0x00, 1 << 7); + ViaCrtcMask(hwp, 0x6A, 1 << 6, 1 << 6); +} + +/** + * Initial settings for displays + */ +void +ViaDisplayInit(ScrnInfoPtr pScrn) +{ + VIAPtr pVia= VIAPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaDisplayPreInit\n")); + + ViaSecondDisplayChannelDisable(pScrn); + ViaCrtcMask(hwp, 0x6A, 0x00, 0x3D); + + hwp->writeCrtc(hwp, 0x6B, 0x00); + hwp->writeCrtc(hwp, 0x6C, 0x00); + hwp->writeCrtc(hwp, 0x79, 0x00); + + /* (IGA1 Timing Plus 2, added in VT3259 A3 or later) */ + if (pVia->Chipset != VIA_CLE266 && pVia->Chipset != VIA_KM400) + ViaCrtcMask(hwp, 0x47, 0x00, 0xC8); + +} + +/** + * Enables simultaneous mode + */ +void +ViaDisplayEnableSimultaneous(ScrnInfoPtr pScrn) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaDisplayEnableSimultaneous\n")); + ViaCrtcMask(hwp, 0x6B, 0x08, 0x08); +} + +/** + * Disables simultaneous mode + */ +void +ViaDisplayDisableSimultaneous(ScrnInfoPtr pScrn) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaDisplayDisableSimultaneous\n")); + ViaCrtcMask(hwp, 0x6B, 0x00, 0x08); +} + +/** + * Enables CRT using DPMS registers + */ +void +ViaDisplayEnableCRT(ScrnInfoPtr pScrn) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaDisplayEnableCRT\n")); + ViaCrtcMask(hwp, 0x36, 0x00, 0x30); +} + +/** + * Disables CRT using DPMS registers + */ +void +ViaDisplayDisableCRT(ScrnInfoPtr pScrn) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaDisplayDisableCRT\n")); + ViaCrtcMask(hwp, 0x36, 0x30, 0x30); +} + +/** + * Sets the primary or secondary display stream on CRT + */ +void +ViaDisplaySetStreamOnCRT(ScrnInfoPtr pScrn, Bool primary) { + vgaHWPtr hwp = VGAHWPTR(pScrn); + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaDisplaySetStreamOnCRT\n")); + + if (primary) + ViaSeqMask(hwp, 0x16, 0x00, 0x40); + else + ViaSeqMask(hwp, 0x16, 0x40, 0x40); +}
\ No newline at end of file diff --git a/src/via_driver.c b/src/via_driver.c index 81ba88b..c866475 100644 --- a/src/via_driver.c +++ b/src/via_driver.c @@ -174,42 +174,42 @@ typedef enum { static OptionInfoRec VIAOptions[] = { #ifdef HAVE_DEBUG /* Don't document these */ - {OPTION_PRINTVGAREGS, "PrintVGARegs", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_PRINTTVREGS, "PrintTVRegs", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_I2CSCAN, "I2CScan", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_PRINTVGAREGS, "PrintVGARegs", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_PRINTTVREGS, "PrintTVRegs", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_I2CSCAN, "I2CScan", OPTV_BOOLEAN, {0}, FALSE}, #endif /* HAVE_DEBUG */ - {OPTION_VBEMODES, "VBEModes", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_VBEMODES, "VBEModes", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE}, #ifdef VIA_HAVE_EXA - {OPTION_ACCELMETHOD, "AccelMethod", OPTV_STRING, {0}, FALSE}, - {OPTION_EXA_NOCOMPOSITE, "ExaNoComposite", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_EXA_SCRATCH_SIZE, "ExaScratchSize", OPTV_INTEGER, {0}, FALSE}, + {OPTION_ACCELMETHOD, "AccelMethod", OPTV_STRING, {0}, FALSE}, + {OPTION_EXA_NOCOMPOSITE, "ExaNoComposite", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_EXA_SCRATCH_SIZE, "ExaScratchSize", OPTV_INTEGER, {0}, FALSE}, #endif /* VIA_HAVE_EXA */ - {OPTION_HWCURSOR, "HWCursor", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_SWCURSOR, "SWCursor", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE}, - {OPTION_VIDEORAM, "VideoRAM", OPTV_INTEGER, {0}, FALSE}, - {OPTION_ACTIVEDEVICE, "ActiveDevice", OPTV_ANYSTR, {0}, FALSE}, - {OPTION_BUSWIDTH, "BusWidth", OPTV_ANYSTR, {0}, FALSE}, - {OPTION_CENTER, "Center", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_PANELSIZE, "PanelSize", OPTV_ANYSTR, {0}, FALSE}, - {OPTION_FORCEPANEL, "ForcePanel", OPTV_BOOLEAN, {0}, FALSE}, /* last resort - don't doc */ - {OPTION_TVDOTCRAWL, "TVDotCrawl", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_TVDEFLICKER,"TVDeflicker", OPTV_INTEGER, {0}, FALSE}, - {OPTION_TVPROGRESSIVE, "TVProgressive", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_TVTYPE, "TVType", OPTV_ANYSTR, {0}, FALSE}, - {OPTION_TVOUTPUT, "TVOutput", OPTV_ANYSTR, {0}, FALSE}, - {OPTION_DISABLEVQ, "DisableVQ", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_DISABLEIRQ, "DisableIRQ", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_AGP_DMA, "EnableAGPDMA", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_2D_DMA, "NoAGPFor2D", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_XV_DMA, "NoXVDMA", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_VBE_SAVERESTORE, "VbeSaveRestore", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_HWCURSOR, "HWCursor", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_SWCURSOR, "SWCursor", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE}, + {OPTION_VIDEORAM, "VideoRAM", OPTV_INTEGER, {0}, FALSE}, + {OPTION_ACTIVEDEVICE, "ActiveDevice", OPTV_ANYSTR, {0}, FALSE}, + {OPTION_BUSWIDTH, "BusWidth", OPTV_ANYSTR, {0}, FALSE}, + {OPTION_CENTER, "Center", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_PANELSIZE, "PanelSize", OPTV_ANYSTR, {0}, FALSE}, + {OPTION_FORCEPANEL, "ForcePanel", OPTV_BOOLEAN, {0}, FALSE}, /* last resort - don't doc */ + {OPTION_TVDOTCRAWL, "TVDotCrawl", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_TVDEFLICKER, "TVDeflicker", OPTV_INTEGER, {0}, FALSE}, + {OPTION_TVPROGRESSIVE, "TVProgressive", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_TVTYPE, "TVType", OPTV_ANYSTR, {0}, FALSE}, + {OPTION_TVOUTPUT, "TVOutput", OPTV_ANYSTR, {0}, FALSE}, + {OPTION_DISABLEVQ, "DisableVQ", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_DISABLEIRQ, "DisableIRQ", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_AGP_DMA, "EnableAGPDMA", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_2D_DMA, "NoAGPFor2D", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_XV_DMA, "NoXVDMA", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_VBE_SAVERESTORE, "VbeSaveRestore", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_DISABLE_XV_BW_CHECK, "DisableXvBWCheck", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_MAX_DRIMEM, "MaxDRIMem", OPTV_INTEGER, {0}, FALSE}, - {OPTION_AGPMEM, "AGPMem", OPTV_INTEGER, {0}, FALSE}, - {-1, NULL, OPTV_NONE, {0}, FALSE} + {OPTION_MAX_DRIMEM, "MaxDRIMem", OPTV_INTEGER, {0}, FALSE}, + {OPTION_AGPMEM, "AGPMem", OPTV_INTEGER, {0}, FALSE}, + {-1, NULL, OPTV_NONE, {0}, FALSE} }; @@ -304,20 +304,20 @@ static const char *xaaSymbols[] = { #ifdef VIA_HAVE_EXA static const char *exaSymbols[] = { - "exaGetVersion", - "exaDriverInit", - "exaDriverFini", - "exaOffscreenAlloc", - "exaOffscreenFree", - "exaGetPixmapPitch", - "exaGetPixmapOffset", - "exaWaitSync", + "exaGetVersion", + "exaDriverInit", + "exaDriverFini", + "exaOffscreenAlloc", + "exaOffscreenFree", + "exaGetPixmapPitch", + "exaGetPixmapOffset", + "exaWaitSync", #if (EXA_VERSION_MAJOR >= 2) - "exaDriverAlloc", + "exaDriverAlloc", #else - "exaGetVersion", + "exaGetVersion", #endif - NULL + NULL }; #endif @@ -429,30 +429,30 @@ static pointer VIASetup(pointer module, pointer opts, int *errmaj, int *errmin) xf86AddDriver(&VIA, module, 0); LoaderRefSymLists(vgaHWSymbols, #ifdef USE_FB - fbSymbols, + fbSymbols, #else - cfbSymbols, + cfbSymbols, #endif - ramdacSymbols, - xaaSymbols, + ramdacSymbols, + xaaSymbols, #ifdef VIA_HAVE_EXA - exaSymbols, + exaSymbols, #endif - shadowSymbols, - vbeSymbols, - i2cSymbols, - ddcSymbols, + shadowSymbols, + vbeSymbols, + i2cSymbols, + ddcSymbols, #ifdef XF86DRI - drmSymbols, - driSymbols, + drmSymbols, + driSymbols, #endif - NULL); + NULL); return (pointer) 1; } else { if (errmaj) - *errmaj = LDR_ONCEONLY; + *errmaj = LDR_ONCEONLY; return NULL; } @@ -483,14 +483,19 @@ static Bool VIAGetRec(ScrnInfoPtr pScrn) pBIOSInfo->Panel = (ViaPanelInfoPtr)xnfcalloc(sizeof(ViaPanelInfoRec), 1); if (pBIOSInfo->Panel) { + pBIOSInfo->Panel->NativeModeIndex = VIA_PANEL_INVALID ; pBIOSInfo->Panel->NativeMode = (ViaPanelModePtr)xnfcalloc(sizeof(ViaPanelModeRec), 1); + pBIOSInfo->Panel->CenteredMode = (DisplayModePtr)xnfcalloc(sizeof(DisplayModeRec), 1); pBIOSInfo->Lvds = (ViaLVDSInfoPtr)xnfcalloc(sizeof(ViaLVDSInfoRec), 1); pBIOSInfo->FirstCRTC = (ViaCRTCInfoPtr)xnfcalloc(sizeof(ViaCRTCInfoRec), 1); pBIOSInfo->SecondCRTC = (ViaCRTCInfoPtr)xnfcalloc(sizeof(ViaCRTCInfoRec), 1); - ret = pBIOSInfo->Panel->NativeMode && + pBIOSInfo->Simultaneous = (ViaSimultaneousInfoPtr)xnfcalloc(sizeof(ViaSimultaneousInfoRec), 1); + ret = pBIOSInfo->Panel->NativeMode && + pBIOSInfo->Panel->CenteredMode && pBIOSInfo->Lvds && pBIOSInfo->FirstCRTC && - pBIOSInfo->SecondCRTC ; + pBIOSInfo->SecondCRTC && + pBIOSInfo->Simultaneous ; } } } @@ -513,6 +518,8 @@ static void VIAFreeRec(ScrnInfoPtr pScrn) if (pBIOSInfo->Panel) { if (pBIOSInfo->Panel->NativeMode) xfree(pBIOSInfo->Panel->NativeMode); + if (pBIOSInfo->Panel->CenteredMode) + xfree(pBIOSInfo->Panel->CenteredMode); xfree(pBIOSInfo->Panel); } @@ -520,6 +527,8 @@ static void VIAFreeRec(ScrnInfoPtr pScrn) xfree(pBIOSInfo->FirstCRTC); if (pBIOSInfo->SecondCRTC) xfree(pBIOSInfo->SecondCRTC); + if (pBIOSInfo->Simultaneous) + xfree(pBIOSInfo->Simultaneous); if (pBIOSInfo->Lvds) xfree(pBIOSInfo->Lvds); } @@ -777,6 +786,7 @@ static Bool VIASetupDefaultOptions(ScrnInfoPtr pScrn) */ pVia->pBIOSInfo->FirstCRTC->IsActive = TRUE ; pVia->pBIOSInfo->SecondCRTC->IsActive = TRUE ; + pVia->pBIOSInfo->Simultaneous->IsActive = FALSE ; pVia->pBIOSInfo->Lvds->IsActive = TRUE ; pVia->UseLegacyModeSwitch = FALSE ; @@ -785,8 +795,14 @@ static Bool VIASetupDefaultOptions(ScrnInfoPtr pScrn) pVia->VideoEngine = VIDEO_ENGINE_CME; pVia->agpEnable = FALSE; break; - case VIA_PM800: - case VIA_CX700: + case VIA_CX700: + /* FIXME: + * Only for testing, this code will be removed + * when randr 1.2 support is added + */ + pVia->pBIOSInfo->FirstCRTC->IsActive = TRUE ; + pVia->UseLegacyModeSwitch = FALSE ; + case VIA_PM800: pVia->VideoEngine = VIDEO_ENGINE_CME; pVia->swov.maxWInterp = 1920 ; pVia->swov.maxHInterp = 1080 ; @@ -895,7 +911,7 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) pVIAEnt->IsSecondaryRestored = FALSE; } } else { - pVia->sharedData = xnfcalloc(sizeof(ViaSharedRec),1); + pVia->sharedData = xnfcalloc(sizeof(ViaSharedRec),1); } if (flags & PROBE_DETECT) { @@ -1011,8 +1027,7 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) pVia->ChipRev = pEnt->device->chipRev; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", pVia->ChipRev); - } - else { + } else { /* Read PCI bus 0, dev 0, function 0, index 0xF6 to get chip revision */ pVia->ChipRev = pciReadByte(pciTag(0, 0, 0), 0xF6); } @@ -1059,15 +1074,13 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) pVia->hwcursor = FALSE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Rotating screen clockwise - acceleration disabled.\n"); - } - else if(!xf86NameCmp(s, "CCW")) { + } else if(!xf86NameCmp(s, "CCW")) { pVia->shadowFB = TRUE; pVia->rotate = -1; pVia->hwcursor = FALSE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Rotating screen" "counter clockwise - acceleration disabled.\n"); - } - else { + } else { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "\"%s\" is not a valid" "value for Option \"Rotate\".\n", s); xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -1092,12 +1105,12 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) from = X_DEFAULT; if((s = (char *)xf86GetOptValString(VIAOptions, OPTION_ACCELMETHOD))) { if(!xf86NameCmp(s,"XAA")) { - from = X_CONFIG; - pVia->useEXA = FALSE; + from = X_CONFIG; + pVia->useEXA = FALSE; } else if(!xf86NameCmp(s,"EXA")) { - from = X_CONFIG; - pVia->useEXA = TRUE; + from = X_CONFIG; + pVia->useEXA = TRUE; } } xf86DrvMsg(pScrn->scrnIndex, from, "Using %s acceleration architecture.\n", @@ -1137,12 +1150,12 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) from = X_CONFIG; } if (pVia->IsSecondary) - pVia->hwcursor = FALSE; + pVia->hwcursor = FALSE; if (pVia->hwcursor) xf86DrvMsg(pScrn->scrnIndex, from, "Hardware two-color cursors; " "software full-color cursors.\n"); else - xf86DrvMsg(pScrn->scrnIndex, from, "Using software cursors.\n"); + xf86DrvMsg(pScrn->scrnIndex, from, "Using software cursors.\n"); //pVia->VQEnable = TRUE; from = xf86GetOptValBool(VIAOptions, OPTION_DISABLEVQ, &pVia->VQEnable) @@ -1208,7 +1221,7 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, from, "Xv Bandwidth check is %s.\n", pVia->disableXvBWCheck ? "disabled" : "enabled"); if (pVia->disableXvBWCheck) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "You may get a \"snowy\" screen" " when using the Xv overlay.\n"); } @@ -1237,21 +1250,21 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) /* ActiveDevice Option for device selection */ //pVia->ActiveDevice = 0x00; if ((s = xf86GetOptValString(VIAOptions, OPTION_ACTIVEDEVICE))) { - if (xf86strstr(s, "CRT")) - pVia->ActiveDevice |= VIA_DEVICE_CRT; - if (xf86strstr(s, "LCD")) - pVia->ActiveDevice |= VIA_DEVICE_LCD; - if (xf86strstr(s, "DFP")) /* just treat this the same as LCD */ - pVia->ActiveDevice |= VIA_DEVICE_LCD; - if (xf86strstr(s, "TV")) - pVia->ActiveDevice |= VIA_DEVICE_TV; + if (xf86strstr(s, "CRT")) + pVia->ActiveDevice |= VIA_DEVICE_CRT; + if (xf86strstr(s, "LCD")) + pVia->ActiveDevice |= VIA_DEVICE_LCD; + if (xf86strstr(s, "DFP")) /* just treat this the same as LCD */ + pVia->ActiveDevice |= VIA_DEVICE_LCD; + if (xf86strstr(s, "TV")) + pVia->ActiveDevice |= VIA_DEVICE_TV; } /* Digital Output Bus Width Option */ pBIOSInfo->BusWidth = VIA_DI_12BIT; from = X_DEFAULT; if ((s = xf86GetOptValString(VIAOptions, OPTION_BUSWIDTH))) { - from = X_CONFIG; + from = X_CONFIG; if (!xf86NameCmp(s, "12BIT")) { pBIOSInfo->BusWidth = VIA_DI_12BIT; } else if (!xf86NameCmp(s, "24BIT")) { @@ -1338,7 +1351,7 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "TV Type is HDTV 1080i.\n"); } } else { - xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, + xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "No default TV type is set.\n"); } @@ -1366,7 +1379,7 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "TV Output Signal is YCbCr.\n"); } } else { - xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, + xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "No default TV output signal type is set.\n"); } @@ -1381,6 +1394,7 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) VIAFreeRec(pScrn); return FALSE; } + hwp = VGAHWPTR(pScrn); #ifdef HAVE_DEBUG @@ -1412,7 +1426,7 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) if (pVia->MemClk >= VIA_MEM_END) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unknown Memory clock: %d\n", pVia->MemClk); - pVia->MemClk = VIA_MEM_END - 1; + pVia->MemClk = VIA_MEM_END - 1; } pBIOSInfo->Bandwidth = ViaGetMemoryBandwidth(pScrn); @@ -1525,13 +1539,19 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) } ViaOutputsDetect(pScrn); + if (!ViaOutputsSelect(pScrn)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No outputs possible.\n"); VIAFreeRec(pScrn); return FALSE; } + + if (!pVia->UseLegacyModeSwitch) { + if (pBIOSInfo->Panel->IsActive) + ViaPanelPreInit(pScrn); + } - if (pBIOSInfo->PanelActive && + if (pBIOSInfo->Panel->IsActive && ((pVia->Chipset == VIA_K8M800) || (pVia->Chipset == VIA_PM800) || (pVia->Chipset == VIA_VM800) || @@ -1569,73 +1589,74 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) } } else { - /* Add own Modes */ - ViaModesAttach(pScrn, pScrn->monitor); - - /* - * Setup the ClockRanges, which describe what clock ranges are available, - * and what sort of modes they can be used for. - */ - - clockRanges = xnfalloc(sizeof(ClockRange)); - clockRanges->next = NULL; - clockRanges->minClock = 20000; - clockRanges->maxClock = 230000; - - clockRanges->clockIndex = -1; - clockRanges->interlaceAllowed = TRUE; - clockRanges->doubleScanAllowed = FALSE; - - /* - * xf86ValidateModes will check that the mode HTotal and VTotal values - * don't exceed the chipset's limit if pScrn->maxHValue and - * pScrn->maxVValue are set. Since our VIAValidMode() already takes - * care of this, we don't worry about setting them here. - * - * CLE266A: - * Max Line Pitch: 4080, (FB corruption when higher, driver problem?) - * Max Height: 4096 (and beyond) - * - * CLE266A: primary AdjustFrame only is able to use 24bits, so we are - * limited to 12x11bits; 4080x2048 (~2:1), 3344x2508 (4:3) or 2896x2896 - * (1:1). - * Test CLE266Cx, KM400, KM400A, K8M800, PM800, CN400 please. - * - * We should be able to limit the memory available for a mode to 32MB, - * yet xf86ValidateModes (or miScanLineWidth) fails to catch this properly - * (apertureSize). - */ - - /* Select valid modes from those available */ - i = xf86ValidateModes(pScrn, - pScrn->monitor->Modes, /* availModes */ - pScrn->display->modes, /* modeNames */ - clockRanges, /* list of clock ranges */ - NULL, /* list of line pitches */ - 256, /* mini line pitch */ - 3344, /* max line pitch */ - 32*8, /* pitch inc (bits) */ - 128, /* min height */ - 2508, /* max height */ - pScrn->display->virtualX, /* virtual width */ - pScrn->display->virtualY, /* virtual height */ - pVia->videoRambytes, /* apertureSize */ - LOOKUP_BEST_REFRESH); /* lookup mode flags */ - - - if (i == -1) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "xf86ValidateModes failure\n"); - VIAFreeRec(pScrn); - return FALSE; - } - - xf86PruneDriverModes(pScrn); - - if (i == 0 || pScrn->modes == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); - VIAFreeRec(pScrn); - return FALSE; - } + + /* Add own Modes */ + ViaModesAttach(pScrn, pScrn->monitor); + + /* + * Setup the ClockRanges, which describe what clock ranges are available, + * and what sort of modes they can be used for. + */ + + clockRanges = xnfalloc(sizeof(ClockRange)); + clockRanges->next = NULL; + clockRanges->minClock = 20000; + clockRanges->maxClock = 230000; + + clockRanges->clockIndex = -1; + clockRanges->interlaceAllowed = TRUE; + clockRanges->doubleScanAllowed = FALSE; + + /* + * xf86ValidateModes will check that the mode HTotal and VTotal values + * don't exceed the chipset's limit if pScrn->maxHValue and + * pScrn->maxVValue are set. Since our VIAValidMode() already takes + * care of this, we don't worry about setting them here. + * + * CLE266A: + * Max Line Pitch: 4080, (FB corruption when higher, driver problem?) + * Max Height: 4096 (and beyond) + * + * CLE266A: primary AdjustFrame only is able to use 24bits, so we are + * limited to 12x11bits; 4080x2048 (~2:1), 3344x2508 (4:3) or 2896x2896 + * (1:1). + * Test CLE266Cx, KM400, KM400A, K8M800, PM800, CN400 please. + * + * We should be able to limit the memory available for a mode to 32MB, + * yet xf86ValidateModes (or miScanLineWidth) fails to catch this properly + * (apertureSize). + */ + + /* Select valid modes from those available */ + i = xf86ValidateModes(pScrn, + pScrn->monitor->Modes, /* availModes */ + pScrn->display->modes, /* modeNames */ + clockRanges, /* list of clock ranges */ + NULL, /* list of line pitches */ + 256, /* mini line pitch */ + 3344, /* max line pitch */ + 32*8, /* pitch inc (bits) */ + 128, /* min height */ + 2508, /* max height */ + pScrn->display->virtualX, /* virtual width */ + pScrn->display->virtualY, /* virtual height */ + pVia->videoRambytes, /* apertureSize */ + LOOKUP_BEST_REFRESH); /* lookup mode flags */ + + + if (i == -1) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "xf86ValidateModes failure\n"); + VIAFreeRec(pScrn); + return FALSE; + } + + xf86PruneDriverModes(pScrn); + + if (i == 0 || pScrn->modes == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + VIAFreeRec(pScrn); + return FALSE; + } } @@ -1747,14 +1768,14 @@ static Bool VIAEnterVT(int scrnIndex, int flags) DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIAEnterVT\n")); if (pVia->pVbe) { - if (pVia->vbeSR) - ViaVbeSaveRestore(pScrn, MODE_SAVE); - else - VIASave(pScrn); - ret = ViaVbeSetMode(pScrn, pScrn->currentMode); + if (pVia->vbeSR) + ViaVbeSaveRestore(pScrn, MODE_SAVE); + else + VIASave(pScrn); + ret = ViaVbeSetMode(pScrn, pScrn->currentMode); } else { - VIASave(pScrn); - ret = VIAWriteMode(pScrn, pScrn->currentMode); + VIASave(pScrn); + ret = VIAWriteMode(pScrn, pScrn->currentMode); } vgaHWUnlock(hwp); @@ -1778,16 +1799,16 @@ static Bool VIAEnterVT(int scrnIndex, int flags) #endif if (pVia->NoAccel) { - memset(pVia->FBBase, 0x00, pVia->Bpl * pScrn->virtualY); + memset(pVia->FBBase, 0x00, pVia->Bpl * pScrn->virtualY); } else { - viaAccelFillRect(pScrn, 0, 0, pScrn->displayWidth, pScrn->virtualY, + viaAccelFillRect(pScrn, 0, 0, pScrn->displayWidth, pScrn->virtualY, 0x00000000); - viaAccelSyncMarker(pScrn); + viaAccelSyncMarker(pScrn); } #ifdef XF86DRI if (pVia->directRenderingEnabled) { - DRIUnlock(screenInfo.screens[scrnIndex]); + DRIUnlock(screenInfo.screens[scrnIndex]); } #endif @@ -1805,11 +1826,11 @@ static void VIALeaveVT(int scrnIndex, int flags) #ifdef XF86DRI if (pVia->directRenderingEnabled) { - volatile drm_via_sarea_t *saPriv = (drm_via_sarea_t *) + volatile drm_via_sarea_t *saPriv = (drm_via_sarea_t *) DRIGetSAREAPrivate(pScrn->pScreen); - DRILock(screenInfo.screens[scrnIndex], 0); - saPriv->ctxOwner = ~0; + DRILock(screenInfo.screens[scrnIndex], 0); + saPriv->ctxOwner = ~0; } #endif @@ -1823,8 +1844,8 @@ static void VIALeaveVT(int scrnIndex, int flags) #ifdef XF86DRI if (pVia->directRenderingEnabled) { - VIADRIRingBufferCleanup(pScrn); - viaDRIOffscreenSave(pScrn); + VIADRIRingBufferCleanup(pScrn); + viaDRIOffscreenSave(pScrn); } #endif @@ -1837,17 +1858,49 @@ static void VIALeaveVT(int scrnIndex, int flags) viaSaveVideo(pScrn); if (pVia->hwcursor) - ViaCursorStore(pScrn); + ViaCursorStore(pScrn); if (pVia->pVbe && pVia->vbeSR) - ViaVbeSaveRestore(pScrn, MODE_RESTORE); + ViaVbeSaveRestore(pScrn, MODE_RESTORE); else - VIARestore(pScrn); + VIARestore(pScrn); vgaHWLock(hwp); } +static void +ViaGammaDisable(ScrnInfoPtr pScrn) { + + VIAPtr pVia = VIAPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + + switch (pVia->Chipset) { + case VIA_CLE266: + case VIA_KM400: + ViaSeqMask(hwp, 0x16, 0x00, 0x80); + break; + default: + ViaCrtcMask(hwp, 0x33, 0x00, 0x80); + break; + } + + /* Disable gamma on secondary */ + /* This is needed or the hardware will lockup */ + ViaSeqMask(hwp, 0x1A, 0x00, 0x01); + ViaCrtcMask(hwp, 0x6A, 0x00, 0x02); + switch (pVia->Chipset) { + case VIA_CLE266: + case VIA_KM400: + case VIA_K8M800: + case VIA_PM800: + break; + default: + ViaCrtcMask(hwp, 0x6A, 0x00, 0x20); + break; + } + +} static void VIASave(ScrnInfoPtr pScrn) @@ -1878,7 +1931,7 @@ VIASave(ScrnInfoPtr pScrn) pVia->SavedReg = pVia1->SavedReg; } else { - DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Primary\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Primary\n")); vgaHWProtect(pScrn, TRUE); @@ -1887,34 +1940,34 @@ VIASave(ScrnInfoPtr pScrn) else vgaHWSave(pScrn, &hwp->SavedReg, VGA_SR_MODE); - /* Unlock extended regs */ - hwp->writeSeq(hwp, 0x10, 0x01); - - Regs->SR14 = hwp->readSeq(hwp, 0x14); - Regs->SR15 = hwp->readSeq(hwp, 0x15); - Regs->SR16 = hwp->readSeq(hwp, 0x16); - Regs->SR17 = hwp->readSeq(hwp, 0x17); - Regs->SR18 = hwp->readSeq(hwp, 0x18); - Regs->SR19 = hwp->readSeq(hwp, 0x19); - Regs->SR1A = hwp->readSeq(hwp, 0x1A); - Regs->SR1B = hwp->readSeq(hwp, 0x1B); - Regs->SR1C = hwp->readSeq(hwp, 0x1C); - Regs->SR1D = hwp->readSeq(hwp, 0x1D); - Regs->SR1E = hwp->readSeq(hwp, 0x1E); - Regs->SR1F = hwp->readSeq(hwp, 0x1F); - - Regs->SR22 = hwp->readSeq(hwp, 0x22); - Regs->SR23 = hwp->readSeq(hwp, 0x23); - Regs->SR24 = hwp->readSeq(hwp, 0x24); - Regs->SR25 = hwp->readSeq(hwp, 0x25); - Regs->SR26 = hwp->readSeq(hwp, 0x26); - Regs->SR27 = hwp->readSeq(hwp, 0x27); - Regs->SR28 = hwp->readSeq(hwp, 0x28); - Regs->SR29 = hwp->readSeq(hwp, 0x29); - Regs->SR2A = hwp->readSeq(hwp, 0x2A); - Regs->SR2B = hwp->readSeq(hwp, 0x2B); - - Regs->SR2E = hwp->readSeq(hwp, 0x2E); + /* Unlock extended regs */ + hwp->writeSeq(hwp, 0x10, 0x01); + + Regs->SR14 = hwp->readSeq(hwp, 0x14); + Regs->SR15 = hwp->readSeq(hwp, 0x15); + Regs->SR16 = hwp->readSeq(hwp, 0x16); + Regs->SR17 = hwp->readSeq(hwp, 0x17); + Regs->SR18 = hwp->readSeq(hwp, 0x18); + Regs->SR19 = hwp->readSeq(hwp, 0x19); + Regs->SR1A = hwp->readSeq(hwp, 0x1A); + Regs->SR1B = hwp->readSeq(hwp, 0x1B); + Regs->SR1C = hwp->readSeq(hwp, 0x1C); + Regs->SR1D = hwp->readSeq(hwp, 0x1D); + Regs->SR1E = hwp->readSeq(hwp, 0x1E); + Regs->SR1F = hwp->readSeq(hwp, 0x1F); + + Regs->SR22 = hwp->readSeq(hwp, 0x22); + Regs->SR23 = hwp->readSeq(hwp, 0x23); + Regs->SR24 = hwp->readSeq(hwp, 0x24); + Regs->SR25 = hwp->readSeq(hwp, 0x25); + Regs->SR26 = hwp->readSeq(hwp, 0x26); + Regs->SR27 = hwp->readSeq(hwp, 0x27); + Regs->SR28 = hwp->readSeq(hwp, 0x28); + Regs->SR29 = hwp->readSeq(hwp, 0x29); + Regs->SR2A = hwp->readSeq(hwp, 0x2A); + Regs->SR2B = hwp->readSeq(hwp, 0x2B); + + Regs->SR2E = hwp->readSeq(hwp, 0x2E); Regs->SR44 = hwp->readSeq(hwp, 0x44); Regs->SR45 = hwp->readSeq(hwp, 0x45); @@ -1935,32 +1988,36 @@ VIASave(ScrnInfoPtr pScrn) DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Crtc...\n")); - Regs->CR13 = hwp->readCrtc(hwp, 0x13); - - Regs->CR32 = hwp->readCrtc(hwp, 0x32); - Regs->CR33 = hwp->readCrtc(hwp, 0x33); - Regs->CR34 = hwp->readCrtc(hwp, 0x34); - Regs->CR35 = hwp->readCrtc(hwp, 0x35); - Regs->CR36 = hwp->readCrtc(hwp, 0x36); - - Regs->CR49 = hwp->readCrtc(hwp, 0x49); - - DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "TVSave...\n")); - if (pBIOSInfo->TVI2CDev) - ViaTVSave(pScrn); - + Regs->CR13 = hwp->readCrtc(hwp, 0x13); + Regs->CR32 = hwp->readCrtc(hwp, 0x32); + Regs->CR33 = hwp->readCrtc(hwp, 0x33); + Regs->CR34 = hwp->readCrtc(hwp, 0x34); + Regs->CR35 = hwp->readCrtc(hwp, 0x35); + Regs->CR36 = hwp->readCrtc(hwp, 0x36); + + Regs->CR49 = hwp->readCrtc(hwp, 0x49); + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "TVSave...\n")); + if (pBIOSInfo->TVI2CDev) + ViaTVSave(pScrn); + /* Save LCD control regs */ for (i = 0; i < 68; i++) - Regs->CRTCRegs[i] = hwp->readCrtc(hwp, i + 0x50); - - Regs->CRA0 = hwp->readCrtc(hwp, 0xA0); - Regs->CRA1 = hwp->readCrtc(hwp, 0xA1); - Regs->CRA2 = hwp->readCrtc(hwp, 0xA2); - - Regs->CR97 = hwp->readCrtc(hwp, 0x97); - Regs->CR99 = hwp->readCrtc(hwp, 0x99); - Regs->CR9B = hwp->readCrtc(hwp, 0x9B); - Regs->CR9F = hwp->readCrtc(hwp, 0x9F); + Regs->CRTCRegs[i] = hwp->readCrtc(hwp, i + 0x50); + + if (pVia->Chipset != VIA_CLE266 + && pVia->Chipset != VIA_KM400) { + + Regs->CRA0 = hwp->readCrtc(hwp, 0xA0); + Regs->CRA1 = hwp->readCrtc(hwp, 0xA1); + Regs->CRA2 = hwp->readCrtc(hwp, 0xA2); + + Regs->CR97 = hwp->readCrtc(hwp, 0x97); + Regs->CR99 = hwp->readCrtc(hwp, 0x99); + Regs->CR9B = hwp->readCrtc(hwp, 0x9B); + Regs->CR9F = hwp->readCrtc(hwp, 0x9F); + + } vgaHWProtect(pScrn, FALSE); } @@ -1988,9 +2045,11 @@ VIARestore(ScrnInfoPtr pScrn) hwp->writeCrtc(hwp, 0x6A, 0x00); hwp->writeCrtc(hwp, 0x6B, 0x00); hwp->writeCrtc(hwp, 0x6C, 0x00); + + ViaGammaDisable(pScrn); if (pBIOSInfo->TVI2CDev) - ViaTVRestore(pScrn); + ViaTVRestore(pScrn); /* Restore the standard vga regs */ if (xf86IsPrimaryPci(pVia->PciInfo)) @@ -2058,18 +2117,23 @@ VIARestore(ScrnInfoPtr pScrn) /* Restore LCD control regs */ for (i = 0; i < 68; i++) hwp->writeCrtc(hwp, i + 0x50, Regs->CRTCRegs[i]); + + if (pVia->Chipset != VIA_CLE266 + && pVia->Chipset != VIA_KM400) { - hwp->writeCrtc(hwp, 0xA0, Regs->CRA0); - hwp->writeCrtc(hwp, 0xA1, Regs->CRA1); - hwp->writeCrtc(hwp, 0xA2, Regs->CRA2); -/* - hwp->writeCrtc(hwp, 0x97, Regs->CR97); - hwp->writeCrtc(hwp, 0x99, Regs->CR99); - hwp->writeCrtc(hwp, 0x9B, Regs->CR9B); - hwp->writeCrtc(hwp, 0x9F, Regs->CR9F); -*/ - if (pBIOSInfo->PanelActive) - ViaLCDPower(pScrn, TRUE); + hwp->writeCrtc(hwp, 0xA0, Regs->CRA0); + hwp->writeCrtc(hwp, 0xA1, Regs->CRA1); + hwp->writeCrtc(hwp, 0xA2, Regs->CRA2); + + hwp->writeCrtc(hwp, 0x97, Regs->CR97); + hwp->writeCrtc(hwp, 0x99, Regs->CR99); + hwp->writeCrtc(hwp, 0x9B, Regs->CR9B); + hwp->writeCrtc(hwp, 0x9F, Regs->CR9F); + + } + + if (pBIOSInfo->Panel->IsActive) + ViaLCDPower(pScrn, TRUE); ViaDisablePrimaryFIFO(pScrn); @@ -2080,6 +2144,48 @@ VIARestore(ScrnInfoPtr pScrn) vgaHWProtect(pScrn, FALSE); } +static void +ViaMMIOEnable(ScrnInfoPtr pScrn) +{ + VIAPtr pVia = VIAPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + + switch (pVia->Chipset) { + case VIA_K8M890: + case VIA_CX700: + case VIA_P4M900: + ViaSeqMask(hwp, 0x1A, 0x08, 0x08); + break; + default: + if (pVia->IsSecondary) + ViaSeqMask(hwp, 0x1A, 0x38, 0x38); + else + ViaSeqMask(hwp, 0x1A, 0x68, 0x68); + break; + } + + +} + +static void +ViaMMIODisable(ScrnInfoPtr pScrn) +{ + VIAPtr pVia = VIAPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + + switch (pVia->Chipset) { + case VIA_K8M890: + case VIA_CX700: + case VIA_P4M900: + ViaSeqMask(VGAHWPTR(pScrn), 0x1A, 0x00, 0x08); + break; + default: + ViaSeqMask(VGAHWPTR(pScrn), 0x1A, 0x00, 0x60); + break; + } + +} + static Bool VIAMapMMIO(ScrnInfoPtr pScrn) { @@ -2090,6 +2196,18 @@ VIAMapMMIO(ScrnInfoPtr pScrn) pVia->FrameBufferBase = pVia->PciInfo->memBase[0]; pVia->MmioBase = pVia->PciInfo->memBase[1]; + if (!pVia->FrameBufferBase) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Frame Buffer Base could not be detected.\n"); + return FALSE; + } + + if (!pVia->MmioBase) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "MMIO Base could not be detected.\n"); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "mapping MMIO @ 0x%lx with size 0x%x\n", pVia->MmioBase, VIA_MMIO_REGSIZE); @@ -2097,6 +2215,12 @@ VIAMapMMIO(ScrnInfoPtr pScrn) pVia->MapBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pVia->PciTag, pVia->MmioBase, VIA_MMIO_REGSIZE); + if (!pVia->MapBase) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "MMIO could not be mapped.\n"); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "mapping BitBlt MMIO @ 0x%lx with size 0x%x\n", pVia->MmioBase + VIA_MMIO_BLTBASE, VIA_MMIO_BLTSIZE); @@ -2105,12 +2229,12 @@ VIAMapMMIO(ScrnInfoPtr pScrn) pVia->MmioBase + VIA_MMIO_BLTBASE, VIA_MMIO_BLTSIZE); - if (!pVia->MapBase || !pVia->BltBase) { + if (!pVia->BltBase) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Internal error: cound not map registers\n"); + "BitBlit could not be mapped.\n"); return FALSE; } - + /* Memory mapped IO for Video Engine */ pVia->VidMapBase = pVia->MapBase + 0x200; /* Memory mapped IO for Mpeg Engine */ @@ -2118,94 +2242,90 @@ VIAMapMMIO(ScrnInfoPtr pScrn) /* Set up MMIO vgaHW */ { - vgaHWPtr hwp = VGAHWPTR(pScrn); - CARD8 val; - - vgaHWSetMmioFuncs(hwp, pVia->MapBase, 0x8000); - - val = hwp->readEnable(hwp); - hwp->writeEnable(hwp, val | 0x01); - - val = hwp->readMiscOut(hwp); - hwp->writeMiscOut(hwp, val | 0x01); - - /* Unlock Extended IO Space */ - hwp->writeSeq(hwp, 0x10, 0x01); - - /* Enable MMIO */ - if (pVia->IsSecondary) - ViaSeqMask(hwp, 0x1A, 0x38, 0x38); - else - ViaSeqMask(hwp, 0x1A, 0x68, 0x68); - - vgaHWGetIOBase(hwp); + vgaHWPtr hwp = VGAHWPTR(pScrn); + CARD8 val; + + vgaHWGetIOBase(hwp); + + val = hwp->readEnable(hwp); + hwp->writeEnable(hwp, val | 0x01); + + val = hwp->readMiscOut(hwp); + hwp->writeMiscOut(hwp, val | 0x01); + + /* Unlock Extended IO Space */ + ViaSeqMask(hwp, 0x10, 0x01, 0x01); + + ViaMMIOEnable(pScrn); + + vgaHWSetMmioFuncs(hwp, pVia->MapBase, 0x8000); + + /* unlock crtc */ + ViaCrtcMask(hwp, 0x47, 0x00, 0x01); } - + return TRUE; } -static Bool VIAMapFB(ScrnInfoPtr pScrn) +static Bool +VIAMapFB(ScrnInfoPtr pScrn) { - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAMapFB\n")); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "mapping framebuffer @ 0x%lx with size 0x%lx\n", - pVia->FrameBufferBase, pVia->videoRambytes); + "mapping framebuffer @ 0x%lx with size 0x%lx\n", + pVia->FrameBufferBase, pVia->videoRambytes); if (pVia->videoRambytes) { - /* - * FIXME: This is a hack to get rid of offending wrongly sized - * MTRR regions set up by the VIA BIOS. Should be taken care of - * in the OS support layer. - */ - - unsigned char *tmp; - tmp = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, - pVia->PciTag, pVia->FrameBufferBase, - pVia->videoRambytes); - xf86UnMapVidMem(pScrn->scrnIndex, (pointer)tmp, - pVia->videoRambytes); + /* + * FIXME: This is a hack to get rid of offending wrongly sized + * MTRR regions set up by the VIA BIOS. Should be taken care of + * in the OS support layer. + */ - /* - * And, as if this wasn't enough, 2.6 series kernels doesn't - * remove MTRR regions on the first attempt. Try again. - */ + unsigned char *tmp; + tmp = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pVia->PciTag, + pVia->FrameBufferBase, pVia->videoRambytes); + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)tmp, pVia->videoRambytes); - tmp = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, - pVia->PciTag, pVia->FrameBufferBase, - pVia->videoRambytes); - xf86UnMapVidMem(pScrn->scrnIndex, (pointer)tmp, - pVia->videoRambytes); + /* + * And, as if this wasn't enough, 2.6 series kernels doesn't + * remove MTRR regions on the first attempt. Try again. + */ - /* - * End of hack. - */ + tmp = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pVia->PciTag, + pVia->FrameBufferBase, pVia->videoRambytes); + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)tmp, pVia->videoRambytes); + + /* + * End of hack. + */ pVia->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, - pVia->PciTag, pVia->FrameBufferBase, - pVia->videoRambytes); + pVia->PciTag, pVia->FrameBufferBase, pVia->videoRambytes); if (!pVia->FBBase) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Internal error: could not map framebuffer\n"); + "Internal error: could not map framebuffer\n"); return FALSE; } - pVia->FBFreeStart = (pScrn->displayWidth * pScrn->bitsPerPixel >> 3) * - pScrn->virtualY; + pVia->FBFreeStart = (pScrn->displayWidth * pScrn->bitsPerPixel >> 3) + * pScrn->virtualY; pVia->FBFreeEnd = pVia->videoRambytes; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Frame buffer start: %p, free start: 0x%x end: 0x%x\n", - pVia->FBBase, pVia->FBFreeStart, pVia->FBFreeEnd); + "Frame buffer start: %p, free start: 0x%x end: 0x%x\n", + pVia->FBBase, pVia->FBFreeStart, pVia->FBFreeEnd); } pScrn->memPhysBase = pVia->PciInfo->memBase[0]; pScrn->fbOffset = 0; - if(pVia->IsSecondary) pScrn->fbOffset = pScrn->videoRam << 10; + if (pVia->IsSecondary) + pScrn->fbOffset = pScrn->videoRam << 10; return TRUE; } @@ -2218,9 +2338,8 @@ VIAUnmapMem(ScrnInfoPtr pScrn) DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAUnmapMem\n")); - /* Disable MMIO */ - ViaSeqMask(VGAHWPTR(pScrn), 0x1A, 0x00, 0x60); - + ViaMMIODisable(pScrn); + if (pVia->MapBase) xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pVia->MapBase, VIA_MMIO_REGSIZE); @@ -2254,9 +2373,9 @@ VIALoadRgbLut(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, Visu index = indices[i]; hwp->writeDacWriteAddr(hwp, index * 4); for (j = 0; j < 4; j++) { - hwp->writeDacData(hwp, colors[index/2].red); - hwp->writeDacData(hwp, colors[index].green); - hwp->writeDacData(hwp, colors[index/2].blue); + hwp->writeDacData(hwp, colors[index/2].red); + hwp->writeDacData(hwp, colors[index].green); + hwp->writeDacData(hwp, colors[index/2].blue); } } break; @@ -2281,88 +2400,98 @@ VIALoadRgbLut(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, Visu static void VIALoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, - LOCO *colors, VisualPtr pVisual) + LOCO *colors, VisualPtr pVisual) { vgaHWPtr hwp = VGAHWPTR(pScrn); - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); + VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo ; + int i, index; int SR1A, SR1B, CR67, CR6A; DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIALoadPalette\n")); if (pScrn->bitsPerPixel != 8) { - switch(pVia->Chipset) { - case VIA_CLE266: - case VIA_KM400: - ViaSeqMask(hwp, 0x16, 0x80, 0x80); - break; - case VIA_P4M900: - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "VIALoadPalette: Function not implemented for this chipset.\n"); - return; - default: - ViaCrtcMask(hwp, 0x33, 0x80, 0x80); - break; - } + + if (pBIOSInfo->FirstCRTC->IsActive) { + + switch (pVia->Chipset) { + case VIA_CLE266: + case VIA_KM400: + ViaSeqMask(hwp, 0x16, 0x80, 0x80); + break; + default: + ViaCrtcMask(hwp, 0x33, 0x80, 0x80); + break; + } - ViaSeqMask(hwp, 0x1A, 0x00, 0x01); - VIALoadRgbLut(pScrn, numColors, indices, colors, pVisual); - - /* If secondary is enabled, adjust its palette too. */ - if (hwp->readCrtc(hwp, 0x6A) & 0x80) { - ViaSeqMask(hwp, 0x1A, 0x01, 0x01); - ViaCrtcMask(hwp, 0x6A, 0x02, 0x02); - switch(pVia->Chipset) { - case VIA_K8M800: - case VIA_PM800: - break; - default: - ViaSeqMask(hwp, 0x6A, 0x20, 0x20); - break; - } - VIALoadRgbLut(pScrn, numColors, indices, colors, pVisual); - } + ViaSeqMask(hwp, 0x1A, 0x00, 0x01); + VIALoadRgbLut(pScrn, numColors, indices, colors, pVisual); + } - return; - } + /* If secondary is enabled, adjust its palette too. */ + if (pBIOSInfo->SecondCRTC->IsActive) { + if (!(pVia->Chipset == VIA_CLE266 && CLE266_REV_IS_AX(pVia->ChipRev))) { + ViaSeqMask(hwp, 0x1A, 0x01, 0x01); + ViaCrtcMask(hwp, 0x6A, 0x02, 0x02); + switch (pVia->Chipset) { + case VIA_CLE266: + case VIA_KM400: + case VIA_K8M800: + case VIA_PM800: + break; + default: + ViaCrtcMask(hwp, 0x6A, 0x20, 0x20); + break; + } + VIALoadRgbLut(pScrn, numColors, indices, colors, pVisual); + } + } - SR1A = hwp->readSeq(hwp, 0x1A); - SR1B = hwp->readSeq(hwp, 0x1B); - CR67 = hwp->readCrtc(hwp, 0x67); - CR6A = hwp->readCrtc(hwp, 0x6A); + } else { + + SR1A = hwp->readSeq(hwp, 0x1A); + SR1B = hwp->readSeq(hwp, 0x1B); + CR67 = hwp->readCrtc(hwp, 0x67); + CR6A = hwp->readCrtc(hwp, 0x6A); + + if (pBIOSInfo->SecondCRTC->IsActive) { + ViaSeqMask(hwp, 0x1A, 0x01, 0x01); + ViaSeqMask(hwp, 0x1B, 0x80, 0x80); + ViaCrtcMask(hwp, 0x67, 0x00, 0xC0); + ViaCrtcMask(hwp, 0x6A, 0xC0, 0xC0); + } - if (pVia->IsSecondary) { - ViaSeqMask(hwp, 0x1A, 0x01, 0x01); - ViaSeqMask(hwp, 0x1B, 0x80, 0x80); - ViaCrtcMask(hwp, 0x67, 0x00, 0xC0); - ViaCrtcMask(hwp, 0x6A, 0xC0, 0xC0); - } - - for (i = 0; i < numColors; i++) { - index = indices[i]; - hwp->writeDacWriteAddr(hwp, index); - hwp->writeDacData(hwp, colors[index].red); - hwp->writeDacData(hwp, colors[index].green); - hwp->writeDacData(hwp, colors[index].blue); - } + for (i = 0; i < numColors; i++) { + index = indices[i]; + hwp->writeDacWriteAddr(hwp, index); + hwp->writeDacData(hwp, colors[index].red); + hwp->writeDacData(hwp, colors[index].green); + hwp->writeDacData(hwp, colors[index].blue); + } - if (pVia->IsSecondary) { - hwp->writeSeq(hwp, 0x1A, SR1A); - hwp->writeSeq(hwp, 0x1B, SR1B); - hwp->writeCrtc(hwp, 0x67, CR67); - hwp->writeCrtc(hwp, 0x6A, CR6A); - - /* Screen 0 palette was changed by mode setting of Screen 1, - * so load again */ - for (i = 0; i < numColors; i++) { - index = indices[i]; - hwp->writeDacWriteAddr(hwp, index); - hwp->writeDacData(hwp, colors[index].red); - hwp->writeDacData(hwp, colors[index].green); - hwp->writeDacData(hwp, colors[index].blue); + if (pBIOSInfo->SecondCRTC->IsActive) { + hwp->writeSeq(hwp, 0x1A, SR1A); + hwp->writeSeq(hwp, 0x1B, SR1B); + hwp->writeCrtc(hwp, 0x67, CR67); + hwp->writeCrtc(hwp, 0x6A, CR6A); + + /* Screen 0 palette was changed by mode setting of Screen 1, + * so load again */ + for (i = 0; i < numColors; i++) { + index = indices[i]; + hwp->writeDacWriteAddr(hwp, index); + hwp->writeDacData(hwp, colors[index].red); + hwp->writeDacData(hwp, colors[index].green); + hwp->writeDacData(hwp, colors[index].blue); + } } + } + } + /* * */ @@ -2399,8 +2528,10 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } } else { vgaHWBlankScreen(pScrn, FALSE); - if (!pVia->IsSecondary) + + if (!pVia->UseLegacyModeSwitch && !pVia->IsSecondary) ViaCRTCInit(pScrn); + if (!VIAWriteMode(pScrn, pScrn->currentMode)) { vgaHWBlankScreen(pScrn, TRUE); return FALSE; @@ -2437,7 +2568,7 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- Visuals set up\n")); if (!VIAInternalScreenInit(scrnIndex, pScreen)) - return FALSE; + return FALSE; xf86SetBlackWhitePixels(pScreen); DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- B & W\n")); @@ -2511,13 +2642,13 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) #ifdef XF86DRI if (pVia->directRenderingEnabled) - pVia->directRenderingEnabled = VIADRIFinishScreenInit(pScreen); + pVia->directRenderingEnabled = VIADRIFinishScreenInit(pScreen); if (pVia->directRenderingEnabled) { - VIADRIPtr pVIADRI = pVia->pDRIInfo->devPrivate; + VIADRIPtr pVIADRI = pVia->pDRIInfo->devPrivate; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering enabled\n"); - pVia->agpDMA = pVia->dma2d && pVIADRI->ringBufActive; + pVia->agpDMA = pVia->dma2d && pVIADRI->ringBufActive; } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n"); } @@ -2526,7 +2657,7 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) viaFinishInitAccel(pScreen); if (pVia->NoAccel) { - memset(pVia->FBBase, 0x00, pVia->videoRambytes); + memset(pVia->FBBase, 0x00, pVia->videoRambytes); } else { #ifdef XF86DRI if (pVia->directRenderingEnabled) @@ -2538,7 +2669,7 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) viaAccelSyncMarker(pScrn); #ifdef XF86DRI if (pVia->directRenderingEnabled) - DRIUnlock(screenInfo.screens[scrnIndex]); + DRIUnlock(screenInfo.screens[scrnIndex]); #endif } vgaHWBlankScreen(pScrn, TRUE); @@ -2557,10 +2688,10 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) AvailFBArea.y1 = 0; AvailFBArea.x2 = pScrn->displayWidth; AvailFBArea.y2 = pScrn->virtualY + 1; - pVia->FBFreeStart=(AvailFBArea.y2 + 1)*pVia->Bpl; - xf86InitFBManager(pScreen, &AvailFBArea); - VIAInitLinear(pScreen); - pVia->driSize = (pVia->FBFreeEnd - pVia->FBFreeStart - pVia->Bpl); + pVia->FBFreeStart=(AvailFBArea.y2 + 1)*pVia->Bpl; + xf86InitFBManager(pScreen, &AvailFBArea); + VIAInitLinear(pScreen); + pVia->driSize = (pVia->FBFreeEnd - pVia->FBFreeStart - pVia->Bpl); } viaInitVideo(pScreen); @@ -2570,13 +2701,13 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) #ifdef HAVE_DEBUG if (pVia->PrintVGARegs) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAScreenInit: Printing VGA registers.\n"); - ViaVgahwPrint(VGAHWPTR(pScrn)); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAScreenInit: Printing VGA registers.\n"); + ViaVgahwPrint(VGAHWPTR(pScrn)); } if (pVia->PrintTVRegs) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAScreenInit: Printing TV registers.\n"); - ViaTVPrintRegs(pScrn); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAScreenInit: Printing TV registers.\n"); + ViaTVPrintRegs(pScrn); } #endif @@ -2657,11 +2788,11 @@ VIAWriteMode(ScrnInfoPtr pScrn, DisplayModePtr mode) if (pVia->UseLegacyModeSwitch) { if (!pVia->IsSecondary) - ViaModePrimary(pScrn, mode); + ViaModePrimaryLegacy(pScrn, mode); else - ViaModeSecondary(pScrn, mode); + ViaModeSecondaryLegacy(pScrn, mode); } else { - + ViaModeSet(pScrn, mode); } } else { @@ -2676,12 +2807,12 @@ VIAWriteMode(ScrnInfoPtr pScrn, DisplayModePtr mode) * chipsets as well */ if (pVia->Chipset == VIA_P4M900 && - pVia->pBIOSInfo->PanelActive) { + pVia->pBIOSInfo->Panel->IsActive) { /* * Since we are using virtual, we need to adjust * the offset to match the framebuffer alignment */ - if (pScrn->displayWidth != mode->HDisplay) + if (pScrn->displayWidth != mode->CrtcHDisplay) ViaSecondCRTCHorizontalOffset(pScrn); } } @@ -2689,9 +2820,9 @@ VIAWriteMode(ScrnInfoPtr pScrn, DisplayModePtr mode) /* Enable the graphics engine. */ if (!pVia->NoAccel) { #if defined(XF86DRI) || defined(VIA_HAVE_EXA) - VIAInitialize3DEngine(pScrn); + VIAInitialize3DEngine(pScrn); #endif - viaInitialize2DEngine(pScrn); + viaInitialize2DEngine(pScrn); } VIAAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); @@ -2699,43 +2830,42 @@ VIAWriteMode(ScrnInfoPtr pScrn, DisplayModePtr mode) } -static Bool VIACloseScreen(int scrnIndex, ScreenPtr pScreen) +static Bool +VIACloseScreen(int scrnIndex, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - vgaHWPtr hwp = VGAHWPTR(pScrn); - VIAPtr pVia = VIAPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIACloseScreen\n")); /* Is the display currently visible ? */ - if(pScrn->vtSema) - { + if (pScrn->vtSema) { #ifdef XF86DRI if (pVia->directRenderingEnabled) - DRILock(screenInfo.screens[scrnIndex], 0); + DRILock(screenInfo.screens[scrnIndex], 0); #endif /* Wait Hardware Engine idle to exit graphical mode */ viaAccelSync(pScrn); - - /* A soft reset Fixes 3D Hang after X restart */ - if (pVia->Chipset != VIA_K8M890 && pVia->Chipset != VIA_P4M900) + /* A soft reset Fixes 3D Hang after X restart */ + if (pVia->Chipset != VIA_K8M890 && pVia->Chipset != VIA_P4M900) hwp->writeSeq(hwp, 0x1A, pVia->SavedReg.SR1A | 0x40); - if (!pVia->IsSecondary) { + if (!pVia->IsSecondary) { /* Turn off all video activities */ - viaExitVideo(pScrn); + viaExitVideo(pScrn); VIAHideCursor(pScrn); } if (pVia->VQEnable) - viaDisableVQ(pScrn); + viaDisableVQ(pScrn); } #ifdef XF86DRI if (pVia->directRenderingEnabled) - VIADRICloseScreen(pScreen); + VIADRICloseScreen(pScreen); #endif viaExitAccel(pScreen); @@ -2753,12 +2883,12 @@ static Bool VIACloseScreen(int scrnIndex, ScreenPtr pScreen) } if (pScrn->vtSema) { - if (pVia->pVbe && pVia->vbeSR) - ViaVbeSaveRestore(pScrn, MODE_RESTORE); - else - VIARestore(pScrn); + if (pVia->pVbe && pVia->vbeSR) + ViaVbeSaveRestore(pScrn, MODE_RESTORE); + else + VIARestore(pScrn); - vgaHWLock(hwp); + vgaHWLock(hwp); VIAUnmapMem(pScrn); } pScrn->vtSema = FALSE; @@ -2770,7 +2900,8 @@ static Bool VIACloseScreen(int scrnIndex, ScreenPtr pScreen) * This only gets called when a screen is being deleted. It does not * get called routinely at the end of a server generation. */ -static void VIAFreeScreen(int scrnIndex, int flags) +static void +VIAFreeScreen(int scrnIndex, int flags) { DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIAFreeScreen\n")); @@ -2820,37 +2951,37 @@ static Bool VIASwitchMode(int scrnIndex, DisplayModePtr mode, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - VIAPtr pVia = VIAPTR(pScrn); - Bool ret; - + VIAPtr pVia= VIAPTR(pScrn); + Bool ret; + DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIASwitchMode\n")); - + #ifdef XF86DRI if (pVia->directRenderingEnabled) - DRILock(screenInfo.screens[scrnIndex], 0); + DRILock(screenInfo.screens[scrnIndex], 0); #endif - + viaAccelSync(pScrn); - + #ifdef XF86DRI if (pVia->directRenderingEnabled) - VIADRIRingBufferCleanup(pScrn); + VIADRIRingBufferCleanup(pScrn); #endif - + if (pVia->VQEnable) - viaDisableVQ(pScrn); + viaDisableVQ(pScrn); ret = VIAWriteMode(pScrn, mode); #ifdef XF86DRI if (pVia->directRenderingEnabled) { - kickVblank(pScrn); - VIADRIRingBufferInit(pScrn); - DRIUnlock(screenInfo.screens[scrnIndex]); + kickVblank(pScrn); + VIADRIRingBufferInit(pScrn); + DRIUnlock(screenInfo.screens[scrnIndex]); } #endif return ret; - + } @@ -2860,104 +2991,101 @@ VIADPMS(ScrnInfoPtr pScrn, int mode, int flags) vgaHWPtr hwp = VGAHWPTR(pScrn); VIAPtr pVia= VIAPTR(pScrn); VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; - CARD8 val; if (pVia->pVbe) { + ViaVbeDPMS(pScrn, mode, flags); - return; - } - - /* Clear DPMS setting */ - val = hwp->readCrtc(hwp, 0x36); - val &= 0xCF; - - /* Turn Off CRT, if user doesn't want crt on */ - if (!pVia->IsSecondary && !pBIOSInfo->CrtActive) - val |= 0x30; - - switch (mode) { - case DPMSModeOn: - - if (pBIOSInfo->Lvds->IsActive) - ViaLVDSPower(pScrn, TRUE); - - if (pBIOSInfo->PanelActive) - ViaLCDPower(pScrn, TRUE); + + } else { - if (pBIOSInfo->TVActive) - ViaTVPower(pScrn, TRUE); + switch (mode) { + case DPMSModeOn: - hwp->writeCrtc(hwp, 0x36, val); - break; - case DPMSModeStandby: - case DPMSModeSuspend: - case DPMSModeOff: - - if (pBIOSInfo->Lvds->IsActive) - ViaLVDSPower(pScrn, FALSE); - - if (pBIOSInfo->PanelActive) - ViaLCDPower(pScrn, FALSE); + if (pBIOSInfo->Lvds->IsActive) + ViaLVDSPower(pScrn, TRUE); + + if (pBIOSInfo->CrtActive) + ViaDisplayEnableCRT(pScrn); + + if (pBIOSInfo->Panel->IsActive) + ViaLCDPower(pScrn, TRUE); - if (pBIOSInfo->TVActive) - ViaTVPower(pScrn, FALSE); + if (pBIOSInfo->TVActive) + ViaTVPower(pScrn, TRUE); + + if (pBIOSInfo->Simultaneous->IsActive) + ViaDisplayEnableSimultaneous(pScrn); - val |= 0x30; - hwp->writeCrtc(hwp, 0x36, val); - break; - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid DPMS mode %d\n", - mode); - break; + break; + case DPMSModeStandby: + case DPMSModeSuspend: + case DPMSModeOff: + + if (pBIOSInfo->Lvds->IsActive) + ViaLVDSPower(pScrn, FALSE); + + if (pBIOSInfo->CrtActive) + ViaDisplayDisableCRT(pScrn); + + if (pBIOSInfo->Panel->IsActive) + ViaLCDPower(pScrn, FALSE); + + if (pBIOSInfo->TVActive) + ViaTVPower(pScrn, FALSE); + + if (pBIOSInfo->Simultaneous->IsActive) + ViaDisplayDisableSimultaneous(pScrn); + + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid DPMS mode %d\n", + mode); + break; + } } - return; + } #if defined(XF86DRI) || defined(VIA_HAVE_EXA) void VIAInitialize3DEngine(ScrnInfoPtr pScrn) { - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia = VIAPTR(pScrn); int i; VIASETREG(VIA_REG_TRANSET, 0x00010000); - for (i = 0; i <= 0x7D; i++) - { - VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); - } + for (i = 0; i <= 0x7D; i++) { + VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); + } VIASETREG(VIA_REG_TRANSET, 0x00020000); - for (i = 0; i <= 0x94; i++) - { - VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); - } + for (i = 0; i <= 0x94; i++) { + VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); + } VIASETREG(VIA_REG_TRANSPACE, 0x82400000); VIASETREG(VIA_REG_TRANSET, 0x01020000); - - for (i = 0; i <= 0x94; i++) - { - VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); - } + for (i = 0; i <= 0x94; i++) { + VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); + } VIASETREG(VIA_REG_TRANSPACE, 0x82400000); VIASETREG(VIA_REG_TRANSET, 0xfe020000); - for (i = 0; i <= 0x03; i++) - { - VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); - } + for (i = 0; i <= 0x03; i++) { + VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); + } VIASETREG(VIA_REG_TRANSET, 0x00030000); - for (i = 0; i <= 0xff; i++) - { - VIASETREG(VIA_REG_TRANSPACE, 0); - } + for (i = 0; i <= 0xff; i++) { + VIASETREG(VIA_REG_TRANSPACE, 0); + } + VIASETREG(VIA_REG_TRANSET, 0x00100000); VIASETREG(VIA_REG_TRANSPACE, 0x00333004); VIASETREG(VIA_REG_TRANSPACE, 0x10000002); @@ -2969,10 +3097,10 @@ VIAInitialize3DEngine(ScrnInfoPtr pScrn) VIASETREG(VIA_REG_TRANSET, 0x00fe0000); - if (pVia->ChipRev >= 3 ) - VIASETREG(VIA_REG_TRANSPACE,0x40008c0f); + if (pVia->Chipset == VIA_CLE266 && pVia->ChipRev >= 3) + VIASETREG(VIA_REG_TRANSPACE,0x40008c0f); else - VIASETREG(VIA_REG_TRANSPACE,0x4000800f); + VIASETREG(VIA_REG_TRANSPACE,0x4000800f); VIASETREG(VIA_REG_TRANSPACE,0x44000000); VIASETREG(VIA_REG_TRANSPACE,0x45080C04); @@ -2982,7 +3110,6 @@ VIAInitialize3DEngine(ScrnInfoPtr pScrn) VIASETREG(VIA_REG_TRANSPACE,0x52000000); VIASETREG(VIA_REG_TRANSPACE,0x53000000); - VIASETREG(VIA_REG_TRANSET,0x00fe0000); VIASETREG(VIA_REG_TRANSPACE,0x08000001); VIASETREG(VIA_REG_TRANSPACE,0x0A000183); diff --git a/src/via_lvds.c b/src/via_lvds.c index 7085042..263b727 100644 --- a/src/via_lvds.c +++ b/src/via_lvds.c @@ -75,7 +75,7 @@ ViaLVDSPowerSecondSequence(ScrnInfoPtr pScrn, Bool on) /* Turn on back light. */ hwp->writeCrtc(hwp, 0xD3, hwp->readCrtc(hwp, 0xD3) & 0x3F); /* Turn on hardware power sequence. */ - hwp->writeCrtc(hwp, 0xD4, hwp->readCrtc(hwp, 0x6A) | 0x02); + hwp->writeCrtc(hwp, 0xD4, hwp->readCrtc(hwp, 0xD4) | 0x02); } else { @@ -97,10 +97,10 @@ ViaLVDSDFPPower(ScrnInfoPtr pScrn, Bool on) if (on) { /* Turn DFP High/Low pad on. */ - hwp->writeSeq(hwp, 0x2A, hwp->readSeq(hwp, 0x2A) | 0xF0); + hwp->writeSeq(hwp, 0x2A, hwp->readSeq(hwp, 0x2A) | 0x0F); } else { /* Turn DFP High/Low pad off. */ - hwp->writeSeq(hwp, 0x2A, hwp->readSeq(hwp, 0x2A) & 0xF0); + hwp->writeSeq(hwp, 0x2A, hwp->readSeq(hwp, 0x2A) & 0x0F); } } @@ -125,7 +125,7 @@ ViaLVDSPowerChannel(ScrnInfoPtr pScrn, Bool on) void ViaLVDSPower(ScrnInfoPtr pScrn, Bool on) { - + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaLVDSPower\n")); ViaLVDSPowerFirstSequence(pScrn, on); ViaLVDSPowerSecondSequence(pScrn, on); ViaLVDSDFPPower(pScrn, on); diff --git a/src/via_mode.c b/src/via_mode.c index 41249c5..93ec486 100644 --- a/src/via_mode.c +++ b/src/via_mode.c @@ -46,6 +46,44 @@ */ #include "via_mode.h" +static void +ViaPrintMode( ScrnInfoPtr pScrn, DisplayModePtr mode ) { + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Name: %s\n", mode->name ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock: %d\n", mode->Clock ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VRefresh: %f\n", mode->VRefresh ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "HSync: %f\n", mode->HSync ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "HDisplay: %d\n", mode->HDisplay ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "HSyncStart: %d\n", mode->HSyncStart ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "HSyncEnd: %d\n", mode->HSyncEnd ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "HTotal: %d\n", mode->HTotal ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "HSkew: %d\n", mode->HSkew ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VDisplay: %d\n", mode->VDisplay ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VSyncStart: %d\n", mode->VSyncStart ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VSyncEnd: %d\n", mode->VSyncEnd ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VTotal: %d\n", mode->VTotal ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VScan: %d\n", mode->VScan ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Flags: %d\n", mode->Flags ) ; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHDisplay: 0x%x\n", mode->CrtcHDisplay ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHBlankStart: 0x%x\n", mode->CrtcHBlankStart ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHSyncStart: 0x%x\n", mode->CrtcHSyncStart ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHSyncEnd: 0x%x\n", mode->CrtcHSyncEnd ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHBlankEnd: 0x%x\n", mode->CrtcHBlankEnd ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHTotal: 0x%x\n", mode->CrtcHTotal ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHSkew: 0x%x\n", mode->CrtcHSkew ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVDisplay: 0x%x\n", mode->CrtcVDisplay ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVBlankStart: 0x%x\n", mode->CrtcVBlankStart ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVSyncStart: 0x%x\n", mode->CrtcVSyncStart ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVSyncEnd: 0x%x\n", mode->CrtcVSyncEnd ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVBlankEnd: 0x%x\n", mode->CrtcVBlankEnd ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVTotal: 0x%x\n", mode->CrtcVTotal ) ; +/* +Bool CrtcHAdjusted; +Bool CrtcVAdjusted; +*/ +} + /* * * TV specific code. @@ -347,14 +385,14 @@ ViaOutputsSelect(ScrnInfoPtr pScrn) " Initialised register: 0x%02x\n", VIAGetActiveDisplay(pScrn))); - pBIOSInfo->PanelActive = FALSE; + pBIOSInfo->Panel->IsActive = FALSE; pBIOSInfo->CrtActive = FALSE; pBIOSInfo->TVActive = FALSE; if (!pVia->ActiveDevice) { /* always enable the panel when present */ if (pBIOSInfo->PanelPresent) - pBIOSInfo->PanelActive = TRUE; + pBIOSInfo->Panel->IsActive = TRUE; else if (pBIOSInfo->TVOutput != TVOUTPUT_NONE) /* cable is attached! */ pBIOSInfo->TVActive = TRUE; @@ -364,7 +402,7 @@ ViaOutputsSelect(ScrnInfoPtr pScrn) } else { if (pVia->ActiveDevice & VIA_DEVICE_LCD) { if (pBIOSInfo->PanelPresent) - pBIOSInfo->PanelActive = TRUE; + pBIOSInfo->Panel->IsActive = TRUE; else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unable to activate" " panel: no panel is present.\n"); @@ -377,7 +415,7 @@ ViaOutputsSelect(ScrnInfoPtr pScrn) else if (pBIOSInfo->TVOutput == TVOUTPUT_NONE) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unable to activate" " TV encoder: no cable attached.\n"); - else if (pBIOSInfo->PanelActive) + else if (pBIOSInfo->Panel->IsActive) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unable to activate" " TV encoder and panel simultaneously. Not using" " TV encoder.\n"); @@ -385,7 +423,7 @@ ViaOutputsSelect(ScrnInfoPtr pScrn) pBIOSInfo->TVActive = TRUE; } - if ((pVia->ActiveDevice & VIA_DEVICE_CRT) || (!pBIOSInfo->PanelActive + if ((pVia->ActiveDevice & VIA_DEVICE_CRT) || (!pBIOSInfo->Panel->IsActive && !pBIOSInfo->TVActive)) { pBIOSInfo->CrtPresent = TRUE; pBIOSInfo->CrtActive = TRUE; @@ -395,7 +433,7 @@ ViaOutputsSelect(ScrnInfoPtr pScrn) #ifdef HAVE_DEBUG if (pBIOSInfo->CrtActive) DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaOutputsSelect: CRT.\n")); - if (pBIOSInfo->PanelActive) + if (pBIOSInfo->Panel->IsActive) DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaOutputsSelect: Panel.\n")); if (pBIOSInfo->TVActive) DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaOutputsSelect: TV.\n")); @@ -776,7 +814,7 @@ ViaModesAttach(ScrnInfoPtr pScrn, MonPtr monitorp) DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModesAttach\n")); - if (pBIOSInfo->PanelActive) + if (pBIOSInfo->Panel->IsActive) ViaModesAttachHelper(pScrn, monitorp, ViaPanelModes); if (pBIOSInfo->TVActive && pBIOSInfo->TVModes) ViaModesAttachHelper(pScrn, monitorp, pBIOSInfo->TVModes); @@ -825,150 +863,6 @@ ViaGetMemoryBandwidth(ScrnInfoPtr pScrn) } } -/* - * Checks for limitations imposed by the available VGA timing registers. - * - */ -static ModeStatus -ViaModePrimaryVGAValid(ScrnInfoPtr pScrn, DisplayModePtr mode) -{ - DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModePrimaryVGAValid\n")); - - if (mode->CrtcHTotal > 4100) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHTotal out of range.\n"); - return MODE_BAD_HVALUE; - } - - if (mode->CrtcHDisplay > 2048) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHDisplay out of range.\n"); - return MODE_BAD_HVALUE; - } - - if (mode->CrtcHBlankStart > 2048) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHBlankStart out of range.\n"); - return MODE_BAD_HVALUE; - } - - if ((mode->CrtcHBlankEnd - mode->CrtcHBlankStart) > 1025) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHBlankEnd out of range.\n"); - return MODE_HBLANK_WIDE; - } - - if (mode->CrtcHSyncStart > 4095) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHSyncStart out of range.\n"); - return MODE_BAD_HVALUE; - } - - if ((mode->CrtcHSyncEnd - mode->CrtcHSyncStart) > 256) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHSyncEnd out of range.\n"); - return MODE_HSYNC_WIDE; - } - - if (mode->CrtcVTotal > 2049) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVTotal out of range.\n"); - return MODE_BAD_VVALUE; - } - - if (mode->CrtcVDisplay > 2048) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVDisplay out of range.\n"); - return MODE_BAD_VVALUE; - } - - if (mode->CrtcVSyncStart > 2047) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVSyncStart out of range.\n"); - return MODE_BAD_VVALUE; - } - - if ((mode->CrtcVSyncEnd - mode->CrtcVSyncStart) > 16) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVSyncEnd out of range.\n"); - return MODE_VSYNC_WIDE; - } - - if (mode->CrtcVBlankStart > 2048) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVBlankStart out of range.\n"); - return MODE_BAD_VVALUE; - } - - if ((mode->CrtcVBlankEnd - mode->CrtcVBlankStart) > 257) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVBlankEnd out of range.\n"); - return MODE_VBLANK_WIDE; - } - - return MODE_OK; -} - -/* - * - */ -static ModeStatus -ViaModeSecondaryVGAValid(ScrnInfoPtr pScrn, - DisplayModePtr mode) -{ - DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModeSecondaryVGAValid\n")); - - if (mode->CrtcHTotal > 4096) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHTotal out of range.\n"); - return MODE_BAD_HVALUE; - } - - if (mode->CrtcHDisplay > 2048) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHDisplay out of range.\n"); - return MODE_BAD_HVALUE; - } - - if (mode->CrtcHBlankStart > 2048) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHBlankStart out of range.\n"); - return MODE_BAD_HVALUE; - } - - if (mode->CrtcHBlankEnd > 4096) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHBlankEnd out of range.\n"); - return MODE_HBLANK_WIDE; - } - - if (mode->CrtcHSyncStart > 2047) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHSyncStart out of range.\n"); - return MODE_BAD_HVALUE; - } - - if ((mode->CrtcHSyncEnd - mode->CrtcHSyncStart) > 512) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcHSyncEnd out of range.\n"); - return MODE_HSYNC_WIDE; - } - - if (mode->CrtcVTotal > 2048) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVTotal out of range.\n"); - return MODE_BAD_VVALUE; - } - - if (mode->CrtcVDisplay > 2048) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVDisplay out of range.\n"); - return MODE_BAD_VVALUE; - } - - if (mode->CrtcVBlankStart > 2048) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVBlankStart out of range.\n"); - return MODE_BAD_VVALUE; - } - - if (mode->CrtcVBlankEnd > 2048) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVBlankEnd out of range.\n"); - return MODE_VBLANK_WIDE; - } - - if (mode->CrtcVSyncStart > 2047) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVSyncStart out of range.\n"); - return MODE_BAD_VVALUE; - } - - if ((mode->CrtcVSyncEnd - mode->CrtcVSyncStart) > 32) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CrtcVSyncEnd out of range.\n"); - return MODE_VSYNC_WIDE; - } - - return MODE_OK; -} - static CARD32 ViaModeDotClockTranslate(ScrnInfoPtr pScrn, DisplayModePtr mode); @@ -994,26 +888,56 @@ ViaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, if (mode->Flags & V_INTERLACE) return MODE_NO_INTERLACE; - if (pVia->IsSecondary) - ret = ViaModeSecondaryVGAValid(pScrn, mode); - else - ret = ViaModePrimaryVGAValid(pScrn, mode); - - if (ret != MODE_OK) - return ret; + if (pVia->UseLegacyModeSwitch) { + + if (pVia->IsSecondary) + ret = ViaSecondCRTCModeValid(pScrn, mode); + else + ret = ViaFirstCRTCModeValid(pScrn, mode); - if (pBIOSInfo->TVActive) { - ret = ViaTVModeValid(pScrn, mode); - if (ret != MODE_OK) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Mode \"%s\" not supported by" - " TV encoder.\n", mode->name); + if (ret != MODE_OK) return ret; + + + if (pBIOSInfo->TVActive) { + ret = ViaTVModeValid(pScrn, mode); + if (ret != MODE_OK) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Mode \"%s\" not supported by" + " TV encoder.\n", mode->name); + return ret; + } + } else { + if (pBIOSInfo->Panel->IsActive && !ViaPanelGetIndex(pScrn, mode)) + return MODE_BAD; + else if (!ViaModeDotClockTranslate(pScrn, mode)) + return MODE_NOCLOCK; } - } else if (pBIOSInfo->PanelActive && !ViaPanelGetIndex(pScrn, mode)) - return MODE_BAD; - else if (!ViaModeDotClockTranslate(pScrn, mode)) - return MODE_NOCLOCK; + + } else { + + if (pBIOSInfo->FirstCRTC->IsActive) + ret = ViaFirstCRTCModeValid(pScrn, mode); + + if (ret != MODE_OK) + return ret; + if (pBIOSInfo->SecondCRTC->IsActive) + ret = ViaSecondCRTCModeValid(pScrn, mode); + + if (ret != MODE_OK) + return ret; + + if (pBIOSInfo->Panel->IsActive) { + + ViaPanelModePtr nativeMode = pBIOSInfo->Panel->NativeMode ; + if (nativeMode->Width < mode->HDisplay + || nativeMode->Height < mode->VDisplay) + return MODE_PANEL ; + } + if (!ViaModeDotClockTranslate(pScrn, mode)) + return MODE_NOCLOCK; + } + temp = mode->CrtcHDisplay * mode->CrtcVDisplay * mode->VRefresh * (pScrn->bitsPerPixel >> 3); if (pBIOSInfo->Bandwidth < temp) { @@ -1443,14 +1367,15 @@ ViaModeDotClockTranslate(ScrnInfoPtr pScrn, DisplayModePtr mode) * */ void -ViaModePrimary(ScrnInfoPtr pScrn, DisplayModePtr mode) +ViaModePrimaryLegacy(ScrnInfoPtr pScrn, DisplayModePtr mode) { vgaHWPtr hwp = VGAHWPTR(pScrn); VIAPtr pVia= VIAPTR(pScrn); VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModePrimary\n")); - + DEBUG(ViaPrintMode(pScrn,mode)); + /* Turn off Screen */ ViaCrtcMask(hwp, 0x17, 0x00, 0x80); @@ -1473,7 +1398,7 @@ ViaModePrimary(ScrnInfoPtr pScrn, DisplayModePtr mode) else ViaSeqMask(hwp, 0x16, 0x00, 0x40); - if (pBIOSInfo->PanelActive && ViaPanelGetIndex(pScrn, mode)) { + if (pBIOSInfo->Panel->IsActive && ViaPanelGetIndex(pScrn, mode)) { VIASetLCDMode(pScrn, mode); ViaLCDPower(pScrn, TRUE); } else if (pBIOSInfo->PanelPresent) @@ -1521,27 +1446,28 @@ ViaModePrimary(ScrnInfoPtr pScrn, DisplayModePtr mode) * */ void -ViaModeSecondary(ScrnInfoPtr pScrn, DisplayModePtr mode) +ViaModeSecondaryLegacy(ScrnInfoPtr pScrn, DisplayModePtr mode) { vgaHWPtr hwp = VGAHWPTR(pScrn); VIAPtr pVia = VIAPTR(pScrn); VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModeSecondary\n")); - + DEBUG(ViaPrintMode(pScrn,mode)); + /* Turn off Screen */ ViaCrtcMask(hwp, 0x17, 0x00, 0x80); ViaSecondCRTCSetMode(pScrn, mode); if (pBIOSInfo->TVActive) - ViaTVSetMode(pScrn, mode); + ViaTVSetMode(pScrn, mode); /* CLE266A2 apparently doesn't like this */ - if ((pVia->Chipset != VIA_CLE266) || (pVia->ChipRev != 0x02)) - ViaCrtcMask(hwp, 0x6C, 0x00, 0x1E); + if (!(pVia->Chipset == VIA_CLE266 && pVia->ChipRev != 0x02)) + ViaCrtcMask(hwp, 0x6C, 0x00, 0x1E); - if (pBIOSInfo->PanelActive && (pBIOSInfo->PanelIndex != VIA_BIOS_NUM_PANEL)) { + if (pBIOSInfo->Panel->IsActive && (pBIOSInfo->PanelIndex != VIA_BIOS_NUM_PANEL)) { pBIOSInfo->SetDVI = TRUE; VIASetLCDMode(pScrn, mode); ViaLCDPower(pScrn, TRUE); @@ -1619,3 +1545,109 @@ ViaLCDPower(ScrnInfoPtr pScrn, Bool On) ViaLCDPowerSequence(hwp, powerOff[i]); usleep(1); } + +void +ViaModeFirstCRTC(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModeFirstCRTC\n"); + vgaHWPtr hwp = VGAHWPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); + VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; + + /* Turn off Screen */ + ViaCrtcMask(hwp, 0x17, 0x00, 0x80); + + ViaFirstCRTCSetMode(pScrn, mode); + pBIOSInfo->Clock = ViaModeDotClockTranslate(pScrn, mode); + pBIOSInfo->ClockExternal = FALSE; + + ViaSetPrimaryFIFO(pScrn, mode); + + ViaSetPrimaryDotclock(pScrn, pBIOSInfo->Clock); + ViaSetUseExternalClock(hwp); + ViaCrtcMask(hwp, 0x6B, 0x00, 0x01); + + hwp->disablePalette(hwp); + + /* Turn on Screen */ + ViaCrtcMask(hwp, 0x17, 0x80, 0x80); + +} + +void +ViaModeSecondCRTC(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModeSecondCRTC\n")); + VIAPtr pVia= VIAPTR(pScrn); + VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; + vgaHWPtr hwp = VGAHWPTR(pScrn); + DisplayModePtr nativeDisplayMode = pBIOSInfo->Panel->NativeDisplayMode; + DisplayModePtr centeredMode = pBIOSInfo->Panel->CenteredMode; + DisplayModePtr realMode = mode; + + if (pBIOSInfo->Panel->IsActive) { + if (nativeDisplayMode) { + + ViaPanelScale(pScrn, mode->HDisplay, mode->VDisplay, + nativeDisplayMode->HDisplay, nativeDisplayMode->VDisplay); + if ( !pBIOSInfo->Center && (mode->HDisplay + < nativeDisplayMode->HDisplay || mode->VDisplay + < nativeDisplayMode->VDisplay)) { + + realMode = nativeDisplayMode; + } else { + ViaPanelCenterMode(centeredMode, nativeDisplayMode, mode); + realMode = centeredMode; + ViaPanelScaleDisable(pScrn); + } + } + } + + ViaSecondCRTCSetMode(pScrn, realMode); + ViaSetSecondaryFIFO(pScrn, realMode); + pBIOSInfo->Clock = ViaModeDotClockTranslate(pScrn, realMode); + + /* Fix LCD scaling */ + ViaSecondCRTCHorizontalQWCount(pScrn, mode->CrtcHDisplay); + + pBIOSInfo->ClockExternal = FALSE; + ViaSetSecondaryDotclock(pScrn, pBIOSInfo->Clock); + ViaSetUseExternalClock(hwp); + + hwp->disablePalette(hwp); + +} + +void +ViaModeSet(ScrnInfoPtr pScrn, DisplayModePtr mode) { + VIAPtr pVia= VIAPTR(pScrn); + VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModeSet\n")); + + ViaPrintMode(pScrn, mode); + + if (pBIOSInfo->SecondCRTC->IsActive) { + ViaModeSecondCRTC(pScrn, mode); + ViaSecondDisplayChannelEnable(pScrn); + } + + if (pBIOSInfo->FirstCRTC->IsActive) { + /* CRT on FirstCRTC */ + ViaDisplaySetStreamOnCRT(pScrn, TRUE); + ViaDisplayEnableCRT(pScrn); + ViaModeFirstCRTC(pScrn, mode); + } else { + ViaDisplayDisableCRT(pScrn); + } + + + if (pBIOSInfo->Simultaneous->IsActive) { + ViaDisplayEnableSimultaneous(pScrn); + } else { + ViaDisplayDisableSimultaneous(pScrn); + } + +} diff --git a/src/via_panel.c b/src/via_panel.c index 41b6b15..ecbadb9 100644 --- a/src/via_panel.c +++ b/src/via_panel.c @@ -1,5 +1,6 @@ /* * Copyright 2007 The Openchrome Project [openchrome.org] + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. * Copyright 1998-2007 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2007 S3 Graphics, Inc. All Rights Reserved. * @@ -55,7 +56,8 @@ static ViaPanelModeRec ViaPanelNativeModes[] = { }; /** - * + * Sets the panel dimensions from the configuration + * using name with format "9999x9999" */ void ViaPanelGetNativeModeFromOption(ScrnInfoPtr pScrn, char* name) @@ -66,42 +68,70 @@ ViaPanelGetNativeModeFromOption(ScrnInfoPtr pScrn, char* name) CARD8 index; CARD8 length; + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaPanelGetNativeModeFromOption\n")); + panel->NativeModeIndex = VIA_PANEL_INVALID; - length = sizeof(ViaPanelNativeModes) / sizeof(ViaPanelModeRec); - char aux[10]; - for (index = 0; index < length; index++) { - sprintf(aux, "%dx%d", ViaPanelNativeModes[ index ].Width, - ViaPanelNativeModes[ index ].Height) ; - if (!xf86NameCmp(name, aux)) { - panel->NativeModeIndex = index; - panel->NativeMode->Width = ViaPanelNativeModes[ index ].Width ; - panel->NativeMode->Height = ViaPanelNativeModes[ index ].Height ; - break; + if (strlen(name) < 10) { + length = sizeof(ViaPanelNativeModes) / sizeof(ViaPanelModeRec); + char aux[10]; + for (index = 0; index < length; index++) { + sprintf(aux, "%dx%d", ViaPanelNativeModes[ index ].Width, + ViaPanelNativeModes[ index ].Height) ; + if (!xf86NameCmp(name, aux)) { + panel->NativeModeIndex = index; + panel->NativeMode->Width = ViaPanelNativeModes[ index ].Width ; + panel->NativeMode->Height = ViaPanelNativeModes[ index ].Height ; + break; + } } + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "%s is not a valid panel size.\n", name); } } +/** + * Gets the native panel resolution from scratch pad registers + * + */ void ViaPanelGetNativeModeFromScratchPad(ScrnInfoPtr pScrn) { VIAPtr pVia = VIAPTR(pScrn); vgaHWPtr hwp = VGAHWPTR(pScrn); CARD8 index ; + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaPanelGetNativeModeFromScratchPad\n")); + index = hwp->readCrtc(hwp, 0x3F) & 0x0F ; ViaPanelInfoPtr panel = pVia->pBIOSInfo->Panel ; panel->NativeModeIndex = index ; panel->NativeMode->Width = ViaPanelNativeModes[ index ].Width ; panel->NativeMode->Height = ViaPanelNativeModes[ index ].Height ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Native Panel Resolution is %dx%d\n", + panel->NativeMode->Width, panel->NativeMode->Height); +} + +void +ViaPanelScaleDisable(ScrnInfoPtr pScrn) { + VIAPtr pVia = VIAPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + + ViaCrtcMask(hwp, 0x79, 0x00, 0x01); + if (pVia->Chipset != VIA_CLE266 && pVia->Chipset != VIA_KM400) + ViaCrtcMask(hwp, 0xA2, 0x00, 0xC8); } /** * */ -void ViaPanelScale(ScrnInfoPtr pScrn, int resWidth, int resHeight, int panelWidth, int panelHeight ) { +void +ViaPanelScale(ScrnInfoPtr pScrn, int resWidth, int resHeight, int panelWidth, int panelHeight ) { VIAPtr pVia = VIAPTR(pScrn); vgaHWPtr hwp = VGAHWPTR(pScrn); - int horScalingFactor; - int verScalingFactor; + int horScalingFactor = 0; + int verScalingFactor = 0; CARD8 cra2 = 0; CARD8 cr77 = 0; CARD8 cr78 = 0; @@ -140,16 +170,19 @@ void ViaPanelScale(ScrnInfoPtr pScrn, int resWidth, int resHeight, int panelWidt scaling = TRUE ; } - DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Scaling factor: horizontal %d (0x%x), vertical %d (0x%x)\n", - horScalingFactor, horScalingFactor, verScalingFactor, verScalingFactor )); - if (scaling) { + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Scaling factor: horizontal %d (0x%x), vertical %d (0x%x)\n", + horScalingFactor, horScalingFactor, verScalingFactor, verScalingFactor )); + ViaCrtcMask(hwp, 0x77, cr77, 0xFF); ViaCrtcMask(hwp, 0x78, cr78, 0xFF); ViaCrtcMask(hwp, 0x79, cr79, 0xF8); ViaCrtcMask(hwp, 0x9F, cr9f, 0x03); - } + ViaCrtcMask(hwp, 0x79, 0x03, 0x03); + } else + ViaCrtcMask(hwp, 0x79, 0x00, 0x01); ViaCrtcMask(hwp, 0xA2, cra2, 0xC8); @@ -159,6 +192,123 @@ void ViaPanelScale(ScrnInfoPtr pScrn, int resWidth, int resHeight, int panelWidt // ViaCrtcMask(hwp, 0x79, 0x00, 0x02); /* Horizontal scaling factor selection original / linear */ //ViaCrtcMask(hwp, 0xA2, 0x40, 0x40); + +} + + +/** + * Generates a display mode for the native panel resolution + * using CVT + */ +static void +ViaPanelGetNativeDisplayMode(ScrnInfoPtr pScrn) { + + VIAPtr pVia= VIAPTR(pScrn); + ViaPanelModePtr panelMode = pVia->pBIOSInfo->Panel->NativeMode ; + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaPanelGetNativeDisplayMode\n")); + + if (panelMode->Width && panelMode->Height) { + + /* TODO: fix refresh rate */ + DisplayModePtr p = ViaCVTMode( panelMode->Width, panelMode->Height, 60.0, TRUE, FALSE ) ; + + /* The following code is borrowed from xf86SetModeCrtc */ + if (p) { + p->CrtcHDisplay = p->HDisplay; + p->CrtcHSyncStart = p->HSyncStart; + p->CrtcHSyncEnd = p->HSyncEnd; + p->CrtcHTotal = p->HTotal; + p->CrtcHSkew = p->HSkew; + p->CrtcVDisplay = p->VDisplay; + p->CrtcVSyncStart = p->VSyncStart; + p->CrtcVSyncEnd = p->VSyncEnd; + p->CrtcVTotal = p->VTotal; + + p->CrtcVBlankStart = min(p->CrtcVSyncStart, p->CrtcVDisplay); + p->CrtcVBlankEnd = max(p->CrtcVSyncEnd, p->CrtcVTotal); + + if ((p->CrtcVBlankEnd - p->CrtcVBlankStart) >= 127) { + /* + * V Blanking size must be < 127. + * Moving blank start forward is safer than moving blank end + * back, since monitors clamp just AFTER the sync pulse (or in + * the sync pulse), but never before. + */ + p->CrtcVBlankStart = p->CrtcVBlankEnd - 127; + /* + * If VBlankStart is now > VSyncStart move VBlankStart + * to VSyncStart using the maximum width that fits into + * VTotal. + */ + if (p->CrtcVBlankStart > p->CrtcVSyncStart) { + p->CrtcVBlankStart = p->CrtcVSyncStart; + p->CrtcVBlankEnd = min(p->CrtcHBlankStart + 127, p->CrtcVTotal); + } + } + p->CrtcHBlankStart = min(p->CrtcHSyncStart, p->CrtcHDisplay); + p->CrtcHBlankEnd = max(p->CrtcHSyncEnd, p->CrtcHTotal); + + if ((p->CrtcHBlankEnd - p->CrtcHBlankStart) >= 63 * 8) { + /* + * H Blanking size must be < 63*8. Same remark as above. + */ + p->CrtcHBlankStart = p->CrtcHBlankEnd - 63 * 8; + if (p->CrtcHBlankStart > p->CrtcHSyncStart) { + p->CrtcHBlankStart = p->CrtcHSyncStart; + p->CrtcHBlankEnd = min(p->CrtcHBlankStart + 63 * 8, p->CrtcHTotal); + } + } + + } + + pVia->pBIOSInfo->Panel->NativeDisplayMode = p ; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Invalid panel dimension (%dx%d)\n", + panelMode->Width, panelMode->Height); + } + +} + +void +ViaPanelPreInit(ScrnInfoPtr pScrn) { + VIAPtr pVia= VIAPTR(pScrn); + VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaPanelPreInit\n")); + + ViaPanelInfoPtr panel = pBIOSInfo->Panel ; +/* + if (panel->PanelSizeFromOption) + ViaPanelGetNativeModeFromOption(pScrn, panel->PanelSizeFromOption); +*/ + if (panel->NativeModeIndex == VIA_PANEL_INVALID) + ViaPanelGetNativeModeFromScratchPad(pScrn); + + if (panel->NativeModeIndex != VIA_PANEL_INVALID) + ViaPanelGetNativeDisplayMode(pScrn); + +} + +void +ViaPanelCenterMode(DisplayModePtr centerMode, DisplayModePtr panelMode, + DisplayModePtr mode) +{ + memcpy(centerMode, mode, sizeof(DisplayModeRec)); + + CARD32 HDiff = (panelMode->CrtcHDisplay - mode->CrtcHDisplay) / 2 ; + CARD32 VDiff = (panelMode->CrtcVDisplay - mode->CrtcVDisplay) / 2 ; + + centerMode->CrtcHTotal += HDiff * 2; + centerMode->CrtcVTotal += VDiff * 2; + + centerMode->CrtcHSyncStart += HDiff ; + centerMode->CrtcHSyncEnd += HDiff ; + centerMode->CrtcHBlankStart += HDiff ; + centerMode->CrtcHBlankEnd += HDiff ; - ViaCrtcMask(hwp, 0x79, 0x07, 0x07); + centerMode->CrtcVSyncStart += VDiff ; + centerMode->CrtcVSyncEnd += VDiff ; ; + centerMode->CrtcVBlankStart += VDiff ; + centerMode->CrtcVBlankEnd += VDiff ; } diff --git a/src/via_regs.h b/src/via_regs.h index 6538388..5fdc8b9 100644 --- a/src/via_regs.h +++ b/src/via_regs.h @@ -42,7 +42,7 @@ #define VIA_MMIO_REGBASE 0x0 #define VIA_MMIO_VGABASE 0x8000 #define VIA_MMIO_BLTBASE 0x200000 -#define VIA_MMIO_BLTSIZE 0x20000 +#define VIA_MMIO_BLTSIZE 0x200000 /* defines for VIA 2D registers */ diff --git a/src/via_swov.c b/src/via_swov.c index 4dc0448..8831bd9 100644 --- a/src/via_swov.c +++ b/src/via_swov.c @@ -79,7 +79,7 @@ viaWaitVideoCommandFire(VIAPtr pVia) while (--count && ((*pdwState & V1_COMMAND_FIRE) || (*pdwState & V3_COMMAND_FIRE))) ; if (!count) { - ErrorF("viaWaitVideoCommandFire: Timeout.\n"); + ErrorF("viaWaitVideoCommandFire: Timeout.\n"); } } @@ -95,9 +95,9 @@ viaWaitHQVFlip(VIAPtr pVia) pdwState = (CARD32 volatile *)(pVia->VidMapBase + (HQV_CONTROL + proReg)); if (pVia->VideoEngine == VIDEO_ENGINE_CME) { - while (*pdwState & (HQV_SUBPIC_FLIP | HQV_SW_FLIP)) ; + while (*pdwState & (HQV_SUBPIC_FLIP | HQV_SW_FLIP)) ; } else { - while (!(*pdwState & HQV_FLIP_STATUS)) ; + while (!(*pdwState & HQV_FLIP_STATUS)) ; } } @@ -109,7 +109,7 @@ viaWaitHQVFlipClear(VIAPtr pVia, unsigned long dwData) *pdwState = dwData; while ((*pdwState & HQV_FLIP_STATUS)) { - VIDOutD(HQV_CONTROL, *pdwState | HQV_FLIP_STATUS); + VIDOutD(HQV_CONTROL, *pdwState | HQV_FLIP_STATUS); } } @@ -130,7 +130,7 @@ viaWaitHQVDone(VIAPtr pVia) pdwState = (CARD32 volatile *)(pVia->VidMapBase + (HQV_CONTROL + proReg)); if (pVia->swov.MPEG_ON) { - while ((*pdwState & HQV_SW_FLIP)) ; + while ((*pdwState & HQV_SW_FLIP)) ; } } @@ -145,10 +145,10 @@ FlushVidRegBuffer(VIAPtr pVia) viaWaitVideoCommandFire(pVia); for (i = 0; i < pVia->VidRegCursor; i += 2) { - VIDOutD(pVia->VidRegBuffer[i], pVia->VidRegBuffer[i + 1]); - DBG_DD(ErrorF("FlushVideoRegs: [%i] %08lx %08lx\n", - i >> 1, pVia->VidRegBuffer[i] + 0x200, - pVia->VidRegBuffer[i + 1])); + VIDOutD(pVia->VidRegBuffer[i], pVia->VidRegBuffer[i + 1]); + DBG_DD(ErrorF("FlushVideoRegs: [%i] %08lx %08lx\n", + i >> 1, pVia->VidRegBuffer[i] + 0x200, + pVia->VidRegBuffer[i + 1])); } /* BUG: (?) VIA never resets the cursor. @@ -165,8 +165,8 @@ ResetVidRegBuffer(VIAPtr pVia) { /* BUG: (Memory leak) This allocation may need have a corresponding free somewhere... /A */ if (!pVia->VidRegBuffer) - pVia->VidRegBuffer = - xnfcalloc(VIDREG_BUFFER_SIZE, sizeof(CARD32) * 2); + pVia->VidRegBuffer = + xnfcalloc(VIDREG_BUFFER_SIZE, sizeof(CARD32) * 2); pVia->VidRegCursor = 0; } @@ -180,7 +180,7 @@ SaveVideoRegister(VIAPtr pVia, CARD32 index, CARD32 data) pVia->VidRegBuffer[pVia->VidRegCursor++] = data; if (pVia->VidRegCursor > VIDREG_BUFFER_SIZE) { - DBG_DD(ErrorF("SaveVideoRegister: Out of video register space")); + DBG_DD(ErrorF("SaveVideoRegister: Out of video register space")); } } @@ -201,87 +201,87 @@ SaveVideoRegister(VIAPtr pVia, CARD32 index, CARD32 data) void VIAVidHWDiffInit(ScrnInfoPtr pScrn) { - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); VIAHWDiff *HWDiff = &pVia->HWDiff; switch (pVia->Chipset) { - case VIA_CLE266: - if (CLE266_REV_IS_AX(pVia->ChipRev)) { - HWDiff->dwThreeHQVBuffer = VID_HWDIFF_FALSE; - HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_FALSE; - HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; - HWDiff->dwHQVInitPatch = VID_HWDIFF_TRUE; - HWDiff->dwHQVDisablePatch = VID_HWDIFF_FALSE; - HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; - } else { - HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; - HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; - HWDiff->dwSupportTwoColorKey = VID_HWDIFF_TRUE; - HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; - HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; - HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; - } - break; - case VIA_KM400: - HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; - HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; - HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; - HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; - HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; - HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; - break; - case VIA_K8M800: - HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; - HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; - HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; - HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; - HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; - HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; - break; - case VIA_PM800: - HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; - HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; - HWDiff->dwSupportTwoColorKey = VID_HWDIFF_TRUE; - HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; - HWDiff->dwHQVDisablePatch = VID_HWDIFF_FALSE; - HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; - break; - case VIA_VM800: - case VIA_P4M900: - HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; - HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; - HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; - HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; - HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; - HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; - break; - case VIA_K8M890: - HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; - HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; - HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; - HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; - HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; - HWDiff->dwNeedV1Prefetch = VID_HWDIFF_TRUE; - break; - case VIA_P4M890: - HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; - HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; - HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; - HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; - HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; - HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; - break; - case VIA_CX700: - HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; - HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; - HWDiff->dwSupportTwoColorKey = VID_HWDIFF_TRUE; - HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; - HWDiff->dwHQVDisablePatch = VID_HWDIFF_FALSE; - HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; - break; - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "VIAVidHWDiffInit: Unhandled ChipSet.\n"); + case VIA_CLE266: + if (CLE266_REV_IS_AX(pVia->ChipRev)) { + HWDiff->dwThreeHQVBuffer = VID_HWDIFF_FALSE; + HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_FALSE; + HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; + HWDiff->dwHQVInitPatch = VID_HWDIFF_TRUE; + HWDiff->dwHQVDisablePatch = VID_HWDIFF_FALSE; + HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; + } else { + HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; + HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; + HWDiff->dwSupportTwoColorKey = VID_HWDIFF_TRUE; + HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; + HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; + HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; + } + break; + case VIA_KM400: + HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; + HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; + HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; + HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; + HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; + HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; + break; + case VIA_K8M800: + HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; + HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; + HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; + HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; + HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; + HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; + break; + case VIA_PM800: + HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; + HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; + HWDiff->dwSupportTwoColorKey = VID_HWDIFF_TRUE; + HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; + HWDiff->dwHQVDisablePatch = VID_HWDIFF_FALSE; + HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; + break; + case VIA_VM800: + case VIA_P4M900: + HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; + HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; + HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; + HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; + HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; + HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; + break; + case VIA_K8M890: + HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; + HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; + HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; + HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; + HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; + HWDiff->dwNeedV1Prefetch = VID_HWDIFF_TRUE; + break; + case VIA_P4M890: + HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; + HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; + HWDiff->dwSupportTwoColorKey = VID_HWDIFF_FALSE; + HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; + HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE; + HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; + break; + case VIA_CX700: + HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE; + HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE; + HWDiff->dwSupportTwoColorKey = VID_HWDIFF_TRUE; + HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE; + HWDiff->dwHQVDisablePatch = VID_HWDIFF_FALSE; + HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE; + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "VIAVidHWDiffInit: Unhandled ChipSet.\n"); } } @@ -320,83 +320,82 @@ typedef struct _YCBCRREC #endif static BOOL -viaOverlayGetV1V3Format(VIAPtr pVia, int vport, /* 1 or 3, as in V1 or V3 */ - unsigned long videoFlag, unsigned long *pVidCtl, unsigned long *pHQVCtl) +viaOverlayGetV1V3Format(VIAPtr pVia, int vport, /* 1 or 3, as in V1 or V3 */ + unsigned long videoFlag, unsigned long *pVidCtl, unsigned long *pHQVCtl) { if (videoFlag & VIDEO_HQV_INUSE) { - switch (pVia->swov.SrcFourCC) { - case FOURCC_YV12: - case FOURCC_XVMC: - *pHQVCtl |= HQV_YUV420; - break; - case FOURCC_YUY2: - *pHQVCtl |= HQV_YUV422; - break; - case FOURCC_RV32: - *pVidCtl |= V1_RGB32; - *pHQVCtl |= HQV_RGB32; - break; - case FOURCC_RV15: - *pVidCtl |= V1_RGB15; - *pHQVCtl |= HQV_RGB15; - break; - case FOURCC_RV16: - *pVidCtl |= V1_RGB16; - *pHQVCtl |= HQV_RGB16; - break; - default: - DBG_DD(ErrorF - ("viaOverlayGetV1V3Format: Invalid FOURCC format (0x%lx).\n", - pVia->swov.SrcFourCC)); - return FALSE; - } - *pVidCtl |= V1_SWAP_HW_HQV; - *pHQVCtl |= HQV_SRC_SW | HQV_ENABLE | HQV_SW_FLIP; + switch (pVia->swov.SrcFourCC) { + case FOURCC_YV12: + case FOURCC_XVMC: + *pHQVCtl |= HQV_YUV420; + break; + case FOURCC_YUY2: + *pHQVCtl |= HQV_YUV422; + break; + case FOURCC_RV32: + *pVidCtl |= V1_RGB32; + *pHQVCtl |= HQV_RGB32; + break; + case FOURCC_RV15: + *pVidCtl |= V1_RGB15; + *pHQVCtl |= HQV_RGB15; + break; + case FOURCC_RV16: + *pVidCtl |= V1_RGB16; + *pHQVCtl |= HQV_RGB16; + break; + default: + DBG_DD(ErrorF + ("viaOverlayGetV1V3Format: Invalid FOURCC format (0x%lx).\n", + pVia->swov.SrcFourCC)); + return FALSE; + } + *pVidCtl |= V1_SWAP_HW_HQV; + *pHQVCtl |= HQV_SRC_SW | HQV_ENABLE | HQV_SW_FLIP; } else { - switch (pVia->swov.SrcFourCC) { - case FOURCC_YV12: - case FOURCC_XVMC: - if (vport == 1) { - *pVidCtl |= V1_YCbCr420; - } else { - DBG_DD(ErrorF - ("viaOverlayGetV1V3Format: V3 does not support planar YUV.\n")); - return FALSE; - } - break; - case FOURCC_YUY2: - *pVidCtl |= V1_YUV422; - break; - case FOURCC_RV32: - case FOURCC_RV15: - case FOURCC_RV16: - ErrorF - ("viaOverlayGetV1V3Format: Can't display RGB video in this configuration.\n"); - return FALSE; - default: - DBG_DD(ErrorF - ("viaOverlayGetV1V3Format: Invalid FOURCC format (0x%lx).\n", - pVia->swov.SrcFourCC)); - return FALSE; - } + switch (pVia->swov.SrcFourCC) { + case FOURCC_YV12: + case FOURCC_XVMC: + if (vport == 1) { + *pVidCtl |= V1_YCbCr420; + } else { + DBG_DD(ErrorF + ("viaOverlayGetV1V3Format: V3 does not support planar YUV.\n")); + return FALSE; + } + break; + case FOURCC_YUY2: + *pVidCtl |= V1_YUV422; + break; + case FOURCC_RV32: + case FOURCC_RV15: + case FOURCC_RV16: + ErrorF("viaOverlayGetV1V3Format: Can't display RGB video in this configuration.\n"); + return FALSE; + default: + DBG_DD(ErrorF + ("viaOverlayGetV1V3Format: Invalid FOURCC format (0x%lx).\n", + pVia->swov.SrcFourCC)); + return FALSE; + } } *pVidCtl |= V1_COLORSPACE_SIGN; return TRUE; } static unsigned long -viaOverlayGetSrcStartAddress(VIAPtr pVia, unsigned long videoFlag, - LPDDUPDATEOVERLAY pUpdate, unsigned long srcPitch, - unsigned long *pHQVoffset) +viaOverlayGetSrcStartAddress(VIAPtr pVia, + unsigned long videoFlag, LPDDUPDATEOVERLAY pUpdate, + unsigned long srcPitch, unsigned long *pHQVoffset) { - unsigned long srcWidth = - (unsigned long)(pUpdate->SrcRight - pUpdate->SrcLeft); - unsigned long dstWidth = - (unsigned long)(pUpdate->DstRight - pUpdate->DstLeft); - unsigned long srcHeight = - (unsigned long)(pUpdate->SrcBottom - pUpdate->SrcTop); - unsigned long dstHeight = - (unsigned long)(pUpdate->DstBottom - pUpdate->DstTop); + unsigned long srcWidth = (unsigned long)(pUpdate->SrcRight + - pUpdate->SrcLeft); + unsigned long dstWidth = (unsigned long)(pUpdate->DstRight + - pUpdate->DstLeft); + unsigned long srcHeight = (unsigned long)(pUpdate->SrcBottom + - pUpdate->SrcTop); + unsigned long dstHeight = (unsigned long)(pUpdate->DstBottom + - pUpdate->DstTop); unsigned long offset = 0; unsigned long srcTopOffset = 0; @@ -405,66 +404,61 @@ viaOverlayGetSrcStartAddress(VIAPtr pVia, unsigned long videoFlag, int n = 1; if ((pUpdate->SrcLeft != 0) || (pUpdate->SrcTop != 0)) { - switch (pVia->swov.SrcFourCC) { - case FOURCC_RV32: - n = 2; - case FOURCC_YUY2: - case FOURCC_UYVY: - case FOURCC_RV15: - case FOURCC_RV16: - - if (videoFlag & VIDEO_HQV_INUSE) { - offset = - (((pUpdate->SrcTop & ~3) * srcPitch) + - ((pUpdate->SrcLeft << n) & ~31)); - - if (srcHeight > dstHeight) - srcTopOffset = - ((pUpdate->SrcTop & ~3) * dstHeight / srcHeight) * - srcPitch; - else - srcTopOffset = (pUpdate->SrcTop & ~3) * srcPitch; - - if (srcWidth > dstWidth) - srcLeftOffset = - ((pUpdate->SrcLeft << n) & ~31) * dstWidth / srcWidth; - else - srcLeftOffset = (pUpdate->SrcLeft << n) & ~31; - *pHQVoffset = srcTopOffset + srcLeftOffset; - } else - offset = - ((pUpdate->SrcTop * srcPitch) + - ((pUpdate->SrcLeft << n) & ~15)); - break; - - case FOURCC_YV12: - case FOURCC_XVMC: - - if (videoFlag & VIDEO_HQV_INUSE) - offset = - (((pUpdate->SrcTop & ~3) * (srcPitch << 1)) + - ((pUpdate->SrcLeft << 1) & ~31)); - else { - offset = - ((((pUpdate->SrcTop & ~3) * srcPitch) + - pUpdate->SrcLeft) & ~31); - if (pUpdate->SrcTop > 0) - pVia->swov.overlayRecordV1.dwUVoffset = - (((((pUpdate->SrcTop & ~3) >> 1) * srcPitch) + - pUpdate->SrcLeft) & ~31) >> 1; - else - pVia->swov.overlayRecordV1.dwUVoffset = offset >> 1; - } - break; - - default: - DBG_DD(ErrorF - ("viaGetSrcStartAddress: Invalid FOURCC format (0x%lx).\n", - pVia->swov.SrcFourCC)); - break; - } + switch (pVia->swov.SrcFourCC) { + case FOURCC_RV32: + n = 2; + case FOURCC_YUY2: + case FOURCC_UYVY: + case FOURCC_RV15: + case FOURCC_RV16: + + if (videoFlag & VIDEO_HQV_INUSE) { + offset = (((pUpdate->SrcTop & ~3) * srcPitch) + + ((pUpdate->SrcLeft << n) & ~31)); + + if (srcHeight > dstHeight) + srcTopOffset = ((pUpdate->SrcTop & ~3) * dstHeight + / srcHeight) * srcPitch; + else + srcTopOffset = (pUpdate->SrcTop & ~3) * srcPitch; + + if (srcWidth > dstWidth) + srcLeftOffset = ((pUpdate->SrcLeft << n) & ~31) + * dstWidth / srcWidth; + else + srcLeftOffset = (pUpdate->SrcLeft << n) & ~31; + *pHQVoffset = srcTopOffset + srcLeftOffset; + } else + offset = ((pUpdate->SrcTop * srcPitch) + ((pUpdate->SrcLeft + << n) & ~15)); + break; + + case FOURCC_YV12: + case FOURCC_XVMC: + + if (videoFlag & VIDEO_HQV_INUSE) + offset = (((pUpdate->SrcTop & ~3) * (srcPitch << 1)) + + ((pUpdate->SrcLeft << 1) & ~31)); + else { + offset = ((((pUpdate->SrcTop & ~3) * srcPitch) + + pUpdate->SrcLeft) & ~31); + if (pUpdate->SrcTop > 0) + pVia->swov.overlayRecordV1.dwUVoffset + = (((((pUpdate->SrcTop & ~3) >> 1) * srcPitch) + + pUpdate->SrcLeft) & ~31) >> 1; + else + pVia->swov.overlayRecordV1.dwUVoffset = offset >> 1; + } + break; + + default: + DBG_DD(ErrorF + ("viaGetSrcStartAddress: Invalid FOURCC format (0x%lx).\n", + pVia->swov.SrcFourCC)); + break; + } } else { - pVia->swov.overlayRecordV1.dwUVoffset = offset = 0; + pVia->swov.overlayRecordV1.dwUVoffset = offset = 0; } return offset; @@ -472,121 +466,117 @@ viaOverlayGetSrcStartAddress(VIAPtr pVia, unsigned long videoFlag, static YCBCRREC viaOverlayGetYCbCrStartAddress(unsigned long videoFlag, - unsigned long startAddr, unsigned long offset, unsigned long UVoffset, - unsigned long srcPitch, unsigned long srcHeight) + unsigned long startAddr, unsigned long offset, unsigned long UVoffset, + unsigned long srcPitch, unsigned long srcHeight) { YCBCRREC YCbCr; if (videoFlag & VIDEO_HQV_INUSE) { - YCbCr.dwY = startAddr; - YCbCr.dwCB = startAddr + srcPitch * srcHeight; - YCbCr.dwCR = startAddr + srcPitch * srcHeight - + srcPitch * (srcHeight >> 2); + YCbCr.dwY = startAddr; + YCbCr.dwCB = startAddr + srcPitch * srcHeight; + YCbCr.dwCR = startAddr + srcPitch * srcHeight + srcPitch * (srcHeight + >> 2); } else { - YCbCr.dwY = startAddr + offset; - YCbCr.dwCB = startAddr + srcPitch * srcHeight + UVoffset; - YCbCr.dwCR = startAddr + srcPitch * srcHeight + UVoffset - + srcPitch * (srcHeight >> 2); + YCbCr.dwY = startAddr + offset; + YCbCr.dwCB = startAddr + srcPitch * srcHeight + UVoffset; + YCbCr.dwCR = startAddr + srcPitch * srcHeight + UVoffset + srcPitch + * (srcHeight >> 2); } return YCbCr; } static unsigned long -viaOverlayHQVCalcZoomWidth(VIAPtr pVia, unsigned long videoFlag, - unsigned long srcWidth, unsigned long dstWidth, - unsigned long *pZoomCtl, unsigned long *pMiniCtl, - unsigned long *pHQVfilterCtl, unsigned long *pHQVminiCtl, - unsigned long *pHQVzoomflag) +viaOverlayHQVCalcZoomWidth(VIAPtr pVia, + unsigned long videoFlag, unsigned long srcWidth, + unsigned long dstWidth, unsigned long *pZoomCtl, + unsigned long *pMiniCtl, unsigned long *pHQVfilterCtl, + unsigned long *pHQVminiCtl, unsigned long *pHQVzoomflag) { unsigned long tmp, sw1, d, falign, mdiv; Bool zoom_ok = TRUE; - CARD32 HQVfilter[5] = { - HQV_H_FILTER_DEFAULT, HQV_H_TAP4_121, HQV_H_TAP4_121, - HQV_H_TAP8_12221, HQV_H_TAP8_12221 - }; + CARD32 HQVfilter[5] = { HQV_H_FILTER_DEFAULT, HQV_H_TAP4_121, + HQV_H_TAP4_121, HQV_H_TAP8_12221, HQV_H_TAP8_12221 }; /* CARD HQVmini[5] = { 0, 0xc00, 0xa00, 0x900, 0x8800 }; */ falign = 0; mdiv = 1; - if (srcWidth == dstWidth) { /* No zoom */ - *pHQVfilterCtl |= HQV_H_FILTER_DEFAULT; - } else if (srcWidth < dstWidth) { /* Zoom in */ - - tmp = srcWidth * 0x800 / dstWidth; - *pZoomCtl = ((tmp & 0x7ff) << 16) | V1_X_ZOOM_ENABLE; - *pMiniCtl |= V1_X_INTERPOLY; - zoom_ok = !(tmp > 0x7ff); - - *pHQVzoomflag = 1; - *pHQVfilterCtl |= HQV_H_FILTER_DEFAULT; - - } else { /* srcWidth > dstWidth - Zoom out */ - - /* HQV rounding patch, instead of: - * //tmp = dstWidth*0x0800 / srcWidth; */ - tmp = dstWidth * 0x800 * 0x400 / srcWidth; - tmp = tmp / 0x400 + ((tmp & 0x3ff) ? 1 : 0); - - *pHQVminiCtl = - (tmp & 0x7ff) | HQV_H_MINIFY_ENABLE | HQV_H_MINIFY_DOWN; - - /* Scale down the picture by a factor mdiv = (1 << d) = {2, 4, 8 or 16} */ - - sw1 = srcWidth; - for (d = 1; d < 5; d++) { - sw1 >>= 1; - if (sw1 <= dstWidth) - break; - } - if (d == 5) { /* Too small. */ - d = 4; - zoom_ok = FALSE; - } - mdiv = 1 << d; /* <= {2,4,8,16} */ - falign = ((mdiv << 1) - 1) & 0xf; /* <= {3,7,15,15} */ - *pMiniCtl |= V1_X_INTERPOLY; - *pMiniCtl |= ((d << 1) - 1) << 24; /* <= {1,3,5,7} << 24 */ - - *pHQVfilterCtl |= HQVfilter[d]; - /* *pHQVminiCtl = HQVmini[d]; */ - *pHQVminiCtl |= HQV_HDEBLOCK_FILTER; - - /* Scale to arbitrary size, on top of previous scaling by (1 << d). */ - - if (sw1 < dstWidth) { - /* CLE bug - *pZoomCtl = sw1 * 0x0800 / dstWidth;*/ - *pZoomCtl = (sw1 - 2) * 0x0800 / dstWidth; - *pZoomCtl = ((*pZoomCtl & 0x7ff) << 16) | V1_X_ZOOM_ENABLE; - } + if (srcWidth == dstWidth) { /* No zoom */ + *pHQVfilterCtl |= HQV_H_FILTER_DEFAULT; + } else if (srcWidth < dstWidth) { /* Zoom in */ + + tmp = srcWidth * 0x800 / dstWidth; + *pZoomCtl = ((tmp & 0x7ff) << 16) | V1_X_ZOOM_ENABLE; + *pMiniCtl |= V1_X_INTERPOLY; + zoom_ok = !(tmp > 0x7ff); + + *pHQVzoomflag = 1; + *pHQVfilterCtl |= HQV_H_FILTER_DEFAULT; + + } else { /* srcWidth > dstWidth - Zoom out */ + + /* HQV rounding patch, instead of: + * //tmp = dstWidth*0x0800 / srcWidth; */ + tmp = dstWidth * 0x800 * 0x400 / srcWidth; + tmp = tmp / 0x400 + ((tmp & 0x3ff) ? 1 : 0); + + *pHQVminiCtl = (tmp & 0x7ff) | HQV_H_MINIFY_ENABLE | HQV_H_MINIFY_DOWN; + + /* Scale down the picture by a factor mdiv = (1 << d) = {2, 4, 8 or 16} */ + + sw1 = srcWidth; + for (d = 1; d < 5; d++) { + sw1 >>= 1; + if (sw1 <= dstWidth) + break; + } + if (d == 5) { /* Too small. */ + d = 4; + zoom_ok = FALSE; + } + mdiv = 1 << d; /* <= {2,4,8,16} */ + falign = ((mdiv << 1) - 1) & 0xf; /* <= {3,7,15,15} */ + *pMiniCtl |= V1_X_INTERPOLY; + *pMiniCtl |= ((d << 1) - 1) << 24; /* <= {1,3,5,7} << 24 */ + + *pHQVfilterCtl |= HQVfilter[d]; + /* *pHQVminiCtl = HQVmini[d]; */ + *pHQVminiCtl |= HQV_HDEBLOCK_FILTER; + + /* Scale to arbitrary size, on top of previous scaling by (1 << d). */ + + if (sw1 < dstWidth) { + /* CLE bug + *pZoomCtl = sw1 * 0x0800 / dstWidth;*/ + *pZoomCtl = (sw1 - 2) * 0x0800 / dstWidth; + *pZoomCtl = ((*pZoomCtl & 0x7ff) << 16) | V1_X_ZOOM_ENABLE; + } } if (videoFlag & VIDEO_1_INUSE) { - pVia->swov.overlayRecordV1.dwFetchAlignment = falign; - pVia->swov.overlayRecordV1.dwminifyH = mdiv; + pVia->swov.overlayRecordV1.dwFetchAlignment = falign; + pVia->swov.overlayRecordV1.dwminifyH = mdiv; } else { - pVia->swov.overlayRecordV3.dwFetchAlignment = falign; - pVia->swov.overlayRecordV3.dwminifyH = mdiv; + pVia->swov.overlayRecordV3.dwFetchAlignment = falign; + pVia->swov.overlayRecordV3.dwminifyH = mdiv; } return zoom_ok; } static unsigned long -viaOverlayHQVCalcZoomHeight(VIAPtr pVia, unsigned long srcHeight, - unsigned long dstHeight, unsigned long *pZoomCtl, - unsigned long *pMiniCtl, unsigned long *pHQVfilterCtl, - unsigned long *pHQVminiCtl, unsigned long *pHQVzoomflag) +viaOverlayHQVCalcZoomHeight(VIAPtr pVia, + unsigned long srcHeight, unsigned long dstHeight, + unsigned long *pZoomCtl, unsigned long *pMiniCtl, + unsigned long *pHQVfilterCtl, unsigned long *pHQVminiCtl, + unsigned long *pHQVzoomflag) { unsigned long tmp, sh1, d; Bool zoom_ok = TRUE; - CARD32 HQVfilter[5] = { - HQV_V_TAP4_121, HQV_V_TAP4_121, HQV_V_TAP4_121, - HQV_V_TAP8_12221, HQV_V_TAP8_12221 - }; + CARD32 HQVfilter[5] = { HQV_V_TAP4_121, HQV_V_TAP4_121, HQV_V_TAP4_121, + HQV_V_TAP8_12221, HQV_V_TAP8_12221 }; /* CARD32 HQVmini[5] = { 0, 0x0c000000, 0x0a000000, 0x09000000, 0x08800000 }; */ /*if (pVia->pBIOSInfo->scaleY) @@ -594,51 +584,51 @@ viaOverlayHQVCalcZoomHeight(VIAPtr pVia, unsigned long srcHeight, * dstHeight = dstHeight + 1; * } */ - if (srcHeight == dstHeight) { /* No zoom */ - *pHQVfilterCtl |= HQV_V_TAP4_121; - } else if (srcHeight < dstHeight) { /* Zoom in */ - - tmp = srcHeight * 0x0400 / dstHeight; - *pZoomCtl |= ((tmp & 0x3ff) | V1_Y_ZOOM_ENABLE); - *pMiniCtl |= (V1_Y_INTERPOLY | V1_YCBCR_INTERPOLY); - - *pHQVzoomflag = 1; - *pHQVfilterCtl |= HQV_V_TAP4_121; - } else { /* srcHeight > dstHeight - Zoom out */ - - /* HQV rounding patch, instead of: - * //tmp = dstHeight*0x0800 / srcHeight; */ - tmp = dstHeight * 0x0800 * 0x400 / srcHeight; - tmp = tmp / 0x400 + ((tmp & 0x3ff) ? 1 : 0); - *pHQVminiCtl |= - ((tmp & 0x7ff) << 16) | HQV_V_MINIFY_ENABLE | HQV_V_MINIFY_DOWN; - - /* Scale down the picture by a factor (1 << d) = {2, 4, 8 or 16} */ - - sh1 = srcHeight; - for (d = 1; d < 5; d++) { - sh1 >>= 1; - if (sh1 <= dstHeight) - break; - } - if (d == 5) { /* Too small. */ - d = 4; - zoom_ok = FALSE; - } - - *pMiniCtl |= ((d << 1) - 1) << 16; /* <= {1,3,5,7} << 16 */ - - *pHQVfilterCtl |= HQVfilter[d]; - /* *pHQVminiCtl |= HQVmini[d]; */ - *pHQVminiCtl |= HQV_VDEBLOCK_FILTER; - - /* Scale to arbitrary size, on top of previous scaling by (1 << d). */ - - if (sh1 < dstHeight) { - tmp = sh1 * 0x0400 / dstHeight; - *pZoomCtl |= ((tmp & 0x3ff) | V1_Y_ZOOM_ENABLE); - *pMiniCtl |= V1_Y_INTERPOLY | V1_YCBCR_INTERPOLY; - } + if (srcHeight == dstHeight) { /* No zoom */ + *pHQVfilterCtl |= HQV_V_TAP4_121; + } else if (srcHeight < dstHeight) { /* Zoom in */ + + tmp = srcHeight * 0x0400 / dstHeight; + *pZoomCtl |= ((tmp & 0x3ff) | V1_Y_ZOOM_ENABLE); + *pMiniCtl |= (V1_Y_INTERPOLY | V1_YCBCR_INTERPOLY); + + *pHQVzoomflag = 1; + *pHQVfilterCtl |= HQV_V_TAP4_121; + } else { /* srcHeight > dstHeight - Zoom out */ + + /* HQV rounding patch, instead of: + * //tmp = dstHeight*0x0800 / srcHeight; */ + tmp = dstHeight * 0x0800 * 0x400 / srcHeight; + tmp = tmp / 0x400 + ((tmp & 0x3ff) ? 1 : 0); + *pHQVminiCtl |= ((tmp & 0x7ff) << 16) | HQV_V_MINIFY_ENABLE + | HQV_V_MINIFY_DOWN; + + /* Scale down the picture by a factor (1 << d) = {2, 4, 8 or 16} */ + + sh1 = srcHeight; + for (d = 1; d < 5; d++) { + sh1 >>= 1; + if (sh1 <= dstHeight) + break; + } + if (d == 5) { /* Too small. */ + d = 4; + zoom_ok = FALSE; + } + + *pMiniCtl |= ((d << 1) - 1) << 16; /* <= {1,3,5,7} << 16 */ + + *pHQVfilterCtl |= HQVfilter[d]; + /* *pHQVminiCtl |= HQVmini[d]; */ + *pHQVminiCtl |= HQV_VDEBLOCK_FILTER; + + /* Scale to arbitrary size, on top of previous scaling by (1 << d). */ + + if (sh1 < dstHeight) { + tmp = sh1 * 0x0400 / dstHeight; + *pZoomCtl |= ((tmp & 0x3ff) | V1_Y_ZOOM_ENABLE); + *pMiniCtl |= V1_Y_INTERPOLY | V1_YCBCR_INTERPOLY; + } } return zoom_ok; @@ -646,55 +636,55 @@ viaOverlayHQVCalcZoomHeight(VIAPtr pVia, unsigned long srcHeight, static unsigned long viaOverlayGetFetch(VIAPtr pVia, unsigned long videoFlag, - unsigned long srcWidth, unsigned long dstWidth, - unsigned long oriSrcWidth, unsigned long *pHQVsrcFetch) + unsigned long srcWidth, unsigned long dstWidth, + unsigned long oriSrcWidth, unsigned long *pHQVsrcFetch) { unsigned long fetch = 0; - int n = 2; /* 2^n bytes per pixel. */ + int n = 2; /* 2^n bytes per pixel. */ switch (pVia->swov.SrcFourCC) { - case FOURCC_YV12: - case FOURCC_XVMC: - n = 0; /* 2^n = 1 byte per pixel (Y channel in planar YUV) */ - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - case FOURCC_RV15: - case FOURCC_RV16: - n = 1; /* 2^n = 2 bytes per pixel (packed YUV) */ - break; - case FOURCC_RV32: - n = 2; - break; - default: - DBG_DD(ErrorF("viaOverlayGetFetch: Invalid FOURCC format (0x%lx).\n", - pVia->swov.SrcFourCC)); - break; + case FOURCC_YV12: + case FOURCC_XVMC: + n = 0; /* 2^n = 1 byte per pixel (Y channel in planar YUV) */ + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + case FOURCC_RV15: + case FOURCC_RV16: + n = 1; /* 2^n = 2 bytes per pixel (packed YUV) */ + break; + case FOURCC_RV32: + n = 2; + break; + default: + DBG_DD(ErrorF("viaOverlayGetFetch: Invalid FOURCC format (0x%lx).\n", + pVia->swov.SrcFourCC)); + break; } if (videoFlag & VIDEO_HQV_INUSE) { - *pHQVsrcFetch = oriSrcWidth << n; - if (n == 0) { - /* Assume n == 0 <=> Planar YUV. - * The V1/V3 pixelformat is always packed YUV when we use HQV, - * so we switch from 8-bit to 16-bit pixels here. - */ - n = 1; - } - if (dstWidth >= srcWidth) - fetch = (ALIGN_TO(srcWidth << n, 16) >> 4) + 1; - else - fetch = (ALIGN_TO(dstWidth << n, 16) >> 4) + 1; + *pHQVsrcFetch = oriSrcWidth << n; + if (n == 0) { + /* Assume n == 0 <=> Planar YUV. + * The V1/V3 pixelformat is always packed YUV when we use HQV, + * so we switch from 8-bit to 16-bit pixels here. + */ + n = 1; + } + if (dstWidth >= srcWidth) + fetch = (ALIGN_TO(srcWidth << n, 16) >> 4) + 1; + else + fetch = (ALIGN_TO(dstWidth << n, 16) >> 4) + 1; } else { - if (n == 0) - fetch = (ALIGN_TO(srcWidth, 32) >> 4); - else - fetch = (ALIGN_TO(srcWidth << n, 16) >> 4) + 1; + if (n == 0) + fetch = (ALIGN_TO(srcWidth, 32) >> 4); + else + fetch = (ALIGN_TO(srcWidth << n, 16) >> 4) + 1; } /* Fix planar mode problem. */ if (fetch < 4) - fetch = 4; + fetch = 4; return fetch; } @@ -744,8 +734,8 @@ static colorCoeff colorCTable[] = { {1.1875, 1.625, 0.875, 0.375, 2.0}, * implemented in the model switch below. */ static void -viaCalculateVideoColor(VIAPtr pVia, int hue, int saturation, int brightness, - int contrast, Bool reset, CARD32 * col1, CARD32 * col2) +viaCalculateVideoColor(VIAPtr pVia, int hue, int saturation, + int brightness, int contrast, Bool reset, CARD32 * col1, CARD32 * col2) { float fA, fB1, fC1, fD, fB2, fC2, fB3, fC3; float fPI, fContrast, fSaturation, fHue, fBrightness; @@ -758,46 +748,47 @@ viaCalculateVideoColor(VIAPtr pVia, int hue, int saturation, int brightness, fPI = (float)(M_PI / 180.); if (reset) { - saturation = 10000; - brightness = 5000; - contrast = 10000; + saturation = 10000; + brightness = 5000; + contrast = 10000; } switch (pVia->ChipId) { - case PCI_CHIP_VT3205: - case PCI_CHIP_VT3204: - case PCI_CHIP_VT3259: - case PCI_CHIP_VT3314: - case PCI_CHIP_VT3336: - case PCI_CHIP_VT3364: - case PCI_CHIP_VT3324: - case PCI_CHIP_VT3327: - model = 0; - break; - case PCI_CHIP_CLE3122: - model = (CLE266_REV_IS_CX(pVia->ChipRev) ? 0 : 1); - break; - default: - ErrorF("Unknown Chip ID\n"); - model = 0; + case PCI_CHIP_VT3205: + case PCI_CHIP_VT3204: + case PCI_CHIP_VT3259: + case PCI_CHIP_VT3314: + case PCI_CHIP_VT3336: + case PCI_CHIP_VT3364: + case PCI_CHIP_VT3324: + case PCI_CHIP_VT3327: + model = 0; + break; + case PCI_CHIP_CLE3122: + model = (CLE266_REV_IS_CX(pVia->ChipRev) ? 0 : 1); + break; + default: + ErrorF("Unknown Chip ID\n"); + model = 0; } switch (model) { - case 0: - fBrightness = - rangeEqualize(0., 10000., -128., 128., -16., (float)brightness); - fContrast = - rangeEqualize(0., 20000., 0., 1.6645, 1.0, (float)contrast); - fSaturation = rangeEqualize(0., 20000, 0., 2., 1., (float)saturation); - break; - default: - fBrightness = - rangeEqualize(0., 10000., -128., 128., -12., (float)brightness); - fContrast = - rangeEqualize(0., 20000., 0., 1.6645, 1.1, (float)contrast); - fSaturation = - rangeEqualize(0., 20000, 0., 2., 1.15, (float)saturation); - break; + case 0: + fBrightness = rangeEqualize(0., 10000., -128., 128., -16., + (float)brightness); + fContrast = rangeEqualize(0., 20000., 0., 1.6645, 1.0, + (float)contrast); + fSaturation = rangeEqualize(0., 20000, 0., 2., 1., + (float)saturation); + break; + default: + fBrightness = rangeEqualize(0., 10000., -128., 128., -12., + (float)brightness); + fContrast = rangeEqualize(0., 20000., 0., 1.6645, 1.1, + (float)contrast); + fSaturation = rangeEqualize(0., 20000, 0., 2., 1.15, + (float)saturation); + break; } fHue = (float)hue; @@ -807,79 +798,78 @@ viaCalculateVideoColor(VIAPtr pVia, int hue, int saturation, int brightness, fB1 = (float)(-mCoeff[1] * fContrast * fSaturation * sin(fHue * fPI)); fC1 = (float)(mCoeff[1] * fContrast * fSaturation * cos(fHue * fPI)); fD = (float)(mCoeff[0] * (fBrightness)); - fB2 = (float)((mCoeff[2] * sin(fHue * fPI) - - mCoeff[3] * cos(fHue * fPI)) * fContrast * fSaturation); - fC2 = (float)(-(mCoeff[2] * cos(fHue * fPI) + - mCoeff[3] * sin(fHue * fPI)) * fContrast * fSaturation); + fB2 = (float)((mCoeff[2] * sin(fHue * fPI) - mCoeff[3] * cos(fHue * fPI)) + * fContrast * fSaturation); + fC2 = (float)(-(mCoeff[2] * cos(fHue * fPI) + mCoeff[3] * sin(fHue * fPI)) + * fContrast * fSaturation); fB3 = (float)(mCoeff[4] * fContrast * fSaturation * cos(fHue * fPI)); fC3 = (float)(mCoeff[4] * fContrast * fSaturation * sin(fHue * fPI)); switch (model) { - case 0: - dwA = vPackFloat(fA, 1.9375, 0., 32., 5, 0); - dwB1 = vPackFloat(fB1, 2.125, -2.125, 16., 5, 1); - dwC1 = vPackFloat(fC1, 2.125, -2.125, 16., 5, 1); - - if (fD >= 0) { - intD = (int)fD; - if (intD > 127) - intD = 127; - dwD_Int = ((unsigned long)intD) & 0xff; - dwD = ((unsigned long)(fD * 16 + 1)) >> 1; - dwD_Dec = dwD & 0x7; - } else { - intD = (int)fD; - if (intD < -128) - intD = -128; - intD = intD + 256; - dwD_Int = ((unsigned long)intD) & 0xff; - fD = -fD; - dwD = ((unsigned long)(fD * 16 + 1)) >> 1; - dwD_Dec = dwD & 0x7; - } - - dwB2 = vPackFloat(fB2, 1.875, -1.875, 16, 4, 1); - dwC2 = vPackFloat(fC2, 1.875, -1.875, 16, 4, 1); - dwB3 = vPackFloat(fB3, 3.875, -3.875, 16, 5, 1); - dwC3 = vPackFloat(fC3, 3.875, -3.875, 16, 5, 1); - *col1 = (dwA << 24) | (dwB1 << 16) | (dwC1 << 8) | dwD_Int; - *col2 = - (dwD_Dec << 29 | dwB2 << 24) | (dwC2 << 16) | (dwB3 << 8) | - (dwC3); - break; - - default: - dwA = vPackFloat(fA, 1.9375, -0., 32, 5, 0); - dwB1 = vPackFloat(fB1, 0.75, -0.75, 8., 2, 1); - dwC1 = vPackFloat(fC1, 2.875, 1., 16., 5, 0); - - if (fD >= 127) - fD = 127; - - if (fD <= -128) - fD = -128; - - if (fD >= 0) { - dwS = 0; - } else { - dwS = 1; - fD = fD + 128; - } - - dwD = ((unsigned long)(fD * 2 + 1)) >> 1; - if (dwD >= 0x7f) { - dwD = 0x7f | (dwS << 7); - } else { - dwD = (dwD & 0x7f) | (dwS << 7); - } - - dwB2 = vPackFloat(fB2, 0., -0.875, 16., 3, 0); - dwC2 = vPackFloat(fC2, 0., -1.875, 16., 4, 0); - dwB3 = vPackFloat(fB3, 3.75, 0., 8., 4, 0); - dwC3 = vPackFloat(fC3, 1.25, -1.25, 8., 3, 1); - *col1 = (dwA << 24) | (dwB1 << 18) | (dwC1 << 9) | dwD; - *col2 = (dwB2 << 25) | (dwC2 << 17) | (dwB3 << 10) | (dwC3 << 2); - break; + case 0: + dwA = vPackFloat(fA, 1.9375, 0., 32., 5, 0); + dwB1 = vPackFloat(fB1, 2.125, -2.125, 16., 5, 1); + dwC1 = vPackFloat(fC1, 2.125, -2.125, 16., 5, 1); + + if (fD >= 0) { + intD = (int)fD; + if (intD > 127) + intD = 127; + dwD_Int = ((unsigned long)intD) & 0xff; + dwD = ((unsigned long)(fD * 16 + 1)) >> 1; + dwD_Dec = dwD & 0x7; + } else { + intD = (int)fD; + if (intD < -128) + intD = -128; + intD = intD + 256; + dwD_Int = ((unsigned long)intD) & 0xff; + fD = -fD; + dwD = ((unsigned long)(fD * 16 + 1)) >> 1; + dwD_Dec = dwD & 0x7; + } + + dwB2 = vPackFloat(fB2, 1.875, -1.875, 16, 4, 1); + dwC2 = vPackFloat(fC2, 1.875, -1.875, 16, 4, 1); + dwB3 = vPackFloat(fB3, 3.875, -3.875, 16, 5, 1); + dwC3 = vPackFloat(fC3, 3.875, -3.875, 16, 5, 1); + *col1 = (dwA << 24) | (dwB1 << 16) | (dwC1 << 8) | dwD_Int; + *col2 = (dwD_Dec << 29 | dwB2 << 24) | (dwC2 << 16) | (dwB3 << 8) + | (dwC3); + break; + + default: + dwA = vPackFloat(fA, 1.9375, -0., 32, 5, 0); + dwB1 = vPackFloat(fB1, 0.75, -0.75, 8., 2, 1); + dwC1 = vPackFloat(fC1, 2.875, 1., 16., 5, 0); + + if (fD >= 127) + fD = 127; + + if (fD <= -128) + fD = -128; + + if (fD >= 0) { + dwS = 0; + } else { + dwS = 1; + fD = fD + 128; + } + + dwD = ((unsigned long)(fD * 2 + 1)) >> 1; + if (dwD >= 0x7f) { + dwD = 0x7f | (dwS << 7); + } else { + dwD = (dwD & 0x7f) | (dwS << 7); + } + + dwB2 = vPackFloat(fB2, 0., -0.875, 16., 3, 0); + dwC2 = vPackFloat(fC2, 0., -1.875, 16., 4, 0); + dwB3 = vPackFloat(fB3, 3.75, 0., 8., 4, 0); + dwC3 = vPackFloat(fC3, 1.25, -1.25, 8., 3, 1); + *col1 = (dwA << 24) | (dwB1 << 18) | (dwC1 << 9) | dwD; + *col2 = (dwB2 << 25) | (dwC2 << 17) | (dwB3 << 10) | (dwC3 << 2); + break; } } @@ -889,38 +879,38 @@ viaCalculateVideoColor(VIAPtr pVia, int hue, int saturation, int brightness, */ void viaSetColorSpace(VIAPtr pVia, int hue, int saturation, int brightness, - int contrast, Bool reset) + int contrast, Bool reset) { CARD32 col1, col2; viaCalculateVideoColor(pVia, hue, saturation, brightness, contrast, reset, - &col1, &col2); + &col1, &col2); switch (pVia->ChipId) { - case PCI_CHIP_VT3205: - case PCI_CHIP_VT3204: - case PCI_CHIP_VT3259: - case PCI_CHIP_VT3314: - VIDOutD(V3_ColorSpaceReg_1, col1); - VIDOutD(V3_ColorSpaceReg_2, col2); - DBG_DD(ErrorF("000002C4 %08lx\n", col1)); - DBG_DD(ErrorF("000002C8 %08lx\n", col2)); - break; - case PCI_CHIP_VT3327: - case PCI_CHIP_VT3336: - case PCI_CHIP_VT3324: - case PCI_CHIP_VT3364: - case PCI_CHIP_CLE3122: - VIDOutD(V1_ColorSpaceReg_2, col2); - VIDOutD(V1_ColorSpaceReg_1, col1); - VIDOutD(V3_ColorSpaceReg_2, col2); - VIDOutD(V3_ColorSpaceReg_1, col1); - - DBG_DD(ErrorF("00000288 %08lx\n", col2)); - DBG_DD(ErrorF("00000284 %08lx\n", col1)); - break; - default: - DBG_DD(ErrorF("Unknown DeviceID\n")); - break; + case PCI_CHIP_VT3205: + case PCI_CHIP_VT3204: + case PCI_CHIP_VT3259: + case PCI_CHIP_VT3314: + VIDOutD(V3_ColorSpaceReg_1, col1); + VIDOutD(V3_ColorSpaceReg_2, col2); + DBG_DD(ErrorF("000002C4 %08lx\n", col1)); + DBG_DD(ErrorF("000002C8 %08lx\n", col2)); + break; + case PCI_CHIP_VT3327: + case PCI_CHIP_VT3336: + case PCI_CHIP_VT3324: + case PCI_CHIP_VT3364: + case PCI_CHIP_CLE3122: + VIDOutD(V1_ColorSpaceReg_2, col2); + VIDOutD(V1_ColorSpaceReg_1, col1); + VIDOutD(V3_ColorSpaceReg_2, col2); + VIDOutD(V3_ColorSpaceReg_1, col1); + + DBG_DD(ErrorF("00000288 %08lx\n", col2)); + DBG_DD(ErrorF("00000284 %08lx\n", col1)); + break; + default: + DBG_DD(ErrorF("Unknown DeviceID\n")); + break; } } @@ -928,22 +918,22 @@ static unsigned long ViaInitVideoStatusFlag(VIAPtr pVia) { switch (pVia->ChipId) { - case PCI_CHIP_VT3205: - case PCI_CHIP_VT3204: - case PCI_CHIP_VT3259: - case PCI_CHIP_VT3314: - return VIDEO_HQV_INUSE | SW_USE_HQV | VIDEO_3_INUSE; - case PCI_CHIP_VT3327: - case PCI_CHIP_VT3336: - case PCI_CHIP_VT3324: - case PCI_CHIP_VT3364: - return VIDEO_HQV_INUSE | SW_USE_HQV | VIDEO_1_INUSE | \ - VIDEO_ACTIVE | VIDEO_SHOW; - case PCI_CHIP_CLE3122: - return VIDEO_HQV_INUSE | SW_USE_HQV | VIDEO_1_INUSE; - default: - DBG_DD(ErrorF("Unknown DeviceID\n")); - break; + case PCI_CHIP_VT3205: + case PCI_CHIP_VT3204: + case PCI_CHIP_VT3259: + case PCI_CHIP_VT3314: + return VIDEO_HQV_INUSE | SW_USE_HQV | VIDEO_3_INUSE; + case PCI_CHIP_VT3327: + case PCI_CHIP_VT3336: + case PCI_CHIP_VT3324: + case PCI_CHIP_VT3364: + return VIDEO_HQV_INUSE | SW_USE_HQV | VIDEO_1_INUSE | + VIDEO_ACTIVE | VIDEO_SHOW; + case PCI_CHIP_CLE3122: + return VIDEO_HQV_INUSE | SW_USE_HQV | VIDEO_1_INUSE; + default: + DBG_DD(ErrorF("Unknown DeviceID\n")); + break; } return 0UL; } @@ -952,39 +942,39 @@ static unsigned long ViaSetVidCtl(VIAPtr pVia, unsigned int videoFlag) { if (videoFlag & VIDEO_1_INUSE) { - /*=* Modify for C1 FIFO *=*/ - /* WARNING: not checking Chipset! */ - if (CLE266_REV_IS_CX(pVia->ChipRev)) - return V1_ENABLE | V1_EXPIRE_NUM_F; - else { - /* Overlay source format for V1 */ - if (pVia->swov.gdwUseExtendedFIFO) - return V1_ENABLE | V1_EXPIRE_NUM_A | V1_FIFO_EXTENDED; - else - return V1_ENABLE | V1_EXPIRE_NUM; - } + /*=* Modify for C1 FIFO *=*/ + /* WARNING: not checking Chipset! */ + if (CLE266_REV_IS_CX(pVia->ChipRev)) + return V1_ENABLE | V1_EXPIRE_NUM_F; + else { + /* Overlay source format for V1 */ + if (pVia->swov.gdwUseExtendedFIFO) + return V1_ENABLE | V1_EXPIRE_NUM_A | V1_FIFO_EXTENDED; + else + return V1_ENABLE | V1_EXPIRE_NUM; + } } else { - switch (pVia->ChipId) { - case PCI_CHIP_VT3205: - case PCI_CHIP_VT3204: - case PCI_CHIP_VT3259: - case PCI_CHIP_VT3314: - return V3_ENABLE | V3_EXPIRE_NUM_3205; - case PCI_CHIP_VT3327: - case PCI_CHIP_VT3336: - case PCI_CHIP_VT3324: - case PCI_CHIP_VT3364: - return V3_ENABLE | VIDEO_EXPIRE_NUM_VT3336; - case PCI_CHIP_CLE3122: - if (CLE266_REV_IS_CX(pVia->ChipRev)) - return V3_ENABLE | V3_EXPIRE_NUM_F; - else - return V3_ENABLE | V3_EXPIRE_NUM; - break; - default: - DBG_DD(ErrorF("Unknown DeviceID\n")); - break; - } + switch (pVia->ChipId) { + case PCI_CHIP_VT3205: + case PCI_CHIP_VT3204: + case PCI_CHIP_VT3259: + case PCI_CHIP_VT3314: + return V3_ENABLE | V3_EXPIRE_NUM_3205; + case PCI_CHIP_VT3327: + case PCI_CHIP_VT3336: + case PCI_CHIP_VT3324: + case PCI_CHIP_VT3364: + return V3_ENABLE | VIDEO_EXPIRE_NUM_VT3336; + case PCI_CHIP_CLE3122: + if (CLE266_REV_IS_CX(pVia->ChipRev)) + return V3_ENABLE | V3_EXPIRE_NUM_F; + else + return V3_ENABLE | V3_EXPIRE_NUM; + break; + default: + DBG_DD(ErrorF("Unknown DeviceID\n")); + break; + } } return 0; } @@ -1017,13 +1007,14 @@ AddHQVSurface(ScrnInfoPtr pScrn, unsigned int numbuf, CARD32 fourcc) unsigned long retCode; BOOL isplanar; - VIAPtr pVia = VIAPTR(pScrn); - CARD32 AddrReg[3] = - { HQV_DST_STARTADDR0, HQV_DST_STARTADDR1, HQV_DST_STARTADDR2 }; + VIAPtr pVia= VIAPTR(pScrn); + CARD32 AddrReg[3] = { HQV_DST_STARTADDR0, HQV_DST_STARTADDR1, + HQV_DST_STARTADDR2 }; unsigned long proReg = 0; - if (pVia->ChipId == PCI_CHIP_VT3259 && !(pVia->swov.gdwVideoFlagSW & VIDEO_1_INUSE)) - proReg = PRO_HQV1_OFFSET; + if (pVia->ChipId == PCI_CHIP_VT3259 && !(pVia->swov.gdwVideoFlagSW + & VIDEO_1_INUSE)) + proReg = PRO_HQV1_OFFSET; isplanar = ((fourcc == FOURCC_YV12) || (fourcc == FOURCC_XVMC)); @@ -1035,15 +1026,15 @@ AddHQVSurface(ScrnInfoPtr pScrn, unsigned int numbuf, CARD32 fourcc) VIAFreeLinear(&pVia->swov.HQVMem); retCode = VIAAllocLinear(&pVia->swov.HQVMem, pScrn, fbsize * numbuf); if (retCode != Success) - return retCode; + return retCode; addr = pVia->swov.HQVMem.base; ViaYUVFillBlack(pVia, addr, fbsize); for (i = 0; i < numbuf; i++) { - pVia->swov.overlayRecordV1.dwHQVAddr[i] = addr; - VIDOutD(AddrReg[i] + proReg, addr); - addr += fbsize; + pVia->swov.overlayRecordV1.dwHQVAddr[i] = addr; + VIDOutD(AddrReg[i] + proReg, addr); + addr += fbsize; } return Success; @@ -1055,9 +1046,9 @@ AddHQVSurface(ScrnInfoPtr pScrn, unsigned int numbuf, CARD32 fourcc) */ static long CreateSurface(ScrnInfoPtr pScrn, CARD32 FourCC, CARD16 Width, - CARD16 Height, BOOL doalloc) + CARD16 Height, BOOL doalloc) { - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); unsigned long pitch, fbsize, addr; unsigned long retCode; BOOL isplanar; @@ -1067,49 +1058,51 @@ CreateSurface(ScrnInfoPtr pScrn, CARD32 FourCC, CARD16 Width, isplanar = FALSE; switch (FourCC) { - case FOURCC_YV12: - case FOURCC_XVMC: - isplanar = TRUE; - pitch = ALIGN_TO(Width, 32); - fbsize = pitch * Height * 1.5; - break; - case FOURCC_RV32: - pitch = ALIGN_TO(Width << 2, 32); - fbsize = pitch * Height; - break; - default: - pitch = ALIGN_TO(Width << 1, 32); - fbsize = pitch * Height; - break; + case FOURCC_YV12: + case FOURCC_XVMC: + isplanar = TRUE; + pitch = ALIGN_TO(Width, 32); + fbsize = pitch * Height * 1.5; + break; + case FOURCC_RV32: + pitch = ALIGN_TO(Width << 2, 32); + fbsize = pitch * Height; + break; + default: + pitch = ALIGN_TO(Width << 1, 32); + fbsize = pitch * Height; + break; } if (doalloc) { - VIAFreeLinear(&pVia->swov.SWfbMem); - retCode = VIAAllocLinear(&pVia->swov.SWfbMem, pScrn, fbsize * 2); - if (retCode != Success) - return retCode; - addr = pVia->swov.SWfbMem.base; - - ViaYUVFillBlack(pVia, addr, fbsize); - - pVia->swov.SWDevice.dwSWPhysicalAddr[0] = addr; - pVia->swov.SWDevice.dwSWPhysicalAddr[1] = addr + fbsize; - pVia->swov.SWDevice.lpSWOverlaySurface[0] = pVia->FBBase + addr; - pVia->swov.SWDevice.lpSWOverlaySurface[1] = - pVia->swov.SWDevice.lpSWOverlaySurface[0] + fbsize; - - if (isplanar) { - pVia->swov.SWDevice.dwSWCrPhysicalAddr[0] = - pVia->swov.SWDevice.dwSWPhysicalAddr[0] + (pitch * Height); - pVia->swov.SWDevice.dwSWCrPhysicalAddr[1] = - pVia->swov.SWDevice.dwSWPhysicalAddr[1] + (pitch * Height); - pVia->swov.SWDevice.dwSWCbPhysicalAddr[0] = - pVia->swov.SWDevice.dwSWCrPhysicalAddr[0] + - ((pitch >> 1) * (Height >> 1)); - pVia->swov.SWDevice.dwSWCbPhysicalAddr[1] = - pVia->swov.SWDevice.dwSWCrPhysicalAddr[1] + - ((pitch >> 1) * (Height >> 1)); - } + VIAFreeLinear(&pVia->swov.SWfbMem); + retCode = VIAAllocLinear(&pVia->swov.SWfbMem, pScrn, fbsize * 2); + if (retCode != Success) + return retCode; + addr = pVia->swov.SWfbMem.base; + + ViaYUVFillBlack(pVia, addr, fbsize); + + pVia->swov.SWDevice.dwSWPhysicalAddr[0] = addr; + pVia->swov.SWDevice.dwSWPhysicalAddr[1] = addr + fbsize; + pVia->swov.SWDevice.lpSWOverlaySurface[0] = pVia->FBBase + addr; + pVia->swov.SWDevice.lpSWOverlaySurface[1] + = pVia->swov.SWDevice.lpSWOverlaySurface[0] + fbsize; + + if (isplanar) { + pVia->swov.SWDevice.dwSWCrPhysicalAddr[0] + = pVia->swov.SWDevice.dwSWPhysicalAddr[0] + + (pitch * Height); + pVia->swov.SWDevice.dwSWCrPhysicalAddr[1] + = pVia->swov.SWDevice.dwSWPhysicalAddr[1] + + (pitch * Height); + pVia->swov.SWDevice.dwSWCbPhysicalAddr[0] + = pVia->swov.SWDevice.dwSWCrPhysicalAddr[0] + ((pitch >> 1) + * (Height >> 1)); + pVia->swov.SWDevice.dwSWCbPhysicalAddr[1] + = pVia->swov.SWDevice.dwSWCrPhysicalAddr[1] + ((pitch >> 1) + * (Height >> 1)); + } } pVia->swov.SWDevice.gdwSWSrcWidth = Width; @@ -1127,64 +1120,63 @@ CreateSurface(ScrnInfoPtr pScrn, CARD32 FourCC, CARD16 Width, * */ int -ViaSwovSurfaceCreate(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv, CARD32 FourCC, - CARD16 Width, CARD16 Height) +ViaSwovSurfaceCreate(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv, + CARD32 FourCC, CARD16 Width, CARD16 Height) { - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); unsigned long retCode = Success; int numbuf = pVia->HWDiff.dwThreeHQVBuffer ? 3 : 2; DBG_DD(ErrorF("ViaSwovSurfaceCreate: FourCC =0x%08lx\n", FourCC)); - if ((pVia->VideoStatus & VIDEO_SWOV_SURFACE_CREATED) && - (FourCC == pPriv->FourCC)) - return Success; + if ((pVia->VideoStatus & VIDEO_SWOV_SURFACE_CREATED) && (FourCC + == pPriv->FourCC)) + return Success; pPriv->FourCC = FourCC; switch (FourCC) { - case FOURCC_YUY2: - case FOURCC_RV15: - case FOURCC_RV16: - case FOURCC_RV32: - retCode = CreateSurface(pScrn, FourCC, Width, Height, TRUE); - if (retCode != Success) - break; - if ((pVia->swov.gdwVideoFlagSW & SW_USE_HQV)) - retCode = AddHQVSurface(pScrn, numbuf, FourCC); - break; - - case FOURCC_HQVSW: - retCode = AddHQVSurface(pScrn, numbuf, FOURCC_YUY2); - break; - - case FOURCC_YV12: - retCode = CreateSurface(pScrn, FourCC, Width, Height, TRUE); - if (retCode == Success) - retCode = AddHQVSurface(pScrn, numbuf, FOURCC_YV12); - break; - - case FOURCC_XVMC: - retCode = CreateSurface(pScrn, FourCC, Width, Height, FALSE); - if (retCode == Success) - retCode = AddHQVSurface(pScrn, numbuf, FOURCC_XVMC); - break; - - default: - break; + case FOURCC_YUY2: + case FOURCC_RV15: + case FOURCC_RV16: + case FOURCC_RV32: + retCode = CreateSurface(pScrn, FourCC, Width, Height, TRUE); + if (retCode != Success) + break; + if ((pVia->swov.gdwVideoFlagSW & SW_USE_HQV)) + retCode = AddHQVSurface(pScrn, numbuf, FourCC); + break; + + case FOURCC_HQVSW: + retCode = AddHQVSurface(pScrn, numbuf, FOURCC_YUY2); + break; + + case FOURCC_YV12: + retCode = CreateSurface(pScrn, FourCC, Width, Height, TRUE); + if (retCode == Success) + retCode = AddHQVSurface(pScrn, numbuf, FOURCC_YV12); + break; + + case FOURCC_XVMC: + retCode = CreateSurface(pScrn, FourCC, Width, Height, FALSE); + if (retCode == Success) + retCode = AddHQVSurface(pScrn, numbuf, FOURCC_XVMC); + break; + + default: + break; } if (retCode == Success) { - pVia->swov.SWDevice.lpSWOverlaySurface[0] = - pVia->FBBase + pVia->swov.SWDevice.dwSWPhysicalAddr[0]; - pVia->swov.SWDevice.lpSWOverlaySurface[1] = - pVia->FBBase + pVia->swov.SWDevice.dwSWPhysicalAddr[1]; + pVia->swov.SWDevice.lpSWOverlaySurface[0] = pVia->FBBase + + pVia->swov.SWDevice.dwSWPhysicalAddr[0]; + pVia->swov.SWDevice.lpSWOverlaySurface[1] = pVia->FBBase + + pVia->swov.SWDevice.dwSWPhysicalAddr[1]; - DBG_DD(ErrorF(" lpSWOverlaySurface[0]: %p\n", - pVia->swov.SWDevice.lpSWOverlaySurface[0])); - DBG_DD(ErrorF(" lpSWOverlaySurface[1]: %p\n", - pVia->swov.SWDevice.lpSWOverlaySurface[1])); + DBG_DD(ErrorF(" lpSWOverlaySurface[0]: %p\n", + pVia->swov.SWDevice.lpSWOverlaySurface[0]));DBG_DD(ErrorF(" lpSWOverlaySurface[1]: %p\n", + pVia->swov.SWDevice.lpSWOverlaySurface[1])); - pVia->VideoStatus |= VIDEO_SWOV_SURFACE_CREATED | VIDEO_SWOV_ON; + pVia->VideoStatus |= VIDEO_SWOV_SURFACE_CREATED | VIDEO_SWOV_ON; } return retCode; } @@ -1192,52 +1184,52 @@ ViaSwovSurfaceCreate(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv, CARD32 FourCC, /* * Destroy Surface */ -void +void ViaSwovSurfaceDestroy(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv) { - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); DBG_DD(ErrorF("ViaSwovSurfaceDestroy: FourCC =0x%08lx\n", pPriv->FourCC)); if (pVia->VideoStatus & VIDEO_SWOV_SURFACE_CREATED) { - DBG_DD(ErrorF("ViaSwovSurfaceDestroy: VideoStatus =0x%08lx\n", - pVia->VideoStatus)); - - switch (pPriv->FourCC) { - case FOURCC_YUY2: - case FOURCC_RV16: - case FOURCC_RV32: - case FOURCC_RV15: - pVia->swov.SrcFourCC = 0; - - VIAFreeLinear(&pVia->swov.SWfbMem); - if ((pVia->swov.gdwVideoFlagSW & SW_USE_HQV)) - VIAFreeLinear(&pVia->swov.HQVMem); - pVia->swov.gdwVideoFlagSW = 0; - break; - - case FOURCC_HQVSW: - VIAFreeLinear(&pVia->swov.HQVMem); - pVia->swov.gdwVideoFlagSW = 0; - break; - - case FOURCC_YV12: - VIAFreeLinear(&pVia->swov.SWfbMem); - case FOURCC_XVMC: - pVia->swov.SrcFourCC = 0; - - VIAFreeLinear(&pVia->swov.HQVMem); - pVia->swov.gdwVideoFlagSW = 0; - break; - } - - pPriv->FourCC = 0; - pVia->VideoStatus &= ~VIDEO_SWOV_SURFACE_CREATED; + DBG_DD(ErrorF("ViaSwovSurfaceDestroy: VideoStatus =0x%08lx\n", + pVia->VideoStatus)); + + switch (pPriv->FourCC) { + case FOURCC_YUY2: + case FOURCC_RV16: + case FOURCC_RV32: + case FOURCC_RV15: + pVia->swov.SrcFourCC = 0; + + VIAFreeLinear(&pVia->swov.SWfbMem); + if ((pVia->swov.gdwVideoFlagSW & SW_USE_HQV)) + VIAFreeLinear(&pVia->swov.HQVMem); + pVia->swov.gdwVideoFlagSW = 0; + break; + + case FOURCC_HQVSW: + VIAFreeLinear(&pVia->swov.HQVMem); + pVia->swov.gdwVideoFlagSW = 0; + break; + + case FOURCC_YV12: + VIAFreeLinear(&pVia->swov.SWfbMem); + case FOURCC_XVMC: + pVia->swov.SrcFourCC = 0; + + VIAFreeLinear(&pVia->swov.HQVMem); + pVia->swov.gdwVideoFlagSW = 0; + break; + } + + pPriv->FourCC = 0; + pVia->VideoStatus &= ~VIDEO_SWOV_SURFACE_CREATED; } else - DBG_DD(ErrorF - ("ViaSwovSurfaceDestroy: No SW Overlay Surface Destroyed," - " VideoStatus =0x%08lx\n", pVia->VideoStatus)); + DBG_DD(ErrorF + ("ViaSwovSurfaceDestroy: No SW Overlay Surface Destroyed," + " VideoStatus =0x%08lx\n", pVia->VideoStatus)); } static void @@ -1250,7 +1242,10 @@ SetFIFO_V1(VIAPtr pVia, CARD8 depth, CARD8 prethreshold, CARD8 threshold) static void SetFIFO_V3(VIAPtr pVia, CARD8 depth, CARD8 prethreshold, CARD8 threshold) { - if ((pVia->ChipId == PCI_CHIP_VT3314) || (pVia->ChipId == PCI_CHIP_VT3324) || (pVia->ChipId == PCI_CHIP_VT3327)) { + if ((pVia->ChipId == PCI_CHIP_VT3314) + || (pVia->ChipId == PCI_CHIP_VT3324) + || (pVia->ChipId == PCI_CHIP_VT3327)) { + SaveVideoRegister(pVia, ALPHA_V3_FIFO_CONTROL, (VIDInD(ALPHA_V3_FIFO_CONTROL) & ALPHA_FIFO_MASK) | ((depth - 1) & 0xff) | ((threshold & 0xff) << 8)); @@ -1258,6 +1253,7 @@ SetFIFO_V3(VIAPtr pVia, CARD8 depth, CARD8 prethreshold, CARD8 threshold) (VIDInD(ALPHA_V3_PREFIFO_CONTROL) & ~V3_FIFO_MASK_3314) | (prethreshold & 0xff)); } else { + SaveVideoRegister(pVia, ALPHA_V3_FIFO_CONTROL, (VIDInD(ALPHA_V3_FIFO_CONTROL) & ALPHA_FIFO_MASK) | ((depth - 1) & 0xff) | ((threshold & 0xff) << 8)); @@ -1273,9 +1269,9 @@ SetFIFO_64or32(VIAPtr pVia) /*=* Modify for C1 FIFO *=*/ /* WARNING: not checking Chipset! */ if (CLE266_REV_IS_CX(pVia->ChipRev)) - SetFIFO_V1(pVia, 64, 56, 56); + SetFIFO_V1(pVia, 64, 56, 56); else - SetFIFO_V1(pVia, 32, 29, 16); + SetFIFO_V1(pVia, 32, 29, 16); } static void @@ -1284,9 +1280,9 @@ SetFIFO_64or16(VIAPtr pVia) /*=* Modify for C1 FIFO *=*/ /* WARNING: not checking Chipset! */ if (CLE266_REV_IS_CX(pVia->ChipRev)) - SetFIFO_V1(pVia, 64, 56, 56); + SetFIFO_V1(pVia, 64, 56, 56); else - SetFIFO_V1(pVia, 16, 12, 8); + SetFIFO_V1(pVia, 16, 12, 8); } static void @@ -1295,12 +1291,12 @@ SetFIFO_64or48or32(VIAPtr pVia) /*=* Modify for C1 FIFO *=*/ /* WARNING: not checking Chipset! */ if (CLE266_REV_IS_CX(pVia->ChipRev)) - SetFIFO_V1(pVia, 64, 56, 56); + SetFIFO_V1(pVia, 64, 56, 56); else { - if (pVia->swov.gdwUseExtendedFIFO) - SetFIFO_V1(pVia, 48, 40, 40); - else - SetFIFO_V1(pVia, 32, 29, 16); + if (pVia->swov.gdwUseExtendedFIFO) + SetFIFO_V1(pVia, 48, 40, 40); + else + SetFIFO_V1(pVia, 32, 29, 16); } } @@ -1308,30 +1304,30 @@ static void SetFIFO_V3_64or32or32(VIAPtr pVia) { switch (pVia->ChipId) { - case PCI_CHIP_VT3327: - case PCI_CHIP_VT3336: - case PCI_CHIP_VT3324: - case PCI_CHIP_VT3364: - SetFIFO_V3(pVia, 225, 200, 250); - break; - case PCI_CHIP_VT3204: - SetFIFO_V3(pVia, 100, 89, 89); - break; - case PCI_CHIP_VT3314: - SetFIFO_V3(pVia, 64, 61, 61); - break; - case PCI_CHIP_VT3205: - case PCI_CHIP_VT3259: - SetFIFO_V3(pVia, 32, 29, 29); - break; - case PCI_CHIP_CLE3122: - if (CLE266_REV_IS_CX(pVia->ChipRev)) - SetFIFO_V3(pVia, 64, 56, 56); - else - SetFIFO_V3(pVia, 32, 16, 16); - break; - default: - break; + case PCI_CHIP_VT3327: + case PCI_CHIP_VT3336: + case PCI_CHIP_VT3324: + case PCI_CHIP_VT3364: + SetFIFO_V3(pVia, 225, 200, 250); + break; + case PCI_CHIP_VT3204: + SetFIFO_V3(pVia, 100, 89, 89); + break; + case PCI_CHIP_VT3314: + SetFIFO_V3(pVia, 64, 61, 61); + break; + case PCI_CHIP_VT3205: + case PCI_CHIP_VT3259: + SetFIFO_V3(pVia, 32, 29, 29); + break; + case PCI_CHIP_CLE3122: + if (CLE266_REV_IS_CX(pVia->ChipRev)) + SetFIFO_V3(pVia, 64, 56, 56); + else + SetFIFO_V3(pVia, 32, 16, 16); + break; + default: + break; } } @@ -1339,130 +1335,129 @@ static void SetFIFO_V3_64or32or16(VIAPtr pVia) { switch (pVia->ChipId) { - case PCI_CHIP_VT3327: - case PCI_CHIP_VT3336: - case PCI_CHIP_VT3324: - case PCI_CHIP_VT3364: - SetFIFO_V3(pVia, 225, 200, 250); - break; - case PCI_CHIP_VT3204: - SetFIFO_V3(pVia, 100, 89, 89); - break; - case PCI_CHIP_VT3314: - SetFIFO_V3(pVia, 64, 61, 61); - break; - case PCI_CHIP_VT3205: - case PCI_CHIP_VT3259: - SetFIFO_V3(pVia, 32, 29, 29); - break; - - case PCI_CHIP_CLE3122: - if (CLE266_REV_IS_CX(pVia->ChipRev)) - SetFIFO_V3(pVia, 64, 56, 56); - else - SetFIFO_V3(pVia, 16, 16, 8); - break; - - default: - break; + case PCI_CHIP_VT3327: + case PCI_CHIP_VT3336: + case PCI_CHIP_VT3324: + case PCI_CHIP_VT3364: + SetFIFO_V3(pVia, 225, 200, 250); + break; + case PCI_CHIP_VT3204: + SetFIFO_V3(pVia, 100, 89, 89); + break; + case PCI_CHIP_VT3314: + SetFIFO_V3(pVia, 64, 61, 61); + break; + case PCI_CHIP_VT3205: + case PCI_CHIP_VT3259: + SetFIFO_V3(pVia, 32, 29, 29); + break; + + case PCI_CHIP_CLE3122: + if (CLE266_REV_IS_CX(pVia->ChipRev)) + SetFIFO_V3(pVia, 64, 56, 56); + else + SetFIFO_V3(pVia, 16, 16, 8); + break; + + default: + break; } } static void -SetupFIFOs(VIAPtr pVia, unsigned long videoFlag, unsigned long miniCtl, - unsigned long srcWidth) +SetupFIFOs(VIAPtr pVia, unsigned long videoFlag, + unsigned long miniCtl, unsigned long srcWidth) { if (miniCtl & V1_Y_INTERPOLY) { - if (pVia->swov.SrcFourCC == FOURCC_YV12 || - pVia->swov.SrcFourCC == FOURCC_XVMC) { - if (videoFlag & VIDEO_HQV_INUSE) { - if (videoFlag & VIDEO_1_INUSE) - SetFIFO_64or32(pVia); - else - SetFIFO_V3_64or32or16(pVia); - } else { - /* Minified video will be skewed without this workaround. */ - if (srcWidth <= 80) { /* Fetch count <= 5 */ - if (videoFlag & VIDEO_1_INUSE) - SetFIFO_V1(pVia, 16, 0, 0); - else - SetFIFO_V3(pVia, 16, 16, 0); - } else { - if (videoFlag & VIDEO_1_INUSE) - SetFIFO_64or16(pVia); - else - SetFIFO_V3_64or32or16(pVia); - } - } - } else { - if (videoFlag & VIDEO_1_INUSE) - SetFIFO_64or48or32(pVia); - else { - /* Fix V3 bug. */ - if (srcWidth <= 8) - SetFIFO_V3(pVia, 1, 0, 0); - else - SetFIFO_V3_64or32or32(pVia); - } - } + if (pVia->swov.SrcFourCC == FOURCC_YV12 || pVia->swov.SrcFourCC + == FOURCC_XVMC) { + if (videoFlag & VIDEO_HQV_INUSE) { + if (videoFlag & VIDEO_1_INUSE) + SetFIFO_64or32(pVia); + else + SetFIFO_V3_64or32or16(pVia); + } else { + /* Minified video will be skewed without this workaround. */ + if (srcWidth <= 80) { /* Fetch count <= 5 */ + if (videoFlag & VIDEO_1_INUSE) + SetFIFO_V1(pVia, 16, 0, 0); + else + SetFIFO_V3(pVia, 16, 16, 0); + } else { + if (videoFlag & VIDEO_1_INUSE) + SetFIFO_64or16(pVia); + else + SetFIFO_V3_64or32or16(pVia); + } + } + } else { + if (videoFlag & VIDEO_1_INUSE) + SetFIFO_64or48or32(pVia); + else { + /* Fix V3 bug. */ + if (srcWidth <= 8) + SetFIFO_V3(pVia, 1, 0, 0); + else + SetFIFO_V3_64or32or32(pVia); + } + } } else { - if (pVia->swov.SrcFourCC == FOURCC_YV12 || - pVia->swov.SrcFourCC == FOURCC_XVMC) { - if (videoFlag & VIDEO_HQV_INUSE) { - if (videoFlag & VIDEO_1_INUSE) - SetFIFO_64or32(pVia); - else - SetFIFO_V3_64or32or16(pVia); - } else { - /* Minified video will be skewed without this workaround. */ - if (srcWidth <= 80) { /* Fetch count <= 5 */ - if (videoFlag & VIDEO_1_INUSE) - SetFIFO_V1(pVia, 16, 0, 0); - else - SetFIFO_V3(pVia, 16, 16, 0); - } else { - if (videoFlag & VIDEO_1_INUSE) - SetFIFO_64or16(pVia); - else - SetFIFO_V3_64or32or16(pVia); - } - } - } else { - if (videoFlag & VIDEO_1_INUSE) - SetFIFO_64or48or32(pVia); - else { - /* Fix V3 bug. */ - if (srcWidth <= 8) - SetFIFO_V3(pVia, 1, 0, 0); - else - SetFIFO_V3_64or32or32(pVia); - } - } + if (pVia->swov.SrcFourCC == FOURCC_YV12 || pVia->swov.SrcFourCC + == FOURCC_XVMC) { + if (videoFlag & VIDEO_HQV_INUSE) { + if (videoFlag & VIDEO_1_INUSE) + SetFIFO_64or32(pVia); + else + SetFIFO_V3_64or32or16(pVia); + } else { + /* Minified video will be skewed without this workaround. */ + if (srcWidth <= 80) { /* Fetch count <= 5 */ + if (videoFlag & VIDEO_1_INUSE) + SetFIFO_V1(pVia, 16, 0, 0); + else + SetFIFO_V3(pVia, 16, 16, 0); + } else { + if (videoFlag & VIDEO_1_INUSE) + SetFIFO_64or16(pVia); + else + SetFIFO_V3_64or32or16(pVia); + } + } + } else { + if (videoFlag & VIDEO_1_INUSE) + SetFIFO_64or48or32(pVia); + else { + /* Fix V3 bug. */ + if (srcWidth <= 8) + SetFIFO_V3(pVia, 1, 0, 0); + else + SetFIFO_V3_64or32or32(pVia); + } + } } } static CARD32 -SetColorKey(VIAPtr pVia, unsigned long videoFlag, - CARD32 keyLow, CARD32 keyHigh, CARD32 compose) +SetColorKey(VIAPtr pVia, unsigned long videoFlag, CARD32 keyLow, + CARD32 keyHigh, CARD32 compose) { keyLow &= 0x00FFFFFF; if (pVia->VideoEngine == VIDEO_ENGINE_CME) - keyLow |= 0x40000000; + keyLow |= 0x40000000; /*SaveVideoRegister(pVia, V_COLOR_KEY, keyLow); */ if (videoFlag & VIDEO_1_INUSE) { - SaveVideoRegister(pVia, V_COLOR_KEY, keyLow); + SaveVideoRegister(pVia, V_COLOR_KEY, keyLow); } else { - if (pVia->HWDiff.dwSupportTwoColorKey) /*CLE_C0 */ - SaveVideoRegister(pVia, V3_COLOR_KEY, keyLow); + if (pVia->HWDiff.dwSupportTwoColorKey) /*CLE_C0 */ + SaveVideoRegister(pVia, V3_COLOR_KEY, keyLow); } /*compose = (compose & ~0x0f) | SELECT_VIDEO_IF_COLOR_KEY; */ /*CLE_C0 */ - compose = - (compose & ~0x0f) | SELECT_VIDEO_IF_COLOR_KEY | - SELECT_VIDEO3_IF_COLOR_KEY; + compose = (compose & ~0x0f) | SELECT_VIDEO_IF_COLOR_KEY + | SELECT_VIDEO3_IF_COLOR_KEY; /*compose = (compose & ~0x0f) ; */ return compose; @@ -1470,7 +1465,7 @@ SetColorKey(VIAPtr pVia, unsigned long videoFlag, static CARD32 SetChromaKey(VIAPtr pVia, unsigned long videoFlag, - CARD32 chromaLow, CARD32 chromaHigh, CARD32 miniCtl, CARD32 compose) + CARD32 chromaLow, CARD32 chromaHigh, CARD32 miniCtl, CARD32 compose) { chromaLow &= CHROMA_KEY_LOW; chromaHigh &= CHROMA_KEY_HIGH; @@ -1479,30 +1474,30 @@ SetChromaKey(VIAPtr pVia, unsigned long videoFlag, chromaHigh |= (VIDInD(V_CHROMAKEY_HIGH) & ~CHROMA_KEY_HIGH); if (pVia->VideoEngine == VIDEO_ENGINE_CME) - chromaLow |= 0x40000000; + chromaLow |= 0x40000000; SaveVideoRegister(pVia, V_CHROMAKEY_HIGH, chromaHigh); if (videoFlag & VIDEO_1_INUSE) { - SaveVideoRegister(pVia, V_CHROMAKEY_LOW, chromaLow & ~V_CHROMAKEY_V3); - /* Temporarily solve the HW interpolation error when using Chroma key */ - SaveVideoRegister(pVia, V1_MINI_CONTROL, miniCtl & 0xFFFFFFF8); + SaveVideoRegister(pVia, V_CHROMAKEY_LOW, chromaLow & ~V_CHROMAKEY_V3); + /* Temporarily solve the HW interpolation error when using Chroma key */ + SaveVideoRegister(pVia, V1_MINI_CONTROL, miniCtl & 0xFFFFFFF8); } else { - SaveVideoRegister(pVia, V_CHROMAKEY_LOW, chromaLow | V_CHROMAKEY_V3); - SaveVideoRegister(pVia, V3_MINI_CONTROL, miniCtl & 0xFFFFFFF8); + SaveVideoRegister(pVia, V_CHROMAKEY_LOW, chromaLow | V_CHROMAKEY_V3); + SaveVideoRegister(pVia, V3_MINI_CONTROL, miniCtl & 0xFFFFFFF8); } /* Modified by Scottie[2001.12.5] for select video if (Color key & Chroma key) */ if (compose == SELECT_VIDEO_IF_COLOR_KEY) - compose = SELECT_VIDEO_IF_COLOR_KEY | SELECT_VIDEO_IF_CHROMA_KEY; + compose = SELECT_VIDEO_IF_COLOR_KEY | SELECT_VIDEO_IF_CHROMA_KEY; else - compose = (compose & ~0x0f) | SELECT_VIDEO_IF_CHROMA_KEY; + compose = (compose & ~0x0f) | SELECT_VIDEO_IF_CHROMA_KEY; return compose; } static void SetVideoStart(VIAPtr pVia, unsigned long videoFlag, - unsigned int numbufs, CARD32 a1, CARD32 a2, CARD32 a3) + unsigned int numbufs, CARD32 a1, CARD32 a2, CARD32 a3) { CARD32 V1Addr[3] = { V1_STARTADDR_0, V1_STARTADDR_1, V1_STARTADDR_2 }; CARD32 V3Addr[3] = { V3_STARTADDR_0, V3_STARTADDR_1, V3_STARTADDR_2 }; @@ -1510,9 +1505,9 @@ SetVideoStart(VIAPtr pVia, unsigned long videoFlag, SaveVideoRegister(pVia, VideoAddr[0], a1); if (numbufs > 1) - SaveVideoRegister(pVia, VideoAddr[1], a2); + SaveVideoRegister(pVia, VideoAddr[1], a2); if (numbufs > 2) - SaveVideoRegister(pVia, VideoAddr[2], a3); + SaveVideoRegister(pVia, VideoAddr[2], a3); } static void @@ -1520,15 +1515,16 @@ SetHQVFetch(VIAPtr pVia, CARD32 srcFetch, unsigned long srcHeight) { unsigned long proReg = 0; - if (pVia->ChipId == PCI_CHIP_VT3259 && !(pVia->swov.gdwVideoFlagSW & VIDEO_1_INUSE)) - proReg = PRO_HQV1_OFFSET; + if (pVia->ChipId == PCI_CHIP_VT3259 && !(pVia->swov.gdwVideoFlagSW + & VIDEO_1_INUSE)) + proReg = PRO_HQV1_OFFSET; - if (!pVia->HWDiff.dwHQVFetchByteUnit) { /* CLE_C0 */ - srcFetch >>= 3; /* fetch unit is 8-byte */ + if (!pVia->HWDiff.dwHQVFetchByteUnit) { /* CLE_C0 */ + srcFetch >>= 3; /* fetch unit is 8-byte */ } - SaveVideoRegister(pVia, HQV_SRC_FETCH_LINE + proReg, - ((srcFetch - 1) << 16) | (srcHeight - 1)); + SaveVideoRegister(pVia, HQV_SRC_FETCH_LINE + proReg, ((srcFetch - 1) << 16) + | (srcHeight - 1)); } static void @@ -1536,16 +1532,16 @@ SetFetch(VIAPtr pVia, unsigned long videoFlag, CARD32 fetch) { fetch <<= 20; if (videoFlag & VIDEO_1_INUSE) { - SaveVideoRegister(pVia, V12_QWORD_PER_LINE, fetch); + SaveVideoRegister(pVia, V12_QWORD_PER_LINE, fetch); } else { - fetch |= VIDInD(V3_ALPHA_QWORD_PER_LINE) & ~V3_FETCH_COUNT; - SaveVideoRegister(pVia, V3_ALPHA_QWORD_PER_LINE, fetch); + fetch |= VIDInD(V3_ALPHA_QWORD_PER_LINE) & ~V3_FETCH_COUNT; + SaveVideoRegister(pVia, V3_ALPHA_QWORD_PER_LINE, fetch); } } static void SetDisplayCount(VIAPtr pVia, unsigned long videoFlag, - unsigned long srcWidth, unsigned long srcHeight) + unsigned long srcWidth, unsigned long srcHeight) { unsigned long DisplayCount; @@ -1555,27 +1551,27 @@ SetDisplayCount(VIAPtr pVia, unsigned long videoFlag, */ if (videoFlag & VIDEO_HQV_INUSE) - DisplayCount = srcWidth - 1; + DisplayCount = srcWidth - 1; else - DisplayCount = srcWidth - pVia->swov.overlayRecordV1.dwminifyH; + DisplayCount = srcWidth - pVia->swov.overlayRecordV1.dwminifyH; if (videoFlag & VIDEO_1_INUSE) - SaveVideoRegister(pVia, V1_SOURCE_HEIGHT, - (srcHeight << 16) | DisplayCount); + SaveVideoRegister(pVia, V1_SOURCE_HEIGHT, (srcHeight << 16) + | DisplayCount); else - SaveVideoRegister(pVia, V3_SOURCE_WIDTH, DisplayCount); + SaveVideoRegister(pVia, V3_SOURCE_WIDTH, DisplayCount); } static void SetMiniAndZoom(VIAPtr pVia, unsigned long videoFlag, - CARD32 miniCtl, CARD32 zoomCtl) + CARD32 miniCtl, CARD32 zoomCtl) { if (videoFlag & VIDEO_1_INUSE) { - SaveVideoRegister(pVia, V1_MINI_CONTROL, miniCtl); - SaveVideoRegister(pVia, V1_ZOOM_CONTROL, zoomCtl); + SaveVideoRegister(pVia, V1_MINI_CONTROL, miniCtl); + SaveVideoRegister(pVia, V1_ZOOM_CONTROL, zoomCtl); } else { - SaveVideoRegister(pVia, V3_MINI_CONTROL, miniCtl); - SaveVideoRegister(pVia, V3_ZOOM_CONTROL, zoomCtl); + SaveVideoRegister(pVia, V3_MINI_CONTROL, miniCtl); + SaveVideoRegister(pVia, V3_ZOOM_CONTROL, zoomCtl); } } @@ -1583,25 +1579,26 @@ static void SetVideoControl(VIAPtr pVia, unsigned long videoFlag, CARD32 vidCtl) { if (videoFlag & VIDEO_1_INUSE) - SaveVideoRegister(pVia, V1_CONTROL, vidCtl); + SaveVideoRegister(pVia, V1_CONTROL, vidCtl); else - SaveVideoRegister(pVia, V3_CONTROL, vidCtl); + SaveVideoRegister(pVia, V3_CONTROL, vidCtl); } static void -FireVideoCommand(VIAPtr pVia, unsigned long videoFlag, CARD32 compose) +FireVideoCommand(VIAPtr pVia, unsigned long videoFlag, + CARD32 compose) { if (videoFlag & VIDEO_1_INUSE) - SaveVideoRegister(pVia, V_COMPOSE_MODE, compose | V1_COMMAND_FIRE); + SaveVideoRegister(pVia, V_COMPOSE_MODE, compose | V1_COMMAND_FIRE); else - SaveVideoRegister(pVia, V_COMPOSE_MODE, compose | V3_COMMAND_FIRE); + SaveVideoRegister(pVia, V_COMPOSE_MODE, compose | V3_COMMAND_FIRE); } static void SetVideoWindow(ScrnInfoPtr pScrn, unsigned long videoFlag, - LPDDUPDATEOVERLAY pUpdate) + LPDDUPDATEOVERLAY pUpdate) { - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; CARD32 left = pUpdate->DstLeft; CARD32 top = pUpdate->DstTop; @@ -1609,7 +1606,7 @@ SetVideoWindow(ScrnInfoPtr pScrn, unsigned long videoFlag, CARD32 bottom = pUpdate->DstBottom - 1; DBG_DD(ErrorF("SetVideoWindow: X (%ld,%ld) Y (%ld,%ld)\n", - left, right, top, bottom)); + left, right, top, bottom)); /* Modify for HW DVI limitation. * When we enable both the CRT and DVI, then change resolution. @@ -1618,42 +1615,40 @@ SetVideoWindow(ScrnInfoPtr pScrn, unsigned long videoFlag, * So, we need to adjust the Y top and bottom position. */ if (videoFlag & VIDEO_1_INUSE) { - if (pBIOSInfo->SetDVI && pBIOSInfo->scaleY) { - top = - pUpdate->DstTop * pBIOSInfo->panelY / - pScrn->currentMode->VDisplay; - bottom = - pUpdate->DstBottom * pBIOSInfo->panelY / - pScrn->currentMode->VDisplay; - } + if (pBIOSInfo->SetDVI && pBIOSInfo->scaleY) { + top = pUpdate->DstTop * pBIOSInfo->panelY + / pScrn->currentMode->VDisplay; + bottom = pUpdate->DstBottom * pBIOSInfo->panelY + / pScrn->currentMode->VDisplay; + } } if (top < 0) - top = 0; + top = 0; else if (top > 2047) - top = 2047; + top = 2047; if (bottom < 0) - bottom = 0; + bottom = 0; else if (bottom > 2047) - bottom = 2047; + bottom = 2047; if (left < 0) - left = 0; + left = 0; else if (left > 2047) - left = 2047; + left = 2047; if (right < 0) - right = 0; + right = 0; else if (right > 2047) - right = 2047; + right = 2047; if (videoFlag & VIDEO_1_INUSE) { - SaveVideoRegister(pVia, V1_WIN_END_Y, (right << 16) | bottom); - SaveVideoRegister(pVia, V1_WIN_START_Y, (left << 16) | top); + SaveVideoRegister(pVia, V1_WIN_END_Y, (right << 16) | bottom); + SaveVideoRegister(pVia, V1_WIN_START_Y, (left << 16) | top); } else { - SaveVideoRegister(pVia, V3_WIN_END_Y, (right << 16) | bottom); - SaveVideoRegister(pVia, V3_WIN_START_Y, (left << 16) | top); + SaveVideoRegister(pVia, V3_WIN_END_Y, (right << 16) | bottom); + SaveVideoRegister(pVia, V3_WIN_START_Y, (left << 16) | top); } } @@ -1662,15 +1657,14 @@ SetVideoWindow(ScrnInfoPtr pScrn, unsigned long videoFlag, */ static Bool Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFlag, - unsigned long startAddr, LPDDUPDATEOVERLAY pUpdate, - unsigned long srcPitch, - unsigned long oriSrcWidth, unsigned long oriSrcHeight, - unsigned long deinterlaceMode, - unsigned long haveColorKey, unsigned long haveChromaKey, - unsigned long colorKeyLow, unsigned long colorKeyHigh, - unsigned long chromaKeyLow, unsigned long chromaKeyHigh) + unsigned long startAddr, LPDDUPDATEOVERLAY pUpdate, + unsigned long srcPitch, unsigned long oriSrcWidth, + unsigned long oriSrcHeight, unsigned long deinterlaceMode, + unsigned long haveColorKey, unsigned long haveChromaKey, + unsigned long colorKeyLow, unsigned long colorKeyHigh, + unsigned long chromaKeyLow, unsigned long chromaKeyHigh) { - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); vgaHWPtr hwp = VGAHWPTR(pScrn); VIAHWDiff *hwDiff = &pVia->HWDiff; @@ -1689,184 +1683,177 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFlag, DBG_DD(ErrorF("videoflag=%p\n",videoFlag)); if (pVia->ChipId == PCI_CHIP_VT3259 && !(videoFlag & VIDEO_1_INUSE)) - proReg = PRO_HQV1_OFFSET; + proReg = PRO_HQV1_OFFSET; compose = (VIDInD(V_COMPOSE_MODE) & - ~(SELECT_VIDEO_IF_COLOR_KEY | V1_COMMAND_FIRE | V3_COMMAND_FIRE)) | - V_COMMAND_LOAD_VBI; + ~(SELECT_VIDEO_IF_COLOR_KEY | V1_COMMAND_FIRE | V3_COMMAND_FIRE)) + | V_COMMAND_LOAD_VBI; - DBG_DD(ErrorF("// Upd_Video:\n")); - DBG_DD(ErrorF("Modified rSrc X (%ld,%ld) Y (%ld,%ld)\n", - pUpdate->SrcLeft, pUpdate->SrcRight, - pUpdate->SrcTop, pUpdate->SrcBottom)); + DBG_DD(ErrorF("// Upd_Video:\n"));DBG_DD(ErrorF("Modified rSrc X (%ld,%ld) Y (%ld,%ld)\n", + pUpdate->SrcLeft, pUpdate->SrcRight, + pUpdate->SrcTop, pUpdate->SrcBottom)); DBG_DD(ErrorF("Modified rDest X (%ld,%ld) Y (%ld,%ld)\n", - pUpdate->DstLeft, pUpdate->DstRight, - pUpdate->DstTop, pUpdate->DstBottom)); + pUpdate->DstLeft, pUpdate->DstRight, + pUpdate->DstTop, pUpdate->DstBottom)); - pVia->swov.overlayRecordV1.dwWidth = dstWidth = - pUpdate->DstRight - pUpdate->DstLeft; - pVia->swov.overlayRecordV1.dwHeight = dstHeight = - pUpdate->DstBottom - pUpdate->DstTop; + pVia->swov.overlayRecordV1.dwWidth = dstWidth = pUpdate->DstRight + - pUpdate->DstLeft; + pVia->swov.overlayRecordV1.dwHeight = dstHeight = pUpdate->DstBottom + - pUpdate->DstTop; srcWidth = (unsigned long)pUpdate->SrcRight - pUpdate->SrcLeft; - srcHeight = (unsigned long)pUpdate->SrcBottom - pUpdate->SrcTop; - DBG_DD(ErrorF("===srcWidth= %ld \n", srcWidth)); - DBG_DD(ErrorF("===srcHeight= %ld \n", srcHeight)); + srcHeight = (unsigned long)pUpdate->SrcBottom - pUpdate->SrcTop;DBG_DD(ErrorF("===srcWidth= %ld \n", srcWidth));DBG_DD(ErrorF("===srcHeight= %ld \n", srcHeight)); vidCtl = ViaSetVidCtl(pVia, videoFlag); - if(hwDiff->dwNeedV1Prefetch) { + if (hwDiff->dwNeedV1Prefetch) { DBG_DD(ErrorF("NEEDV1PREFETCH\n")); vidCtl |= V1_PREFETCH_ON_3336; } - + /* * FIXME: * Enable video on secondary */ - if (pVia->Chipset == VIA_P4M900 && - pVia->pBIOSInfo->PanelActive) { - /* V1_ON_SND_DISPLAY */ - vidCtl |= 0x80000000; + if (pVia->Chipset == VIA_P4M900 && pVia->pBIOSInfo->Panel->IsActive) { + /* V1_ON_SND_DISPLAY */ + vidCtl |= 0x80000000; /* SECOND_DISPLAY_COLOR_KEY_ENABLE */ - compose |= 0x00010000 | 0x1 ; + compose |= 0x00010000 | 0x1; } viaOverlayGetV1V3Format(pVia, (videoFlag & VIDEO_1_INUSE) ? 1 : 3, - videoFlag, &vidCtl, &hqvCtl); + videoFlag, &vidCtl, &hqvCtl); - if (hwDiff->dwThreeHQVBuffer) { /* CLE_C0: HQV supports triple-buffering */ - hqvCtl &= ~HQV_SW_FLIP; - hqvCtl |= HQV_TRIPLE_BUFF | HQV_FLIP_STATUS; + if (hwDiff->dwThreeHQVBuffer) { /* CLE_C0: HQV supports triple-buffering */ + hqvCtl &= ~HQV_SW_FLIP; + hqvCtl |= HQV_TRIPLE_BUFF | HQV_FLIP_STATUS; } /* Starting address of source and Source offset */ - dwOffset = - viaOverlayGetSrcStartAddress(pVia, videoFlag, pUpdate, srcPitch, - &hqvOffset); - DBG_DD(ErrorF("===dwOffset= 0x%lx \n", dwOffset)); + dwOffset = viaOverlayGetSrcStartAddress(pVia, videoFlag, pUpdate, srcPitch, + &hqvOffset);DBG_DD(ErrorF("===dwOffset= 0x%lx \n", dwOffset)); pVia->swov.overlayRecordV1.dwOffset = dwOffset; - if (pVia->swov.SrcFourCC == FOURCC_YV12 || - pVia->swov.SrcFourCC == FOURCC_XVMC) { - YCBCRREC YCbCr; - - if (videoFlag & VIDEO_HQV_INUSE) { - SetVideoStart(pVia, videoFlag, hwDiff->dwThreeHQVBuffer ? 3 : 2, - pVia->swov.overlayRecordV1.dwHQVAddr[0] + dwOffset, - pVia->swov.overlayRecordV1.dwHQVAddr[1] + dwOffset, - pVia->swov.overlayRecordV1.dwHQVAddr[2] + dwOffset); - - if (pVia->swov.SrcFourCC != FOURCC_XVMC) { - YCbCr = viaOverlayGetYCbCrStartAddress(videoFlag, startAddr, - pVia->swov.overlayRecordV1.dwOffset, - pVia->swov.overlayRecordV1.dwUVoffset, - srcPitch, oriSrcHeight); - if (pVia->VideoEngine == VIDEO_ENGINE_CME) { - SaveVideoRegister(pVia, HQV_SRC_STARTADDR_Y + proReg, - YCbCr.dwY); - SaveVideoRegister(pVia, HQV_SRC_STARTADDR_U + proReg, - YCbCr.dwCB); - } else { - SaveVideoRegister(pVia, HQV_SRC_STARTADDR_Y, YCbCr.dwY); - SaveVideoRegister(pVia, HQV_SRC_STARTADDR_U, YCbCr.dwCR); - SaveVideoRegister(pVia, HQV_SRC_STARTADDR_V, YCbCr.dwCB); - } - } - } else { - YCbCr = viaOverlayGetYCbCrStartAddress(videoFlag, startAddr, - pVia->swov.overlayRecordV1.dwOffset, - pVia->swov.overlayRecordV1.dwUVoffset, - srcPitch, oriSrcHeight); - - if (videoFlag & VIDEO_1_INUSE) { - SaveVideoRegister(pVia, V1_STARTADDR_0, YCbCr.dwY); - SaveVideoRegister(pVia, V1_STARTADDR_CB0, YCbCr.dwCR); - SaveVideoRegister(pVia, V1_STARTADDR_CR0, YCbCr.dwCB); - } else - DBG_DD(ErrorF - ("Upd_Video() : We do not support YV12 with V3!\n")); - } + if (pVia->swov.SrcFourCC == FOURCC_YV12 || pVia->swov.SrcFourCC + == FOURCC_XVMC) { + YCBCRREC YCbCr; + + if (videoFlag & VIDEO_HQV_INUSE) { + SetVideoStart(pVia, videoFlag, hwDiff->dwThreeHQVBuffer ? 3 : 2, + pVia->swov.overlayRecordV1.dwHQVAddr[0] + dwOffset, + pVia->swov.overlayRecordV1.dwHQVAddr[1] + dwOffset, + pVia->swov.overlayRecordV1.dwHQVAddr[2] + dwOffset); + + if (pVia->swov.SrcFourCC != FOURCC_XVMC) { + YCbCr = viaOverlayGetYCbCrStartAddress(videoFlag, startAddr, + pVia->swov.overlayRecordV1.dwOffset, + pVia->swov.overlayRecordV1.dwUVoffset, srcPitch, + oriSrcHeight); + if (pVia->VideoEngine == VIDEO_ENGINE_CME) { + SaveVideoRegister(pVia, HQV_SRC_STARTADDR_Y + proReg, + YCbCr.dwY); + SaveVideoRegister(pVia, HQV_SRC_STARTADDR_U + proReg, + YCbCr.dwCB); + } else { + SaveVideoRegister(pVia, HQV_SRC_STARTADDR_Y, YCbCr.dwY); + SaveVideoRegister(pVia, HQV_SRC_STARTADDR_U, YCbCr.dwCR); + SaveVideoRegister(pVia, HQV_SRC_STARTADDR_V, YCbCr.dwCB); + } + } + } else { + YCbCr = viaOverlayGetYCbCrStartAddress(videoFlag, startAddr, + pVia->swov.overlayRecordV1.dwOffset, + pVia->swov.overlayRecordV1.dwUVoffset, srcPitch, + oriSrcHeight); + + if (videoFlag & VIDEO_1_INUSE) { + SaveVideoRegister(pVia, V1_STARTADDR_0, YCbCr.dwY); + SaveVideoRegister(pVia, V1_STARTADDR_CB0, YCbCr.dwCR); + SaveVideoRegister(pVia, V1_STARTADDR_CR0, YCbCr.dwCB); + } else + DBG_DD(ErrorF + ("Upd_Video() : We do not support YV12 with V3!\n")); + } } else { - if (videoFlag & VIDEO_HQV_INUSE) { - hqvSrcWidth = (unsigned long)pUpdate->SrcRight - pUpdate->SrcLeft; - hqvDstWidth = (unsigned long)pUpdate->DstRight - pUpdate->DstLeft; - - if (hqvSrcWidth > hqvDstWidth) - dwOffset = dwOffset * hqvDstWidth / hqvSrcWidth; - - SetVideoStart(pVia, videoFlag, hwDiff->dwThreeHQVBuffer ? 3 : 2, - pVia->swov.overlayRecordV1.dwHQVAddr[0] + hqvOffset, - pVia->swov.overlayRecordV1.dwHQVAddr[1] + hqvOffset, - pVia->swov.overlayRecordV1.dwHQVAddr[2] + hqvOffset); - - if (pVia->VideoEngine == VIDEO_ENGINE_CME) - SaveVideoRegister(pVia, 0x1cc + proReg, dwOffset); - SaveVideoRegister(pVia, HQV_SRC_STARTADDR_Y + proReg, startAddr); - } else { - startAddr += dwOffset; - SetVideoStart(pVia, videoFlag, 1, startAddr, 0, 0); - } + if (videoFlag & VIDEO_HQV_INUSE) { + hqvSrcWidth = (unsigned long)pUpdate->SrcRight - pUpdate->SrcLeft; + hqvDstWidth = (unsigned long)pUpdate->DstRight - pUpdate->DstLeft; + + if (hqvSrcWidth > hqvDstWidth) + dwOffset = dwOffset * hqvDstWidth / hqvSrcWidth; + + SetVideoStart(pVia, videoFlag, hwDiff->dwThreeHQVBuffer ? 3 : 2, + pVia->swov.overlayRecordV1.dwHQVAddr[0] + hqvOffset, + pVia->swov.overlayRecordV1.dwHQVAddr[1] + hqvOffset, + pVia->swov.overlayRecordV1.dwHQVAddr[2] + hqvOffset); + + if (pVia->VideoEngine == VIDEO_ENGINE_CME) + SaveVideoRegister(pVia, 0x1cc + proReg, dwOffset); + SaveVideoRegister(pVia, HQV_SRC_STARTADDR_Y + proReg, startAddr); + } else { + startAddr += dwOffset; + SetVideoStart(pVia, videoFlag, 1, startAddr, 0, 0); + } } - fetch = viaOverlayGetFetch(pVia, videoFlag, - srcWidth, dstWidth, oriSrcWidth, &hqvSrcFetch); - DBG_DD(ErrorF("===fetch= 0x%lx\n", fetch)); + fetch = viaOverlayGetFetch(pVia, videoFlag, srcWidth, dstWidth, + oriSrcWidth, &hqvSrcFetch);DBG_DD(ErrorF("===fetch= 0x%lx\n", fetch)); #if 0 /* For DCT450 test-BOB INTERLEAVE */ if ((deinterlaceMode & DDOVER_INTERLEAVED) - && (deinterlaceMode & DDOVER_BOB)) { - if (videoFlag & VIDEO_HQV_INUSE) - hqvCtl |= HQV_FIELD_2_FRAME | HQV_FRAME_2_FIELD | HQV_DEINTERLACE; - else - vidCtl |= V1_BOB_ENABLE | V1_FRAME_BASE; + && (deinterlaceMode & DDOVER_BOB)) { + if (videoFlag & VIDEO_HQV_INUSE) + hqvCtl |= HQV_FIELD_2_FRAME | HQV_FRAME_2_FIELD | HQV_DEINTERLACE; + else + vidCtl |= V1_BOB_ENABLE | V1_FRAME_BASE; } else if (deinterlaceMode & DDOVER_BOB) { - if (videoFlag & VIDEO_HQV_INUSE) - /* The HQV source data line count should be two times of the original line count */ - hqvCtl |= HQV_FIELD_2_FRAME | HQV_DEINTERLACE; - else - vidCtl |= V1_BOB_ENABLE; + if (videoFlag & VIDEO_HQV_INUSE) + /* The HQV source data line count should be two times of the original line count */ + hqvCtl |= HQV_FIELD_2_FRAME | HQV_DEINTERLACE; + else + vidCtl |= V1_BOB_ENABLE; } #endif if (videoFlag & VIDEO_HQV_INUSE) { - if (!(deinterlaceMode & DDOVER_INTERLEAVED) - && (deinterlaceMode & DDOVER_BOB)) - SetHQVFetch(pVia, hqvSrcFetch, oriSrcHeight << 1); - else - SetHQVFetch(pVia, hqvSrcFetch, oriSrcHeight); - - if (pVia->swov.SrcFourCC == FOURCC_YV12 || - pVia->swov.SrcFourCC == FOURCC_XVMC) { - if (videoFlag & VIDEO_1_INUSE) - SaveVideoRegister(pVia, V1_STRIDE, srcPitch << 1); - else - SaveVideoRegister(pVia, V3_STRIDE, srcPitch << 1); - - if (pVia->HWDiff.dwHQVFetchByteUnit) - SaveVideoRegister(pVia, HQV_SRC_STRIDE + proReg, - ((srcPitch >> 1) << 16) | srcPitch | HQV_FIFO_DEPTH_1); - else - SaveVideoRegister(pVia, HQV_SRC_STRIDE + proReg, - ((srcPitch >> 1) << 16) | srcPitch); - - SaveVideoRegister(pVia, HQV_DST_STRIDE + proReg, (srcPitch << 1)); - } else { - if (videoFlag & VIDEO_1_INUSE) - SaveVideoRegister(pVia, V1_STRIDE, srcPitch); - else - SaveVideoRegister(pVia, V3_STRIDE, srcPitch); - - SaveVideoRegister(pVia, HQV_SRC_STRIDE + proReg, srcPitch); - SaveVideoRegister(pVia, HQV_DST_STRIDE + proReg, srcPitch); - } + if (!(deinterlaceMode & DDOVER_INTERLEAVED) && (deinterlaceMode + & DDOVER_BOB)) + SetHQVFetch(pVia, hqvSrcFetch, oriSrcHeight << 1); + else + SetHQVFetch(pVia, hqvSrcFetch, oriSrcHeight); + + if (pVia->swov.SrcFourCC == FOURCC_YV12 || pVia->swov.SrcFourCC + == FOURCC_XVMC) { + if (videoFlag & VIDEO_1_INUSE) + SaveVideoRegister(pVia, V1_STRIDE, srcPitch << 1); + else + SaveVideoRegister(pVia, V3_STRIDE, srcPitch << 1); + + if (pVia->HWDiff.dwHQVFetchByteUnit) + SaveVideoRegister(pVia, HQV_SRC_STRIDE + proReg, ((srcPitch + >> 1) << 16) | srcPitch | HQV_FIFO_DEPTH_1); + else + SaveVideoRegister(pVia, HQV_SRC_STRIDE + proReg, ((srcPitch + >> 1) << 16) | srcPitch); + + SaveVideoRegister(pVia, HQV_DST_STRIDE + proReg, (srcPitch << 1)); + } else { + if (videoFlag & VIDEO_1_INUSE) + SaveVideoRegister(pVia, V1_STRIDE, srcPitch); + else + SaveVideoRegister(pVia, V3_STRIDE, srcPitch); + + SaveVideoRegister(pVia, HQV_SRC_STRIDE + proReg, srcPitch); + SaveVideoRegister(pVia, HQV_DST_STRIDE + proReg, srcPitch); + } } else { - if (videoFlag & VIDEO_1_INUSE) - SaveVideoRegister(pVia, V1_STRIDE, srcPitch | (srcPitch << 15)); - else - SaveVideoRegister(pVia, V3_STRIDE, srcPitch | (srcPitch << 15)); + if (videoFlag & VIDEO_1_INUSE) + SaveVideoRegister(pVia, V1_STRIDE, srcPitch | (srcPitch << 15)); + else + SaveVideoRegister(pVia, V3_STRIDE, srcPitch | (srcPitch << 15)); } /* Set destination window */ @@ -1879,12 +1866,12 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFlag, pVia->swov.overlayRecordV1.dwFetchAlignment = 0; if (!viaOverlayHQVCalcZoomWidth(pVia, videoFlag, srcWidth, dstWidth, - &zoomCtl, &miniCtl, &hqvFilterCtl, &hqvMiniCtl, &haveHQVzoomH)) { - /* Need to scale (minify) too much - can't handle it. */ - SetFetch(pVia, videoFlag, fetch); - FireVideoCommand(pVia, videoFlag, compose); - FlushVidRegBuffer(pVia); - return FALSE; + &zoomCtl, &miniCtl, &hqvFilterCtl, &hqvMiniCtl, &haveHQVzoomH)) { + /* Need to scale (minify) too much - can't handle it. */ + SetFetch(pVia, videoFlag, fetch); + FireVideoCommand(pVia, videoFlag, compose); + FlushVidRegBuffer(pVia); + return FALSE; } SetFetch(pVia, videoFlag, fetch); @@ -1893,175 +1880,168 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFlag, /* For DCT450 test-BOB INTERLEAVE */ if ((deinterlaceMode & DDOVER_INTERLEAVED) - && (deinterlaceMode & DDOVER_BOB)) { - if (!(videoFlag & VIDEO_HQV_INUSE)) { - srcHeight /= 2; - if (videoFlag & VIDEO_1_INUSE) - vidCtl |= V1_BOB_ENABLE | V1_FRAME_BASE; - else - vidCtl |= V3_BOB_ENABLE | V3_FRAME_BASE; - } else - hqvCtl |= HQV_FIELD_2_FRAME | HQV_FRAME_2_FIELD | HQV_DEINTERLACE; + && (deinterlaceMode & DDOVER_BOB)) { + if (!(videoFlag & VIDEO_HQV_INUSE)) { + srcHeight /= 2; + if (videoFlag & VIDEO_1_INUSE) + vidCtl |= V1_BOB_ENABLE | V1_FRAME_BASE; + else + vidCtl |= V3_BOB_ENABLE | V3_FRAME_BASE; + } else + hqvCtl |= HQV_FIELD_2_FRAME | HQV_FRAME_2_FIELD | HQV_DEINTERLACE; } else if (deinterlaceMode & DDOVER_BOB) { - if (videoFlag & VIDEO_HQV_INUSE) { - srcHeight <<= 1; - hqvCtl |= HQV_FIELD_2_FRAME | HQV_DEINTERLACE; - } else { - if (videoFlag & VIDEO_1_INUSE) - vidCtl |= V1_BOB_ENABLE; - else - vidCtl |= V3_BOB_ENABLE; - } + if (videoFlag & VIDEO_HQV_INUSE) { + srcHeight <<= 1; + hqvCtl |= HQV_FIELD_2_FRAME | HQV_DEINTERLACE; + } else { + if (videoFlag & VIDEO_1_INUSE) + vidCtl |= V1_BOB_ENABLE; + else + vidCtl |= V3_BOB_ENABLE; + } } SetDisplayCount(pVia, videoFlag, srcWidth, srcHeight); if (!viaOverlayHQVCalcZoomHeight(pVia, srcHeight, dstHeight, &zoomCtl, - &miniCtl, &hqvFilterCtl, &hqvMiniCtl, &haveHQVzoomV)) { - /* Need to scale (minify) too much - can't handle it. */ - FireVideoCommand(pVia, videoFlag, compose); - FlushVidRegBuffer(pVia); - return FALSE; + &miniCtl, &hqvFilterCtl, &hqvMiniCtl, &haveHQVzoomV)) { + /* Need to scale (minify) too much - can't handle it. */ + FireVideoCommand(pVia, videoFlag, compose); + FlushVidRegBuffer(pVia); + return FALSE; } SetupFIFOs(pVia, videoFlag, miniCtl, srcWidth); if (videoFlag & VIDEO_HQV_INUSE) { - miniCtl = 0; + miniCtl = 0; - if (haveHQVzoomH || haveHQVzoomV) { - tmp = 0; + if (haveHQVzoomH || haveHQVzoomV) { + tmp = 0; - if (haveHQVzoomH) { - miniCtl = V1_X_INTERPOLY; - /* Disable X interpolation if the height exceeds - * the maximum supported by the hardware */ + if (haveHQVzoomH) { + miniCtl = V1_X_INTERPOLY; + /* Disable X interpolation if the height exceeds + * the maximum supported by the hardware */ if (srcHeight >= pVia->swov.maxHInterp) miniCtl &= ~V1_X_INTERPOLY; - tmp = zoomCtl & 0xffff0000; - } + tmp = zoomCtl & 0xffff0000; + } - if (haveHQVzoomV) { - miniCtl |= V1_Y_INTERPOLY | V1_YCBCR_INTERPOLY; - /* Disable Y interpolation if the width exceeds - * the maximum supported by the hardware */ + if (haveHQVzoomV) { + miniCtl |= V1_Y_INTERPOLY | V1_YCBCR_INTERPOLY; + /* Disable Y interpolation if the width exceeds + * the maximum supported by the hardware */ if (srcWidth >= pVia->swov.maxWInterp) miniCtl &= ~V1_Y_INTERPOLY; - tmp |= zoomCtl & 0x0000ffff; - hqvFilterCtl &= 0xfffdffff; - } - - /* Temporary fix for 2D bandwidth problem. 2002/08/01 */ - if (pVia->swov.gdwUseExtendedFIFO) - miniCtl &= ~V1_Y_INTERPOLY; - - SetMiniAndZoom(pVia, videoFlag, miniCtl, tmp); - } else { - if (srcHeight == dstHeight) - hqvFilterCtl &= 0xfffdffff; - - SetMiniAndZoom(pVia, videoFlag, 0, 0); - } - SaveVideoRegister(pVia, HQV_MINIFY_CONTROL + proReg, hqvMiniCtl); - SaveVideoRegister(pVia, HQV_FILTER_CONTROL + proReg, hqvFilterCtl); + tmp |= zoomCtl & 0x0000ffff; + hqvFilterCtl &= 0xfffdffff; + } + + /* Temporary fix for 2D bandwidth problem. 2002/08/01 */ + if (pVia->swov.gdwUseExtendedFIFO) + miniCtl &= ~V1_Y_INTERPOLY; + + SetMiniAndZoom(pVia, videoFlag, miniCtl, tmp); + } else { + if (srcHeight == dstHeight) + hqvFilterCtl &= 0xfffdffff; + + SetMiniAndZoom(pVia, videoFlag, 0, 0); + } + SaveVideoRegister(pVia, HQV_MINIFY_CONTROL + proReg, hqvMiniCtl); + SaveVideoRegister(pVia, HQV_FILTER_CONTROL + proReg, hqvFilterCtl); } else - SetMiniAndZoom(pVia, videoFlag, miniCtl, zoomCtl); + SetMiniAndZoom(pVia, videoFlag, miniCtl, zoomCtl); if (haveColorKey) - compose = - SetColorKey(pVia, videoFlag, colorKeyLow, colorKeyHigh, compose); + compose = SetColorKey(pVia, videoFlag, colorKeyLow, colorKeyHigh, + compose); if (haveChromaKey) - compose = SetChromaKey(pVia, videoFlag, chromaKeyLow, chromaKeyHigh, - miniCtl, compose); + compose = SetChromaKey(pVia, videoFlag, chromaKeyLow, chromaKeyHigh, + miniCtl, compose); /* Set up video control */ if (videoFlag & VIDEO_HQV_INUSE) { - if (!pVia->swov.SWVideo_ON) { - DBG_DD(ErrorF(" First HQV\n")); - - FlushVidRegBuffer(pVia); - - DBG_DD(ErrorF(" Wait flips")); - - if (hwDiff->dwHQVInitPatch) { - DBG_DD(ErrorF(" Initializing HQV twice ...")); - for (i = 0; i < 2; i++) { - viaWaitHQVFlipClear(pVia, - ((hqvCtl & ~HQV_SW_FLIP) | HQV_FLIP_STATUS) & - ~HQV_ENABLE); - VIDOutD(HQV_CONTROL + proReg, hqvCtl); - viaWaitHQVFlip(pVia); - } - DBG_DD(ErrorF(" done.\n")); - } else { /* CLE_C0 */ - CARD32 volatile *HQVCtrl = - (CARD32 volatile *)(pVia->VidMapBase + HQV_CONTROL + - proReg); - - /* Check that HQV is idle */ - DBG_DD(ErrorF("HQV control wf - %08lx\n", *HQVCtrl)); - while (!(*HQVCtrl & HQV_IDLE)) { - DBG_DD(ErrorF("HQV control busy - %08lx\n", *HQVCtrl)); - usleep(1); - } - - if (pVia->VideoEngine == VIDEO_ENGINE_CME) - hqvCtl |= HQV_GEN_IRQ; - - VIDOutD(HQV_CONTROL + proReg, hqvCtl & ~HQV_SW_FLIP); - VIDOutD(HQV_CONTROL + proReg, hqvCtl | HQV_SW_FLIP); - - DBG_DD(ErrorF("HQV control wf5 - %08lx\n", *HQVCtrl)); - DBG_DD(ErrorF(" Wait flips5")); - - if (pVia->VideoEngine != VIDEO_ENGINE_CME) { - for (i = 0; (i < 50) && !(*HQVCtrl & HQV_FLIP_STATUS); - i++) { - DBG_DD(ErrorF(" HQV wait %d %08lx\n", i, *HQVCtrl)); - *HQVCtrl |= HQV_SW_FLIP | HQV_FLIP_STATUS; - usleep(1); - } - } else { - viaWaitHQVFlip(pVia); - } - - DBG_DD(ErrorF(" Wait flips6")); - } - - if (videoFlag & VIDEO_1_INUSE) { - VIDOutD(V1_CONTROL, vidCtl); - VIDOutD(V_COMPOSE_MODE, compose | V1_COMMAND_FIRE); - if (pVia->swov.gdwUseExtendedFIFO) { - /* Set Display FIFO */ - DBG_DD(ErrorF(" Wait flips7")); - viaWaitVBI(pVia); - DBG_DD(ErrorF(" Wait flips 8")); - hwp->writeSeq(hwp, 0x17, 0x2F); - ViaSeqMask(hwp, 0x16, 0x14, 0x1F); - hwp->writeSeq(hwp, 0x18, 0x56); - DBG_DD(ErrorF(" Wait flips 9")); - } - } else { - DBG_DD(ErrorF(" Wait flips 10")); - VIDOutD(V3_CONTROL, vidCtl); - VIDOutD(V_COMPOSE_MODE, compose | V3_COMMAND_FIRE); - } - DBG_DD(ErrorF(" Done flips")); - } else { - DBG_DD(ErrorF(" Normal called\n")); - SaveVideoRegister(pVia, HQV_CONTROL + proReg, - hqvCtl | HQV_FLIP_STATUS); - SetVideoControl(pVia, videoFlag, vidCtl); - FireVideoCommand(pVia, videoFlag, compose); - viaWaitHQVDone(pVia); - FlushVidRegBuffer(pVia); - } + if (!pVia->swov.SWVideo_ON) { + DBG_DD(ErrorF(" First HQV\n")); + + FlushVidRegBuffer(pVia); + + DBG_DD(ErrorF(" Wait flips")); + + if (hwDiff->dwHQVInitPatch) { + DBG_DD(ErrorF(" Initializing HQV twice ...")); + for (i = 0; i < 2; i++) { + viaWaitHQVFlipClear(pVia, ((hqvCtl & ~HQV_SW_FLIP) + | HQV_FLIP_STATUS) & ~HQV_ENABLE); + VIDOutD(HQV_CONTROL + proReg, hqvCtl); + viaWaitHQVFlip(pVia); + }DBG_DD(ErrorF(" done.\n")); + } else { /* CLE_C0 */ + CARD32 volatile *HQVCtrl = (CARD32 volatile *)(pVia->VidMapBase + + HQV_CONTROL + proReg); + + /* Check that HQV is idle */ + DBG_DD(ErrorF("HQV control wf - %08lx\n", *HQVCtrl)); + while (!(*HQVCtrl & HQV_IDLE)) { + DBG_DD(ErrorF("HQV control busy - %08lx\n", *HQVCtrl)); + usleep(1); + } + + if (pVia->VideoEngine == VIDEO_ENGINE_CME) + hqvCtl |= HQV_GEN_IRQ; + + VIDOutD(HQV_CONTROL + proReg, hqvCtl & ~HQV_SW_FLIP); + VIDOutD(HQV_CONTROL + proReg, hqvCtl | HQV_SW_FLIP); + + DBG_DD(ErrorF("HQV control wf5 - %08lx\n", *HQVCtrl));DBG_DD(ErrorF(" Wait flips5")); + + if (pVia->VideoEngine != VIDEO_ENGINE_CME) { + for (i = 0; (i < 50) && !(*HQVCtrl & HQV_FLIP_STATUS); i++) { + DBG_DD(ErrorF(" HQV wait %d %08lx\n", i, *HQVCtrl)); + *HQVCtrl |= HQV_SW_FLIP | HQV_FLIP_STATUS; + usleep(1); + } + } else { + viaWaitHQVFlip(pVia); + } + + DBG_DD(ErrorF(" Wait flips6")); + } + + if (videoFlag & VIDEO_1_INUSE) { + + VIDOutD(V1_CONTROL, vidCtl); + VIDOutD(V_COMPOSE_MODE, compose | V1_COMMAND_FIRE); + if (pVia->swov.gdwUseExtendedFIFO) { + /* Set Display FIFO */ + DBG_DD(ErrorF(" Wait flips7")); + viaWaitVBI(pVia);DBG_DD(ErrorF(" Wait flips 8")); + hwp->writeSeq(hwp, 0x17, 0x2F); + ViaSeqMask(hwp, 0x16, 0x14, 0x1F); + hwp->writeSeq(hwp, 0x18, 0x56);DBG_DD(ErrorF(" Wait flips 9")); + } + } else { + DBG_DD(ErrorF(" Wait flips 10")); + VIDOutD(V3_CONTROL, vidCtl); + VIDOutD(V_COMPOSE_MODE, compose | V3_COMMAND_FIRE); + }DBG_DD(ErrorF(" Done flips")); + } else { + DBG_DD(ErrorF(" Normal called\n")); + SaveVideoRegister(pVia, HQV_CONTROL + proReg, hqvCtl + | HQV_FLIP_STATUS); + SetVideoControl(pVia, videoFlag, vidCtl); + FireVideoCommand(pVia, videoFlag, compose); + viaWaitHQVDone(pVia); + FlushVidRegBuffer(pVia); + } } else { - SetVideoControl(pVia, videoFlag, vidCtl); - FireVideoCommand(pVia, videoFlag, compose); - viaWaitHQVDone(pVia); - FlushVidRegBuffer(pVia); + SetVideoControl(pVia, videoFlag, vidCtl); + FireVideoCommand(pVia, videoFlag, compose); + viaWaitHQVDone(pVia); + FlushVidRegBuffer(pVia); } pVia->swov.SWVideo_ON = TRUE; @@ -2069,7 +2049,7 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFlag, return TRUE; -} /* Upd_Video */ +} /* Upd_Video */ /* * VIAVidUpdateOverlay() @@ -2080,7 +2060,7 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFlag, Bool VIAVidUpdateOverlay(ScrnInfoPtr pScrn, LPDDUPDATEOVERLAY pUpdate) { - VIAPtr pVia = VIAPTR(pScrn); + VIAPtr pVia= VIAPTR(pScrn); OVERLAYRECORD *ovlV1 = &pVia->swov.overlayRecordV1; unsigned long flags = pUpdate->dwFlags; @@ -2094,7 +2074,7 @@ VIAVidUpdateOverlay(ScrnInfoPtr pScrn, LPDDUPDATEOVERLAY pUpdate) unsigned long scrnWidth, scrnHeight; int dstTop, dstBottom, dstLeft, dstRight; - int panDX, panDY; /* Panning delta */ + int panDX, panDY; /* Panning delta */ unsigned long proReg = 0; @@ -2109,29 +2089,29 @@ VIAVidUpdateOverlay(ScrnInfoPtr pScrn, LPDDUPDATEOVERLAY pUpdate) pUpdate->DstBottom -= panDY; DBG_DD(ErrorF("Raw rSrc X (%ld,%ld) Y (%ld,%ld)\n", - pUpdate->SrcLeft, pUpdate->SrcRight, - pUpdate->SrcTop, pUpdate->SrcBottom)); + pUpdate->SrcLeft, pUpdate->SrcRight, + pUpdate->SrcTop, pUpdate->SrcBottom)); DBG_DD(ErrorF("Raw rDest X (%ld,%ld) Y (%ld,%ld)\n", - pUpdate->DstLeft, pUpdate->DstRight, - pUpdate->DstTop, pUpdate->DstBottom)); - - if ((pVia->swov.SrcFourCC == FOURCC_YUY2) || - (pVia->swov.SrcFourCC == FOURCC_RV15) || - (pVia->swov.SrcFourCC == FOURCC_RV16) || - (pVia->swov.SrcFourCC == FOURCC_RV32) || - (pVia->swov.SrcFourCC == FOURCC_YV12) || - (pVia->swov.SrcFourCC == FOURCC_XVMC)) { - videoFlag = pVia->swov.gdwVideoFlagSW; + pUpdate->DstLeft, pUpdate->DstRight, + pUpdate->DstTop, pUpdate->DstBottom)); + + if ((pVia->swov.SrcFourCC == FOURCC_YUY2) + || (pVia->swov.SrcFourCC == FOURCC_RV15) + || (pVia->swov.SrcFourCC == FOURCC_RV16) + || (pVia->swov.SrcFourCC == FOURCC_RV32) + || (pVia->swov.SrcFourCC == FOURCC_YV12) + || (pVia->swov.SrcFourCC == FOURCC_XVMC)) { + videoFlag = pVia->swov.gdwVideoFlagSW; } if (pVia->ChipId == PCI_CHIP_VT3259 && !(videoFlag & VIDEO_1_INUSE)) - proReg = PRO_HQV1_OFFSET; + proReg = PRO_HQV1_OFFSET; flags |= DDOVER_INTERLEAVED; /* Disable destination color keying if the alpha window is in use. */ if (pVia->swov.gdwAlphaEnabled) - flags &= ~DDOVER_KEYDEST; + flags &= ~DDOVER_KEYDEST; ResetVidRegBuffer(pVia); @@ -2139,22 +2119,22 @@ VIAVidUpdateOverlay(ScrnInfoPtr pScrn, LPDDUPDATEOVERLAY pUpdate) startAddr = VIDInD(HQV_SRC_STARTADDR_Y + proReg); if (flags & DDOVER_KEYDEST) { - haveColorKey = 1; - colorKeyLow = pUpdate->dwColorSpaceLowValue; + haveColorKey = 1; + colorKeyLow = pUpdate->dwColorSpaceLowValue; } if (flags & DDOVER_INTERLEAVED) - deinterlaceMode |= DDOVER_INTERLEAVED; + deinterlaceMode |= DDOVER_INTERLEAVED; if (flags & DDOVER_BOB) - deinterlaceMode |= DDOVER_BOB; + deinterlaceMode |= DDOVER_BOB; - if ((pVia->ChipId == PCI_CHIP_CLE3122) - && (pScrn->currentMode->HDisplay > 1024)) { - DBG_DD(ErrorF("UseExtendedFIFO\n")); - pVia->swov.gdwUseExtendedFIFO = 1; + if ((pVia->ChipId == PCI_CHIP_CLE3122) + && (pScrn->currentMode->HDisplay > 1024)) { + DBG_DD(ErrorF("UseExtendedFIFO\n")); + pVia->swov.gdwUseExtendedFIFO = 1; } else - pVia->swov.gdwUseExtendedFIFO = 0; + pVia->swov.gdwUseExtendedFIFO = 0; /* Figure out actual rSrc rectangle */ @@ -2167,41 +2147,41 @@ VIAVidUpdateOverlay(ScrnInfoPtr pScrn, LPDDUPDATEOVERLAY pUpdate) scrnHeight = pScrn->currentMode->VDisplay; if (dstLeft < 0) { - pUpdate->SrcLeft = (((-dstLeft) * ovlV1->dwV1OriWidth) + - ((dstRight - dstLeft) >> 1)) / (dstRight - dstLeft); + pUpdate->SrcLeft = (((-dstLeft) * ovlV1->dwV1OriWidth) + + ((dstRight - dstLeft) >> 1)) / (dstRight - dstLeft); } if (dstRight > scrnWidth) { - pUpdate->SrcRight = (((scrnWidth - dstLeft) * ovlV1->dwV1OriWidth) + - ((dstRight - dstLeft) >> 1)) / (dstRight - dstLeft); + pUpdate->SrcRight = (((scrnWidth - dstLeft) * ovlV1->dwV1OriWidth) + + ((dstRight - dstLeft) >> 1)) / (dstRight - dstLeft); } if (dstTop < 0) { - pUpdate->SrcTop = (((-dstTop) * ovlV1->dwV1OriHeight) + - ((dstBottom - dstTop) >> 1)) / (dstBottom - dstTop); + pUpdate->SrcTop = (((-dstTop) * ovlV1->dwV1OriHeight) + + ((dstBottom - dstTop) >> 1)) / (dstBottom - dstTop); } if (dstBottom > scrnHeight) { - pUpdate->SrcBottom = (((scrnHeight - dstTop) * ovlV1->dwV1OriHeight) + - ((dstBottom - dstTop) >> 1)) / (dstBottom - dstTop); + pUpdate->SrcBottom = (((scrnHeight - dstTop) * ovlV1->dwV1OriHeight) + + ((dstBottom - dstTop) >> 1)) / (dstBottom - dstTop); } /* Save modified src & original dest rectangle parameters */ - if ((pVia->swov.SrcFourCC == FOURCC_YUY2) || - (pVia->swov.SrcFourCC == FOURCC_RV15) || - (pVia->swov.SrcFourCC == FOURCC_RV16) || - (pVia->swov.SrcFourCC == FOURCC_RV32) || - (pVia->swov.SrcFourCC == FOURCC_YV12) || - (pVia->swov.SrcFourCC == FOURCC_XVMC)) { - pVia->swov.SWDevice.gdwSWDstLeft = pUpdate->DstLeft + panDX; - pVia->swov.SWDevice.gdwSWDstTop = pUpdate->DstTop + panDY; - pVia->swov.SWDevice.gdwSWDstWidth = - pUpdate->DstRight - pUpdate->DstLeft; - pVia->swov.SWDevice.gdwSWDstHeight = - pUpdate->DstBottom - pUpdate->DstTop; - - pVia->swov.SWDevice.gdwSWSrcWidth = - ovlV1->dwV1SrcWidth = pUpdate->SrcRight - pUpdate->SrcLeft; - pVia->swov.SWDevice.gdwSWSrcHeight = - ovlV1->dwV1SrcHeight = pUpdate->SrcBottom - pUpdate->SrcTop; + if ((pVia->swov.SrcFourCC == FOURCC_YUY2) + || (pVia->swov.SrcFourCC == FOURCC_RV15) + || (pVia->swov.SrcFourCC == FOURCC_RV16) + || (pVia->swov.SrcFourCC == FOURCC_RV32) + || (pVia->swov.SrcFourCC == FOURCC_YV12) + || (pVia->swov.SrcFourCC == FOURCC_XVMC)) { + pVia->swov.SWDevice.gdwSWDstLeft = pUpdate->DstLeft + panDX; + pVia->swov.SWDevice.gdwSWDstTop = pUpdate->DstTop + panDY; + pVia->swov.SWDevice.gdwSWDstWidth = pUpdate->DstRight + - pUpdate->DstLeft; + pVia->swov.SWDevice.gdwSWDstHeight = pUpdate->DstBottom + - pUpdate->DstTop; + + pVia->swov.SWDevice.gdwSWSrcWidth = ovlV1->dwV1SrcWidth + = pUpdate->SrcRight - pUpdate->SrcLeft; + pVia->swov.SWDevice.gdwSWSrcHeight = ovlV1->dwV1SrcHeight + = pUpdate->SrcBottom - pUpdate->SrcTop; } ovlV1->dwV1SrcLeft = pUpdate->SrcLeft; @@ -2214,24 +2194,23 @@ VIAVidUpdateOverlay(ScrnInfoPtr pScrn, LPDDUPDATEOVERLAY pUpdate) pUpdate->DstLeft = (dstLeft < 0) ? 0 : dstLeft; pUpdate->DstTop = (dstTop < 0) ? 0 : dstTop; if (pUpdate->DstTop >= scrnHeight) - pUpdate->DstTop = scrnHeight - 1; + pUpdate->DstTop = scrnHeight - 1; pUpdate->DstRight = (dstRight > scrnWidth) ? scrnWidth : dstRight; pUpdate->DstBottom = (dstBottom > scrnHeight) ? scrnHeight : dstBottom; /* Update the overlay */ if (!Upd_Video(pScrn, videoFlag, startAddr, pUpdate, - pVia->swov.SWDevice.dwPitch, ovlV1->dwV1OriWidth, - ovlV1->dwV1OriHeight, deinterlaceMode, haveColorKey, - haveChromaKey, colorKeyLow, colorKeyHigh, chromaKeyLow, - chromaKeyHigh)) - return FALSE; + pVia->swov.SWDevice.dwPitch, ovlV1->dwV1OriWidth, + ovlV1->dwV1OriHeight, deinterlaceMode, haveColorKey, haveChromaKey, + colorKeyLow, colorKeyHigh, chromaKeyLow, chromaKeyHigh)) + return FALSE; pVia->swov.SWVideo_ON = FALSE; return TRUE; -} /* VIAVidUpdateOverlay */ +} /* VIAVidUpdateOverlay */ /* * @@ -2253,32 +2232,32 @@ ViaOverlayHide(ScrnInfoPtr pScrn) videoFlag = pVia->swov.gdwVideoFlagSW; if (pVia->ChipId == PCI_CHIP_VT3259 && !(videoFlag & VIDEO_1_INUSE)) - proReg = PRO_HQV1_OFFSET; + proReg = PRO_HQV1_OFFSET; ResetVidRegBuffer(pVia); if (pVia->HWDiff.dwHQVDisablePatch) - ViaSeqMask(hwp, 0x2E, 0x00, 0x10); + ViaSeqMask(hwp, 0x2E, 0x00, 0x10); - SaveVideoRegister(pVia, V_FIFO_CONTROL, V1_FIFO_PRETHRESHOLD12 | - V1_FIFO_THRESHOLD8 | V1_FIFO_DEPTH16); - SaveVideoRegister(pVia, ALPHA_V3_FIFO_CONTROL, ALPHA_FIFO_THRESHOLD4 - | ALPHA_FIFO_DEPTH8 | V3_FIFO_THRESHOLD24 | V3_FIFO_DEPTH32); + SaveVideoRegister(pVia, V_FIFO_CONTROL, V1_FIFO_PRETHRESHOLD12 + | V1_FIFO_THRESHOLD8 | V1_FIFO_DEPTH16); + SaveVideoRegister(pVia, ALPHA_V3_FIFO_CONTROL, ALPHA_FIFO_THRESHOLD4 + | ALPHA_FIFO_DEPTH8 | V3_FIFO_THRESHOLD24 | V3_FIFO_DEPTH32); if (videoFlag & VIDEO_HQV_INUSE) - SaveVideoRegister(pVia, HQV_CONTROL + proReg, - VIDInD(HQV_CONTROL + proReg) & ~HQV_ENABLE); + SaveVideoRegister(pVia, HQV_CONTROL + proReg, + VIDInD(HQV_CONTROL + proReg) & ~HQV_ENABLE); if (videoFlag & VIDEO_1_INUSE) - SaveVideoRegister(pVia, V1_CONTROL, VIDInD(V1_CONTROL) & ~V1_ENABLE); + SaveVideoRegister(pVia, V1_CONTROL, VIDInD(V1_CONTROL) & ~V1_ENABLE); else - SaveVideoRegister(pVia, V3_CONTROL, VIDInD(V3_CONTROL) & ~V3_ENABLE); + SaveVideoRegister(pVia, V3_CONTROL, VIDInD(V3_CONTROL) & ~V3_ENABLE); FireVideoCommand(pVia, videoFlag, VIDInD(V_COMPOSE_MODE)); FlushVidRegBuffer(pVia); if (pVia->HWDiff.dwHQVDisablePatch) - ViaSeqMask(hwp, 0x2E, 0x10, 0x10); + ViaSeqMask(hwp, 0x2E, 0x10, 0x10); pVia->swov.SWVideo_ON = FALSE; pVia->VideoStatus &= ~VIDEO_SWOV_ON; diff --git a/src/via_vbe.c b/src/via_vbe.c index 4122558..228b6a2 100644 --- a/src/via_vbe.c +++ b/src/via_vbe.c @@ -95,7 +95,7 @@ static int ViaVbeGetActiveDevices(ScrnInfoPtr pScrn) { /* Set Active Device and Translate BIOS byte definition */ if (pBIOSInfo->CrtActive) activeDevices = 0x01; - if (pBIOSInfo->PanelActive) + if (pBIOSInfo->Panel->IsActive) activeDevices |= 0x02; if (pBIOSInfo->TVActive) activeDevices |= 0x04; @@ -242,7 +242,7 @@ ViaVbeSetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode) } } else { - if (pBIOSInfo->PanelActive && !pVia->useLegacyVBE) { + if (pBIOSInfo->Panel->IsActive && !pVia->useLegacyVBE) { /* * FIXME: should we always set the panel expansion? * does it depend on the resolution? @@ -435,7 +435,7 @@ ViaVbeDoDPMS(ScrnInfoPtr pScrn, int mode) VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; - if (pBIOSInfo->PanelActive) + if (pBIOSInfo->Panel->IsActive) ViaVbePanelPower(pVia->pVbe, (mode == DPMSModeOn)); VBEDPMSSet(pVia->pVbe,mode); diff --git a/src/via_video.c b/src/via_video.c index 3e04177..5ce980c 100644 --- a/src/via_video.c +++ b/src/via_video.c @@ -276,157 +276,157 @@ DecideOverlaySupport(ScrnInfoPtr pScrn) * to avoid numeric overflow */ if (pVia->ChipId != PCI_CHIP_VT3205 && - pVia->ChipId != PCI_CHIP_VT3204 && - pVia->ChipId != PCI_CHIP_VT3259 && - pVia->ChipId != PCI_CHIP_VT3314 && - pVia->ChipId != PCI_CHIP_VT3327 && - pVia->ChipId != PCI_CHIP_VT3336 && - pVia->ChipId != PCI_CHIP_VT3364 && - pVia->ChipId != PCI_CHIP_VT3324) { - CARD32 bandwidth = (mode->HDisplay >> 4) * (mode->VDisplay >> 5) * - pScrn->bitsPerPixel * mode->VRefresh; - - switch (pVia->MemClk) { - case VIA_MEM_SDR100: /* No overlay without DDR */ - case VIA_MEM_SDR133: - return FALSE; - case VIA_MEM_DDR200: - /* Basic limit for DDR200 is about this */ - if (bandwidth > 1800000) - return FALSE; - /* But we have constraints at higher than 800x600 */ - if (mode->HDisplay > 800) { - if (pScrn->bitsPerPixel != 8) - return FALSE; - if (mode->VDisplay > 768) - return FALSE; - if (mode->VRefresh > 60) - return FALSE; - } - return TRUE; - case 0: /* FIXME: Why does my CLE266 report 0? */ - case VIA_MEM_DDR266: - if (bandwidth > 7901250) - return FALSE; - return TRUE; - } - return FALSE; + pVia->ChipId != PCI_CHIP_VT3204 && + pVia->ChipId != PCI_CHIP_VT3259 && + pVia->ChipId != PCI_CHIP_VT3314 && + pVia->ChipId != PCI_CHIP_VT3327 && + pVia->ChipId != PCI_CHIP_VT3336 && + pVia->ChipId != PCI_CHIP_VT3364 && + pVia->ChipId != PCI_CHIP_VT3324) { + CARD32 bandwidth = (mode->HDisplay >> 4) * (mode->VDisplay >> 5) * + pScrn->bitsPerPixel * mode->VRefresh; + + switch (pVia->MemClk) { + case VIA_MEM_SDR100: /* No overlay without DDR */ + case VIA_MEM_SDR133: + return FALSE; + case VIA_MEM_DDR200: + /* Basic limit for DDR200 is about this */ + if (bandwidth > 1800000) + return FALSE; + /* But we have constraints at higher than 800x600 */ + if (mode->HDisplay > 800) { + if (pScrn->bitsPerPixel != 8) + return FALSE; + if (mode->VDisplay > 768) + return FALSE; + if (mode->VRefresh > 60) + return FALSE; + } + return TRUE; + case 0: /* FIXME: Why does my CLE266 report 0? */ + case VIA_MEM_DDR266: + if (bandwidth > 7901250) + return FALSE; + return TRUE; + } + return FALSE; } else { - VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; - unsigned width, height, refresh, dClock; - float mClock, memEfficiency, needBandWidth, totalBandWidth; - int bTV = 0; - - switch (pVia->MemClk) { - case VIA_MEM_SDR100: - mClock = 50; /*HW base on 128 bit */ - memEfficiency = (float)SINGLE_3205_100; - break; - case VIA_MEM_SDR133: - mClock = 66.5; - memEfficiency = (float)SINGLE_3205_100; - break; - case VIA_MEM_DDR200: - mClock = 100; - memEfficiency = (float)SINGLE_3205_100; - break; - case VIA_MEM_DDR266: - mClock = 133; - memEfficiency = (float)SINGLE_3205_133; - break; - case VIA_MEM_DDR333: - mClock = 166; - memEfficiency = (float)SINGLE_3205_133; - break; - case VIA_MEM_DDR400: - mClock = 200; - memEfficiency = (float)SINGLE_3205_133; - break; - case VIA_MEM_DDR533: - mClock = 266; - memEfficiency = (float)SINGLE_3205_133; - break; - case VIA_MEM_DDR667: - mClock = 333; - memEfficiency = (float)SINGLE_3205_133; - break; - default: - /*Unknow DRAM Type */ - DBG_DD(ErrorF("Unknow DRAM Type!\n")); - mClock = 166; - memEfficiency = (float)SINGLE_3205_133; - break; - } - - width = mode->HDisplay; - height = mode->VDisplay; - refresh = mode->VRefresh; - - /* - * FIXME: If VBE modes assume a high refresh (100) for now - */ - - if (pVia->pVbe) { - refresh = 100; - if (pBIOSInfo->PanelActive) - refresh = 70; - if (pBIOSInfo->TVActive) - refresh = 60; - } else { - if (pBIOSInfo->PanelActive) { - width = pBIOSInfo->panelX; - height = pBIOSInfo->panelY; - if ((width == 1400) && (height == 1050)) { - width = 1280; - height = 1024; - refresh = 60; - } - } else if (pBIOSInfo->TVActive) { - bTV = 1; - } - } - if (bTV) { - - /* - * Approximative, VERY conservative formula in some cases. - * This formula and the one below are derived analyzing the - * tables present in VIA's own drivers. They may reject the over- - * lay in some cases where VIA's driver don't. - */ - - dClock = (width * height * 60) / 580000; - - } else { - - /* - * Approximative, slightly conservative formula. See above. - */ - - dClock = (width * height * refresh) / 680000; - } - - if (dClock) { - needBandWidth = - (float)(((pScrn->bitsPerPixel >> 3) + VIDEO_BPP) * dClock); - totalBandWidth = (float)(mClock * 16. * memEfficiency); - - DBG_DD(ErrorF(" via_video.c : cBitsPerPel= %d : \n", - pScrn->bitsPerPixel)); - DBG_DD(ErrorF(" via_video.c : Video_Bpp= %d : \n", VIDEO_BPP)); - DBG_DD(ErrorF(" via_video.c : refresh = %d : \n", refresh)); - DBG_DD(ErrorF(" via_video.c : dClock= %d : \n", dClock)); - DBG_DD(ErrorF(" via_video.c : mClk= %f : \n", mClock)); - DBG_DD(ErrorF(" via_video.c : memEfficiency= %f : \n", - memEfficiency)); - DBG_DD(ErrorF(" via_video.c : needBandwidth= %f : \n", - needBandWidth)); - DBG_DD(ErrorF(" via_video.c : totalBandwidth= %f : \n", - totalBandWidth)); - if (needBandWidth < totalBandWidth) - return TRUE; - } - return FALSE; + VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; + unsigned width, height, refresh, dClock; + float mClock, memEfficiency, needBandWidth, totalBandWidth; + int bTV = 0; + + switch (pVia->MemClk) { + case VIA_MEM_SDR100: + mClock = 50; /*HW base on 128 bit */ + memEfficiency = (float)SINGLE_3205_100; + break; + case VIA_MEM_SDR133: + mClock = 66.5; + memEfficiency = (float)SINGLE_3205_100; + break; + case VIA_MEM_DDR200: + mClock = 100; + memEfficiency = (float)SINGLE_3205_100; + break; + case VIA_MEM_DDR266: + mClock = 133; + memEfficiency = (float)SINGLE_3205_133; + break; + case VIA_MEM_DDR333: + mClock = 166; + memEfficiency = (float)SINGLE_3205_133; + break; + case VIA_MEM_DDR400: + mClock = 200; + memEfficiency = (float)SINGLE_3205_133; + break; + case VIA_MEM_DDR533: + mClock = 266; + memEfficiency = (float)SINGLE_3205_133; + break; + case VIA_MEM_DDR667: + mClock = 333; + memEfficiency = (float)SINGLE_3205_133; + break; + default: + /*Unknow DRAM Type */ + DBG_DD(ErrorF("Unknow DRAM Type!\n")); + mClock = 166; + memEfficiency = (float)SINGLE_3205_133; + break; + } + + width = mode->HDisplay; + height = mode->VDisplay; + refresh = mode->VRefresh; + + /* + * FIXME: If VBE modes assume a high refresh (100) for now + */ + + if (pVia->pVbe) { + refresh = 100; + if (pBIOSInfo->Panel->IsActive) + refresh = 70; + if (pBIOSInfo->TVActive) + refresh = 60; + } else { + if (pBIOSInfo->Panel->IsActive) { + width = pBIOSInfo->panelX; + height = pBIOSInfo->panelY; + if ((width == 1400) && (height == 1050)) { + width = 1280; + height = 1024; + refresh = 60; + } + } else if (pBIOSInfo->TVActive) { + bTV = 1; + } + } + if (bTV) { + + /* + * Approximative, VERY conservative formula in some cases. + * This formula and the one below are derived analyzing the + * tables present in VIA's own drivers. They may reject the over- + * lay in some cases where VIA's driver don't. + */ + + dClock = (width * height * 60) / 580000; + + } else { + + /* + * Approximative, slightly conservative formula. See above. + */ + + dClock = (width * height * refresh) / 680000; + } + + if (dClock) { + needBandWidth = + (float)(((pScrn->bitsPerPixel >> 3) + VIDEO_BPP) * dClock); + totalBandWidth = (float)(mClock * 16. * memEfficiency); + + DBG_DD(ErrorF(" via_video.c : cBitsPerPel= %d : \n", + pScrn->bitsPerPixel)); + DBG_DD(ErrorF(" via_video.c : Video_Bpp= %d : \n", VIDEO_BPP)); + DBG_DD(ErrorF(" via_video.c : refresh = %d : \n", refresh)); + DBG_DD(ErrorF(" via_video.c : dClock= %d : \n", dClock)); + DBG_DD(ErrorF(" via_video.c : mClk= %f : \n", mClock)); + DBG_DD(ErrorF(" via_video.c : memEfficiency= %f : \n", + memEfficiency)); + DBG_DD(ErrorF(" via_video.c : needBandwidth= %f : \n", + needBandWidth)); + DBG_DD(ErrorF(" via_video.c : totalBandwidth= %f : \n", + totalBandWidth)); + if (needBandWidth < totalBandWidth) + return TRUE; + } + return FALSE; } return FALSE; } @@ -443,15 +443,15 @@ static void viaXvError(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv, XvError error) { if (error == xve_none) { - pPriv->xvErr = xve_none; - return; + pPriv->xvErr = xve_none; + return; } if (error == pPriv->xvErr) { - return; + return; } pPriv->xvErr = error; xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[Xv] Port %d: %s\n", - pPriv->xv_portnum, viaXvErrMsg[error]); + pPriv->xv_portnum, viaXvErrMsg[error]); } static void @@ -522,25 +522,25 @@ viaExitVideo(ScrnInfoPtr pScrn) */ for (i = 0; i < XV_ADAPT_NUM; ++i) { - curAdapt = viaAdaptPtr[i]; - if (curAdapt) { - if (curAdapt->pPortPrivates) { - if (curAdapt->pPortPrivates->ptr) { - numPorts = numAdaptPort[i]; - for (j = 0; j < numPorts; ++j) { - viaStopVideo(pScrn, - (viaPortPrivPtr) curAdapt->pPortPrivates->ptr + j, - TRUE); - } - xfree(curAdapt->pPortPrivates->ptr); - } - xfree(curAdapt->pPortPrivates); - } - xfree(curAdapt); - } + curAdapt = viaAdaptPtr[i]; + if (curAdapt) { + if (curAdapt->pPortPrivates) { + if (curAdapt->pPortPrivates->ptr) { + numPorts = numAdaptPort[i]; + for (j = 0; j < numPorts; ++j) { + viaStopVideo(pScrn, + (viaPortPrivPtr) curAdapt->pPortPrivates->ptr + j, + TRUE); + } + xfree(curAdapt->pPortPrivates->ptr); + } + xfree(curAdapt->pPortPrivates); + } + xfree(curAdapt); + } } if (allAdaptors) - xfree(allAdaptors); + xfree(allAdaptors); } void @@ -560,65 +560,65 @@ viaInitVideo(ScreenPtr pScreen) pVia->useDmaBlit = FALSE; #ifdef XF86DRI pVia->useDmaBlit = pVia->directRenderingEnabled && - ((pVia->Chipset == VIA_CLE266) || - (pVia->Chipset == VIA_KM400) || - (pVia->Chipset == VIA_K8M800) || - (pVia->Chipset == VIA_PM800) || - (pVia->Chipset == VIA_VM800) || - (pVia->Chipset == VIA_K8M890) || - (pVia->Chipset == VIA_P4M900) || - (pVia->Chipset == VIA_CX700) || - (pVia->Chipset == VIA_P4M890)); - if ((pVia->drmVerMajor < 2) || - ((pVia->drmVerMajor == 2) && (pVia->drmVerMinor < 9))) - pVia->useDmaBlit = FALSE; + ((pVia->Chipset == VIA_CLE266) || + (pVia->Chipset == VIA_KM400) || + (pVia->Chipset == VIA_K8M800) || + (pVia->Chipset == VIA_PM800) || + (pVia->Chipset == VIA_VM800) || + (pVia->Chipset == VIA_K8M890) || + (pVia->Chipset == VIA_P4M900) || + (pVia->Chipset == VIA_CX700) || + (pVia->Chipset == VIA_P4M890)); + if ((pVia->drmVerMajor < 2) + || ((pVia->drmVerMajor == 2) && (pVia->drmVerMinor < 9))) + pVia->useDmaBlit = FALSE; #endif pVia->useDmaBlit = pVia->useDmaBlit && pVia->dmaXV; if (pVia->useDmaBlit) - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[Xv] Using PCI DMA for Xv image transfer.\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[Xv] Using PCI DMA for Xv image transfer.\n"); if (!viaFastVidCpy) - viaFastVidCpy = viaVidCopyInit("video", pScreen); + viaFastVidCpy = viaVidCopyInit("video", pScreen); if ((pVia->Chipset == VIA_CLE266) || (pVia->Chipset == VIA_KM400) || - (pVia->Chipset == VIA_K8M800) || (pVia->Chipset == VIA_PM800) || - (pVia->Chipset == VIA_VM800) || (pVia->Chipset == VIA_K8M890) || - (pVia->Chipset == VIA_P4M900) || (pVia->Chipset == VIA_CX700) || - (pVia->Chipset == VIA_P4M890)) { - num_new = viaSetupAdaptors(pScreen, &newAdaptors); - num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + (pVia->Chipset == VIA_K8M800) || (pVia->Chipset == VIA_PM800) || + (pVia->Chipset == VIA_VM800) || (pVia->Chipset == VIA_K8M890) || + (pVia->Chipset == VIA_P4M900) || (pVia->Chipset == VIA_CX700) || + (pVia->Chipset == VIA_P4M890)) { + num_new = viaSetupAdaptors(pScreen, &newAdaptors); + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); } else { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "[Xv] Unsupported Chipset. X video functionality disabled.\n"); - num_adaptors = 0; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "[Xv] Unsupported Chipset. X video functionality disabled.\n"); + num_adaptors = 0; } DBG_DD(ErrorF(" via_video.c : num_adaptors : %d\n", num_adaptors)); if (newAdaptors) { - allAdaptors = xalloc((num_adaptors + num_new) * - sizeof(XF86VideoAdaptorPtr *)); - if (allAdaptors) { - if (num_adaptors) - memcpy(allAdaptors, adaptors, - num_adaptors * sizeof(XF86VideoAdaptorPtr)); - memcpy(allAdaptors + num_adaptors, newAdaptors, - num_new * sizeof(XF86VideoAdaptorPtr)); - num_adaptors += num_new; - } + allAdaptors = xalloc((num_adaptors + num_new) * + sizeof(XF86VideoAdaptorPtr *)); + if (allAdaptors) { + if (num_adaptors) + memcpy(allAdaptors, adaptors, + num_adaptors * sizeof(XF86VideoAdaptorPtr)); + memcpy(allAdaptors + num_adaptors, newAdaptors, + num_new * sizeof(XF86VideoAdaptorPtr)); + num_adaptors += num_new; + } } if (num_adaptors) { - xf86XVScreenInit(pScreen, allAdaptors, num_adaptors); + xf86XVScreenInit(pScreen, allAdaptors, num_adaptors); #ifdef XF86DRI - ViaInitXVMC(pScreen); + ViaInitXVMC(pScreen); #endif - viaSetColorSpace(pVia, 0, 0, 0, 0, TRUE); - pVia->swov.panning_x = 0; - pVia->swov.panning_y = 0; - pVia->swov.oldPanningX = 0; - pVia->swov.oldPanningY = 0; + viaSetColorSpace(pVia, 0, 0, 0, 0, TRUE); + pVia->swov.panning_x = 0; + pVia->swov.panning_y = 0; + pVia->swov.oldPanningX = 0; + pVia->swov.oldPanningY = 0; } } @@ -630,21 +630,22 @@ RegionsEqual(RegionPtr A, RegionPtr B) num = REGION_NUM_RECTS(A); if (num != REGION_NUM_RECTS(B)) - return FALSE; + return FALSE; if ((A->extents.x1 != B->extents.x1) || - (A->extents.x2 != B->extents.x2) || - (A->extents.y1 != B->extents.y1) || (A->extents.y2 != B->extents.y2)) - return FALSE; + (A->extents.x2 != B->extents.x2) || + (A->extents.y1 != B->extents.y1) || + (A->extents.y2 != B->extents.y2)) + return FALSE; dataA = (int *)REGION_RECTS(A); dataB = (int *)REGION_RECTS(B); while (num--) { - if ((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) - return FALSE; - dataA += 2; - dataB += 2; + if ((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + return FALSE; + dataA += 2; + dataB += 2; } return TRUE; @@ -653,101 +654,98 @@ RegionsEqual(RegionPtr A, RegionPtr B) #ifdef USE_NEW_XVABI static void -viaVideoFillPixmap(ScrnInfoPtr pScrn, - char *base, - unsigned long pitch, - int depth, - int x, int y, int w, int h, - unsigned long color) +viaVideoFillPixmap(ScrnInfoPtr pScrn, + char *base, + unsigned long pitch, + int depth, + int x, int y, int w, int h, + unsigned long color) { int i; ErrorF("pitch %lu, depth %d, x %d, y %d, w %d h %d, color 0x%08x\n", - pitch, depth, x, y, w, h, color); - + pitch, depth, x, y, w, h, color); + depth = (depth + 7) >> 3; base += y*pitch + x*depth; - + switch(depth) { - case 4: - while(h--) { - register CARD32 *p = (CARD32 *)base; - for (i=0; i<w; ++i) { - *p++ = color; - } - base += pitch; - } - break; - case 2: { - register CARD16 col = color & 0x0000FFFF; - while(h--) { - register CARD16 *p = (CARD16 *)base; - for (i=0; i<w; ++i) { - *p++ = col; - } - base += pitch; - } - break; - } - case 1: { - register CARD8 col = color & 0xFF; - while(h--) { - register CARD8 *p = (CARD8 *)base; - for (i=0; i<w; ++i) { - *p++ = col; - } - base += pitch; - } - break; - } - default: - break; + case 4: + while(h--) { + register CARD32 *p = (CARD32 *)base; + for (i=0; i<w; ++i) { + *p++ = color; + } + base += pitch; + } + break; + case 2: { + register CARD16 col = color & 0x0000FFFF; + while(h--) { + register CARD16 *p = (CARD16 *)base; + for (i=0; i<w; ++i) { + *p++ = col; + } + base += pitch; + } + break; + } + case 1: { + register CARD8 col = color & 0xFF; + while(h--) { + register CARD8 *p = (CARD8 *)base; + for (i=0; i<w; ++i) { + *p++ = col; + } + base += pitch; + } + break; + } + default: + break; } } - - static int viaPaintColorkey(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv, RegionPtr clipBoxes, - DrawablePtr pDraw) + DrawablePtr pDraw) { if (pDraw->type == DRAWABLE_WINDOW) { VIAPtr pVia = VIAPTR(pScrn); - PixmapPtr pPix = (pScrn->pScreen->GetWindowPixmap)((WindowPtr) pDraw); - unsigned long pitch = pPix->devKind; - long offset = (long) pPix->devPrivate.ptr - - (long) pVia->FBBase; - int x,y; - BoxPtr pBox; - int nBox; - - - REGION_TRANSLATE(pScrn->pScreen, clipBoxes, - pPix->screen_x, - - pPix->screen_y); - - nBox = REGION_NUM_RECTS(clipBoxes); - pBox = REGION_RECTS(clipBoxes); - - while(nBox--) { - if (pVia->NoAccel || offset < 0 || - offset > pScrn->videoRam*1024) { - viaVideoFillPixmap(pScrn, pPix->devPrivate.ptr, pitch, - pDraw->bitsPerPixel, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1, - pPriv->colorKey); - } else { - viaAccelFillPixmap(pScrn, offset, pitch, - pDraw->bitsPerPixel, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1, - pPriv->colorKey); - } - pBox++; - } - - DamageDamageRegion(pPix, clipBoxes); + PixmapPtr pPix = (pScrn->pScreen->GetWindowPixmap)((WindowPtr) pDraw); + unsigned long pitch = pPix->devKind; + long offset = (long) pPix->devPrivate.ptr - + (long) pVia->FBBase; + int x,y; + BoxPtr pBox; + int nBox; + + REGION_TRANSLATE(pScrn->pScreen, clipBoxes, - pPix->screen_x, + - pPix->screen_y); + + nBox = REGION_NUM_RECTS(clipBoxes); + pBox = REGION_RECTS(clipBoxes); + + while(nBox--) { + if (pVia->NoAccel || offset < 0 || + offset > pScrn->videoRam*1024) { + viaVideoFillPixmap(pScrn, pPix->devPrivate.ptr, pitch, + pDraw->bitsPerPixel, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1, + pPriv->colorKey); + } else { + viaAccelFillPixmap(pScrn, offset, pitch, + pDraw->bitsPerPixel, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1, + pPriv->colorKey); + } + pBox++; + } + + DamageDamageRegion(pPix, clipBoxes); } return 0; @@ -761,11 +759,11 @@ viaPaintColorkey(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv, RegionPtr clipBoxes, static int viaReputImage(ScrnInfoPtr pScrn, - short drw_x, short drw_y, RegionPtr clipBoxes, pointer data + short drw_x, short drw_y, RegionPtr clipBoxes, pointer data #ifdef USE_NEW_XVABI - , DrawablePtr pDraw + , DrawablePtr pDraw #endif - ) +) { DDUPDATEOVERLAY UpdateOverlay_Video; @@ -774,28 +772,28 @@ viaReputImage(ScrnInfoPtr pScrn, VIAPtr pVia = VIAPTR(pScrn); if (!RegionsEqual(&pPriv->clip, clipBoxes)) { - REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); - if (pPriv->autoPaint) { + REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); + if (pPriv->autoPaint) { #ifdef USE_NEW_XVABI - if (pDraw->type == DRAWABLE_WINDOW) { - viaPaintColorkey(pScrn, pPriv, clipBoxes, pDraw); - } else { - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, - clipBoxes); - } + if (pDraw->type == DRAWABLE_WINDOW) { + viaPaintColorkey(pScrn, pPriv, clipBoxes, pDraw); + } else { + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, + clipBoxes); + } #else - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, - clipBoxes); + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, + clipBoxes); #endif - } + } } if (drw_x == pPriv->old_drw_x && - drw_y == pPriv->old_drw_y && - pVia->swov.oldPanningX == pVia->swov.panning_x && - pVia->swov.oldPanningY == pVia->swov.panning_y) { - viaXvError(pScrn, pPriv, xve_none); - return Success; + drw_y == pPriv->old_drw_y && + pVia->swov.oldPanningX == pVia->swov.panning_x && + pVia->swov.oldPanningY == pVia->swov.panning_y) { + viaXvError(pScrn, pPriv, xve_none); + return Success; } lpUpdateOverlay->SrcLeft = pPriv->old_src_x; @@ -813,9 +811,9 @@ viaReputImage(ScrnInfoPtr pScrn, lpUpdateOverlay->dwFlags = DDOVER_KEYDEST; if (pScrn->bitsPerPixel == 8) - lpUpdateOverlay->dwColorSpaceLowValue = pPriv->colorKey & 0xff; + lpUpdateOverlay->dwColorSpaceLowValue = pPriv->colorKey & 0xff; else - lpUpdateOverlay->dwColorSpaceLowValue = pPriv->colorKey; + lpUpdateOverlay->dwColorSpaceLowValue = pPriv->colorKey; VIAVidUpdateOverlay(pScrn, lpUpdateOverlay); @@ -927,24 +925,24 @@ viaStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) REGION_EMPTY(pScrn->pScreen, &pPriv->clip); if (exit) { - ViaOverlayHide(pScrn); - ViaSwovSurfaceDestroy(pScrn, pPriv); - if (pPriv->dmaBounceBuffer) - xfree(pPriv->dmaBounceBuffer); - pPriv->dmaBounceBuffer = 0; - pPriv->dmaBounceStride = 0; - pPriv->dmaBounceLines = 0; - pVia->dwFrameNum = 0; - pPriv->old_drw_x = 0; - pPriv->old_drw_y = 0; - pPriv->old_drw_w = 0; - pPriv->old_drw_h = 0; + ViaOverlayHide(pScrn); + ViaSwovSurfaceDestroy(pScrn, pPriv); + if (pPriv->dmaBounceBuffer) + xfree(pPriv->dmaBounceBuffer); + pPriv->dmaBounceBuffer = 0; + pPriv->dmaBounceStride = 0; + pPriv->dmaBounceLines = 0; + pVia->dwFrameNum = 0; + pPriv->old_drw_x = 0; + pPriv->old_drw_y = 0; + pPriv->old_drw_w = 0; + pPriv->old_drw_h = 0; } } static int viaSetPortAttribute(ScrnInfoPtr pScrn, - Atom attribute, INT32 value, pointer data) + Atom attribute, INT32 value, pointer data) { VIAPtr pVia = VIAPTR(pScrn); vmmtr viaVidEng = (vmmtr) pVia->VidMapBase; @@ -955,45 +953,45 @@ viaSetPortAttribute(ScrnInfoPtr pScrn, /* Color Key */ if (attribute == xvColorKey) { - DBG_DD(ErrorF(" V4L Disable xvColorKey = %08lx\n", value)); + DBG_DD(ErrorF(" V4L Disable xvColorKey = %08lx\n", value)); - pPriv->colorKey = value; - /* All assume color depth is 16 */ - value &= 0x00FFFFFF; - viaVidEng->color_key = value; - viaVidEng->snd_color_key = value; - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - DBG_DD(ErrorF(" V4L Disable done xvColorKey = %08lx\n", value)); + pPriv->colorKey = value; + /* All assume color depth is 16 */ + value &= 0x00FFFFFF; + viaVidEng->color_key = value; + viaVidEng->snd_color_key = value; + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + DBG_DD(ErrorF(" V4L Disable done xvColorKey = %08lx\n", value)); } else if (attribute == xvAutoPaint) { - pPriv->autoPaint = value; - DBG_DD(ErrorF(" xvAutoPaint = %08lx\n", value)); - /* Color Control */ + pPriv->autoPaint = value; + DBG_DD(ErrorF(" xvAutoPaint = %08lx\n", value)); + /* Color Control */ } else if (attribute == xvBrightness || - attribute == xvContrast || - attribute == xvSaturation || attribute == xvHue) { - if (attribute == xvBrightness) { - DBG_DD(ErrorF(" xvBrightness = %08ld\n", value)); - pPriv->brightness = value; - } - if (attribute == xvContrast) { - DBG_DD(ErrorF(" xvContrast = %08ld\n", value)); - pPriv->contrast = value; - } - if (attribute == xvSaturation) { - DBG_DD(ErrorF(" xvSaturation = %08ld\n", value)); - pPriv->saturation = value; - } - if (attribute == xvHue) { - DBG_DD(ErrorF(" xvHue = %08ld\n", value)); - pPriv->hue = value; - } - viaSetColorSpace(pVia, pPriv->hue, pPriv->saturation, - pPriv->brightness, pPriv->contrast, FALSE); + attribute == xvContrast || + attribute == xvSaturation || attribute == xvHue) { + if (attribute == xvBrightness) { + DBG_DD(ErrorF(" xvBrightness = %08ld\n", value)); + pPriv->brightness = value; + } + if (attribute == xvContrast) { + DBG_DD(ErrorF(" xvContrast = %08ld\n", value)); + pPriv->contrast = value; + } + if (attribute == xvSaturation) { + DBG_DD(ErrorF(" xvSaturation = %08ld\n", value)); + pPriv->saturation = value; + } + if (attribute == xvHue) { + DBG_DD(ErrorF(" xvHue = %08ld\n", value)); + pPriv->hue = value; + } + viaSetColorSpace(pVia, pPriv->hue, pPriv->saturation, + pPriv->brightness, pPriv->contrast, FALSE); } else { - DBG_DD(ErrorF - (" via_video.c : viaSetPortAttribute : is not supported the attribute")); - return BadMatch; + DBG_DD(ErrorF + (" via_video.c : viaSetPortAttribute : is not supported the attribute")); + return BadMatch; } /* attr,avalue hardware processing goes here */ @@ -1005,60 +1003,60 @@ viaSetPortAttribute(ScrnInfoPtr pScrn, static int viaGetPortAttribute(ScrnInfoPtr pScrn, - Atom attribute, INT32 * value, pointer data) + Atom attribute, INT32 * value, pointer data) { viaPortPrivPtr pPriv = (viaPortPrivPtr) data; DBG_DD(ErrorF(" via_video.c : viaGetPortAttribute : port %d %ld\n", - pPriv->xv_portnum, attribute)); + pPriv->xv_portnum, attribute)); *value = 0; if (attribute == xvColorKey) { - *value = (INT32) pPriv->colorKey; - DBG_DD(ErrorF(" via_video.c : ColorKey 0x%lx\n", pPriv->colorKey)); + *value = (INT32) pPriv->colorKey; + DBG_DD(ErrorF(" via_video.c : ColorKey 0x%lx\n", pPriv->colorKey)); } else if (attribute == xvAutoPaint) { - *value = (INT32) pPriv->autoPaint; - DBG_DD(ErrorF(" AutoPaint = %08ld\n", *value)); - /* Color Control */ + *value = (INT32) pPriv->autoPaint; + DBG_DD(ErrorF(" AutoPaint = %08ld\n", *value)); + /* Color Control */ } else if (attribute == xvBrightness || - attribute == xvContrast || - attribute == xvSaturation || attribute == xvHue) { - if (attribute == xvBrightness) { - *value = pPriv->brightness; - DBG_DD(ErrorF(" xvBrightness = %08ld\n", *value)); - } - if (attribute == xvContrast) { - *value = pPriv->contrast; - DBG_DD(ErrorF(" xvContrast = %08ld\n", *value)); - } - if (attribute == xvSaturation) { - *value = pPriv->saturation; - DBG_DD(ErrorF(" xvSaturation = %08ld\n", *value)); - } - if (attribute == xvHue) { - *value = pPriv->hue; - DBG_DD(ErrorF(" xvHue = %08ld\n", *value)); - } + attribute == xvContrast || + attribute == xvSaturation || attribute == xvHue) { + if (attribute == xvBrightness) { + *value = pPriv->brightness; + DBG_DD(ErrorF(" xvBrightness = %08ld\n", *value)); + } + if (attribute == xvContrast) { + *value = pPriv->contrast; + DBG_DD(ErrorF(" xvContrast = %08ld\n", *value)); + } + if (attribute == xvSaturation) { + *value = pPriv->saturation; + DBG_DD(ErrorF(" xvSaturation = %08ld\n", *value)); + } + if (attribute == xvHue) { + *value = pPriv->hue; + DBG_DD(ErrorF(" xvHue = %08ld\n", *value)); + } } else { - /*return BadMatch */ ; + /*return BadMatch */; } return Success; } static void viaQueryBestSize(ScrnInfoPtr pScrn, - Bool motion, - short vid_w, short vid_h, - short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, pointer data) + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, pointer data) { DBG_DD(ErrorF(" via_video.c : viaQueryBestSize :\n")); *p_w = drw_w; *p_h = drw_h; if (*p_w > 2048) - *p_w = 2048; + *p_w = 2048; } /* @@ -1066,45 +1064,45 @@ viaQueryBestSize(ScrnInfoPtr pScrn, */ static void Flip(VIAPtr pVia, viaPortPrivPtr pPriv, int fourcc, - unsigned long DisplayBufferIndex) + unsigned long DisplayBufferIndex) { unsigned long proReg = 0; if (pVia->ChipId == PCI_CHIP_VT3259 && !(pVia->swov.gdwVideoFlagSW & VIDEO_1_INUSE)) - proReg = PRO_HQV1_OFFSET; + proReg = PRO_HQV1_OFFSET; switch (fourcc) { - case FOURCC_UYVY: - case FOURCC_YUY2: - case FOURCC_RV15: - case FOURCC_RV16: - case FOURCC_RV32: - while ((VIDInD(HQV_CONTROL + proReg) & HQV_SW_FLIP)) ; - VIDOutD(HQV_SRC_STARTADDR_Y + proReg, - pVia->swov.SWDevice.dwSWPhysicalAddr[DisplayBufferIndex]); - VIDOutD(HQV_CONTROL + proReg, - (VIDInD(HQV_CONTROL + - proReg) & ~HQV_FLIP_ODD) | HQV_SW_FLIP | HQV_FLIP_STATUS); - break; - - case FOURCC_YV12: - default: - while ((VIDInD(HQV_CONTROL + proReg) & HQV_SW_FLIP)) ; - VIDOutD(HQV_SRC_STARTADDR_Y + proReg, - pVia->swov.SWDevice.dwSWPhysicalAddr[DisplayBufferIndex]); - if (pVia->VideoEngine == VIDEO_ENGINE_CME) { - VIDOutD(HQV_SRC_STARTADDR_U + proReg, - pVia->swov.SWDevice.dwSWCrPhysicalAddr[DisplayBufferIndex]); - } else { - VIDOutD(HQV_SRC_STARTADDR_U, - pVia->swov.SWDevice.dwSWCbPhysicalAddr[DisplayBufferIndex]); - VIDOutD(HQV_SRC_STARTADDR_V, - pVia->swov.SWDevice.dwSWCrPhysicalAddr[DisplayBufferIndex]); - } - VIDOutD(HQV_CONTROL + proReg, - (VIDInD(HQV_CONTROL + - proReg) & ~HQV_FLIP_ODD) | HQV_SW_FLIP | HQV_FLIP_STATUS); - break; + case FOURCC_UYVY: + case FOURCC_YUY2: + case FOURCC_RV15: + case FOURCC_RV16: + case FOURCC_RV32: + while ((VIDInD(HQV_CONTROL + proReg) & HQV_SW_FLIP)); + VIDOutD(HQV_SRC_STARTADDR_Y + proReg, + pVia->swov.SWDevice.dwSWPhysicalAddr[DisplayBufferIndex]); + VIDOutD(HQV_CONTROL + proReg, + (VIDInD(HQV_CONTROL + + proReg) & ~HQV_FLIP_ODD) | HQV_SW_FLIP | HQV_FLIP_STATUS); + break; + + case FOURCC_YV12: + default: + while ((VIDInD(HQV_CONTROL + proReg) & HQV_SW_FLIP)); + VIDOutD(HQV_SRC_STARTADDR_Y + proReg, + pVia->swov.SWDevice.dwSWPhysicalAddr[DisplayBufferIndex]); + if (pVia->VideoEngine == VIDEO_ENGINE_CME) { + VIDOutD(HQV_SRC_STARTADDR_U + proReg, + pVia->swov.SWDevice.dwSWCrPhysicalAddr[DisplayBufferIndex]); + } else { + VIDOutD(HQV_SRC_STARTADDR_U, + pVia->swov.SWDevice.dwSWCbPhysicalAddr[DisplayBufferIndex]); + VIDOutD(HQV_SRC_STARTADDR_V, + pVia->swov.SWDevice.dwSWCrPhysicalAddr[DisplayBufferIndex]); + } + VIDOutD(HQV_CONTROL + proReg, + (VIDInD(HQV_CONTROL + proReg) + & ~HQV_FLIP_ODD) | HQV_SW_FLIP | HQV_FLIP_STATUS); + break; } } @@ -1129,9 +1127,9 @@ nv12cp(unsigned char *dst, static int viaDmaBlitImage(VIAPtr pVia, - viaPortPrivPtr pPort, - unsigned char *src, - CARD32 dst, unsigned width, unsigned height, unsigned lumaStride, int id) + viaPortPrivPtr pPort, + unsigned char *src, + CARD32 dst, unsigned width, unsigned height, unsigned lumaStride, int id) { Bool bounceBuffer; drm_via_dmablit_t blit; @@ -1146,53 +1144,52 @@ viaDmaBlitImage(VIAPtr pVia, Bool nv12Conversion; bounceBuffer = ((unsigned long)src & 15); - nv12Conversion = (pVia->VideoEngine == VIDEO_ENGINE_CME && - id == FOURCC_YV12); + nv12Conversion = (pVia->VideoEngine == VIDEO_ENGINE_CME && + id == FOURCC_YV12); switch (id) { - case FOURCC_YUY2: - case FOURCC_RV15: - case FOURCC_RV16: - bounceStride = ALIGN_TO(2 * width, 16); - bounceLines = height; - break; - case FOURCC_RV32: - bounceStride = ALIGN_TO(4 * width, 16); - bounceLines = height; - break; - - case FOURCC_YV12: - default: - bounceStride = ALIGN_TO(width, 16); - bounceLines = height; - break; + case FOURCC_YUY2: + case FOURCC_RV15: + case FOURCC_RV16: + bounceStride = ALIGN_TO(2 * width, 16); + bounceLines = height; + break; + case FOURCC_RV32: + bounceStride = ALIGN_TO(4 * width, 16); + bounceLines = height; + break; + case FOURCC_YV12: + default: + bounceStride = ALIGN_TO(width, 16); + bounceLines = height; + break; } if (bounceBuffer || nv12Conversion) { - if (!pPort->dmaBounceBuffer || - pPort->dmaBounceStride != bounceStride || - pPort->dmaBounceLines != bounceLines) { - if (pPort->dmaBounceBuffer) { - xfree(pPort->dmaBounceBuffer); - pPort->dmaBounceBuffer = 0; - } - size = bounceStride * bounceLines + 16; - if (FOURCC_YV12 == id) - size += ALIGN_TO(bounceStride >> 1, 16) * bounceLines; - pPort->dmaBounceBuffer = (unsigned char *)malloc(size); - pPort->dmaBounceLines = bounceLines; - pPort->dmaBounceStride = bounceStride; - } + if (!pPort->dmaBounceBuffer || + pPort->dmaBounceStride != bounceStride || + pPort->dmaBounceLines != bounceLines) { + if (pPort->dmaBounceBuffer) { + xfree(pPort->dmaBounceBuffer); + pPort->dmaBounceBuffer = 0; + } + size = bounceStride * bounceLines + 16; + if (FOURCC_YV12 == id) + size += ALIGN_TO(bounceStride >> 1, 16) * bounceLines; + pPort->dmaBounceBuffer = (unsigned char *)malloc(size); + pPort->dmaBounceLines = bounceLines; + pPort->dmaBounceStride = bounceStride; + } } bounceBase = - (unsigned char *)ALIGN_TO((unsigned long)(pPort->dmaBounceBuffer), - 16); + (unsigned char *)ALIGN_TO((unsigned long)(pPort->dmaBounceBuffer), + 16); base = (bounceBuffer) ? bounceBase : src; if (bounceBuffer) { - (*viaFastVidCpy) (base, src, bounceStride, bounceStride >> 1, height, - 1); + (*viaFastVidCpy) (base, src, bounceStride, bounceStride >> 1, height, + 1); } blit.num_lines = height; @@ -1204,61 +1201,61 @@ viaDmaBlitImage(VIAPtr pVia, blit.to_fb = 1; #ifdef XV_DEBUG ErrorF - ("Addr: 0x%lx, Offset 0x%lx\n Fb_stride: %u, Mem_stride: %u\n width: %u num_lines: %u\n", - (unsigned long)blit.mem_addr, (unsigned long)blit.fb_addr, - (unsigned)blit.fb_stride, (unsigned)blit.mem_stride, - (unsigned)blit.line_length, (unsigned)blit.num_lines); + ("Addr: 0x%lx, Offset 0x%lx\n Fb_stride: %u, Mem_stride: %u\n width: %u num_lines: %u\n", + (unsigned long)blit.mem_addr, (unsigned long)blit.fb_addr, + (unsigned)blit.fb_stride, (unsigned)blit.mem_stride, + (unsigned)blit.line_length, (unsigned)blit.num_lines); #endif while (-EAGAIN == (err = - drmCommandWriteRead(pVia->drmFD, DRM_VIA_DMA_BLIT, &blit, - sizeof(blit)))) ; + drmCommandWriteRead(pVia->drmFD, DRM_VIA_DMA_BLIT, &blit, + sizeof(blit)))); if (err < 0) - return -1; + return -1; lumaSync = blit.sync; if (id == FOURCC_YV12) { - unsigned tmp = ALIGN_TO(width >> 1, 16); - - if (nv12Conversion) { - nv12Blit(bounceBase + bounceStride * height, - src + bounceStride * height + tmp * (height >> 1), - src + bounceStride * height, width >> 1, tmp, - bounceStride, height >> 1); - } else if (bounceBuffer) { - (*viaFastVidCpy) (base + bounceStride * height, - src + bounceStride * height, tmp, tmp >> 1, height, 1); - } - - if (nv12Conversion) { - blit.num_lines = height >> 1; - blit.line_length = bounceStride; - blit.mem_addr = bounceBase + bounceStride * height; - blit.fb_stride = lumaStride; - blit.mem_stride = bounceStride; - } else { - blit.num_lines = height; - blit.line_length = tmp; - blit.mem_addr = base + bounceStride * height; - blit.fb_stride = lumaStride >> 1; - blit.mem_stride = tmp; - } - - blit.fb_addr = dst + lumaStride * height; - blit.to_fb = 1; - - while (-EAGAIN == (err = - drmCommandWriteRead(pVia->drmFD, DRM_VIA_DMA_BLIT, &blit, - sizeof(blit)))) ; - if (err < 0) - return -1; + unsigned tmp = ALIGN_TO(width >> 1, 16); + + if (nv12Conversion) { + nv12Blit(bounceBase + bounceStride * height, + src + bounceStride * height + tmp * (height >> 1), + src + bounceStride * height, width >> 1, tmp, + bounceStride, height >> 1); + } else if (bounceBuffer) { + (*viaFastVidCpy) (base + bounceStride * height, + src + bounceStride * height, tmp, tmp >> 1, height, 1); + } + + if (nv12Conversion) { + blit.num_lines = height >> 1; + blit.line_length = bounceStride; + blit.mem_addr = bounceBase + bounceStride * height; + blit.fb_stride = lumaStride; + blit.mem_stride = bounceStride; + } else { + blit.num_lines = height; + blit.line_length = tmp; + blit.mem_addr = base + bounceStride * height; + blit.fb_stride = lumaStride >> 1; + blit.mem_stride = tmp; + } + + blit.fb_addr = dst + lumaStride * height; + blit.to_fb = 1; + + while (-EAGAIN == (err = + drmCommandWriteRead(pVia->drmFD, DRM_VIA_DMA_BLIT, &blit, + sizeof(blit)))); + if (err < 0) + return -1; } while (-EAGAIN == (err = drmCommandWrite(pVia->drmFD, DRM_VIA_BLIT_SYNC, - chromaSync, sizeof(*chromaSync)))) ; + chromaSync, sizeof(*chromaSync)))); if (err < 0) - return -1; + return -1; return Success; } @@ -1444,19 +1441,19 @@ viaPutImage(ScrnInfoPtr pScrn, /* BitBlt: Draw the colorkey rectangle */ if (!RegionsEqual(&pPriv->clip, clipBoxes)) { REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); - if (pPriv->autoPaint) { + if (pPriv->autoPaint) { #ifdef USE_NEW_XVABI - if (pDraw->type == DRAWABLE_WINDOW) { - viaPaintColorkey(pScrn, pPriv, clipBoxes, pDraw); - } else { - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, - clipBoxes); - } + if (pDraw->type == DRAWABLE_WINDOW) { + viaPaintColorkey(pScrn, pPriv, clipBoxes, pDraw); + } else { + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, + clipBoxes); + } #else - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, - clipBoxes); + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, + clipBoxes); #endif - } + } } /* * Update video overlay @@ -1472,9 +1469,9 @@ viaPutImage(ScrnInfoPtr pScrn, break; } default: - DBG_DD(ErrorF(" via_video.c : XVPort not supported\n")); - viaXvError(pScrn, pPriv, xve_adaptor); - break; + DBG_DD(ErrorF(" via_video.c : XVPort not supported\n")); + viaXvError(pScrn, pPriv, xve_adaptor); + break; } DBG_DD(ErrorF(" via_video.c : PutImage done OK\n")); viaXvError(pScrn, pPriv, xve_none); @@ -1483,94 +1480,94 @@ viaPutImage(ScrnInfoPtr pScrn, static int viaQueryImageAttributes(ScrnInfoPtr pScrn, - int id, unsigned short *w, unsigned short *h, int *pitches, int *offsets) + int id, unsigned short *w, unsigned short *h, int *pitches, int *offsets) { int size, tmp; VIAPtr pVia = VIAPTR(pScrn); DBG_DD(ErrorF(" via_video.c : viaQueryImageAttributes : FourCC=0x%x, ", - id)); + id)); if ((!w) || (!h)) - return 0; + return 0; if (*w > VIA_MAX_XVIMAGE_X) - *w = VIA_MAX_XVIMAGE_X; + *w = VIA_MAX_XVIMAGE_X; if (*h > VIA_MAX_XVIMAGE_Y) - *h = VIA_MAX_XVIMAGE_Y; + *h = VIA_MAX_XVIMAGE_Y; *w = (*w + 1) & ~1; if (offsets) - offsets[0] = 0; + offsets[0] = 0; switch (id) { - case FOURCC_YV12: /*Planar format : YV12 -4:2:0 */ - *h = (*h + 1) & ~1; - size = *w; - if (pVia->useDmaBlit) - size = (size + 15) & ~15; - if (pitches) - pitches[0] = size; - size *= *h; - if (offsets) - offsets[1] = size; - tmp = (*w >> 1); - if (pVia->useDmaBlit) - tmp = (tmp + 15) & ~15; - if (pitches) - pitches[1] = pitches[2] = tmp; - tmp *= (*h >> 1); - size += tmp; - if (offsets) - offsets[2] = size; - size += tmp; - break; - case FOURCC_XVMC: - *h = (*h + 1) & ~1; + case FOURCC_YV12: /*Planar format : YV12 -4:2:0 */ + *h = (*h + 1) & ~1; + size = *w; + if (pVia->useDmaBlit) + size = (size + 15) & ~15; + if (pitches) + pitches[0] = size; + size *= *h; + if (offsets) + offsets[1] = size; + tmp = (*w >> 1); + if (pVia->useDmaBlit) + tmp = (tmp + 15) & ~15; + if (pitches) + pitches[1] = pitches[2] = tmp; + tmp *= (*h >> 1); + size += tmp; + if (offsets) + offsets[2] = size; + size += tmp; + break; + case FOURCC_XVMC: + *h = (*h + 1) & ~1; #ifdef XF86DRI - size = viaXvMCPutImageSize(pScrn); + size = viaXvMCPutImageSize(pScrn); #else - size = 0; + size = 0; #endif - if (pitches) - pitches[0] = size; - break; - case FOURCC_AI44: - case FOURCC_IA44: - size = *w * *h; - if (pitches) - pitches[0] = *w; - if (offsets) - offsets[0] = 0; - break; - case FOURCC_RV32: - size = *w << 2; - if (pVia->useDmaBlit) - size = (size + 15) & ~15; - if (pitches) - pitches[0] = size; - size *= *h; - break; - case FOURCC_UYVY: /*Packed format : UYVY -4:2:2 */ - case FOURCC_YUY2: /*Packed format : YUY2 -4:2:2 */ - case FOURCC_RV15: - case FOURCC_RV16: - default: - size = *w << 1; - if (pVia->useDmaBlit) - size = (size + 15) & ~15; - if (pitches) - pitches[0] = size; - size *= *h; - break; + if (pitches) + pitches[0] = size; + break; + case FOURCC_AI44: + case FOURCC_IA44: + size = *w * *h; + if (pitches) + pitches[0] = *w; + if (offsets) + offsets[0] = 0; + break; + case FOURCC_RV32: + size = *w << 2; + if (pVia->useDmaBlit) + size = (size + 15) & ~15; + if (pitches) + pitches[0] = size; + size *= *h; + break; + case FOURCC_UYVY: /*Packed format : UYVY -4:2:2 */ + case FOURCC_YUY2: /*Packed format : YUY2 -4:2:2 */ + case FOURCC_RV15: + case FOURCC_RV16: + default: + size = *w << 1; + if (pVia->useDmaBlit) + size = (size + 15) & ~15; + if (pitches) + pitches[0] = size; + size *= *h; + break; } if (pitches) - DBG_DD(ErrorF(" pitches[0]=%d, pitches[1]=%d, pitches[2]=%d, ", - pitches[0], pitches[1], pitches[2])); + DBG_DD(ErrorF(" pitches[0]=%d, pitches[1]=%d, pitches[2]=%d, ", + pitches[0], pitches[1], pitches[2])); if (offsets) - DBG_DD(ErrorF(" offsets[0]=%d, offsets[1]=%d, offsets[2]=%d, ", - offsets[0], offsets[1], offsets[2])); + DBG_DD(ErrorF(" offsets[0]=%d, offsets[1]=%d, offsets[2]=%d, ", + offsets[0], offsets[1], offsets[2])); DBG_DD(ErrorF(" width=%d, height=%d \n", *w, *h)); return size; @@ -1595,9 +1592,9 @@ VIAVidAdjustFrame(ScrnInfoPtr pScrn, int x, int y) static void nv12Blit(unsigned char *nv12Chroma, - const unsigned char *uBuffer, - const unsigned char *vBuffer, - unsigned width, unsigned srcPitch, unsigned dstPitch, unsigned lines) + const unsigned char *uBuffer, + const unsigned char *vBuffer, + unsigned width, unsigned srcPitch, unsigned dstPitch, unsigned lines) { int x; int dstAdd; @@ -1607,33 +1604,33 @@ nv12Blit(unsigned char *nv12Chroma, srcAdd = srcPitch - width; while (lines--) { - x = width; - while (x > 3) { - register CARD32 - dst32, - src32 = *((CARD32 *) vBuffer), - src32_2 = *((CARD32 *) uBuffer); - dst32 = - (src32_2 & 0xff) | ((src32 & 0xff) << 8) | - ((src32_2 & 0x0000ff00) << 8) | ((src32 & 0x0000ff00) << 16); - *((CARD32 *) nv12Chroma) = dst32; - nv12Chroma += 4; - dst32 = - ((src32_2 & 0x00ff0000) >> 16) | ((src32 & 0x00ff0000) >> 8) | - ((src32_2 & 0xff000000) >> 8) | (src32 & 0xff000000); - *((CARD32 *) nv12Chroma) = dst32; - nv12Chroma += 4; - x -= 4; - vBuffer += 4; - uBuffer += 4; - } - while (x--) { - *nv12Chroma++ = *uBuffer++; - *nv12Chroma++ = *vBuffer++; - } - nv12Chroma += dstAdd; - vBuffer += srcAdd; - uBuffer += srcAdd; + x = width; + while (x > 3) { + register CARD32 + dst32, + src32 = *((CARD32 *) vBuffer), + src32_2 = *((CARD32 *) uBuffer); + dst32 = + (src32_2 & 0xff) | ((src32 & 0xff) << 8) | + ((src32_2 & 0x0000ff00) << 8) | ((src32 & 0x0000ff00) << 16); + *((CARD32 *) nv12Chroma) = dst32; + nv12Chroma += 4; + dst32 = + ((src32_2 & 0x00ff0000) >> 16) | ((src32 & 0x00ff0000) >> 8) | + ((src32_2 & 0xff000000) >> 8) | (src32 & 0xff000000); + *((CARD32 *) nv12Chroma) = dst32; + nv12Chroma += 4; + x -= 4; + vBuffer += 4; + uBuffer += 4; + } + while (x--) { + *nv12Chroma++ = *uBuffer++; + *nv12Chroma++ = *vBuffer++; + } + nv12Chroma += dstAdd; + vBuffer += srcAdd; + uBuffer += srcAdd; } } |