xf86: Extract screen configuration matching into its own function

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
This commit is contained in:
Zoltán Böszörményi 2021-07-08 06:09:44 +02:00 committed by Povilas Kanapickas
parent 16571b8926
commit cd567415cc
1 changed files with 27 additions and 22 deletions

View File

@ -106,6 +106,28 @@ xf86CallDriverProbe(DriverPtr drv, Bool detect_only)
return foundScreen;
}
static screenLayoutPtr
xf86BusConfigMatch(ScrnInfoPtr scrnInfo) {
screenLayoutPtr layout;
int i;
for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
layout++) {
for (i = 0; i < scrnInfo->numEntities; i++) {
GDevPtr dev =
xf86GetDevFromEntity(scrnInfo->entityList[i],
scrnInfo->entityInstanceList[i]);
if (dev == layout->screen->device) {
/* A match has been found */
return layout;
}
}
}
return NULL;
}
/**
* @return TRUE if all buses are configured and set up correctly and FALSE
* otherwise.
@ -114,7 +136,7 @@ Bool
xf86BusConfig(void)
{
screenLayoutPtr layout;
int i, j;
int i;
/*
* 3 step probe to (hopefully) ensure that we always find at least 1
@ -170,27 +192,10 @@ xf86BusConfig(void)
*
*/
for (i = 0; i < xf86NumScreens; i++) {
for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
layout++) {
Bool found = FALSE;
for (j = 0; j < xf86Screens[i]->numEntities; j++) {
GDevPtr dev =
xf86GetDevFromEntity(xf86Screens[i]->entityList[j],
xf86Screens[i]->entityInstanceList[j]);
if (dev == layout->screen->device) {
/* A match has been found */
xf86Screens[i]->confScreen = layout->screen;
found = TRUE;
break;
}
}
if (found)
break;
}
if (layout->screen == NULL) {
layout = xf86BusConfigMatch(xf86Screens[i]);
if (layout && layout->screen)
xf86Screens[i]->confScreen = layout->screen;
else {
/* No match found */
xf86Msg(X_ERROR,
"Screen %d deleted because of no matching config section.\n",