aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/xgifb/vb_setmode.c
diff options
context:
space:
mode:
authorAaro Koskinen <aaro.koskinen@iki.fi>2011-08-31 21:46:00 +0300
committerGreg Kroah-Hartman <gregkh@suse.de>2011-09-06 11:42:08 -0700
commit105d8d0d904f045aafe114ebb9304308032e7d1b (patch)
tree5cd3a4d08b607ceb71fab01ae37a03a87f5a7b49 /drivers/staging/xgifb/vb_setmode.c
parent160b006ae90c821de3aace654159aa75da6d9c3d (diff)
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 <aaro.koskinen@iki.fi> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/xgifb/vb_setmode.c')
-rw-r--r--drivers/staging/xgifb/vb_setmode.c92
1 files changed, 22 insertions, 70 deletions
diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c
index 910d8d9afc4..9b2871ee6ab 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)