16419614 sparc: X config improvement: remove dependency on /dev/fb and -dev option
16557880 sparc: need to restore pci bus probing in X server
--- a/open-src/driver/xf86-video-mga/Makefile Wed May 15 13:55:16 2013 -0700
+++ b/open-src/driver/xf86-video-mga/Makefile Wed May 22 11:43:48 2013 -0700
@@ -41,7 +41,6 @@
libraries.patch,-p1 \
g200se_pilot3_offscreen.patch,-p1 \
sparc.patch,-p1 \
- sparc-bus-probe.patch,-p1 \
rom_map.patch,-p1
# Man pages to apply Sun footer to & attributes to list
--- a/open-src/driver/xf86-video-mga/sparc-bus-probe.patch Wed May 15 13:55:16 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
---- a/src/mga_driver.c Fri Aug 10 17:30:22 2012
-+++ b/src/mga_driver.c Fri Aug 17 16:33:15 2012
-@@ -120,6 +120,9 @@
- static const OptionInfoRec * MGAAvailableOptions(int chipid, int busid);
- static void MGAIdentify(int flags);
- #ifdef XSERVER_LIBPCIACCESS
-+#ifdef __sparc__
-+static Bool MGACompProbe(DriverPtr drv, int flags);
-+#endif
- static Bool MGAPciProbe(DriverPtr drv, int entity_num,
- struct pci_device * dev, intptr_t match_data);
- #else
-@@ -535,7 +538,11 @@
- MGA_DRIVER_NAME,
- MGAIdentify,
- #ifdef XSERVER_LIBPCIACCESS
-+#ifdef __sparc__
-+ MGACompProbe,
-+#else
- NULL,
-+#endif
- #else
- MGAProbe,
- #endif
-@@ -4273,3 +4280,19 @@
-
- }
- #endif
-+
-+#ifdef __sparc__
-+static Bool
-+MGACompProbe(DriverPtr drvp, int flags)
-+{
-+ static Bool PciInitDone = FALSE;
-+
-+ /* Create pci system for use by the driver */
-+ if (!PciInitDone) {
-+ xf86BusProbe();
-+ PciInitDone = TRUE;
-+ }
-+
-+ return xf86PciProbeDev(drvp);
-+}
-+#endif
--- a/open-src/xserver/xorg/mapfile-Xorg-externs.sparc Wed May 15 13:55:16 2013 -0700
+++ b/open-src/xserver/xorg/mapfile-Xorg-externs.sparc Wed May 22 11:43:48 2013 -0700
@@ -1779,7 +1779,6 @@
xf86PMGetEventFromOs { FLAGS = EXTERN };
xf86ParsePciBusString { FLAGS = EXTERN };
xf86PathIsSafe { FLAGS = EXTERN };
- xf86PciProbeDev { FLAGS = EXTERN };
xf86Pix24 { FLAGS = EXTERN };
xf86PointerName { FLAGS = EXTERN };
xf86PostButtonEvent { FLAGS = EXTERN };
--- a/open-src/xserver/xorg/patch-list Wed May 15 13:55:16 2013 -0700
+++ b/open-src/xserver/xorg/patch-list Wed May 22 11:43:48 2013 -0700
@@ -27,5 +27,5 @@
record-regset.patch,-p1
autodetect-kernel-dev-fb.patch,-p1
workaround-7154410.patch,-p1
-sparc-no-bus-probe.patch,-p1
xaa-stpl-reduce-16.patch
+sparc-config-improv.patch,-p1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/xserver/xorg/sparc-config-improv.patch Wed May 22 11:43:48 2013 -0700
@@ -0,0 +1,138 @@
+--- a/hw/xfree86/os-support/solaris/sun_init.c Thu Apr 18 19:01:12 2013
++++ b/hw/xfree86/os-support/solaris/sun_init.c Thu Apr 18 19:05:33 2013
+@@ -1,7 +1,8 @@
+ /*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <[email protected]>
+ * Copyright 1999 by David Holland <[email protected]>
++ * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+@@ -66,6 +67,10 @@
+ /* Set by -dev argument on CLI
+ Used by hw/xfree86/common/xf86AutoConfig.c for VIS_GETIDENTIFIER */
+ _X_HIDDEN char xf86SolarisFbDev[PATH_MAX] = "/dev/fb";
++#if (defined(__sparc__) || defined(__sparc))
++static void GetFbDevFromProbe(void);
++static Bool xf86SolarisFbDevIsSet = FALSE;
++#endif
+
+ static void
+ switch_to(int vt, const char *from)
+@@ -121,6 +126,16 @@
+ }
+ }
+
++#if (defined(__sparc__) || defined(__sparc))
++ {
++ struct stat buf;
++
++ if (!xf86SolarisFbDevIsSet && (stat("/dev/fb", &buf) != 0) &&
++ (xf86NumDrivers == 1))
++ GetFbDevFromProbe();
++ }
++#endif
++
+ #ifdef HAS_USL_VTS
+
+ /*
+@@ -409,6 +424,9 @@
+ if ((i + 1) < argc) {
+ if (!strcmp(argv[i], "-dev")) {
+ strlcpy(xf86SolarisFbDev, argv[i + 1], sizeof(xf86SolarisFbDev));
++#if (defined(__sparc__) || defined(__sparc))
++ xf86SolarisFbDevIsSet = TRUE;
++#endif
+ return 2;
+ }
+ }
+@@ -416,6 +434,88 @@
+ return 0;
+ }
+
++#if (defined(__sparc__) || defined(__sparc))
++static void
++GetFbDevFromProbe(void) {
++ unsigned numDevs;
++ GDevPtr *devList;
++
++ numDevs = xf86MatchDevice(xf86DriverList[0]->driverName, &devList);
++
++ if (numDevs != 1)
++ return;
++ else {
++ struct pci_device_iterator *iter;
++ unsigned device_id;
++ const struct pci_id_match *const devices =
++ xf86DriverList[0]->supported_devices;
++ int i;
++ Bool found = FALSE;
++ struct pci_device *pPci;
++ struct sol_device_private {
++ struct pci_device base;
++ const char * device_string;
++ };
++#define DEV_PATH(dev) (((struct sol_device_private *) dev)->device_string)
++#define END_OF_MATCHES(m) \
++ (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0))
++
++ /* Find the pciVideoRec associated with this device section.
++ */
++ iter = pci_id_match_iterator_create(NULL);
++ while ((pPci = pci_device_next(iter)) != NULL) {
++ if (devList[0]->busID && *devList[0]->busID) {
++ if (xf86ComparePciBusString(devList[0]->busID,
++ ((pPci->domain << 8)
++ | pPci->bus),
++ pPci->dev, pPci->func)) {
++ break;
++ }
++ }
++ else if (xf86IsPrimaryPci(pPci)) {
++ break;
++ }
++ }
++
++ pci_iterator_destroy(iter);
++
++ if (pPci == NULL)
++ return;
++
++ /* If driver provides supported_devices, then check if this
++ device is on the list. Otherwise skip check.
++ */
++ if (!devices)
++ found = TRUE;
++ else {
++ device_id = (devList[0]->chipID > 0)
++ ? devList[0]->chipID : pPci->device_id;
++
++ /* Once the pciVideoRec is found, determine if the device is supported
++ * by the driver.
++ */
++ for (i = 0; !END_OF_MATCHES(devices[i]); i++) {
++ if (PCI_ID_COMPARE(devices[i].vendor_id, pPci->vendor_id)
++ && PCI_ID_COMPARE(devices[i].device_id, device_id)
++ && ((devices[i].device_class_mask & pPci->device_class)
++ == devices[i].device_class)) {
++
++ found = TRUE;
++ break;
++ }
++ }
++ }
++
++ if (found) {
++ strcpy(xf86SolarisFbDev, "/devices");
++ strcat(xf86SolarisFbDev, DEV_PATH(pPci));
++ xf86Msg(X_INFO, "Got xf86SolarisFbDev From Probe: %s\n", xf86SolarisFbDev);
++ }
++
++ }
++}
++#endif
++
+ void
+ xf86UseMsg(void)
+ {
--- a/open-src/xserver/xorg/sparc-no-bus-probe.patch Wed May 15 13:55:16 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
---- a/hw/xfree86/common/xf86Init.c Fri Aug 10 17:42:37 2012
-+++ b/hw/xfree86/common/xf86Init.c Fri Aug 10 19:45:41 2012
-@@ -453,7 +453,9 @@
- DoShowOptions();
-
- /* Do a general bus probe. This will be a PCI probe for x86 platforms */
-+#if (!defined(__sparc__) && !defined(__sparc))
- xf86BusProbe();
-+#endif
-
- if (xf86DoConfigure)
- DoConfigure();
---- a/hw/xfree86/common/xf86pciBus.h Fri Aug 17 15:28:07 2012
-+++ b/hw/xfree86/common/xf86pciBus.h Fri Aug 17 15:25:34 2012
-@@ -35,7 +35,9 @@
-
- void xf86PciProbe(void);
- Bool xf86PciAddMatchingDev(DriverPtr drvp);
-+#if (!defined(__sparc__) && !defined(__sparc))
- Bool xf86PciProbeDev(DriverPtr drvp);
-+#endif
- void xf86PciIsolateDevice(char *argument);
- int xf86PciMatchDriver(char *matches[], int nmatches);
- Bool xf86PciConfigure(void *busData, struct pci_device *pDev);
---- a/hw/xfree86/common/xf86Priv.h Fri Aug 10 21:43:08 2012
-+++ b/hw/xfree86/common/xf86Priv.h Fri Aug 17 15:26:21 2012
-@@ -117,6 +117,11 @@
- extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex);
- extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
-
-+/* xf86pciBus.c */
-+#if (defined(__sparc__) || defined(__sparc))
-+extern _X_EXPORT Bool xf86PciProbeDev(DriverPtr drvp);
-+#endif
-+
- /* xf86Config.c */
-
- extern _X_EXPORT Bool xf86PathIsSafe(const char *path);
---- a/hw/xfree86/common/xf86AutoConfig.c Fri Aug 24 11:29:28 2012
-+++ b/hw/xfree86/common/xf86AutoConfig.c Fri Aug 24 12:14:43 2012
-@@ -215,6 +215,10 @@
- return ret == CONFIG_OK;
- }
-
-+#if (defined(__sparc__) || defined(__sparc))
-+#define xf86SolarisFb0Dev "/dev/fb0"
-+#endif
-+
- static void
- listPossibleVideoDrivers(char *matches[], int nmatches)
- {
-@@ -250,6 +254,19 @@
- close(fbfd);
- }
- }
-+#if (defined(__sparc__) || defined(__sparc))
-+ if (!got_vis_id) {
-+ int fbfd;
-+
-+ fbfd = open(xf86SolarisFb0Dev, O_RDONLY);
-+ if (fbfd >= 0) {
-+ SYSCALL(iret = ioctl(fbfd, VIS_GETIDENTIFIER, &visid));
-+ if (iret >= 0)
-+ got_vis_id = 1;
-+ close(fbfd);
-+ }
-+ }
-+#endif
- if (got_vis_id) {
- const char *cp;
-