Imported Debian patch 2:1.15.1-0ubuntu2.6
[deb_xorg-server.git] / debian / patches / 228_autobind_gpu.patch
CommitLineData
7217e0ca
ML
1From 37d51acb3b6a38af1717bfaa7925043c35bfb447 Mon Sep 17 00:00:00 2001
2From: Dave Airlie <airlied@redhat.com>
3Date: Fri, 17 Aug 2012 09:49:24 +1000
4Subject: [PATCH] autobind GPUs to the screen, (v3)
5
6this is racy and really not what we want for hotplug going forward,
7but until DE support is in GNOME its probably for the best.
8
9v2: fix if config or slave config is NULL
10v3: fix multi useful slaves
11DO NOT UPSTREAM.
12---
13 hw/xfree86/common/xf86Init.c | 12 ++++++++++++
14 hw/xfree86/common/xf86platformBus.c | 3 +++
15 hw/xfree86/modes/xf86Crtc.c | 32 ++++++++++++++++++++++++++++++++
16 3 files changed, 47 insertions(+), 0 deletions(-)
17
18diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
19index d231ced..89629c1 100644
20--- a/hw/xfree86/common/xf86Init.c
21+++ b/hw/xfree86/common/xf86Init.c
22@@ -361,6 +361,16 @@ xf86CreateRootWindow(WindowPtr pWin)
23 return ret;
24 }
25
26+extern void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master);
27+static void
28+xf86AutoConfigOutputDevices(void)
29+{
30+ int i;
31+
32+ for (i = 0; i < xf86NumGPUScreens; i++)
33+ xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]);
34+}
35+
36 static void
37 InstallSignalHandlers(void)
38 {
39@@ -926,6 +936,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
40 for (i = 0; i < xf86NumGPUScreens; i++)
41 AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
42
43+ xf86AutoConfigOutputDevices();
44+
45 xf86VGAarbiterWrapFunctions();
46 if (sigio_blocked)
47 OsReleaseSIGIO();
48diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
49index 0525e39..82fef32 100644
50--- a/hw/xfree86/common/xf86platformBus.c
51+++ b/hw/xfree86/common/xf86platformBus.c
52@@ -387,6 +387,8 @@ xf86platformProbeDev(DriverPtr drvp)
53 return foundScreen;
54 }
55
56+extern void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master);
57+
58 int
59 xf86platformAddDevice(int index)
60 {
61@@ -446,6 +448,7 @@ xf86platformAddDevice(int index)
62
63 /* attach unbound to 0 protocol screen */
64 AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
65+ xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]);
66
67 return 0;
68 }
69diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
70index 3011f13..34c1848 100644
71--- a/hw/xfree86/modes/xf86Crtc.c
72+++ b/hw/xfree86/modes/xf86Crtc.c
73@@ -3323,3 +3323,35 @@ xf86DetachAllCrtc(ScrnInfoPtr scrn)
74 crtc->x = crtc->y = 0;
75 }
76 }
77+
78+
79+void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master)
80+{
81+ RRProviderPtr master_provider;
82+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(master);
83+ xf86CrtcConfigPtr slave_config = XF86_CRTC_CONFIG_PTR(pScrn);
84+ Bool unbound = FALSE;
85+
86+ if (!config || !slave_config)
87+ return;
88+
89+ master_provider = config->randr_provider;
90+
91+ if ((master->capabilities & RR_Capability_SinkOffload) &&
92+ pScrn->capabilities & RR_Capability_SourceOffload) {
93+ /* source offload */
94+
95+ DetachUnboundGPU(pScrn->pScreen);
96+ unbound = TRUE;
97+ AttachOffloadGPU(master->pScreen, pScrn->pScreen);
98+ slave_config->randr_provider->offload_sink = master_provider;
99+ }
100+ if ((master->capabilities & RR_Capability_SourceOutput) &&
101+ pScrn->capabilities & RR_Capability_SinkOutput) {
102+ /* sink offload */
103+ if (!unbound)
104+ DetachUnboundGPU(pScrn->pScreen);
105+ AttachOutputGPU(master->pScreen, pScrn->pScreen);
106+ slave_config->randr_provider->output_source = master_provider;
107+ }
108+}
109--
1101.8.1
111