Rev 479 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
466 | giacomo | 1 | /* |
2 | * framebuffer driver for VBE 2.0 compliant graphic boards |
||
3 | * |
||
4 | * switching to graphics mode happens at boot time (while |
||
5 | * running in real mode, see arch/i386/boot/video.S). |
||
6 | * |
||
7 | * (c) 1998 Gerd Knorr <kraxel@goldbach.in-berlin.de> |
||
8 | * |
||
9 | */ |
||
10 | |||
11 | #include <linuxcomp.h> |
||
12 | |||
13 | #include <linux/module.h> |
||
14 | #include <linux/kernel.h> |
||
15 | #include <linux/errno.h> |
||
16 | #include <linux/string.h> |
||
17 | #include <linux/mm.h> |
||
18 | #include <linux/tty.h> |
||
19 | #include <linux/slab.h> |
||
20 | #include <linux/delay.h> |
||
21 | #include <linux/fb.h> |
||
22 | #include <linux/ioport.h> |
||
23 | #include <linux/init.h> |
||
24 | #ifdef __i386__ |
||
25 | #include <video/edid.h> |
||
26 | #endif |
||
27 | #include <asm/io.h> |
||
28 | #include <asm/mtrr.h> |
||
29 | |||
30 | #define dac_reg (0x3c8) |
||
31 | #define dac_val (0x3c9) |
||
32 | |||
477 | giacomo | 33 | #include <vesa.h> |
34 | |||
35 | #define INIT_MODE 0x4101 |
||
36 | |||
466 | giacomo | 37 | /* --------------------------------------------------------------------- */ |
38 | |||
39 | static struct fb_var_screeninfo vesafb_defined __initdata = { |
||
40 | .activate = FB_ACTIVATE_NOW, |
||
41 | .height = -1, |
||
42 | .width = -1, |
||
43 | .right_margin = 32, |
||
44 | .upper_margin = 16, |
||
45 | .lower_margin = 4, |
||
46 | .vsync_len = 4, |
||
47 | .vmode = FB_VMODE_NONINTERLACED, |
||
48 | }; |
||
49 | |||
50 | static struct fb_fix_screeninfo vesafb_fix __initdata = { |
||
51 | .id = "VESA VGA", |
||
52 | .type = FB_TYPE_PACKED_PIXELS, |
||
53 | .accel = FB_ACCEL_NONE, |
||
54 | }; |
||
55 | |||
56 | static struct fb_info fb_info; |
||
57 | static u32 pseudo_palette[17]; |
||
58 | |||
59 | static int inverse = 0; |
||
60 | static int mtrr = 1; |
||
61 | |||
62 | static int pmi_setpal = 0; /* pmi for palette changes ??? */ |
||
63 | static int ypan = 0; /* 0..nothing, 1..ypan, 2..ywrap */ |
||
64 | static unsigned short *pmi_base = 0; |
||
65 | static void (*pmi_start)(void); |
||
66 | static void (*pmi_pal)(void); |
||
67 | |||
68 | /* --------------------------------------------------------------------- */ |
||
69 | |||
70 | static int vesafb_pan_display(struct fb_var_screeninfo *var, |
||
71 | struct fb_info *info) |
||
72 | { |
||
73 | #ifdef __i386__ |
||
74 | int offset; |
||
75 | |||
76 | if (!ypan) |
||
77 | return -EINVAL; |
||
78 | if (var->xoffset) |
||
79 | return -EINVAL; |
||
80 | if (var->yoffset > var->yres_virtual) |
||
81 | return -EINVAL; |
||
82 | if ((ypan==1) && var->yoffset+var->yres > var->yres_virtual) |
||
83 | return -EINVAL; |
||
84 | |||
85 | offset = (var->yoffset * info->fix.line_length + var->xoffset) / 4; |
||
86 | |||
87 | __asm__ __volatile__( |
||
88 | "call *(%%edi)" |
||
89 | : /* no return value */ |
||
90 | : "a" (0x4f07), /* EAX */ |
||
91 | "b" (0), /* EBX */ |
||
92 | "c" (offset), /* ECX */ |
||
93 | "d" (offset >> 16), /* EDX */ |
||
94 | "D" (&pmi_start)); /* EDI */ |
||
95 | #endif |
||
96 | return 0; |
||
97 | } |
||
98 | |||
99 | static void vesa_setpalette(int regno, unsigned red, unsigned green, unsigned blue) |
||
100 | { |
||
101 | #ifdef __i386__ |
||
102 | struct { u_char blue, green, red, pad; } entry; |
||
103 | |||
104 | if (pmi_setpal) { |
||
105 | entry.red = red >> 10; |
||
106 | entry.green = green >> 10; |
||
107 | entry.blue = blue >> 10; |
||
108 | entry.pad = 0; |
||
109 | __asm__ __volatile__( |
||
110 | "call *(%%esi)" |
||
111 | : /* no return value */ |
||
112 | : "a" (0x4f09), /* EAX */ |
||
113 | "b" (0), /* EBX */ |
||
114 | "c" (1), /* ECX */ |
||
115 | "d" (regno), /* EDX */ |
||
116 | "D" (&entry), /* EDI */ |
||
117 | "S" (&pmi_pal)); /* ESI */ |
||
118 | } else { |
||
119 | /* without protected mode interface, try VGA registers... */ |
||
120 | outb_p(regno, dac_reg); |
||
121 | outb_p(red >> 10, dac_val); |
||
122 | outb_p(green >> 10, dac_val); |
||
123 | outb_p(blue >> 10, dac_val); |
||
124 | } |
||
125 | #endif |
||
126 | } |
||
127 | |||
128 | static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green, |
||
129 | unsigned blue, unsigned transp, |
||
130 | struct fb_info *info) |
||
131 | { |
||
132 | /* |
||
133 | * Set a single color register. The values supplied are |
||
134 | * already rounded down to the hardware's capabilities |
||
135 | * (according to the entries in the `var' structure). Return |
||
136 | * != 0 for invalid regno. |
||
137 | */ |
||
138 | |||
139 | if (regno >= info->cmap.len) |
||
140 | return 1; |
||
141 | |||
142 | switch (info->var.bits_per_pixel) { |
||
143 | case 8: |
||
144 | vesa_setpalette(regno,red,green,blue); |
||
145 | break; |
||
146 | case 16: |
||
147 | if (info->var.red.offset == 10) { |
||
148 | /* 1:5:5:5 */ |
||
149 | ((u32*) (info->pseudo_palette))[regno] = |
||
150 | ((red & 0xf800) >> 1) | |
||
151 | ((green & 0xf800) >> 6) | |
||
152 | ((blue & 0xf800) >> 11); |
||
153 | } else { |
||
154 | /* 0:5:6:5 */ |
||
155 | ((u32*) (info->pseudo_palette))[regno] = |
||
156 | ((red & 0xf800) ) | |
||
157 | ((green & 0xfc00) >> 5) | |
||
158 | ((blue & 0xf800) >> 11); |
||
159 | } |
||
160 | break; |
||
161 | case 24: |
||
162 | red >>= 8; |
||
163 | green >>= 8; |
||
164 | blue >>= 8; |
||
165 | ((u32 *)(info->pseudo_palette))[regno] = |
||
166 | (red << info->var.red.offset) | |
||
167 | (green << info->var.green.offset) | |
||
168 | (blue << info->var.blue.offset); |
||
169 | break; |
||
170 | case 32: |
||
171 | red >>= 8; |
||
172 | green >>= 8; |
||
173 | blue >>= 8; |
||
174 | ((u32 *)(info->pseudo_palette))[regno] = |
||
175 | (red << info->var.red.offset) | |
||
176 | (green << info->var.green.offset) | |
||
177 | (blue << info->var.blue.offset); |
||
178 | break; |
||
179 | } |
||
180 | return 0; |
||
181 | } |
||
182 | |||
478 | giacomo | 183 | static int vesafb_release(struct fb_info *info, int user) |
184 | { |
||
185 | |||
186 | vbe_restore_vga(); |
||
187 | return 0; |
||
188 | |||
189 | } |
||
190 | |||
466 | giacomo | 191 | int __init vesafb_setup(char *options) |
192 | { |
||
193 | char *this_opt; |
||
194 | |||
195 | if (!options || !*options) |
||
196 | return 0; |
||
197 | |||
198 | while ((this_opt = strsep(&options, ",")) != NULL) { |
||
199 | if (!*this_opt) continue; |
||
200 | |||
201 | if (! strcmp(this_opt, "inverse")) |
||
202 | inverse=1; |
||
203 | else if (! strcmp(this_opt, "redraw")) |
||
204 | ypan=0; |
||
205 | else if (! strcmp(this_opt, "ypan")) |
||
206 | ypan=1; |
||
207 | else if (! strcmp(this_opt, "ywrap")) |
||
208 | ypan=2; |
||
209 | else if (! strcmp(this_opt, "vgapal")) |
||
210 | pmi_setpal=0; |
||
211 | else if (! strcmp(this_opt, "pmipal")) |
||
212 | pmi_setpal=1; |
||
213 | else if (! strcmp(this_opt, "mtrr")) |
||
214 | mtrr=1; |
||
215 | else if (! strcmp(this_opt, "nomtrr")) |
||
216 | mtrr=0; |
||
217 | } |
||
218 | return 0; |
||
219 | } |
||
220 | |||
477 | giacomo | 221 | extern VbeInfoBlock VbeInfo; |
222 | extern int vbe_getifo(void); |
||
223 | extern void vm86_init(void); |
||
224 | |||
479 | giacomo | 225 | static int vesafb_set_par(struct fb_info *info) |
226 | { |
||
227 | |||
228 | ModeInfoBlock ModeInfo; |
||
229 | int wx,wy,bpp,mode; |
||
230 | int video_cmap_len; |
||
231 | |||
232 | wx = info->var.xres; |
||
233 | wy = info->var.yres; |
||
234 | bpp = info->var.bits_per_pixel; |
||
235 | |||
236 | mode = vbe_modenum(wx,wy,bpp); |
||
237 | if (mode == -1) return -1; |
||
238 | |||
239 | screen_info.lfb_base = vbe_getmodeinfo(&ModeInfo,mode); |
||
240 | |||
241 | screen_info.orig_video_isVGA = VIDEO_TYPE_VLFB; |
||
242 | |||
243 | if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB) |
||
244 | return -ENXIO; |
||
245 | |||
246 | screen_info.lfb_depth = ModeInfo.BitsPerPixel; |
||
247 | screen_info.lfb_width = ModeInfo.XResolution; |
||
248 | screen_info.lfb_height = ModeInfo.YResolution; |
||
249 | screen_info.lfb_linelength = ModeInfo.BytesPerScanLine; |
||
250 | screen_info.lfb_size = VbeInfo.TotalMemory; |
||
251 | screen_info.pages = ModeInfo.NumberOfImagePages; |
||
252 | |||
253 | screen_info.vesapm_seg = 0; |
||
254 | screen_info.vesapm_off = 0; |
||
255 | |||
256 | screen_info.red_pos = ModeInfo.RedFieldPosition; |
||
257 | screen_info.red_size = ModeInfo.RedMaskSize; |
||
258 | screen_info.green_pos = ModeInfo.GreenFieldPosition; |
||
259 | screen_info.green_size = ModeInfo.GreenMaskSize; |
||
260 | screen_info.blue_pos = ModeInfo.BlueFieldPosition; |
||
261 | screen_info.blue_size = ModeInfo.BlueMaskSize; |
||
262 | screen_info.rsvd_pos = ModeInfo.RsvdFieldPosition; |
||
263 | screen_info.rsvd_size = ModeInfo.RsvdMaskSize; |
||
264 | |||
265 | vbe_setmode(mode); |
||
266 | |||
267 | info->fix.smem_start = screen_info.lfb_base; |
||
268 | info->var.bits_per_pixel = screen_info.lfb_depth; |
||
269 | if (15 == info->var.bits_per_pixel) |
||
270 | info->var.bits_per_pixel = 16; |
||
271 | info->var.xres = screen_info.lfb_width; |
||
272 | info->var.yres = screen_info.lfb_height; |
||
273 | info->fix.line_length = screen_info.lfb_linelength; |
||
274 | info->fix.smem_len = screen_info.lfb_size; |
||
275 | info->fix.visual = (info->var.bits_per_pixel == 8) ? |
||
276 | FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
||
277 | |||
278 | /* limit framebuffer size to 16 MB. Otherwise we'll eat tons of |
||
279 | * kernel address space for nothing if the gfx card has alot of |
||
280 | * memory (>= 128 MB isn't uncommon these days ...) */ |
||
281 | if (info->fix.smem_len > 16 * 1024 * 1024) |
||
282 | info->fix.smem_len = 16 * 1024 * 1024; |
||
283 | |||
482 | giacomo | 284 | fb_info.screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len); |
285 | |||
479 | giacomo | 286 | /* some dummy values for timing to make fbset happy */ |
287 | info->var.pixclock = 10000000 / info->var.xres * 1000 / info->var.yres; |
||
288 | info->var.left_margin = (info->var.xres / 8) & 0xf8; |
||
289 | info->var.hsync_len = (info->var.xres / 8) & 0xf8; |
||
290 | |||
291 | if (info->var.bits_per_pixel > 8) { |
||
292 | info->var.red.offset = screen_info.red_pos; |
||
293 | info->var.red.length = screen_info.red_size; |
||
294 | info->var.green.offset = screen_info.green_pos; |
||
295 | info->var.green.length = screen_info.green_size; |
||
296 | info->var.blue.offset = screen_info.blue_pos; |
||
297 | info->var.blue.length = screen_info.blue_size; |
||
298 | info->var.transp.offset = screen_info.rsvd_pos; |
||
299 | info->var.transp.length = screen_info.rsvd_size; |
||
300 | video_cmap_len = 16; |
||
301 | } else { |
||
302 | info->var.red.length = 6; |
||
303 | info->var.green.length = 6; |
||
304 | info->var.blue.length = 6; |
||
305 | video_cmap_len = 256; |
||
306 | } |
||
307 | |||
308 | info->fix.ypanstep = ypan ? 1 : 0; |
||
309 | info->fix.ywrapstep = (ypan>1) ? 1 : 0; |
||
310 | |||
311 | return 0; |
||
312 | |||
313 | } |
||
314 | |||
315 | static int vesafb_check_var(struct fb_var_screeninfo *var, |
||
316 | struct fb_info *info) |
||
317 | { |
||
318 | |||
319 | return 0; |
||
320 | |||
321 | } |
||
322 | |||
323 | static struct fb_ops vesafb_ops = { |
||
324 | .owner = THIS_MODULE, |
||
325 | .fb_setcolreg = vesafb_setcolreg, |
||
326 | .fb_pan_display = vesafb_pan_display, |
||
327 | .fb_set_par = vesafb_set_par, |
||
328 | .fb_check_var = vesafb_check_var, |
||
329 | .fb_fillrect = cfb_fillrect, |
||
330 | .fb_copyarea = cfb_copyarea, |
||
331 | .fb_imageblit = cfb_imageblit, |
||
332 | .fb_cursor = soft_cursor, |
||
333 | .fb_release = vesafb_release, |
||
334 | }; |
||
335 | |||
336 | |||
466 | giacomo | 337 | int __init vesafb_init(void) |
338 | { |
||
477 | giacomo | 339 | ModeInfoBlock ModeInfo; |
466 | giacomo | 340 | int video_cmap_len; |
341 | int i; |
||
342 | |||
477 | giacomo | 343 | vm86_init(); |
344 | |||
345 | if (vbe_getinfo()) |
||
346 | return -EIO; |
||
347 | |||
348 | printk(KERN_INFO "VBE Extension Found.\n"); |
||
349 | |||
350 | screen_info.lfb_base = vbe_getmodeinfo(&ModeInfo,INIT_MODE); |
||
351 | |||
352 | screen_info.orig_video_isVGA = VIDEO_TYPE_VLFB; |
||
353 | |||
466 | giacomo | 354 | if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB) |
355 | return -ENXIO; |
||
356 | |||
477 | giacomo | 357 | screen_info.lfb_depth = ModeInfo.BitsPerPixel; |
358 | screen_info.lfb_width = ModeInfo.XResolution; |
||
359 | screen_info.lfb_height = ModeInfo.YResolution; |
||
360 | screen_info.lfb_linelength = ModeInfo.BytesPerScanLine; |
||
361 | screen_info.lfb_size = VbeInfo.TotalMemory; |
||
362 | screen_info.pages = ModeInfo.NumberOfImagePages; |
||
363 | |||
364 | screen_info.vesapm_seg = 0; |
||
365 | screen_info.vesapm_off = 0; |
||
366 | |||
367 | screen_info.red_pos = ModeInfo.RedFieldPosition; |
||
368 | screen_info.red_size = ModeInfo.RedMaskSize; |
||
369 | screen_info.green_pos = ModeInfo.GreenFieldPosition; |
||
370 | screen_info.green_size = ModeInfo.GreenMaskSize; |
||
371 | screen_info.blue_pos = ModeInfo.BlueFieldPosition; |
||
372 | screen_info.blue_size = ModeInfo.BlueMaskSize; |
||
373 | screen_info.rsvd_pos = ModeInfo.RsvdFieldPosition; |
||
374 | screen_info.rsvd_size = ModeInfo.RsvdMaskSize; |
||
375 | |||
376 | vbe_setmode(INIT_MODE); |
||
377 | |||
466 | giacomo | 378 | vesafb_fix.smem_start = screen_info.lfb_base; |
379 | vesafb_defined.bits_per_pixel = screen_info.lfb_depth; |
||
380 | if (15 == vesafb_defined.bits_per_pixel) |
||
381 | vesafb_defined.bits_per_pixel = 16; |
||
382 | vesafb_defined.xres = screen_info.lfb_width; |
||
383 | vesafb_defined.yres = screen_info.lfb_height; |
||
384 | vesafb_fix.line_length = screen_info.lfb_linelength; |
||
477 | giacomo | 385 | vesafb_fix.smem_len = screen_info.lfb_size; |
466 | giacomo | 386 | vesafb_fix.visual = (vesafb_defined.bits_per_pixel == 8) ? |
387 | FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
||
388 | |||
389 | /* limit framebuffer size to 16 MB. Otherwise we'll eat tons of |
||
390 | * kernel address space for nothing if the gfx card has alot of |
||
391 | * memory (>= 128 MB isn't uncommon these days ...) */ |
||
392 | if (vesafb_fix.smem_len > 16 * 1024 * 1024) |
||
393 | vesafb_fix.smem_len = 16 * 1024 * 1024; |
||
394 | |||
395 | #ifndef __i386__ |
||
396 | screen_info.vesapm_seg = 0; |
||
397 | #endif |
||
398 | |||
399 | if (!request_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len, "vesafb")) { |
||
400 | printk(KERN_WARNING |
||
401 | "vesafb: abort, cannot reserve video memory at 0x%lx\n", |
||
402 | vesafb_fix.smem_start); |
||
403 | /* We cannot make this fatal. Sometimes this comes from magic |
||
404 | spaces our resource handlers simply don't know about */ |
||
405 | } |
||
406 | |||
407 | fb_info.screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len); |
||
408 | if (!fb_info.screen_base) { |
||
409 | release_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len); |
||
410 | printk(KERN_ERR |
||
411 | "vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n", |
||
412 | vesafb_fix.smem_len, vesafb_fix.smem_start); |
||
413 | return -EIO; |
||
414 | } |
||
415 | |||
416 | printk(KERN_INFO "vesafb: framebuffer at 0x%lx, mapped to 0x%p, size %dk\n", |
||
417 | vesafb_fix.smem_start, fb_info.screen_base, vesafb_fix.smem_len/1024); |
||
418 | printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n", |
||
419 | vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages); |
||
420 | |||
421 | if (screen_info.vesapm_seg) { |
||
422 | printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n", |
||
423 | screen_info.vesapm_seg,screen_info.vesapm_off); |
||
424 | } |
||
425 | |||
426 | if (screen_info.vesapm_seg < 0xc000) |
||
427 | ypan = pmi_setpal = 0; /* not available or some DOS TSR ... */ |
||
428 | |||
429 | if (ypan || pmi_setpal) { |
||
430 | pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off); |
||
431 | pmi_start = (void*)((char*)pmi_base + pmi_base[1]); |
||
432 | pmi_pal = (void*)((char*)pmi_base + pmi_base[2]); |
||
433 | printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal); |
||
434 | if (pmi_base[3]) { |
||
435 | printk(KERN_INFO "vesafb: pmi: ports = "); |
||
436 | for (i = pmi_base[3]/2; pmi_base[i] != 0xffff; i++) |
||
437 | printk("%x ",pmi_base[i]); |
||
438 | printk("\n"); |
||
477 | giacomo | 439 | |
466 | giacomo | 440 | if (pmi_base[i] != 0xffff) { |
441 | /* |
||
442 | * memory areas not supported (yet?) |
||
443 | * |
||
444 | * Rules are: we have to set up a descriptor for the requested |
||
445 | * memory area and pass it in the ES register to the BIOS function. |
||
446 | */ |
||
447 | printk(KERN_INFO "vesafb: can't handle memory requests, pmi disabled\n"); |
||
448 | ypan = pmi_setpal = 0; |
||
449 | } |
||
450 | } |
||
451 | } |
||
452 | |||
453 | vesafb_defined.xres_virtual = vesafb_defined.xres; |
||
454 | vesafb_defined.yres_virtual = vesafb_fix.smem_len / vesafb_fix.line_length; |
||
455 | if (ypan && vesafb_defined.yres_virtual > vesafb_defined.yres) { |
||
456 | printk(KERN_INFO "vesafb: scrolling: %s using protected mode interface, yres_virtual=%d\n", |
||
457 | (ypan > 1) ? "ywrap" : "ypan",vesafb_defined.yres_virtual); |
||
458 | } else { |
||
459 | printk(KERN_INFO "vesafb: scrolling: redraw\n"); |
||
460 | vesafb_defined.yres_virtual = vesafb_defined.yres; |
||
461 | ypan = 0; |
||
462 | } |
||
463 | |||
464 | /* some dummy values for timing to make fbset happy */ |
||
465 | vesafb_defined.pixclock = 10000000 / vesafb_defined.xres * 1000 / vesafb_defined.yres; |
||
466 | vesafb_defined.left_margin = (vesafb_defined.xres / 8) & 0xf8; |
||
467 | vesafb_defined.hsync_len = (vesafb_defined.xres / 8) & 0xf8; |
||
468 | |||
469 | if (vesafb_defined.bits_per_pixel > 8) { |
||
470 | vesafb_defined.red.offset = screen_info.red_pos; |
||
471 | vesafb_defined.red.length = screen_info.red_size; |
||
472 | vesafb_defined.green.offset = screen_info.green_pos; |
||
473 | vesafb_defined.green.length = screen_info.green_size; |
||
474 | vesafb_defined.blue.offset = screen_info.blue_pos; |
||
475 | vesafb_defined.blue.length = screen_info.blue_size; |
||
476 | vesafb_defined.transp.offset = screen_info.rsvd_pos; |
||
477 | vesafb_defined.transp.length = screen_info.rsvd_size; |
||
478 | printk(KERN_INFO "vesafb: directcolor: " |
||
479 | "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n", |
||
480 | screen_info.rsvd_size, |
||
481 | screen_info.red_size, |
||
482 | screen_info.green_size, |
||
483 | screen_info.blue_size, |
||
484 | screen_info.rsvd_pos, |
||
485 | screen_info.red_pos, |
||
486 | screen_info.green_pos, |
||
487 | screen_info.blue_pos); |
||
488 | video_cmap_len = 16; |
||
489 | } else { |
||
490 | vesafb_defined.red.length = 6; |
||
491 | vesafb_defined.green.length = 6; |
||
492 | vesafb_defined.blue.length = 6; |
||
493 | video_cmap_len = 256; |
||
494 | } |
||
495 | |||
496 | vesafb_fix.ypanstep = ypan ? 1 : 0; |
||
497 | vesafb_fix.ywrapstep = (ypan>1) ? 1 : 0; |
||
498 | |||
499 | /* request failure does not faze us, as vgacon probably has this |
||
500 | * region already (FIXME) */ |
||
501 | request_region(0x3c0, 32, "vesafb"); |
||
502 | |||
503 | if (mtrr) { |
||
504 | int temp_size = vesafb_fix.smem_len; |
||
505 | /* Find the largest power-of-two */ |
||
506 | while (temp_size & (temp_size - 1)) |
||
507 | temp_size &= (temp_size - 1); |
||
508 | |||
509 | /* Try and find a power of two to add */ |
||
510 | while (temp_size && mtrr_add(vesafb_fix.smem_start, temp_size, MTRR_TYPE_WRCOMB, 1)==-EINVAL) { |
||
511 | temp_size >>= 1; |
||
512 | } |
||
513 | } |
||
514 | |||
515 | fb_info.fbops = &vesafb_ops; |
||
516 | fb_info.var = vesafb_defined; |
||
517 | fb_info.fix = vesafb_fix; |
||
518 | fb_info.pseudo_palette = pseudo_palette; |
||
519 | fb_info.flags = FBINFO_FLAG_DEFAULT; |
||
520 | |||
521 | fb_alloc_cmap(&fb_info.cmap, video_cmap_len, 0); |
||
522 | |||
523 | if (register_framebuffer(&fb_info)<0) |
||
524 | return -EINVAL; |
||
525 | |||
526 | printk(KERN_INFO "fb%d: %s frame buffer device\n", |
||
527 | fb_info.node, fb_info.fix.id); |
||
528 | return 0; |
||
529 | } |
||
530 | |||
531 | /* |
||
532 | * Overrides for Emacs so that we follow Linus's tabbing style. |
||
533 | * --------------------------------------------------------------------------- |
||
534 | * Local variables: |
||
535 | * c-basic-offset: 8 |
||
536 | * End: |
||
537 | */ |
||
538 | |||
539 | MODULE_LICENSE("GPL"); |