Commit 599c4eeb authored by Sylvain Meyer's avatar Sylvain Meyer Committed by Linus Torvalds

[PATCH] fbdev: Add vram option to intelfb

- add vram option to reserve more memory than stolen by BIOS if needed
- fix intelfbhw_pan_display typo
- add __initdata annotations
Signed-off-by: default avatarSylvain Meyer <sylvain.meyer@worldonline.fr>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 30b81706
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
/*** Version/name ***/ /*** Version/name ***/
#define INTELFB_VERSION "0.9.1" #define INTELFB_VERSION "0.9.2"
#define INTELFB_MODULE_NAME "intelfb" #define INTELFB_MODULE_NAME "intelfb"
#define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G" #define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G"
...@@ -199,10 +199,13 @@ struct intelfb_info { ...@@ -199,10 +199,13 @@ struct intelfb_info {
struct intelfb_hwstate save_state; struct intelfb_hwstate save_state;
/* agpgart structs */ /* agpgart structs */
struct agp_memory *gtt_fb_mem; // use all stolen memory struct agp_memory *gtt_fb_mem; // use all stolen memory or vram
struct agp_memory *gtt_ring_mem; // ring buffer struct agp_memory *gtt_ring_mem; // ring buffer
struct agp_memory *gtt_cursor_mem; // hw cursor struct agp_memory *gtt_cursor_mem; // hw cursor
/* use a gart reserved fb mem */
u8 fbmem_gart;
/* mtrr support */ /* mtrr support */
u32 mtrr_reg; u32 mtrr_reg;
u32 has_mtrr; u32 has_mtrr;
......
...@@ -94,6 +94,11 @@ ...@@ -94,6 +94,11 @@
* Use module_param instead of old MODULE_PARM * Use module_param instead of old MODULE_PARM
* Some cleanup * Some cleanup
* *
* 11/2004 - Version 0.9.2
* Add vram option to reserve more memory than stolen by BIOS
* Fix intelfbhw_pan_display typo
* Add __initdata annotations
*
* TODO: * TODO:
* *
* *
...@@ -186,19 +191,22 @@ MODULE_DESCRIPTION( ...@@ -186,19 +191,22 @@ MODULE_DESCRIPTION(
MODULE_LICENSE("Dual BSD/GPL"); MODULE_LICENSE("Dual BSD/GPL");
MODULE_DEVICE_TABLE(pci, intelfb_pci_table); MODULE_DEVICE_TABLE(pci, intelfb_pci_table);
static int accel = 1; static int accel __initdata = 1;
static int hwcursor = 1; static int vram __initdata = 4;
static int mtrr = 1; static int hwcursor __initdata = 1;
static int fixed = 0; static int mtrr __initdata = 1;
static int noinit = 0; static int fixed __initdata = 0;
static int noregister = 0; static int noinit __initdata = 0;
static int probeonly = 0; static int noregister __initdata = 0;
static int idonly = 0; static int probeonly __initdata = 0;
static int bailearly = 0; static int idonly __initdata = 0;
static char *mode = NULL; static int bailearly __initdata = 0;
static char *mode __initdata = NULL;
module_param(accel, bool, S_IRUGO); module_param(accel, bool, S_IRUGO);
MODULE_PARM_DESC(accel, "Enable console acceleration"); MODULE_PARM_DESC(accel, "Enable console acceleration");
module_param(vram, int, S_IRUGO);
MODULE_PARM_DESC(vram, "System RAM to allocate to framebuffer in MiB");
module_param(hwcursor, bool, S_IRUGO); module_param(hwcursor, bool, S_IRUGO);
MODULE_PARM_DESC(hwcursor, "Enable HW cursor"); MODULE_PARM_DESC(hwcursor, "Enable HW cursor");
module_param(mtrr, bool, S_IRUGO); module_param(mtrr, bool, S_IRUGO);
...@@ -257,6 +265,7 @@ intelfb_exit(void) ...@@ -257,6 +265,7 @@ intelfb_exit(void)
#ifndef MODULE #ifndef MODULE
#define OPT_EQUAL(opt, name) (!strncmp(opt, name, strlen(name))) #define OPT_EQUAL(opt, name) (!strncmp(opt, name, strlen(name)))
#define OPT_INTVAL(opt, name) simple_strtoul(opt + strlen(name), NULL, 0)
#define OPT_STRVAL(opt, name) (opt + strlen(name)) #define OPT_STRVAL(opt, name) (opt + strlen(name))
static __inline__ char * static __inline__ char *
...@@ -278,6 +287,19 @@ get_opt_string(const char *this_opt, const char *name) ...@@ -278,6 +287,19 @@ get_opt_string(const char *this_opt, const char *name)
return ret; return ret;
} }
static __inline__ int
get_opt_int(const char *this_opt, const char *name, int *ret)
{
if (!ret)
return 0;
if (!OPT_EQUAL(this_opt, name))
return 0;
*ret = OPT_INTVAL(this_opt, name);
return 1;
}
static __inline__ int static __inline__ int
get_opt_bool(const char *this_opt, const char *name, int *ret) get_opt_bool(const char *this_opt, const char *name, int *ret)
{ {
...@@ -330,6 +352,8 @@ intelfb_setup(char *options) ...@@ -330,6 +352,8 @@ intelfb_setup(char *options)
continue; continue;
if (get_opt_bool(this_opt, "accel", &accel)) if (get_opt_bool(this_opt, "accel", &accel))
; ;
else if (get_opt_int(this_opt, "vram", &vram))
;
else if (get_opt_bool(this_opt, "hwcursor", &hwcursor)) else if (get_opt_bool(this_opt, "hwcursor", &hwcursor))
; ;
else if (get_opt_bool(this_opt, "mtrr", &mtrr)) else if (get_opt_bool(this_opt, "mtrr", &mtrr))
...@@ -402,8 +426,10 @@ cleanup(struct intelfb_info *dinfo) ...@@ -402,8 +426,10 @@ cleanup(struct intelfb_info *dinfo)
unset_mtrr(dinfo); unset_mtrr(dinfo);
if (dinfo->gtt_fb_mem) if (dinfo->fbmem_gart && dinfo->gtt_fb_mem) {
agp_unbind_memory(dinfo->gtt_fb_mem); agp_unbind_memory(dinfo->gtt_fb_mem);
agp_free_memory(dinfo->gtt_fb_mem);
}
if (dinfo->gtt_cursor_mem) { if (dinfo->gtt_cursor_mem) {
agp_unbind_memory(dinfo->gtt_cursor_mem); agp_unbind_memory(dinfo->gtt_cursor_mem);
agp_free_memory(dinfo->gtt_cursor_mem); agp_free_memory(dinfo->gtt_cursor_mem);
...@@ -560,13 +586,14 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -560,13 +586,14 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
dinfo->accel = 0; dinfo->accel = 0;
} }
/* Framebuffer parameters - Use all the stolen memory */ /* Framebuffer parameters - Use all the stolen memory if >= vram */
if (ROUND_UP_TO_PAGE(stolen_size) >= MB(vram)) {
dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size); dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size);
dinfo->fb.offset = 0; // starts at offset 0 dinfo->fbmem_gart = 0;
dinfo->fb.physical = dinfo->aperture.physical } else {
+ (dinfo->fb.offset << 12); dinfo->fb.size = MB(vram);
dinfo->fb.virtual = dinfo->aperture.virtual + (dinfo->fb.offset << 12); dinfo->fbmem_gart = 1;
dinfo->fb_start = dinfo->fb.offset << 12; }
/* Allocate space for the ring buffer and HW cursor if enabled. */ /* Allocate space for the ring buffer and HW cursor if enabled. */
if (dinfo->accel) { if (dinfo->accel) {
...@@ -601,6 +628,11 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -601,6 +628,11 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
dinfo->cursor.offset = (stolen_size >> 12) + dinfo->cursor.offset = (stolen_size >> 12) +
+ gtt_info.current_memory + (dinfo->ring.size >> 12); + gtt_info.current_memory + (dinfo->ring.size >> 12);
} }
if (dinfo->fbmem_gart) {
dinfo->fb.offset = (stolen_size >> 12) +
+ gtt_info.current_memory + (dinfo->ring.size >> 12)
+ (dinfo->cursor.size >> 12);
}
/* Allocate memories (which aren't stolen) */ /* Allocate memories (which aren't stolen) */
if (dinfo->accel) { if (dinfo->accel) {
...@@ -652,6 +684,29 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -652,6 +684,29 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
dinfo->cursor.virtual = dinfo->aperture.virtual dinfo->cursor.virtual = dinfo->aperture.virtual
+ (dinfo->cursor.offset << 12); + (dinfo->cursor.offset << 12);
} }
if (dinfo->fbmem_gart) {
if (!(dinfo->gtt_fb_mem =
agp_allocate_memory(dinfo->fb.size >> 12,
AGP_NORMAL_MEMORY))) {
WRN_MSG("cannot allocate framebuffer memory - use "
"the stolen one\n");
dinfo->fbmem_gart = 0;
}
if (agp_bind_memory(dinfo->gtt_fb_mem,
dinfo->fb.offset)) {
WRN_MSG("cannot bind framebuffer memory - use "
"the stolen one\n");
dinfo->fbmem_gart = 0;
}
}
/* update framebuffer memory parameters */
if (!dinfo->fbmem_gart)
dinfo->fb.offset = 0; /* starts at offset 0 */
dinfo->fb.physical = dinfo->aperture.physical
+ (dinfo->fb.offset << 12);
dinfo->fb.virtual = dinfo->aperture.virtual + (dinfo->fb.offset << 12);
dinfo->fb_start = dinfo->fb.offset << 12;
/* release agpgart */ /* release agpgart */
agp_backend_release(); agp_backend_release();
...@@ -673,8 +728,8 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -673,8 +728,8 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
(u32 __iomem ) dinfo->cursor.virtual, dinfo->cursor.offset, (u32 __iomem ) dinfo->cursor.virtual, dinfo->cursor.offset,
dinfo->cursor.physical); dinfo->cursor.physical);
DBG_MSG("options: accel = %d, hwcursor = %d, fixed = %d, " DBG_MSG("options: vram = %d, accel = %d, hwcursor = %d, fixed = %d, "
"noinit = %d\n", accel, hwcursor, fixed, noinit); "noinit = %d\n", vram, accel, hwcursor, fixed, noinit);
DBG_MSG("options: mode = \"%s\"\n", mode ? mode : ""); DBG_MSG("options: mode = \"%s\"\n", mode ? mode : "");
if (probeonly) if (probeonly)
......
...@@ -295,7 +295,7 @@ intelfbhw_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) ...@@ -295,7 +295,7 @@ intelfbhw_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
offset = (yoffset * dinfo->pitch) + offset = (yoffset * dinfo->pitch) +
(xoffset * var->bits_per_pixel) / 8; (xoffset * var->bits_per_pixel) / 8;
offset += dinfo->fb.offset >> 12; offset += dinfo->fb.offset << 12;
OUTREG(DSPABASE, offset); OUTREG(DSPABASE, offset);
......
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