From 105d8d0d904f045aafe114ebb9304308032e7d1b Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 31 Aug 2011 21:46:00 +0300 Subject: [PATCH] staging: xgifb: refactor XGI_SetXG21LCD() and XGI_SetXG27LCD() The code is almost the same for XG21 and XG27, a single routine can cover both. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 92 +++++++----------------------- 1 file changed, 22 insertions(+), 70 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 910d8d9afc4c..9b2871ee6ab8 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -988,65 +988,10 @@ static void XGI_SetXG27CRTC(unsigned short ModeNo, } } -/* --------------------------------------------------------------------- */ -/* Function : XGI_SetXG21LCD */ -/* Input : */ -/* Output : FCLK duty cycle, FCLK delay compensation */ -/* Description : All values set zero */ -/* --------------------------------------------------------------------- */ -static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, - unsigned short RefreshRateTableIndex, unsigned short ModeNo) -{ - unsigned short Data, Temp, b3CC; - unsigned short XGI_P3cc; - - XGI_P3cc = pVBInfo->P3cc; - - xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); - xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); - xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); - xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); - if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { - xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E); - xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F); - xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46); - xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47); - } - - Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); - - if (Temp & 0x01) { - xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */ - xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); - } - - xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ - - xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); - xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); - - if (ModeNo <= 0x13) { - b3CC = (unsigned char) inb(XGI_P3cc); - if (b3CC & 0x40) - /* Hsync polarity */ - xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); - if (b3CC & 0x80) - /* Vsync polarity */ - xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); - } else { - Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - if (Data & 0x4000) - /* Hsync polarity */ - xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); - if (Data & 0x8000) - /* Vsync polarity */ - xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); - } -} - -static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, - unsigned short RefreshRateTableIndex, - unsigned short ModeNo) +static void xgifb_set_lcd(int chip_id, + struct vb_device_info *pVBInfo, + unsigned short RefreshRateTableIndex, + unsigned short ModeNo) { unsigned short Data, Temp, b3CC; unsigned short XGI_P3cc; @@ -1058,10 +1003,12 @@ static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); - Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); - if ((Temp & 0x03) == 0) { /* dual 12 */ - xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); - xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); + if (chip_id == XG27) { + Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); + if ((Temp & 0x03) == 0) { /* dual 12 */ + xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); + xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); + } } if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { @@ -1071,7 +1018,16 @@ static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47); } - XGI_SetXG27FPBits(pVBInfo); + if (chip_id == XG27) { + XGI_SetXG27FPBits(pVBInfo); + } else { + Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); + if (Temp & 0x01) { + /* 18 bits FP */ + xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); + xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); + } + } xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ @@ -8278,12 +8234,8 @@ static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, XGI_UpdateXG21CRTC(ModeNo, pVBInfo, RefreshRateTableIndex); - if (HwDeviceExtension->jChipType == XG27) - XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex, - ModeNo); - else - XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex, - ModeNo); + xgifb_set_lcd(HwDeviceExtension->jChipType, + pVBInfo, RefreshRateTableIndex, ModeNo); if (pVBInfo->IF_DEF_LVDS == 1) { if (HwDeviceExtension->jChipType == XG27) -- 2.20.1