ODROID-U3 xorg-server debian package fork :
[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
7217e0ca
ML
18--- a/hw/xfree86/common/xf86Init.c
19+++ b/hw/xfree86/common/xf86Init.c
20@@ -361,6 +361,16 @@ xf86CreateRootWindow(WindowPtr pWin)
21 return ret;
22 }
23
24+extern void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master);
25+static void
26+xf86AutoConfigOutputDevices(void)
27+{
28+ int i;
29+
30+ for (i = 0; i < xf86NumGPUScreens; i++)
31+ xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]);
32+}
33+
34 static void
35 InstallSignalHandlers(void)
36 {
4db25562 37@@ -951,6 +961,8 @@ InitOutput(ScreenInfo * pScreenInfo, int
7217e0ca
ML
38 for (i = 0; i < xf86NumGPUScreens; i++)
39 AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
40
41+ xf86AutoConfigOutputDevices();
42+
43 xf86VGAarbiterWrapFunctions();
44 if (sigio_blocked)
45 OsReleaseSIGIO();
7217e0ca
ML
46--- a/hw/xfree86/common/xf86platformBus.c
47+++ b/hw/xfree86/common/xf86platformBus.c
4db25562 48@@ -401,6 +401,8 @@ xf86platformProbeDev(DriverPtr drvp)
7217e0ca
ML
49 return foundScreen;
50 }
51
52+extern void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master);
53+
54 int
55 xf86platformAddDevice(int index)
56 {
4db25562
JB
57@@ -473,6 +475,7 @@ xf86platformAddDevice(int index)
58 }
7217e0ca
ML
59 /* attach unbound to 0 protocol screen */
60 AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
61+ xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]);
62
4db25562
JB
63 RRResourcesChanged(xf86Screens[0]->pScreen);
64 RRTellChanged(xf86Screens[0]->pScreen);
7217e0ca
ML
65--- a/hw/xfree86/modes/xf86Crtc.c
66+++ b/hw/xfree86/modes/xf86Crtc.c
4db25562 67@@ -3383,3 +3383,35 @@ xf86DetachAllCrtc(ScrnInfoPtr scrn)
7217e0ca
ML
68 crtc->x = crtc->y = 0;
69 }
70 }
71+
72+
73+void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master)
74+{
75+ RRProviderPtr master_provider;
76+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(master);
77+ xf86CrtcConfigPtr slave_config = XF86_CRTC_CONFIG_PTR(pScrn);
78+ Bool unbound = FALSE;
79+
80+ if (!config || !slave_config)
81+ return;
82+
83+ master_provider = config->randr_provider;
84+
85+ if ((master->capabilities & RR_Capability_SinkOffload) &&
86+ pScrn->capabilities & RR_Capability_SourceOffload) {
87+ /* source offload */
88+
89+ DetachUnboundGPU(pScrn->pScreen);
90+ unbound = TRUE;
91+ AttachOffloadGPU(master->pScreen, pScrn->pScreen);
92+ slave_config->randr_provider->offload_sink = master_provider;
93+ }
94+ if ((master->capabilities & RR_Capability_SourceOutput) &&
95+ pScrn->capabilities & RR_Capability_SinkOutput) {
96+ /* sink offload */
97+ if (!unbound)
98+ DetachUnboundGPU(pScrn->pScreen);
99+ AttachOutputGPU(master->pScreen, pScrn->pScreen);
100+ slave_config->randr_provider->output_source = master_provider;
101+ }
102+}