Rev 478 | Rev 482 | 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 | |||
284 | /* some dummy values for timing to make fbset happy */ |
||
285 | info->var.pixclock = 10000000 / info->var.xres * 1000 / info->var.yres; |
||
286 | info->var.left_margin = (info->var.xres / 8) & 0xf8; |
||
287 | info->var.hsync_len = (info->var.xres / 8) & 0xf8; |
||
288 | |||
289 | if (info->var.bits_per_pixel > 8) { |
||
290 | info->var.red.offset = screen_info.red_pos; |
||
291 | info->var.red.length = screen_info.red_size; |
||
292 | info->var.green.offset = screen_info.green_pos; |
||
293 | info->var.green.length = screen_info.green_size; |
||
294 | info->var.blue.offset = screen_info.blue_pos; |
||
295 | info->var.blue.length = screen_info.blue_size; |
||
296 | info->var.transp.offset = screen_info.rsvd_pos; |
||
297 | info->var.transp.length = screen_info.rsvd_size; |
||
298 | video_cmap_len = 16; |
||
299 | } else { |
||
300 | info->var.red.length = 6; |
||
301 | info->var.green.length = 6; |
||
302 | info->var.blue.length = 6; |
||
303 | video_cmap_len = 256; |
||
304 | } |
||
305 | |||
306 | info->fix.ypanstep = ypan ? 1 : 0; |
||
307 | info->fix.ywrapstep = (ypan>1) ? 1 : 0; |
||
308 | |||
309 | return 0; |
||
310 | |||
311 | } |
||
312 | |||
313 | static int vesafb_check_var(struct fb_var_screeninfo *var, |
||
314 | struct fb_info *info) |
||
315 | { |
||
316 | |||
317 | return 0; |
||
318 | |||
319 | } |
||
320 | |||
321 | static struct fb_ops vesafb_ops = { |
||
322 | .owner = THIS_MODULE, |
||
323 | .fb_setcolreg = vesafb_setcolreg, |
||
324 | .fb_pan_display = vesafb_pan_display, |
||
325 | .fb_set_par = vesafb_set_par, |
||
326 | .fb_check_var = vesafb_check_var, |
||
327 | .fb_fillrect = cfb_fillrect, |
||
328 | .fb_copyarea = cfb_copyarea, |
||
329 | .fb_imageblit = cfb_imageblit, |
||
330 | .fb_cursor = soft_cursor, |
||
331 | .fb_release = vesafb_release, |
||
332 | }; |
||
333 | |||
334 | |||
466 | giacomo | 335 | int __init vesafb_init(void) |
336 | { |
||
477 | giacomo | 337 | ModeInfoBlock ModeInfo; |
466 | giacomo | 338 | int video_cmap_len; |
339 | int i; |
||
340 | |||
477 | giacomo | 341 | vm86_init(); |
342 | |||
343 | if (vbe_getinfo()) |
||
344 | return -EIO; |
||
345 | |||
346 | printk(KERN_INFO "VBE Extension Found.\n"); |
||
347 | |||
348 | screen_info.lfb_base = vbe_getmodeinfo(&ModeInfo,INIT_MODE); |
||
349 | |||
350 | screen_info.orig_video_isVGA = VIDEO_TYPE_VLFB; |
||
351 | |||
466 | giacomo | 352 | if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB) |
353 | return -ENXIO; |
||
354 | |||
477 | giacomo | 355 | screen_info.lfb_depth = ModeInfo.BitsPerPixel; |
356 | screen_info.lfb_width = ModeInfo.XResolution; |
||
357 | screen_info.lfb_height = ModeInfo.YResolution; |
||
358 | screen_info.lfb_linelength = ModeInfo.BytesPerScanLine; |
||
359 | screen_info.lfb_size = VbeInfo.TotalMemory; |
||
360 | screen_info.pages = ModeInfo.NumberOfImagePages; |
||
361 | |||
362 | screen_info.vesapm_seg = 0; |
||
363 | screen_info.vesapm_off = 0; |
||
364 | |||
365 | screen_info.red_pos = ModeInfo.RedFieldPosition; |
||
366 | screen_info.red_size = ModeInfo.RedMaskSize; |
||
367 | screen_info.green_pos = ModeInfo.GreenFieldPosition; |
||
368 | screen_info.green_size = ModeInfo.GreenMaskSize; |
||
369 | screen_info.blue_pos = ModeInfo.BlueFieldPosition; |
||
370 | screen_info.blue_size = ModeInfo.BlueMaskSize; |
||
371 | screen_info.rsvd_pos = ModeInfo.RsvdFieldPosition; |
||
372 | screen_info.rsvd_size = ModeInfo.RsvdMaskSize; |
||
373 | |||
374 | vbe_setmode(INIT_MODE); |
||
375 | |||
466 | giacomo | 376 | vesafb_fix.smem_start = screen_info.lfb_base; |
377 | vesafb_defined.bits_per_pixel = screen_info.lfb_depth; |
||
378 | if (15 == vesafb_defined.bits_per_pixel) |
||
379 | vesafb_defined.bits_per_pixel = 16; |
||
380 | vesafb_defined.xres = screen_info.lfb_width; |
||
381 | vesafb_defined.yres = screen_info.lfb_height; |
||
382 | vesafb_fix.line_length = screen_info.lfb_linelength; |
||
477 | giacomo | 383 | vesafb_fix.smem_len = screen_info.lfb_size; |
466 | giacomo | 384 | vesafb_fix.visual = (vesafb_defined.bits_per_pixel == 8) ? |
385 | FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
||
386 | |||
387 | /* limit framebuffer size to 16 MB. Otherwise we'll eat tons of |
||
388 | * kernel address space for nothing if the gfx card has alot of |
||
389 | * memory (>= 128 MB isn't uncommon these days ...) */ |
||
390 | if (vesafb_fix.smem_len > 16 * 1024 * 1024) |
||
391 | vesafb_fix.smem_len = 16 * 1024 * 1024; |
||
392 | |||
393 | #ifndef __i386__ |
||
394 | screen_info.vesapm_seg = 0; |
||
395 | #endif |
||
396 | |||
397 | if (!request_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len, "vesafb")) { |
||
398 | printk(KERN_WARNING |
||
399 | "vesafb: abort, cannot reserve video memory at 0x%lx\n", |
||
400 | vesafb_fix.smem_start); |
||
401 | /* We cannot make this fatal. Sometimes this comes from magic |
||
402 | spaces our resource handlers simply don't know about */ |
||
403 | } |
||
404 | |||
405 | fb_info.screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len); |
||
406 | if (!fb_info.screen_base) { |
||
407 | release_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len); |
||
408 | printk(KERN_ERR |
||
409 | "vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n", |
||
410 | vesafb_fix.smem_len, vesafb_fix.smem_start); |
||
411 | return -EIO; |
||
412 | } |
||
413 | |||
414 | printk(KERN_INFO "vesafb: framebuffer at 0x%lx, mapped to 0x%p, size %dk\n", |
||
415 | vesafb_fix.smem_start, fb_info.screen_base, vesafb_fix.smem_len/1024); |
||
416 | printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n", |
||
417 | vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages); |
||
418 | |||
419 | if (screen_info.vesapm_seg) { |
||
420 | printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n", |
||
421 | screen_info.vesapm_seg,screen_info.vesapm_off); |
||
422 | } |
||
423 | |||
424 | if (screen_info.vesapm_seg < 0xc000) |
||
425 | ypan = pmi_setpal = 0; /* not available or some DOS TSR ... */ |
||
426 | |||
427 | if (ypan || pmi_setpal) { |
||
428 | pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off); |
||
429 | pmi_start = (void*)((char*)pmi_base + pmi_base[1]); |
||
430 | pmi_pal = (void*)((char*)pmi_base + pmi_base[2]); |
||
431 | printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal); |
||
432 | if (pmi_base[3]) { |
||
433 | printk(KERN_INFO "vesafb: pmi: ports = "); |
||
434 | for (i = pmi_base[3]/2; pmi_base[i] != 0xffff; i++) |
||
435 | printk("%x ",pmi_base[i]); |
||
436 | printk("\n"); |
||
477 | giacomo | 437 | |
466 | giacomo | 438 | if (pmi_base[i] != 0xffff) { |
439 | /* |
||
440 | * memory areas not supported (yet?) |
||
441 | * |
||
442 | * Rules are: we have to set up a descriptor for the requested |
||
443 | * memory area and pass it in the ES register to the BIOS function. |
||
444 | */ |
||
445 | printk(KERN_INFO "vesafb: can't handle memory requests, pmi disabled\n"); |
||
446 | ypan = pmi_setpal = 0; |
||
447 | } |
||
448 | } |
||
449 | } |
||
450 | |||
451 | vesafb_defined.xres_virtual = vesafb_defined.xres; |
||
452 | vesafb_defined.yres_virtual = vesafb_fix.smem_len / vesafb_fix.line_length; |
||
453 | if (ypan && vesafb_defined.yres_virtual > vesafb_defined.yres) { |
||
454 | printk(KERN_INFO "vesafb: scrolling: %s using protected mode interface, yres_virtual=%d\n", |
||
455 | (ypan > 1) ? "ywrap" : "ypan",vesafb_defined.yres_virtual); |
||
456 | } else { |
||
457 | printk(KERN_INFO "vesafb: scrolling: redraw\n"); |
||
458 | vesafb_defined.yres_virtual = vesafb_defined.yres; |
||
459 | ypan = 0; |
||
460 | } |
||
461 | |||
462 | /* some dummy values for timing to make fbset happy */ |
||
463 | vesafb_defined.pixclock = 10000000 / vesafb_defined.xres * 1000 / vesafb_defined.yres; |
||
464 | vesafb_defined.left_margin = (vesafb_defined.xres / 8) & 0xf8; |
||
465 | vesafb_defined.hsync_len = (vesafb_defined.xres / 8) & 0xf8; |
||
466 | |||
467 | if (vesafb_defined.bits_per_pixel > 8) { |
||
468 | vesafb_defined.red.offset = screen_info.red_pos; |
||
469 | vesafb_defined.red.length = screen_info.red_size; |
||
470 | vesafb_defined.green.offset = screen_info.green_pos; |
||
471 | vesafb_defined.green.length = screen_info.green_size; |
||
472 | vesafb_defined.blue.offset = screen_info.blue_pos; |
||
473 | vesafb_defined.blue.length = screen_info.blue_size; |
||
474 | vesafb_defined.transp.offset = screen_info.rsvd_pos; |
||
475 | vesafb_defined.transp.length = screen_info.rsvd_size; |
||
476 | printk(KERN_INFO "vesafb: directcolor: " |
||
477 | "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n", |
||
478 | screen_info.rsvd_size, |
||
479 | screen_info.red_size, |
||
480 | screen_info.green_size, |
||
481 | screen_info.blue_size, |
||
482 | screen_info.rsvd_pos, |
||
483 | screen_info.red_pos, |
||
484 | screen_info.green_pos, |
||
485 | screen_info.blue_pos); |
||
486 | video_cmap_len = 16; |
||
487 | } else { |
||
488 | vesafb_defined.red.length = 6; |
||
489 | vesafb_defined.green.length = 6; |
||
490 | vesafb_defined.blue.length = 6; |
||
491 | video_cmap_len = 256; |
||
492 | } |
||
493 | |||
494 | vesafb_fix.ypanstep = ypan ? 1 : 0; |
||
495 | vesafb_fix.ywrapstep = (ypan>1) ? 1 : 0; |
||
496 | |||
497 | /* request failure does not faze us, as vgacon probably has this |
||
498 | * region already (FIXME) */ |
||
499 | request_region(0x3c0, 32, "vesafb"); |
||
500 | |||
501 | if (mtrr) { |
||
502 | int temp_size = vesafb_fix.smem_len; |
||
503 | /* Find the largest power-of-two */ |
||
504 | while (temp_size & (temp_size - 1)) |
||
505 | temp_size &= (temp_size - 1); |
||
506 | |||
507 | /* Try and find a power of two to add */ |
||
508 | while (temp_size && mtrr_add(vesafb_fix.smem_start, temp_size, MTRR_TYPE_WRCOMB, 1)==-EINVAL) { |
||
509 | temp_size >>= 1; |
||
510 | } |
||
511 | } |
||
512 | |||
513 | fb_info.fbops = &vesafb_ops; |
||
514 | fb_info.var = vesafb_defined; |
||
515 | fb_info.fix = vesafb_fix; |
||
516 | fb_info.pseudo_palette = pseudo_palette; |
||
517 | fb_info.flags = FBINFO_FLAG_DEFAULT; |
||
518 | |||
519 | fb_alloc_cmap(&fb_info.cmap, video_cmap_len, 0); |
||
520 | |||
521 | if (register_framebuffer(&fb_info)<0) |
||
522 | return -EINVAL; |
||
523 | |||
524 | printk(KERN_INFO "fb%d: %s frame buffer device\n", |
||
525 | fb_info.node, fb_info.fix.id); |
||
526 | return 0; |
||
527 | } |
||
528 | |||
529 | /* |
||
530 | * Overrides for Emacs so that we follow Linus's tabbing style. |
||
531 | * --------------------------------------------------------------------------- |
||
532 | * Local variables: |
||
533 | * c-basic-offset: 8 |
||
534 | * End: |
||
535 | */ |
||
536 | |||
537 | MODULE_LICENSE("GPL"); |