Platform Framebuffers and SimpleDRM
Subsystems (9)
v2 cover Platform Framebuffers and SimpleDRM
Hi
This series changes the way we handle firmware framebuffers on x86 systems. On other architectures the recently introduced "simple-framebuffer" platform-devices provide a sane and proper way to handle firmware framebuffers. So why not use it on x86, too?
This series adds x86 setup code to create proper platform-devices for firmware framebuffers. For backwards compatibility, efi-fb, vesa-fb and platform-fb devices are created and vesafb.c, efifb.c bind to the right device. We no longer have vesafb and efifb load unconditionally on "screen_info". If a fw-FB is compatible to "simple-framebuffer" devices, we create these instead. We can then use the generic arch-independent simplefb.c on x86 without any vesafb/efifb conflicts.
Last but not least, the series introduces SimpleDRM, which is basically simplefb but as DRM driver with all the usual benefits. SimpleDRM is also the motivation behind this series, but probably only of interest for the dri-devel mailing-list.
* Patches 1 & 2 modify simplefb.c to accept framebuffer information via plain old platform_data and allow real hw drivers to remove simplefb on conflicts.
* Patches 3 & 4 add x86 setup code to create the right platform-device for any found firmware framebuffer.
* Patches 5 - 7 modify simplefb.c, vesafb.c, efifb.c to use these new devices and support common x86 formats.
* Patch 8 fixes fbcon to require console binding to avoid crashes during framebuffer hotplugging
* Patches 9-14: Introduce SimpleDRM
Changes in v2:
- We now provide efi-framebuffer, vesa-framebuffer or platform-framebuffer legacy devices instead of just platform-framebuffer devs. This allows to load vesafb, efifb, .. simultaneously instead of only one driver.
- vesafb and efifb now use the new platform devices
- simplefb can now be unloaded via remove_conflicting_framebuffers()
- efifb EFI quirks now moved to x86 setup
- refactored x86 setup code to avoid #ifdefs
- Many small fixes (thanks to Stephen and Andy)
- Adjusted i915 and radeon to use new drm_kick_out_firmware()
- fbcon now works with SimpleDRM (fixed the palette handling and def-flags)
- fbdev unloading fixed (Patch #8)
Open issues:
- How does static platform-device creation conflict with OF support on x86? If we want to support "simple-framebuffer" devices via OF, we currently require screen_info...isVGA to be 0 so sysfb.c does nothing. Is that guaranteed?
- Should we try to move the offb.c DT parser to sysfb.c, too, so we can convert these devices to simple-framebuffers?
- How can we integrate vga16fb.c into this? Bind to "platform-framebuffer"?
- Is there any other generic driver that we might want to check? I haven't found more (except uvesafb, which always was separate, anyway).
- What FB formats are common on x86 that we should add to SIMPLEFB_FORMATS? (other than ARGB/XRGB32)
- Should we move default_vga detection from efifb.c to sysfb_efi.c, too? We could make the DMI table __init then.
I tested this (including DRM handover) with vesafb, efifb and simpledrm. It all worked well without problems. More testing is highly welcome! Also feel free to pickup individual fixes which don't directly depend on the series (eg. #1,
#2, #7, #8).
Comments welcome!
Cheers
David
David Herrmann (14):
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 32bit RGB formats
fbdev: vesafb: bind to platform-framebuffer device
fbdev: efifb: bind to efi-framebuffer
fbdev: fbcon: select VT_HW_CONSOLE_BINDING
drm: add SimpleDRM driver
drm: simpledrm: add fbdev fallback support
drm: add helpers to kick out firmware drivers
drm: nouveau: kick out firmware drivers during probe drm/i915: use new drm_kick_out_firmware() drm/radeon: use new drm_kick_out_firmware()
MAINTAINERS | 8 + 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/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_pci.c | 1 + drivers/gpu/drm/drm_platform.c | 1 + drivers/gpu/drm/drm_stub.c | 118 +++++++++ drivers/gpu/drm/drm_usb.c | 1 + drivers/gpu/drm/i915/i915_dma.c | 6 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 29 ++- drivers/gpu/drm/radeon/radeon_drv.c | 28 --- drivers/gpu/drm/radeon/radeon_kms.c | 30 +++ drivers/gpu/drm/simpledrm/Kconfig | 29 +++ drivers/gpu/drm/simpledrm/Makefile | 6 + drivers/gpu/drm/simpledrm/simpledrm.h | 112 +++++++++ drivers/gpu/drm/simpledrm/simpledrm_drv.c | 227 +++++++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_fbdev.c | 153 ++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_main.c | 363 ++++++++++++++++++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_mem.c | 252 +++++++++++++++++++ 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/drm/drmP.h | 26 ++ include/linux/platform_data/simplefb.h | 58 +++++ 31 files changed, 2016 insertions(+), 368 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 drivers/gpu/drm/simpledrm/Kconfig create mode 100644 drivers/gpu/drm/simpledrm/Makefile create mode 100644 drivers/gpu/drm/simpledrm/simpledrm.h create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_drv.c create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_fbdev.c create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_main.c create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_mem.c create mode 100644 include/linux/platform_data/simplefb.h
Signature · 1 line
1.8.3.2
PATCH v2 1/14 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
@@ -2455,7 +2455,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
@@ -2467,8 +2467,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.2
Re: [PATCH v2 01/14] fbdev: simplefb: add init through platform_data
Quoted 11 lines · David Herrmann
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_dataobject 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.
Patches 1 and 5,
PATCH v2 2/14 fbdev: simplefb: mark as fw and allocate apertures
In reply to David Herrmannfbdev-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
@@ -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.2
PATCH v2 3/14 x86: provide platform-devices for boot-framebuffers
In reply to David HerrmannThe 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
@@ -2255,6 +2255,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
@@ -100,6 +100,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
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.2
Re: [PATCH v2 03/14] x86: provide platform-devices for boot-framebuffers
Hi
Any comments on this?
Quoted 328 lines · 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_infoavailable 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_SYSFBis selected, we try to match thescreen_infoagainst a simple-framebuffer supported format. If we succeed, we create a "simple-framebuffer" device instead of a platform-framebuffer.
This allows to reuse thesimplefb.cdriver across architectures and also to introduce a SimpleDRM driver. There is no need to havevesafb.c,efifb.c,simplefb.cand 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.
Signed-off-by David Herrmann <[email protected]>--- 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.carch/x86/Kconfig +26
-0@@ -2255,6 +2255,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. + endmenuarch/x86/include/asm/sysfb.h new file +41
-0@@ -0,0 +1,41 @@ +#ifndef _ARCH_X86_KERNEL_SYSFB_H +#define _ARCH_X86_KERNEL_SYSFB_H + +/* +* Generic System Framebuffers on x86 +* Copyright (c) 2012-2013 David Herrmann <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the Free +* Software Foundation; either version 2 of the License, or (at your option) +* any later version. +*/ + +#include <linux/kernel.h> +#include <linux/platform_data/simplefb.h> +#include <linux/screen_info.h> + +#ifdef CONFIG_X86_SYSFB + +bool parse_mode (const struct screen_info *si, +struct simplefb_platform_data *mode); +int create_simplefb (const struct screen_info *si, +const struct simplefb_platform_data *mode); + +#else /* CONFIG_X86_SYSFB */ + +static inline bool parse_mode (const struct screen_info *si, +struct simplefb_platform_data *mode) +{ +return false; +} + +static inline int create_simplefb (const struct screen_info *si, +const struct simplefb_platform_data *mode) +{ +return -EINVAL ; +} + +#endif /* CONFIG_X86_SYSFB */ + +#endif /* _ARCH_X86_KERNEL_SYSFB_H */ arch/x86/kernel/Makefile +2
-0@@ -100,6 +100,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.oarch/x86/kernel/sysfb.c new file +71
-0@@ -0,0 +1,71 @@ +/* +* Generic System Framebuffers on x86 +* Copyright (c) 2012-2013 David Herrmann <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the Free +* Software Foundation; either version 2 of the License, or (at your option) +* any later version. +*/ + +/* +* Simple-Framebuffer support for x86 systems +* Create a platform-device for any available boot framebuffer. The +* simple-framebuffer platform device is already available on DT systems, so +* this module parses the global "screen_info" object and creates a suitable +* platform device compatible with the "simple-framebuffer" DT object. If +* the framebuffer is incompatible, we instead create a legacy +* "vesa-framebuffer", "efi-framebuffer" or "platform-framebuffer" device and +* pass the screen_info as platform_data. This allows legacy drivers +* to pick these devices up without messing with simple-framebuffer drivers. +* The global "screen_info" is still valid at all times. +* +* If CONFIG_X86_SYSFB is not selected, we never register "simple-framebuffer" +* platform devices, but only use legacy framebuffer devices for +* backwards compatibility. +* +* TODO: We set the dev_id field of all platform-devices to 0. This allows +* other x86 OF/DT parsers to create such devices, too. However, they must +* start at offset 1 for this to work. +*/ + +#include <linux/err.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/mm.h> +#include <linux/platform_data/simplefb.h> +#include <linux/platform_device.h> +#include <linux/screen_info.h> +#include <asm/sysfb.h> + +static __init int sysfb_init (void ) +{ +struct screen_info *si = &screen_info; +struct simplefb_platform_data mode; +struct platform_device *pd; +const char *name; +bool compatible; +int ret; + +/* try to create a simple-framebuffer device */ + compatible =parse_mode (si, &mode); +if (compatible) { + ret =create_simplefb (si, &mode); +if (!ret) +return 0 ; + } + +/* if the FB is incompatible, create a legacy framebuffer device */ +if (si->orig_video_isVGA ==VIDEO_TYPE_EFI ) + name ="efi-framebuffer" ; +else if (si->orig_video_isVGA ==VIDEO_TYPE_VLFB ) + name ="vesa-framebuffer" ; +else + name ="platform-framebuffer" ; + + pd =platform_device_register_resndata (NULL , name,0 , +NULL ,0 , si,sizeof (*si)); +return IS_ERR (pd) ?PTR_ERR (pd) :0 ; +} + +device_initcall (sysfb_init);arch/x86/kernel/sysfb_simplefb.c new file +95
-1@@ -0,0 +1,95 @@ +/* +* Generic System Framebuffers on x86 +* Copyright (c) 2012-2013 David Herrmann <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the Free +* Software Foundation; either version 2 of the License, or (at your option) +* any later version. +*/ + +/* +* simple-framebuffer probing +* Try to convert "screen_info" into a "simple-framebuffer" compatible mode. +* If the mode is incompatible, we return "false" and let the caller create +* legacy nodes instead. +*/ + +#include <linux/err.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/mm.h> +#include <linux/platform_data/simplefb.h> +#include <linux/platform_device.h> +#include <linux/screen_info.h> +#include <asm/sysfb.h> + +static const char simplefb_resname[] ="BOOTFB" ; +static const struct simplefb_format formats[] =SIMPLEFB_FORMATS ; + +/* try parsing x86 screen_info into a simple-framebuffer mode struct */ +__init bool parse_mode (const struct screen_info *si, +struct simplefb_platform_data *mode) +{ +const struct simplefb_format *f; +__u8 type; +unsigned int i; + + type = si->orig_video_isVGA; +if (type !=VIDEO_TYPE_VLFB && type !=VIDEO_TYPE_EFI ) +return false; + +for (i =0 ; i <ARRAY_SIZE (formats); ++i) { + f = &formats[i]; +if (si->lfb_depth == f->bits_per_pixel && + si->red_size == f->red.length && + si->red_pos == f->red.offset && + si->green_size == f->green.length && + si->green_pos == f->green.offset && + si->blue_size == f->blue.length && + si->blue_pos == f->blue.offset && + si->rsvd_size == f->transp.length && + si->rsvd_pos == f->transp.offset) { + mode->format = f->name; + mode->width = si->lfb_width; + mode->height = si->lfb_height; + mode->stride = si->lfb_linelength; +return true; + } + } + +return false; +} + +__init int create_simplefb (const struct screen_info *si, +const struct simplefb_platform_data *mode) +{ +struct platform_device *pd; +struct resource res; +unsigned long len; + +/* don't use lfb_size as it may contain the whole VMEM instead of only +* the part that is occupied by the framebuffer */ + len = mode->height * mode->stride; + len =PAGE_ALIGN (len); +if (len > si->lfb_size <<16 ) { +printk (KERN_WARNING "sysfb: VRAM smaller than advertised\n" ); +return -EINVAL ; + } + +/* setup IORESOURCE_MEM as framebuffer memory */ +memset (&res,0 ,sizeof (res)); + res.flags =IORESOURCE_MEM ; + res.name = simplefb_resname; + res.start = si->lfb_base; + res.end = si->lfb_base + len -1 ; +if (res.end <= res.start) +return -EINVAL ; + + pd =platform_device_register_resndata (NULL ,"simple-framebuffer" ,0 , + &res,1 , mode,sizeof (*mode)); +if (IS_ERR (pd)) +return PTR_ERR (pd); + +return 0 ; +} --1.8.3.2
PATCH v2 4/14 x86: sysfb: move EFI quirks from efifb to sysfb
In reply to David HerrmannThe 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
@@ -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
@@ -102,6 +102,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
arch/x86/kernel/sysfb.c +3 -0
@@ -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.2
PATCH v2 5/14 fbdev: simplefb: add 32bit RGB formats
In reply to David Herrmann32bit XRGB and ARGB are used by modern x86 systems for EFI and VESA framebuffers. Add both variants so simplefb can be used on such systems.
--- include/linux/platform_data/simplefb.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/platform_data/simplefb.h +2 -0
@@ -20,6 +20,8 @@#define SIMPLEFB_FORMATS \ { \ { "r5g6b5", 16, {11, 5}, {5, 6}, {0, 5}, {0, 0}, DRM_FORMAT_RGB565 }, \ + { "a8r8g8b8", 32, {16, 8}, {8, 8}, {0, 8}, {24, 8}, DRM_FORMAT_ARGB8888 }, \ + { "x8r8g8b8", 32, {16, 8}, {8, 8}, {0, 8}, {0, 0}, DRM_FORMAT_XRGB8888 }, \ }/*
Signature · 1 line
1.8.3.2
PATCH v2 6/14 fbdev: vesafb: bind to platform-framebuffer device
In reply to David Herrmannx86 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
@@ -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.2
PATCH v2 7/14 fbdev: efifb: bind to efi-framebuffer
In reply to David HerrmannInstead 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
@@ -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.2
PATCH v2 8/14 fbdev: fbcon: select VT_HW_CONSOLE_BINDING
In reply to David Herrmannfbdev 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
@@ -89,7 +89,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 help Low-level framebuffer-based console driver.
Signature · 1 line
1.8.3.2
PATCH v2 9/14 drm: add SimpleDRM driver
In reply to David HerrmannThe SimpleDRM driver binds to simple-framebuffer devices and provides a DRM/KMS API. It provides only a single CRTC+encoder+connector combination plus one initial mode.
Userspace can create one dumb-buffer and attach it to the CRTC. Only if the buffer is destroyed, a new buffer can be created. The buffer is directly mapped into user-space, so we have only resources for a single buffer. Otherwise, shadow buffers plus damage-request would be needed.
--- MAINTAINERS | 8 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/simpledrm/Kconfig | 18 ++ drivers/gpu/drm/simpledrm/Makefile | 5 + drivers/gpu/drm/simpledrm/simpledrm.h | 89 ++++++++ drivers/gpu/drm/simpledrm/simpledrm_drv.c | 226 ++++++++++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_main.c | 328 +++++++++++++++++++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_mem.c | 252 ++++++++++++++++++++++ 9 files changed, 929 insertions(+) create mode 100644 drivers/gpu/drm/simpledrm/Kconfig create mode 100644 drivers/gpu/drm/simpledrm/Makefile create mode 100644 drivers/gpu/drm/simpledrm/simpledrm.h create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_drv.c create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_main.c create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_mem.c
MAINTAINERS +8 -0
@@ -7305,6 +7305,14 @@ S: Odd Fixes F: drivers/media/platform/sh_vou.c F: include/media/sh_vou.h +SIMPLE DRM DRIVER +M: David Herrmann <[email protected]> +L: [email protected] +T: git git://people.freedesktop.org/~dvdhrm/linux +S: Maintained +F: drivers/gpu/drm/simpledrm +F: include/linux/platform_data/simpledrm.h + SIMPLE FIRMWARE INTERFACE (SFI) M: Len Brown <[email protected]> L: [email protected]
drivers/gpu/drm/Kconfig +2 -0
@@ -220,3 +220,5 @@ source "drivers/gpu/drm/omapdrm/Kconfig" source "drivers/gpu/drm/tilcdc/Kconfig" source "drivers/gpu/drm/qxl/Kconfig" + +source "drivers/gpu/drm/simpledrm/Kconfig"
drivers/gpu/drm/Makefile +1 -0
@@ -52,4 +52,5 @@ obj-$(CONFIG_DRM_SHMOBILE) +=shmobile/ obj-$(CONFIG_DRM_OMAP) += omapdrm/ obj-$(CONFIG_DRM_TILCDC) += tilcdc/ obj-$(CONFIG_DRM_QXL) += qxl/ +obj-$(CONFIG_DRM_SIMPLEDRM) += simpledrm/ obj-y += i2c/
drivers/gpu/drm/simpledrm/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +config DRM_SIMPLEDRM + tristate "Simple firmware framebuffer DRM driver" + depends on DRM && !FB_SIMPLE + help + SimpleDRM can run on all systems with pre-initialized graphics + hardware. It uses a framebuffer that was initialized during + firmware boot. No page-flipping, modesetting or other advanced + features are available. However, other DRM drivers can be loaded + later and take over from SimpleDRM if they provide real hardware + support. + + SimpleDRM supports "simple-framebuffer" DeviceTree objects and + compatible platform framebuffers. + + If unsure, say Y. + + To compile this driver as a module, choose M here: the + module will be called simpledrm.
drivers/gpu/drm/simpledrm/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +ccflags-y := -Iinclude/drm + +simpledrm-y := simpledrm_drv.o simpledrm_main.o simpledrm_mem.o + +obj-$(CONFIG_DRM_SIMPLEDRM) := simpledrm.o
drivers/gpu/drm/simpledrm/simpledrm.h new file +89 -0
89 lines not on this page · raw message
drivers/gpu/drm/simpledrm/simpledrm_drv.c new file +226 -0
226 lines not on this page · raw message
drivers/gpu/drm/simpledrm/simpledrm_main.c new file +328 -0
328 lines not on this page · raw message
drivers/gpu/drm/simpledrm/simpledrm_mem.c new file +252 -0
252 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH v2 10/14 drm: simpledrm: add fbdev fallback support
In reply to David HerrmannCreate a simple fbdev device during SimpleDRM setup so legacy user-space and fbcon can use it.
--- drivers/gpu/drm/simpledrm/Kconfig | 11 ++ drivers/gpu/drm/simpledrm/Makefile | 1 + drivers/gpu/drm/simpledrm/simpledrm.h | 22 ++++ drivers/gpu/drm/simpledrm/simpledrm_fbdev.c | 153 ++++++++++++++++++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_main.c | 2 + 5 files changed, 189 insertions(+) create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_fbdev.c
drivers/gpu/drm/simpledrm/Kconfig +11 -0
@@ -12,7 +12,18 @@ config DRM_SIMPLEDRM SimpleDRM supports "simple-framebuffer" DeviceTree objects and compatible platform framebuffers. + If fbdev support is enabled, this driver will also provide an fbdev + compatibility layer. + If unsure, say Y. To compile this driver as a module, choose M here: the module will be called simpledrm. + +config DRM_SIMPLEDRM_FBDEV + bool + depends on DRM_SIMPLEDRM && FB + default y + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT
drivers/gpu/drm/simpledrm/Makefile +1 -0
@@ -1,5 +1,6 @@ ccflags-y := -Iinclude/drm simpledrm-y := simpledrm_drv.o simpledrm_main.o simpledrm_mem.o +simpledrm-$(CONFIG_DRM_SIMPLEDRM_FBDEV) += simpledrm_fbdev.o obj-$(CONFIG_DRM_SIMPLEDRM) := simpledrm.o
drivers/gpu/drm/simpledrm/simpledrm.h +22 -0
@@ -46,6 +46,9 @@ struct sdrm_device {struct drm_encoder enc;struct drm_connector conn;struct drm_display_mode *mode; + +/* fbdev */ +struct fb_info *fbdev; };int sdrm_drm_load (struct drm_device *ddev,unsigned long flags);
@@ -86,4 +89,23 @@ struct sdrm_framebuffer {#define to_sdrm_fb (x) container_of(x, struct sdrm_framebuffer, base) +/* simpledrm fbdev helpers */ + +#ifdef CONFIG_DRM_SIMPLEDRM_FBDEV + +void sdrm_fbdev_init (struct sdrm_device *sdrm); +void sdrm_fbdev_cleanup (struct sdrm_device *sdrm); + +#else /* CONFIG_DRM_SIMPLEDRM_FBDEV */ + +static inline void sdrm_fbdev_init (struct sdrm_device *sdrm) +{ +} + +static inline void sdrm_fbdev_cleanup (struct sdrm_device *sdrm) +{ +} + +#endif /* CONFIG_DRM_SIMPLEDRM_FBDEV */ +#endif /* SDRM_DRV_H */
drivers/gpu/drm/simpledrm/simpledrm_fbdev.c new file +153 -0
153 lines not on this page · raw message
drivers/gpu/drm/simpledrm/simpledrm_main.c +2 -0
@@ -303,6 +303,7 @@ int sdrm_drm_load(struct drm_device *ddev, unsigned long flags)if (ret) goto err_cleanup; +sdrm_fbdev_init (sdrm);return 0 ; err_cleanup:
@@ -320,6 +321,7 @@ int sdrm_drm_unload(struct drm_device *ddev) {struct sdrm_device *sdrm = ddev->dev_private; +sdrm_fbdev_cleanup (sdrm);drm_mode_config_cleanup (ddev);sdrm_pdev_destroy (sdrm);kfree (sdrm);
Signature · 1 line
1.8.3.2
PATCH v2 11/14 drm: add helpers to kick out firmware drivers
In reply to David HerrmannIf we load a real hardware DRM driver, we want all firmware drivers to be unloaded. Historically, this was done via remove_conflicting_framebuffers(), but for DRM drivers (like SimpleDRM) we need a new way.
This patch introduces DRIVER_FIRMWARE and DRM apertures to provide a quite similar way to kick out firmware DRM drivers. Additionally, unlike the fbdev equivalent, DRM firmware drivers can now query the system whether a real hardware driver is already loaded and prevent loading themselves.
Whenever a real hardware DRM driver is loaded which claims to provide the boot fw FB, we invalidate the firmware framebuffer. Otherwise, simpledrm could be loaded again, after a real hw-driver was unloaded (which is very unlikely to work, except if hw-drivers reset fw FBs during unload). Note that fbdev doesn't provide such protection against late driver probing.
--- drivers/gpu/drm/drm_pci.c | 1 + drivers/gpu/drm/drm_platform.c | 1 + drivers/gpu/drm/drm_stub.c | 118 +++++++++++++++++++++++++++++ drivers/gpu/drm/drm_usb.c | 1 + drivers/gpu/drm/simpledrm/simpledrm.h | 1 + drivers/gpu/drm/simpledrm/simpledrm_drv.c | 3 +- drivers/gpu/drm/simpledrm/simpledrm_main.c | 33 ++++++++ include/drm/drmP.h | 26 +++++++ 8 files changed, 183 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_pci.c +1 -0
@@ -366,6 +366,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, }list_add_tail (&dev->driver_item, &driver->device_list); +list_add_tail (&dev->global_item, &drm_devlist); DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n", driver->name, driver->major, driver->minor, driver->patchlevel,
drivers/gpu/drm/drm_platform.c +1 -0
@@ -88,6 +88,7 @@ int drm_get_platform_dev(struct platform_device *platdev, }list_add_tail (&dev->driver_item, &driver->device_list); +list_add_tail (&dev->global_item, &drm_devlist);mutex_unlock (&drm_global_mutex);
drivers/gpu/drm/drm_stub.c +118 -0
134 lines not on this page · raw message
drivers/gpu/drm/drm_usb.c +1 -0
@@ -50,6 +50,7 @@ int drm_get_usb_dev(struct usb_interface *interface, goto err_g3;list_add_tail (&dev->driver_item, &driver->device_list); +list_add_tail (&dev->global_item, &drm_devlist);mutex_unlock (&drm_global_mutex);
drivers/gpu/drm/simpledrm/simpledrm.h +1 -0
@@ -53,6 +53,7 @@ struct sdrm_device {int sdrm_drm_load (struct drm_device *ddev,unsigned long flags);int sdrm_drm_unload (struct drm_device *ddev); +void sdrm_drm_kick_out_firmware (struct drm_device *ddev);int sdrm_drm_mmap (struct file *filp,struct vm_area_struct *vma);int sdrm_pdev_init (struct sdrm_device *sdrm);void sdrm_pdev_destroy (struct sdrm_device *sdrm);
drivers/gpu/drm/simpledrm/simpledrm_drv.c +2 -1
@@ -34,9 +34,10 @@ static const struct file_operations sdrm_drm_fops = { };static struct drm_driver sdrm_drm_driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_FIRMWARE , .load = sdrm_drm_load, .unload = sdrm_drm_unload, + .kick_out_firmware = sdrm_drm_kick_out_firmware, .fops = &sdrm_drm_fops, .gem_init_object = sdrm_gem_init_object,
drivers/gpu/drm/simpledrm/simpledrm_main.c +33 -0
@@ -267,6 +267,21 @@ int sdrm_drm_load(struct drm_device *ddev, unsigned long flags)if (ret) goto err_name; + ddev->apertures =alloc_apertures (1 ); +if (!ddev->apertures) { + ret = -ENOMEM ; + goto err_pdev; + } + + ddev->apertures->ranges[0 ].base = sdrm->fb_base; + ddev->apertures->ranges[0 ].size = sdrm->fb_size; + +if (drm_is_firmware_used (ddev->apertures)) { +dev_info (ddev->dev,"firmware framebuffer is already in use\n" ); + ret = -EBUSY ; + goto err_apert; + } +drm_mode_config_init (ddev); ddev->mode_config.min_width =0 ; ddev->mode_config.min_height =0 ;
@@ -308,6 +323,9 @@ int sdrm_drm_load(struct drm_device *ddev, unsigned long flags) err_cleanup:drm_mode_config_cleanup (ddev); +err_apert: +kfree (ddev->apertures); +err_pdev:sdrm_pdev_destroy (sdrm); err_name:kfree (ddev->devname);
@@ -328,3 +346,18 @@ int sdrm_drm_unload(struct drm_device *ddev)return 0 ; } + +void sdrm_drm_kick_out_firmware (struct drm_device *ddev) +{ +struct sdrm_device *sdrm = ddev->dev_private; + +mutex_lock (&ddev->struct_mutex); + +sdrm_fbdev_cleanup (sdrm); +drm_unplug_dev_locked (ddev); +if (sdrm->fb_obj) +sdrm_gem_unmap_object (sdrm->fb_obj); +sdrm_pdev_destroy (sdrm); + +mutex_unlock (&ddev->struct_mutex); +}
include/drm/drmP.h +26 -0
@@ -47,6 +47,7 @@#include <linux/fs.h> #include <linux/proc_fs.h> #include <linux/init.h> +#include <linux/fb.h> #include <linux/file.h> #include <linux/platform_device.h> #include <linux/pci.h>
@@ -156,6 +157,7 @@ int drm_err(const char *func, const char *format, ...);#define DRIVER_GEM 0x1000#define DRIVER_MODESET 0x2000#define DRIVER_PRIME 0x4000 +#define DRIVER_FIRMWARE 0x8000#define DRIVER_BUS_PCI 0x1#define DRIVER_BUS_PLATFORM 0x2
@@ -954,6 +956,23 @@ struct drm_driver {struct drm_device *dev, uint32_t handle); +/** +* kick_out_firmware - kick out firmware driver +* @dev: DRM device +* +* Iff this driver has DRIVER_FIRMWARE set, this function is called +* when a real hw-driver is loaded and claims the framebuffer memory +* that is mapped by the firmware driver. This is called with the +* global drm mutex held. +* Drivers should unmap any memory-mappings, disable the device and +* schedule a driver removal. +* +* Note that a driver setting DRIVER_FIRMWARE is supposed to also set +* the "apertures" information on @dev. It is used to match the memory +* regions that are used by firmware drivers. +*/ +void (*kick_out_firmware) (struct drm_device *dev); +/* Driver private ops for this object */ const struct vm_operations_struct *gem_vm_ops;
@@ -1077,6 +1096,7 @@ struct drm_pending_vblank_event {*/ struct drm_device {struct list_head driver_item;/**< list of devices per driver */ +struct list_head global_item;/**< global list of devices */ char *devname;/**< For /proc/interrupts */ int if_version;/**< Highest interface version set */
@@ -1218,6 +1238,8 @@ struct drm_device {int switch_power_state;atomic_t unplugged;/* device has been unplugged or gone away */ +struct apertures_struct *apertures;/**< fbmem apertures */ +bool apert_boot;/**< true if mapped as boot fb */ };#define DRM_SWITCH_POWER_ON 0
@@ -1532,6 +1554,10 @@ extern void drm_master_put(struct drm_master **master);extern void drm_put_dev (struct drm_device *dev);extern int drm_put_minor (struct drm_minor **minor);extern void drm_unplug_dev (struct drm_device *dev); +extern void drm_unplug_dev_locked (struct drm_device *dev); +extern void drm_kick_out_firmware (struct apertures_struct *ap,bool boot); +extern bool drm_is_firmware_used (struct apertures_struct *ap); +extern struct list_head drm_devlist;extern unsigned int drm_debug;extern unsigned int drm_vblank_offdelay;
Signature · 1 line
1.8.3.2
PATCH v2 12/14 drm: nouveau: kick out firmware drivers during probe
In reply to David HerrmannUse the new DRM infrastructure to kick out firmware drivers before probing the real driver.
--- drivers/gpu/drm/nouveau/nouveau_drm.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +22 -7
@@ -233,13 +233,11 @@ nouveau_accel_init(struct nouveau_drm *drm)nouveau_bo_move_init (drm); } -static int nouveau_drm_probe (struct pci_dev *pdev, -const struct pci_device_id *pent) +static int nouveau_kick_out_firmware (struct drm_device *dev) { -struct nouveau_device *device;struct apertures_struct *aper;bool boot = false; -int ret; +struct pci_dev *pdev = dev->pdev;/* remove conflicting drivers (vesafb, efifb etc) */ aper =alloc_apertures (3 );
@@ -265,8 +263,18 @@ static int nouveau_drm_probe(struct pci_dev *pdev,#ifdef CONFIG_X86 boot = pdev->resource[PCI_ROM_RESOURCE ].flags &IORESOURCE_ROM_SHADOW ;#endif -remove_conflicting_framebuffers (aper,"nouveaufb" , boot); -kfree (aper); + +drm_kick_out_firmware (aper, boot); + dev->apertures = aper; + dev->apert_boot = boot; +return 0 ; +} + +static int nouveau_drm_probe (struct pci_dev *pdev, +const struct pci_device_id *pent) +{ +struct nouveau_device *device; +int ret; ret =nouveau_device_create (pdev,nouveau_name (pdev),pci_name (pdev), nouveau_config, nouveau_debug, &device);
@@ -294,9 +302,13 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)struct nouveau_drm *drm;int ret; - ret =nouveau_cli_create (pdev,"DRM" ,sizeof (*drm), (void **)&drm); + ret =nouveau_kick_out_firmware (dev);if (ret)return ret; + + ret =nouveau_cli_create (pdev,"DRM" ,sizeof (*drm), (void **)&drm); +if (ret) + goto fail_apert;lockdep_set_class (&drm->client.mutex, &drm_client_lock_class_key); dev->dev_private = drm;
@@ -392,6 +404,9 @@ fail_ttm:nouveau_vga_fini (drm); fail_device:nouveau_cli_destroy (&drm->client); +fail_apert: +kfree (dev->apertures); + dev->apertures =NULL ;return ret; }
Signature · 1 line
1.8.3.2
PATCH v2 13/14 drm/i915: use new drm_kick_out_firmware()
In reply to David HerrmannUse the new DRM infrastructure to kick out firmware DRM drivers before loading i915.
--- drivers/gpu/drm/i915/i915_dma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +3 -3
@@ -1436,9 +1436,9 @@ static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv) primary = pdev->resource[PCI_ROM_RESOURCE ].flags &IORESOURCE_ROM_SHADOW ; -remove_conflicting_framebuffers (ap,"inteldrmfb" , primary); - -kfree (ap); +drm_kick_out_firmware (ap, primary); + dev_priv->dev->apertures = ap; + dev_priv->dev->apert_boot = primary; }static void i915_dump_device_info (struct drm_i915_private *dev_priv)
Signature · 1 line
1.8.3.2
PATCH v2 14/14 drm/radeon: use new drm_kick_out_firmware()
In reply to David HerrmannKick out firmware DRM and fbdev drivers via the new drm_kick_out_firmware() before loading radeon.
--- drivers/gpu/drm/radeon/radeon_drv.c | 28 ---------------------------- drivers/gpu/drm/radeon/radeon_kms.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 28 deletions(-)
drivers/gpu/drm/radeon/radeon_drv.c +0 -28
@@ -308,37 +308,9 @@ static struct drm_driver driver_old = {static struct drm_driver kms_driver; -static int radeon_kick_out_firmware_fb (struct pci_dev *pdev) -{ -struct apertures_struct *ap; -bool primary = false; - - ap =alloc_apertures (1 ); -if (!ap) -return -ENOMEM ; - - ap->ranges[0 ].base =pci_resource_start (pdev,0 ); - ap->ranges[0 ].size =pci_resource_len (pdev,0 ); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE ].flags &IORESOURCE_ROM_SHADOW ; -#endif -remove_conflicting_framebuffers (ap,"radeondrmfb" , primary); -kfree (ap); - -return 0 ; -} -static int radeon_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) { -int ret; - -/* Get rid of things like offb */ - ret =radeon_kick_out_firmware_fb (pdev); -if (ret) -return ret; -return drm_get_pci_dev (pdev, ent, &kms_driver); }
drivers/gpu/drm/radeon/radeon_kms.c +30 -0
@@ -62,6 +62,30 @@ done_free:return 0 ; } +static int radeon_kick_out_firmware (struct drm_device *dev) +{ +struct pci_dev *pdev = dev->pdev; +struct apertures_struct *ap; +bool primary = false; + + ap =alloc_apertures (1 ); +if (!ap) +return -ENOMEM ; + + ap->ranges[0 ].base =pci_resource_start (pdev,0 ); + ap->ranges[0 ].size =pci_resource_len (pdev,0 ); + +#ifdef CONFIG_X86 + primary = pdev->resource[PCI_ROM_RESOURCE ].flags &IORESOURCE_ROM_SHADOW ; +#endif + +drm_kick_out_firmware (ap, primary); + dev->apertures = ap; + dev->apert_boot = primary; + +return 0 ; +} +/** * radeon_driver_load_kms - Main load function for KMS. *
@@ -86,6 +110,12 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) } dev->dev_private = (void *)rdev; + r =radeon_kick_out_firmware (dev); +if (r) { +kfree (rdev); +return r; + } +/* update BUS flag */ if (drm_pci_device_is_agp (dev)) { flags |=RADEON_IS_AGP ;
Signature · 1 line
1.8.3.2
H. Peter Anvin
reviewerQuoted 2 lines · David Herrmann
- What FB formats are common on x86 that we should add to
SIMPLEFB_FORMATS? (other than ARGB/XRGB32)
The common pixel formats on x86 are:
- Palettized 4-bit planar (bigendian, i.e. MSB to the left)
- Palettized 8-bit packed (one byte per pixel)
- 16-bit RGB555 (16-bit littleendian words with R=14:10, G=9:5, B=4:0)
- 16-bit RGB565 (16-bit littleendian words with R=15:11, G=10:5, B=4:0)
- 24-bit RGB888 in littleendian order (first byte in memory is B, second is G, third is R)
- 32-bit ARGB8888 (first byte in memory is B, second G, third R, fourth unused in the framebuffer proper)
- 32-bit RGB10:10:10 (I *believe* 32-bit littleendian words with R=29:20, G=19:10, B=9:0)
-hpa
Hi
Quoted 11 lines · H. Peter Anvin
Quoted 4 lines · David Herrmann
- What FB formats are common on x86 that we should add to
SIMPLEFB_FORMATS?
(other than ARGB/XRGB32)The common pixel formats on x86 are:
- Palettized 4-bit planar (bigendian, i.e. MSB to the left)
- Palettized 8-bit packed (one byte per pixel)
Unlikely to be supported with DRM. But if users want it, we can always add a shadow-buffer and advertise it as RGB332 or alike. Otherwise, they have to use fbdev as usual, which sounds reasonable to me.
Quoted 1 line
- 16-bit RGB555 (16-bit littleendian words with R=14:10, G=9:5, B=4:0)
DRM_FORMAT_XRGB1555
Quoted 1 line
- 16-bit RGB565 (16-bit littleendian words with R=15:11, G=10:5, B=4:0)
DRM_FORMAT_RGB565
Quoted 2 lines
- 24-bit RGB888 in littleendian order (first byte in memory is B, second is G, third is R)
DRM_FORMAT_RGB888
Quoted 2 lines
- 32-bit ARGB8888 (first byte in memory is B, second G, third R, fourth unused in the framebuffer proper)
DRM_FORMAT_ARGB8888
Quoted 2 lines
- 32-bit RGB10:10:10 (I *believe* 32-bit littleendian words with R=29:20, G=19:10, B=9:0)
DRM_FORMAT_XRGB2101010
Thanks for the hints, I will add these to patch #5. David
Quoted 6 lines · David Herrmann
Hi
This series changes the way we handle firmware framebuffers on x86 systems. On other architectures the recently introduced "simple-framebuffer" platform-devices provide a sane and proper way to handle firmware framebuffers. So why not use it on x86, too?
(This time I didn't see any issue with the FB content being blank; I must have forgotten a console= command-line parameter or something the last time around)
Hi
Quoted 8 lines · Stephen Warren
Quoted 6 lines · David Herrmann
Hi
This series changes the way we handle firmware framebuffers on x86 systems. On other architectures the recently introduced "simple-framebuffer" platform-devices provide a sane and proper way to handle firmware framebuffers. So why not use it on x86, too?
Quoted 5 lines
Tested-by Stephen Warren <[email protected]>(This time I didn't see any issue with the FB content being blank; I must have forgotten a console= command-line parameter or something the last time around)
I think I had some error in the pseudo_palette handling (which I now copied from simplefb.c), but I am not sure why it didn't work in v1. Thanks a lot for testing!
Regards
David