1347N/A--- a/hw/xfree86/os-support/solaris/sun_init.c Thu Apr 18 19:01:12 2013
1347N/A+++ b/hw/xfree86/os-support/solaris/sun_init.c Thu Apr 18 19:05:33 2013
1347N/A@@ -1,7 +1,8 @@
1347N/A /*
1347N/A * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
1347N/A * Copyright 1993 by David Wexelblat <dwex@goblin.org>
1347N/A * Copyright 1999 by David Holland <davidh@iquest.net>
1347N/A+ * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
1347N/A *
1347N/A * Permission to use, copy, modify, distribute, and sell this software and its
1347N/A * documentation for any purpose is hereby granted without fee, provided that
1347N/A@@ -66,6 +67,10 @@
1347N/A /* Set by -dev argument on CLI
1347N/A Used by hw/xfree86/common/xf86AutoConfig.c for VIS_GETIDENTIFIER */
1347N/A _X_HIDDEN char xf86SolarisFbDev[PATH_MAX] = "/dev/fb";
1347N/A+#if (defined(__sparc__) || defined(__sparc))
1347N/A+static void GetFbDevFromProbe(void);
1347N/A+static Bool xf86SolarisFbDevIsSet = FALSE;
1347N/A+#endif
1347N/A
1347N/A static void
1347N/A switch_to(int vt, const char *from)
1347N/A@@ -121,6 +126,16 @@
1347N/A }
1347N/A }
1347N/A
1347N/A+#if (defined(__sparc__) || defined(__sparc))
1347N/A+ {
1347N/A+ struct stat buf;
1347N/A+
1347N/A+ if (!xf86SolarisFbDevIsSet && (stat("/dev/fb", &buf) != 0) &&
1347N/A+ (xf86NumDrivers == 1))
1347N/A+ GetFbDevFromProbe();
1347N/A+ }
1347N/A+#endif
1347N/A+
1347N/A #ifdef HAS_USL_VTS
1347N/A
1347N/A /*
1347N/A@@ -409,6 +424,9 @@
1347N/A if ((i + 1) < argc) {
1347N/A if (!strcmp(argv[i], "-dev")) {
1347N/A strlcpy(xf86SolarisFbDev, argv[i + 1], sizeof(xf86SolarisFbDev));
1347N/A+#if (defined(__sparc__) || defined(__sparc))
1347N/A+ xf86SolarisFbDevIsSet = TRUE;
1347N/A+#endif
1347N/A return 2;
1347N/A }
1347N/A }
1347N/A@@ -416,6 +434,88 @@
1347N/A return 0;
1347N/A }
1347N/A
1347N/A+#if (defined(__sparc__) || defined(__sparc))
1347N/A+static void
1347N/A+GetFbDevFromProbe(void) {
1347N/A+ unsigned numDevs;
1347N/A+ GDevPtr *devList;
1347N/A+
1347N/A+ numDevs = xf86MatchDevice(xf86DriverList[0]->driverName, &devList);
1347N/A+
1347N/A+ if (numDevs != 1)
1347N/A+ return;
1347N/A+ else {
1347N/A+ struct pci_device_iterator *iter;
1347N/A+ unsigned device_id;
1347N/A+ const struct pci_id_match *const devices =
1347N/A+ xf86DriverList[0]->supported_devices;
1347N/A+ int i;
1347N/A+ Bool found = FALSE;
1347N/A+ struct pci_device *pPci;
1347N/A+ struct sol_device_private {
1347N/A+ struct pci_device base;
1347N/A+ const char * device_string;
1347N/A+ };
1347N/A+#define DEV_PATH(dev) (((struct sol_device_private *) dev)->device_string)
1347N/A+#define END_OF_MATCHES(m) \
1347N/A+ (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0))
1347N/A+
1347N/A+ /* Find the pciVideoRec associated with this device section.
1347N/A+ */
1347N/A+ iter = pci_id_match_iterator_create(NULL);
1347N/A+ while ((pPci = pci_device_next(iter)) != NULL) {
1347N/A+ if (devList[0]->busID && *devList[0]->busID) {
1347N/A+ if (xf86ComparePciBusString(devList[0]->busID,
1347N/A+ ((pPci->domain << 8)
1347N/A+ | pPci->bus),
1347N/A+ pPci->dev, pPci->func)) {
1347N/A+ break;
1347N/A+ }
1347N/A+ }
1347N/A+ else if (xf86IsPrimaryPci(pPci)) {
1347N/A+ break;
1347N/A+ }
1347N/A+ }
1347N/A+
1347N/A+ pci_iterator_destroy(iter);
1347N/A+
1347N/A+ if (pPci == NULL)
1347N/A+ return;
1347N/A+
1347N/A+ /* If driver provides supported_devices, then check if this
1347N/A+ device is on the list. Otherwise skip check.
1347N/A+ */
1347N/A+ if (!devices)
1347N/A+ found = TRUE;
1347N/A+ else {
1347N/A+ device_id = (devList[0]->chipID > 0)
1347N/A+ ? devList[0]->chipID : pPci->device_id;
1347N/A+
1347N/A+ /* Once the pciVideoRec is found, determine if the device is supported
1347N/A+ * by the driver.
1347N/A+ */
1347N/A+ for (i = 0; !END_OF_MATCHES(devices[i]); i++) {
1347N/A+ if (PCI_ID_COMPARE(devices[i].vendor_id, pPci->vendor_id)
1347N/A+ && PCI_ID_COMPARE(devices[i].device_id, device_id)
1347N/A+ && ((devices[i].device_class_mask & pPci->device_class)
1347N/A+ == devices[i].device_class)) {
1347N/A+
1347N/A+ found = TRUE;
1347N/A+ break;
1347N/A+ }
1347N/A+ }
1347N/A+ }
1347N/A+
1347N/A+ if (found) {
1347N/A+ strcpy(xf86SolarisFbDev, "/devices");
1347N/A+ strcat(xf86SolarisFbDev, DEV_PATH(pPci));
1347N/A+ xf86Msg(X_INFO, "Got xf86SolarisFbDev From Probe: %s\n", xf86SolarisFbDev);
1347N/A+ }
1347N/A+
1347N/A+ }
1347N/A+}
1347N/A+#endif
1347N/A+
1347N/A void
1347N/A xf86UseMsg(void)
1347N/A {