Separate choosing driver from the file-based implementation
This clears the implementation out of the way to prepare for development of a symbol-based resolution scheme
This commit is contained in:
parent
3aa41bcb82
commit
3367091f7f
|
@ -332,41 +332,20 @@ autoConfigDevice(GDevPtr preconf_device)
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
static void
|
||||||
chooseVideoDriver(void)
|
matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip)
|
||||||
{
|
{
|
||||||
struct pci_device * info = NULL;
|
|
||||||
struct pci_device_iterator *iter;
|
|
||||||
DIR *idsdir;
|
DIR *idsdir;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct dirent *direntry;
|
struct dirent *direntry;
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
char *chosen_driver = NULL;
|
|
||||||
size_t len;
|
size_t len;
|
||||||
ssize_t read;
|
ssize_t read;
|
||||||
char path_name[256], vendor_str[5], chip_str[5];
|
char path_name[256], vendor_str[5], chip_str[5];
|
||||||
uint16_t vendor, chip;
|
uint16_t vendor, chip;
|
||||||
int i, j;
|
int i, j;
|
||||||
char *matches[20]; /* If we have more than 20 drivers we're in trouble */
|
|
||||||
|
|
||||||
for (i=0 ; i<20 ; i++)
|
|
||||||
matches[i] = NULL;
|
|
||||||
|
|
||||||
/* Find the primary device, and get some information about it. */
|
|
||||||
iter = pci_slot_match_iterator_create(NULL);
|
|
||||||
while ((info = pci_device_next(iter)) != NULL) {
|
|
||||||
if (xf86IsPrimaryPci(info)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pci_iterator_destroy(iter);
|
|
||||||
|
|
||||||
if (!info) {
|
|
||||||
ErrorF("Primary device is not PCI\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
idsdir = opendir("/usr/share/xserver-xorg/pci");
|
idsdir = opendir("/usr/share/xserver-xorg/pci");
|
||||||
|
|
||||||
if (idsdir) {
|
if (idsdir) {
|
||||||
direntry = readdir(idsdir);
|
direntry = readdir(idsdir);
|
||||||
/* Read the directory */
|
/* Read the directory */
|
||||||
|
@ -408,8 +387,8 @@ chooseVideoDriver(void)
|
||||||
chip = (int)strtol(chip_str, NULL, 16);
|
chip = (int)strtol(chip_str, NULL, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vendor == info->vendor_id &&
|
if (vendor == match_vendor &&
|
||||||
(chip == info->device_id || chip == -1)) {
|
(chip == match_chip || chip == -1)) {
|
||||||
i = 0;
|
i = 0;
|
||||||
while (matches[i]) {
|
while (matches[i]) {
|
||||||
i++;
|
i++;
|
||||||
|
@ -442,6 +421,38 @@ chooseVideoDriver(void)
|
||||||
direntry = readdir(idsdir);
|
direntry = readdir(idsdir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
end:
|
||||||
|
xfree(line);
|
||||||
|
closedir(idsdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
chooseVideoDriver(void)
|
||||||
|
{
|
||||||
|
struct pci_device * info = NULL;
|
||||||
|
struct pci_device_iterator *iter;
|
||||||
|
char *chosen_driver = NULL;
|
||||||
|
int i;
|
||||||
|
char *matches[20]; /* If we have more than 20 drivers we're in trouble */
|
||||||
|
|
||||||
|
for (i=0 ; i<20 ; i++)
|
||||||
|
matches[i] = NULL;
|
||||||
|
|
||||||
|
/* Find the primary device, and get some information about it. */
|
||||||
|
iter = pci_slot_match_iterator_create(NULL);
|
||||||
|
while ((info = pci_device_next(iter)) != NULL) {
|
||||||
|
if (xf86IsPrimaryPci(info)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pci_iterator_destroy(iter);
|
||||||
|
|
||||||
|
if (!info) {
|
||||||
|
ErrorF("Primary device is not PCI\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
matchDriverFromFiles(matches, info->vendor_id, info->device_id);
|
||||||
|
|
||||||
/* TODO Handle multiple drivers claiming to support the same PCI ID */
|
/* TODO Handle multiple drivers claiming to support the same PCI ID */
|
||||||
if (matches[0]) {
|
if (matches[0]) {
|
||||||
|
@ -463,7 +474,6 @@ chooseVideoDriver(void)
|
||||||
|
|
||||||
xf86Msg(X_DEFAULT, "Matched %s for the autoconfigured driver\n", chosen_driver);
|
xf86Msg(X_DEFAULT, "Matched %s for the autoconfigured driver\n", chosen_driver);
|
||||||
|
|
||||||
end:
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (matches[i]) {
|
while (matches[i]) {
|
||||||
if (matches[i] != chosen_driver) {
|
if (matches[i] != chosen_driver) {
|
||||||
|
@ -471,8 +481,6 @@ chooseVideoDriver(void)
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
xfree(line);
|
|
||||||
closedir(idsdir);
|
|
||||||
|
|
||||||
return chosen_driver;
|
return chosen_driver;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user