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