From f1dbc266ccfe26c6b9a272e40a5bbe9afaa4f2e0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 2 Oct 2008 14:45:12 -0700 Subject: [PATCH] Work around libpciaccess reporting a 0 rom size by guessing. I required the following patch on top of this to work around libpciaccess brokenness. libpciaccess reports 0 rom size if there's no rom resource, even if the rom file exists in sysfs. --- src/i830_bios.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/i830_bios.c b/src/i830_bios.c index 726fe30f..007530dc 100644 --- a/src/i830_bios.c +++ b/src/i830_bios.c @@ -159,6 +159,8 @@ parse_general_features(I830Ptr pI830, struct bdb_header *bdb) } } +#define INTEL_VBIOS_SIZE (64 * 1024) /* XXX */ + /** * i830_bios_init - map VBIOS, find VBT * @@ -182,25 +184,35 @@ i830_bios_init(ScrnInfoPtr pScrn) #if XSERVER_LIBPCIACCESS size = pI830->PciInfo->rom_size; + if (size == 0) { + size = INTEL_VBIOS_SIZE; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "libpciaccess reported 0 rom size, guessing %dkB\n", + size / 1024); + } #else -#define INTEL_VBIOS_SIZE (64 * 1024) /* XXX */ size = INTEL_VBIOS_SIZE; #endif - if (size == 0) - return -1; bios = xalloc(size); if (bios == NULL) return -1; #if XSERVER_LIBPCIACCESS ret = pci_device_read_rom (pI830->PciInfo, bios); - if (ret != 0) + if (ret != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "libpciaccess failed to read %dkB video BIOS: %s\n", + size / 1024, strerror(-ret)); + xfree (bios); return -1; + } #else /* xf86ReadPciBIOS returns the length read */ ret = xf86ReadPciBIOS(0, pI830->PciTag, 0, bios, size); - if (ret <= 0) + if (ret <= 0) { + xfree (bios); return -1; + } #endif vbt_off = INTEL_BIOS_16(0x1a);