modesetting: probe only succeeds if connectors are detected

This will prevent modesetting being used for outputless intel or nvidia cards.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
This commit is contained in:
Maarten Lankhorst 2013-06-12 14:05:19 +02:00
parent d4791dd97b
commit 525ac7fb9a

View File

@ -201,12 +201,25 @@ static int open_hw(char *dev)
return fd; return fd;
} }
static int check_outputs(int fd)
{
drmModeResPtr res = drmModeGetResources(fd);
int ret;
if (!res)
return FALSE;
ret = res->count_connectors > 0;
drmModeFreeResources(res);
return ret;
}
static Bool probe_hw(char *dev) static Bool probe_hw(char *dev)
{ {
int fd = open_hw(dev); int fd = open_hw(dev);
if (fd != -1) { if (fd != -1) {
int ret = check_outputs(fd);
close(fd); close(fd);
return TRUE; return ret;
} }
return FALSE; return FALSE;
} }
@ -226,7 +239,7 @@ ms_DRICreatePCIBusID(const struct pci_device *dev)
static Bool probe_hw_pci(char *dev, struct pci_device *pdev) static Bool probe_hw_pci(char *dev, struct pci_device *pdev)
{ {
int fd = open_hw(dev); int ret = FALSE, fd = open_hw(dev);
char *id, *devid; char *id, *devid;
drmSetVersion sv; drmSetVersion sv;
@ -247,13 +260,12 @@ static Bool probe_hw_pci(char *dev, struct pci_device *pdev)
devid = ms_DRICreatePCIBusID(pdev); devid = ms_DRICreatePCIBusID(pdev);
close(fd); close(fd);
if (!id || !devid) if (id && devid && !strcmp(id, devid))
return FALSE; ret = check_outputs(fd);
if (!strcmp(id, devid)) free(id);
return TRUE; free(devid);
return ret;
return FALSE;
} }
static const OptionInfoRec * static const OptionInfoRec *
AvailableOptions(int chipid, int busid) AvailableOptions(int chipid, int busid)