Commit 2145851e authored by Böszörményi Zoltán's avatar Böszörményi Zoltán Committed by Zoltán Böszörményi
Browse files

Don't hardcode screen 0 in GPU assignments to screens



When there is explicit configuration, it's better to use
confScreen->screennum instead of hardcoded 0.

When there is no configuration (default case) the screen number is
still 0 so it doesn't change behaviour.

But at least for a case when the Intel device is backed by the
intel driver and using a screen description like this below,
both providers are correctly assigned to :0.2.

  Section "Screen"
        Identifier      "SCREEN2"
        Option          "AutoServerLayout" "on"
        Device          "UDL"
        GPUDevice       "Intel2"
        Monitor         "Monitor-DVI-I-1"
        SubSection      "Display"
                Modes   "1024x768"
                Depth   24
        EndSubSection
  EndSection

  Section "ServerLayout"
        Identifier      "LAYOUT"
        Option          "AutoServerLayout" "on"
        Screen          0 "SCREEN"
        Screen          1 "SCREEN1" RightOf "SCREEN"
        Screen          2 "SCREEN2" RightOf "SCREEN1"
  EndSection

  # 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's avatarZoltán Böszörményi <zboszor@gmail.com>
parent ef89b664
Pipeline #344925 canceled with stages
in 23 seconds
......@@ -114,7 +114,7 @@ Bool
xf86BusConfig(void)
{
screenLayoutPtr layout;
int i, j;
int i, j, k;
/*
* 3 step probe to (hopefully) ensure that we always find at least 1
......@@ -199,9 +199,34 @@ 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++) {
int scrnum = 0;
for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
layout++) {
for (j = 0; j < xf86GPUScreens[i]->numEntities; j++) {
GDevPtr dev =
xf86GetDevFromEntity(xf86GPUScreens[i]->entityList[j],
xf86GPUScreens[i]->entityInstanceList[j]);
for (k = 0; k < MAX_GPUDEVICES; k++) {
if (dev == layout->screen->gpu_devices[k]) {
/* A match has been found */
xf86GPUScreens[i]->confScreen = layout->screen;
scrnum = layout->screen->screennum;
break;
}
}
if (scrnum)
break;
}
if (scrnum)
break;
}
xf86GPUScreens[i]->confScreen = xf86Screens[scrnum]->confScreen;
}
/* If no screens left, return now. */
if (xf86NumScreens == 0) {
......
......@@ -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();
......
......@@ -606,7 +606,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";
......@@ -673,13 +673,14 @@ xf86platformAddDevice(int index)
return -1;
}
/* attach unbound to 0 protocol screen */
AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
scrnum = xf86GPUScreens[i]->confScreen->screennum;
AttachUnboundGPU(xf86Screens[scr_index]->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;
}
......@@ -688,7 +689,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++) {
......@@ -715,6 +716,8 @@ xf86platformRemoveDevice(int index)
goto out;
}
scrnum = xf86GPUScreens[i]->confScreen->screennum;
xf86GPUScreens[i]->pScreen->CloseScreen(xf86GPUScreens[i]->pScreen);
RemoveGPUScreen(xf86GPUScreens[i]->pScreen);
......@@ -724,8 +727,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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment