11 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/errno.h>
14 #include <linux/string.h>
21 #include <linux/screen_info.h>
27 #define dac_reg (0x3c8)
28 #define dac_val (0x3c9)
81 static int vesa_setpalette(
int regno,
unsigned red,
unsigned green,
84 int shift = 16 -
depth;
102 if (err && pmi_setpal) {
105 entry.red = red >> shift;
106 entry.green = green >> shift;
107 entry.blue = blue >> shift;
125 static int vesafb_setcolreg(
unsigned regno,
unsigned red,
unsigned green,
126 unsigned blue,
unsigned transp,
138 if (regno >= info->
cmap.len)
141 if (info->
var.bits_per_pixel == 8)
142 err = vesa_setpalette(regno,red,green,blue);
143 else if (regno < 16) {
144 switch (info->
var.bits_per_pixel) {
146 if (info->
var.red.offset == 10) {
149 ((red & 0xf800) >> 1) |
150 ((green & 0xf800) >> 6) |
151 ((blue & 0xf800) >> 11);
156 ((green & 0xfc00) >> 5) |
157 ((blue & 0xf800) >> 11);
166 (red << info->
var.red.offset) |
167 (green << info->
var.green.offset) |
168 (blue << info->
var.blue.offset);
176 static void vesafb_destroy(
struct fb_info *info)
185 static struct fb_ops vesafb_ops = {
187 .fb_destroy = vesafb_destroy,
188 .fb_setcolreg = vesafb_setcolreg,
189 .fb_pan_display = vesafb_pan_display,
199 if (!options || !*options)
202 while ((this_opt =
strsep(&options,
",")) !=
NULL) {
203 if (!*this_opt)
continue;
205 if (!
strcmp(this_opt,
"inverse"))
207 else if (!
strcmp(this_opt,
"redraw"))
209 else if (!
strcmp(this_opt,
"ypan"))
211 else if (!
strcmp(this_opt,
"ywrap"))
213 else if (!
strcmp(this_opt,
"vgapal"))
215 else if (!
strcmp(this_opt,
"pmipal"))
217 else if (!
strncmp(this_opt,
"mtrr:", 5))
219 else if (!
strcmp(this_opt,
"nomtrr"))
221 else if (!
strncmp(this_opt,
"vtotal:", 7))
223 else if (!
strncmp(this_opt,
"vremap:", 7))
233 unsigned int size_vmode;
234 unsigned int size_remap;
235 unsigned int size_total;
243 if (15 == vesafb_defined.bits_per_pixel)
244 vesafb_defined.bits_per_pixel = 16;
248 vesafb_fix.visual = (vesafb_defined.bits_per_pixel == 8) ?
254 size_vmode = vesafb_defined.yres * vesafb_fix.line_length;
261 size_total = vram_total * 1024 * 1024;
262 if (size_total < size_vmode)
263 size_total = size_vmode;
269 size_remap = size_vmode * 2;
271 size_remap = vram_remap * 1024 * 1024;
272 if (size_remap < size_vmode)
273 size_remap = size_vmode;
274 if (size_remap > size_total)
275 size_remap = size_total;
276 vesafb_fix.smem_len = size_remap;
284 "vesafb: cannot reserve video memory at 0x%lx\n",
285 vesafb_fix.smem_start);
305 info->
apertures->ranges[0].size = size_total;
307 printk(
KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
308 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length,
screen_info.
pages);
311 printk(
KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
316 ypan = pmi_setpal = 0;
318 if (ypan || pmi_setpal) {
319 unsigned short *pmi_base;
321 pmi_start = (
void*)((
char*)pmi_base + pmi_base[1]);
322 pmi_pal = (
void*)((
char*)pmi_base + pmi_base[2]);
323 printk(
KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
326 for (i = pmi_base[3]/2; pmi_base[
i] != 0xffff; i++)
327 printk(
"%x ",pmi_base[i]);
329 if (pmi_base[i] != 0xffff) {
336 printk(
KERN_INFO "vesafb: can't handle memory requests, pmi disabled\n");
337 ypan = pmi_setpal = 0;
342 if (vesafb_defined.bits_per_pixel == 8 && !pmi_setpal && !vga_compat) {
344 " colors may be incorrect\n");
348 vesafb_defined.xres_virtual = vesafb_defined.xres;
349 vesafb_defined.yres_virtual = vesafb_fix.smem_len / vesafb_fix.line_length;
350 if (ypan && vesafb_defined.yres_virtual > vesafb_defined.yres) {
351 printk(
KERN_INFO "vesafb: scrolling: %s using protected mode interface, yres_virtual=%d\n",
352 (ypan > 1) ?
"ywrap" :
"ypan",vesafb_defined.yres_virtual);
355 vesafb_defined.yres_virtual = vesafb_defined.yres;
360 vesafb_defined.pixclock = 10000000 / vesafb_defined.xres * 1000 / vesafb_defined.yres;
361 vesafb_defined.left_margin = (vesafb_defined.xres / 8) & 0xf8;
362 vesafb_defined.hsync_len = (vesafb_defined.xres / 8) & 0xf8;
373 if (vesafb_defined.bits_per_pixel <= 8) {
374 depth = vesafb_defined.green.length;
375 vesafb_defined.red.length =
376 vesafb_defined.green.length =
377 vesafb_defined.blue.length =
378 vesafb_defined.bits_per_pixel;
382 "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
383 (vesafb_defined.bits_per_pixel > 8) ?
384 "Truecolor" : (vga_compat || pmi_setpal) ?
385 "Pseudocolor" :
"Static Pseudocolor",
395 vesafb_fix.ypanstep = ypan ? 1 : 0;
396 vesafb_fix.ywrapstep = (ypan>1) ? 1 : 0;
404 unsigned int temp_size = size_total;
405 unsigned int type = 0;
433 rc =
mtrr_add(vesafb_fix.smem_start, temp_size,
458 "vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n",
459 vesafb_fix.smem_len, vesafb_fix.smem_start);
465 "using %dk, total %dk\n",
467 size_remap/1024, size_total/1024);
469 info->
fbops = &vesafb_ops;
470 info->
var = vesafb_defined;
471 info->
fix = vesafb_fix;
506 static int __init vesafb_init(
void)
513 vesafb_setup(option);
528 vesafb_device =
NULL;