mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 22:15:40 +07:00
44adece57e
Lots of drivers don't properly compile without this when CONFIG_FB=n. It's kinda a hack, but since CONFIG_FB doesn't stub any fucntions when it's disabled I think it makes sense to add it to drm_fb_helper.h. Long term we probably need to rethink all the logic to unload firmware framebuffer drivers, at least if we want to be able to move away from CONFIG_FB and fbcon. v2: Unfortunately just stubbing out remove_conflicting_framebuffers in drm_fb_helper.h upset gcc about static vs. non-static declarations, so a new wrapper it needs to be. Means more churn :( Cc: Tobias Jakobi <tjakobi@math.uni-bielefeld.de> Cc: Noralf Trønnes <noralf@tronnes.org> Cc: tomi.valkeinen@ti.com Cc: dh.herrmann@gmail.com Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1470847958-28465-2-git-send-email-daniel.vetter@ffwll.ch
87 lines
2.5 KiB
C
87 lines
2.5 KiB
C
/*
|
|
* Copyright (C) 2015 Red Hat, Inc.
|
|
* All Rights Reserved.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
* a copy of this software and associated documentation files (the
|
|
* "Software"), to deal in the Software without restriction, including
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
* the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the
|
|
* next paragraph) shall be included in all copies or substantial
|
|
* portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
|
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include <linux/pci.h>
|
|
#include <drm/drm_fb_helper.h>
|
|
|
|
#include "virtgpu_drv.h"
|
|
|
|
static void virtio_pci_kick_out_firmware_fb(struct pci_dev *pci_dev)
|
|
{
|
|
struct apertures_struct *ap;
|
|
bool primary;
|
|
|
|
ap = alloc_apertures(1);
|
|
if (!ap)
|
|
return;
|
|
|
|
ap->ranges[0].base = pci_resource_start(pci_dev, 0);
|
|
ap->ranges[0].size = pci_resource_len(pci_dev, 0);
|
|
|
|
primary = pci_dev->resource[PCI_ROM_RESOURCE].flags
|
|
& IORESOURCE_ROM_SHADOW;
|
|
|
|
drm_fb_helper_remove_conflicting_framebuffers(ap, "virtiodrmfb", primary);
|
|
|
|
kfree(ap);
|
|
}
|
|
|
|
int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev)
|
|
{
|
|
struct drm_device *dev;
|
|
int ret;
|
|
|
|
dev = drm_dev_alloc(driver, &vdev->dev);
|
|
if (!dev)
|
|
return -ENOMEM;
|
|
dev->virtdev = vdev;
|
|
vdev->priv = dev;
|
|
|
|
if (strcmp(vdev->dev.parent->bus->name, "pci") == 0) {
|
|
struct pci_dev *pdev = to_pci_dev(vdev->dev.parent);
|
|
bool vga = (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA;
|
|
|
|
DRM_INFO("pci: %s detected\n",
|
|
vga ? "virtio-vga" : "virtio-gpu-pci");
|
|
dev->pdev = pdev;
|
|
if (vga)
|
|
virtio_pci_kick_out_firmware_fb(pdev);
|
|
}
|
|
|
|
ret = drm_dev_register(dev, 0);
|
|
if (ret)
|
|
goto err_free;
|
|
|
|
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", driver->name,
|
|
driver->major, driver->minor, driver->patchlevel,
|
|
driver->date, dev->primary->index);
|
|
|
|
return 0;
|
|
|
|
err_free:
|
|
drm_dev_unref(dev);
|
|
return ret;
|
|
}
|