Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Implement DRM aperture helpers under video/

Implement DRM's aperture helpers under video/ for sharing with other
sub-systems. Remove DRM-isms from the interface. The helpers track
the ownership of framebuffer apertures and provide hand-over from
firmware, such as EFI and VESA, to native graphics drivers.

Other subsystems, such as fbdev and vfio, also have to maintain ownership
of framebuffer apertures. Moving DRM's aperture helpers to a more public
location allows all subsystems to interact with each other and share a
common implementation.

The aperture helpers are selected by the various firmware drivers within
DRM and fbdev, and the VGA text-console driver.

The original DRM interface is kept in place for use by DRM drivers.

v3:
* prefix all interfaces with aperture_ (Javier)
* rework and simplify documentation (Javier)
* rename struct dev_aperture to struct aperture_range
* rebase onto latest DRM
* update MAINTAINERS entry

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220622140134.12763-3-tzimmermann@suse.de

+448 -170
+13
Documentation/driver-api/aperture.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + Managing Ownership of the Framebuffer Aperture 4 + ============================================== 5 + 6 + .. kernel-doc:: drivers/video/aperture.c 7 + :doc: overview 8 + 9 + .. kernel-doc:: include/linux/aperture.h 10 + :internal: 11 + 12 + .. kernel-doc:: drivers/video/aperture.c 13 + :export:
+1
Documentation/driver-api/index.rst
··· 27 27 component 28 28 message-based 29 29 infiniband 30 + aperture 30 31 frame-buffer 31 32 regulator 32 33 reset
+2
MAINTAINERS
··· 6481 6481 T: git git://anongit.freedesktop.org/drm/drm-misc 6482 6482 F: drivers/gpu/drm/drm_aperture.c 6483 6483 F: drivers/gpu/drm/tiny/simpledrm.c 6484 + F: drivers/video/aperture.c 6484 6485 F: include/drm/drm_aperture.h 6486 + F: include/linux/aperture.h 6485 6487 6486 6488 DRM DRIVER FOR SIS VIDEO CARDS 6487 6489 S: Orphan / Obsolete
+9 -169
drivers/gpu/drm/drm_aperture.c
··· 1 1 // SPDX-License-Identifier: MIT 2 2 3 - #include <linux/device.h> 4 - #include <linux/fb.h> 5 - #include <linux/list.h> 6 - #include <linux/mutex.h> 7 - #include <linux/pci.h> 8 - #include <linux/platform_device.h> /* for firmware helpers */ 9 - #include <linux/slab.h> 10 - #include <linux/types.h> 11 - #include <linux/vgaarb.h> 3 + #include <linux/aperture.h> 4 + #include <linux/platform_device.h> 12 5 13 6 #include <drm/drm_aperture.h> 14 7 #include <drm/drm_drv.h> ··· 119 126 * afterwards. 120 127 */ 121 128 122 - struct drm_aperture { 123 - struct drm_device *dev; 124 - resource_size_t base; 125 - resource_size_t size; 126 - struct list_head lh; 127 - void (*detach)(struct drm_device *dev); 128 - }; 129 - 130 - static LIST_HEAD(drm_apertures); 131 - static DEFINE_MUTEX(drm_apertures_lock); 132 - 133 - static bool overlap(resource_size_t base1, resource_size_t end1, 134 - resource_size_t base2, resource_size_t end2) 135 - { 136 - return (base1 < end2) && (end1 > base2); 137 - } 138 - 139 - static void devm_aperture_acquire_release(void *data) 140 - { 141 - struct drm_aperture *ap = data; 142 - bool detached = !ap->dev; 143 - 144 - if (detached) 145 - return; 146 - 147 - mutex_lock(&drm_apertures_lock); 148 - list_del(&ap->lh); 149 - mutex_unlock(&drm_apertures_lock); 150 - } 151 - 152 - static int devm_aperture_acquire(struct drm_device *dev, 153 - resource_size_t base, resource_size_t size, 154 - void (*detach)(struct drm_device *)) 155 - { 156 - size_t end = base + size; 157 - struct list_head *pos; 158 - struct drm_aperture *ap; 159 - 160 - mutex_lock(&drm_apertures_lock); 161 - 162 - list_for_each(pos, &drm_apertures) { 163 - ap = container_of(pos, struct drm_aperture, lh); 164 - if (overlap(base, end, ap->base, ap->base + ap->size)) { 165 - mutex_unlock(&drm_apertures_lock); 166 - return -EBUSY; 167 - } 168 - } 169 - 170 - ap = devm_kzalloc(dev->dev, sizeof(*ap), GFP_KERNEL); 171 - if (!ap) { 172 - mutex_unlock(&drm_apertures_lock); 173 - return -ENOMEM; 174 - } 175 - 176 - ap->dev = dev; 177 - ap->base = base; 178 - ap->size = size; 179 - ap->detach = detach; 180 - INIT_LIST_HEAD(&ap->lh); 181 - 182 - list_add(&ap->lh, &drm_apertures); 183 - 184 - mutex_unlock(&drm_apertures_lock); 185 - 186 - return devm_add_action_or_reset(dev->dev, devm_aperture_acquire_release, ap); 187 - } 188 - 189 - static void drm_aperture_detach_firmware(struct drm_device *dev) 190 - { 191 - struct platform_device *pdev = to_platform_device(dev->dev); 192 - 193 - /* 194 - * Remove the device from the device hierarchy. This is the right thing 195 - * to do for firmware-based DRM drivers, such as EFI, VESA or VGA. After 196 - * the new driver takes over the hardware, the firmware device's state 197 - * will be lost. 198 - * 199 - * For non-platform devices, a new callback would be required. 200 - * 201 - * If the aperture helpers ever need to handle native drivers, this call 202 - * would only have to unplug the DRM device, so that the hardware device 203 - * stays around after detachment. 204 - */ 205 - platform_device_unregister(pdev); 206 - } 207 - 208 129 /** 209 130 * devm_aperture_acquire_from_firmware - Acquires ownership of a firmware framebuffer 210 131 * on behalf of a DRM driver. ··· 146 239 int devm_aperture_acquire_from_firmware(struct drm_device *dev, resource_size_t base, 147 240 resource_size_t size) 148 241 { 242 + struct platform_device *pdev; 243 + 149 244 if (drm_WARN_ON(dev, !dev_is_platform(dev->dev))) 150 245 return -EINVAL; 151 246 152 - return devm_aperture_acquire(dev, base, size, drm_aperture_detach_firmware); 247 + pdev = to_platform_device(dev->dev); 248 + 249 + return devm_aperture_acquire_for_platform_device(pdev, base, size); 153 250 } 154 251 EXPORT_SYMBOL(devm_aperture_acquire_from_firmware); 155 - 156 - static void drm_aperture_detach_drivers(resource_size_t base, resource_size_t size) 157 - { 158 - resource_size_t end = base + size; 159 - struct list_head *pos, *n; 160 - 161 - mutex_lock(&drm_apertures_lock); 162 - 163 - list_for_each_safe(pos, n, &drm_apertures) { 164 - struct drm_aperture *ap = 165 - container_of(pos, struct drm_aperture, lh); 166 - struct drm_device *dev = ap->dev; 167 - 168 - if (WARN_ON_ONCE(!dev)) 169 - continue; 170 - 171 - if (!overlap(base, end, ap->base, ap->base + ap->size)) 172 - continue; 173 - 174 - ap->dev = NULL; /* detach from device */ 175 - list_del(&ap->lh); 176 - 177 - ap->detach(dev); 178 - } 179 - 180 - mutex_unlock(&drm_apertures_lock); 181 - } 182 252 183 253 /** 184 254 * drm_aperture_remove_conflicting_framebuffers - remove existing framebuffers in the given range ··· 173 289 int drm_aperture_remove_conflicting_framebuffers(resource_size_t base, resource_size_t size, 174 290 bool primary, const struct drm_driver *req_driver) 175 291 { 176 - #if IS_REACHABLE(CONFIG_FB) 177 - struct apertures_struct *a; 178 - int ret; 179 - 180 - a = alloc_apertures(1); 181 - if (!a) 182 - return -ENOMEM; 183 - 184 - a->ranges[0].base = base; 185 - a->ranges[0].size = size; 186 - 187 - ret = remove_conflicting_framebuffers(a, req_driver->name, primary); 188 - kfree(a); 189 - 190 - if (ret) 191 - return ret; 192 - #endif 193 - 194 - drm_aperture_detach_drivers(base, size); 195 - 196 - return 0; 292 + return aperture_remove_conflicting_devices(base, size, primary, req_driver->name); 197 293 } 198 294 EXPORT_SYMBOL(drm_aperture_remove_conflicting_framebuffers); 199 295 ··· 192 328 int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, 193 329 const struct drm_driver *req_driver) 194 330 { 195 - resource_size_t base, size; 196 - int bar, ret; 197 - 198 - /* 199 - * WARNING: Apparently we must kick fbdev drivers before vgacon, 200 - * otherwise the vga fbdev driver falls over. 201 - */ 202 - #if IS_REACHABLE(CONFIG_FB) 203 - ret = remove_conflicting_pci_framebuffers(pdev, req_driver->name); 204 - if (ret) 205 - return ret; 206 - #endif 207 - ret = vga_remove_vgacon(pdev); 208 - if (ret) 209 - return ret; 210 - 211 - for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) { 212 - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) 213 - continue; 214 - base = pci_resource_start(pdev, bar); 215 - size = pci_resource_len(pdev, bar); 216 - drm_aperture_detach_drivers(base, size); 217 - } 218 - 219 - return 0; 331 + return aperture_remove_conflicting_pci_devices(pdev, req_driver->name); 220 332 } 221 333 EXPORT_SYMBOL(drm_aperture_remove_conflicting_pci_framebuffers);
+1
drivers/gpu/drm/tiny/Kconfig
··· 69 69 config DRM_SIMPLEDRM 70 70 tristate "Simple framebuffer driver" 71 71 depends on DRM && MMU 72 + select APERTURE_HELPERS 72 73 select DRM_GEM_SHMEM_HELPER 73 74 select DRM_KMS_HELPER 74 75 help
+6
drivers/video/Kconfig
··· 5 5 6 6 menu "Graphics support" 7 7 8 + config APERTURE_HELPERS 9 + bool 10 + help 11 + Support tracking and hand-over of aperture ownership. Required 12 + by graphics drivers for firmware-provided framebuffers. 13 + 8 14 if HAS_IOMEM 9 15 10 16 config HAVE_FB_ATMEL
+2
drivers/video/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 + 3 + obj-$(CONFIG_APERTURE_HELPERS) += aperture.o 2 4 obj-$(CONFIG_VGASTATE) += vgastate.o 3 5 obj-$(CONFIG_HDMI) += hdmi.o 4 6
+351
drivers/video/aperture.c
··· 1 + // SPDX-License-Identifier: MIT 2 + 3 + #include <linux/aperture.h> 4 + #include <linux/device.h> 5 + #include <linux/fb.h> /* for old fbdev helpers */ 6 + #include <linux/list.h> 7 + #include <linux/mutex.h> 8 + #include <linux/pci.h> 9 + #include <linux/platform_device.h> 10 + #include <linux/slab.h> 11 + #include <linux/types.h> 12 + #include <linux/vgaarb.h> 13 + 14 + /** 15 + * DOC: overview 16 + * 17 + * A graphics device might be supported by different drivers, but only one 18 + * driver can be active at any given time. Many systems load a generic 19 + * graphics drivers, such as EFI-GOP or VESA, early during the boot process. 20 + * During later boot stages, they replace the generic driver with a dedicated, 21 + * hardware-specific driver. To take over the device the dedicated driver 22 + * first has to remove the generic driver. Aperture functions manage 23 + * ownership of framebuffer memory and hand-over between drivers. 24 + * 25 + * Graphics drivers should call aperture_remove_conflicting_devices() 26 + * at the top of their probe function. The function removes any generic 27 + * driver that is currently associated with the given framebuffer memory. 28 + * An example for a graphics device on the platform bus is shown below. 29 + * 30 + * .. code-block:: c 31 + * 32 + * static int example_probe(struct platform_device *pdev) 33 + * { 34 + * struct resource *mem; 35 + * resource_size_t base, size; 36 + * int ret; 37 + * 38 + * mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 39 + * if (!mem) 40 + * return -ENODEV; 41 + * base = mem->start; 42 + * size = resource_size(mem); 43 + * 44 + * ret = aperture_remove_conflicting_devices(base, size, false, "example"); 45 + * if (ret) 46 + * return ret; 47 + * 48 + * // Initialize the hardware 49 + * ... 50 + * 51 + * return 0; 52 + * } 53 + * 54 + * static const struct platform_driver example_driver = { 55 + * .probe = example_probe, 56 + * ... 57 + * }; 58 + * 59 + * The given example reads the platform device's I/O-memory range from the 60 + * device instance. An active framebuffer will be located within this range. 61 + * The call to aperture_remove_conflicting_devices() releases drivers that 62 + * have previously claimed ownership of the range and are currently driving 63 + * output on the framebuffer. If successful, the new driver can take over 64 + * the device. 65 + * 66 + * While the given example uses a platform device, the aperture helpers work 67 + * with every bus that has an addressable framebuffer. In the case of PCI, 68 + * device drivers can also call aperture_remove_conflicting_pci_devices() and 69 + * let the function detect the apertures automatically. Device drivers without 70 + * knowledge of the framebuffer's location can call 71 + * aperture_remove_all_conflicting_devices(), which removes all known devices. 72 + * 73 + * Drivers that are susceptible to being removed by other drivers, such as 74 + * generic EFI or VESA drivers, have to register themselves as owners of their 75 + * framebuffer apertures. Ownership of the framebuffer memory is achieved 76 + * by calling devm_aperture_acquire_for_platform_device(). If successful, the 77 + * driveris the owner of the framebuffer range. The function fails if the 78 + * framebuffer is already owned by another driver. See below for an example. 79 + * 80 + * .. code-block:: c 81 + * 82 + * static int generic_probe(struct platform_device *pdev) 83 + * { 84 + * struct resource *mem; 85 + * resource_size_t base, size; 86 + * 87 + * mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 88 + * if (!mem) 89 + * return -ENODEV; 90 + * base = mem->start; 91 + * size = resource_size(mem); 92 + * 93 + * ret = devm_aperture_acquire_for_platform_device(pdev, base, size); 94 + * if (ret) 95 + * return ret; 96 + * 97 + * // Initialize the hardware 98 + * ... 99 + * 100 + * return 0; 101 + * } 102 + * 103 + * static int generic_remove(struct platform_device *) 104 + * { 105 + * // Hot-unplug the device 106 + * ... 107 + * 108 + * return 0; 109 + * } 110 + * 111 + * static const struct platform_driver generic_driver = { 112 + * .probe = generic_probe, 113 + * .remove = generic_remove, 114 + * ... 115 + * }; 116 + * 117 + * The similar to the previous example, the generic driver claims ownership 118 + * of the framebuffer memory from its probe function. This will fail if the 119 + * memory range, or parts of it, is already owned by another driver. 120 + * 121 + * If successful, the generic driver is now subject to forced removal by 122 + * another driver. This only works for platform drivers that support hot 123 + * unplugging. When a driver calls aperture_remove_conflicting_devices() 124 + * et al for the registered framebuffer range, the aperture helpers call 125 + * platform_device_unregister() and the generic driver unloads itself. The 126 + * generic driver also has to provide a remove function to make this work. 127 + * Once hot unplugged fro mhardware, it may not access the device's 128 + * registers, framebuffer memory, ROM, etc afterwards. 129 + */ 130 + 131 + struct aperture_range { 132 + struct device *dev; 133 + resource_size_t base; 134 + resource_size_t size; 135 + struct list_head lh; 136 + void (*detach)(struct device *dev); 137 + }; 138 + 139 + static LIST_HEAD(apertures); 140 + static DEFINE_MUTEX(apertures_lock); 141 + 142 + static bool overlap(resource_size_t base1, resource_size_t end1, 143 + resource_size_t base2, resource_size_t end2) 144 + { 145 + return (base1 < end2) && (end1 > base2); 146 + } 147 + 148 + static void devm_aperture_acquire_release(void *data) 149 + { 150 + struct aperture_range *ap = data; 151 + bool detached = !ap->dev; 152 + 153 + if (detached) 154 + return; 155 + 156 + mutex_lock(&apertures_lock); 157 + list_del(&ap->lh); 158 + mutex_unlock(&apertures_lock); 159 + } 160 + 161 + static int devm_aperture_acquire(struct device *dev, 162 + resource_size_t base, resource_size_t size, 163 + void (*detach)(struct device *)) 164 + { 165 + size_t end = base + size; 166 + struct list_head *pos; 167 + struct aperture_range *ap; 168 + 169 + mutex_lock(&apertures_lock); 170 + 171 + list_for_each(pos, &apertures) { 172 + ap = container_of(pos, struct aperture_range, lh); 173 + if (overlap(base, end, ap->base, ap->base + ap->size)) { 174 + mutex_unlock(&apertures_lock); 175 + return -EBUSY; 176 + } 177 + } 178 + 179 + ap = devm_kzalloc(dev, sizeof(*ap), GFP_KERNEL); 180 + if (!ap) { 181 + mutex_unlock(&apertures_lock); 182 + return -ENOMEM; 183 + } 184 + 185 + ap->dev = dev; 186 + ap->base = base; 187 + ap->size = size; 188 + ap->detach = detach; 189 + INIT_LIST_HEAD(&ap->lh); 190 + 191 + list_add(&ap->lh, &apertures); 192 + 193 + mutex_unlock(&apertures_lock); 194 + 195 + return devm_add_action_or_reset(dev, devm_aperture_acquire_release, ap); 196 + } 197 + 198 + static void aperture_detach_platform_device(struct device *dev) 199 + { 200 + struct platform_device *pdev = to_platform_device(dev); 201 + 202 + /* 203 + * Remove the device from the device hierarchy. This is the right thing 204 + * to do for firmware-based DRM drivers, such as EFI, VESA or VGA. After 205 + * the new driver takes over the hardware, the firmware device's state 206 + * will be lost. 207 + * 208 + * For non-platform devices, a new callback would be required. 209 + * 210 + * If the aperture helpers ever need to handle native drivers, this call 211 + * would only have to unplug the DRM device, so that the hardware device 212 + * stays around after detachment. 213 + */ 214 + platform_device_unregister(pdev); 215 + } 216 + 217 + /** 218 + * devm_aperture_acquire_for_platform_device - Acquires ownership of an aperture 219 + * on behalf of a platform device. 220 + * @pdev: the platform device to own the aperture 221 + * @base: the aperture's byte offset in physical memory 222 + * @size: the aperture size in bytes 223 + * 224 + * Installs the given device as the new owner of the aperture. The function 225 + * expects the aperture to be provided by a platform device. If another 226 + * driver takes over ownership of the aperture, aperture helpers will then 227 + * unregister the platform device automatically. All acquired apertures are 228 + * released automatically when the underlying device goes away. 229 + * 230 + * The function fails if the aperture, or parts of it, is currently 231 + * owned by another device. To evict current owners, callers should use 232 + * remove_conflicting_devices() et al. before calling this function. 233 + * 234 + * Returns: 235 + * 0 on success, or a negative errno value otherwise. 236 + */ 237 + int devm_aperture_acquire_for_platform_device(struct platform_device *pdev, 238 + resource_size_t base, 239 + resource_size_t size) 240 + { 241 + return devm_aperture_acquire(&pdev->dev, base, size, aperture_detach_platform_device); 242 + } 243 + EXPORT_SYMBOL(devm_aperture_acquire_for_platform_device); 244 + 245 + static void aperture_detach_devices(resource_size_t base, resource_size_t size) 246 + { 247 + resource_size_t end = base + size; 248 + struct list_head *pos, *n; 249 + 250 + mutex_lock(&apertures_lock); 251 + 252 + list_for_each_safe(pos, n, &apertures) { 253 + struct aperture_range *ap = container_of(pos, struct aperture_range, lh); 254 + struct device *dev = ap->dev; 255 + 256 + if (WARN_ON_ONCE(!dev)) 257 + continue; 258 + 259 + if (!overlap(base, end, ap->base, ap->base + ap->size)) 260 + continue; 261 + 262 + ap->dev = NULL; /* detach from device */ 263 + list_del(&ap->lh); 264 + 265 + ap->detach(dev); 266 + } 267 + 268 + mutex_unlock(&apertures_lock); 269 + } 270 + 271 + /** 272 + * aperture_remove_conflicting_devices - remove devices in the given range 273 + * @base: the aperture's base address in physical memory 274 + * @size: aperture size in bytes 275 + * @primary: also kick vga16fb if present; only relevant for VGA devices 276 + * @name: a descriptive name of the requesting driver 277 + * 278 + * This function removes devices that own apertures within @base and @size. 279 + * 280 + * Returns: 281 + * 0 on success, or a negative errno code otherwise 282 + */ 283 + int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t size, 284 + bool primary, const char *name) 285 + { 286 + #if IS_REACHABLE(CONFIG_FB) 287 + struct apertures_struct *a; 288 + int ret; 289 + 290 + a = alloc_apertures(1); 291 + if (!a) 292 + return -ENOMEM; 293 + 294 + a->ranges[0].base = base; 295 + a->ranges[0].size = size; 296 + 297 + ret = remove_conflicting_framebuffers(a, name, primary); 298 + kfree(a); 299 + 300 + if (ret) 301 + return ret; 302 + #endif 303 + 304 + aperture_detach_devices(base, size); 305 + 306 + return 0; 307 + } 308 + EXPORT_SYMBOL(aperture_remove_conflicting_devices); 309 + 310 + /** 311 + * aperture_remove_conflicting_pci_devices - remove existing framebuffers for PCI devices 312 + * @pdev: PCI device 313 + * @name: a descriptive name of the requesting driver 314 + * 315 + * This function removes devices that own apertures within any of @pdev's 316 + * memory bars. The function assumes that PCI device with shadowed ROM 317 + * drives a primary display and therefore kicks out vga16fb as well. 318 + * 319 + * Returns: 320 + * 0 on success, or a negative errno code otherwise 321 + */ 322 + int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name) 323 + { 324 + resource_size_t base, size; 325 + int bar, ret; 326 + 327 + /* 328 + * WARNING: Apparently we must kick fbdev drivers before vgacon, 329 + * otherwise the vga fbdev driver falls over. 330 + */ 331 + #if IS_REACHABLE(CONFIG_FB) 332 + ret = remove_conflicting_pci_framebuffers(pdev, name); 333 + if (ret) 334 + return ret; 335 + #endif 336 + ret = vga_remove_vgacon(pdev); 337 + if (ret) 338 + return ret; 339 + 340 + for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) { 341 + if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) 342 + continue; 343 + base = pci_resource_start(pdev, bar); 344 + size = pci_resource_len(pdev, bar); 345 + aperture_detach_devices(base, size); 346 + } 347 + 348 + return 0; 349 + 350 + } 351 + EXPORT_SYMBOL(aperture_remove_conflicting_pci_devices);
+1
drivers/video/console/Kconfig
··· 10 10 depends on !4xx && !PPC_8xx && !SPARC && !M68K && !PARISC && !SUPERH && \ 11 11 (!ARM || ARCH_FOOTBRIDGE || ARCH_INTEGRATOR || ARCH_NETWINDER) && \ 12 12 !ARM64 && !ARC && !MICROBLAZE && !OPENRISC && !S390 && !UML 13 + select APERTURE_HELPERS if (DRM || FB || VFIO_PCI_CORE) 13 14 default y 14 15 help 15 16 Saying Y here will allow you to use Linux in text mode through a
+6 -1
drivers/video/fbdev/Kconfig
··· 455 455 config FB_OF 456 456 bool "Open Firmware frame buffer device support" 457 457 depends on (FB = y) && PPC && (!PPC_PSERIES || PCI) 458 + select APERTURE_HELPERS 458 459 select FB_CFB_FILLRECT 459 460 select FB_CFB_COPYAREA 460 461 select FB_CFB_IMAGEBLIT ··· 528 527 config FB_VGA16 529 528 tristate "VGA 16-color graphics support" 530 529 depends on FB && (X86 || PPC) 530 + select APERTURE_HELPERS 531 531 select FB_CFB_FILLRECT 532 532 select FB_CFB_COPYAREA 533 533 select FB_CFB_IMAGEBLIT ··· 553 551 BIOS routines contained in a ROM chip in HP PA-RISC based machines. 554 552 Enabling this option will implement the linux framebuffer device 555 553 using calls to the STI BIOS routines for initialisation. 556 - 554 + 557 555 If you enable this option, you will get a planar framebuffer device 558 556 /dev/fb which will work on the most common HP graphic cards of the 559 557 NGLE family, including the artist chips (in the 7xx and Bxxx series), ··· 619 617 config FB_VESA 620 618 bool "VESA VGA graphics support" 621 619 depends on (FB = y) && X86 620 + select APERTURE_HELPERS 622 621 select FB_CFB_FILLRECT 623 622 select FB_CFB_COPYAREA 624 623 select FB_CFB_IMAGEBLIT ··· 633 630 config FB_EFI 634 631 bool "EFI-based Framebuffer Support" 635 632 depends on (FB = y) && !IA64 && EFI 633 + select APERTURE_HELPERS 636 634 select DRM_PANEL_ORIENTATION_QUIRKS 637 635 select FB_CFB_FILLRECT 638 636 select FB_CFB_COPYAREA ··· 2194 2190 tristate "Simple framebuffer support" 2195 2191 depends on FB 2196 2192 depends on !DRM_SIMPLEDRM 2193 + select APERTURE_HELPERS 2197 2194 select FB_CFB_FILLRECT 2198 2195 select FB_CFB_COPYAREA 2199 2196 select FB_CFB_IMAGEBLIT
+56
include/linux/aperture.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + 3 + #ifndef _LINUX_APERTURE_H_ 4 + #define _LINUX_APERTURE_H_ 5 + 6 + #include <linux/types.h> 7 + 8 + struct pci_dev; 9 + struct platform_device; 10 + 11 + #if defined(CONFIG_APERTURE_HELPERS) 12 + int devm_aperture_acquire_for_platform_device(struct platform_device *pdev, 13 + resource_size_t base, 14 + resource_size_t size); 15 + 16 + int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t size, 17 + bool primary, const char *name); 18 + 19 + int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name); 20 + #else 21 + static inline int devm_aperture_acquire_for_platform_device(struct platform_device *pdev, 22 + resource_size_t base, 23 + resource_size_t size) 24 + { 25 + return 0; 26 + } 27 + 28 + static inline int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t size, 29 + bool primary, const char *name) 30 + { 31 + return 0; 32 + } 33 + 34 + static inline int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name) 35 + { 36 + return 0; 37 + } 38 + #endif 39 + 40 + /** 41 + * aperture_remove_all_conflicting_devices - remove all existing framebuffers 42 + * @primary: also kick vga16fb if present; only relevant for VGA devices 43 + * @name: a descriptive name of the requesting driver 44 + * 45 + * This function removes all graphics device drivers. Use this function on systems 46 + * that can have their framebuffer located anywhere in memory. 47 + * 48 + * Returns: 49 + * 0 on success, or a negative errno code otherwise 50 + */ 51 + static inline int aperture_remove_all_conflicting_devices(bool primary, const char *name) 52 + { 53 + return aperture_remove_conflicting_devices(0, (resource_size_t)-1, primary, name); 54 + } 55 + 56 + #endif