Skip to content

Commit 228abe7

Browse files
committed
Merge branch 'x86-fb-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fb changes from Ingo Molnar: "This tree includes preparatory patches for SimpleDRM driver support, by David Herrmann. They clean up x86 framebuffer support by creating simplefb devices wherever possible. More background can be found at http://lwn.net/Articles/558104/" * 'x86-fb-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: fbdev: fbcon: select VT_HW_CONSOLE_BINDING fbdev: efifb: bind to efi-framebuffer fbdev: vesafb: bind to platform-framebuffer device fbdev: simplefb: add common x86 RGB formats x86: sysfb: move EFI quirks from efifb to sysfb x86: provide platform-devices for boot-framebuffers fbdev: simplefb: mark as fw and allocate apertures fbdev: simplefb: add init through platform_data
2 parents 1f9c52e + 765d5b9 commit 228abe7

File tree

12 files changed

+666
-330
lines changed

12 files changed

+666
-330
lines changed

arch/x86/Kconfig

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,32 @@ config RAPIDIO
22702270

22712271
source "drivers/rapidio/Kconfig"
22722272

2273+
config X86_SYSFB
2274+
bool "Mark VGA/VBE/EFI FB as generic system framebuffer"
2275+
help
2276+
Firmwares often provide initial graphics framebuffers so the BIOS,
2277+
bootloader or kernel can show basic video-output during boot for
2278+
user-guidance and debugging. Historically, x86 used the VESA BIOS
2279+
Extensions and EFI-framebuffers for this, which are mostly limited
2280+
to x86.
2281+
This option, if enabled, marks VGA/VBE/EFI framebuffers as generic
2282+
framebuffers so the new generic system-framebuffer drivers can be
2283+
used on x86. If the framebuffer is not compatible with the generic
2284+
modes, it is adverticed as fallback platform framebuffer so legacy
2285+
drivers like efifb, vesafb and uvesafb can pick it up.
2286+
If this option is not selected, all system framebuffers are always
2287+
marked as fallback platform framebuffers as usual.
2288+
2289+
Note: Legacy fbdev drivers, including vesafb, efifb, uvesafb, will
2290+
not be able to pick up generic system framebuffers if this option
2291+
is selected. You are highly encouraged to enable simplefb as
2292+
replacement if you select this option. simplefb can correctly deal
2293+
with generic system framebuffers. But you should still keep vesafb
2294+
and others enabled as fallback if a system framebuffer is
2295+
incompatible with simplefb.
2296+
2297+
If unsure, say Y.
2298+
22732299
endmenu
22742300

22752301

arch/x86/include/asm/sysfb.h

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#ifndef _ARCH_X86_KERNEL_SYSFB_H
2+
#define _ARCH_X86_KERNEL_SYSFB_H
3+
4+
/*
5+
* Generic System Framebuffers on x86
6+
* Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com>
7+
*
8+
* This program is free software; you can redistribute it and/or modify it
9+
* under the terms of the GNU General Public License as published by the Free
10+
* Software Foundation; either version 2 of the License, or (at your option)
11+
* any later version.
12+
*/
13+
14+
#include <linux/kernel.h>
15+
#include <linux/platform_data/simplefb.h>
16+
#include <linux/screen_info.h>
17+
18+
enum {
19+
M_I17, /* 17-Inch iMac */
20+
M_I20, /* 20-Inch iMac */
21+
M_I20_SR, /* 20-Inch iMac (Santa Rosa) */
22+
M_I24, /* 24-Inch iMac */
23+
M_I24_8_1, /* 24-Inch iMac, 8,1th gen */
24+
M_I24_10_1, /* 24-Inch iMac, 10,1th gen */
25+
M_I27_11_1, /* 27-Inch iMac, 11,1th gen */
26+
M_MINI, /* Mac Mini */
27+
M_MINI_3_1, /* Mac Mini, 3,1th gen */
28+
M_MINI_4_1, /* Mac Mini, 4,1th gen */
29+
M_MB, /* MacBook */
30+
M_MB_2, /* MacBook, 2nd rev. */
31+
M_MB_3, /* MacBook, 3rd rev. */
32+
M_MB_5_1, /* MacBook, 5th rev. */
33+
M_MB_6_1, /* MacBook, 6th rev. */
34+
M_MB_7_1, /* MacBook, 7th rev. */
35+
M_MB_SR, /* MacBook, 2nd gen, (Santa Rosa) */
36+
M_MBA, /* MacBook Air */
37+
M_MBA_3, /* Macbook Air, 3rd rev */
38+
M_MBP, /* MacBook Pro */
39+
M_MBP_2, /* MacBook Pro 2nd gen */
40+
M_MBP_2_2, /* MacBook Pro 2,2nd gen */
41+
M_MBP_SR, /* MacBook Pro (Santa Rosa) */
42+
M_MBP_4, /* MacBook Pro, 4th gen */
43+
M_MBP_5_1, /* MacBook Pro, 5,1th gen */
44+
M_MBP_5_2, /* MacBook Pro, 5,2th gen */
45+
M_MBP_5_3, /* MacBook Pro, 5,3rd gen */
46+
M_MBP_6_1, /* MacBook Pro, 6,1th gen */
47+
M_MBP_6_2, /* MacBook Pro, 6,2th gen */
48+
M_MBP_7_1, /* MacBook Pro, 7,1th gen */
49+
M_MBP_8_2, /* MacBook Pro, 8,2nd gen */
50+
M_UNKNOWN /* placeholder */
51+
};
52+
53+
struct efifb_dmi_info {
54+
char *optname;
55+
unsigned long base;
56+
int stride;
57+
int width;
58+
int height;
59+
int flags;
60+
};
61+
62+
#ifdef CONFIG_EFI
63+
64+
extern struct efifb_dmi_info efifb_dmi_list[];
65+
void sysfb_apply_efi_quirks(void);
66+
67+
#else /* CONFIG_EFI */
68+
69+
static inline void sysfb_apply_efi_quirks(void)
70+
{
71+
}
72+
73+
#endif /* CONFIG_EFI */
74+
75+
#ifdef CONFIG_X86_SYSFB
76+
77+
bool parse_mode(const struct screen_info *si,
78+
struct simplefb_platform_data *mode);
79+
int create_simplefb(const struct screen_info *si,
80+
const struct simplefb_platform_data *mode);
81+
82+
#else /* CONFIG_X86_SYSFB */
83+
84+
static inline bool parse_mode(const struct screen_info *si,
85+
struct simplefb_platform_data *mode)
86+
{
87+
return false;
88+
}
89+
90+
static inline int create_simplefb(const struct screen_info *si,
91+
const struct simplefb_platform_data *mode)
92+
{
93+
return -EINVAL;
94+
}
95+
96+
#endif /* CONFIG_X86_SYSFB */
97+
98+
#endif /* _ARCH_X86_KERNEL_SYSFB_H */

