diff options
author | Zoltán Böszörményi <zboszor@gmail.com> | 2021-07-08 06:13:24 +0200 |
---|---|---|
committer | Povilas Kanapickas <povilas@radix.lt> | 2021-07-30 00:27:39 +0000 |
commit | f08bc32f5abc23ea715c15e8e86150434cc99e4f (patch) | |
tree | 437476b5917ac99cf2c426db376fd95f66394b5e | |
parent | cd567415cc5645f8cdc78e85e8887e5cce76e6d7 (diff) |
xf86: Assign GPUs to screens according to configuration
If there is an explicit configuration, assign the RandR provider
of the GPUDevice to the screen it was specified for.
If there is no configuration (default case) the screen number is
still 0 so it doesn't change behaviour.
The result is e.g:
# DISPLAY=:0.2 xrandr --listproviders
Providers: number : 2
Provider 0: id: 0xd2 cap: 0x2, Sink Output crtcs: 1 outputs: 1 associated providers: 0 name:modesetting
Provider 1: id: 0xfd cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 2 outputs: 2 associated providers: 0 name:Intel
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
-rw-r--r-- | hw/xfree86/common/xf86Bus.c | 30 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Init.c | 12 | ||||
-rw-r--r-- | hw/xfree86/common/xf86platformBus.c | 21 |
3 files changed, 41 insertions, 22 deletions
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index 6dc1aebf0..fd144dbe7 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -107,9 +107,9 @@ xf86CallDriverProbe(DriverPtr drv, Bool detect_only) } static screenLayoutPtr -xf86BusConfigMatch(ScrnInfoPtr scrnInfo) { +xf86BusConfigMatch(ScrnInfoPtr scrnInfo, Bool is_gpu) { screenLayoutPtr layout; - int i; + int i, j; for (layout = xf86ConfigLayout.screens; layout->screen != NULL; layout++) { @@ -118,9 +118,18 @@ xf86BusConfigMatch(ScrnInfoPtr scrnInfo) { xf86GetDevFromEntity(scrnInfo->entityList[i], scrnInfo->entityInstanceList[i]); - if (dev == layout->screen->device) { - /* A match has been found */ - return layout; + if (is_gpu) { + for (j = 0; j < layout->screen->num_gpu_devices; j++) { + if (dev == layout->screen->gpu_devices[j]) { + /* A match has been found */ + return layout; + } + } + } else { + if (dev == layout->screen->device) { + /* A match has been found */ + return layout; + } } } } @@ -192,7 +201,7 @@ xf86BusConfig(void) * */ for (i = 0; i < xf86NumScreens; i++) { - layout = xf86BusConfigMatch(xf86Screens[i]); + layout = xf86BusConfigMatch(xf86Screens[i], FALSE); if (layout && layout->screen) xf86Screens[i]->confScreen = layout->screen; else { @@ -204,9 +213,12 @@ xf86BusConfig(void) } } - /* bind GPU conf screen to protocol screen 0 */ - for (i = 0; i < xf86NumGPUScreens; i++) - xf86GPUScreens[i]->confScreen = xf86Screens[0]->confScreen; + /* bind GPU conf screen to the configured protocol screen, or 0 if not configured */ + for (i = 0; i < xf86NumGPUScreens; i++) { + layout = xf86BusConfigMatch(xf86GPUScreens[i], TRUE); + int scrnum = (layout && layout->screen) ? layout->screen->screennum : 0; + xf86GPUScreens[i]->confScreen = xf86Screens[scrnum]->confScreen; + } /* If no screens left, return now. */ if (xf86NumScreens == 0) { diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index e6fb11398..2a0cfc361 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -209,9 +209,11 @@ xf86AutoConfigOutputDevices(void) if (!xf86Info.autoBindGPU) return; - for (i = 0; i < xf86NumGPUScreens; i++) + for (i = 0; i < xf86NumGPUScreens; i++) { + int scrnum = xf86GPUScreens[i]->confScreen->screennum; RRProviderAutoConfigGpuScreen(xf86ScrnToScreen(xf86GPUScreens[i]), - xf86ScrnToScreen(xf86Screens[0])); + xf86ScrnToScreen(xf86Screens[scrnum])); + } } static void @@ -689,8 +691,10 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) } } - for (i = 0; i < xf86NumGPUScreens; i++) - AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen); + for (i = 0; i < xf86NumGPUScreens; i++) { + int scrnum = xf86GPUScreens[i]->confScreen->screennum; + AttachUnboundGPU(xf86Screens[scrnum]->pScreen, xf86GPUScreens[i]->pScreen); + } xf86AutoConfigOutputDevices(); diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c index e43ff69af..0e0a995ac 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -608,7 +608,7 @@ xf86platformAddGPUDevices(DriverPtr drvp) int xf86platformAddDevice(int index) { - int i, old_screens, scr_index; + int i, old_screens, scr_index, scrnum; DriverPtr drvp = NULL; screenLayoutPtr layout; static const char *hotplug_driver_name = "modesetting"; @@ -674,14 +674,15 @@ xf86platformAddDevice(int index) xf86NumGPUScreens = old_screens; return -1; } - /* attach unbound to 0 protocol screen */ - AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen); + /* attach unbound to the configured protocol screen (or 0) */ + scrnum = xf86GPUScreens[i]->confScreen->screennum; + AttachUnboundGPU(xf86Screens[scrnum]->pScreen, xf86GPUScreens[i]->pScreen); if (xf86Info.autoBindGPU) RRProviderAutoConfigGpuScreen(xf86ScrnToScreen(xf86GPUScreens[i]), - xf86ScrnToScreen(xf86Screens[0])); + xf86ScrnToScreen(xf86Screens[scrnum])); - RRResourcesChanged(xf86Screens[0]->pScreen); - RRTellChanged(xf86Screens[0]->pScreen); + RRResourcesChanged(xf86Screens[scrnum]->pScreen); + RRTellChanged(xf86Screens[scrnum]->pScreen); return 0; } @@ -690,7 +691,7 @@ void xf86platformRemoveDevice(int index) { EntityPtr entity; - int ent_num, i, j; + int ent_num, i, j, scrnum; Bool found; for (ent_num = 0; ent_num < xf86NumEntities; ent_num++) { @@ -717,6 +718,8 @@ xf86platformRemoveDevice(int index) goto out; } + scrnum = xf86GPUScreens[i]->confScreen->screennum; + xf86GPUScreens[i]->pScreen->CloseScreen(xf86GPUScreens[i]->pScreen); RemoveGPUScreen(xf86GPUScreens[i]->pScreen); @@ -726,8 +729,8 @@ xf86platformRemoveDevice(int index) xf86_remove_platform_device(index); - RRResourcesChanged(xf86Screens[0]->pScreen); - RRTellChanged(xf86Screens[0]->pScreen); + RRResourcesChanged(xf86Screens[scrnum]->pScreen); + RRTellChanged(xf86Screens[scrnum]->pScreen); out: return; } |