xfree86: fbdevhw: use the fbdev passed by the user, if there is one

The fbdev pci probe doesn't use the fbdev passed by the user,
and instead tries to guess what framebuffer the user wants to use.

Only if that fails, fbdev falls back to the option passed by the user.

This is backwards, if the user explicitly passes a framebuffer
device to use, the X server should use that, and fall back on
guessing if that fails.

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
This commit is contained in:
stefan11111
2025-07-14 00:27:01 +03:00
committed by Enrico Weigelt
parent ca7a1e1e39
commit 6233fa8b9f

View File

@@ -239,12 +239,29 @@ fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode)
* Try to find the framebuffer device for a given PCI device
*/
static int
fbdev_open_pci(struct pci_device *pPci, char **namep)
fbdev_open_pci(struct pci_device *pPci, char *device, char **namep)
{
struct fb_fix_screeninfo fix;
char filename[256];
int fd, i;
/* try argument (from XF86Config) first */
if (device) {
fd = open(device, O_RDWR);
}
else {
/* second: environment variable */
device = getenv("FRAMEBUFFER");
fd = device ? open(device, O_RDWR) : -1;
}
if (fd != -1) {
/* fbdev was provided by the user instead of guessed, skip pci check */
if (namep)
*namep = NULL;
return fd;
}
for (i = 0; i < 8; i++) {
snprintf(filename, sizeof(filename),
"/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics/fb%d",
@@ -389,7 +406,7 @@ fbdevHWProbe(struct pci_device *pPci, const char *device, char **namep)
int fd;
if (pPci)
fd = fbdev_open_pci(pPci, namep);
fd = fbdev_open_pci(pPci, device, namep);
else
fd = fbdev_open(-1, device, namep);
@@ -409,7 +426,7 @@ fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, const char *device)
/* open device */
if (pPci)
fPtr->fd = fbdev_open_pci(pPci, NULL);
fPtr->fd = fbdev_open_pci(pPci, device, NULL);
else
fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL);
if (-1 == fPtr->fd) {