diff -urN linux/drivers/video/aty.h bk/drivers/video/aty.h --- linux/drivers/video/aty.h Tue Jun 27 14:52:43 2000 +++ bk/drivers/video/aty.h Sat Jul 15 04:34:32 2000 @@ -461,6 +461,7 @@ #define VERTEX_2_SECONDARY_T 0x0738 /* Dword offset 1_CE */ #define VERTEX_2_SECONDARY_W 0x073C /* Dword offset 1_CF */ +#define GTC_3D_RESET_DELAY 3 /* 3D engine reset delay in ms */ /* CRTC control values (mostly CRTC_GEN_CNTL) */ @@ -747,7 +748,8 @@ #define GI_CHIP_ID 0x4749 /* RAGE PRO, BGA, PCI33 only */ #define GP_CHIP_ID 0x4750 /* RAGE PRO, PQFP, PCI33, full 3D */ #define GQ_CHIP_ID 0x4751 /* RAGE PRO, PQFP, PCI33, limited 3D */ -#define LN_CHIP_ID 0x4c4d /* RAGE Mobility AGP */ +#define LM_CHIP_ID 0x4c4d /* RAGE Mobility PCI */ +#define LN_CHIP_ID 0x4c4e /* RAGE Mobility AGP */ /* Mach64 major ASIC revisions */ @@ -998,5 +1000,12 @@ #define LCD_LT_GIO 0x07 #define LCD_POWER_MANAGEMENT 0x08 #define LCD_ZVGPIO 0x09 +#define LCD_MISC_CNTL 0x14 + +/* Values in LCD_MISC_CNTL */ +#define BIAS_MOD_LEVEL_MASK 0x0000ff00 +#define BIAS_MOD_LEVEL_SHIFT 8 +#define BLMOD_EN 0x00010000 +#define BIASMOD_EN 0x00020000 #endif /* REGMACH64_H */ diff -urN linux/drivers/video/aty128.h bk/drivers/video/aty128.h --- linux/drivers/video/aty128.h Tue Jun 27 14:52:43 2000 +++ bk/drivers/video/aty128.h Sat Jul 15 04:34:32 2000 @@ -43,6 +43,7 @@ #define OVR_CLR 0x0230 #define OVR_WID_LEFT_RIGHT 0x0234 #define OVR_WID_TOP_BOTTOM 0x0238 +#define LVDS_GEN_CNTL 0x02d0 #define DDA_CONFIG 0x02e0 #define DDA_ON_OFF 0x02e4 #define VGA_DDA_CONFIG 0x02e8 @@ -267,7 +268,8 @@ #define DAC_BLANKING 0x00000004 #define DAC_RANGE_CNTL 0x00000003 #define DAC_RANGE_CNTL 0x00000003 -#define PALETTE_ACCESS_CNTL 0x00000020 +#define DAC_PALETTE_ACCESS_CNTL 0x00000020 +#define DAC_PDWN 0x00008000 /* GEN_RESET_CNTL bit constants */ #define SOFT_RESET_GUI 0x00000001 @@ -339,5 +341,12 @@ #define DP_SRC_RECT 0x00000200 #define DP_SRC_HOST 0x00000300 #define DP_SRC_HOST_BYTEALIGN 0x00000400 + +/* LVDS_GEN_CNTL constants */ +#define LVDS_BL_MOD_LEVEL_MASK 0x0000ff00 +#define LVDS_BL_MOD_LEVEL_SHIFT 8 +#define LVDS_BL_MOD_EN 0x00010000 +#define LVDS_DIGION 0x00040000 +#define LVDS_BLON 0x00080000 #endif /* REG_RAGE128_H */ diff -urN linux/drivers/video/aty128fb.c bk/drivers/video/aty128fb.c --- linux/drivers/video/aty128fb.c Wed Aug 2 15:20:30 2000 +++ bk/drivers/video/aty128fb.c Tue Aug 29 09:48:33 2000 @@ -55,6 +55,15 @@ #endif #endif +#ifdef CONFIG_ADB_PMU +#include +#include +#endif + +#ifdef CONFIG_PMAC_BACKLIGHT +#include +#endif + #ifdef CONFIG_FB_COMPAT_XPMAC #include #endif @@ -211,13 +220,8 @@ #endif #ifdef CONFIG_PPC -#ifdef CONFIG_NVRAM_NOT_DEFINED -static int default_vmode __initdata = VMODE_640_480_60; +static int default_vmode __initdata = VMODE_1024_768_60; static int default_cmode __initdata = CMODE_8; -#else -static int default_vmode __initdata = VMODE_NVRAM; -static int default_cmode __initdata = CMODE_NVRAM; -#endif #endif #ifdef CONFIG_MTRR @@ -419,6 +423,15 @@ fb_rasterimg: aty128fb_rasterimg, }; +#ifdef CONFIG_PMAC_BACKLIGHT +static int aty128_set_backlight_enable(int on, int level, void* data); +static int aty128_set_backlight_level(int level, void* data); + +static struct backlight_controller aty128_backlight_controller = { + aty128_set_backlight_enable, + aty128_set_backlight_level +}; +#endif /* CONFIG_PMAC_BACKLIGHT */ /* * Functions to read from/write to the mmio registers @@ -1712,15 +1725,8 @@ if (!mac_find_mode(&var, &info->fb_info, mode_option, 8)) var = default_var; } else { -#ifdef CONFIG_NVRAM - if (default_vmode == VMODE_NVRAM) - default_vmode = nvram_read_byte(NV_VMODE); - - if (default_cmode == CMODE_NVRAM) - default_cmode = nvram_read_byte(NV_CMODE); -#endif if (default_vmode <= 0 || default_vmode > VMODE_MAX) - default_vmode = VMODE_640_480_60; + default_vmode = VMODE_1024_768_60; if (default_cmode < CMODE_8 || default_cmode > CMODE_32) default_cmode = CMODE_8; @@ -1772,6 +1778,12 @@ if (register_framebuffer(&info->fb_info) < 0) return 0; +#ifdef CONFIG_PMAC_BACKLIGHT + /* Could be extended to Rage128Pro LVDS output too */ + if (info->chip_gen == rage_M3) + register_backlight_controller(&aty128_backlight_controller, info, "ati"); +#endif /* CONFIG_PMAC_BACKLIGHT */ + printk(KERN_INFO "fb%d: %s frame buffer device on %s\n", GET_FB_IDX(info->fb_info.node), aty128fb_name, name); @@ -1916,6 +1928,11 @@ } #endif /* CONFIG_MTRR */ +#ifdef CONFIG_FB_COMPAT_XPMAC + if (!console_fb_info) + console_fb_info = &info->fb_info; +#endif + return 0; err_out: @@ -2136,6 +2153,11 @@ struct fb_info_aty128 *info = (struct fb_info_aty128 *)fb; u8 state = 0; +#ifdef CONFIG_PMAC_BACKLIGHT + if ((_machine == _MACH_Pmac) && blank) + set_backlight_enable(0); +#endif /* CONFIG_PMAC_BACKLIGHT */ + if (blank & VESA_VSYNC_SUSPEND) state |= 2; if (blank & VESA_HSYNC_SUSPEND) @@ -2144,6 +2166,11 @@ state |= 4; aty_st_8(CRTC_EXT_CNTL+1, state); + +#ifdef CONFIG_PMAC_BACKLIGHT + if ((_machine == _MACH_Pmac) && !blank) + set_backlight_enable(1); +#endif /* CONFIG_PMAC_BACKLIGHT */ } @@ -2199,7 +2226,7 @@ int i; if (info->chip_gen == rage_M3) - aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) & ~PALETTE_ACCESS_CNTL); + aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) & ~DAC_PALETTE_ACCESS_CNTL); for (i=16; i<256; i++) { aty_st_8(PALETTE_INDEX, i); @@ -2208,7 +2235,7 @@ } if (info->chip_gen == rage_M3) { - aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) | PALETTE_ACCESS_CNTL); + aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) | DAC_PALETTE_ACCESS_CNTL); for (i=16; i<256; i++) { aty_st_8(PALETTE_INDEX, i); @@ -2221,7 +2248,7 @@ /* initialize palette */ if (info->chip_gen == rage_M3) - aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) & ~PALETTE_ACCESS_CNTL); + aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) & ~DAC_PALETTE_ACCESS_CNTL); if (info->current_par.crtc.bpp == 16) aty_st_8(PALETTE_INDEX, (regno << 3)); @@ -2230,7 +2257,7 @@ col = (red << 16) | (green << 8) | blue; aty_st_le32(PALETTE_DATA, col); if (info->chip_gen == rage_M3) { - aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) | PALETTE_ACCESS_CNTL); + aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) | DAC_PALETTE_ACCESS_CNTL); if (info->current_par.crtc.bpp == 16) aty_st_8(PALETTE_INDEX, (regno << 3)); else @@ -2282,6 +2309,38 @@ } } + +#ifdef CONFIG_PMAC_BACKLIGHT +static int backlight_conv[] = { + 0xff, 0xc0, 0xb5, 0xaa, 0x9f, 0x94, 0x89, 0x7e, + 0x73, 0x68, 0x5d, 0x52, 0x47, 0x3c, 0x31, 0x24 +}; + +static int +aty128_set_backlight_enable(int on, int level, void* data) +{ + struct fb_info_aty128 *info = (struct fb_info_aty128 *)data; + unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL); + + reg |= LVDS_BL_MOD_EN | LVDS_BLON; + if (on && level > BACKLIGHT_OFF) { + reg &= ~LVDS_BL_MOD_LEVEL_MASK; + reg |= (backlight_conv[level] << LVDS_BL_MOD_LEVEL_SHIFT); + } else { + reg &= ~LVDS_BL_MOD_LEVEL_MASK; + reg |= (backlight_conv[0] << LVDS_BL_MOD_LEVEL_SHIFT); + } + aty_st_le32(LVDS_GEN_CNTL, reg); + + return 0; +} + +static int +aty128_set_backlight_level(int level, void* data) +{ + return aty128_set_backlight_enable(1, level, data); +} +#endif /* CONFIG_PMAC_BACKLIGHT */ /* * Accelerated functions diff -urN linux/drivers/video/atyfb.c bk/drivers/video/atyfb.c --- linux/drivers/video/atyfb.c Wed Aug 2 15:20:30 2000 +++ bk/drivers/video/atyfb.c Tue Aug 29 09:48:33 2000 @@ -20,6 +20,8 @@ * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. + * + * Many thanks to Nitya from ATI devrel for support and patience ! */ /****************************************************************************** @@ -73,6 +75,10 @@ #ifdef CONFIG_NVRAM #include #endif +#ifdef CONFIG_PMAC_BACKLIGHT +#include +#endif + #ifdef __sparc__ #include #include @@ -286,6 +292,15 @@ static struct fb_info_aty* first_display = NULL; #endif +#ifdef CONFIG_PMAC_BACKLIGHT +static int aty_set_backlight_enable(int on, int level, void* data); +static int aty_set_backlight_level(int level, void* data); + +static struct backlight_controller aty_backlight_controller = { + aty_set_backlight_enable, + aty_set_backlight_level +}; +#endif /* CONFIG_PMAC_BACKLIGHT */ /* * Frame buffer device API @@ -556,6 +571,8 @@ { 0x4749, 0x4749, "3D RAGE PRO (BGA, PCI)" }, { 0x4750, 0x4750, "3D RAGE PRO (PQFP, PCI)" }, { 0x4751, 0x4751, "3D RAGE PRO (PQFP, PCI, limited 3D)" }, + { 0x4c4d, 0x4c4d, "3D RAGE Mobility (PCI)" }, + { 0x4c4e, 0x4c4e, "3D RAGE Mobility (AGP)" }, }; static const char *aty_gx_ram[8] __initdata = { @@ -567,48 +584,51 @@ }; -static inline u32 aty_ld_le32(unsigned int regindex, +static inline u32 aty_ld_le32(int regindex, const struct fb_info_aty *info) { -#if defined(__powerpc__) - unsigned long temp; - u32 val; + /* Hack for bloc 1, should be cleanly optimized by compiler */ + if (regindex >= 0x400) + regindex -= 0x800; - temp = info->ati_regbase; - asm volatile("lwbrx %0,%1,%2;eieio" : "=r"(val) : "b" (regindex), "r" (temp)); - return val; -#elif defined(__mc68000__) +#if defined(__mc68000__) return le32_to_cpu(*((volatile u32 *)(info->ati_regbase+regindex))); #else return readl (info->ati_regbase + regindex); #endif } -static inline void aty_st_le32(unsigned int regindex, u32 val, +static inline void aty_st_le32(int regindex, u32 val, const struct fb_info_aty *info) { -#if defined(__powerpc__) - unsigned long temp; + /* Hack for bloc 1, should be cleanly optimized by compiler */ + if (regindex >= 0x400) + regindex -= 0x800; - temp = info->ati_regbase; - asm volatile("stwbrx %0,%1,%2;eieio" : : "r" (val), "b" (regindex), "r" (temp) : - "memory"); -#elif defined(__mc68000__) +#if defined(__mc68000__) *((volatile u32 *)(info->ati_regbase+regindex)) = cpu_to_le32(val); #else writel (val, info->ati_regbase + regindex); #endif } -static inline u8 aty_ld_8(unsigned int regindex, +static inline u8 aty_ld_8(int regindex, const struct fb_info_aty *info) { + /* Hack for bloc 1, should be cleanly optimized by compiler */ + if (regindex >= 0x400) + regindex -= 0x800; + return readb (info->ati_regbase + regindex); } -static inline void aty_st_8(unsigned int regindex, u8 val, +static inline void aty_st_8(int regindex, u8 val, const struct fb_info_aty *info) { + /* Hack for bloc 1, should be cleanly optimized by compiler */ + if (regindex >= 0x400) + regindex -= 0x800; + writeb (val, info->ati_regbase + regindex); } @@ -675,6 +695,16 @@ BUS_FIFO_ERR_ACK, info); } +static void reset_GTC_3D_engine(const struct fb_info_aty *info) +{ + aty_st_le32(SCALE_3D_CNTL, 0xc0, info); + mdelay(GTC_3D_RESET_DELAY); + aty_st_le32(SETUP_CNTL, 0x00, info); + mdelay(GTC_3D_RESET_DELAY); + aty_st_le32(SCALE_3D_CNTL, 0x00, info); + mdelay(GTC_3D_RESET_DELAY); +} + static void init_engine(const struct atyfb_par *par, struct fb_info_aty *info) { u32 pitch_value; @@ -688,11 +718,19 @@ pitch_value = pitch_value * 3; } - /* Reset engine, enable, and clear any engine errors */ + /* On GTC (RagePro), we need to reset the 3D engine before */ + if (Gx == LB_CHIP_ID || Gx == LD_CHIP_ID || Gx == LI_CHIP_ID || + Gx == LP_CHIP_ID || Gx == GB_CHIP_ID || Gx == GD_CHIP_ID || + Gx == GI_CHIP_ID || Gx == GP_CHIP_ID || Gx == GQ_CHIP_ID || + Gx == LM_CHIP_ID || Gx == LN_CHIP_ID) + reset_GTC_3D_engine(info); + + /* Reset engine, enable, and clear any engine errors */ reset_engine(info); - /* Ensure that vga page pointers are set to zero - the upper */ - /* page pointers are set to 1 to handle overflows in the */ - /* lower page */ + + /* Ensure that vga page pointers are set to zero - the upper + * page pointers are set to 1 to handle overflows in the + * lower page */ aty_st_le32(MEM_VGA_WP_SEL, 0x00010000, info); aty_st_le32(MEM_VGA_RP_SEL, 0x00010000, info); @@ -2494,6 +2532,9 @@ } else if ((Gx == VT_CHIP_ID) || (Gx == VU_CHIP_ID)) { aty_st_le32(DAC_CNTL, 0x87010184, info); aty_st_le32(BUS_CNTL, 0x680000f9, info); + } else if ((Gx == LN_CHIP_ID) || (Gx == LM_CHIP_ID)) { + aty_st_le32(DAC_CNTL, 0x80010102, info); + aty_st_le32(BUS_CNTL, 0x7b33a040, info); } else { /* GT */ aty_st_le32(DAC_CNTL, 0x86010102, info); @@ -3374,6 +3415,10 @@ /* Rage LT */ pll = 230; mclk = 63; + } else if ((Gx == LN_CHIP_ID) || (Gx == LM_CHIP_ID)) { + /* Rage mobility M1 */ + pll = 230; + mclk = 50; } else { /* other RAGE */ pll = 135; @@ -3544,13 +3589,15 @@ info->fb_info.blank = &atyfbcon_blank; info->fb_info.flags = FBINFO_FLAG_DEFAULT; -#ifdef CONFIG_PPC +#ifdef CONFIG_PMAC_BACKLIGHT if (Gx == LI_CHIP_ID && machine_is_compatible("PowerBook1,1")) { /* these bits let the 101 powerbook wake up from sleep -- paulus */ aty_st_lcd(LCD_POWER_MANAGEMENT, aty_ld_lcd(LCD_POWER_MANAGEMENT, info) | (USE_F32KHZ | TRISTATE_MEM_EN), info); } -#endif /* CONFIG_PPC */ + if ((Gx == LN_CHIP_ID) || (Gx == LM_CHIP_ID)) + register_backlight_controller(&aty_backlight_controller, info, "ati"); +#endif /* CONFIG_PMAC_BACKLIGHT */ #ifdef MODULE var = default_var; @@ -3579,6 +3626,9 @@ default_vmode = VMODE_1024_768_60; else if (machine_is_compatible("iMac")) default_vmode = VMODE_1024_768_75; + else if (machine_is_compatible("PowerBook2,1")) + /* iBook with 800x600 LCD */ + default_vmode = VMODE_800_600_60; else default_vmode = VMODE_640_480_67; sense = read_aty_sense(info); @@ -3912,7 +3962,7 @@ info->ati_regbase_phys = 0x7ff000 + addr; info->ati_regbase = (unsigned long) - ioremap(info->ati_regbase_phys, 0x1000); + ioremap(info->ati_regbase_phys, 0x2000); if(!info->ati_regbase) { kfree(info); @@ -4215,10 +4265,10 @@ struct fb_info_aty *info = (struct fb_info_aty *)fb; u8 gen_cntl; -#ifdef CONFIG_ADB_PMU +#ifdef CONFIG_PMAC_BACKLIGHT if ((_machine == _MACH_Pmac) && blank) - pmu_enable_backlight(0); -#endif + set_backlight_enable(0); +#endif /* CONFIG_PMAC_BACKLIGHT */ gen_cntl = aty_ld_8(CRTC_GEN_CNTL, info); if (blank > 0) @@ -4240,10 +4290,10 @@ gen_cntl &= ~(0x4c); aty_st_8(CRTC_GEN_CNTL, gen_cntl, info); -#ifdef CONFIG_ADB_PMU +#ifdef CONFIG_PMAC_BACKLIGHT if ((_machine == _MACH_Pmac) && !blank) - pmu_enable_backlight(1); -#endif + set_backlight_enable(1); +#endif /* CONFIG_PMAC_BACKLIGHT */ } @@ -4953,6 +5003,40 @@ return result; } #endif /* CONFIG_PMAC_PBOOK */ + +#ifdef CONFIG_PMAC_BACKLIGHT +static int backlight_conv[] = { + 0x00, 0x3f, 0x4c, 0x59, 0x66, 0x73, 0x80, 0x8d, + 0x9a, 0xa7, 0xb4, 0xc1, 0xcf, 0xdc, 0xe9, 0xff +}; + +static int +aty_set_backlight_enable(int on, int level, void* data) +{ + struct fb_info_aty *info = (struct fb_info_aty *)data; + unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, info); + + reg |= (BLMOD_EN | BIASMOD_EN); + if (on && level > BACKLIGHT_OFF) { + reg &= ~BIAS_MOD_LEVEL_MASK; + reg |= (backlight_conv[level] << BIAS_MOD_LEVEL_SHIFT); + } else { + reg &= ~BIAS_MOD_LEVEL_MASK; + reg |= (backlight_conv[0] << BIAS_MOD_LEVEL_SHIFT); + } + aty_st_lcd(LCD_MISC_CNTL, reg, info); + + return 0; +} + +static int +aty_set_backlight_level(int level, void* data) +{ + return aty_set_backlight_enable(1, level, data); +} + +#endif /* CONFIG_PMAC_BACKLIGHT */ + #ifdef MODULE int __init init_module(void) diff -urN linux/drivers/video/chipsfb.c bk/drivers/video/chipsfb.c --- linux/drivers/video/chipsfb.c Thu Aug 10 14:06:59 2000 +++ bk/drivers/video/chipsfb.c Tue Aug 29 09:48:33 2000 @@ -35,6 +35,9 @@ #include #include #include +#ifdef CONFIG_PMAC_BACKLIGHT +#include +#endif #include #include @@ -245,7 +248,9 @@ // used to disable backlight only for blank > 1, but it seems // useful at blank = 1 too (saves battery, extends backlight life) if (blank) { - pmu_enable_backlight(0); +#ifdef CONFIG_PMAC_BACKLIGHT + set_backlight_enable(0); +#endif /* CONFIG_PMAC_BACKLIGHT */ /* get the palette from the chip */ for (i = 0; i < 256; ++i) { out_8(p->io_base + 0x3c7, i); @@ -262,7 +267,9 @@ out_8(p->io_base + 0x3c9, 0); } } else { - pmu_enable_backlight(1); +#ifdef CONFIG_PMAC_BACKLIGHT + set_backlight_enable(1); +#endif /* CONFIG_PMAC_BACKLIGHT */ for (i = 0; i < 256; ++i) { out_8(p->io_base + 0x3c8, i); udelay(1); @@ -673,8 +680,10 @@ /* Clear the entire framebuffer */ memset(p->frame_buffer, 0, 0x100000); +#ifdef CONFIG_PMAC_BACKLIGHT /* turn on the backlight */ - pmu_enable_backlight(1); + set_backlight_enable(1); +#endif /* CONFIG_PMAC_BACKLIGHT */ init_chips(p); } diff -urN linux/drivers/video/controlfb.c bk/drivers/video/controlfb.c --- linux/drivers/video/controlfb.c Thu Aug 10 14:06:59 2000 +++ bk/drivers/video/controlfb.c Tue Aug 22 09:45:16 2000 @@ -466,11 +466,6 @@ } } -#ifdef CONFIG_FB_COMPAT_XPMAC -extern struct vc_mode display_info; -extern struct fb_info *console_fb_info; -#endif /* CONFIG_FB_COMPAT_XPMAC */ - static inline int control_vram_reqd(int video_mode, int color_mode) { return (control_reg_init[video_mode-1]->vres @@ -483,12 +478,14 @@ struct adb_request req; int i; +#ifdef CONFIG_ADB_CUDA for (i = 0; i < 3; ++i) { cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC, 0x50, i + 1, params[i]); while (!req.complete) cuda_poll(); } +#endif } diff -urN linux/drivers/video/offb.c bk/drivers/video/offb.c --- linux/drivers/video/offb.c Thu Aug 10 14:06:59 2000 +++ bk/drivers/video/offb.c Tue Aug 22 10:32:20 2000 @@ -43,6 +43,15 @@ static int currcon = 0; +/* Supported palette hacks */ +enum { + cmap_unknown, + cmap_m64, /* ATI Mach64 */ + cmap_r128, /* ATI Rage128 */ + cmap_M3A, /* ATI Rage Mobility M3 Head A */ + cmap_M3B /* ATI Rage Mobility M3 Head B */ +}; + struct fb_info_offb { struct fb_info info; struct fb_fix_screeninfo fix; @@ -51,7 +60,7 @@ struct { u_char red, green, blue, pad; } palette[256]; volatile unsigned char *cmap_adr; volatile unsigned char *cmap_data; - int is_rage_128; + int cmap_type; union { #ifdef FBCON_HAS_CFB16 u16 cfb16[16]; @@ -408,21 +417,27 @@ fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; - info->is_rage_128 = 0; + info->cmap_type = cmap_unknown; if (depth == 8) { /* XXX kludge for ati */ - if (strncmp(name, "ATY,Rage128", 11) == 0) { - if (dp) { + if (dp && !strncmp(name, "ATY,Rage128", 11)) { unsigned long regbase = dp->addrs[2].address; - info->cmap_adr = ioremap(regbase, 0x1FFF) + 0x00b0; - info->cmap_data = info->cmap_adr + 4; - info->is_rage_128 = 1; - } - } else if (strncmp(name, "ATY,", 4) == 0) { + info->cmap_adr = ioremap(regbase, 0x1FFF); + info->cmap_type = cmap_r128; + } else if (dp && !strncmp(name, "ATY,RageM3pA", 12)) { + unsigned long regbase = dp->parent->addrs[2].address; + info->cmap_adr = ioremap(regbase, 0x1FFF); + info->cmap_type = cmap_M3A; + } else if (dp && !strncmp(name, "ATY,RageM3pB", 12)) { + unsigned long regbase = dp->parent->addrs[2].address; + info->cmap_adr = ioremap(regbase, 0x1FFF); + info->cmap_type = cmap_M3B; + } else if (!strncmp(name, "ATY,", 4)) { unsigned long base = address & 0xff000000UL; info->cmap_adr = ioremap(base + 0x7ff000, 0x1000) + 0xcc0; info->cmap_data = info->cmap_adr + 1; + info->cmap_type = cmap_m64; } fix->visual = info->cmap_adr ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_STATIC_PSEUDOCOLOR; @@ -580,7 +595,7 @@ display_info.cmap_data_address = 0; display_info.disp_reg_address = 0; /* XXX kludge for ati */ - if (strncmp(name, "ATY,", 4) == 0) { + if (info->cmap_type == cmap_m64) { unsigned long base = address & 0xff000000UL; display_info.disp_reg_address = base + 0x7ffc00; display_info.cmap_adr_address = base + 0x7ffcc0; @@ -628,11 +643,32 @@ if (blank) for (i = 0; i < 256; i++) { - *info2->cmap_adr = i; - mach_eieio(); - for (j = 0; j < 3; j++) { - *info2->cmap_data = 0; - mach_eieio(); + switch(info2->cmap_type) { + case cmap_m64: + *info2->cmap_adr = i; + mach_eieio(); + for (j = 0; j < 3; j++) { + *info2->cmap_data = 0; + mach_eieio(); + } + break; + case cmap_M3A: + /* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */ + out_le32((unsigned *)(info2->cmap_adr + 0x58), + in_le32((unsigned *)(info2->cmap_adr + 0x58)) & ~0x20); + case cmap_r128: + /* Set palette index & data */ + out_8(info2->cmap_adr + 0xb0, i); + out_le32((unsigned *)(info2->cmap_adr + 0xb4), 0); + break; + case cmap_M3B: + /* Set PALETTE_ACCESS_CNTL in DAC_CNTL */ + out_le32((unsigned *)(info2->cmap_adr + 0x58), + in_le32((unsigned *)(info2->cmap_adr + 0x58)) | 0x20); + /* Set palette index & data */ + out_8(info2->cmap_adr + 0xb0, i); + out_le32((unsigned *)(info2->cmap_adr + 0xb4), 0); + break; } } else @@ -682,18 +718,36 @@ info2->palette[regno].green = green; info2->palette[regno].blue = blue; - *info2->cmap_adr = regno;/* On some chipsets, add << 3 in 15 bits */ - mach_eieio(); - if (info2->is_rage_128) { - out_le32((unsigned int *)info2->cmap_data, - (red << 16 | green << 8 | blue)); - } else { + switch(info2->cmap_type) { + case cmap_m64: + *info2->cmap_adr = regno; + mach_eieio(); *info2->cmap_data = red; - mach_eieio(); - *info2->cmap_data = green; - mach_eieio(); - *info2->cmap_data = blue; - mach_eieio(); + mach_eieio(); + *info2->cmap_data = green; + mach_eieio(); + *info2->cmap_data = blue; + mach_eieio(); + break; + case cmap_M3A: + /* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */ + out_le32((unsigned *)(info2->cmap_adr + 0x58), + in_le32((unsigned *)(info2->cmap_adr + 0x58)) & ~0x20); + case cmap_r128: + /* Set palette index & data */ + out_8(info2->cmap_adr + 0xb0, regno); + out_le32((unsigned *)(info2->cmap_adr + 0xb4), + (red << 16 | green << 8 | blue)); + break; + case cmap_M3B: + /* Set PALETTE_ACCESS_CNTL in DAC_CNTL */ + out_le32((unsigned *)(info2->cmap_adr + 0x58), + in_le32((unsigned *)(info2->cmap_adr + 0x58)) | 0x20); + /* Set palette index & data */ + out_8(info2->cmap_adr + 0xb0, regno); + out_le32((unsigned *)(info2->cmap_adr + 0xb4), + (red << 16 | green << 8 | blue)); + break; } if (regno < 16) diff -urN linux/drivers/video/valkyriefb.c bk/drivers/video/valkyriefb.c --- linux/drivers/video/valkyriefb.c Thu Aug 10 14:06:59 2000 +++ bk/drivers/video/valkyriefb.c Tue Aug 22 09:45:16 2000 @@ -425,12 +425,14 @@ struct adb_request req; int i; +#ifdef CONFIG_ADB_CUDA for (i = 0; i < 3; ++i) { cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC, 0x50, i + 1, params[i]); while (!req.complete) cuda_poll(); } +#endif } static void __init init_valkyrie(struct fb_info_valkyrie *p)