Skip to contentSkip to conversation

x86 platform framebuffers

PATCH RESEND In review David Herrmann 4 participants 24 messages Aug 2, 2013 – Aug 4, 2013

Subsystems (4)

v1 of 2 In review Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover x86 platform framebuffers

Hi

I cut down my previous series to no longer include the SimpleDRM driver. If anyone is interested, you can find it here:
http://lwn.net/Articles/558104/
I will resend it once these preparation patches are in.

Changes since v2:
- added common x86 formats (reported by hpa) (patch #5)

This whole series (including simpledrm) is tested by Stephen and me. I would be glad if maintainers could ack/nack this so I can continue my work.

This series is pretty small and just converts x86 to use platform-devices instead of global objects to pass framebuffer data to drivers. The commit messages explain everything in detail.
The idea is to create a "platform-framebuffer" device which drivers can bind to. If x86 boot code detectes efi or vesa framebuffers, it creates efi-framebuffer or vesa-framebuffer devices instead.

Additionally, if the modes are compatible, "simple-framebuffer" devices are created so simplefb can be used on x86. This feature is only enabled if CONFIG_X86_SYSFB is selected (off by default) so users without simplefb still get boot logs.

@Stephen: I wasn't sure whether you tested the efi/vesa framebuffer changes,
too, so I didn't add your tested-by there. And I changed patch #5 so I dropped it there, too. Thanks for testing!

Thanks
David

David Herrmann (8):
fbdev: simplefb: add init through platform_data
fbdev: simplefb: mark as fw and allocate apertures
x86: provide platform-devices for boot-framebuffers
x86: sysfb: move EFI quirks from efifb to sysfb
fbdev: simplefb: add common x86 RGB formats
fbdev: vesafb: bind to platform-framebuffer device
fbdev: efifb: bind to efi-framebuffer
fbdev: fbcon: select VT_HW_CONSOLE_BINDING

 arch/x86/Kconfig                       |  26 +++
 arch/x86/include/asm/sysfb.h           |  98 +++++++++++
 arch/x86/kernel/Makefile               |   3 +
 arch/x86/kernel/sysfb.c                |  74 ++++++++
 arch/x86/kernel/sysfb_efi.c            | 214 +++++++++++++++++++++++
 arch/x86/kernel/sysfb_simplefb.c       |  95 +++++++++++
 drivers/video/Kconfig                  |   5 +-
 drivers/video/console/Kconfig          |   3 +-
 drivers/video/efifb.c                  | 302 ++++-----------------------------
 drivers/video/simplefb.c               |  58 +++++--
 drivers/video/vesafb.c                 |  55 ++----
 include/linux/platform_data/simplefb.h |  63 +++++++
 12 files changed, 666 insertions(+), 330 deletions(-)
 create mode 100644 arch/x86/include/asm/sysfb.h
 create mode 100644 arch/x86/kernel/sysfb.c
 create mode 100644 arch/x86/kernel/sysfb_efi.c
 create mode 100644 arch/x86/kernel/sysfb_simplefb.c
 create mode 100644 include/linux/platform_data/simplefb.h
Signature · 1 line
1.8.3.4
#1 lore raw

PATCH RESEND 1/8 fbdev: simplefb: add init through platform_data

If we create proper platform-devices in x86 boot-code, we can use simplefb for VBE or EFI framebuffers, too. However, there is normally no OF support so we introduce a platform_data object so x86 boot-code can pass the parameters via plain old platform-data.

This also removes the OF dependency as it is not needed. The headers provide proper dummies for the case OF is disabled.

Furthermore, we move the FORMAT-definitions to the common platform header so initialization code can use it to transform "struct screen_info" to the right format-name.

---
 drivers/video/Kconfig                  |  5 ++-
 drivers/video/simplefb.c               | 48 +++++++++++++++++++++--------
 include/linux/platform_data/simplefb.h | 56 ++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+), 16 deletions(-)
 create mode 100644 include/linux/platform_data/simplefb.h
drivers/video/Kconfig +2 -3
index 4cf1e1d..34c3d96 100644
@@ -2457,7 +2457,7 @@ config FB_HYPERV
 
 config FB_SIMPLE
 	bool "Simple framebuffer support"
-	depends on (FB = y) && OF
+	depends on (FB = y)
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
@@ -2469,8 +2469,7 @@ config FB_SIMPLE
 	  pre-allocated frame buffer surface.
 
 	  Configuration re: surface address, size, and format must be provided
-	  through device tree, or potentially plain old platform data in the
-	  future.
+	  through device tree, or plain old platform data.
 
 source "drivers/video/omap/Kconfig"
 source "drivers/video/omap2/Kconfig"
drivers/video/simplefb.c +35 -13

72 lines not on this page · raw message

include/linux/platform_data/simplefb.h new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
1.8.3.4
#3 lore raw

PATCH RESEND 2/8 fbdev: simplefb: mark as fw and allocate apertures

In reply to David Herrmann

fbdev-core uses FBINFO_MISC_FIRMWARE to mark drivers that use firmware framebuffers. Furthermore, we now allocate apertures for the fbinfo device.
Both information is used by remove_conflicting_framebuffers() to remove a fbdev device whenever a real driver is loaded. This is used heavily on x86 for VGA/vesa/EFI framebuffers, but is also of great use for all other systems.

Especially with x86 support for simplefb, this information is needed to unload simplefb before a real hw-driver (like i915, radeon, nouveau) is loaded.

---
 drivers/video/simplefb.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/video/simplefb.c +9 -1
index 5886989..8d78106 100644
@@ -202,8 +202,16 @@ static int simplefb_probe(struct platform_device *pdev)
 	info->var.blue = params.format->blue;
 	info->var.transp = params.format->transp;
 
+	info->apertures = alloc_apertures(1);
+	if (!info->apertures) {
+		framebuffer_release(info);
+		return -ENOMEM;
+	}
+	info->apertures->ranges[0].base = info->fix.smem_start;
+	info->apertures->ranges[0].size = info->fix.smem_len;
+
 	info->fbops = &simplefb_ops;
