From 89ce5370731745973be06426ad0bc045823c8143 Mon Sep 17 00:00:00 2001 From: Hans-Juergen Mauser Date: Wed, 9 May 2012 11:36:53 +0200 Subject: Set DuoView flag depending on active outputs The DuoView flag only needs to be set if TV and another output is active. Signed-off-by: Hans-Juergen Mauser [Tormod: patch split out from a big diff] Signed-off-by: Tormod Volden --- src/savage_driver.h | 1 + src/savage_regs.h | 2 ++ src/savage_vbe.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/src/savage_driver.h b/src/savage_driver.h index 9849fdf..355a0f0 100644 --- a/src/savage_driver.h +++ b/src/savage_driver.h @@ -620,6 +620,7 @@ void SavageSetVESAMode( SavagePtr psav, int n, int Refresh ); void SavageSetPanelEnabled( SavagePtr psav, Bool active ); void SavageFreeBIOSModeTable( SavagePtr psav, SavageModeTablePtr* ppTable ); int SavageGetTV( SavagePtr psav ); +int SavageCorrectDuoViewFlag(int iDevInfo, Bool bEnableActivate, Bool bEnableDeactivate); SavageModeTablePtr SavageGetBIOSModeTable( SavagePtr psav, int iDepth ); ModeStatus SavageMatchBiosMode(ScrnInfoPtr pScrn,int width,int height,int refresh, unsigned int *vesaMode,unsigned int *newRefresh); diff --git a/src/savage_regs.h b/src/savage_regs.h index 66cb215..0175fc1 100644 --- a/src/savage_regs.h +++ b/src/savage_regs.h @@ -200,6 +200,8 @@ do { \ #define CRT_ATTACHED 0x10 #define LCD_ATTACHED 0x20 #define TV_ATTACHED 0x40 +/* flag for DuoView, use identical naming to s3switch */ +#define DUO_ON 0x80 /* flag to mask away anything but the active devices (x_ACTIVE) */ #define ACTIVE_DEVICES 0x07 diff --git a/src/savage_vbe.c b/src/savage_vbe.c index 31da072..c2e6000 100644 --- a/src/savage_vbe.c +++ b/src/savage_vbe.c @@ -179,6 +179,9 @@ SavageSetVESAMode( SavagePtr psav, int n, int Refresh ) psav->CrtOnly = (((psav->iDevInfo & ACTIVE_DEVICES) & ((unsigned char) ~CRT_ACTIVE)) == 0); } + /* fully adjust the DuoView flag */ + psav->iDevInfo = SavageCorrectDuoViewFlag(psav->iDevInfo, TRUE, TRUE); + /* Establish the refresh rate for this mode. */ SavageClearVM86Regs( psav->pVbe->pInt10 ); @@ -304,6 +307,57 @@ int SavageGetTV( SavagePtr psav ) return ((psav->pVbe->pInt10->cx) & 0xc); /* TV mode bits are bits 2 and 3 */ } +/* Function to correct the DuoView flag in the case of a single display */ + +int SavageCorrectDuoViewFlag(int iDevInfo, Bool bEnableActivate, + Bool bEnableDeactivate) +{ + /* TODO: limit this function to be used only if no multi view mode is + * active ("real" DuoView) */ + + /* + * This function can be used to correctly set the DuoView flag in case of + * a single X display. It operates directly on an "iDevInfo" bit field, so + * the caller has the choice which one should be checked. + * + * The DuoView flag is only necessary as soon as the TV output is involved. + * Logic derived from the behaviour of the hardware features of HP XE3: + * - if LCD or CRT or both are active and TV is NOT active, DuoView NEVER + * needs to be set + * - if TV is the only active output, DuoView also does NOT need to be set + * - if TV is active together with LCD or CRT or both, DuoView MUST be set + * to allow all outputs to work + * + * The two Bool flags allow the caller to set which operations should be + * done on the bit field. + * To use the full logic mentioned above, set both flags to TRUE. + */ + + Bool bDoEnable = FALSE; + int iNewDevInfo = iDevInfo; + + /* decision logic */ + /* only use iDevInfo here to avoid side effects on the return value */ + if ((iDevInfo & TV_ACTIVE) != 0) { /* TV enabled, check if either CRT or LCD is also on */ + if (((iDevInfo & CRT_ACTIVE) != 0) + || ((iDevInfo & LCD_ACTIVE) != 0)) { + bDoEnable = TRUE; + } + } + + /* action logic */ + if (bDoEnable == TRUE) { + if (bEnableActivate == TRUE) { + iNewDevInfo |= DUO_ON; + } + } else { /* bDoEnable == FALSE */ + if (bEnableDeactivate == TRUE) { + iNewDevInfo &= ~DUO_ON; + } + } + + return iNewDevInfo; +} void SavageFreeBIOSModeTable( SavagePtr psav, SavageModeTablePtr* ppTable ) -- cgit v1.2.3