// SPDX-License-Identifier: GPL-2.0-or-later /* * Generic System Framebuffers * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com>
*/
/* * Simple-Framebuffer support * 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_SYSFB_SIMPLEFB is not selected, 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 OF/DT parsers to create such devices, too. However, they must * start at offset 1 for this to work.
*/
staticbool sysfb_unregister(void)
{ if (IS_ERR_OR_NULL(pd)) returnfalse;
platform_device_unregister(pd);
pd = NULL;
returntrue;
}
/** * sysfb_disable() - disable the Generic System Framebuffers support * @dev: the device to check if non-NULL * * This disables the registration of system framebuffer devices that match the * generic drivers that make use of the system framebuffer set up by firmware. * * It also unregisters a device if this was already registered by sysfb_init(). * * Context: The function can sleep. A @disable_lock mutex is acquired to serialize * against sysfb_init(), that registers a system framebuffer device.
*/ void sysfb_disable(struct device *dev)
{ struct screen_info *si = &screen_info; struct device *parent;
/** * sysfb_handles_screen_info() - reports if sysfb handles the global screen_info * * Callers can use sysfb_handles_screen_info() to determine whether the Generic * System Framebuffers (sysfb) can handle the global screen_info data structure * or not. Drivers might need this information to know if they have to setup the * system framebuffer, or if they have to delegate this action to sysfb instead. * * Returns: * True if sysfb handles the global screen_info data structure.
*/ bool sysfb_handles_screen_info(void)
{ conststruct screen_info *si = &screen_info;
#ifdefined(CONFIG_PCI) staticbool sysfb_pci_dev_is_enabled(struct pci_dev *pdev)
{ /* * TODO: Try to integrate this code into the PCI subsystem
*/ int ret;
u16 command;
ret = pci_read_config_word(pdev, PCI_COMMAND, &command); if (ret != PCIBIOS_SUCCESSFUL) returnfalse; if (!(command & PCI_COMMAND_MEMORY)) returnfalse; returntrue;
} #else staticbool sysfb_pci_dev_is_enabled(struct pci_dev *pdev)
{ returnfalse;
} #endif
static __init int sysfb_init(void)
{ struct screen_info *si = &screen_info; struct device *parent; unsignedint type; struct simplefb_platform_data mode; constchar *name; bool compatible; int ret = 0;
screen_info_apply_fixups();
mutex_lock(&disable_lock); if (disabled) goto unlock_mutex;
sysfb_apply_efi_quirks();
parent = sysfb_parent_dev(si); if (IS_ERR(parent)) {
ret = PTR_ERR(parent); goto unlock_mutex;
}
/* try to create a simple-framebuffer device */
compatible = sysfb_parse_mode(si, &mode); if (compatible) {
pd = sysfb_create_simplefb(si, &mode, parent); if (!IS_ERR(pd)) goto put_device;
}
type = screen_info_video_type(si);
/* if the FB is incompatible, create a legacy framebuffer device */ switch (type) { case VIDEO_TYPE_EGAC:
name = "ega-framebuffer"; break; case VIDEO_TYPE_VGAC:
name = "vga-framebuffer"; break; case VIDEO_TYPE_VLFB:
name = "vesa-framebuffer"; break; case VIDEO_TYPE_EFI:
name = "efi-framebuffer"; break; default:
name = "platform-framebuffer"; break;
}
pd = platform_device_alloc(name, 0); if (!pd) {
ret = -ENOMEM; goto put_device;
}
pd->dev.parent = parent;
sysfb_set_efifb_fwnode(pd);
ret = platform_device_add_data(pd, si, sizeof(*si)); if (ret) goto err;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.