-	info->flags = FBINFO_DEFAULT;
+	info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE;
 	info->screen_base = devm_ioremap(&pdev->dev, info->fix.smem_start,
 					 info->fix.smem_len);
 	if (!info->screen_base) {
Signature · 1 line
1.8.3.4
#5 lore raw

PATCH RESEND 3/8 x86: provide platform-devices for boot-framebuffers

In reply to David Herrmann

The current situation regarding boot-framebuffers (VGA, VESA/VBE, EFI) on x86 causes troubles when loading multiple fbdev drivers. The global "struct screen_info" does not provide any state-tracking about which drivers use the FBs. request_mem_region() theoretically works, but unfortunately vesafb/efifb ignore it due to quirks for broken boards.

Avoid this by creating a platform framebuffer devices with a pointer to the "struct screen_info" as platform-data. Drivers can now create platform-drivers and the driver-core will refuse multiple drivers being active simultaneously.

We keep the screen_info available for backwards-compatibility. Drivers can be converted in follow-up patches.

Different devices are created for VGA/VESA/EFI FBs to allow multiple drivers to be loaded on distro kernels. We create:
- "vesa-framebuffer" for VBE/VESA graphics FBs
- "efi-framebuffer" for EFI FBs
- "platform-framebuffer" for everything else
This allows to load vesafb, efifb and others simultaneously and each picks up only the supported FB types.

Apart from platform-framebuffer devices, this also introduces a compatibility option for "simple-framebuffer" drivers which recently got introduced for OF based systems. If CONFIG_X86_SYSFB is selected, we try to match the screen_info against a simple-framebuffer supported format. If we succeed, we create a "simple-framebuffer" device instead of a platform-framebuffer.
This allows to reuse the simplefb.c driver across architectures and also to introduce a SimpleDRM driver. There is no need to have vesafb.c, efifb.c, simplefb.c and more just to have architecture specific quirks in their setup-routines.

Instead, we now move the architecture specific quirks into x86-setup and provide a generic simple-framebuffer. For backwards-compatibility (if strange formats are used), we still allow vesafb/efifb to be loaded simultaneously and pick up all remaining devices.

---
 arch/x86/Kconfig                 | 26 +++++++++++
 arch/x86/include/asm/sysfb.h     | 41 +++++++++++++++++
 arch/x86/kernel/Makefile         |  2 +
 arch/x86/kernel/sysfb.c          | 71 ++++++++++++++++++++++++++++++
 arch/x86/kernel/sysfb_simplefb.c | 95 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 235 insertions(+)
 create mode 100644 arch/x86/include/asm/sysfb.h
 create mode 100644 arch/x86/kernel/sysfb.c
 create mode 100644 arch/x86/kernel/sysfb_simplefb.c
arch/x86/Kconfig +26 -0
index b32ebf9..5c56559 100644
@@ -2270,6 +2270,32 @@ config RAPIDIO
 
 source "drivers/rapidio/Kconfig"
 
+config X86_SYSFB
+	bool "Mark VGA/VBE/EFI FB as generic system framebuffer"
+	help
+	  Firmwares often provide initial graphics framebuffers so the BIOS,
+	  bootloader or kernel can show basic video-output during boot for
+	  user-guidance and debugging. Historically, x86 used the VESA BIOS
+	  Extensions and EFI-framebuffers for this, which are mostly limited
+	  to x86.
+	  This option, if enabled, marks VGA/VBE/EFI framebuffers as generic
+	  framebuffers so the new generic system-framebuffer drivers can be
+	  used on x86. If the framebuffer is not compatible with the generic
+	  modes, it is adverticed as fallback platform framebuffer so legacy
+	  drivers like efifb, vesafb and uvesafb can pick it up.
+	  If this option is not selected, all system framebuffers are always
+	  marked as fallback platform framebuffers as usual.
+
+	  Note: Legacy fbdev drivers, including vesafb, efifb, uvesafb, will
+	  not be able to pick up generic system framebuffers if this option
+	  is selected. You are highly encouraged to enable simplefb as
+	  replacement if you select this option. simplefb can correctly deal
+	  with generic system framebuffers. But you should still keep vesafb
+	  and others enabled as fallback if a system framebuffer is
+	  incompatible with simplefb.
+
+	  If unsure, say Y.
+
 endmenu
 
 
arch/x86/include/asm/sysfb.h new file +41 -0

41 lines not on this page · raw message

arch/x86/kernel/Makefile +2 -0
index 88d99ea..90ecdc5 100644
@@ -103,6 +103,8 @@ obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
 obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
 obj-$(CONFIG_OF)			+= devicetree.o
 obj-$(CONFIG_UPROBES)			+= uprobes.o
+obj-y					+= sysfb.o
+obj-$(CONFIG_X86_SYSFB)			+= sysfb_simplefb.o
 
 obj-$(CONFIG_PERF_EVENTS)		+= perf_regs.o
 obj-$(CONFIG_TRACING)			+= tracepoint.o
arch/x86/kernel/sysfb.c new file +71 -0

71 lines not on this page · raw message

arch/x86/kernel/sysfb_simplefb.c new file +95 -0

95 lines not on this page · raw message

Signature · 1 line
1.8.3.4
#7 lore raw

PATCH RESEND 4/8 x86: sysfb: move EFI quirks from efifb to sysfb

In reply to David Herrmann

The EFI FB quirks from efifb.c are useful for simple-framebuffer devices as well. Apply them by default so we can convert efifb.c to use efi-framebuffer platform devices.

---
 arch/x86/include/asm/sysfb.h |  57 +++++++++++
 arch/x86/kernel/Makefile     |   1 +
 arch/x86/kernel/sysfb.c      |   3 +
 arch/x86/kernel/sysfb_efi.c  | 214 +++++++++++++++++++++++++++++++++++++++
 drivers/video/efifb.c        | 234 ++-----------------------------------------
 5 files changed, 282 insertions(+), 227 deletions(-)
 create mode 100644 arch/x86/kernel/sysfb_efi.c
arch/x86/include/asm/sysfb.h +57 -0
index 2395fe0..2aeb3e2 100644
@@ -15,6 +15,63 @@
 #include <linux/platform_data/simplefb.h>
 #include <linux/screen_info.h>
 
+enum {
+	M_I17,		/* 17-Inch iMac */
+	M_I20,		/* 20-Inch iMac */
+	M_I20_SR,	/* 20-Inch iMac (Santa Rosa) */
+	M_I24,		/* 24-Inch iMac */
+	M_I24_8_1,	/* 24-Inch iMac, 8,1th gen */
+	M_I24_10_1,	/* 24-Inch iMac, 10,1th gen */
+	M_I27_11_1,	/* 27-Inch iMac, 11,1th gen */
+	M_MINI,		/* Mac Mini */
+	M_MINI_3_1,	/* Mac Mini, 3,1th gen */
+	M_MINI_4_1,	/* Mac Mini, 4,1th gen */
+	M_MB,		/* MacBook */
+	M_MB_2,		/* MacBook, 2nd rev. */
+	M_MB_3,		/* MacBook, 3rd rev. */
+	M_MB_5_1,	/* MacBook, 5th rev. */
+	M_MB_6_1,	/* MacBook, 6th rev. */
+	M_MB_7_1,	/* MacBook, 7th rev. */
+	M_MB_SR,	/* MacBook, 2nd gen, (Santa Rosa) */
+	M_MBA,		/* MacBook Air */
+	M_MBA_3,	/* Macbook Air, 3rd rev */
+	M_MBP,		/* MacBook Pro */
+	M_MBP_2,	/* MacBook Pro 2nd gen */
+	M_MBP_2_2,	/* MacBook Pro 2,2nd gen */
+	M_MBP_SR,	/* MacBook Pro (Santa Rosa) */
+	M_MBP_4,	/* MacBook Pro, 4th gen */
+	M_MBP_5_1,	/* MacBook Pro, 5,1th gen */
+	M_MBP_5_2,	/* MacBook Pro, 5,2th gen */
+	M_MBP_5_3,	/* MacBook Pro, 5,3rd gen */
+	M_MBP_6_1,	/* MacBook Pro, 6,1th gen */
+	M_MBP_6_2,	/* MacBook Pro, 6,2th gen */
+	M_MBP_7_1,	/* MacBook Pro, 7,1th gen */
+	M_MBP_8_2,	/* MacBook Pro, 8,2nd gen */
+	M_UNKNOWN	/* placeholder */
+};
+
+struct efifb_dmi_info {
+	char *optname;
+	unsigned long base;
+	int stride;
+	int width;
+	int height;
+	int flags;
+};
+
+#ifdef CONFIG_EFI
+
+extern struct efifb_dmi_info efifb_dmi_list[];
+void sysfb_apply_efi_quirks(void);
+
+#else /* CONFIG_EFI */
+
+static inline void sysfb_apply_efi_quirks(void)
+{
+}
+
+#endif /* CONFIG_EFI */
+
 #ifdef CONFIG_X86_SYSFB
 
 bool parse_mode(const struct screen_info *si,
arch/x86/kernel/Makefile +1 -0
index 90ecdc5..a5408b9 100644
@@ -105,6 +105,7 @@ obj-$(CONFIG_OF)			+= devicetree.o
 obj-$(CONFIG_UPROBES)			+= uprobes.o
 obj-y					+= sysfb.o
 obj-$(CONFIG_X86_SYSFB)			+= sysfb_simplefb.o
+obj-$(CONFIG_EFI)			+= sysfb_efi.o
 
 obj-$(CONFIG_PERF_EVENTS)		+= perf_regs.o
 obj-$(CONFIG_TRACING)			+= tracepoint.o
arch/x86/kernel/sysfb.c +3 -0
index 7f30e19..193ec2c 100644
@@ -47,6 +47,8 @@ static __init int sysfb_init(void)
 	bool compatible;
 	int ret;
 
+	sysfb_apply_efi_quirks();
+
 	/* try to create a simple-framebuffer device */
 	compatible = parse_mode(si, &mode);
 	if (compatible) {
@@ -68,4 +70,5 @@ static __init int sysfb_init(void)
 	return IS_ERR(pd) ? PTR_ERR(pd) : 0;
 }
 
+/* must execute after PCI subsystem for EFI quirks */
 device_initcall(sysfb_init);
arch/x86/kernel/sysfb_efi.c new file +214 -0

214 lines not on this page · raw message

drivers/video/efifb.c +7 -227

258 lines not on this page · raw message

Signature · 1 line
1.8.3.4
#9 lore raw

PATCH RESEND 5/8 fbdev: simplefb: add common x86 RGB formats

In reply to David Herrmann

32bit XRGB and ARGB are used by modern x86 systems for EFI and VESA framebuffers. The other formats were reported by hpa to be most common. Add these so simplefb works on most common x86 systems.

---
 include/linux/platform_data/simplefb.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/linux/platform_data/simplefb.h +7 -0
index 5fa2c5e..53774b0 100644
@@ -20,6 +20,13 @@
 #define SIMPLEFB_FORMATS \
 { \
 	{ "r5g6b5", 16, {11, 5}, {5, 6}, {0, 5}, {0, 0}, DRM_FORMAT_RGB565 }, \
+	{ "x1r5g5b5", 16, {10, 5}, {5, 5}, {0, 5}, {0, 0}, DRM_FORMAT_XRGB1555 }, \
+	{ "a1r5g5b5", 16, {10, 5}, {5, 5}, {0, 5}, {15, 1}, DRM_FORMAT_ARGB1555 }, \
+	{ "r8g8b8", 24, {16, 8}, {8, 8}, {0, 8}, {0, 0}, DRM_FORMAT_RGB888 }, \
+	{ "x8r8g8b8", 32, {16, 8}, {8, 8}, {0, 8}, {0, 0}, DRM_FORMAT_XRGB8888 }, \
+	{ "a8r8g8b8", 32, {16, 8}, {8, 8}, {0, 8}, {24, 8}, DRM_FORMAT_ARGB8888 }, \
+	{ "x2r10g10b10", 32, {20, 10}, {10, 10}, {0, 10}, {0, 0}, DRM_FORMAT_XRGB2101010 }, \
+	{ "a2r10g10b10", 32, {20, 10}, {10, 10}, {0, 10}, {30, 2}, DRM_FORMAT_ARGB2101010 }, \
 }
 
 /*
Signature · 1 line
1.8.3.4
#11 lore raw

PATCH RESEND 6/8 fbdev: vesafb: bind to platform-framebuffer device

In reply to David Herrmann

x86 creates platform-framebuffer platform devices for every system framebuffer. Use these instead of creating a dummy device.

This requires us to remove the __init annotations as hotplugging may occur during runtime.

---
 drivers/video/vesafb.c | 55 +++++++++++++++-----------------------------------
 1 file changed, 16 insertions(+), 39 deletions(-)
drivers/video/vesafb.c +16 -39
index 501b340..bd83233 100644
@@ -29,7 +29,7 @@
 
 /* --------------------------------------------------------------------- */
 
-static struct fb_var_screeninfo vesafb_defined __initdata = {
+static struct fb_var_screeninfo vesafb_defined = {
 	.activate	= FB_ACTIVATE_NOW,
 	.height		= -1,
 	.width		= -1,
@@ -40,7 +40,7 @@ static struct fb_var_screeninfo vesafb_defined __initdata = {
 	.vmode		= FB_VMODE_NONINTERLACED,
 };
 
-static struct fb_fix_screeninfo vesafb_fix __initdata = {
+static struct fb_fix_screeninfo vesafb_fix = {
 	.id	= "VESA VGA",
 	.type	= FB_TYPE_PACKED_PIXELS,
 	.accel	= FB_ACCEL_NONE,
@@ -48,8 +48,8 @@ static struct fb_fix_screeninfo vesafb_fix __initdata = {
 
 static int   inverse    __read_mostly;
 static int   mtrr       __read_mostly;		/* disable mtrr */
-static int   vram_remap __initdata;		/* Set amount of memory to be used */
-static int   vram_total __initdata;		/* Set total amount of memory */
+static int   vram_remap;			/* Set amount of memory to be used */
+static int   vram_total;			/* Set total amount of memory */
 static int   pmi_setpal __read_mostly = 1;	/* pmi for palette changes ??? */
 static int   ypan       __read_mostly;		/* 0..nothing, 1..ypan, 2..ywrap */
 static void  (*pmi_start)(void) __read_mostly;
@@ -192,7 +192,7 @@ static struct fb_ops vesafb_ops = {
 	.fb_imageblit	= cfb_imageblit,
 };
 
-static int __init vesafb_setup(char *options)
+static int vesafb_setup(char *options)
 {
 	char *this_opt;
 	
@@ -226,13 +226,18 @@ static int __init vesafb_setup(char *options)
 	return 0;
 }
 
-static int __init vesafb_probe(struct platform_device *dev)
+static int vesafb_probe(struct platform_device *dev)
 {
 	struct fb_info *info;
 	int i, err;
 	unsigned int size_vmode;
 	unsigned int size_remap;
 	unsigned int size_total;
+	char *option = NULL;
+
+	/* ignore error return of fb_get_options */
+	fb_get_options("vesafb", &option);
+	vesafb_setup(option);
 
 	if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
 		return -ENODEV;
@@ -496,40 +501,12 @@ err:
 }
 
 static struct platform_driver vesafb_driver = {
-	.driver	= {
-		.name	= "vesafb",
+	.driver = {
+		.name = "vesa-framebuffer",
+		.owner = THIS_MODULE,
 	},
+	.probe = vesafb_probe,
 };
 
-static struct platform_device *vesafb_device;
-
-static int __init vesafb_init(void)
-{
-	int ret;
-	char *option = NULL;
-
-	/* ignore error return of fb_get_options */
-	fb_get_options("vesafb", &option);
-	vesafb_setup(option);
-
-	vesafb_device = platform_device_alloc("vesafb", 0);
-	if (!vesafb_device)
-		return -ENOMEM;
-
-	ret = platform_device_add(vesafb_device);
-	if (!ret) {
-		ret = platform_driver_probe(&vesafb_driver, vesafb_probe);
-		if (ret)
-			platform_device_del(vesafb_device);
-	}
-
-	if (ret) {
-		platform_device_put(vesafb_device);
-		vesafb_device = NULL;
-	}
-
-	return ret;
-}
-module_init(vesafb_init);
-
+module_platform_driver(vesafb_driver);
 MODULE_LICENSE("GPL");
Signature · 1 line
1.8.3.4
#13 lore raw

PATCH RESEND 7/8 fbdev: efifb: bind to efi-framebuffer

In reply to David Herrmann

Instead of creating a dummy device, we now bind to the efi-fb device which is provided by x86 initialization code.

---
 drivers/video/efifb.c | 68 +++++++++++++++++----------------------------------
 1 file changed, 22 insertions(+), 46 deletions(-)
drivers/video/efifb.c +22 -46
index e493bcb..2a8286e 100644
@@ -96,7 +96,7 @@ void vga_set_default_device(struct pci_dev *pdev)
 	default_vga = pdev;
 }
 
-static int __init efifb_setup(char *options)
+static int efifb_setup(char *options)
 {
 	char *this_opt;
 	int i;
@@ -153,13 +153,28 @@ static int __init efifb_setup(char *options)
 	return 0;
 }
 
-static int __init efifb_probe(struct platform_device *dev)
+static int efifb_probe(struct platform_device *dev)
 {
 	struct fb_info *info;
 	int err;
 	unsigned int size_vmode;
 	unsigned int size_remap;
 	unsigned int size_total;
+	char *option = NULL;
+
+	if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
+		return -ENODEV;
+
+	if (fb_get_options("efifb", &option))
+		return -ENODEV;
+	efifb_setup(option);
+
+	/* We don't get linelength from UGA Draw Protocol, only from
+	 * EFI Graphics Protocol.  So if it's not in DMI, and it's not
+	 * passed in from the user, we really can't use the framebuffer.
+	 */
+	if (!screen_info.lfb_linelength)
+		return -ENODEV;
 
 	if (!screen_info.lfb_depth)
 		screen_info.lfb_depth = 32;
@@ -323,51 +338,12 @@ err_release_mem:
 }
 
 static struct platform_driver efifb_driver = {
-	.driver	= {
-		.name	= "efifb",
+	.driver = {
+		.name = "efi-framebuffer",
+		.owner = THIS_MODULE,
 	},
+	.probe = efifb_probe,
 };
 
-static struct platform_device efifb_device = {
-	.name	= "efifb",
-};
-
-static int __init efifb_init(void)
-{
-	int ret;
-	char *option = NULL;
-
-	if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
-		return -ENODEV;
-
-	if (fb_get_options("efifb", &option))
-		return -ENODEV;
-	efifb_setup(option);
-
-	/* We don't get linelength from UGA Draw Protocol, only from
-	 * EFI Graphics Protocol.  So if it's not in DMI, and it's not
-	 * passed in from the user, we really can't use the framebuffer.
-	 */
-	if (!screen_info.lfb_linelength)
-		return -ENODEV;
-
-	ret = platform_device_register(&efifb_device);
-	if (ret)
-		return ret;
-
-	/*
-	 * This is not just an optimization.  We will interfere
-	 * with a real driver if we get reprobed, so don't allow
-	 * it.
-	 */
-	ret = platform_driver_probe(&efifb_driver, efifb_probe);
-	if (ret) {
-		platform_device_unregister(&efifb_device);
-		return ret;
-	}
-
-	return ret;
-}
-module_init(efifb_init);
-
+module_platform_driver(efifb_driver);
 MODULE_LICENSE("GPL");
Signature · 1 line
1.8.3.4
#15 lore raw

PATCH RESEND 8/8 fbdev: fbcon: select VT_HW_CONSOLE_BINDING

In reply to David Herrmann

fbdev provides framebuffer hotplugging, hence, we need to allow fbcon to unbind from framebuffers. Unfortunately, fbcon_fb_unbind() cannot unbind from the last framebuffer, unless console-unbinding is supported.

Fixing fbcon_unbind() to return 0 caused some horrible NULL-derefs in the VT layer and I couldn't figure out why. Hence, lets just require console-unbinding so fbdev hotplugging works with fbcon.

---
 drivers/video/console/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/console/Kconfig +2 -1
index 8c30603..846caab 100644
@@ -92,7 +92,8 @@ config DUMMY_CONSOLE_ROWS
 
 config FRAMEBUFFER_CONSOLE
 	tristate "Framebuffer Console support"
-	depends on FB
+	depends on FB && !UML
+	select VT_HW_CONSOLE_BINDING
 	select CRC32
 	select FONT_SUPPORT
 	help
Signature · 1 line
1.8.3.4
#17 lore raw
In reply to David Herrmann
Quoted 9 lines · David Herrmann

Hi

I cut down my previous series to no longer include the SimpleDRM driver. If anyone is interested, you can find it here:
http://lwn.net/Articles/558104/
I will resend it once these preparation patches are in.

Changes since v2:
- added common x86 formats (reported by hpa) (patch #5)

So I assume this is V3; patch subject doesn't say so:-)

...

Quoted 3 lines

@Stephen: I wasn't sure whether you tested the efi/vesa framebuffer changes, too, so I didn't add your tested-by there. And I changed patch #5 so I dropped it there, too. Thanks for testing!

Yes, I'm only testing on ARM platforms using simplefb, not any x86 platforms. This latest version seems to work fine, so feel free to re-apply by tested-by where appropriate.

#19 lore raw
In reply to David Herrmann
Quoted 20 lines · David Herrmann

Hi

I cut down my previous series to no longer include the SimpleDRM driver. If anyone is interested, you can find it here:
http://lwn.net/Articles/558104/
I will resend it once these preparation patches are in.

Changes since v2:
- added common x86 formats (reported by hpa) (patch #5)

This whole series (including simpledrm) is tested by Stephen and me. I would be glad if maintainers could ack/nack this so I can continue my work.

This series is pretty small and just converts x86 to use platform-devices instead of global objects to pass framebuffer data to drivers. The commit messages explain everything in detail.
The idea is to create a "platform-framebuffer" device which drivers can bind to. If x86 boot code detectes efi or vesa framebuffers, it creates efi-framebuffer or vesa-framebuffer devices instead.

Quoted 9 lines

Additionally, if the modes are compatible, "simple-framebuffer" devices are created so simplefb can be used on x86. This feature is only enabled if CONFIG_X86_SYSFB is selected (off by default) so users without simplefb still get boot logs.

@Stephen: I wasn't sure whether you tested the efi/vesa framebuffer changes,
too, so I didn't add your tested-by there. And I changed patch #5 so I dropped it there, too. Thanks for testing!

I am getting a bunch of new warnings with this patchset, typically of the form:

/home/hpa/kernel/distwork/drivers/video/arkfb.c:1019:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

  par->state.vgabase = (void __iomem *) vga_res.start;
                       ^
/home/hpa/kernel/distwork/drivers/video/s3fb.c: In function ‘s3_pci_probe’:
/home/hpa/kernel/distwork/drivers/video/s3fb.c:1186:23: warning: cast to
pointer from integer of different size [-Wint-to-pointer-cast]
  par->state.vgabase = (void __iomem *) vga_res.start;
                       ^

I have pushed it out to a topic branch in the tip tree, partly to give Fengguang's build bot a run at it (it is excellent at spotting the origin of new warnings), but this needs to be fixed; we will not merge this branch in its current form.

-hpa

#2 lore raw

[tip:x86/fb] fbdev: simplefb: add init through platform_data

In reply to David Herrmann
fbdev: simplefb: add init through platform_data
Commit-ID:  5ef76da644bf346d29200007d8d3779e7009dabb
Gitweb:     http://git.kernel.org/tip/5ef76da644bf346d29200007d8d3779e7009dabb
Author:     David Herrmann <[email protected]>
AuthorDate: Fri, 2 Aug 2013 14:05:20 +0200
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 2 Aug 2013 16:17:44 -0700

fbdev: simplefb: add init through platform_data

If we create proper platform-devices in x86 boot-code, we can use simplefb for VBE or EFI framebuffers, too. However, there is normally no OF support so we introduce a platform_data object so x86 boot-code can pass the parameters via plain old platform-data.

This also removes the OF dependency as it is not needed. The headers provide proper dummies for the case OF is disabled.

Furthermore, we move the FORMAT-definitions to the common platform header so initialization code can use it to transform "struct screen_info" to the right format-name.

---
 drivers/video/Kconfig                  |  5 ++-
 drivers/video/simplefb.c               | 48 +++++++++++++++++++++--------
 include/linux/platform_data/simplefb.h | 56 ++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+), 16 deletions(-)
drivers/video/Kconfig +2 -3
index 4cf1e1d..34c3d96 100644
@@ -2457,7 +2457,7 @@ config FB_HYPERV
 
 config FB_SIMPLE
 	bool "Simple framebuffer support"
-	depends on (FB = y) && OF
+	depends on (FB = y)
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
@@ -2469,8 +2469,7 @@ config FB_SIMPLE
 	  pre-allocated frame buffer surface.
 
 	  Configuration re: surface address, size, and format must be provided
-	  through device tree, or potentially plain old platform data in the
-	  future.
+	  through device tree, or plain old platform data.
 
 source "drivers/video/omap/Kconfig"
 source "drivers/video/omap2/Kconfig"
drivers/video/simplefb.c +35 -13

72 lines not on this page · raw message

include/linux/platform_data/simplefb.h new file +56 -0

56 lines not on this page · raw message

#4 lore raw

[tip:x86/fb] fbdev: simplefb: mark as fw and allocate apertures

In reply to David Herrmann
fbdev: simplefb: mark as fw and allocate apertures
Commit-ID:  df0960ab2d95543a7c162b04b2064991666adbad
Gitweb:     http://git.kernel.org/tip/df0960ab2d95543a7c162b04b2064991666adbad
Author:     David Herrmann <[email protected]>
AuthorDate: Fri, 2 Aug 2013 14:05:21 +0200
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 2 Aug 2013 16:17:45 -0700

fbdev: simplefb: mark as fw and allocate apertures

fbdev-core uses FBINFO_MISC_FIRMWARE to mark drivers that use firmware framebuffers. Furthermore, we now allocate apertures for the fbinfo device.
Both information is used by remove_conflicting_framebuffers() to remove a fbdev device whenever a real driver is loaded. This is used heavily on x86 for VGA/vesa/EFI framebuffers, but is also of great use for all other systems.

Especially with x86 support for simplefb, this information is needed to unload simplefb before a real hw-driver (like i915, radeon, nouveau) is loaded.

---
 drivers/video/simplefb.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/video/simplefb.c +9 -1
index 5886989..8d78106 100644
@@ -202,8 +202,16 @@ static int simplefb_probe(struct platform_device *pdev)
 	info->var.blue = params.format->blue;
 	info->var.transp = params.format->transp;
 
+	info->apertures = alloc_apertures(1);
+	if (!info->apertures) {
+		framebuffer_release(info);
+		return -ENOMEM;
+	}
+	info->apertures->ranges[0].base = info->fix.smem_start;
+	info->apertures->ranges[0].size = info->fix.smem_len;
+
 	info->fbops = &simplefb_ops;
-	info->flags = FBINFO_DEFAULT;
+	info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE;
 	info->screen_base = devm_ioremap(&pdev->dev, info->fix.smem_start,
 					 info->fix.smem_len);
 	if (!info->screen_base) {
#6 lore raw

[tip:x86/fb] x86: provide platform-devices for boot-framebuffers

In reply to David Herrmann
x86: provide platform-devices for boot-framebuffers
Commit-ID:  e3263ab389a7bc9398c3d366819d6f39b9cfd677
Gitweb:     http://git.kernel.org/tip/e3263ab389a7bc9398c3d366819d6f39b9cfd677
Author:     David Herrmann <[email protected]>
AuthorDate: Fri, 2 Aug 2013 14:05:22 +0200
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 2 Aug 2013 16:17:46 -0700

x86: provide platform-devices for boot-framebuffers

The current situation regarding boot-framebuffers (VGA, VESA/VBE, EFI) on x86 causes troubles when loading multiple fbdev drivers. The global "struct screen_info" does not provide any state-tracking about which drivers use the FBs. request_mem_region() theoretically works, but unfortunately vesafb/efifb ignore it due to quirks for broken boards.

Avoid this by creating a platform framebuffer devices with a pointer to the "struct screen_info" as platform-data. Drivers can now create platform-drivers and the driver-core will refuse multiple drivers being active simultaneously.

We keep the screen_info available for backwards-compatibility. Drivers can be converted in follow-up patches.

Different devices are created for VGA/VESA/EFI FBs to allow multiple drivers to be loaded on distro kernels. We create:
- "vesa-framebuffer" for VBE/VESA graphics FBs
- "efi-framebuffer" for EFI FBs
- "platform-framebuffer" for everything else
This allows to load vesafb, efifb and others simultaneously and each picks up only the supported FB types.

Apart from platform-framebuffer devices, this also introduces a compatibility option for "simple-framebuffer" drivers which recently got introduced for OF based systems. If CONFIG_X86_SYSFB is selected, we try to match the screen_info against a simple-framebuffer supported format. If we succeed, we create a "simple-framebuffer" device instead of a platform-framebuffer.
This allows to reuse the simplefb.c driver across architectures and also to introduce a SimpleDRM driver. There is no need to have vesafb.c, efifb.c, simplefb.c and more just to have architecture specific quirks in their setup-routines.

Instead, we now move the architecture specific quirks into x86-setup and provide a generic simple-framebuffer. For backwards-compatibility (if strange formats are used), we still allow vesafb/efifb to be loaded simultaneously and pick up all remaining devices.

---
 arch/x86/Kconfig                 | 26 +++++++++++
 arch/x86/include/asm/sysfb.h     | 41 +++++++++++++++++
 arch/x86/kernel/Makefile         |  2 +
 arch/x86/kernel/sysfb.c          | 71 ++++++++++++++++++++++++++++++
 arch/x86/kernel/sysfb_simplefb.c | 95 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 235 insertions(+)
arch/x86/Kconfig +26 -0
index b32ebf9..5c56559 100644
@@ -2270,6 +2270,32 @@ config RAPIDIO
 
 source "drivers/rapidio/Kconfig"
 
+config X86_SYSFB
+	bool "Mark VGA/VBE/EFI FB as generic system framebuffer"
+	help
+	  Firmwares often provide initial graphics framebuffers so the BIOS,
+	  bootloader or kernel can show basic video-output during boot for
+	  user-guidance and debugging. Historically, x86 used the VESA BIOS
+	  Extensions and EFI-framebuffers for this, which are mostly limited
+	  to x86.
+	  This option, if enabled, marks VGA/VBE/EFI framebuffers as generic
+	  framebuffers so the new generic system-framebuffer drivers can be
+	  used on x86. If the framebuffer is not compatible with the generic
+	  modes, it is adverticed as fallback platform framebuffer so legacy
+	  drivers like efifb, vesafb and uvesafb can pick it up.
+	  If this option is not selected, all system framebuffers are always
+	  marked as fallback platform framebuffers as usual.
+
+	  Note: Legacy fbdev drivers, including vesafb, efifb, uvesafb, will
+	  not be able to pick up generic system framebuffers if this option
+	  is selected. You are highly encouraged to enable simplefb as
+	  replacement if you select this option. simplefb can correctly deal
+	  with generic system framebuffers. But you should still keep vesafb
+	  and others enabled as fallback if a system framebuffer is
+	  incompatible with simplefb.
+
+	  If unsure, say Y.
+
 endmenu
 
 
arch/x86/include/asm/sysfb.h new file +41 -0

41 lines not on this page · raw message

arch/x86/kernel/Makefile +2 -0
index 88d99ea..90ecdc5 100644
@@ -103,6 +103,8 @@ obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
 obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
 obj-$(CONFIG_OF)			+= devicetree.o
 obj-$(CONFIG_UPROBES)			+= uprobes.o
+obj-y					+= sysfb.o
+obj-$(CONFIG_X86_SYSFB)			+= sysfb_simplefb.o
 
 obj-$(CONFIG_PERF_EVENTS)		+= perf_regs.o
 obj-$(CONFIG_TRACING)			+= tracepoint.o
arch/x86/kernel/sysfb.c new file +71 -0

71 lines not on this page · raw message

arch/x86/kernel/sysfb_simplefb.c new file +95 -0

95 lines not on this page · raw message

#8 lore raw

[tip:x86/fb] x86: sysfb: move EFI quirks from efifb to sysfb

In reply to David Herrmann
x86: sysfb: move EFI quirks from efifb to sysfb
Commit-ID:  2995e506276bfdc7311eb02db8b2aa1a61a4b849
Gitweb:     http://git.kernel.org/tip/2995e506276bfdc7311eb02db8b2aa1a61a4b849
Author:     David Herrmann <[email protected]>
AuthorDate: Fri, 2 Aug 2013 14:05:23 +0200
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 2 Aug 2013 16:17:47 -0700

x86: sysfb: move EFI quirks from efifb to sysfb

The EFI FB quirks from efifb.c are useful for simple-framebuffer devices as well. Apply them by default so we can convert efifb.c to use efi-framebuffer platform devices.

---
 arch/x86/include/asm/sysfb.h |  57 +++++++++++
 arch/x86/kernel/Makefile     |   1 +
 arch/x86/kernel/sysfb.c      |   3 +
 arch/x86/kernel/sysfb_efi.c  | 214 +++++++++++++++++++++++++++++++++++++++
 drivers/video/efifb.c        | 234 ++-----------------------------------------
 5 files changed, 282 insertions(+), 227 deletions(-)
arch/x86/include/asm/sysfb.h +57 -0
index 2395fe0..2aeb3e2 100644
@@ -15,6 +15,63 @@
 #include <linux/platform_data/simplefb.h>
 #include <linux/screen_info.h>
 
+enum {
+	M_I17,		/* 17-Inch iMac */
+	M_I20,		/* 20-Inch iMac */
+	M_I20_SR,	/* 20-Inch iMac (Santa Rosa) */
+	M_I24,		/* 24-Inch iMac */
+	M_I24_8_1,	/* 24-Inch iMac, 8,1th gen */
+	M_I24_10_1,	/* 24-Inch iMac, 10,1th gen */
+	M_I27_11_1,	/* 27-Inch iMac, 11,1th gen */
+	M_MINI,		/* Mac Mini */
+	M_MINI_3_1,	/* Mac Mini, 3,1th gen */
+	M_MINI_4_1,	/* Mac Mini, 4,1th gen */
+	M_MB,		/* MacBook */
+	M_MB_2,		/* MacBook, 2nd rev. */
+	M_MB_3,		/* MacBook, 3rd rev. */
+	M_MB_5_1,	/* MacBook, 5th rev. */
+	M_MB_6_1,	/* MacBook, 6th rev. */
+	M_MB_7_1,	/* MacBook, 7th rev. */
+	M_MB_SR,	/* MacBook, 2nd gen, (Santa Rosa) */
+	M_MBA,		/* MacBook Air */
+	M_MBA_3,	/* Macbook Air, 3rd rev */
+	M_MBP,		/* MacBook Pro */
+	M_MBP_2,	/* MacBook Pro 2nd gen */
+	M_MBP_2_2,	/* MacBook Pro 2,2nd gen */
+	M_MBP_SR,	/* MacBook Pro (Santa Rosa) */
+	M_MBP_4,	/* MacBook Pro, 4th gen */
+	M_MBP_5_1,	/* MacBook Pro, 5,1th gen */
+	M_MBP_5_2,	/* MacBook Pro, 5,2th gen */
+	M_MBP_5_3,	/* MacBook Pro, 5,3rd gen */
+	M_MBP_6_1,	/* MacBook Pro, 6,1th gen */
+	M_MBP_6_2,	/* MacBook Pro, 6,2th gen */
+	M_MBP_7_1,	/* MacBook Pro, 7,1th gen */
+	M_MBP_8_2,	/* MacBook Pro, 8,2nd gen */
+	M_UNKNOWN	/* placeholder */
+};
+
+struct efifb_dmi_info {
+	char *optname;
+	unsigned long base;
+	int stride;
+	int width;
+	int height;
+	int flags;
+};
+
+#ifdef CONFIG_EFI
+
+extern struct efifb_dmi_info efifb_dmi_list[];
+void sysfb_apply_efi_quirks(void);
+
+#else /* CONFIG_EFI */
+
+static inline void sysfb_apply_efi_quirks(void)
+{
+}
+
+#endif /* CONFIG_EFI */
+
 #ifdef CONFIG_X86_SYSFB
 
 bool parse_mode(const struct screen_info *si,
arch/x86/kernel/Makefile +1 -0
index 90ecdc5..a5408b9 100644
@@ -105,6 +105,7 @@ obj-$(CONFIG_OF)			+= devicetree.o
 obj-$(CONFIG_UPROBES)			+= uprobes.o
 obj-y					+= sysfb.o
 obj-$(CONFIG_X86_SYSFB)			+= sysfb_simplefb.o
+obj-$(CONFIG_EFI)			+= sysfb_efi.o
 
 obj-$(CONFIG_PERF_EVENTS)		+= perf_regs.o
 obj-$(CONFIG_TRACING)			+= tracepoint.o
arch/x86/kernel/sysfb.c +3 -0
index 7f30e19..193ec2c 100644
@@ -47,6 +47,8 @@ static __init int sysfb_init(void)
 	bool compatible;
 	int ret;
 
+	sysfb_apply_efi_quirks();
+
 	/* try to create a simple-framebuffer device */
 	compatible = parse_mode(si, &mode);
 	if (compatible) {
@@ -68,4 +70,5 @@ static __init int sysfb_init(void)
 	return IS_ERR(pd) ? PTR_ERR(pd) : 0;
 }
 
+/* must execute after PCI subsystem for EFI quirks */
 device_initcall(sysfb_init);
arch/x86/kernel/sysfb_efi.c new file +214 -0

214 lines not on this page · raw message

drivers/video/efifb.c +7 -227

258 lines not on this page · raw message

#12 lore raw

[tip:x86/fb] fbdev: vesafb: bind to platform-framebuffer device

In reply to David Herrmann
fbdev: vesafb: bind to platform-framebuffer device
Commit-ID:  2e5155ecbb729d3a2e7d1cea7c18493516fec55a
Gitweb:     http://git.kernel.org/tip/2e5155ecbb729d3a2e7d1cea7c18493516fec55a
Author:     David Herrmann <[email protected]>
AuthorDate: Fri, 2 Aug 2013 14:05:25 +0200
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 2 Aug 2013 16:17:49 -0700

fbdev: vesafb: bind to platform-framebuffer device

x86 creates platform-framebuffer platform devices for every system framebuffer. Use these instead of creating a dummy device.

This requires us to remove the __init annotations as hotplugging may occur during runtime.

---
 drivers/video/vesafb.c | 55 +++++++++++++++-----------------------------------
 1 file changed, 16 insertions(+), 39 deletions(-)
drivers/video/vesafb.c +16 -39
index 501b340..bd83233 100644
@@ -29,7 +29,7 @@
 
 /* --------------------------------------------------------------------- */
 
-static struct fb_var_screeninfo vesafb_defined __initdata = {
+static struct fb_var_screeninfo vesafb_defined = {
 	.activate	= FB_ACTIVATE_NOW,
 	.height		= -1,
 	.width		= -1,
@@ -40,7 +40,7 @@ static struct fb_var_screeninfo vesafb_defined __initdata = {
 	.vmode		= FB_VMODE_NONINTERLACED,
 };
 
-static struct fb_fix_screeninfo vesafb_fix __initdata = {
+static struct fb_fix_screeninfo vesafb_fix = {
 	.id	= "VESA VGA",
 	.type	= FB_TYPE_PACKED_PIXELS,
 	.accel	= FB_ACCEL_NONE,
@@ -48,8 +48,8 @@ static struct fb_fix_screeninfo vesafb_fix __initdata = {
 
 static int   inverse    __read_mostly;
 static int   mtrr       __read_mostly;		/* disable mtrr */
-static int   vram_remap __initdata;		/* Set amount of memory to be used */
-static int   vram_total __initdata;		/* Set total amount of memory */
+static int   vram_remap;			/* Set amount of memory to be used */
+static int   vram_total;			/* Set total amount of memory */
 static int   pmi_setpal __read_mostly = 1;	/* pmi for palette changes ??? */
 static int   ypan       __read_mostly;		/* 0..nothing, 1..ypan, 2..ywrap */
 static void  (*pmi_start)(void) __read_mostly;
@@ -192,7 +192,7 @@ static struct fb_ops vesafb_ops = {
 	.fb_imageblit	= cfb_imageblit,
 };
 
-static int __init vesafb_setup(char *options)
+static int vesafb_setup(char *options)
 {
 	char *this_opt;
 	
@@ -226,13 +226,18 @@ static int __init vesafb_setup(char *options)
 	return 0;
 }
 
-static int __init vesafb_probe(struct platform_device *dev)
+static int vesafb_probe(struct platform_device *dev)
 {
 	struct fb_info *info;
 	int i, err;
 	unsigned int size_vmode;
 	unsigned int size_remap;
 	unsigned int size_total;
+	char *option = NULL;
+
+	/* ignore error return of fb_get_options */
+	fb_get_options("vesafb", &option);
+	vesafb_setup(option);
 
 	if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
 		return -ENODEV;
@@ -496,40 +501,12 @@ err:
 }
 
 static struct platform_driver vesafb_driver = {
-	.driver	= {
-		.name	= "vesafb",
+	.driver = {
+		.name = "vesa-framebuffer",
+		.owner = THIS_MODULE,
 	},
+	.probe = vesafb_probe,
 };
 
-static struct platform_device *vesafb_device;
-
-static int __init vesafb_init(void)
-{
-	int ret;
-	char *option = NULL;
-
-	/* ignore error return of fb_get_options */
-	fb_get_options("vesafb", &option);
-	vesafb_setup(option);
-
-	vesafb_device = platform_device_alloc("vesafb", 0);
-	if (!vesafb_device)
-		return -ENOMEM;
-
-	ret = platform_device_add(vesafb_device);
-	if (!ret) {
-		ret = platform_driver_probe(&vesafb_driver, vesafb_probe);
-		if (ret)
-			platform_device_del(vesafb_device);
-	}
-
-	if (ret) {
-		platform_device_put(vesafb_device);
-		vesafb_device = NULL;
-	}
-
-	return ret;
-}
-module_init(vesafb_init);
-
+module_platform_driver(vesafb_driver);
 MODULE_LICENSE("GPL");
#14 lore raw

[tip:x86/fb] fbdev: efifb: bind to efi-framebuffer

In reply to David Herrmann
fbdev: efifb: bind to efi-framebuffer
Commit-ID:  e6816a8d85549444feb3838920b1f4efba73d1da
Gitweb:     http://git.kernel.org/tip/e6816a8d85549444feb3838920b1f4efba73d1da
Author:     David Herrmann <[email protected]>
AuthorDate: Fri, 2 Aug 2013 14:05:26 +0200
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 2 Aug 2013 16:17:50 -0700

fbdev: efifb: bind to efi-framebuffer

Instead of creating a dummy device, we now bind to the efi-fb device which is provided by x86 initialization code.

---
 drivers/video/efifb.c | 68 +++++++++++++++++----------------------------------
 1 file changed, 22 insertions(+), 46 deletions(-)
drivers/video/efifb.c +22 -46
index e493bcb..2a8286e 100644
@@ -96,7 +96,7 @@ void vga_set_default_device(struct pci_dev *pdev)
 	default_vga = pdev;
 }
 
-static int __init efifb_setup(char *options)
+static int efifb_setup(char *options)
 {
 	char *this_opt;
 	int i;
@@ -153,13 +153,28 @@ static int __init efifb_setup(char *options)
 	return 0;
 }
 
-static int __init efifb_probe(struct platform_device *dev)
+static int efifb_probe(struct platform_device *dev)
 {
 	struct fb_info *info;
 	int err;
 	unsigned int size_vmode;
 	unsigned int size_remap;
 	unsigned int size_total;
+	char *option = NULL;
+
+	if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
+		return -ENODEV;
+
+	if (fb_get_options("efifb", &option))
+		return -ENODEV;
+	efifb_setup(option);
+
+	/* We don't get linelength from UGA Draw Protocol, only from
+	 * EFI Graphics Protocol.  So if it's not in DMI, and it's not
+	 * passed in from the user, we really can't use the framebuffer.
+	 */
+	if (!screen_info.lfb_linelength)
+		return -ENODEV;
 
 	if (!screen_info.lfb_depth)
 		screen_info.lfb_depth = 32;
@@ -323,51 +338,12 @@ err_release_mem:
 }
 
 static struct platform_driver efifb_driver = {
-	.driver	= {
-		.name	= "efifb",
+	.driver = {
+		.name = "efi-framebuffer",
+		.owner = THIS_MODULE,
 	},
+	.probe = efifb_probe,
 };
 
-static struct platform_device efifb_device = {
-	.name	= "efifb",
-};
-
-static int __init efifb_init(void)
-{
-	int ret;
-	char *option = NULL;
-
-	if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
-		return -ENODEV;
-
-	if (fb_get_options("efifb", &option))
-		return -ENODEV;
-	efifb_setup(option);
-
-	/* We don't get linelength from UGA Draw Protocol, only from
-	 * EFI Graphics Protocol.  So if it's not in DMI, and it's not
-	 * passed in from the user, we really can't use the framebuffer.
-	 */
-	if (!screen_info.lfb_linelength)
-		return -ENODEV;
-
-	ret = platform_device_register(&efifb_device);
-	if (ret)
-		return ret;
-
-	/*
-	 * This is not just an optimization.  We will interfere
-	 * with a real driver if we get reprobed, so don't allow
-	 * it.
-	 */
-	ret = platform_driver_probe(&efifb_driver, efifb_probe);
-	if (ret) {
-		platform_device_unregister(&efifb_device);
-		return ret;
-	}
-
-	return ret;
-}
-module_init(efifb_init);
-
+module_platform_driver(efifb_driver);
 MODULE_LICENSE("GPL");
#16 lore raw

[tip:x86/fb] fbdev: fbcon: select VT_HW_CONSOLE_BINDING

In reply to David Herrmann
fbdev: fbcon: select VT_HW_CONSOLE_BINDING
Commit-ID:  765d5b9c2b72f5b99722cdfcf4bf8f88c556cf92
Gitweb:     http://git.kernel.org/tip/765d5b9c2b72f5b99722cdfcf4bf8f88c556cf92
Author:     David Herrmann <[email protected]>
AuthorDate: Fri, 2 Aug 2013 14:05:27 +0200
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 2 Aug 2013 16:17:51 -0700

fbdev: fbcon: select VT_HW_CONSOLE_BINDING

fbdev provides framebuffer hotplugging, hence, we need to allow fbcon to unbind from framebuffers. Unfortunately, fbcon_fb_unbind() cannot unbind from the last framebuffer, unless console-unbinding is supported.

Fixing fbcon_unbind() to return 0 caused some horrible NULL-derefs in the VT layer and I couldn't figure out why. Hence, lets just require console-unbinding so fbdev hotplugging works with fbcon.

---
 drivers/video/console/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/console/Kconfig +2 -1
index 8c30603..846caab 100644
@@ -92,7 +92,8 @@ config DUMMY_CONSOLE_ROWS
 
 config FRAMEBUFFER_CONSOLE
 	tristate "Framebuffer Console support"
-	depends on FB
+	depends on FB && !UML
+	select VT_HW_CONSOLE_BINDING
 	select CRC32
 	select FONT_SUPPORT
 	help
#10 lore raw

[tip:x86/fb] fbdev: simplefb: add common x86 RGB formats

In reply to David Herrmann
fbdev: simplefb: add common x86 RGB formats
Commit-ID:  9a6a36d19c9d24479300511e23933876a4a9cf82
Gitweb:     http://git.kernel.org/tip/9a6a36d19c9d24479300511e23933876a4a9cf82
Author:     David Herrmann <[email protected]>
AuthorDate: Fri, 2 Aug 2013 14:05:24 +0200
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 2 Aug 2013 16:17:48 -0700

fbdev: simplefb: add common x86 RGB formats

32bit XRGB and ARGB are used by modern x86 systems for EFI and VESA framebuffers. The other formats were reported by hpa to be most common. Add these so simplefb works on most common x86 systems.

---
 include/linux/platform_data/simplefb.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/linux/platform_data/simplefb.h +7 -0
index 5fa2c5e..53774b0 100644
@@ -20,6 +20,13 @@
 #define SIMPLEFB_FORMATS \
 { \
 	{ "r5g6b5", 16, {11, 5}, {5, 6}, {0, 5}, {0, 0}, DRM_FORMAT_RGB565 }, \
+	{ "x1r5g5b5", 16, {10, 5}, {5, 5}, {0, 5}, {0, 0}, DRM_FORMAT_XRGB1555 }, \
+	{ "a1r5g5b5", 16, {10, 5}, {5, 5}, {0, 5}, {15, 1}, DRM_FORMAT_ARGB1555 }, \
+	{ "r8g8b8", 24, {16, 8}, {8, 8}, {0, 8}, {0, 0}, DRM_FORMAT_RGB888 }, \
+	{ "x8r8g8b8", 32, {16, 8}, {8, 8}, {0, 8}, {0, 0}, DRM_FORMAT_XRGB8888 }, \
+	{ "a8r8g8b8", 32, {16, 8}, {8, 8}, {0, 8}, {24, 8}, DRM_FORMAT_ARGB8888 }, \
+	{ "x2r10g10b10", 32, {20, 10}, {10, 10}, {0, 10}, {0, 0}, DRM_FORMAT_XRGB2101010 }, \
+	{ "a2r10g10b10", 32, {20, 10}, {10, 10}, {0, 10}, {30, 2}, DRM_FORMAT_ARGB2101010 }, \
 }
 
 /*
#20 lore raw
In reply to H. Peter Anvin

Hi

Quoted 44 lines · H. Peter Anvin
Quoted 20 lines · David Herrmann

Hi

I cut down my previous series to no longer include the SimpleDRM driver. If anyone is interested, you can find it here:
http://lwn.net/Articles/558104/
I will resend it once these preparation patches are in.

Changes since v2:
- added common x86 formats (reported by hpa) (patch #5)

This whole series (including simpledrm) is tested by Stephen and me. I would be glad if maintainers could ack/nack this so I can continue my work.

This series is pretty small and just converts x86 to use platform-devices instead of global objects to pass framebuffer data to drivers. The commit messages explain everything in detail.
The idea is to create a "platform-framebuffer" device which drivers can bind to. If x86 boot code detectes efi or vesa framebuffers, it creates efi-framebuffer or vesa-framebuffer devices instead.

Quoted 9 lines

Additionally, if the modes are compatible, "simple-framebuffer" devices are created so simplefb can be used on x86. This feature is only enabled if CONFIG_X86_SYSFB is selected (off by default) so users without simplefb still get boot logs.

@Stephen: I wasn't sure whether you tested the efi/vesa framebuffer changes,
too, so I didn't add your tested-by there. And I changed patch #5 so I dropped it there, too. Thanks for testing!

I am getting a bunch of new warnings with this patchset, typically of the form:

/home/hpa/kernel/distwork/drivers/video/arkfb.c:1019:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

  par->state.vgabase = (void __iomem *) vga_res.start;
                       ^
/home/hpa/kernel/distwork/drivers/video/s3fb.c: In function ‘s3_pci_probe’:
/home/hpa/kernel/distwork/drivers/video/s3fb.c:1186:23: warning: cast to
pointer from integer of different size [-Wint-to-pointer-cast]
  par->state.vgabase = (void __iomem *) vga_res.start;
                       ^
Quoted 4 lines

I have pushed it out to a topic branch in the tip tree, partly to give Fengguang's build bot a run at it (it is excellent at spotting the origin of new warnings), but this needs to be fixed; we will not merge this branch in its current form.

Thanks for looking at it. However, these warnings seem unrelated to my patchset. I didn't change any vga/fb headers nor did I touch arkfb/s3fb. Furthermore, I cannot reproduce these warnings. "vga_res" is a "struct resource", "->start" is of type "resource_size_t" which is typedef'ed to "phys_addr_t". Seems like the build-bot used some random config with CONFIG_PHYS_ADDR_T_64BIT set but building on 32bit (or something like that).

Is there any place where I can see the compiler log? Or the used .config file?

Thanks
David

#18 lore raw
In reply to Stephen Warren

Hi

Quoted 8 lines · Stephen Warren
Quoted 7 lines · David Herrmann

Hi

I cut down my previous series to no longer include the SimpleDRM driver. If anyone is interested, you can find it here:
http://lwn.net/Articles/558104/
I will resend it once these preparation patches are in.

Quoted 4 lines
Quoted 2 lines

Changes since v2:
- added common x86 formats (reported by hpa) (patch #5)

So I assume this is V3; patch subject doesn't say so:-)

Whoops, my bad, sorry. It's v3, yes.

Quoted 8 lines

...

Quoted 3 lines

@Stephen: I wasn't sure whether you tested the efi/vesa framebuffer changes, too, so I didn't add your tested-by there. And I changed patch #5 so I dropped it there, too. Thanks for testing!

Yes, I'm only testing on ARM platforms using simplefb, not any x86 platforms. This latest version seems to work fine, so feel free to re-apply by tested-by where appropriate.

That's what I thought. Thanks for verifying.

Cheers
David

#21 lore raw
In reply to David Herrmann

When compiled for i386 PAE phys_addr_t is 64 bits but pointers are 32 bits.

Quoted 81 lines · David Herrmann

Hi

Quoted 4 lines · H. Peter Anvin
Quoted 3 lines · David Herrmann

Hi

I cut down my previous series to no longer include the SimpleDRM

driver. If

Quoted 8 lines
Quoted 8 lines

anyone is interested, you can find it here:
http://lwn.net/Articles/558104/
I will resend it once these preparation patches are in.

Changes since v2:
- added common x86 formats (reported by hpa) (patch #5)

This whole series (including simpledrm) is tested by Stephen and me.

I would be

Quoted 3 lines
Quoted 3 lines

glad if maintainers could ack/nack this so I can continue my work.

This series is pretty small and just converts x86 to use

platform-devices

Quoted 1 line
Quoted 1 line

instead of global objects to pass framebuffer data to drivers. The

commit

Quoted 2 lines
Quoted 2 lines

messages explain everything in detail.
The idea is to create a "platform-framebuffer" device which drivers

can bind to.

Quoted 1 line
Quoted 1 line

If x86 boot code detectes efi or vesa framebuffers, it creates

efi-framebuffer

Quoted 3 lines
Quoted 3 lines

or vesa-framebuffer devices instead.

Additionally, if the modes are compatible, "simple-framebuffer"

devices are

Quoted 1 line
Quoted 1 line

created so simplefb can be used on x86. This feature is only enabled

if

Quoted 1 line
Quoted 1 line

CONFIG_X86_SYSFB is selected (off by default) so users without

simplefb still

Quoted 3 lines
Quoted 3 lines

get boot logs.

@Stephen: I wasn't sure whether you tested the efi/vesa framebuffer

changes,

Quoted 1 line
Quoted 1 line

too, so I didn't add your tested-by there. And I changed patch #5 so

I dropped

Quoted 8 lines
Quoted 2 lines

it there, too. Thanks for testing!

I am getting a bunch of new warnings with this patchset, typically of the form:

/home/hpa/kernel/distwork/drivers/video/arkfb.c:1019:23: warning:

cast

Quoted 4 lines

to pointer from integer of different size [-Wint-to-pointer-cast]

  par->state.vgabase = (void __iomem *) vga_res.start;
                       ^

/home/hpa/kernel/distwork/drivers/video/s3fb.c: In function

‘s3_pci_probe’:

Quoted 1 line

/home/hpa/kernel/distwork/drivers/video/s3fb.c:1186:23: warning: cast

to

Quoted 4 lines

pointer from integer of different size [-Wint-to-pointer-cast]

  par->state.vgabase = (void __iomem *) vga_res.start;
                       ^

I have pushed it out to a topic branch in the tip tree, partly to

give

Quoted 2 lines

Fengguang's build bot a run at it (it is excellent at spotting the origin of new warnings), but this needs to be fixed; we will not

merge

Quoted 1 line

this branch in its current form.

Thanks for looking at it. However, these warnings seem unrelated to my patchset. I didn't change any vga/fb headers nor did I touch arkfb/s3fb. Furthermore, I cannot reproduce these warnings. "vga_res" is a "struct resource", "->start" is of type "resource_size_t" which is typedef'ed to "phys_addr_t". Seems like the build-bot used some random config with CONFIG_PHYS_ADDR_T_64BIT set but building on 32bit (or something like that).

Is there any place where I can see the compiler log? Or the used .config file?

Thanks
David

Signature · 1 line
Sent from my mobile phone. Please excuse brevity and lack of formatting.
#22 lore raw

Hi

Quoted 1 line · H. Peter Anvin

When compiled for i386 PAE phys_addr_t is 64 bits but pointers are 32 bits.

Yepp, that makes sense. I am not really comfortable fixing this as I have no idea how PAE actually works, but I digged through git history and sent a patch to linux-fbdev (I put you on CC). The (long)-cast should be sufficient, I guess.

Were there any other build warnings you encountered?

Thanks
David

Quoted 85 lines
Quoted 76 lines · David Herrmann

Hi

Quoted 4 lines · H. Peter Anvin
Quoted 3 lines · David Herrmann

Hi

I cut down my previous series to no longer include the SimpleDRM

driver. If

Quoted 8 lines
Quoted 8 lines

anyone is interested, you can find it here:
http://lwn.net/Articles/558104/
I will resend it once these preparation patches are in.

Changes since v2:
- added common x86 formats (reported by hpa) (patch #5)

This whole series (including simpledrm) is tested by Stephen and me.

I would be

Quoted 3 lines
Quoted 3 lines

glad if maintainers could ack/nack this so I can continue my work.

This series is pretty small and just converts x86 to use

platform-devices

Quoted 1 line
Quoted 1 line

instead of global objects to pass framebuffer data to drivers. The

commit

Quoted 2 lines
Quoted 2 lines

messages explain everything in detail.
The idea is to create a "platform-framebuffer" device which drivers

can bind to.

Quoted 1 line
Quoted 1 line

If x86 boot code detectes efi or vesa framebuffers, it creates

efi-framebuffer

Quoted 3 lines
Quoted 3 lines

or vesa-framebuffer devices instead.

Additionally, if the modes are compatible, "simple-framebuffer"

devices are

Quoted 1 line
Quoted 1 line

created so simplefb can be used on x86. This feature is only enabled

if

Quoted 1 line
Quoted 1 line

CONFIG_X86_SYSFB is selected (off by default) so users without

simplefb still

Quoted 3 lines
Quoted 3 lines

get boot logs.

@Stephen: I wasn't sure whether you tested the efi/vesa framebuffer

changes,

Quoted 1 line
Quoted 1 line

too, so I didn't add your tested-by there. And I changed patch #5 so

I dropped

Quoted 8 lines
Quoted 2 lines

it there, too. Thanks for testing!

I am getting a bunch of new warnings with this patchset, typically of the form:

/home/hpa/kernel/distwork/drivers/video/arkfb.c:1019:23: warning:

cast

Quoted 4 lines

to pointer from integer of different size [-Wint-to-pointer-cast]

  par->state.vgabase = (void __iomem *) vga_res.start;
                       ^

/home/hpa/kernel/distwork/drivers/video/s3fb.c: In function

‘s3_pci_probe’:

Quoted 1 line

/home/hpa/kernel/distwork/drivers/video/s3fb.c:1186:23: warning: cast

to

Quoted 4 lines

pointer from integer of different size [-Wint-to-pointer-cast]

  par->state.vgabase = (void __iomem *) vga_res.start;
                       ^

I have pushed it out to a topic branch in the tip tree, partly to

give

Quoted 2 lines

Fengguang's build bot a run at it (it is excellent at spotting the origin of new warnings), but this needs to be fixed; we will not

merge

Quoted 1 line

this branch in its current form.

Thanks for looking at it. However, these warnings seem unrelated to my patchset. I didn't change any vga/fb headers nor did I touch arkfb/s3fb. Furthermore, I cannot reproduce these warnings. "vga_res" is a "struct resource", "->start" is of type "resource_size_t" which is typedef'ed to "phys_addr_t". Seems like the build-bot used some random config with CONFIG_PHYS_ADDR_T_64BIT set but building on 32bit (or something like that).

Quoted 5 lines

Is there any place where I can see the compiler log? Or the used .config file?

Thanks
David

--
Sent from my mobile phone. Please excuse brevity and lack of formatting.

#23 lore raw
Quoted 10 lines · David Herrmann

Hi

Quoted 1 line · H. Peter Anvin

When compiled for i386 PAE phys_addr_t is 64 bits but pointers are 32 bits.

Yepp, that makes sense. I am not really comfortable fixing this as I have no idea how PAE actually works, but I digged through git history and sent a patch to linux-fbdev (I put you on CC). The (long)-cast should be sufficient, I guess.

Quoted 5 lines

Were there any other build warnings you encountered?

Thanks
David

It looks like Fengguang's bot hasn't run yet, so I don't have a summary.
I asked Fengguang what I need to do to kick it off.

-hpa