Module Name:    xsrc
Committed By:   mrg
Date:           Wed Dec 23 22:21:01 UTC 2009

Modified Files:
        xsrc/external/mit/libpciaccess/dist/src: netbsd_pci.c

Log Message:
if a VGA device isn't enabled for io/mem/bus-master, do so here.
xorg-server 1.4.x and earlier would do this for us.

partly fixes dual-head support for various systems.

idea from mhitch.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c
diff -u xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.4 xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.5
--- xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.4	Thu Jul  9 19:27:08 2009
+++ xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c	Wed Dec 23 22:21:01 2009
@@ -272,6 +272,21 @@
 	dev = device->dev;
 	func = device->func;
 
+	/* Enable the device if necessary */
+	err = pci_read(domain, bus, dev, func, PCI_COMMAND_STATUS_REG, &reg);
+	if (err)
+		return err;
+	if ((reg & (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE)) !=
+	    (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE)) {
+		reg |= PCI_COMMAND_IO_ENABLE |
+		       PCI_COMMAND_MEM_ENABLE |
+		       PCI_COMMAND_MASTER_ENABLE;
+		err = pci_write(domain, bus, dev, func, PCI_COMMAND_STATUS_REG,
+				reg);
+		if (err)
+			return err;
+	}
+
 	err = pci_read(domain, bus, dev, func, PCI_BHLC_REG, &reg);
 	if (err)
 		return err;
@@ -454,7 +469,7 @@
 	struct pci_device_private *device;
 	int bus, dev, func, ndevs, nfuncs, domain, pcifd;
 	uint32_t reg;
-	char devname[32];
+	char netbsd_devname[32];
 	struct pciio_businfo businfo;
 
 	pci_sys = calloc(1, sizeof(struct pci_system));
@@ -463,8 +478,8 @@
 
 	ndevs = 0;
 	nbuses = 0;
-	snprintf(devname, 32, "/dev/pci%d", nbuses);
-	pcifd = open(devname, O_RDWR);
+	snprintf(netbsd_devname, 32, "/dev/pci%d", nbuses);
+	pcifd = open(netbsd_devname, O_RDWR);
 	while (pcifd > 0) {
 		ioctl(pcifd, PCI_IOC_BUSINFO, &businfo);
 		buses[nbuses].fd = pcifd;
@@ -485,8 +500,8 @@
 				ndevs++;
 			}
 		}
-		snprintf(devname, 32, "/dev/pci%d", nbuses);
-		pcifd = open(devname, O_RDWR);
+		snprintf(netbsd_devname, 32, "/dev/pci%d", nbuses);
+		pcifd = open(netbsd_devname, O_RDWR);
 	}
 
 	pci_sys->num_devices = ndevs;

Reply via email to