Commit f8de92c9 authored by Joshua Abraham's avatar Joshua Abraham Committed by Greg Kroah-Hartman

staging: xgifb: remove macros with hidden variable

This patch removes macros in XGI_main.h that contain a xgifb_info
variable.  These macros hurt readability by hiding said variable
behind a define.  It also uses a temporary variable to keep the
replaced code from getting too long.
Signed-off-by: default avatarJoshua Abraham <j.abraham1776@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9911bac0
...@@ -18,19 +18,6 @@ static const struct pci_device_id xgifb_pci_table[] = { ...@@ -18,19 +18,6 @@ static const struct pci_device_id xgifb_pci_table[] = {
MODULE_DEVICE_TABLE(pci, xgifb_pci_table); MODULE_DEVICE_TABLE(pci, xgifb_pci_table);
/* To be included in fb.h */
#define XGISR (xgifb_info->dev_info.P3c4)
#define XGICR (xgifb_info->dev_info.P3d4)
#define XGIDACA (xgifb_info->dev_info.P3c8)
#define XGIDACD (xgifb_info->dev_info.P3c9)
#define XGIPART1 (xgifb_info->dev_info.Part1Port)
#define XGIPART2 (xgifb_info->dev_info.Part2Port)
#define XGIPART3 (xgifb_info->dev_info.Part3Port)
#define XGIPART4 (xgifb_info->dev_info.Part4Port)
#define XGIPART5 (xgifb_info->dev_info.Part5Port)
#define XGIDAC2A XGIPART5
#define XGIDAC2D (XGIPART5 + 1)
#define IND_XGI_SCRATCH_REG_CR30 0x30 /* CRs */ #define IND_XGI_SCRATCH_REG_CR30 0x30 /* CRs */
#define IND_XGI_SCRATCH_REG_CR31 0x31 #define IND_XGI_SCRATCH_REG_CR31 0x31
#define IND_XGI_SCRATCH_REG_CR32 0x32 #define IND_XGI_SCRATCH_REG_CR32 0x32
......
...@@ -32,18 +32,19 @@ static unsigned int refresh_rate; ...@@ -32,18 +32,19 @@ static unsigned int refresh_rate;
#ifdef DEBUG #ifdef DEBUG
static void dumpVGAReg(struct xgifb_video_info *xgifb_info) static void dumpVGAReg(struct xgifb_video_info *xgifb_info)
{ {
struct vb_device_info *vb = &xgifb_info->dev_info;
u8 i, reg; u8 i, reg;
xgifb_reg_set(XGISR, 0x05, 0x86); xgifb_reg_set(vb->P3c4, 0x05, 0x86);
for (i = 0; i < 0x4f; i++) { for (i = 0; i < 0x4f; i++) {
reg = xgifb_reg_get(XGISR, i); reg = xgifb_reg_get(vb->P3c4, i);
pr_debug("o 3c4 %x\n", i); pr_debug("o 3c4 %x\n", i);
pr_debug("i 3c5 => %x\n", reg); pr_debug("i 3c5 => %x\n", reg);
} }
for (i = 0; i < 0xF0; i++) { for (i = 0; i < 0xF0; i++) {
reg = xgifb_reg_get(XGICR, i); reg = xgifb_reg_get(vb->P3d4, i);
pr_debug("o 3d4 %x\n", i); pr_debug("o 3d4 %x\n", i);
pr_debug("i 3d5 => %x\n", reg); pr_debug("i 3d5 => %x\n", reg);
} }
...@@ -645,9 +646,10 @@ static void XGIfb_bpp_to_var(struct xgifb_video_info *xgifb_info, ...@@ -645,9 +646,10 @@ static void XGIfb_bpp_to_var(struct xgifb_video_info *xgifb_info,
static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info) static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info)
{ {
struct vb_device_info *vb = &xgifb_info->dev_info;
u8 cr30 = 0, cr31 = 0; u8 cr30 = 0, cr31 = 0;
cr31 = xgifb_reg_get(XGICR, 0x31); cr31 = xgifb_reg_get(vb->P3d4, 0x31);
cr31 &= ~0x60; cr31 &= ~0x60;
switch (xgifb_info->display2) { switch (xgifb_info->display2) {
...@@ -684,14 +686,15 @@ static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info) ...@@ -684,14 +686,15 @@ static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info)
cr31 |= (SIS_DRIVER_MODE | SIS_VB_OUTPUT_DISABLE); cr31 |= (SIS_DRIVER_MODE | SIS_VB_OUTPUT_DISABLE);
} }
xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR30, cr30); xgifb_reg_set(vb->P3d4, IND_XGI_SCRATCH_REG_CR30, cr30);
xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR31, cr31); xgifb_reg_set(vb->P3d4, IND_XGI_SCRATCH_REG_CR31, cr31);
xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR33, xgifb_reg_set(vb->P3d4, IND_XGI_SCRATCH_REG_CR33,
(xgifb_info->rate_idx & 0x0F)); (xgifb_info->rate_idx & 0x0F));
} }
static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
{ {
struct vb_device_info *vb = &xgifb_info->dev_info;
u8 reg; u8 reg;
unsigned char doit = 1; unsigned char doit = 1;
...@@ -714,7 +717,7 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) ...@@ -714,7 +717,7 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
/* We can't switch off CRT1 if bridge is in slave mode */ /* We can't switch off CRT1 if bridge is in slave mode */
if (xgifb_info->hasVB != HASVB_NONE) { if (xgifb_info->hasVB != HASVB_NONE) {
reg = xgifb_reg_get(XGIPART1, 0x00); reg = xgifb_reg_get(vb->Part1Port, 0x00);
if ((reg & 0x50) == 0x10) if ((reg & 0x50) == 0x10)
doit = 0; doit = 0;
...@@ -723,18 +726,18 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) ...@@ -723,18 +726,18 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
XGIfb_crt1off = 0; XGIfb_crt1off = 0;
} }
reg = xgifb_reg_get(XGICR, 0x17); reg = xgifb_reg_get(vb->P3d4, 0x17);
if ((XGIfb_crt1off) && (doit)) if ((XGIfb_crt1off) && (doit))
reg &= ~0x80; reg &= ~0x80;
else else
reg |= 0x80; reg |= 0x80;
xgifb_reg_set(XGICR, 0x17, reg); xgifb_reg_set(vb->P3d4, 0x17, reg);
xgifb_reg_and(XGISR, IND_SIS_RAMDAC_CONTROL, ~0x04); xgifb_reg_and(vb->P3c4, IND_SIS_RAMDAC_CONTROL, ~0x04);
if (xgifb_info->display2 == XGIFB_DISP_TV && if (xgifb_info->display2 == XGIFB_DISP_TV &&
xgifb_info->hasVB == HASVB_301) { xgifb_info->hasVB == HASVB_301) {
reg = xgifb_reg_get(XGIPART4, 0x01); reg = xgifb_reg_get(vb->Part4Port, 0x01);
if (reg < 0xB0) { /* Set filter for XGI301 */ if (reg < 0xB0) { /* Set filter for XGI301 */
int filter_tb; int filter_tb;
...@@ -761,60 +764,58 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) ...@@ -761,60 +764,58 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
filter = -1; filter = -1;
break; break;
} }
xgifb_reg_or(XGIPART1, xgifb_reg_or(vb->Part1Port, SIS_CRT2_WENABLE_315, 0x01);
SIS_CRT2_WENABLE_315,
0x01);
if (xgifb_info->TV_type == TVMODE_NTSC) { if (xgifb_info->TV_type == TVMODE_NTSC) {
xgifb_reg_and(XGIPART2, 0x3a, 0x1f); xgifb_reg_and(vb->Part2Port, 0x3a, 0x1f);
if (xgifb_info->TV_plug == TVPLUG_SVIDEO) { if (xgifb_info->TV_plug == TVPLUG_SVIDEO) {
xgifb_reg_and(XGIPART2, 0x30, 0xdf); xgifb_reg_and(vb->Part2Port, 0x30, 0xdf);
} else if (xgifb_info->TV_plug } else if (xgifb_info->TV_plug
== TVPLUG_COMPOSITE) { == TVPLUG_COMPOSITE) {
xgifb_reg_or(XGIPART2, 0x30, 0x20); xgifb_reg_or(vb->Part2Port, 0x30, 0x20);
switch (xgifb_info->video_width) { switch (xgifb_info->video_width) {
case 640: case 640:
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x35, 0x35,
0xEB); 0xEB);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x36, 0x36,
0x04); 0x04);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x37, 0x37,
0x25); 0x25);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x38, 0x38,
0x18); 0x18);
break; break;
case 720: case 720:
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x35, 0x35,
0xEE); 0xEE);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x36, 0x36,
0x0C); 0x0C);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x37, 0x37,
0x22); 0x22);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x38, 0x38,
0x08); 0x08);
break; break;
case 800: case 800:
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x35, 0x35,
0xEB); 0xEB);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x36, 0x36,
0x15); 0x15);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x37, 0x37,
0x25); 0x25);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x38, 0x38,
0xF6); 0xF6);
break; break;
...@@ -822,55 +823,55 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) ...@@ -822,55 +823,55 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
} }
} else if (xgifb_info->TV_type == TVMODE_PAL) { } else if (xgifb_info->TV_type == TVMODE_PAL) {
xgifb_reg_and(XGIPART2, 0x3A, 0x1F); xgifb_reg_and(vb->Part2Port, 0x3A, 0x1F);
if (xgifb_info->TV_plug == TVPLUG_SVIDEO) { if (xgifb_info->TV_plug == TVPLUG_SVIDEO) {
xgifb_reg_and(XGIPART2, 0x30, 0xDF); xgifb_reg_and(vb->Part2Port, 0x30, 0xDF);
} else if (xgifb_info->TV_plug } else if (xgifb_info->TV_plug
== TVPLUG_COMPOSITE) { == TVPLUG_COMPOSITE) {
xgifb_reg_or(XGIPART2, 0x30, 0x20); xgifb_reg_or(vb->Part2Port, 0x30, 0x20);
switch (xgifb_info->video_width) { switch (xgifb_info->video_width) {
case 640: case 640:
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x35, 0x35,
0xF1); 0xF1);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x36, 0x36,
0xF7); 0xF7);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x37, 0x37,
0x1F); 0x1F);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x38, 0x38,
0x32); 0x32);
break; break;
case 720: case 720:
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x35, 0x35,
0xF3); 0xF3);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x36, 0x36,
0x00); 0x00);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x37, 0x37,
0x1D); 0x1D);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x38, 0x38,
0x20); 0x20);
break; break;
case 800: case 800:
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x35, 0x35,
0xFC); 0xFC);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x36, 0x36,
0xFB); 0xFB);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x37, 0x37,
0x14); 0x14);
xgifb_reg_set(XGIPART2, xgifb_reg_set(vb->Part2Port,
0x38, 0x38,
0x2A); 0x2A);
break; break;
...@@ -883,10 +884,10 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) ...@@ -883,10 +884,10 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
pr_debug("FilterTable[%d]-%d: %*ph\n", pr_debug("FilterTable[%d]-%d: %*ph\n",
filter_tb, filter, 4, f); filter_tb, filter, 4, f);
xgifb_reg_set(XGIPART2, 0x35, f[0]); xgifb_reg_set(vb->Part2Port, 0x35, f[0]);
xgifb_reg_set(XGIPART2, 0x36, f[1]); xgifb_reg_set(vb->Part2Port, 0x36, f[1]);
xgifb_reg_set(XGIPART2, 0x37, f[2]); xgifb_reg_set(vb->Part2Port, 0x37, f[2]);
xgifb_reg_set(XGIPART2, 0x38, f[3]); xgifb_reg_set(vb->Part2Port, 0x38, f[3]);
} }
} }
} }
...@@ -896,6 +897,7 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, ...@@ -896,6 +897,7 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
struct fb_info *info) struct fb_info *info)
{ {
struct xgifb_video_info *xgifb_info = info->par; struct xgifb_video_info *xgifb_info = info->par;
struct vb_device_info *vb = &xgifb_info->dev_info;
struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info; struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info;
unsigned int htotal = var->left_margin + var->xres + var->right_margin unsigned int htotal = var->left_margin + var->xres + var->right_margin
+ var->hsync_len; + var->hsync_len;
...@@ -982,11 +984,10 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, ...@@ -982,11 +984,10 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
info->fix.line_length = (info->var.xres_virtual info->fix.line_length = (info->var.xres_virtual
* info->var.bits_per_pixel) >> 6; * info->var.bits_per_pixel) >> 6;
xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD); xgifb_reg_set(vb->P3c4, IND_SIS_PASSWORD, SIS_PASSWORD);
xgifb_reg_set(XGICR, 0x13, (info->fix.line_length & 0x00ff)); xgifb_reg_set(vb->P3d4, 0x13, (info->fix.line_length & 0x00ff));
xgifb_reg_set(XGISR, xgifb_reg_set(vb->P3c4, 0x0E,
0x0E,
(info->fix.line_length & 0xff00) >> 8); (info->fix.line_length & 0xff00) >> 8);
XGIfb_post_setmode(xgifb_info); XGIfb_post_setmode(xgifb_info);
...@@ -1014,16 +1015,16 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, ...@@ -1014,16 +1015,16 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
xgifb_info->XGI310_AccelDepth = 0x00000000; xgifb_info->XGI310_AccelDepth = 0x00000000;
xgifb_info->video_cmap_len = 256; xgifb_info->video_cmap_len = 256;
#if defined(__BIG_ENDIAN) #if defined(__BIG_ENDIAN)
cr_data = xgifb_reg_get(XGICR, 0x4D); cr_data = xgifb_reg_get(vb->P3d4, 0x4D);
xgifb_reg_set(XGICR, 0x4D, (cr_data & 0xE0)); xgifb_reg_set(vb->P3d4, 0x4D, (cr_data & 0xE0));
#endif #endif
break; break;
case 16: case 16:
xgifb_info->DstColor = 0x8000; xgifb_info->DstColor = 0x8000;
xgifb_info->XGI310_AccelDepth = 0x00010000; xgifb_info->XGI310_AccelDepth = 0x00010000;
#if defined(__BIG_ENDIAN) #if defined(__BIG_ENDIAN)
cr_data = xgifb_reg_get(XGICR, 0x4D); cr_data = xgifb_reg_get(vb->P3d4, 0x4D);
xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x0B)); xgifb_reg_set(vb->P3d4, 0x4D, ((cr_data & 0xE0) | 0x0B));
#endif #endif
xgifb_info->video_cmap_len = 16; xgifb_info->video_cmap_len = 16;
break; break;
...@@ -1032,8 +1033,8 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, ...@@ -1032,8 +1033,8 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
xgifb_info->XGI310_AccelDepth = 0x00020000; xgifb_info->XGI310_AccelDepth = 0x00020000;
xgifb_info->video_cmap_len = 16; xgifb_info->video_cmap_len = 16;
#if defined(__BIG_ENDIAN) #if defined(__BIG_ENDIAN)
cr_data = xgifb_reg_get(XGICR, 0x4D); cr_data = xgifb_reg_get(vb->P3d4, 0x4D);
xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x15)); xgifb_reg_set(vb->P3d4, 0x4D, ((cr_data & 0xE0) | 0x15));
#endif #endif
break; break;
default: default:
...@@ -1052,6 +1053,7 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, ...@@ -1052,6 +1053,7 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
static int XGIfb_pan_var(struct fb_var_screeninfo *var, struct fb_info *info) static int XGIfb_pan_var(struct fb_var_screeninfo *var, struct fb_info *info)
{ {
struct xgifb_video_info *xgifb_info = info->par; struct xgifb_video_info *xgifb_info = info->par;
struct vb_device_info *vb = &xgifb_info->dev_info;
unsigned int base; unsigned int base;
base = var->yoffset * info->var.xres_virtual + var->xoffset; base = var->yoffset * info->var.xres_virtual + var->xoffset;
...@@ -1069,22 +1071,20 @@ static int XGIfb_pan_var(struct fb_var_screeninfo *var, struct fb_info *info) ...@@ -1069,22 +1071,20 @@ static int XGIfb_pan_var(struct fb_var_screeninfo *var, struct fb_info *info)
break; break;
} }
xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD); xgifb_reg_set(vb->P3c4, IND_SIS_PASSWORD, SIS_PASSWORD);
xgifb_reg_set(XGICR, 0x0D, base & 0xFF); xgifb_reg_set(vb->P3d4, 0x0D, base & 0xFF);
xgifb_reg_set(XGICR, 0x0C, (base >> 8) & 0xFF); xgifb_reg_set(vb->P3d4, 0x0C, (base >> 8) & 0xFF);
xgifb_reg_set(XGISR, 0x0D, (base >> 16) & 0xFF); xgifb_reg_set(vb->P3c4, 0x0D, (base >> 16) & 0xFF);
xgifb_reg_set(XGISR, 0x37, (base >> 24) & 0x03); xgifb_reg_set(vb->P3c4, 0x37, (base >> 24) & 0x03);
xgifb_reg_and_or(XGISR, 0x37, 0xDF, (base >> 21) & 0x04); xgifb_reg_and_or(vb->P3c4, 0x37, 0xDF, (base >> 21) & 0x04);
if (xgifb_info->display2 != XGIFB_DISP_NONE) { if (xgifb_info->display2 != XGIFB_DISP_NONE) {
xgifb_reg_or(XGIPART1, SIS_CRT2_WENABLE_315, 0x01); xgifb_reg_or(vb->Part1Port, SIS_CRT2_WENABLE_315, 0x01);
xgifb_reg_set(XGIPART1, 0x06, (base & 0xFF)); xgifb_reg_set(vb->Part1Port, 0x06, (base & 0xFF));
xgifb_reg_set(XGIPART1, 0x05, ((base >> 8) & 0xFF)); xgifb_reg_set(vb->Part1Port, 0x05, ((base >> 8) & 0xFF));
xgifb_reg_set(XGIPART1, 0x04, ((base >> 16) & 0xFF)); xgifb_reg_set(vb->Part1Port, 0x04, ((base >> 16) & 0xFF));
xgifb_reg_and_or(XGIPART1, xgifb_reg_and_or(vb->Part1Port, 0x02, 0x7F,
0x02,
0x7F,
((base >> 24) & 0x01) << 7); ((base >> 24) & 0x01) << 7);
} }
return 0; return 0;
...@@ -1111,21 +1111,22 @@ static int XGIfb_setcolreg(unsigned int regno, unsigned int red, ...@@ -1111,21 +1111,22 @@ static int XGIfb_setcolreg(unsigned int regno, unsigned int red,
unsigned int transp, struct fb_info *info) unsigned int transp, struct fb_info *info)
{ {
struct xgifb_video_info *xgifb_info = info->par; struct xgifb_video_info *xgifb_info = info->par;
struct vb_device_info *vb = &xgifb_info->dev_info;
if (regno >= XGIfb_get_cmap_len(&info->var)) if (regno >= XGIfb_get_cmap_len(&info->var))
return 1; return 1;
switch (info->var.bits_per_pixel) { switch (info->var.bits_per_pixel) {
case 8: case 8:
outb(regno, XGIDACA); outb(regno, vb->P3c8);
outb((red >> 10), XGIDACD); outb((red >> 10), vb->P3c9);
outb((green >> 10), XGIDACD); outb((green >> 10), vb->P3c9);
outb((blue >> 10), XGIDACD); outb((blue >> 10), vb->P3c9);
if (xgifb_info->display2 != XGIFB_DISP_NONE) { if (xgifb_info->display2 != XGIFB_DISP_NONE) {
outb(regno, XGIDAC2A); outb(regno, vb->Part5Port);
outb((red >> 8), XGIDAC2D); outb((red >> 8), (vb->Part5Port + 1));
outb((green >> 8), XGIDAC2D); outb((green >> 8), (vb->Part5Port + 1));
outb((blue >> 8), XGIDAC2D); outb((blue >> 8), (vb->Part5Port + 1));
} }
break; break;
case 16: case 16:
...@@ -1345,18 +1346,19 @@ static int XGIfb_pan_display(struct fb_var_screeninfo *var, ...@@ -1345,18 +1346,19 @@ static int XGIfb_pan_display(struct fb_var_screeninfo *var,
static int XGIfb_blank(int blank, struct fb_info *info) static int XGIfb_blank(int blank, struct fb_info *info)
{ {
struct xgifb_video_info *xgifb_info = info->par; struct xgifb_video_info *xgifb_info = info->par;
struct vb_device_info *vb = &xgifb_info->dev_info;
u8 reg; u8 reg;
reg = xgifb_reg_get(XGICR, 0x17); reg = xgifb_reg_get(vb->P3d4, 0x17);
if (blank > 0) if (blank > 0)
reg &= 0x7f; reg &= 0x7f;
else else
reg |= 0x80; reg |= 0x80;
xgifb_reg_set(XGICR, 0x17, reg); xgifb_reg_set(vb->P3d4, 0x17, reg);
xgifb_reg_set(XGISR, 0x00, 0x01); /* Synchronous Reset */ xgifb_reg_set(vb->P3c4, 0x00, 0x01); /* Synchronous Reset */
xgifb_reg_set(XGISR, 0x00, 0x03); /* End Reset */ xgifb_reg_set(vb->P3c4, 0x00, 0x03); /* End Reset */
return 0; return 0;
} }
...@@ -1380,14 +1382,15 @@ static struct fb_ops XGIfb_ops = { ...@@ -1380,14 +1382,15 @@ static struct fb_ops XGIfb_ops = {
static int XGIfb_get_dram_size(struct xgifb_video_info *xgifb_info) static int XGIfb_get_dram_size(struct xgifb_video_info *xgifb_info)
{ {
struct vb_device_info *vb = &xgifb_info->dev_info;
u8 ChannelNum, tmp; u8 ChannelNum, tmp;
u8 reg = 0; u8 reg = 0;
/* xorg driver sets 32MB * 1 channel */ /* xorg driver sets 32MB * 1 channel */
if (xgifb_info->chip == XG27) if (xgifb_info->chip == XG27)
xgifb_reg_set(XGISR, IND_SIS_DRAM_SIZE, 0x51); xgifb_reg_set(vb->P3c4, IND_SIS_DRAM_SIZE, 0x51);
reg = xgifb_reg_get(XGISR, IND_SIS_DRAM_SIZE); reg = xgifb_reg_get(vb->P3c4, IND_SIS_DRAM_SIZE);
if (!reg) if (!reg)
return -1; return -1;
...@@ -1458,12 +1461,13 @@ static int XGIfb_get_dram_size(struct xgifb_video_info *xgifb_info) ...@@ -1458,12 +1461,13 @@ static int XGIfb_get_dram_size(struct xgifb_video_info *xgifb_info)
static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info) static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info)
{ {
struct vb_device_info *vb = &xgifb_info->dev_info;
u8 cr32, temp = 0; u8 cr32, temp = 0;
xgifb_info->TV_plug = 0; xgifb_info->TV_plug = 0;
xgifb_info->TV_type = 0; xgifb_info->TV_type = 0;
cr32 = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR32); cr32 = xgifb_reg_get(vb->P3d4, IND_XGI_SCRATCH_REG_CR32);
if ((cr32 & SIS_CRT1) && !XGIfb_crt1off) { if ((cr32 & SIS_CRT1) && !XGIfb_crt1off) {
XGIfb_crt1off = 0; XGIfb_crt1off = 0;
...@@ -1500,7 +1504,7 @@ static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info) ...@@ -1500,7 +1504,7 @@ static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info)
} }
if (xgifb_info->TV_type == 0) { if (xgifb_info->TV_type == 0) {
temp = xgifb_reg_get(XGICR, 0x38); temp = xgifb_reg_get(vb->P3d4, 0x38);
if (temp & 0x10) if (temp & 0x10)
xgifb_info->TV_type = TVMODE_PAL; xgifb_info->TV_type = TVMODE_PAL;
else else
...@@ -1520,7 +1524,7 @@ static bool XGIfb_has_VB(struct xgifb_video_info *xgifb_info) ...@@ -1520,7 +1524,7 @@ static bool XGIfb_has_VB(struct xgifb_video_info *xgifb_info)
{ {
u8 vb_chipid; u8 vb_chipid;
vb_chipid = xgifb_reg_get(XGIPART4, 0x00); vb_chipid = xgifb_reg_get(xgifb_info->dev_info.Part4Port, 0x00);
switch (vb_chipid) { switch (vb_chipid) {
case 0x01: case 0x01:
xgifb_info->hasVB = HASVB_301; xgifb_info->hasVB = HASVB_301;
...@@ -1540,7 +1544,8 @@ static void XGIfb_get_VB_type(struct xgifb_video_info *xgifb_info) ...@@ -1540,7 +1544,8 @@ static void XGIfb_get_VB_type(struct xgifb_video_info *xgifb_info)
u8 reg; u8 reg;
if (!XGIfb_has_VB(xgifb_info)) { if (!XGIfb_has_VB(xgifb_info)) {
reg = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR37); reg = xgifb_reg_get(xgifb_info->dev_info.P3d4,
IND_XGI_SCRATCH_REG_CR37);
switch ((reg & SIS_EXTERNAL_CHIP_MASK) >> 1) { switch ((reg & SIS_EXTERNAL_CHIP_MASK) >> 1) {
case SIS_EXTERNAL_CHIP_LVDS: case SIS_EXTERNAL_CHIP_LVDS:
xgifb_info->hasVB = HASVB_LVDS; xgifb_info->hasVB = HASVB_LVDS;
...@@ -1618,6 +1623,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1618,6 +1623,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
int ret; int ret;
struct fb_info *fb_info; struct fb_info *fb_info;
struct xgifb_video_info *xgifb_info; struct xgifb_video_info *xgifb_info;
struct vb_device_info *vb;
struct xgi_hw_device_info *hw_info; struct xgi_hw_device_info *hw_info;
unsigned long video_size_max; unsigned long video_size_max;
...@@ -1626,6 +1632,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1626,6 +1632,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
return -ENOMEM; return -ENOMEM;
xgifb_info = fb_info->par; xgifb_info = fb_info->par;
vb = &xgifb_info->dev_info;
hw_info = &xgifb_info->hw_info; hw_info = &xgifb_info->hw_info;
xgifb_info->fb_info = fb_info; xgifb_info->fb_info = fb_info;
xgifb_info->chip_id = pdev->device; xgifb_info->chip_id = pdev->device;
...@@ -1659,10 +1666,11 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1659,10 +1666,11 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
xgifb_info->display2_force = true; xgifb_info->display2_force = true;
} }
XGIRegInit(&xgifb_info->dev_info, xgifb_info->vga_base); XGIRegInit(vb, xgifb_info->vga_base);
xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD); xgifb_reg_set(vb->P3c4,
reg1 = xgifb_reg_get(XGISR, IND_SIS_PASSWORD); IND_SIS_PASSWORD, SIS_PASSWORD);
reg1 = xgifb_reg_get(vb->P3c4, IND_SIS_PASSWORD);
if (reg1 != 0xa1) { /* I/O error */ if (reg1 != 0xa1) { /* I/O error */
dev_err(&pdev->dev, "I/O error\n"); dev_err(&pdev->dev, "I/O error\n");
...@@ -1672,8 +1680,10 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1672,8 +1680,10 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
switch (xgifb_info->chip_id) { switch (xgifb_info->chip_id) {
case PCI_DEVICE_ID_XGI_20: case PCI_DEVICE_ID_XGI_20:
xgifb_reg_or(XGICR, Index_CR_GPIO_Reg3, GPIOG_EN); xgifb_reg_or(vb->P3d4,
CR48 = xgifb_reg_get(XGICR, Index_CR_GPIO_Reg1); Index_CR_GPIO_Reg3, GPIOG_EN);
CR48 = xgifb_reg_get(vb->P3d4,
Index_CR_GPIO_Reg1);
if (CR48 & GPIOG_READ) if (CR48 & GPIOG_READ)
xgifb_info->chip = XG21; xgifb_info->chip = XG21;
else else
...@@ -1704,11 +1714,12 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1704,11 +1714,12 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
/* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */ /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */
xgifb_reg_or(XGISR, xgifb_reg_or(vb->P3c4,
IND_SIS_PCI_ADDRESS_SET, IND_SIS_PCI_ADDRESS_SET,
(SIS_PCI_ADDR_ENABLE | SIS_MEM_MAP_IO_ENABLE)); (SIS_PCI_ADDR_ENABLE | SIS_MEM_MAP_IO_ENABLE));
/* Enable 2D accelerator engine */ /* Enable 2D accelerator engine */
xgifb_reg_or(XGISR, IND_SIS_MODULE_ENABLE, SIS_ENABLE_2D); xgifb_reg_or(vb->P3c4,
IND_SIS_MODULE_ENABLE, SIS_ENABLE_2D);
hw_info->ulVideoMemorySize = xgifb_info->video_size; hw_info->ulVideoMemorySize = xgifb_info->video_size;
...@@ -1761,7 +1772,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1761,7 +1772,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
(xgifb_info->chip == XG27)) { (xgifb_info->chip == XG27)) {
xgifb_info->hasVB = HASVB_NONE; xgifb_info->hasVB = HASVB_NONE;
} else if (xgifb_info->chip == XG21) { } else if (xgifb_info->chip == XG21) {
CR38 = xgifb_reg_get(XGICR, 0x38); CR38 = xgifb_reg_get(vb->P3d4, 0x38);
if ((CR38 & 0xE0) == 0xC0) if ((CR38 & 0xE0) == 0xC0)
xgifb_info->display2 = XGIFB_DISP_LCD; xgifb_info->display2 = XGIFB_DISP_LCD;
else if ((CR38 & 0xE0) == 0x60) else if ((CR38 & 0xE0) == 0x60)
...@@ -1778,7 +1789,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1778,7 +1789,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
switch (xgifb_info->hasVB) { switch (xgifb_info->hasVB) {
case HASVB_301: case HASVB_301:
reg = xgifb_reg_get(XGIPART4, 0x01); reg = xgifb_reg_get(vb->Part4Port, 0x01);
if (reg >= 0xE0) { if (reg >= 0xE0) {
hw_info->ujVBChipID = VB_CHIP_302LV; hw_info->ujVBChipID = VB_CHIP_302LV;
dev_info(&pdev->dev, dev_info(&pdev->dev,
...@@ -1795,7 +1806,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1795,7 +1806,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
break; break;
case HASVB_302: case HASVB_302:
reg = xgifb_reg_get(XGIPART4, 0x01); reg = xgifb_reg_get(vb->Part4Port, 0x01);
if (reg >= 0xE0) { if (reg >= 0xE0) {
hw_info->ujVBChipID = VB_CHIP_302LV; hw_info->ujVBChipID = VB_CHIP_302LV;
dev_info(&pdev->dev, dev_info(&pdev->dev,
...@@ -1807,7 +1818,8 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1807,7 +1818,8 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
"XGI302LV bridge detected (revision 0x%02x)\n", "XGI302LV bridge detected (revision 0x%02x)\n",
reg); reg);
} else if (reg >= 0xB0) { } else if (reg >= 0xB0) {
reg1 = xgifb_reg_get(XGIPART4, 0x23); reg1 = xgifb_reg_get(vb->Part4Port,
0x23);
hw_info->ujVBChipID = VB_CHIP_302B; hw_info->ujVBChipID = VB_CHIP_302B;
...@@ -1845,7 +1857,8 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1845,7 +1857,8 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (xgifb_info->display2 == XGIFB_DISP_LCD) { if (xgifb_info->display2 == XGIFB_DISP_LCD) {
if (!enable_dstn) { if (!enable_dstn) {
reg = xgifb_reg_get(XGICR, IND_XGI_LCD_PANEL); reg = xgifb_reg_get(vb->P3d4,
IND_XGI_LCD_PANEL);
reg &= 0x0f; reg &= 0x0f;
hw_info->ulCRT2LCDType = XGI310paneltype[reg]; hw_info->ulCRT2LCDType = XGI310paneltype[reg];
} }
...@@ -1941,11 +1954,11 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1941,11 +1954,11 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
XGIfb_bpp_to_var(xgifb_info, &fb_info->var); XGIfb_bpp_to_var(xgifb_info, &fb_info->var);
fb_info->var.pixclock = (u32)(1000000000 / XGIfb_mode_rate_to_dclock fb_info->var.pixclock = (u32)(1000000000 / XGIfb_mode_rate_to_dclock
(&xgifb_info->dev_info, hw_info, (vb, hw_info,
XGIbios_mode[xgifb_info->mode_idx].mode_no)); XGIbios_mode[xgifb_info->mode_idx].mode_no));
if (XGIfb_mode_rate_to_ddata(&xgifb_info->dev_info, if (XGIfb_mode_rate_to_ddata(vb, hw_info,
hw_info, XGIbios_mode[xgifb_info->mode_idx].mode_no, XGIbios_mode[xgifb_info->mode_idx].mode_no,
&fb_info->var.left_margin, &fb_info->var.left_margin,
&fb_info->var.right_margin, &fb_info->var.right_margin,
&fb_info->var.upper_margin, &fb_info->var.upper_margin,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment