]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - drivers/video/fbdev/efifb.c
3946649b85c8908f4e9874b837ccdad274af8499
[mirror_ubuntu-focal-kernel.git] / drivers / video / fbdev / efifb.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Framebuffer driver for EFI/UEFI based system
4 *
5 * (c) 2006 Edgar Hucek <gimli@dark-green.com>
6 * Original efi driver written by Gerd Knorr <kraxel@goldbach.in-berlin.de>
7 *
8 */
9
10 #include <linux/kernel.h>
11 #include <linux/efi.h>
12 #include <linux/efi-bgrt.h>
13 #include <linux/errno.h>
14 #include <linux/fb.h>
15 #include <linux/pci.h>
16 #include <linux/platform_device.h>
17 #include <linux/printk.h>
18 #include <linux/screen_info.h>
19 #include <video/vga.h>
20 #include <asm/efi.h>
21 #include <drm/drm_utils.h> /* For drm_get_panel_orientation_quirk */
22 #include <drm/drm_connector.h> /* For DRM_MODE_PANEL_ORIENTATION_* */
23
24 struct bmp_file_header {
25 u16 id;
26 u32 file_size;
27 u32 reserved;
28 u32 bitmap_offset;
29 } __packed;
30
31 struct bmp_dib_header {
32 u32 dib_header_size;
33 s32 width;
34 s32 height;
35 u16 planes;
36 u16 bpp;
37 u32 compression;
38 u32 bitmap_size;
39 u32 horz_resolution;
40 u32 vert_resolution;
41 u32 colors_used;
42 u32 colors_important;
43 } __packed;
44
45 static bool request_mem_succeeded = false;
46 static u64 mem_flags = EFI_MEMORY_WC | EFI_MEMORY_UC;
47
48 static struct fb_var_screeninfo efifb_defined = {
49 .activate = FB_ACTIVATE_NOW,
50 .height = -1,
51 .width = -1,
52 .right_margin = 32,
53 .upper_margin = 16,
54 .lower_margin = 4,
55 .vsync_len = 4,
56 .vmode = FB_VMODE_NONINTERLACED,
57 };
58
59 static struct fb_fix_screeninfo efifb_fix = {
60 .id = "EFI VGA",
61 .type = FB_TYPE_PACKED_PIXELS,
62 .accel = FB_ACCEL_NONE,
63 .visual = FB_VISUAL_TRUECOLOR,
64 };
65
66 static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green,
67 unsigned blue, unsigned transp,
68 struct fb_info *info)
69 {
70 /*
71 * Set a single color register. The values supplied are
72 * already rounded down to the hardware's capabilities
73 * (according to the entries in the `var' structure). Return
74 * != 0 for invalid regno.
75 */
76
77 if (regno >= info->cmap.len)
78 return 1;
79
80 if (regno < 16) {
81 red >>= 16 - info->var.red.length;
82 green >>= 16 - info->var.green.length;
83 blue >>= 16 - info->var.blue.length;
84 ((u32 *)(info->pseudo_palette))[regno] =
85 (red << info->var.red.offset) |
86 (green << info->var.green.offset) |
87 (blue << info->var.blue.offset);
88 }
89 return 0;
90 }
91
92 /*
93 * If fbcon deffered console takeover is configured, the intent is for the
94 * framebuffer to show the boot graphics (e.g. vendor logo) until there is some
95 * (error) message to display. But the boot graphics may have been destroyed by
96 * e.g. option ROM output, detect this and restore the boot graphics.
97 */
98 #if defined CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER && \
99 defined CONFIG_ACPI_BGRT
100 static void efifb_copy_bmp(u8 *src, u32 *dst, int width, struct screen_info *si)
101 {
102 u8 r, g, b;
103
104 while (width--) {
105 b = *src++;
106 g = *src++;
107 r = *src++;
108 *dst++ = (r << si->red_pos) |
109 (g << si->green_pos) |
110 (b << si->blue_pos);
111 }
112 }
113
114 #ifdef CONFIG_X86
115 /*
116 * On x86 some firmwares use a low non native resolution for the display when
117 * they have shown some text messages. While keeping the bgrt filled with info
118 * for the native resolution. If the bgrt image intended for the native
119 * resolution still fits, it will be displayed very close to the right edge of
120 * the display looking quite bad. This function checks for this.
121 */
122 static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width)
123 {
124 static const int default_resolutions[][2] = {
125 { 800, 600 },
126 { 1024, 768 },
127 { 1280, 1024 },
128 };
129 u32 i, right_margin;
130
131 for (i = 0; i < ARRAY_SIZE(default_resolutions); i++) {
132 if (default_resolutions[i][0] == si->lfb_width &&
133 default_resolutions[i][1] == si->lfb_height)
134 break;
135 }
136 /* If not a default resolution used for textmode, this should be fine */
137 if (i >= ARRAY_SIZE(default_resolutions))
138 return true;
139
140 /* If the right margin is 5 times smaller then the left one, reject */
141 right_margin = si->lfb_width - (bgrt_tab.image_offset_x + bmp_width);
142 if (right_margin < (bgrt_tab.image_offset_x / 5))
143 return false;
144
145 return true;
146 }
147 #else
148 static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width)
149 {
150 return true;
151 }
152 #endif
153
154 static void efifb_show_boot_graphics(struct fb_info *info)
155 {
156 u32 bmp_width, bmp_height, bmp_pitch, screen_pitch, dst_x, y, src_y;
157 struct screen_info *si = &screen_info;
158 struct bmp_file_header *file_header;
159 struct bmp_dib_header *dib_header;
160 void *bgrt_image = NULL;
161 u8 *dst = info->screen_base;
162
163 if (!bgrt_tab.image_address) {
164 pr_info("efifb: No BGRT, not showing boot graphics\n");
165 return;
166 }
167
168 /* Avoid flashing the logo if we're going to print std probe messages */
169 if (console_loglevel > CONSOLE_LOGLEVEL_QUIET)
170 return;
171
172 /* bgrt_tab.status is unreliable, so we don't check it */
173
174 if (si->lfb_depth != 32) {
175 pr_info("efifb: not 32 bits, not showing boot graphics\n");
176 return;
177 }
178
179 bgrt_image = memremap(bgrt_tab.image_address, bgrt_image_size,
180 MEMREMAP_WB);
181 if (!bgrt_image) {
182 pr_warn("efifb: Ignoring BGRT: failed to map image memory\n");
183 return;
184 }
185
186 if (bgrt_image_size < (sizeof(*file_header) + sizeof(*dib_header)))
187 goto error;
188
189 file_header = bgrt_image;
190 if (file_header->id != 0x4d42 || file_header->reserved != 0)
191 goto error;
192
193 dib_header = bgrt_image + sizeof(*file_header);
194 if (dib_header->dib_header_size != 40 || dib_header->width < 0 ||
195 dib_header->planes != 1 || dib_header->bpp != 24 ||
196 dib_header->compression != 0)
197 goto error;
198
199 bmp_width = dib_header->width;
200 bmp_height = abs(dib_header->height);
201 bmp_pitch = round_up(3 * bmp_width, 4);
202 screen_pitch = si->lfb_linelength;
203
204 if ((file_header->bitmap_offset + bmp_pitch * bmp_height) >
205 bgrt_image_size)
206 goto error;
207
208 if ((bgrt_tab.image_offset_x + bmp_width) > si->lfb_width ||
209 (bgrt_tab.image_offset_y + bmp_height) > si->lfb_height)
210 goto error;
211
212 if (!efifb_bgrt_sanity_check(si, bmp_width))
213 goto error;
214
215 pr_info("efifb: showing boot graphics\n");
216
217 for (y = 0; y < si->lfb_height; y++, dst += si->lfb_linelength) {
218 /* Only background? */
219 if (y < bgrt_tab.image_offset_y ||
220 y >= (bgrt_tab.image_offset_y + bmp_height)) {
221 memset(dst, 0, 4 * si->lfb_width);
222 continue;
223 }
224
225 src_y = y - bgrt_tab.image_offset_y;
226 /* Positive header height means upside down row order */
227 if (dib_header->height > 0)
228 src_y = (bmp_height - 1) - src_y;
229
230 memset(dst, 0, bgrt_tab.image_offset_x * 4);
231 dst_x = bgrt_tab.image_offset_x;
232 efifb_copy_bmp(bgrt_image + file_header->bitmap_offset +
233 src_y * bmp_pitch,
234 (u32 *)dst + dst_x, bmp_width, si);
235 dst_x += bmp_width;
236 memset((u32 *)dst + dst_x, 0, (si->lfb_width - dst_x) * 4);
237 }
238
239 memunmap(bgrt_image);
240 return;
241
242 error:
243 memunmap(bgrt_image);
244 pr_warn("efifb: Ignoring BGRT: unexpected or invalid BMP data\n");
245 }
246 #else
247 static inline void efifb_show_boot_graphics(struct fb_info *info) {}
248 #endif
249
250 static void efifb_destroy(struct fb_info *info)
251 {
252 if (info->screen_base) {
253 if (mem_flags & (EFI_MEMORY_UC | EFI_MEMORY_WC))
254 iounmap(info->screen_base);
255 else
256 memunmap(info->screen_base);
257 }
258 if (request_mem_succeeded)
259 release_mem_region(info->apertures->ranges[0].base,
260 info->apertures->ranges[0].size);
261 fb_dealloc_cmap(&info->cmap);
262 }
263
264 static struct fb_ops efifb_ops = {
265 .owner = THIS_MODULE,
266 .fb_destroy = efifb_destroy,
267 .fb_setcolreg = efifb_setcolreg,
268 .fb_fillrect = cfb_fillrect,
269 .fb_copyarea = cfb_copyarea,
270 .fb_imageblit = cfb_imageblit,
271 };
272
273 static int efifb_setup(char *options)
274 {
275 char *this_opt;
276
277 if (options && *options) {
278 while ((this_opt = strsep(&options, ",")) != NULL) {
279 if (!*this_opt) continue;
280
281 efifb_setup_from_dmi(&screen_info, this_opt);
282
283 if (!strncmp(this_opt, "base:", 5))
284 screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0);
285 else if (!strncmp(this_opt, "stride:", 7))
286 screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
287 else if (!strncmp(this_opt, "height:", 7))
288 screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0);
289 else if (!strncmp(this_opt, "width:", 6))
290 screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0);
291 else if (!strcmp(this_opt, "nowc"))
292 mem_flags &= ~EFI_MEMORY_WC;
293 }
294 }
295
296 return 0;
297 }
298
299 static inline bool fb_base_is_valid(void)
300 {
301 if (screen_info.lfb_base)
302 return true;
303
304 if (!(screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE))
305 return false;
306
307 if (screen_info.ext_lfb_base)
308 return true;
309
310 return false;
311 }
312
313 #define efifb_attr_decl(name, fmt) \
314 static ssize_t name##_show(struct device *dev, \
315 struct device_attribute *attr, \
316 char *buf) \
317 { \
318 return sprintf(buf, fmt "\n", (screen_info.lfb_##name)); \
319 } \
320 static DEVICE_ATTR_RO(name)
321
322 efifb_attr_decl(base, "0x%x");
323 efifb_attr_decl(linelength, "%u");
324 efifb_attr_decl(height, "%u");
325 efifb_attr_decl(width, "%u");
326 efifb_attr_decl(depth, "%u");
327
328 static struct attribute *efifb_attrs[] = {
329 &dev_attr_base.attr,
330 &dev_attr_linelength.attr,
331 &dev_attr_width.attr,
332 &dev_attr_height.attr,
333 &dev_attr_depth.attr,
334 NULL
335 };
336 ATTRIBUTE_GROUPS(efifb);
337
338 static bool pci_dev_disabled; /* FB base matches BAR of a disabled device */
339
340 static struct pci_dev *efifb_pci_dev; /* dev with BAR covering the efifb */
341 static struct resource *bar_resource;
342 static u64 bar_offset;
343
344 static int efifb_probe(struct platform_device *dev)
345 {
346 struct fb_info *info;
347 int err, orientation;
348 unsigned int size_vmode;
349 unsigned int size_remap;
350 unsigned int size_total;
351 char *option = NULL;
352 efi_memory_desc_t md;
353
354 if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
355 return -ENODEV;
356
357 if (fb_get_options("efifb", &option))
358 return -ENODEV;
359 efifb_setup(option);
360
361 /* We don't get linelength from UGA Draw Protocol, only from
362 * EFI Graphics Protocol. So if it's not in DMI, and it's not
363 * passed in from the user, we really can't use the framebuffer.
364 */
365 if (!screen_info.lfb_linelength)
366 return -ENODEV;
367
368 if (!screen_info.lfb_depth)
369 screen_info.lfb_depth = 32;
370 if (!screen_info.pages)
371 screen_info.pages = 1;
372 if (!fb_base_is_valid()) {
373 printk(KERN_DEBUG "efifb: invalid framebuffer address\n");
374 return -ENODEV;
375 }
376 printk(KERN_INFO "efifb: probing for efifb\n");
377
378 /* just assume they're all unset if any are */
379 if (!screen_info.blue_size) {
380 screen_info.blue_size = 8;
381 screen_info.blue_pos = 0;
382 screen_info.green_size = 8;
383 screen_info.green_pos = 8;
384 screen_info.red_size = 8;
385 screen_info.red_pos = 16;
386 screen_info.rsvd_size = 8;
387 screen_info.rsvd_pos = 24;
388 }
389
390 efifb_fix.smem_start = screen_info.lfb_base;
391
392 if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
393 u64 ext_lfb_base;
394
395 ext_lfb_base = (u64)(unsigned long)screen_info.ext_lfb_base << 32;
396 efifb_fix.smem_start |= ext_lfb_base;
397 }
398
399 if (bar_resource &&
400 bar_resource->start + bar_offset != efifb_fix.smem_start) {
401 dev_info(&efifb_pci_dev->dev,
402 "BAR has moved, updating efifb address\n");
403 efifb_fix.smem_start = bar_resource->start + bar_offset;
404 }
405
406 efifb_defined.bits_per_pixel = screen_info.lfb_depth;
407 efifb_defined.xres = screen_info.lfb_width;
408 efifb_defined.yres = screen_info.lfb_height;
409 efifb_fix.line_length = screen_info.lfb_linelength;
410
411 /* size_vmode -- that is the amount of memory needed for the
412 * used video mode, i.e. the minimum amount of
413 * memory we need. */
414 size_vmode = efifb_defined.yres * efifb_fix.line_length;
415
416 /* size_total -- all video memory we have. Used for
417 * entries, ressource allocation and bounds
418 * checking. */
419 size_total = screen_info.lfb_size;
420 if (size_total < size_vmode)
421 size_total = size_vmode;
422
423 /* size_remap -- the amount of video memory we are going to
424 * use for efifb. With modern cards it is no
425 * option to simply use size_total as that
426 * wastes plenty of kernel address space. */
427 size_remap = size_vmode * 2;
428 if (size_remap > size_total)
429 size_remap = size_total;
430 if (size_remap % PAGE_SIZE)
431 size_remap += PAGE_SIZE - (size_remap % PAGE_SIZE);
432 efifb_fix.smem_len = size_remap;
433
434 if (request_mem_region(efifb_fix.smem_start, size_remap, "efifb")) {
435 request_mem_succeeded = true;
436 } else {
437 /* We cannot make this fatal. Sometimes this comes from magic
438 spaces our resource handlers simply don't know about */
439 pr_warn("efifb: cannot reserve video memory at 0x%lx\n",
440 efifb_fix.smem_start);
441 }
442
443 info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev);
444 if (!info) {
445 pr_err("efifb: cannot allocate framebuffer\n");
446 err = -ENOMEM;
447 goto err_release_mem;
448 }
449 platform_set_drvdata(dev, info);
450 info->pseudo_palette = info->par;
451 info->par = NULL;
452
453 info->apertures = alloc_apertures(1);
454 if (!info->apertures) {
455 err = -ENOMEM;
456 goto err_release_fb;
457 }
458 info->apertures->ranges[0].base = efifb_fix.smem_start;
459 info->apertures->ranges[0].size = size_remap;
460
461 if (!efi_mem_desc_lookup(efifb_fix.smem_start, &md)) {
462 if ((efifb_fix.smem_start + efifb_fix.smem_len) >
463 (md.phys_addr + (md.num_pages << EFI_PAGE_SHIFT))) {
464 pr_err("efifb: video memory @ 0x%lx spans multiple EFI memory regions\n",
465 efifb_fix.smem_start);
466 err = -EIO;
467 goto err_release_fb;
468 }
469 /*
470 * If the UEFI memory map covers the efifb region, we may only
471 * remap it using the attributes the memory map prescribes.
472 */
473 mem_flags |= EFI_MEMORY_WT | EFI_MEMORY_WB;
474 mem_flags &= md.attribute;
475 }
476 if (mem_flags & EFI_MEMORY_WC)
477 info->screen_base = ioremap_wc(efifb_fix.smem_start,
478 efifb_fix.smem_len);
479 else if (mem_flags & EFI_MEMORY_UC)
480 info->screen_base = ioremap(efifb_fix.smem_start,
481 efifb_fix.smem_len);
482 else if (mem_flags & EFI_MEMORY_WT)
483 info->screen_base = memremap(efifb_fix.smem_start,
484 efifb_fix.smem_len, MEMREMAP_WT);
485 else if (mem_flags & EFI_MEMORY_WB)
486 info->screen_base = memremap(efifb_fix.smem_start,
487 efifb_fix.smem_len, MEMREMAP_WB);
488 if (!info->screen_base) {
489 pr_err("efifb: abort, cannot remap video memory 0x%x @ 0x%lx\n",
490 efifb_fix.smem_len, efifb_fix.smem_start);
491 err = -EIO;
492 goto err_release_fb;
493 }
494
495 efifb_show_boot_graphics(info);
496
497 pr_info("efifb: framebuffer at 0x%lx, using %dk, total %dk\n",
498 efifb_fix.smem_start, size_remap/1024, size_total/1024);
499 pr_info("efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
500 efifb_defined.xres, efifb_defined.yres,
501 efifb_defined.bits_per_pixel, efifb_fix.line_length,
502 screen_info.pages);
503
504 efifb_defined.xres_virtual = efifb_defined.xres;
505 efifb_defined.yres_virtual = efifb_fix.smem_len /
506 efifb_fix.line_length;
507 pr_info("efifb: scrolling: redraw\n");
508 efifb_defined.yres_virtual = efifb_defined.yres;
509
510 /* some dummy values for timing to make fbset happy */
511 efifb_defined.pixclock = 10000000 / efifb_defined.xres *
512 1000 / efifb_defined.yres;
513 efifb_defined.left_margin = (efifb_defined.xres / 8) & 0xf8;
514 efifb_defined.hsync_len = (efifb_defined.xres / 8) & 0xf8;
515
516 efifb_defined.red.offset = screen_info.red_pos;
517 efifb_defined.red.length = screen_info.red_size;
518 efifb_defined.green.offset = screen_info.green_pos;
519 efifb_defined.green.length = screen_info.green_size;
520 efifb_defined.blue.offset = screen_info.blue_pos;
521 efifb_defined.blue.length = screen_info.blue_size;
522 efifb_defined.transp.offset = screen_info.rsvd_pos;
523 efifb_defined.transp.length = screen_info.rsvd_size;
524
525 pr_info("efifb: %s: "
526 "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
527 "Truecolor",
528 screen_info.rsvd_size,
529 screen_info.red_size,
530 screen_info.green_size,
531 screen_info.blue_size,
532 screen_info.rsvd_pos,
533 screen_info.red_pos,
534 screen_info.green_pos,
535 screen_info.blue_pos);
536
537 efifb_fix.ypanstep = 0;
538 efifb_fix.ywrapstep = 0;
539
540 info->fbops = &efifb_ops;
541 info->var = efifb_defined;
542 info->fix = efifb_fix;
543 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE;
544
545 orientation = drm_get_panel_orientation_quirk(efifb_defined.xres,
546 efifb_defined.yres);
547 switch (orientation) {
548 default:
549 info->fbcon_rotate_hint = FB_ROTATE_UR;
550 break;
551 case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
552 info->fbcon_rotate_hint = FB_ROTATE_UD;
553 break;
554 case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
555 info->fbcon_rotate_hint = FB_ROTATE_CCW;
556 break;
557 case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
558 info->fbcon_rotate_hint = FB_ROTATE_CW;
559 break;
560 }
561
562 err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
563 if (err) {
564 pr_err("efifb: cannot add sysfs attrs\n");
565 goto err_unmap;
566 }
567 err = fb_alloc_cmap(&info->cmap, 256, 0);
568 if (err < 0) {
569 pr_err("efifb: cannot allocate colormap\n");
570 goto err_groups;
571 }
572 err = register_framebuffer(info);
573 if (err < 0) {
574 pr_err("efifb: cannot register framebuffer\n");
575 goto err_fb_dealoc;
576 }
577 fb_info(info, "%s frame buffer device\n", info->fix.id);
578 return 0;
579
580 err_fb_dealoc:
581 fb_dealloc_cmap(&info->cmap);
582 err_groups:
583 sysfs_remove_groups(&dev->dev.kobj, efifb_groups);
584 err_unmap:
585 if (mem_flags & (EFI_MEMORY_UC | EFI_MEMORY_WC))
586 iounmap(info->screen_base);
587 else
588 memunmap(info->screen_base);
589 err_release_fb:
590 framebuffer_release(info);
591 err_release_mem:
592 if (request_mem_succeeded)
593 release_mem_region(efifb_fix.smem_start, size_total);
594 return err;
595 }
596
597 static int efifb_remove(struct platform_device *pdev)
598 {
599 struct fb_info *info = platform_get_drvdata(pdev);
600
601 unregister_framebuffer(info);
602 sysfs_remove_groups(&pdev->dev.kobj, efifb_groups);
603 framebuffer_release(info);
604
605 return 0;
606 }
607
608 static struct platform_driver efifb_driver = {
609 .driver = {
610 .name = "efi-framebuffer",
611 },
612 .probe = efifb_probe,
613 .remove = efifb_remove,
614 };
615
616 builtin_platform_driver(efifb_driver);
617
618 #if defined(CONFIG_PCI)
619
620 static void record_efifb_bar_resource(struct pci_dev *dev, int idx, u64 offset)
621 {
622 u16 word;
623
624 efifb_pci_dev = dev;
625
626 pci_read_config_word(dev, PCI_COMMAND, &word);
627 if (!(word & PCI_COMMAND_MEMORY)) {
628 pci_dev_disabled = true;
629 dev_err(&dev->dev,
630 "BAR %d: assigned to efifb but device is disabled!\n",
631 idx);
632 return;
633 }
634
635 bar_resource = &dev->resource[idx];
636 bar_offset = offset;
637
638 dev_info(&dev->dev, "BAR %d: assigned to efifb\n", idx);
639 }
640
641 static void efifb_fixup_resources(struct pci_dev *dev)
642 {
643 u64 base = screen_info.lfb_base;
644 u64 size = screen_info.lfb_size;
645 int i;
646
647 if (efifb_pci_dev || screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
648 return;
649
650 if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
651 base |= (u64)screen_info.ext_lfb_base << 32;
652
653 if (!base)
654 return;
655
656 for (i = 0; i <= PCI_STD_RESOURCE_END; i++) {
657 struct resource *res = &dev->resource[i];
658
659 if (!(res->flags & IORESOURCE_MEM))
660 continue;
661
662 if (res->start <= base && res->end >= base + size - 1) {
663 record_efifb_bar_resource(dev, i, base - res->start);
664 break;
665 }
666 }
667 }
668 DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY,
669 16, efifb_fixup_resources);
670
671 #endif