Blame SOURCES/xserver-autobind-hotplug.patch

70130e
From cd6f931fb06f825f246222a4362fbf728f8dce73 Mon Sep 17 00:00:00 2001
70130e
From: Dave Airlie <airlied@redhat.com>
70130e
Date: Fri, 17 Aug 2012 09:49:24 +1000
70130e
Subject: [PATCH] autobind GPUs to the screen, (v3)
70130e
70130e
this is racy and really not what we want for hotplug going forward,
70130e
but until DE support is in GNOME its probably for the best.
70130e
70130e
v2: fix if config or slave config is NULL
70130e
v3: fix multi useful slaves
70130e
DO NOT UPSTREAM.
70130e
70130e
Signed-off-by: Dave Airlie <airlied@gmail.com>
70130e
---
70130e
 hw/xfree86/common/xf86Init.c        | 12 ++++++++++++
70130e
 hw/xfree86/common/xf86platformBus.c |  3 +++
70130e
 hw/xfree86/modes/xf86Crtc.c         | 32 ++++++++++++++++++++++++++++++++
70130e
 3 files changed, 47 insertions(+)
70130e
70130e
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
70130e
index 6282252..dc33ad1 100644
70130e
--- a/hw/xfree86/common/xf86Init.c
70130e
+++ b/hw/xfree86/common/xf86Init.c
70130e
@@ -361,6 +361,16 @@ xf86CreateRootWindow(WindowPtr pWin)
70130e
     return ret;
70130e
 }
70130e
 
70130e
+extern void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master);                              
70130e
+static void
70130e
+xf86AutoConfigOutputDevices(void)
70130e
+{
70130e
+    int i;
70130e
+
70130e
+    for (i = 0; i < xf86NumGPUScreens; i++)
70130e
+        xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]);
70130e
+}
70130e
+
70130e
 static void
70130e
 InstallSignalHandlers(void)
70130e
 {
70130e
@@ -949,6 +959,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
70130e
     for (i = 0; i < xf86NumGPUScreens; i++)
70130e
         AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
70130e
 
70130e
+    xf86AutoConfigOutputDevices();
70130e
+
70130e
     xf86VGAarbiterWrapFunctions();
70130e
     if (sigio_blocked)
70130e
         OsReleaseSIGIO();
70130e
diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
70130e
index 33b2b7d..be3bdd9 100644
70130e
--- a/hw/xfree86/common/xf86platformBus.c
70130e
+++ b/hw/xfree86/common/xf86platformBus.c
70130e
@@ -393,6 +393,8 @@ xf86platformProbeDev(DriverPtr drvp)
70130e
     return foundScreen;
70130e
 }
70130e
 
70130e
+extern void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master);
70130e
+
70130e
 int
70130e
 xf86platformAddDevice(int index)
70130e
 {
70130e
@@ -465,6 +467,7 @@ xf86platformAddDevice(int index)
70130e
    }
70130e
    /* attach unbound to 0 protocol screen */
70130e
    AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
70130e
+   xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]);
70130e
 
70130e
    RRResourcesChanged(xf86Screens[0]->pScreen);
70130e
    RRTellChanged(xf86Screens[0]->pScreen);
70130e
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
70130e
index 4726f2a..e83ea13 100644
70130e
--- a/hw/xfree86/modes/xf86Crtc.c
70130e
+++ b/hw/xfree86/modes/xf86Crtc.c
70130e
@@ -3440,3 +3440,35 @@ xf86DetachAllCrtc(ScrnInfoPtr scrn)
70130e
             crtc->x = crtc->y = 0;
70130e
         }
70130e
 }
70130e
+
70130e
+
70130e
+void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master)
70130e
+{
70130e
+    RRProviderPtr master_provider;
70130e
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(master);
70130e
+    xf86CrtcConfigPtr slave_config = XF86_CRTC_CONFIG_PTR(pScrn);
70130e
+    Bool unbound = FALSE;
70130e
+
70130e
+    if (!config || !slave_config)
70130e
+        return;
70130e
+
70130e
+    master_provider = config->randr_provider;
70130e
+
70130e
+    if ((master->capabilities & RR_Capability_SinkOffload) &&
70130e
+        pScrn->capabilities & RR_Capability_SourceOffload) {
70130e
+            /* source offload */
70130e
+            
70130e
+        DetachUnboundGPU(pScrn->pScreen);
70130e
+        unbound = TRUE;
70130e
+        AttachOffloadGPU(master->pScreen, pScrn->pScreen);
70130e
+        slave_config->randr_provider->offload_sink = master_provider;
70130e
+    }
70130e
+    if ((master->capabilities & RR_Capability_SourceOutput) &&
70130e
+               pScrn->capabilities & RR_Capability_SinkOutput) {
70130e
+        /* sink offload */
70130e
+        if (!unbound)
70130e
+            DetachUnboundGPU(pScrn->pScreen);
70130e
+        AttachOutputGPU(master->pScreen, pScrn->pScreen);
70130e
+        slave_config->randr_provider->output_source = master_provider;
70130e
+    }
70130e
+}
70130e
-- 
70130e
1.8.3.1
70130e