From 8ed256e94dae884b723c172320b15b0d6ae00a1b Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Fri, 7 Sep 2007 14:37:40 +0200 Subject: [PATCH] randr12: Fix Xv blitter, please see full changelog for other implications. - Removed the CRTCNumber variable, instead just store if crtc0 and crtc1 are active. - This coule break old style setups (picking the wrong monitor for example). - CRTCNumber option temporarily removed, because the piece of code surrounding it is ugly and needs a rework. --- src/nv_const.h | 2 +- src/nv_crtc.c | 6 ++++++ src/nv_dac.c | 13 ++++++------ src/nv_driver.c | 21 ++++++++------------ src/nv_setup.c | 53 ++++++++++++++++++++++++------------------------- src/nv_type.h | 17 ++++++++-------- src/nv_video.c | 4 +++- 7 files changed, 60 insertions(+), 56 deletions(-) diff --git a/src/nv_const.h b/src/nv_const.h index 3e4c782..9198d83 100644 --- a/src/nv_const.h +++ b/src/nv_const.h @@ -35,7 +35,7 @@ static const OptionInfoRec NVOptions[] = { { OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE }, { OPTION_FLAT_PANEL, "FlatPanel", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_FP_DITHER, "FPDither", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_CRTC_NUMBER, "CrtcNumber", OPTV_INTEGER, {0}, FALSE }, + //{ OPTION_CRTC_NUMBER, "CrtcNumber", OPTV_INTEGER, {0}, FALSE }, { OPTION_FP_SCALE, "FPScale", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_FP_TWEAK, "FPTweak", OPTV_INTEGER, {0}, FALSE }, { OPTION_ACCELMETHOD, "AccelMethod", OPTV_STRING, {0}, FALSE }, diff --git a/src/nv_crtc.c b/src/nv_crtc.c index 7d51871..f35e2bb 100644 --- a/src/nv_crtc.c +++ b/src/nv_crtc.c @@ -522,6 +522,7 @@ nv_crtc_dpms(xf86CrtcPtr crtc, int mode) unsigned char seq1 = 0, crtc17 = 0; unsigned char crtc1A; int ret; + Bool crtc_is_on = FALSE; NVCrtcSetOwner(crtc); @@ -550,6 +551,7 @@ nv_crtc_dpms(xf86CrtcPtr crtc, int mode) /* Screen: On; HSync: On, VSync: On */ seq1 = 0x00; crtc17 = 0x80; + crtc_is_on = TRUE; break; } @@ -563,6 +565,8 @@ nv_crtc_dpms(xf86CrtcPtr crtc, int mode) NVWriteVgaCrtc(crtc, NV_VGA_CRTCX_REPAINT1, crtc1A); + /* This is usefull for Xv NVWaitVSync() */ + nv_crtc->pNv->crtc_active[nv_crtc->crtc] = crtc_is_on; } static Bool @@ -1138,6 +1142,8 @@ nv_crtc_init(ScrnInfoPtr pScrn, int crtc_num) nv_crtc = xnfcalloc (sizeof (NVCrtcPrivateRec), 1); nv_crtc->crtc = crtc_num; + /* This is usefull to do stuff from crtc functions */ + nv_crtc->pNv = pNv; crtc->driver_private = nv_crtc; diff --git a/src/nv_dac.c b/src/nv_dac.c index 8f81c2d..f8ef012 100644 --- a/src/nv_dac.c +++ b/src/nv_dac.c @@ -230,7 +230,7 @@ NVDACInit(ScrnInfoPtr pScrn, DisplayModePtr mode) nvReg->fifo = nvReadVGA(pNv, 0x1c) & ~(1<<5); - if(pNv->CRTCnumber) { + if(pNv->crtc_active[1]) { nvReg->head = nvReadCRTC(pNv, 0, NV_CRTC_FSEL) & ~0x00001000; nvReg->head2 = nvReadCRTC(pNv, 1, NV_CRTC_FSEL) | 0x00001000; nvReg->crtcOwner = 3; @@ -238,8 +238,7 @@ NVDACInit(ScrnInfoPtr pScrn, DisplayModePtr mode) nvReg->vpll = nvReadRAMDAC0(pNv, NV_RAMDAC_VPLL); if(pNv->twoStagePLL) nvReg->vpllB = nvReadRAMDAC0(pNv, NV_RAMDAC_VPLL_B); - } else - if(pNv->twoHeads) { + } else if(pNv->twoHeads) { nvReg->head = nvReadCRTC(pNv, 0, NV_CRTC_FSEL) | 0x00001000; nvReg->head2 = nvReadCRTC(pNv, 1, NV_CRTC_FSEL) & ~0x00001000; nvReg->crtcOwner = 0; @@ -312,9 +311,11 @@ NVDACSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, NVRegPtr nvReg, (saveFonts? VGA_SR_FONTS : 0)); NVUnloadStateExt(pNv, nvReg); - /* can't read this reliably on NV11 */ - if((pNv->Chipset & 0x0ff0) == CHIPSET_NV11) - nvReg->crtcOwner = pNv->CRTCnumber; + /* can't read this reliably on NV11 */ + if((pNv->Chipset & 0x0ff0) == CHIPSET_NV11) { + /* 0 if inactive -> crtc0 is active, otherwise 1 */ + nvReg->crtcOwner = pNv->crtc_active[1]; + } } #define DEPTH_SHIFT(val, w) ((val << (8 - w)) | (val >> ((w << 1) - 8))) diff --git a/src/nv_driver.c b/src/nv_driver.c index 433eb8e..204b8d5 100644 --- a/src/nv_driver.c +++ b/src/nv_driver.c @@ -1335,17 +1335,12 @@ NVPreInit(ScrnInfoPtr pScrn, int flags) if (xf86GetOptValBool(pNv->Options, OPTION_FP_DITHER, &(pNv->FPDither))) xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "enabling flat panel dither\n"); - if (xf86GetOptValInteger(pNv->Options, OPTION_CRTC_NUMBER, - &pNv->CRTCnumber)) - { - if((pNv->CRTCnumber < 0) || (pNv->CRTCnumber > 1)) { - pNv->CRTCnumber = -1; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Invalid CRTC number. Must be 0 or 1\n"); - } - } else { - pNv->CRTCnumber = -1; /* autodetect later */ - } + //if (xf86GetOptValInteger(pNv->Options, OPTION_CRTC_NUMBER, + // &pNv->CRTCnumber)) + //{ + //pNv->crtc_active[0] = FALSE; + //pNv->crtc_active[1] = FALSE; + //} if (xf86GetOptValInteger(pNv->Options, OPTION_FP_TWEAK, @@ -1833,7 +1828,7 @@ NVRestore(ScrnInfoPtr pScrn) NVLockUnlock(pNv, 0); if(pNv->twoHeads) { - nvWriteVGA(pNv, NV_VGA_CRTCX_OWNER, pNv->CRTCnumber * 0x3); + nvWriteVGA(pNv, NV_VGA_CRTCX_OWNER, pNv->crtc_active[1] * 0x3); NVLockUnlock(pNv, 0); } @@ -2408,7 +2403,7 @@ NVSave(ScrnInfoPtr pScrn) } else { NVLockUnlock(pNv, 0); if(pNv->twoHeads) { - nvWriteVGA(pNv, NV_VGA_CRTCX_OWNER, pNv->CRTCnumber * 0x3); + nvWriteVGA(pNv, NV_VGA_CRTCX_OWNER, pNv->crtc_active[1] * 0x3); NVLockUnlock(pNv, 0); } diff --git a/src/nv_setup.c b/src/nv_setup.c index a6fbef8..6f17b06 100644 --- a/src/nv_setup.c +++ b/src/nv_setup.c @@ -506,7 +506,8 @@ NVCommonSetup(ScrnInfoPtr pScrn) if(!pNv->twoHeads) { - pNv->CRTCnumber = 0; + pNv->crtc_active[0] = TRUE; + pNv->crtc_active[1] = FALSE; if((monitorA = NVProbeDDC(pScrn, 0))) { FlatPanel = monitorA->features.input_type ? 1 : 0; @@ -536,7 +537,8 @@ NVCommonSetup(ScrnInfoPtr pScrn) } } else { CARD8 outputAfromCRTC, outputBfromCRTC; - int CRTCnumber = -1; + pNv->crtc_active[0] = FALSE; + pNv->crtc_active[1] = FALSE; CARD8 slaved_on_A, slaved_on_B; Bool analog_on_A, analog_on_B; CARD32 oldhead; @@ -588,38 +590,38 @@ NVCommonSetup(ScrnInfoPtr pScrn) monitorB = NVProbeDDC(pScrn, 1); if(slaved_on_A && !tvA) { - CRTCnumber = 0; + pNv->crtc_active[0] = TRUE; FlatPanel = 1; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CRTC 0 is currently programmed for DFP\n"); } else if(slaved_on_B && !tvB) { - CRTCnumber = 1; + pNv->crtc_active[1] = TRUE; FlatPanel = 1; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CRTC 1 is currently programmed for DFP\n"); } else if(analog_on_A) { - CRTCnumber = outputAfromCRTC; + pNv->crtc_active[outputAfromCRTC] = TRUE; FlatPanel = 0; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "CRTC %i appears to have a CRT attached\n", CRTCnumber); + "CRTC %i appears to have a CRT attached\n", pNv->crtc_active[1]); } else if(analog_on_B) { - CRTCnumber = outputBfromCRTC; + pNv->crtc_active[outputBfromCRTC] = TRUE; FlatPanel = 0; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "CRTC %i appears to have a CRT attached\n", CRTCnumber); + "CRTC %i appears to have a CRT attached\n", pNv->crtc_active[1]); } else if(slaved_on_A) { - CRTCnumber = 0; + pNv->crtc_active[0] = TRUE; FlatPanel = 1; Television = 1; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CRTC 0 is currently programmed for TV\n"); } else if(slaved_on_B) { - CRTCnumber = 1; + pNv->crtc_active[1] = TRUE; FlatPanel = 1; Television = 1; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, @@ -655,21 +657,18 @@ NVCommonSetup(ScrnInfoPtr pScrn) pNv->FlatPanel ? "DFP" : "CRT"); } - if(pNv->CRTCnumber == -1) { - if(CRTCnumber != -1) pNv->CRTCnumber = CRTCnumber; - else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Unable to detect which CRTCNumber...\n"); - if(pNv->FlatPanel) pNv->CRTCnumber = 1; - else pNv->CRTCnumber = 0; - xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, - "...Defaulting to CRTCNumber %i\n", pNv->CRTCnumber); + if(!(pNv->crtc_active[0]) && !(pNv->crtc_active[1])) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Unable to detect which CRTC is used...\n"); + if(pNv->FlatPanel) { + pNv->crtc_active[1] = TRUE; + } else { + pNv->crtc_active[0] = TRUE; + } + xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, + "...Defaulting to CRTCNumber %i\n", pNv->crtc_active[1]); } - } else { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Forcing CRTCNumber %i as specified\n", pNv->CRTCnumber); - } - + if(monitorA) { if((monitorA->features.input_type && pNv->FlatPanel) || (!monitorA->features.input_type && !pNv->FlatPanel)) @@ -696,18 +695,18 @@ NVCommonSetup(ScrnInfoPtr pScrn) } if(implementation == CHIPSET_NV11) - cr44 = pNv->CRTCnumber * 0x3; + cr44 = pNv->crtc_active[1] * 0x3; nvWriteCRTC0(pNv, NV_CRTC_FSEL, oldhead); nvWriteVGA(pNv, NV_VGA_CRTCX_OWNER, cr44); - NVSelectHeadRegisters(pScrn, pNv->CRTCnumber); + NVSelectHeadRegisters(pScrn, pNv->crtc_active[1]); } xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using %s on CRTC %i\n", pNv->FlatPanel ? (pNv->Television ? "TV" : "DFP") : "CRT", - pNv->CRTCnumber); + pNv->crtc_active[1]); if(pNv->FlatPanel && !pNv->Television) { pNv->fpWidth = nvReadCurRAMDAC(pNv, NV_RAMDAC_FP_HDISP_END) + 1; diff --git a/src/nv_type.h b/src/nv_type.h index 626f0d4..ec989d3 100644 --- a/src/nv_type.h +++ b/src/nv_type.h @@ -175,13 +175,6 @@ typedef struct { void *map; } NVAllocRec; -typedef struct _NVCrtcPrivateRec { - int crtc; - Bool paletteEnabled; -} NVCrtcPrivateRec, *NVCrtcPrivatePtr; - -#define NVCrtcPrivate(c) ((NVCrtcPrivatePtr)(c)->driver_private) - typedef struct _NVOutputPrivateRec { int ramdac; I2CBusPtr pDDCBus; @@ -295,8 +288,8 @@ typedef struct _NVRec { Bool FPDither; int Mobile; Bool Television; - int CRTCnumber; int vtOWNER; + Bool crtc_active[2]; OptionInfoPtr Options; Bool alphaCursor; unsigned char DDCBase; @@ -349,6 +342,14 @@ typedef struct _NVRec { } i2cMap[4]; } NVRec; +typedef struct _NVCrtcPrivateRec { + int crtc; + Bool paletteEnabled; + NVPtr pNv; +} NVCrtcPrivateRec, *NVCrtcPrivatePtr; + +#define NVCrtcPrivate(c) ((NVCrtcPrivatePtr)(c)->driver_private) + #define NVPTR(p) ((NVPtr)((p)->driverPrivate)) #define nvReadRAMDAC0(pNv, reg) nvReadRAMDAC(pNv, 0, reg) diff --git a/src/nv_video.c b/src/nv_video.c index 05c72a5..7c9bedf 100644 --- a/src/nv_video.c +++ b/src/nv_video.c @@ -181,7 +181,9 @@ NVWaitVSync(ScrnInfoPtr pScrn) NVDmaStart(pNv, NvImageBlit, 0x0000012C, 1); NVDmaNext (pNv, 0); NVDmaStart(pNv, NvImageBlit, 0x00000134, 1); - NVDmaNext (pNv, pNv->CRTCnumber); + /* If crtc1 is active, this will produce one, otherwise zero */ + /* The assumption is that at least one is active */ + NVDmaNext (pNv, pNv->crtc_active[1]); NVDmaStart(pNv, NvImageBlit, 0x00000100, 1); NVDmaNext (pNv, 0); NVDmaStart(pNv, NvImageBlit, 0x00000130, 1); -- 2.32.0.93.g670b81a890