X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fvideo%2Fintelfb%2Fintelfbdrv.c;h=e44303f9bc524ea64e86bd00030ffbaa3110dd01;hb=0e170c72c0c55bd78213a0f5053bd9a1dde403b7;hp=b75eda84858f62ad62937242903ba36bcf471811;hpb=f5610b9c3a2896fcaa623b92d0f24d83f10bb2c0;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c index b75eda8..e44303f 100644 --- a/drivers/video/intelfb/intelfbdrv.c +++ b/drivers/video/intelfb/intelfbdrv.c @@ -2,9 +2,9 @@ * intelfb * * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G/915GM/ - * 945G/945GM integrated graphics chips. + * 945G/945GM/965G/965GM integrated graphics chips. * - * Copyright © 2002, 2003 David Dawes + * Copyright © 2002, 2003 David Dawes * 2004 Sylvain Meyer * 2006 David Airlie * @@ -100,12 +100,8 @@ * Fix intelfbhw_pan_display typo * Add __initdata annotations * - * TODO: - * - * - * Wish List: - * - * + * 04/2008 - Version 0.9.5 + * Add support for 965G/965GM. (Maik Broemme ) */ #include @@ -187,6 +183,8 @@ static struct pci_device_id intelfb_pci_table[] __devinitdata = { { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915GM }, { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945G }, { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945GM }, + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_965G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_965G }, + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_965GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_965GM }, { 0, } }; @@ -222,8 +220,8 @@ static struct pci_driver intelfb_driver = { /* Module description/parameters */ MODULE_AUTHOR("David Dawes , " "Sylvain Meyer "); -MODULE_DESCRIPTION( - "Framebuffer driver for Intel(R) " SUPPORTED_CHIPSETS " chipsets"); +MODULE_DESCRIPTION("Framebuffer driver for Intel(R) " SUPPORTED_CHIPSETS + " chipsets"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_DEVICE_TABLE(pci, intelfb_pci_table); @@ -271,8 +269,7 @@ MODULE_PARM_DESC(mode, #define OPT_INTVAL(opt, name) simple_strtoul(opt + strlen(name) + 1, NULL, 0) #define OPT_STRVAL(opt, name) (opt + strlen(name)) -static __inline__ char * -get_opt_string(const char *this_opt, const char *name) +static __inline__ char * get_opt_string(const char *this_opt, const char *name) { const char *p; int i; @@ -290,8 +287,8 @@ get_opt_string(const char *this_opt, const char *name) return ret; } -static __inline__ int -get_opt_int(const char *this_opt, const char *name, int *ret) +static __inline__ int get_opt_int(const char *this_opt, const char *name, + int *ret) { if (!ret) return 0; @@ -303,8 +300,8 @@ get_opt_int(const char *this_opt, const char *name, int *ret) return 1; } -static __inline__ int -get_opt_bool(const char *this_opt, const char *name, int *ret) +static __inline__ int get_opt_bool(const char *this_opt, const char *name, + int *ret) { if (!ret) return 0; @@ -324,8 +321,7 @@ get_opt_bool(const char *this_opt, const char *name, int *ret) return 1; } -static int __init -intelfb_setup(char *options) +static int __init intelfb_setup(char *options) { char *this_opt; @@ -355,7 +351,7 @@ intelfb_setup(char *options) continue; if (get_opt_bool(this_opt, "accel", &accel)) ; - else if (get_opt_int(this_opt, "vram", &vram)) + else if (get_opt_int(this_opt, "vram", &vram)) ; else if (get_opt_bool(this_opt, "hwcursor", &hwcursor)) ; @@ -376,8 +372,7 @@ intelfb_setup(char *options) #endif -static int __init -intelfb_init(void) +static int __init intelfb_init(void) { #ifndef MODULE char *option = NULL; @@ -401,8 +396,7 @@ intelfb_init(void) return pci_register_driver(&intelfb_driver); } -static void __exit -intelfb_exit(void) +static void __exit intelfb_exit(void) { DBG_MSG("intelfb_exit\n"); pci_unregister_driver(&intelfb_driver); @@ -428,8 +422,8 @@ static inline void __devinit set_mtrr(struct intelfb_info *dinfo) } static inline void unset_mtrr(struct intelfb_info *dinfo) { - if (dinfo->has_mtrr) - mtrr_del(dinfo->mtrr_reg, dinfo->aperture.physical, + if (dinfo->has_mtrr) + mtrr_del(dinfo->mtrr_reg, dinfo->aperture.physical, dinfo->aperture.size); } #else @@ -442,8 +436,7 @@ static inline void unset_mtrr(struct intelfb_info *dinfo) * driver init / cleanup * ***************************************************************/ -static void -cleanup(struct intelfb_info *dinfo) +static void cleanup(struct intelfb_info *dinfo) { DBG_MSG("cleanup\n"); @@ -499,8 +492,8 @@ cleanup(struct intelfb_info *dinfo) } while (0) -static int __devinit -intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) +static int __devinit intelfb_pci_register(struct pci_dev *pdev, + const struct pci_device_id *ent) { struct fb_info *info; struct intelfb_info *dinfo; @@ -510,8 +503,8 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) int agp_memtype; const char *s; struct agp_bridge_data *bridge; - int aperture_bar = 0; - int mmio_bar = 1; + int aperture_bar = 0; + int mmio_bar = 1; int offset; DBG_MSG("intelfb_pci_register\n"); @@ -561,7 +554,10 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) if ((ent->device == PCI_DEVICE_ID_INTEL_915G) || (ent->device == PCI_DEVICE_ID_INTEL_915GM) || (ent->device == PCI_DEVICE_ID_INTEL_945G) || - (ent->device == PCI_DEVICE_ID_INTEL_945GM)) { + (ent->device == PCI_DEVICE_ID_INTEL_945GM) || + (ent->device == PCI_DEVICE_ID_INTEL_965G) || + (ent->device == PCI_DEVICE_ID_INTEL_965GM)) { + aperture_bar = 2; mmio_bar = 0; } @@ -637,9 +633,8 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) dinfo->ring.size = RINGBUFFER_SIZE; dinfo->ring_tail_mask = dinfo->ring.size - 1; } - if (dinfo->hwcursor) { + if (dinfo->hwcursor) dinfo->cursor.size = HW_CURSOR_SIZE; - } /* Use agpgart to manage the GATT */ if (!(bridge = agp_backend_acquire(pdev))) { @@ -662,18 +657,15 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE; /* set the mem offsets - set them after the already used pages */ - if (dinfo->accel) { + if (dinfo->accel) dinfo->ring.offset = offset + gtt_info.current_memory; - } - if (dinfo->hwcursor) { + if (dinfo->hwcursor) dinfo->cursor.offset = offset + + gtt_info.current_memory + (dinfo->ring.size >> 12); - } - if (dinfo->fbmem_gart) { + if (dinfo->fbmem_gart) dinfo->fb.offset = offset + + gtt_info.current_memory + (dinfo->ring.size >> 12) + (dinfo->cursor.size >> 12); - } /* Allocate memories (which aren't stolen) */ /* Map the fb and MMIO regions */ @@ -689,7 +681,7 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) dinfo->mmio_base = (u8 __iomem *)ioremap_nocache(dinfo->mmio_base_phys, - INTEL_REG_SIZE); + INTEL_REG_SIZE); if (!dinfo->mmio_base) { ERR_MSG("Cannot remap MMIO region.\n"); cleanup(dinfo); @@ -820,7 +812,8 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) if (bailearly == 1) bailout(dinfo); - if (FIXED_MODE(dinfo) && ORIG_VIDEO_ISVGA != VIDEO_TYPE_VLFB) { + if (FIXED_MODE(dinfo) && + screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB) { ERR_MSG("Video mode must be programmed at boot time.\n"); cleanup(dinfo); return -ENODEV; @@ -831,16 +824,14 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) /* Initialise dinfo and related data. */ /* If an initial mode was programmed at boot time, get its details. */ - if (ORIG_VIDEO_ISVGA == VIDEO_TYPE_VLFB) + if (screen_info.orig_video_isVGA == VIDEO_TYPE_VLFB) get_initial_mode(dinfo); if (bailearly == 3) bailout(dinfo); - if (FIXED_MODE(dinfo)) { - /* remap fb address */ + if (FIXED_MODE(dinfo)) /* remap fb address */ update_dinfo(dinfo, &dinfo->initial_var); - } if (bailearly == 4) bailout(dinfo); @@ -939,8 +930,7 @@ intelfb_pci_unregister(struct pci_dev *pdev) * helper functions * ***************************************************************/ -int __inline__ -intelfb_var_to_depth(const struct fb_var_screeninfo *var) +int __inline__ intelfb_var_to_depth(const struct fb_var_screeninfo *var) { DBG_MSG("intelfb_var_to_depth: bpp: %d, green.length is %d\n", var->bits_per_pixel, var->green.length); @@ -956,8 +946,7 @@ intelfb_var_to_depth(const struct fb_var_screeninfo *var) } -static __inline__ int -var_to_refresh(const struct fb_var_screeninfo *var) +static __inline__ int var_to_refresh(const struct fb_var_screeninfo *var) { int xtot = var->xres + var->left_margin + var->right_margin + var->hsync_len; @@ -971,8 +960,7 @@ var_to_refresh(const struct fb_var_screeninfo *var) * Various intialisation functions * ***************************************************************/ -static void __devinit -get_initial_mode(struct intelfb_info *dinfo) +static void __devinit get_initial_mode(struct intelfb_info *dinfo) { struct fb_var_screeninfo *var; int xtot, ytot; @@ -1039,8 +1027,7 @@ get_initial_mode(struct intelfb_info *dinfo) } } -static int __devinit -intelfb_init_var(struct intelfb_info *dinfo) +static int __devinit intelfb_init_var(struct intelfb_info *dinfo) { struct fb_var_screeninfo *var; int msrc = 0; @@ -1087,10 +1074,9 @@ intelfb_init_var(struct intelfb_info *dinfo) } - if (!msrc) { + if (!msrc) msrc = fb_find_mode(var, dinfo->info, PREFERRED_MODE, NULL, 0, NULL, 0); - } } if (!msrc) { @@ -1122,8 +1108,7 @@ intelfb_init_var(struct intelfb_info *dinfo) return 0; } -static int __devinit -intelfb_set_fbinfo(struct intelfb_info *dinfo) +static int __devinit intelfb_set_fbinfo(struct intelfb_info *dinfo) { struct fb_info *info = dinfo->info; @@ -1159,8 +1144,8 @@ intelfb_set_fbinfo(struct intelfb_info *dinfo) } /* Update dinfo to match the active video mode. */ -static void -update_dinfo(struct intelfb_info *dinfo, struct fb_var_screeninfo *var) +static void update_dinfo(struct intelfb_info *dinfo, + struct fb_var_screeninfo *var) { DBG_MSG("update_dinfo\n"); @@ -1208,36 +1193,32 @@ update_dinfo(struct intelfb_info *dinfo, struct fb_var_screeninfo *var) * fbdev interface * ***************************************************************/ -static int -intelfb_open(struct fb_info *info, int user) +static int intelfb_open(struct fb_info *info, int user) { struct intelfb_info *dinfo = GET_DINFO(info); - if (user) { + if (user) dinfo->open++; - } return 0; } -static int -intelfb_release(struct fb_info *info, int user) +static int intelfb_release(struct fb_info *info, int user) { struct intelfb_info *dinfo = GET_DINFO(info); if (user) { dinfo->open--; msleep(1); - if (!dinfo->open) { + if (!dinfo->open) intelfbhw_disable_irq(dinfo); - } } return 0; } -static int -intelfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) +static int intelfb_check_var(struct fb_var_screeninfo *var, + struct fb_info *info) { int change_var = 0; struct fb_var_screeninfo v; @@ -1271,15 +1252,15 @@ intelfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) } /* Check for a supported bpp. */ - if (v.bits_per_pixel <= 8) { + if (v.bits_per_pixel <= 8) v.bits_per_pixel = 8; - } else if (v.bits_per_pixel <= 16) { + else if (v.bits_per_pixel <= 16) { if (v.bits_per_pixel == 16) v.green.length = 6; v.bits_per_pixel = 16; - } else if (v.bits_per_pixel <= 32) { + } else if (v.bits_per_pixel <= 32) v.bits_per_pixel = 32; - } else + else return -EINVAL; change_var = ((info->var.xres != var->xres) || @@ -1361,10 +1342,9 @@ intelfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) return 0; } -static int -intelfb_set_par(struct fb_info *info) +static int intelfb_set_par(struct fb_info *info) { - struct intelfb_hwstate *hw; + struct intelfb_hwstate *hw; struct intelfb_info *dinfo = GET_DINFO(info); if (FIXED_MODE(dinfo)) { @@ -1372,9 +1352,9 @@ intelfb_set_par(struct fb_info *info) return -EINVAL; } - hw = kmalloc(sizeof(*hw), GFP_ATOMIC); - if (!hw) - return -ENOMEM; + hw = kmalloc(sizeof(*hw), GFP_ATOMIC); + if (!hw) + return -ENOMEM; DBG_MSG("intelfb_set_par (%dx%d-%d)\n", info->var.xres, info->var.yres, info->var.bits_per_pixel); @@ -1384,15 +1364,15 @@ intelfb_set_par(struct fb_info *info) if (ACCEL(dinfo, info)) intelfbhw_2d_stop(dinfo); - memcpy(hw, &dinfo->save_state, sizeof(*hw)); - if (intelfbhw_mode_to_hw(dinfo, hw, &info->var)) - goto invalid_mode; - if (intelfbhw_program_mode(dinfo, hw, 0)) - goto invalid_mode; + memcpy(hw, &dinfo->save_state, sizeof(*hw)); + if (intelfbhw_mode_to_hw(dinfo, hw, &info->var)) + goto invalid_mode; + if (intelfbhw_program_mode(dinfo, hw, 0)) + goto invalid_mode; #if REGDUMP > 0 - intelfbhw_read_hw_state(dinfo, hw, 0); - intelfbhw_print_hw_state(dinfo, hw); + intelfbhw_read_hw_state(dinfo, hw, 0); + intelfbhw_print_hw_state(dinfo, hw); #endif update_dinfo(dinfo, &info->var); @@ -1408,9 +1388,9 @@ intelfb_set_par(struct fb_info *info) info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT; - } else { + } else info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; - } + kfree(hw); return 0; invalid_mode: @@ -1418,9 +1398,9 @@ invalid_mode: return -EINVAL; } -static int -intelfb_setcolreg(unsigned regno, unsigned red, unsigned green, - unsigned blue, unsigned transp, struct fb_info *info) +static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green, + unsigned blue, unsigned transp, + struct fb_info *info) { struct intelfb_info *dinfo = GET_DINFO(info); @@ -1463,23 +1443,22 @@ intelfb_setcolreg(unsigned regno, unsigned red, unsigned green, return 0; } -static int -intelfb_blank(int blank, struct fb_info *info) +static int intelfb_blank(int blank, struct fb_info *info) { intelfbhw_do_blank(blank, info); return 0; } -static int -intelfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) +static int intelfb_pan_display(struct fb_var_screeninfo *var, + struct fb_info *info) { intelfbhw_pan_display(var, info); return 0; } /* When/if we have our own ioctls. */ -static int -intelfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) +static int intelfb_ioctl(struct fb_info *info, unsigned int cmd, + unsigned long arg) { int retval = 0; struct intelfb_info *dinfo = GET_DINFO(info); @@ -1499,8 +1478,8 @@ intelfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) return retval; } -static void -intelfb_fillrect (struct fb_info *info, const struct fb_fillrect *rect) +static void intelfb_fillrect (struct fb_info *info, + const struct fb_fillrect *rect) { struct intelfb_info *dinfo = GET_DINFO(info); u32 rop, color; @@ -1514,7 +1493,7 @@ intelfb_fillrect (struct fb_info *info, const struct fb_fillrect *rect) if (rect->rop == ROP_COPY) rop = PAT_ROP_GXCOPY; - else // ROP_XOR + else /* ROP_XOR */ rop = PAT_ROP_GXXOR; if (dinfo->depth != 8) @@ -1528,8 +1507,8 @@ intelfb_fillrect (struct fb_info *info, const struct fb_fillrect *rect) rop); } -static void -intelfb_copyarea(struct fb_info *info, const struct fb_copyarea *region) +static void intelfb_copyarea(struct fb_info *info, + const struct fb_copyarea *region) { struct intelfb_info *dinfo = GET_DINFO(info); @@ -1545,8 +1524,8 @@ intelfb_copyarea(struct fb_info *info, const struct fb_copyarea *region) dinfo->pitch, info->var.bits_per_pixel); } -static void -intelfb_imageblit(struct fb_info *info, const struct fb_image *image) +static void intelfb_imageblit(struct fb_info *info, + const struct fb_image *image) { struct intelfb_info *dinfo = GET_DINFO(info); u32 fgcolor, bgcolor; @@ -1574,8 +1553,7 @@ intelfb_imageblit(struct fb_info *info, const struct fb_image *image) return cfb_imageblit(info, image); } -static int -intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor) +static int intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor) { struct intelfb_info *dinfo = GET_DINFO(info); u32 physical; @@ -1689,8 +1667,7 @@ intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor) return 0; } -static int -intelfb_sync(struct fb_info *info) +static int intelfb_sync(struct fb_info *info) { struct intelfb_info *dinfo = GET_DINFO(info);