228_autobind_gpu.patch 3.6 KB

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