Commit 23e9726e authored by Ville Syrjala's avatar Ville Syrjala Committed by James Toy

Fix a bunch of coding style problems in atyfb_base.c.

Signed-off-by: default avatarVille Syrjala <syrjala@sci.fi>
Cc: "H Hartley Sweeten" <hartleys@visionengravers.com>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent adaf2a01
...@@ -193,8 +193,7 @@ static void ATIReduceRatio(int *Numerator, int *Denominator) ...@@ -193,8 +193,7 @@ static void ATIReduceRatio(int *Numerator, int *Denominator)
Multiplier = *Numerator; Multiplier = *Numerator;
Divider = *Denominator; Divider = *Denominator;
while ((Remainder = Multiplier % Divider)) while ((Remainder = Multiplier % Divider)) {
{
Multiplier = Divider; Multiplier = Divider;
Divider = Remainder; Divider = Remainder;
} }
...@@ -203,7 +202,7 @@ static void ATIReduceRatio(int *Numerator, int *Denominator) ...@@ -203,7 +202,7 @@ static void ATIReduceRatio(int *Numerator, int *Denominator)
*Denominator /= Divider; *Denominator /= Divider;
} }
#endif #endif
/* /*
* The Hardware parameters for each card * The Hardware parameters for each card
*/ */
...@@ -223,17 +222,19 @@ static struct fb_fix_screeninfo atyfb_fix __devinitdata = { ...@@ -223,17 +222,19 @@ static struct fb_fix_screeninfo atyfb_fix __devinitdata = {
.ypanstep = 1, .ypanstep = 1,
}; };
/* /*
* Frame buffer device API * Frame buffer device API
*/ */
static int atyfb_open(struct fb_info *info, int user); static int atyfb_open(struct fb_info *info, int user);
static int atyfb_release(struct fb_info *info, int user); static int atyfb_release(struct fb_info *info, int user);
static int atyfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info); static int atyfb_check_var(struct fb_var_screeninfo *var,
struct fb_info *info);
static int atyfb_set_par(struct fb_info *info); static int atyfb_set_par(struct fb_info *info);
static int atyfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, static int atyfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info); u_int transp, struct fb_info *info);
static int atyfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info); static int atyfb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *info);
static int atyfb_blank(int blank, struct fb_info *info); static int atyfb_blank(int blank, struct fb_info *info);
static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg); static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg);
#ifdef __sparc__ #ifdef __sparc__
...@@ -241,7 +242,7 @@ static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma); ...@@ -241,7 +242,7 @@ static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma);
#endif #endif
static int atyfb_sync(struct fb_info *info); static int atyfb_sync(struct fb_info *info);
/* /*
* Internal routines * Internal routines
*/ */
...@@ -254,8 +255,11 @@ static int store_video_par(char *videopar, unsigned char m64_num); ...@@ -254,8 +255,11 @@ static int store_video_par(char *videopar, unsigned char m64_num);
static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc); static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc);
static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc); static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc);
static int aty_var_to_crtc(const struct fb_info *info, const struct fb_var_screeninfo *var, struct crtc *crtc); static int aty_var_to_crtc(const struct fb_info *info,
static int aty_crtc_to_var(const struct crtc *crtc, struct fb_var_screeninfo *var); const struct fb_var_screeninfo *var,
struct crtc *crtc);
static int aty_crtc_to_var(const struct crtc *crtc,
struct fb_var_screeninfo *var);
static void set_off_pitch(struct atyfb_par *par, const struct fb_info *info); static void set_off_pitch(struct atyfb_par *par, const struct fb_info *info);
#ifdef CONFIG_PPC #ifdef CONFIG_PPC
static int read_aty_sense(const struct atyfb_par *par); static int read_aty_sense(const struct atyfb_par *par);
...@@ -264,7 +268,7 @@ static int read_aty_sense(const struct atyfb_par *par); ...@@ -264,7 +268,7 @@ static int read_aty_sense(const struct atyfb_par *par);
static DEFINE_MUTEX(reboot_lock); static DEFINE_MUTEX(reboot_lock);
static struct fb_info *reboot_info; static struct fb_info *reboot_info;
/* /*
* Interface used by the world * Interface used by the world
*/ */
...@@ -452,14 +456,14 @@ static int __devinit correct_chipset(struct atyfb_par *par) ...@@ -452,14 +456,14 @@ static int __devinit correct_chipset(struct atyfb_par *par)
type = chip_id & CFG_CHIP_TYPE; type = chip_id & CFG_CHIP_TYPE;
rev = (chip_id & CFG_CHIP_REV) >> 24; rev = (chip_id & CFG_CHIP_REV) >> 24;
switch(par->pci_id) { switch (par->pci_id) {
#ifdef CONFIG_FB_ATY_GX #ifdef CONFIG_FB_ATY_GX
case PCI_CHIP_MACH64GX: case PCI_CHIP_MACH64GX:
if(type != 0x00d7) if (type != 0x00d7)
return -ENODEV; return -ENODEV;
break; break;
case PCI_CHIP_MACH64CX: case PCI_CHIP_MACH64CX:
if(type != 0x0057) if (type != 0x0057)
return -ENODEV; return -ENODEV;
break; break;
#endif #endif
...@@ -564,7 +568,8 @@ static char *aty_xl_ram[8] __devinitdata = { ...@@ -564,7 +568,8 @@ static char *aty_xl_ram[8] __devinitdata = {
}; };
#endif /* CONFIG_FB_ATY_CT */ #endif /* CONFIG_FB_ATY_CT */
static u32 atyfb_get_pixclock(struct fb_var_screeninfo *var, struct atyfb_par *par) static u32 atyfb_get_pixclock(struct fb_var_screeninfo *var,
struct atyfb_par *par)
{ {
u32 pixclock = var->pixclock; u32 pixclock = var->pixclock;
#ifdef CONFIG_FB_ATY_GENERIC_LCD #ifdef CONFIG_FB_ATY_GENERIC_LCD
...@@ -572,7 +577,7 @@ static u32 atyfb_get_pixclock(struct fb_var_screeninfo *var, struct atyfb_par *p ...@@ -572,7 +577,7 @@ static u32 atyfb_get_pixclock(struct fb_var_screeninfo *var, struct atyfb_par *p
par->pll.ct.xres = 0; par->pll.ct.xres = 0;
if (par->lcd_table != 0) { if (par->lcd_table != 0) {
lcd_on_off = aty_ld_lcd(LCD_GEN_CNTL, par); lcd_on_off = aty_ld_lcd(LCD_GEN_CNTL, par);
if(lcd_on_off & LCD_ON) { if (lcd_on_off & LCD_ON) {
par->pll.ct.xres = var->xres; par->pll.ct.xres = var->xres;
pixclock = par->lcd_pixclock; pixclock = par->lcd_pixclock;
} }
...@@ -632,7 +637,7 @@ static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc) ...@@ -632,7 +637,7 @@ static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc)
{ {
#ifdef CONFIG_FB_ATY_GENERIC_LCD #ifdef CONFIG_FB_ATY_GENERIC_LCD
if (par->lcd_table != 0) { if (par->lcd_table != 0) {
if(!M64_HAS(LT_LCD_REGS)) { if (!M64_HAS(LT_LCD_REGS)) {
crtc->lcd_index = aty_ld_le32(LCD_INDEX, par); crtc->lcd_index = aty_ld_le32(LCD_INDEX, par);
aty_st_le32(LCD_INDEX, crtc->lcd_index, par); aty_st_le32(LCD_INDEX, crtc->lcd_index, par);
} }
...@@ -680,7 +685,8 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc) ...@@ -680,7 +685,8 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc)
#ifdef CONFIG_FB_ATY_GENERIC_LCD #ifdef CONFIG_FB_ATY_GENERIC_LCD
if (par->lcd_table != 0) { if (par->lcd_table != 0) {
/* stop CRTC */ /* stop CRTC */
aty_st_le32(CRTC_GEN_CNTL, crtc->gen_cntl & ~(CRTC_EXT_DISP_EN | CRTC_EN), par); aty_st_le32(CRTC_GEN_CNTL, crtc->gen_cntl &
~(CRTC_EXT_DISP_EN | CRTC_EN), par);
/* update non-shadow registers first */ /* update non-shadow registers first */
aty_st_lcd(CNFG_PANEL, crtc->lcd_config_panel, par); aty_st_lcd(CNFG_PANEL, crtc->lcd_config_panel, par);
...@@ -688,11 +694,9 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc) ...@@ -688,11 +694,9 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc)
~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN), par); ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN), par);
/* temporarily disable stretching */ /* temporarily disable stretching */
aty_st_lcd(HORZ_STRETCHING, aty_st_lcd(HORZ_STRETCHING, crtc->horz_stretching &
crtc->horz_stretching &
~(HORZ_STRETCH_MODE | HORZ_STRETCH_EN), par); ~(HORZ_STRETCH_MODE | HORZ_STRETCH_EN), par);
aty_st_lcd(VERT_STRETCHING, aty_st_lcd(VERT_STRETCHING, crtc->vert_stretching &
crtc->vert_stretching &
~(VERT_STRETCH_RATIO1 | VERT_STRETCH_RATIO2 | ~(VERT_STRETCH_RATIO1 | VERT_STRETCH_RATIO2 |
VERT_STRETCH_USE0 | VERT_STRETCH_EN), par); VERT_STRETCH_USE0 | VERT_STRETCH_EN), par);
} }
...@@ -702,17 +706,19 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc) ...@@ -702,17 +706,19 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc)
DPRINTK("setting up CRTC\n"); DPRINTK("setting up CRTC\n");
DPRINTK("set primary CRT to %ix%i %c%c composite %c\n", DPRINTK("set primary CRT to %ix%i %c%c composite %c\n",
((((crtc->h_tot_disp>>16) & 0xff) + 1)<<3), (((crtc->v_tot_disp>>16) & 0x7ff) + 1), ((((crtc->h_tot_disp >> 16) & 0xff) + 1) << 3),
(crtc->h_sync_strt_wid & 0x200000)?'N':'P', (crtc->v_sync_strt_wid & 0x200000)?'N':'P', (((crtc->v_tot_disp >> 16) & 0x7ff) + 1),
(crtc->gen_cntl & CRTC_CSYNC_EN)?'P':'N'); (crtc->h_sync_strt_wid & 0x200000) ? 'N' : 'P',
(crtc->v_sync_strt_wid & 0x200000) ? 'N' : 'P',
DPRINTK("CRTC_H_TOTAL_DISP: %x\n",crtc->h_tot_disp); (crtc->gen_cntl & CRTC_CSYNC_EN) ? 'P' : 'N');
DPRINTK("CRTC_H_SYNC_STRT_WID: %x\n",crtc->h_sync_strt_wid);
DPRINTK("CRTC_V_TOTAL_DISP: %x\n",crtc->v_tot_disp); DPRINTK("CRTC_H_TOTAL_DISP: %x\n", crtc->h_tot_disp);
DPRINTK("CRTC_V_SYNC_STRT_WID: %x\n",crtc->v_sync_strt_wid); DPRINTK("CRTC_H_SYNC_STRT_WID: %x\n", crtc->h_sync_strt_wid);
DPRINTK("CRTC_V_TOTAL_DISP: %x\n", crtc->v_tot_disp);
DPRINTK("CRTC_V_SYNC_STRT_WID: %x\n", crtc->v_sync_strt_wid);
DPRINTK("CRTC_OFF_PITCH: %x\n", crtc->off_pitch); DPRINTK("CRTC_OFF_PITCH: %x\n", crtc->off_pitch);
DPRINTK("CRTC_VLINE_CRNT_VLINE: %x\n", crtc->vline_crnt_vline); DPRINTK("CRTC_VLINE_CRNT_VLINE: %x\n", crtc->vline_crnt_vline);
DPRINTK("CRTC_GEN_CNTL: %x\n",crtc->gen_cntl); DPRINTK("CRTC_GEN_CNTL: %x\n", crtc->gen_cntl);
aty_st_le32(CRTC_H_TOTAL_DISP, crtc->h_tot_disp, par); aty_st_le32(CRTC_H_TOTAL_DISP, crtc->h_tot_disp, par);
aty_st_le32(CRTC_H_SYNC_STRT_WID, crtc->h_sync_strt_wid, par); aty_st_le32(CRTC_H_SYNC_STRT_WID, crtc->h_sync_strt_wid, par);
...@@ -732,16 +738,22 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc) ...@@ -732,16 +738,22 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc)
if (par->lcd_table != 0) { if (par->lcd_table != 0) {
/* switch to shadow registers */ /* switch to shadow registers */
aty_st_lcd(LCD_GEN_CNTL, (crtc->lcd_gen_cntl & ~CRTC_RW_SELECT) | aty_st_lcd(LCD_GEN_CNTL, (crtc->lcd_gen_cntl & ~CRTC_RW_SELECT) |
(SHADOW_EN | SHADOW_RW_EN), par); SHADOW_EN | SHADOW_RW_EN, par);
DPRINTK("set shadow CRT to %ix%i %c%c\n", DPRINTK("set shadow CRT to %ix%i %c%c\n",
((((crtc->shadow_h_tot_disp>>16) & 0xff) + 1)<<3), (((crtc->shadow_v_tot_disp>>16) & 0x7ff) + 1), ((((crtc->shadow_h_tot_disp >> 16) & 0xff) + 1) << 3),
(crtc->shadow_h_sync_strt_wid & 0x200000)?'N':'P', (crtc->shadow_v_sync_strt_wid & 0x200000)?'N':'P'); (((crtc->shadow_v_tot_disp >> 16) & 0x7ff) + 1),
(crtc->shadow_h_sync_strt_wid & 0x200000) ? 'N' : 'P',
DPRINTK("SHADOW CRTC_H_TOTAL_DISP: %x\n", crtc->shadow_h_tot_disp); (crtc->shadow_v_sync_strt_wid & 0x200000) ? 'N' : 'P');
DPRINTK("SHADOW CRTC_H_SYNC_STRT_WID: %x\n", crtc->shadow_h_sync_strt_wid);
DPRINTK("SHADOW CRTC_V_TOTAL_DISP: %x\n", crtc->shadow_v_tot_disp); DPRINTK("SHADOW CRTC_H_TOTAL_DISP: %x\n",
DPRINTK("SHADOW CRTC_V_SYNC_STRT_WID: %x\n", crtc->shadow_v_sync_strt_wid); crtc->shadow_h_tot_disp);
DPRINTK("SHADOW CRTC_H_SYNC_STRT_WID: %x\n",
crtc->shadow_h_sync_strt_wid);
DPRINTK("SHADOW CRTC_V_TOTAL_DISP: %x\n",
crtc->shadow_v_tot_disp);
DPRINTK("SHADOW CRTC_V_SYNC_STRT_WID: %x\n",
crtc->shadow_v_sync_strt_wid);
aty_st_le32(CRTC_H_TOTAL_DISP, crtc->shadow_h_tot_disp, par); aty_st_le32(CRTC_H_TOTAL_DISP, crtc->shadow_h_tot_disp, par);
aty_st_le32(CRTC_H_SYNC_STRT_WID, crtc->shadow_h_sync_strt_wid, par); aty_st_le32(CRTC_H_SYNC_STRT_WID, crtc->shadow_h_sync_strt_wid, par);
...@@ -752,13 +764,13 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc) ...@@ -752,13 +764,13 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc)
DPRINTK("LCD_GEN_CNTL: %x\n", crtc->lcd_gen_cntl); DPRINTK("LCD_GEN_CNTL: %x\n", crtc->lcd_gen_cntl);
DPRINTK("HORZ_STRETCHING: %x\n", crtc->horz_stretching); DPRINTK("HORZ_STRETCHING: %x\n", crtc->horz_stretching);
DPRINTK("VERT_STRETCHING: %x\n", crtc->vert_stretching); DPRINTK("VERT_STRETCHING: %x\n", crtc->vert_stretching);
if(!M64_HAS(LT_LCD_REGS)) if (!M64_HAS(LT_LCD_REGS))
DPRINTK("EXT_VERT_STRETCH: %x\n", crtc->ext_vert_stretch); DPRINTK("EXT_VERT_STRETCH: %x\n", crtc->ext_vert_stretch);
aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl, par); aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl, par);
aty_st_lcd(HORZ_STRETCHING, crtc->horz_stretching, par); aty_st_lcd(HORZ_STRETCHING, crtc->horz_stretching, par);
aty_st_lcd(VERT_STRETCHING, crtc->vert_stretching, par); aty_st_lcd(VERT_STRETCHING, crtc->vert_stretching, par);
if(!M64_HAS(LT_LCD_REGS)) { if (!M64_HAS(LT_LCD_REGS)) {
aty_st_lcd(EXT_VERT_STRETCH, crtc->ext_vert_stretch, par); aty_st_lcd(EXT_VERT_STRETCH, crtc->ext_vert_stretch, par);
aty_ld_le32(LCD_INDEX, par); aty_ld_le32(LCD_INDEX, par);
aty_st_le32(LCD_INDEX, crtc->lcd_index, par); aty_st_le32(LCD_INDEX, crtc->lcd_index, par);
...@@ -779,7 +791,8 @@ static u32 calc_line_length(struct atyfb_par *par, u32 vxres, u32 bpp) ...@@ -779,7 +791,8 @@ static u32 calc_line_length(struct atyfb_par *par, u32 vxres, u32 bpp)
} }
static int aty_var_to_crtc(const struct fb_info *info, static int aty_var_to_crtc(const struct fb_info *info,
const struct fb_var_screeninfo *var, struct crtc *crtc) const struct fb_var_screeninfo *var,
struct crtc *crtc)
{ {
struct atyfb_par *par = (struct atyfb_par *) info->par; struct atyfb_par *par = (struct atyfb_par *) info->par;
u32 xres, yres, vxres, vyres, xoffset, yoffset, bpp; u32 xres, yres, vxres, vyres, xoffset, yoffset, bpp;
...@@ -814,8 +827,7 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -814,8 +827,7 @@ static int aty_var_to_crtc(const struct fb_info *info,
if (bpp <= 8) { if (bpp <= 8) {
bpp = 8; bpp = 8;
pix_width = CRTC_PIX_WIDTH_8BPP; pix_width = CRTC_PIX_WIDTH_8BPP;
dp_pix_width = dp_pix_width = HOST_8BPP | SRC_8BPP | DST_8BPP |
HOST_8BPP | SRC_8BPP | DST_8BPP |
BYTE_ORDER_LSB_TO_MSB; BYTE_ORDER_LSB_TO_MSB;
dp_chain_mask = DP_CHAIN_8BPP; dp_chain_mask = DP_CHAIN_8BPP;
} else if (bpp <= 15) { } else if (bpp <= 15) {
...@@ -833,8 +845,7 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -833,8 +845,7 @@ static int aty_var_to_crtc(const struct fb_info *info,
} else if (bpp <= 24 && M64_HAS(INTEGRATED)) { } else if (bpp <= 24 && M64_HAS(INTEGRATED)) {
bpp = 24; bpp = 24;
pix_width = CRTC_PIX_WIDTH_24BPP; pix_width = CRTC_PIX_WIDTH_24BPP;
dp_pix_width = dp_pix_width = HOST_8BPP | SRC_8BPP | DST_8BPP |
HOST_8BPP | SRC_8BPP | DST_8BPP |
BYTE_ORDER_LSB_TO_MSB; BYTE_ORDER_LSB_TO_MSB;
dp_chain_mask = DP_CHAIN_24BPP; dp_chain_mask = DP_CHAIN_24BPP;
} else if (bpp <= 32) { } else if (bpp <= 32) {
...@@ -854,7 +865,7 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -854,7 +865,7 @@ static int aty_var_to_crtc(const struct fb_info *info,
h_sync_pol = sync & FB_SYNC_HOR_HIGH_ACT ? 0 : 1; h_sync_pol = sync & FB_SYNC_HOR_HIGH_ACT ? 0 : 1;
v_sync_pol = sync & FB_SYNC_VERT_HIGH_ACT ? 0 : 1; v_sync_pol = sync & FB_SYNC_VERT_HIGH_ACT ? 0 : 1;
if((xres > 1600) || (yres > 1200)) { if ((xres > 1600) || (yres > 1200)) {
FAIL("MACH64 chips are designed for max 1600x1200\n" FAIL("MACH64 chips are designed for max 1600x1200\n"
"select anoter resolution."); "select anoter resolution.");
} }
...@@ -869,10 +880,11 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -869,10 +880,11 @@ static int aty_var_to_crtc(const struct fb_info *info,
#ifdef CONFIG_FB_ATY_GENERIC_LCD #ifdef CONFIG_FB_ATY_GENERIC_LCD
if (par->lcd_table != 0) { if (par->lcd_table != 0) {
if(!M64_HAS(LT_LCD_REGS)) { if (!M64_HAS(LT_LCD_REGS)) {
u32 lcd_index = aty_ld_le32(LCD_INDEX, par); u32 lcd_index = aty_ld_le32(LCD_INDEX, par);
crtc->lcd_index = lcd_index & crtc->lcd_index = lcd_index &
~(LCD_INDEX_MASK | LCD_DISPLAY_DIS | LCD_SRC_SEL | CRTC2_DISPLAY_DIS); ~(LCD_INDEX_MASK | LCD_DISPLAY_DIS |
LCD_SRC_SEL | CRTC2_DISPLAY_DIS);
aty_st_le32(LCD_INDEX, lcd_index, par); aty_st_le32(LCD_INDEX, lcd_index, par);
} }
...@@ -888,12 +900,14 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -888,12 +900,14 @@ static int aty_var_to_crtc(const struct fb_info *info,
USE_SHADOWED_ROWCUR | SHADOW_EN | SHADOW_RW_EN); USE_SHADOWED_ROWCUR | SHADOW_EN | SHADOW_RW_EN);
crtc->lcd_gen_cntl |= DONT_SHADOW_VPAR | LOCK_8DOT; crtc->lcd_gen_cntl |= DONT_SHADOW_VPAR | LOCK_8DOT;
if((crtc->lcd_gen_cntl & LCD_ON) && if ((crtc->lcd_gen_cntl & LCD_ON) &&
((xres > par->lcd_width) || (yres > par->lcd_height))) { ((xres > par->lcd_width) || (yres > par->lcd_height))) {
/* We cannot display the mode on the LCD. If the CRT is enabled /*
we can turn off the LCD. * We cannot display the mode on the LCD. If the CRT is
If the CRT is off, it isn't a good idea to switch it on; we don't * enabled we can turn off the LCD.
know if one is connected. So it's better to fail then. * If the CRT is off, it isn't a good idea to switch it
* on; we don't know if one is connected. So it's better
* to fail then.
*/ */
if (crtc->lcd_gen_cntl & CRT_ON) { if (crtc->lcd_gen_cntl & CRT_ON) {
if (!(var->activate & FB_ACTIVATE_TEST)) if (!(var->activate & FB_ACTIVATE_TEST))
...@@ -916,17 +930,18 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -916,17 +930,18 @@ static int aty_var_to_crtc(const struct fb_info *info,
vmode &= ~(FB_VMODE_DOUBLE | FB_VMODE_INTERLACED); vmode &= ~(FB_VMODE_DOUBLE | FB_VMODE_INTERLACED);
/* This is horror! When we simulate, say 640x480 on an 800x600 /*
LCD monitor, the CRTC should be programmed 800x600 values for * This is horror! When we simulate, say 640x480 on an 800x600
the non visible part, but 640x480 for the visible part. * LCD monitor, the CRTC should be programmed 800x600 values for
This code has been tested on a laptop with it's 1400x1050 LCD * the non visible part, but 640x480 for the visible part.
monitor and a conventional monitor both switched on. * This code has been tested on a laptop with it's 1400x1050 LCD
Tested modes: 1280x1024, 1152x864, 1024x768, 800x600, * monitor and a conventional monitor both switched on.
works with little glitches also with DOUBLESCAN modes * Tested modes: 1280x1024, 1152x864, 1024x768, 800x600,
* works with little glitches also with DOUBLESCAN modes
*/ */
if (yres < par->lcd_height) { if (yres < par->lcd_height) {
VScan = par->lcd_height / yres; VScan = par->lcd_height / yres;
if(VScan > 1) { if (VScan > 1) {
VScan = 2; VScan = 2;
vmode |= FB_VMODE_DOUBLE; vmode |= FB_VMODE_DOUBLE;
} }
...@@ -952,7 +967,7 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -952,7 +967,7 @@ static int aty_var_to_crtc(const struct fb_info *info,
FAIL_MAX("h_disp too large", h_disp, 0xff); FAIL_MAX("h_disp too large", h_disp, 0xff);
FAIL_MAX("h_sync_strt too large", h_sync_strt, 0x1ff); FAIL_MAX("h_sync_strt too large", h_sync_strt, 0x1ff);
/*FAIL_MAX("h_sync_wid too large", h_sync_wid, 0x1f);*/ /*FAIL_MAX("h_sync_wid too large", h_sync_wid, 0x1f);*/
if(h_sync_wid > 0x1f) if (h_sync_wid > 0x1f)
h_sync_wid = 0x1f; h_sync_wid = 0x1f;
FAIL_MAX("h_total too large", h_total, 0x1ff); FAIL_MAX("h_total too large", h_total, 0x1ff);
...@@ -978,7 +993,7 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -978,7 +993,7 @@ static int aty_var_to_crtc(const struct fb_info *info,
FAIL_MAX("v_disp too large", v_disp, 0x7ff); FAIL_MAX("v_disp too large", v_disp, 0x7ff);
FAIL_MAX("v_sync_stsrt too large", v_sync_strt, 0x7ff); FAIL_MAX("v_sync_stsrt too large", v_sync_strt, 0x7ff);
/*FAIL_MAX("v_sync_wid too large", v_sync_wid, 0x1f);*/ /*FAIL_MAX("v_sync_wid too large", v_sync_wid, 0x1f);*/
if(v_sync_wid > 0x1f) if (v_sync_wid > 0x1f)
v_sync_wid = 0x1f; v_sync_wid = 0x1f;
FAIL_MAX("v_total too large", v_total, 0x7ff); FAIL_MAX("v_total too large", v_total, 0x7ff);
...@@ -995,11 +1010,13 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -995,11 +1010,13 @@ static int aty_var_to_crtc(const struct fb_info *info,
((line_length / bpp) << 22); ((line_length / bpp) << 22);
crtc->vline_crnt_vline = 0; crtc->vline_crnt_vline = 0;
crtc->h_tot_disp = h_total | (h_disp<<16); crtc->h_tot_disp = h_total | (h_disp << 16);
crtc->h_sync_strt_wid = (h_sync_strt & 0xff) | (h_sync_dly<<8) | crtc->h_sync_strt_wid = (h_sync_strt & 0xff) | (h_sync_dly << 8) |
((h_sync_strt & 0x100)<<4) | (h_sync_wid<<16) | (h_sync_pol<<21); ((h_sync_strt & 0x100) << 4) | (h_sync_wid << 16) |
crtc->v_tot_disp = v_total | (v_disp<<16); (h_sync_pol << 21);
crtc->v_sync_strt_wid = v_sync_strt | (v_sync_wid<<16) | (v_sync_pol<<21); crtc->v_tot_disp = v_total | (v_disp << 16);
crtc->v_sync_strt_wid = v_sync_strt | (v_sync_wid << 16) |
(v_sync_pol << 21);
/* crtc->gen_cntl = aty_ld_le32(CRTC_GEN_CNTL, par) & CRTC_PRESERVED_MASK; */ /* crtc->gen_cntl = aty_ld_le32(CRTC_GEN_CNTL, par) & CRTC_PRESERVED_MASK; */
crtc->gen_cntl = CRTC_EXT_DISP_EN | CRTC_EN | pix_width | c_sync; crtc->gen_cntl = CRTC_EXT_DISP_EN | CRTC_EN | pix_width | c_sync;
...@@ -1014,13 +1031,15 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -1014,13 +1031,15 @@ static int aty_var_to_crtc(const struct fb_info *info,
#ifdef CONFIG_FB_ATY_GENERIC_LCD #ifdef CONFIG_FB_ATY_GENERIC_LCD
if (par->lcd_table != 0) { if (par->lcd_table != 0) {
vdisplay = yres; vdisplay = yres;
if(vmode & FB_VMODE_DOUBLE) if (vmode & FB_VMODE_DOUBLE)
vdisplay <<= 1; vdisplay <<= 1;
crtc->gen_cntl &= ~(CRTC2_EN | CRTC2_PIX_WIDTH); crtc->gen_cntl &= ~(CRTC2_EN | CRTC2_PIX_WIDTH);
crtc->lcd_gen_cntl &= ~(HORZ_DIVBY2_EN | DIS_HOR_CRT_DIVBY2 | crtc->lcd_gen_cntl &= ~(HORZ_DIVBY2_EN | DIS_HOR_CRT_DIVBY2 |
/*TVCLK_PM_EN | VCLK_DAC_PM_EN |*/ /*TVCLK_PM_EN | VCLK_DAC_PM_EN |*/
USE_SHADOWED_VEND | USE_SHADOWED_ROWCUR | SHADOW_EN | SHADOW_RW_EN); USE_SHADOWED_VEND |
crtc->lcd_gen_cntl |= (DONT_SHADOW_VPAR/* | LOCK_8DOT*/); USE_SHADOWED_ROWCUR |
SHADOW_EN | SHADOW_RW_EN);
crtc->lcd_gen_cntl |= DONT_SHADOW_VPAR/* | LOCK_8DOT*/;
/* MOBILITY M1 tested, FIXME: LT */ /* MOBILITY M1 tested, FIXME: LT */
crtc->horz_stretching = aty_ld_lcd(HORZ_STRETCHING, par); crtc->horz_stretching = aty_ld_lcd(HORZ_STRETCHING, par);
...@@ -1028,20 +1047,24 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -1028,20 +1047,24 @@ static int aty_var_to_crtc(const struct fb_info *info,
crtc->ext_vert_stretch = aty_ld_lcd(EXT_VERT_STRETCH, par) & crtc->ext_vert_stretch = aty_ld_lcd(EXT_VERT_STRETCH, par) &
~(AUTO_VERT_RATIO | VERT_STRETCH_MODE | VERT_STRETCH_RATIO3); ~(AUTO_VERT_RATIO | VERT_STRETCH_MODE | VERT_STRETCH_RATIO3);
crtc->horz_stretching &= crtc->horz_stretching &= ~(HORZ_STRETCH_RATIO |
~(HORZ_STRETCH_RATIO | HORZ_STRETCH_LOOP | AUTO_HORZ_RATIO | HORZ_STRETCH_LOOP | AUTO_HORZ_RATIO |
HORZ_STRETCH_MODE | HORZ_STRETCH_EN); HORZ_STRETCH_MODE | HORZ_STRETCH_EN);
if (xres < par->lcd_width && crtc->lcd_gen_cntl & LCD_ON) { if (xres < par->lcd_width && crtc->lcd_gen_cntl & LCD_ON) {
do { do {
/* /*
* The horizontal blender misbehaves when HDisplay is less than a * The horizontal blender misbehaves when
* a certain threshold (440 for a 1024-wide panel). It doesn't * HDisplay is less than a certain threshold
* stretch such modes enough. Use pixel replication instead of * (440 for a 1024-wide panel). It doesn't
* blending to stretch modes that can be made to exactly fit the * stretch such modes enough. Use pixel
* panel width. The undocumented "NoLCDBlend" option allows the * replication instead of blending to stretch
* pixel-replicated mode to be slightly wider or narrower than the * modes that can be made to exactly fit the
* panel width. It also causes a mode that is exactly half as wide * panel width. The undocumented "NoLCDBlend"
* as the panel to be pixel-replicated, rather than blended. * option allows the pixel-replicated mode to
* be slightly wider or narrower than the
* panel width. It also causes a mode that is
* exactly half as wide as the panel to be
* pixel-replicated, rather than blended.
*/ */
int HDisplay = xres & ~7; int HDisplay = xres & ~7;
int nStretch = par->lcd_width / HDisplay; int nStretch = par->lcd_width / HDisplay;
...@@ -1049,7 +1072,7 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -1049,7 +1072,7 @@ static int aty_var_to_crtc(const struct fb_info *info,
if ((!Remainder && ((nStretch > 2))) || if ((!Remainder && ((nStretch > 2))) ||
(((HDisplay * 16) / par->lcd_width) < 7)) { (((HDisplay * 16) / par->lcd_width) < 7)) {
static const char StretchLoops[] = {10, 12, 13, 15, 16}; static const char StretchLoops[] = { 10, 12, 13, 15, 16 };
int horz_stretch_loop = -1, BestRemainder; int horz_stretch_loop = -1, BestRemainder;
int Numerator = HDisplay, Denominator = par->lcd_width; int Numerator = HDisplay, Denominator = par->lcd_width;
int Index = 5; int Index = 5;
...@@ -1098,12 +1121,12 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -1098,12 +1121,12 @@ static int aty_var_to_crtc(const struct fb_info *info,
(((vdisplay * (VERT_STRETCH_RATIO0 + 1)) / par->lcd_height) & VERT_STRETCH_RATIO0)); (((vdisplay * (VERT_STRETCH_RATIO0 + 1)) / par->lcd_height) & VERT_STRETCH_RATIO0));
if (!M64_HAS(LT_LCD_REGS) && if (!M64_HAS(LT_LCD_REGS) &&
xres <= (M64_HAS(MOBIL_BUS)?1024:800)) xres <= (M64_HAS(MOBIL_BUS) ? 1024 : 800))
crtc->ext_vert_stretch |= VERT_STRETCH_MODE; crtc->ext_vert_stretch |= VERT_STRETCH_MODE;
} else { } else {
/* /*
* Don't use vertical blending if the mode is too wide or not * Don't use vertical blending if the mode is too wide
* vertically stretched. * or not vertically stretched.
*/ */
crtc->vert_stretching = 0; crtc->vert_stretching = 0;
} }
...@@ -1125,11 +1148,11 @@ static int aty_var_to_crtc(const struct fb_info *info, ...@@ -1125,11 +1148,11 @@ static int aty_var_to_crtc(const struct fb_info *info,
return 0; return 0;
} }
static int aty_crtc_to_var(const struct crtc *crtc, struct fb_var_screeninfo *var) static int aty_crtc_to_var(const struct crtc *crtc,
struct fb_var_screeninfo *var)
{ {
u32 xres, yres, bpp, left, right, upper, lower, hslen, vslen, sync; u32 xres, yres, bpp, left, right, upper, lower, hslen, vslen, sync;
u32 h_total, h_disp, h_sync_strt, h_sync_dly, h_sync_wid, u32 h_total, h_disp, h_sync_strt, h_sync_dly, h_sync_wid, h_sync_pol;
h_sync_pol;
u32 v_total, v_disp, v_sync_strt, v_sync_wid, v_sync_pol, c_sync; u32 v_total, v_disp, v_sync_strt, v_sync_wid, v_sync_pol, c_sync;
u32 pix_width; u32 pix_width;
u32 double_scan, interlace; u32 double_scan, interlace;
...@@ -1252,20 +1275,21 @@ static int aty_crtc_to_var(const struct crtc *crtc, struct fb_var_screeninfo *va ...@@ -1252,20 +1275,21 @@ static int aty_crtc_to_var(const struct crtc *crtc, struct fb_var_screeninfo *va
var->vsync_len = vslen; var->vsync_len = vslen;
var->sync = sync; var->sync = sync;
var->vmode = FB_VMODE_NONINTERLACED; var->vmode = FB_VMODE_NONINTERLACED;
/* In double scan mode, the vertical parameters are doubled, so we need to /*
half them to get the right values. * In double scan mode, the vertical parameters are doubled,
In interlaced mode the values are already correct, so no correction is * so we need to halve them to get the right values.
necessary. * In interlaced mode the values are already correct,
* so no correction is necessary.
*/ */
if (interlace) if (interlace)
var->vmode = FB_VMODE_INTERLACED; var->vmode = FB_VMODE_INTERLACED;
if (double_scan) { if (double_scan) {
var->vmode = FB_VMODE_DOUBLE; var->vmode = FB_VMODE_DOUBLE;
var->yres>>=1; var->yres >>= 1;
var->upper_margin>>=1; var->upper_margin >>= 1;
var->lower_margin>>=1; var->lower_margin >>= 1;
var->vsync_len>>=1; var->vsync_len >>= 1;
} }
return 0; return 0;
...@@ -1286,7 +1310,8 @@ static int atyfb_set_par(struct fb_info *info) ...@@ -1286,7 +1310,8 @@ static int atyfb_set_par(struct fb_info *info)
if (par->asleep) if (par->asleep)
return 0; return 0;
if ((err = aty_var_to_crtc(info, var, &par->crtc))) err = aty_var_to_crtc(info, var, &par->crtc);
if (err)
return err; return err;
pixclock = atyfb_get_pixclock(var, par); pixclock = atyfb_get_pixclock(var, par);
...@@ -1295,7 +1320,9 @@ static int atyfb_set_par(struct fb_info *info) ...@@ -1295,7 +1320,9 @@ static int atyfb_set_par(struct fb_info *info)
PRINTKE("Invalid pixclock\n"); PRINTKE("Invalid pixclock\n");
return -EINVAL; return -EINVAL;
} else { } else {
if((err = par->pll_ops->var_to_pll(info, pixclock, var->bits_per_pixel, &par->pll))) err = par->pll_ops->var_to_pll(info, pixclock,
var->bits_per_pixel, &par->pll);
if (err)
return err; return err;
} }
...@@ -1313,22 +1340,23 @@ static int atyfb_set_par(struct fb_info *info) ...@@ -1313,22 +1340,23 @@ static int atyfb_set_par(struct fb_info *info)
wait_for_idle(par); wait_for_idle(par);
aty_set_crtc(par, &par->crtc); aty_set_crtc(par, &par->crtc);
par->dac_ops->set_dac(info, &par->pll, var->bits_per_pixel, par->accel_flags); par->dac_ops->set_dac(info, &par->pll,
var->bits_per_pixel, par->accel_flags);
par->pll_ops->set_pll(info, &par->pll); par->pll_ops->set_pll(info, &par->pll);
#ifdef DEBUG #ifdef DEBUG
if(par->pll_ops && par->pll_ops->pll_to_var) if (par->pll_ops && par->pll_ops->pll_to_var)
pixclock_in_ps = par->pll_ops->pll_to_var(info, &(par->pll)); pixclock_in_ps = par->pll_ops->pll_to_var(info, &par->pll);
else else
pixclock_in_ps = 0; pixclock_in_ps = 0;
if(0 == pixclock_in_ps) { if (0 == pixclock_in_ps) {
PRINTKE("ALERT ops->pll_to_var get 0\n"); PRINTKE("ALERT ops->pll_to_var get 0\n");
pixclock_in_ps = pixclock; pixclock_in_ps = pixclock;
} }
memset(&debug, 0, sizeof(debug)); memset(&debug, 0, sizeof(debug));
if(!aty_crtc_to_var(&(par->crtc), &debug)) { if (!aty_crtc_to_var(&par->crtc, &debug)) {
u32 hSync, vRefresh; u32 hSync, vRefresh;
u32 h_disp, h_sync_strt, h_sync_end, h_total; u32 h_disp, h_sync_strt, h_sync_end, h_total;
u32 v_disp, v_sync_strt, v_sync_end, v_total; u32 v_disp, v_sync_strt, v_sync_end, v_total;
...@@ -1350,10 +1378,14 @@ static int atyfb_set_par(struct fb_info *info) ...@@ -1350,10 +1378,14 @@ static int atyfb_set_par(struct fb_info *info)
vRefresh /= 2; vRefresh /= 2;
DPRINTK("atyfb_set_par\n"); DPRINTK("atyfb_set_par\n");
DPRINTK(" Set Visible Mode to %ix%i-%i\n", var->xres, var->yres, var->bits_per_pixel); DPRINTK(" Set Visible Mode to %ix%i-%i\n",
DPRINTK(" Virtual resolution %ix%i, pixclock_in_ps %i (calculated %i)\n", var->xres, var->yres, var->bits_per_pixel);
var->xres_virtual, var->yres_virtual, pixclock, pixclock_in_ps); DPRINTK(" Virtual resolution %ix%i, "
DPRINTK(" Dot clock: %i MHz\n", 1000000 / pixclock_in_ps); "pixclock_in_ps %i (calculated %i)\n",
var->xres_virtual, var->yres_virtual,
pixclock, pixclock_in_ps);
DPRINTK(" Dot clock: %i MHz\n",
1000000 / pixclock_in_ps);
DPRINTK(" Horizontal sync: %i kHz\n", hSync); DPRINTK(" Horizontal sync: %i kHz\n", hSync);
DPRINTK(" Vertical refresh: %i Hz\n", vRefresh); DPRINTK(" Vertical refresh: %i Hz\n", vRefresh);
DPRINTK(" x style: %i.%03i %i %i %i %i %i %i %i %i\n", DPRINTK(" x style: %i.%03i %i %i %i %i %i %i %i %i\n",
...@@ -1448,7 +1480,8 @@ static int atyfb_set_par(struct fb_info *info) ...@@ -1448,7 +1480,8 @@ static int atyfb_set_par(struct fb_info *info)
base = 0x2000; base = 0x2000;
printk("debug atyfb: Mach64 non-shadow register values:"); printk("debug atyfb: Mach64 non-shadow register values:");
for (i = 0; i < 256; i = i+4) { for (i = 0; i < 256; i = i+4) {
if(i%16 == 0) printk("\ndebug atyfb: 0x%04X: ", base + i); if (i % 16 == 0)
printk("\ndebug atyfb: 0x%04X: ", base + i);
printk(" %08X", aty_ld_le32(i, par)); printk(" %08X", aty_ld_le32(i, par));
} }
printk("\n\n"); printk("\n\n");
...@@ -1458,8 +1491,10 @@ static int atyfb_set_par(struct fb_info *info) ...@@ -1458,8 +1491,10 @@ static int atyfb_set_par(struct fb_info *info)
base = 0x00; base = 0x00;
printk("debug atyfb: Mach64 PLL register values:"); printk("debug atyfb: Mach64 PLL register values:");
for (i = 0; i < 64; i++) { for (i = 0; i < 64; i++) {
if(i%16 == 0) printk("\ndebug atyfb: 0x%02X: ", base + i); if (i % 16 == 0)
if(i%4 == 0) printk(" "); printk("\ndebug atyfb: 0x%02X: ", base + i);
if (i % 4 == 0)
printk(" ");
printk("%02X", aty_ld_pll_ct(i, par)); printk("%02X", aty_ld_pll_ct(i, par));
} }
printk("\n\n"); printk("\n\n");
...@@ -1470,17 +1505,19 @@ static int atyfb_set_par(struct fb_info *info) ...@@ -1470,17 +1505,19 @@ static int atyfb_set_par(struct fb_info *info)
/* LCD registers */ /* LCD registers */
base = 0x00; base = 0x00;
printk("debug atyfb: LCD register values:"); printk("debug atyfb: LCD register values:");
if(M64_HAS(LT_LCD_REGS)) { if (M64_HAS(LT_LCD_REGS)) {
for(i = 0; i <= POWER_MANAGEMENT; i++) { for (i = 0; i <= POWER_MANAGEMENT; i++) {
if(i == EXT_VERT_STRETCH) if (i == EXT_VERT_STRETCH)
continue; continue;
printk("\ndebug atyfb: 0x%04X: ", lt_lcd_regs[i]); printk("\ndebug atyfb: 0x%04X: ",
lt_lcd_regs[i]);
printk(" %08X", aty_ld_lcd(i, par)); printk(" %08X", aty_ld_lcd(i, par));
} }
} else { } else {
for (i = 0; i < 64; i++) { for (i = 0; i < 64; i++) {
if(i%4 == 0) printk("\ndebug atyfb: 0x%02X: ", base + i); if (i % 4 == 0)
printk("\ndebug atyfb: 0x%02X: ",
base + i);
printk(" %08X", aty_ld_lcd(i, par)); printk(" %08X", aty_ld_lcd(i, par));
} }
} }
...@@ -1500,9 +1537,10 @@ static int atyfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) ...@@ -1500,9 +1537,10 @@ static int atyfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
union aty_pll pll; union aty_pll pll;
u32 pixclock; u32 pixclock;
memcpy(&pll, &(par->pll), sizeof(pll)); memcpy(&pll, &par->pll, sizeof(pll));
if((err = aty_var_to_crtc(info, var, &crtc))) err = aty_var_to_crtc(info, var, &crtc);
if (err)
return err; return err;
pixclock = atyfb_get_pixclock(var, par); pixclock = atyfb_get_pixclock(var, par);
...@@ -1512,7 +1550,9 @@ static int atyfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) ...@@ -1512,7 +1550,9 @@ static int atyfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
PRINTKE("Invalid pixclock\n"); PRINTKE("Invalid pixclock\n");
return -EINVAL; return -EINVAL;
} else { } else {
if((err = par->pll_ops->var_to_pll(info, pixclock, var->bits_per_pixel, &pll))) err = par->pll_ops->var_to_pll(info, pixclock,
var->bits_per_pixel, &pll);
if (err)
return err; return err;
} }
...@@ -1539,7 +1579,7 @@ static void set_off_pitch(struct atyfb_par *par, const struct fb_info *info) ...@@ -1539,7 +1579,7 @@ static void set_off_pitch(struct atyfb_par *par, const struct fb_info *info)
} }
/* /*
* Open/Release the frame buffer device * Open/Release the frame buffer device
*/ */
...@@ -1553,7 +1593,7 @@ static int atyfb_open(struct fb_info *info, int user) ...@@ -1553,7 +1593,7 @@ static int atyfb_open(struct fb_info *info, int user)
par->mmaped = 0; par->mmaped = 0;
#endif #endif
} }
return (0); return 0;
} }
static irqreturn_t aty_irq(int irq, void *dev_id) static irqreturn_t aty_irq(int irq, void *dev_id)
...@@ -1568,7 +1608,8 @@ static irqreturn_t aty_irq(int irq, void *dev_id) ...@@ -1568,7 +1608,8 @@ static irqreturn_t aty_irq(int irq, void *dev_id)
if (int_cntl & CRTC_VBLANK_INT) { if (int_cntl & CRTC_VBLANK_INT) {
/* clear interrupt */ /* clear interrupt */
aty_st_le32(CRTC_INT_CNTL, (int_cntl & CRTC_INT_EN_MASK) | CRTC_VBLANK_INT_AK, par); aty_st_le32(CRTC_INT_CNTL, (int_cntl & CRTC_INT_EN_MASK) |
CRTC_VBLANK_INT_AK, par);
par->vblank.count++; par->vblank.count++;
if (par->vblank.pan_display) { if (par->vblank.pan_display) {
par->vblank.pan_display = 0; par->vblank.pan_display = 0;
...@@ -1603,9 +1644,11 @@ static int aty_enable_irq(struct atyfb_par *par, int reenable) ...@@ -1603,9 +1644,11 @@ static int aty_enable_irq(struct atyfb_par *par, int reenable)
spin_lock_irq(&par->int_lock); spin_lock_irq(&par->int_lock);
int_cntl = aty_ld_le32(CRTC_INT_CNTL, par) & CRTC_INT_EN_MASK; int_cntl = aty_ld_le32(CRTC_INT_CNTL, par) & CRTC_INT_EN_MASK;
if (!(int_cntl & CRTC_VBLANK_INT_EN)) { if (!(int_cntl & CRTC_VBLANK_INT_EN)) {
printk("atyfb: someone disabled IRQ [%08x]\n", int_cntl); printk("atyfb: someone disabled IRQ [%08x]\n",
int_cntl);
/* re-enable interrupt */ /* re-enable interrupt */
aty_st_le32(CRTC_INT_CNTL, int_cntl | CRTC_VBLANK_INT_EN, par ); aty_st_le32(CRTC_INT_CNTL, int_cntl |
CRTC_VBLANK_INT_EN, par);
} }
spin_unlock_irq(&par->int_lock); spin_unlock_irq(&par->int_lock);
} }
...@@ -1625,7 +1668,7 @@ static int aty_disable_irq(struct atyfb_par *par) ...@@ -1625,7 +1668,7 @@ static int aty_disable_irq(struct atyfb_par *par)
spin_lock_irq(&par->int_lock); spin_lock_irq(&par->int_lock);
int_cntl = aty_ld_le32(CRTC_INT_CNTL, par) & CRTC_INT_EN_MASK; int_cntl = aty_ld_le32(CRTC_INT_CNTL, par) & CRTC_INT_EN_MASK;
/* disable interrupt */ /* disable interrupt */
aty_st_le32(CRTC_INT_CNTL, int_cntl & ~CRTC_VBLANK_INT_EN, par ); aty_st_le32(CRTC_INT_CNTL, int_cntl & ~CRTC_VBLANK_INT_EN, par);
spin_unlock_irq(&par->int_lock); spin_unlock_irq(&par->int_lock);
free_irq(par->irq, par); free_irq(par->irq, par);
} }
...@@ -1636,23 +1679,33 @@ static int aty_disable_irq(struct atyfb_par *par) ...@@ -1636,23 +1679,33 @@ static int aty_disable_irq(struct atyfb_par *par)
static int atyfb_release(struct fb_info *info, int user) static int atyfb_release(struct fb_info *info, int user)
{ {
struct atyfb_par *par = (struct atyfb_par *) info->par; struct atyfb_par *par = (struct atyfb_par *) info->par;
if (user) { #ifdef __sparc__
int was_mmaped;
#endif
if (!user)
return 0;
par->open--; par->open--;
mdelay(1); mdelay(1);
wait_for_idle(par); wait_for_idle(par);
if (!par->open) {
if (par->open)
return 0;
#ifdef __sparc__ #ifdef __sparc__
int was_mmaped = par->mmaped; was_mmaped = par->mmaped;
par->mmaped = 0; par->mmaped = 0;
if (was_mmaped) { if (was_mmaped) {
struct fb_var_screeninfo var; struct fb_var_screeninfo var;
/* Now reset the default display config, we have no /*
* idea what the program(s) which mmap'd the chip did * Now reset the default display config, we have
* to the configuration, nor whether it restored it * no idea what the program(s) which mmap'd the
* correctly. * chip did to the configuration, nor whether it
* restored it correctly.
*/ */
var = default_var; var = default_var;
if (noaccel) if (noaccel)
...@@ -1661,25 +1714,27 @@ static int atyfb_release(struct fb_info *info, int user) ...@@ -1661,25 +1714,27 @@ static int atyfb_release(struct fb_info *info, int user)
var.accel_flags |= FB_ACCELF_TEXT; var.accel_flags |= FB_ACCELF_TEXT;
if (var.yres == var.yres_virtual) { if (var.yres == var.yres_virtual) {
u32 videoram = (info->fix.smem_len - (PAGE_SIZE << 2)); u32 videoram = (info->fix.smem_len - (PAGE_SIZE << 2));
var.yres_virtual = ((videoram * 8) / var.bits_per_pixel) / var.xres_virtual; var.yres_virtual =
((videoram * 8) / var.bits_per_pixel) /
var.xres_virtual;
if (var.yres_virtual < var.yres) if (var.yres_virtual < var.yres)
var.yres_virtual = var.yres; var.yres_virtual = var.yres;
} }
} }
#endif #endif
aty_disable_irq(par); aty_disable_irq(par);
}
} return 0;
return (0);
} }
/* /*
* Pan or Wrap the Display * Pan or Wrap the Display
* *
* This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag * This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
*/ */
static int atyfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) static int atyfb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *info)
{ {
struct atyfb_par *par = (struct atyfb_par *) info->par; struct atyfb_par *par = (struct atyfb_par *) info->par;
u32 xres, yres, xoffset, yoffset; u32 xres, yres, xoffset, yoffset;
...@@ -1690,7 +1745,8 @@ static int atyfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info ...@@ -1690,7 +1745,8 @@ static int atyfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info
yres >>= 1; yres >>= 1;
xoffset = (var->xoffset + 7) & ~7; xoffset = (var->xoffset + 7) & ~7;
yoffset = var->yoffset; yoffset = var->yoffset;
if (xoffset + xres > par->crtc.vxres || yoffset + yres > par->crtc.vyres) if (xoffset + xres > par->crtc.vxres ||
yoffset + yres > par->crtc.vyres)
return -EINVAL; return -EINVAL;
info->var.xoffset = xoffset; info->var.xoffset = xoffset;
info->var.yoffset = yoffset; info->var.yoffset = yoffset;
...@@ -1727,10 +1783,10 @@ static int aty_waitforvblank(struct atyfb_par *par, u32 crtc) ...@@ -1727,10 +1783,10 @@ static int aty_waitforvblank(struct atyfb_par *par, u32 crtc)
return ret; return ret;
count = vbl->count; count = vbl->count;
ret = wait_event_interruptible_timeout(vbl->wait, count != vbl->count, HZ/10); ret = wait_event_interruptible_timeout(vbl->wait,
if (ret < 0) { count != vbl->count, HZ/10);
if (ret < 0)
return ret; return ret;
}
if (ret == 0) { if (ret == 0) {
aty_enable_irq(par, 1); aty_enable_irq(par, 1);
return -ETIMEDOUT; return -ETIMEDOUT;
...@@ -1784,7 +1840,8 @@ static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg) ...@@ -1784,7 +1840,8 @@ static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
fbtyp.fb_depth = info->var.bits_per_pixel; fbtyp.fb_depth = info->var.bits_per_pixel;
fbtyp.fb_cmsize = info->cmap.len; fbtyp.fb_cmsize = info->cmap.len;
fbtyp.fb_size = info->fix.smem_len; fbtyp.fb_size = info->fix.smem_len;
if (copy_to_user((struct fbtype __user *) arg, &fbtyp, sizeof(fbtyp))) if (copy_to_user((struct fbtype __user *) arg, &fbtyp,
sizeof(fbtyp)))
return -EFAULT; return -EFAULT;
break; break;
#endif /* __sparc__ */ #endif /* __sparc__ */
...@@ -1804,7 +1861,7 @@ static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg) ...@@ -1804,7 +1861,7 @@ static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
case ATYIO_CLKR: case ATYIO_CLKR:
if (M64_HAS(INTEGRATED)) { if (M64_HAS(INTEGRATED)) {
struct atyclk clk; struct atyclk clk;
union aty_pll *pll = &(par->pll); union aty_pll *pll = &par->pll;
u32 dsp_config = pll->ct.dsp_config; u32 dsp_config = pll->ct.dsp_config;
u32 dsp_on_off = pll->ct.dsp_on_off; u32 dsp_on_off = pll->ct.dsp_on_off;
clk.ref_clk_per = par->ref_clk_per; clk.ref_clk_per = par->ref_clk_per;
...@@ -1829,8 +1886,9 @@ static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg) ...@@ -1829,8 +1886,9 @@ static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
case ATYIO_CLKW: case ATYIO_CLKW:
if (M64_HAS(INTEGRATED)) { if (M64_HAS(INTEGRATED)) {
struct atyclk clk; struct atyclk clk;
union aty_pll *pll = &(par->pll); union aty_pll *pll = &par->pll;
if (copy_from_user(&clk, (struct atyclk __user *) arg, sizeof(clk))) if (copy_from_user(&clk, (struct atyclk __user *) arg,
sizeof(clk)))
return -EFAULT; return -EFAULT;
par->ref_clk_per = clk.ref_clk_per; par->ref_clk_per = clk.ref_clk_per;
pll->ct.pll_ref_div = clk.pll_ref_div; pll->ct.pll_ref_div = clk.pll_ref_div;
...@@ -1841,8 +1899,10 @@ static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg) ...@@ -1841,8 +1899,10 @@ static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
pll->ct.vclk_fb_div = clk.vclk_fb_div; pll->ct.vclk_fb_div = clk.vclk_fb_div;
pll->ct.vclk_post_div_real = clk.vclk_post_div; pll->ct.vclk_post_div_real = clk.vclk_post_div;
pll->ct.dsp_config = (clk.dsp_xclks_per_row & 0x3fff) | pll->ct.dsp_config = (clk.dsp_xclks_per_row & 0x3fff) |
((clk.dsp_loop_latency & 0xf)<<16)| ((clk.dsp_precision & 7)<<20); ((clk.dsp_loop_latency & 0xf) << 16) |
pll->ct.dsp_on_off = (clk.dsp_off & 0x7ff) | ((clk.dsp_on & 0x7ff)<<16); ((clk.dsp_precision & 7) << 20);
pll->ct.dsp_on_off = (clk.dsp_off & 0x7ff) |
((clk.dsp_on & 0x7ff) << 16);
/*aty_calc_pll_ct(info, &pll->ct);*/ /*aty_calc_pll_ct(info, &pll->ct);*/
aty_set_pll_ct(info, pll); aty_set_pll_ct(info, pll);
} else } else
...@@ -1913,8 +1973,7 @@ static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -1913,8 +1973,7 @@ static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
continue; continue;
map_size = par->mmap_map[i].size - (offset - start); map_size = par->mmap_map[i].size - (offset - start);
map_offset = map_offset = par->mmap_map[i].poff + (offset - start);
par->mmap_map[i].poff + (offset - start);
break; break;
} }
if (!map_size) { if (!map_size) {
...@@ -1924,8 +1983,7 @@ static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -1924,8 +1983,7 @@ static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
if (page + map_size > size) if (page + map_size > size)
map_size = size - page; map_size = size - page;
pgprot_val(vma->vm_page_prot) &= pgprot_val(vma->vm_page_prot) &= ~(par->mmap_map[i].prot_mask);
~(par->mmap_map[i].prot_mask);
pgprot_val(vma->vm_page_prot) |= par->mmap_map[i].prot_flag; pgprot_val(vma->vm_page_prot) |= par->mmap_map[i].prot_flag;
if (remap_pfn_range(vma, vma->vm_start + page, if (remap_pfn_range(vma, vma->vm_start + page,
...@@ -2029,7 +2087,8 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -2029,7 +2087,8 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
par->asleep = 1; par->asleep = 1;
par->lock_blank = 1; par->lock_blank = 1;
/* Because we may change PCI D state ourselves, we need to /*
* Because we may change PCI D state ourselves, we need to
* first save the config space content so the core can * first save the config space content so the core can
* restore it properly on resume. * restore it properly on resume.
*/ */
...@@ -2080,7 +2139,8 @@ static int atyfb_pci_resume(struct pci_dev *pdev) ...@@ -2080,7 +2139,8 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
acquire_console_sem(); acquire_console_sem();
/* PCI state will have been restored by the core, so /*
* PCI state will have been restored by the core, so
* we should be in D0 now with our config space fully * we should be in D0 now with our config space fully
* restored * restored
*/ */
...@@ -2236,14 +2296,14 @@ static void __devinit aty_calc_mem_refresh(struct atyfb_par *par, int xclk) ...@@ -2236,14 +2296,14 @@ static void __devinit aty_calc_mem_refresh(struct atyfb_par *par, int xclk)
size = ARRAY_SIZE(ragepro_tbl); size = ARRAY_SIZE(ragepro_tbl);
} }
for (i=0; i < size; i++) { for (i = 0; i < size; i++) {
if (xclk < refresh_tbl[i]) if (xclk < refresh_tbl[i])
break; break;
} }
par->mem_refresh_rate = i; par->mem_refresh_rate = i;
} }
/* /*
* Initialisation * Initialisation
*/ */
...@@ -2375,8 +2435,10 @@ static int __devinit aty_init(struct fb_info *info) ...@@ -2375,8 +2435,10 @@ static int __devinit aty_init(struct fb_info *info)
} }
#endif #endif
#ifdef CONFIG_PPC_PMAC #ifdef CONFIG_PPC_PMAC
/* The Apple iBook1 uses non-standard memory frequencies. We detect it /*
* and set the frequency manually. */ * The Apple iBook1 uses non-standard memory frequencies.
* We detect it and set the frequency manually.
*/
if (machine_is_compatible("PowerBook2,1")) { if (machine_is_compatible("PowerBook2,1")) {
par->pll_limits.mclk = 70; par->pll_limits.mclk = 70;
par->pll_limits.xclk = 53; par->pll_limits.xclk = 53;
...@@ -2421,13 +2483,14 @@ static int __devinit aty_init(struct fb_info *info) ...@@ -2421,13 +2483,14 @@ static int __devinit aty_init(struct fb_info *info)
/* save previous video mode */ /* save previous video mode */
aty_get_crtc(par, &par->saved_crtc); aty_get_crtc(par, &par->saved_crtc);
if(par->pll_ops->get_pll) if (par->pll_ops->get_pll)
par->pll_ops->get_pll(info, &par->saved_pll); par->pll_ops->get_pll(info, &par->saved_pll);
par->mem_cntl = aty_ld_le32(MEM_CNTL, par); par->mem_cntl = aty_ld_le32(MEM_CNTL, par);
gtb_memsize = M64_HAS(GTB_DSP); gtb_memsize = M64_HAS(GTB_DSP);
if (gtb_memsize) if (gtb_memsize)
switch (par->mem_cntl & 0xF) { /* 0xF used instead of MEM_SIZE_ALIAS */ /* 0xF used instead of MEM_SIZE_ALIAS */
switch (par->mem_cntl & 0xF) {
case MEM_SIZE_512K: case MEM_SIZE_512K:
info->fix.smem_len = 0x80000; info->fix.smem_len = 0x80000;
break; break;
...@@ -2516,27 +2579,35 @@ static int __devinit aty_init(struct fb_info *info) ...@@ -2516,27 +2579,35 @@ static int __devinit aty_init(struct fb_info *info)
} }
PRINTKI("%d%c %s, %s MHz XTAL, %d MHz PLL, %d Mhz MCLK, %d MHz XCLK\n", PRINTKI("%d%c %s, %s MHz XTAL, %d MHz PLL, %d Mhz MCLK, %d MHz XCLK\n",
info->fix.smem_len == 0x80000 ? 512 : (info->fix.smem_len >> 20), info->fix.smem_len == 0x80000 ? 512 : (info->fix.smem_len>>20),
info->fix.smem_len == 0x80000 ? 'K' : 'M', ramname, xtal, par->pll_limits.pll_max, info->fix.smem_len == 0x80000 ? 'K' : 'M', ramname, xtal,
par->pll_limits.mclk, par->pll_limits.xclk); par->pll_limits.pll_max, par->pll_limits.mclk,
par->pll_limits.xclk);
#if defined(DEBUG) && defined(CONFIG_FB_ATY_CT) #if defined(DEBUG) && defined(CONFIG_FB_ATY_CT)
if (M64_HAS(INTEGRATED)) { if (M64_HAS(INTEGRATED)) {
int i; int i;
printk("debug atyfb: BUS_CNTL DAC_CNTL MEM_CNTL EXT_MEM_CNTL CRTC_GEN_CNTL " printk("debug atyfb: BUS_CNTL DAC_CNTL MEM_CNTL "
"DSP_CONFIG DSP_ON_OFF CLOCK_CNTL\n" "EXT_MEM_CNTL CRTC_GEN_CNTL DSP_CONFIG "
"debug atyfb: %08x %08x %08x %08x %08x %08x %08x %08x\n" "DSP_ON_OFF CLOCK_CNTL\n"
"debug atyfb: %08x %08x %08x "
"%08x %08x %08x "
"%08x %08x\n"
"debug atyfb: PLL", "debug atyfb: PLL",
aty_ld_le32(BUS_CNTL, par), aty_ld_le32(DAC_CNTL, par), aty_ld_le32(BUS_CNTL, par),
aty_ld_le32(MEM_CNTL, par), aty_ld_le32(EXT_MEM_CNTL, par), aty_ld_le32(DAC_CNTL, par),
aty_ld_le32(CRTC_GEN_CNTL, par), aty_ld_le32(DSP_CONFIG, par), aty_ld_le32(MEM_CNTL, par),
aty_ld_le32(DSP_ON_OFF, par), aty_ld_le32(CLOCK_CNTL, par)); aty_ld_le32(EXT_MEM_CNTL, par),
aty_ld_le32(CRTC_GEN_CNTL, par),
aty_ld_le32(DSP_CONFIG, par),
aty_ld_le32(DSP_ON_OFF, par),
aty_ld_le32(CLOCK_CNTL, par));
for (i = 0; i < 40; i++) for (i = 0; i < 40; i++)
printk(" %02x", aty_ld_pll_ct(i, par)); printk(" %02x", aty_ld_pll_ct(i, par));
printk("\n"); printk("\n");
} }
#endif #endif
if(par->pll_ops->init_pll) if (par->pll_ops->init_pll)
par->pll_ops->init_pll(info, &par->pll); par->pll_ops->init_pll(info, &par->pll);
if (par->pll_ops->resume_pll) if (par->pll_ops->resume_pll)
par->pll_ops->resume_pll(info, &par->pll); par->pll_ops->resume_pll(info, &par->pll);
...@@ -2545,9 +2616,9 @@ static int __devinit aty_init(struct fb_info *info) ...@@ -2545,9 +2616,9 @@ static int __devinit aty_init(struct fb_info *info)
* Last page of 8 MB (4 MB on ISA) aperture is MMIO, * Last page of 8 MB (4 MB on ISA) aperture is MMIO,
* unless the auxiliary register aperture is used. * unless the auxiliary register aperture is used.
*/ */
if (!par->aux_start && if (!par->aux_start &&
(info->fix.smem_len == 0x800000 || (par->bus_type == ISA && info->fix.smem_len == 0x400000))) (info->fix.smem_len == 0x800000 ||
(par->bus_type == ISA && info->fix.smem_len == 0x400000)))
info->fix.smem_len -= GUI_RESERVE; info->fix.smem_len -= GUI_RESERVE;
/* /*
...@@ -2556,18 +2627,21 @@ static int __devinit aty_init(struct fb_info *info) ...@@ -2556,18 +2627,21 @@ static int __devinit aty_init(struct fb_info *info)
* the full 8 MB of video RAM on 8 MB boards. * the full 8 MB of video RAM on 8 MB boards.
*/ */
if (par->aux_start) if (par->aux_start)
aty_st_le32(BUS_CNTL, aty_ld_le32(BUS_CNTL, par) | BUS_APER_REG_DIS, par); aty_st_le32(BUS_CNTL, aty_ld_le32(BUS_CNTL, par) |
BUS_APER_REG_DIS, par);
#ifdef CONFIG_MTRR #ifdef CONFIG_MTRR
par->mtrr_aper = -1; par->mtrr_aper = -1;
par->mtrr_reg = -1; par->mtrr_reg = -1;
if (!nomtrr) { if (!nomtrr) {
/* Cover the whole resource. */ /* Cover the whole resource. */
par->mtrr_aper = mtrr_add(par->res_start, par->res_size, MTRR_TYPE_WRCOMB, 1); par->mtrr_aper = mtrr_add(par->res_start, par->res_size,
MTRR_TYPE_WRCOMB, 1);
if (par->mtrr_aper >= 0 && !par->aux_start) { if (par->mtrr_aper >= 0 && !par->aux_start) {
/* Make a hole for mmio. */ /* Make a hole for mmio. */
par->mtrr_reg = mtrr_add(par->res_start + 0x800000 - GUI_RESERVE, par->mtrr_reg = mtrr_add(par->res_start + 0x800000 -
GUI_RESERVE, MTRR_TYPE_UNCACHABLE, 1); GUI_RESERVE, GUI_RESERVE,
MTRR_TYPE_UNCACHABLE, 1);
if (par->mtrr_reg < 0) { if (par->mtrr_reg < 0) {
mtrr_del(par->mtrr_aper, 0, 0); mtrr_del(par->mtrr_aper, 0, 0);
par->mtrr_aper = -1; par->mtrr_aper = -1;
...@@ -2586,14 +2660,17 @@ static int __devinit aty_init(struct fb_info *info) ...@@ -2586,14 +2660,17 @@ static int __devinit aty_init(struct fb_info *info)
#ifdef CONFIG_PMAC_BACKLIGHT #ifdef CONFIG_PMAC_BACKLIGHT
if (M64_HAS(G3_PB_1_1) && machine_is_compatible("PowerBook1,1")) { if (M64_HAS(G3_PB_1_1) && machine_is_compatible("PowerBook1,1")) {
/* these bits let the 101 powerbook wake up from sleep -- paulus */ /*
aty_st_lcd(POWER_MANAGEMENT, aty_ld_lcd(POWER_MANAGEMENT, par) * these bits let the 101 powerbook
| (USE_F32KHZ | TRISTATE_MEM_EN), par); * wake up from sleep -- paulus
*/
aty_st_lcd(POWER_MANAGEMENT, aty_ld_lcd(POWER_MANAGEMENT, par) |
USE_F32KHZ | TRISTATE_MEM_EN, par);
} else } else
#endif #endif
if (M64_HAS(MOBIL_BUS) && backlight) { if (M64_HAS(MOBIL_BUS) && backlight) {
#ifdef CONFIG_FB_ATY_BACKLIGHT #ifdef CONFIG_FB_ATY_BACKLIGHT
aty_bl_init (par); aty_bl_init(par);
#endif #endif
} }
...@@ -2601,8 +2678,8 @@ static int __devinit aty_init(struct fb_info *info) ...@@ -2601,8 +2678,8 @@ static int __devinit aty_init(struct fb_info *info)
#ifdef CONFIG_PPC #ifdef CONFIG_PPC
if (machine_is(powermac)) { if (machine_is(powermac)) {
/* /*
* FIXME: The NVRAM stuff should be put in a Mac-specific file, as it * FIXME: The NVRAM stuff should be put in a Mac-specific file,
* applies to all Mac video cards * as it applies to all Mac video cards
*/ */
if (mode) { if (mode) {
if (mac_find_mode(&var, info, mode, 8)) if (mac_find_mode(&var, info, mode, 8))
...@@ -2615,8 +2692,7 @@ static int __devinit aty_init(struct fb_info *info) ...@@ -2615,8 +2692,7 @@ static int __devinit aty_init(struct fb_info *info)
default_vmode = VMODE_1024_768_60; default_vmode = VMODE_1024_768_60;
else if (machine_is_compatible("iMac")) else if (machine_is_compatible("iMac"))
default_vmode = VMODE_1024_768_75; default_vmode = VMODE_1024_768_75;
else if (machine_is_compatible else if (machine_is_compatible("PowerBook2,1"))
("PowerBook2,1"))
/* iBook with 800x600 LCD */ /* iBook with 800x600 LCD */
default_vmode = VMODE_800_600_60; default_vmode = VMODE_800_600_60;
else else
...@@ -2744,7 +2820,7 @@ static int __devinit store_video_par(char *video_str, unsigned char m64_num) ...@@ -2744,7 +2820,7 @@ static int __devinit store_video_par(char *video_str, unsigned char m64_num)
} }
#endif /* CONFIG_ATARI */ #endif /* CONFIG_ATARI */
/* /*
* Blank the display. * Blank the display.
*/ */
...@@ -2806,7 +2882,7 @@ static void aty_st_pal(u_int regno, u_int red, u_int green, u_int blue, ...@@ -2806,7 +2882,7 @@ static void aty_st_pal(u_int regno, u_int red, u_int green, u_int blue,
aty_st_8(DAC_DATA, blue, par); aty_st_8(DAC_DATA, blue, par);
} }
/* /*
* Set a single color register. The values supplied are already * Set a single color register. The values supplied are already
* rounded down to the hardware's capabilities (according to the * rounded down to the hardware's capabilities (according to the
* entries in the var structure). Return != 0 for invalid regno. * entries in the var structure). Return != 0 for invalid regno.
...@@ -2868,18 +2944,17 @@ static int atyfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, ...@@ -2868,18 +2944,17 @@ static int atyfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
if (depth == 16) { if (depth == 16) {
if (regno < 32) if (regno < 32)
aty_st_pal(regno << 3, red, aty_st_pal(regno << 3, red,
par->palette[regno<<1].green, par->palette[regno << 1].green,
blue, par); blue, par);
red = par->palette[regno>>1].red; red = par->palette[regno >> 1].red;
blue = par->palette[regno>>1].blue; blue = par->palette[regno >> 1].blue;
regno <<= 2; regno <<= 2;
} else if (depth == 15) { } else if (depth == 15) {
regno <<= 3; regno <<= 3;
for(i = 0; i < 8; i++) { for (i = 0; i < 8; i++)
aty_st_pal(regno + i, red, green, blue, par); aty_st_pal(regno + i, red, green, blue, par);
} }
} }
}
aty_st_pal(regno, red, green, blue, par); aty_st_pal(regno, red, green, blue, par);
return 0; return 0;
...@@ -2890,7 +2965,8 @@ static int atyfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, ...@@ -2890,7 +2965,8 @@ static int atyfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
#ifdef __sparc__ #ifdef __sparc__
static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
struct fb_info *info, unsigned long addr) struct fb_info *info,
unsigned long addr)
{ {
struct atyfb_par *par = info->par; struct atyfb_par *par = info->par;
struct device_node *dp; struct device_node *dp;
...@@ -2978,7 +3054,8 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, ...@@ -2978,7 +3054,8 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
j++; j++;
} }
if((ret = correct_chipset(par))) ret = correct_chipset(par);
if (ret)
return ret; return ret;
if (IS_XL(pdev->device)) { if (IS_XL(pdev->device)) {
...@@ -3108,7 +3185,8 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base) ...@@ -3108,7 +3185,8 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base)
u32 driv_inf_tab, sig; u32 driv_inf_tab, sig;
u16 lcd_ofs; u16 lcd_ofs;
/* To support an LCD panel, we should know it's dimensions and /*
* To support an LCD panel, we should know it's dimensions and
* it's desired pixel clock. * it's desired pixel clock.
* There are two ways to do it: * There are two ways to do it:
* - Check the startup video mode and calculate the panel * - Check the startup video mode and calculate the panel
...@@ -3119,18 +3197,17 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base) ...@@ -3119,18 +3197,17 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base)
driv_inf_tab = bios_base + *((u16 *)(bios_base+0x78)); driv_inf_tab = bios_base + *((u16 *)(bios_base+0x78));
/* Check for the driver information table signature. */ /* Check for the driver information table signature. */
sig = (*(u32 *)driv_inf_tab); sig = *(u32 *)driv_inf_tab;
if ((sig == 0x54504c24) || /* Rage LT pro */ if ((sig == 0x54504c24) || /* Rage LT pro */
(sig == 0x544d5224) || /* Rage mobility */ (sig == 0x544d5224) || /* Rage mobility */
(sig == 0x54435824) || /* Rage XC */ (sig == 0x54435824) || /* Rage XC */
(sig == 0x544c5824)) { /* Rage XL */ (sig == 0x544c5824)) { /* Rage XL */
PRINTKI("BIOS contains driver information table.\n"); PRINTKI("BIOS contains driver information table.\n");
lcd_ofs = (*(u16 *)(driv_inf_tab + 10)); lcd_ofs = *(u16 *)(driv_inf_tab + 10);
par->lcd_table = 0; par->lcd_table = 0;
if (lcd_ofs != 0) { if (lcd_ofs != 0)
par->lcd_table = bios_base + lcd_ofs; par->lcd_table = bios_base + lcd_ofs;
} }
}
if (par->lcd_table != 0) { if (par->lcd_table != 0) {
char model[24]; char model[24];
...@@ -3144,14 +3221,16 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base) ...@@ -3144,14 +3221,16 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base)
u16 width, height, panel_type, refresh_rates; u16 width, height, panel_type, refresh_rates;
u16 *lcdmodeptr; u16 *lcdmodeptr;
u32 format; u32 format;
u8 lcd_refresh_rates[16] = {50,56,60,67,70,72,75,76,85,90,100,120,140,150,160,200}; u8 lcd_refresh_rates[16] = { 50, 56, 60, 67, 70, 72, 75, 76, 85,
/* The most important information is the panel size at 90, 100, 120, 140, 150, 160, 200 };
/*
* The most important information is the panel size at
* offset 25 and 27, but there's some other nice information * offset 25 and 27, but there's some other nice information
* which we print to the screen. * which we print to the screen.
*/ */
id = *(u8 *)par->lcd_table; id = *(u8 *)par->lcd_table;
strncpy(model,(char *)par->lcd_table+1,24); strncpy(model, (char *)par->lcd_table+1, 24);
model[23]=0; model[23] = 0;
width = par->lcd_width = *(u16 *)(par->lcd_table+25); width = par->lcd_width = *(u16 *)(par->lcd_table+25);
height = par->lcd_height = *(u16 *)(par->lcd_table+27); height = par->lcd_height = *(u16 *)(par->lcd_table+27);
...@@ -3164,7 +3243,7 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base) ...@@ -3164,7 +3243,7 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base)
txtdual = "dual (split) "; txtdual = "dual (split) ";
else else
txtdual = ""; txtdual = "";
tech = (panel_type>>2) & 63; tech = (panel_type >> 2) & 63;
switch (tech) { switch (tech) {
case 0: case 0:
txtmonitor = "passive matrix"; txtmonitor = "passive matrix";
...@@ -3224,22 +3303,24 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base) ...@@ -3224,22 +3303,24 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base)
} }
} }
PRINTKI("%s%s %s monitor detected: %s\n", PRINTKI("%s%s %s monitor detected: %s\n",
txtdual ,txtcolour, txtmonitor, model); txtdual, txtcolour, txtmonitor, model);
PRINTKI(" id=%d, %dx%d pixels, %s\n", PRINTKI(" id=%d, %dx%d pixels, %s\n",
id, width, height, txtformat); id, width, height, txtformat);
refresh_rates_buf[0] = 0; refresh_rates_buf[0] = 0;
refresh_rates = *(u16 *)(par->lcd_table+62); refresh_rates = *(u16 *)(par->lcd_table+62);
m = 1; m = 1;
f = 0; f = 0;
for (i=0;i<16;i++) { for (i = 0; i < 16; i++) {
if (refresh_rates & m) { if (refresh_rates & m) {
if (f == 0) { if (f == 0) {
sprintf(strbuf, "%d", lcd_refresh_rates[i]); sprintf(strbuf, "%d",
lcd_refresh_rates[i]);
f++; f++;
} else { } else {
sprintf(strbuf, ",%d", lcd_refresh_rates[i]); sprintf(strbuf, ",%d",
lcd_refresh_rates[i]);
} }
strcat(refresh_rates_buf,strbuf); strcat(refresh_rates_buf, strbuf);
} }
m = m << 1; m = m << 1;
} }
...@@ -3247,7 +3328,8 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base) ...@@ -3247,7 +3328,8 @@ static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base)
PRINTKI(" supports refresh rates [%s], default %d Hz\n", PRINTKI(" supports refresh rates [%s], default %d Hz\n",
refresh_rates_buf, lcd_refresh_rates[default_refresh_rate]); refresh_rates_buf, lcd_refresh_rates[default_refresh_rate]);
par->lcd_refreshrate = lcd_refresh_rates[default_refresh_rate]; par->lcd_refreshrate = lcd_refresh_rates[default_refresh_rate];
/* We now need to determine the crtc parameters for the /*
* We now need to determine the crtc parameters for the
* LCD monitor. This is tricky, because they are not stored * LCD monitor. This is tricky, because they are not stored
* individually in the BIOS. Instead, the BIOS contains a * individually in the BIOS. Instead, the BIOS contains a
* table of display modes that work for this monitor. * table of display modes that work for this monitor.
...@@ -3382,7 +3464,9 @@ static int __devinit init_from_bios(struct atyfb_par *par) ...@@ -3382,7 +3464,9 @@ static int __devinit init_from_bios(struct atyfb_par *par)
} }
#endif /* __i386__ */ #endif /* __i386__ */
static int __devinit atyfb_setup_generic(struct pci_dev *pdev, struct fb_info *info, unsigned long addr) static int __devinit atyfb_setup_generic(struct pci_dev *pdev,
struct fb_info *info,
unsigned long addr)
{ {
struct atyfb_par *par = info->par; struct atyfb_par *par = info->par;
u16 tmp; u16 tmp;
...@@ -3429,10 +3513,12 @@ static int __devinit atyfb_setup_generic(struct pci_dev *pdev, struct fb_info *i ...@@ -3429,10 +3513,12 @@ static int __devinit atyfb_setup_generic(struct pci_dev *pdev, struct fb_info *i
goto atyfb_setup_generic_fail; goto atyfb_setup_generic_fail;
} }
if((ret = correct_chipset(par))) ret = correct_chipset(par);
if (ret)
goto atyfb_setup_generic_fail; goto atyfb_setup_generic_fail;
#ifdef __i386__ #ifdef __i386__
if((ret = init_from_bios(par))) ret = init_from_bios(par);
if (ret)
goto atyfb_setup_generic_fail; goto atyfb_setup_generic_fail;
#endif #endif
if (!(aty_ld_le32(CRTC_GEN_CNTL, par) & CRTC_EXT_DISP_EN)) if (!(aty_ld_le32(CRTC_GEN_CNTL, par) & CRTC_EXT_DISP_EN))
...@@ -3457,7 +3543,8 @@ atyfb_setup_generic_fail: ...@@ -3457,7 +3543,8 @@ atyfb_setup_generic_fail:
#endif /* !__sparc__ */ #endif /* !__sparc__ */
static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) static int __devinit atyfb_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{ {
unsigned long addr, res_start, res_size; unsigned long addr, res_start, res_size;
struct fb_info *info; struct fb_info *info;
...@@ -3482,7 +3569,7 @@ static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_devi ...@@ -3482,7 +3569,7 @@ static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_devi
/* Reserve space */ /* Reserve space */
res_start = rp->start; res_start = rp->start;
res_size = rp->end - rp->start + 1; res_size = rp->end - rp->start + 1;
if (!request_mem_region (res_start, res_size, "atyfb")) if (!request_mem_region(res_start, res_size, "atyfb"))
return -EBUSY; return -EBUSY;
/* Allocate framebuffer */ /* Allocate framebuffer */
...@@ -3573,7 +3660,8 @@ static int __init atyfb_atari_probe(void) ...@@ -3573,7 +3660,8 @@ static int __init atyfb_atari_probe(void)
for (m64_num = 0; m64_num < mach64_count; m64_num++) { for (m64_num = 0; m64_num < mach64_count; m64_num++) {
if (!phys_vmembase[m64_num] || !phys_size[m64_num] || if (!phys_vmembase[m64_num] || !phys_size[m64_num] ||
!phys_guiregbase[m64_num]) { !phys_guiregbase[m64_num]) {
PRINTKI("phys_*[%d] parameters not set => returning early. \n", m64_num); PRINTKI("phys_*[%d] parameters not set => "
"returning early. \n", m64_num);
continue; continue;
} }
...@@ -3589,8 +3677,8 @@ static int __init atyfb_atari_probe(void) ...@@ -3589,8 +3677,8 @@ static int __init atyfb_atari_probe(void)
par->irq = (unsigned int) -1; /* something invalid */ par->irq = (unsigned int) -1; /* something invalid */
/* /*
* Map the video memory (physical address given) to somewhere in the * Map the video memory (physical address given)
* kernel address space. * to somewhere in the kernel address space.
*/ */
info->screen_base = ioremap(phys_vmembase[m64_num], phys_size[m64_num]); info->screen_base = ioremap(phys_vmembase[m64_num], phys_size[m64_num]);
info->fix.smem_start = (unsigned long)info->screen_base; /* Fake! */ info->fix.smem_start = (unsigned long)info->screen_base; /* Fake! */
...@@ -3951,8 +4039,7 @@ MODULE_PARM_DESC(mclk, "int: override memory clock"); ...@@ -3951,8 +4039,7 @@ MODULE_PARM_DESC(mclk, "int: override memory clock");
module_param(xclk, int, 0); module_param(xclk, int, 0);
MODULE_PARM_DESC(xclk, "int: override accelerated engine clock"); MODULE_PARM_DESC(xclk, "int: override accelerated engine clock");
module_param(comp_sync, int, 0); module_param(comp_sync, int, 0);
MODULE_PARM_DESC(comp_sync, MODULE_PARM_DESC(comp_sync, "Set composite sync signal to low (0) or high (1)");
"Set composite sync signal to low (0) or high (1)");
module_param(mode, charp, 0); module_param(mode, charp, 0);
MODULE_PARM_DESC(mode, "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" "); MODULE_PARM_DESC(mode, "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" ");
#ifdef CONFIG_MTRR #ifdef CONFIG_MTRR
......
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