9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/errno.h>
14 #include <linux/screen_info.h>
16 #include <linux/pci.h>
19 static bool request_mem_succeeded =
false;
21 static struct pci_dev *default_vga;
76 #define OVERRIDE_NONE 0x0
77 #define OVERRIDE_BASE 0x1
78 #define OVERRIDE_STRIDE 0x2
79 #define OVERRIDE_HEIGHT 0x4
80 #define OVERRIDE_WIDTH 0x8
82 static struct efifb_dmi_info {
124 #define EFIFB_DMI_SYSTEM_ID(vendor, name, enumid) \
125 { set_system, name, { \
126 DMI_MATCH(DMI_BIOS_VENDOR, vendor), \
127 DMI_MATCH(DMI_PRODUCT_NAME, name) }, \
175 #define choose_value(dmivalue, fwvalue, field, flags) ({ \
176 typeof(fwvalue) _ret_ = fwvalue; \
177 if ((flags) & (field)) \
179 else if ((fwvalue) == 0) \
186 struct efifb_dmi_info *
info =
id->driver_data;
188 if (info->base == 0 && info->height == 0 && info->width == 0
189 && info->stride == 0)
194 #if defined(CONFIG_PCI)
203 #if defined(CONFIG_PCI)
250 "(%dx%d, stride %d)\n", id->
ident,
258 static int efifb_setcolreg(
unsigned regno,
unsigned red,
unsigned green,
269 if (regno >= info->
cmap.len)
277 (red << info->
var.red.offset) |
278 (green << info->
var.green.offset) |
279 (blue << info->
var.blue.offset);
284 static void efifb_destroy(
struct fb_info *info)
288 if (request_mem_succeeded)
294 static struct fb_ops efifb_ops = {
296 .fb_destroy = efifb_destroy,
297 .fb_setcolreg = efifb_setcolreg,
321 if (options && *options) {
322 while ((this_opt =
strsep(&options,
",")) !=
NULL) {
323 if (!*this_opt)
continue;
326 if (!
strcmp(this_opt, dmi_list[i].optname) &&
327 dmi_list[i].base != 0) {
334 if (!
strncmp(this_opt,
"base:", 5))
336 else if (!
strncmp(this_opt,
"stride:", 7))
338 else if (!
strncmp(this_opt,
"height:", 7))
340 else if (!
strncmp(this_opt,
"width:", 6))
376 unsigned int size_vmode;
377 unsigned int size_remap;
378 unsigned int size_total;
411 size_vmode = efifb_defined.yres * efifb_fix.line_length;
417 if (size_total < size_vmode)
418 size_total = size_vmode;
424 size_remap = size_vmode * 2;
425 if (size_remap > size_total)
426 size_remap = size_total;
428 size_remap += PAGE_SIZE - (size_remap %
PAGE_SIZE);
429 efifb_fix.smem_len = size_remap;
432 request_mem_succeeded =
true;
437 "efifb: cannot reserve video memory at 0x%lx\n",
438 efifb_fix.smem_start);
445 goto err_release_mem;
455 info->
apertures->ranges[0].base = efifb_fix.smem_start;
456 info->
apertures->ranges[0].size = size_remap;
462 efifb_fix.smem_len, efifb_fix.smem_start);
468 "using %dk, total %dk\n",
470 size_remap/1024, size_total/1024);
472 efifb_defined.xres, efifb_defined.yres,
473 efifb_defined.bits_per_pixel, efifb_fix.line_length,
476 efifb_defined.xres_virtual = efifb_defined.xres;
477 efifb_defined.yres_virtual = efifb_fix.smem_len /
478 efifb_fix.line_length;
480 efifb_defined.yres_virtual = efifb_defined.yres;
483 efifb_defined.pixclock = 10000000 / efifb_defined.xres *
484 1000 / efifb_defined.yres;
485 efifb_defined.left_margin = (efifb_defined.xres / 8) & 0xf8;
486 efifb_defined.hsync_len = (efifb_defined.xres / 8) & 0xf8;
498 "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
509 efifb_fix.ypanstep = 0;
510 efifb_fix.ywrapstep = 0;
512 info->
fbops = &efifb_ops;
513 info->
var = efifb_defined;
514 info->
fix = efifb_fix;
536 if (request_mem_succeeded)
551 static int __init efifb_init(
void)