arch/x86/kernel/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
103103
obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
104104
obj-$(CONFIG_OF) += devicetree.o
105105
obj-$(CONFIG_UPROBES) += uprobes.o
106+
obj-y += sysfb.o
107+
obj-$(CONFIG_X86_SYSFB) += sysfb_simplefb.o
108+
obj-$(CONFIG_EFI) += sysfb_efi.o
106109

107110
obj-$(CONFIG_PERF_EVENTS) += perf_regs.o
108111
obj-$(CONFIG_TRACING) += tracepoint.o

arch/x86/kernel/sysfb.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Generic System Framebuffers on x86
3+
* Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com>
4+
*
5+
* This program is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License as published by the Free
7+
* Software Foundation; either version 2 of the License, or (at your option)
8+
* any later version.
9+
*/
10+
11+
/*
12+
* Simple-Framebuffer support for x86 systems
13+
* Create a platform-device for any available boot framebuffer. The
14+
* simple-framebuffer platform device is already available on DT systems, so
15+
* this module parses the global "screen_info" object and creates a suitable
16+
* platform device compatible with the "simple-framebuffer" DT object. If
17+
* the framebuffer is incompatible, we instead create a legacy
18+
* "vesa-framebuffer", "efi-framebuffer" or "platform-framebuffer" device and
19+
* pass the screen_info as platform_data. This allows legacy drivers
20+
* to pick these devices up without messing with simple-framebuffer drivers.
21+
* The global "screen_info" is still valid at all times.
22+
*
23+
* If CONFIG_X86_SYSFB is not selected, we never register "simple-framebuffer"
24+
* platform devices, but only use legacy framebuffer devices for
25+
* backwards compatibility.
26+
*
27+
* TODO: We set the dev_id field of all platform-devices to 0. This allows
28+
* other x86 OF/DT parsers to create such devices, too. However, they must
29+
* start at offset 1 for this to work.
30+
*/
31+
32+
#include <linux/err.h>
33+
#include <linux/init.h>
34+
#include <linux/kernel.h>
35+
#include <linux/mm.h>
36+
#include <linux/platform_data/simplefb.h>
37+
#include <linux/platform_device.h>
38+
#include <linux/screen_info.h>
39+
#include <asm/sysfb.h>
40+
41+
static __init int sysfb_init(void)
42+
{
43+
struct screen_info *si = &screen_info;
44+
struct simplefb_platform_data mode;
45+
struct platform_device *pd;
46+
const char *name;
47+
bool compatible;
48+
int ret;
49+
50+
sysfb_apply_efi_quirks();
51+
52+
/* try to create a simple-framebuffer device */
53+
compatible = parse_mode(si, &mode);
54+
if (compatible) {
55+
ret = create_simplefb(si, &mode);
56+
if (!ret)
57+
return 0;
58+
}
59+
60+
/* if the FB is incompatible, create a legacy framebuffer device */
61+
if (si->orig_video_isVGA == VIDEO_TYPE_EFI)
62+
name = "efi-framebuffer";
63+
else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
64+
name = "vesa-framebuffer";
65+
else
66+
name = "platform-framebuffer";
67+
68+
pd = platform_device_register_resndata(NULL, name, 0,
69+
NULL, 0, si, sizeof(*si));
70+
return IS_ERR(pd) ? PTR_ERR(pd) : 0;
71+
}
72+
73+
/* must execute after PCI subsystem for EFI quirks */
74+
device_initcall(sysfb_init);

0 commit comments

Comments
 (0)