[v0.11] Do not show error message when there is no Intel iGPU

This commit is contained in:
Dr-Noob
2021-12-18 10:35:51 +01:00
parent 6d4d8b621b
commit bfb9738132
2 changed files with 19 additions and 9 deletions

View File

@@ -4,15 +4,15 @@
#define CLASS_VGA_CONTROLLER 0x0300 #define CLASS_VGA_CONTROLLER 0x0300
uint16_t pciutils_get_pci_vendor_id(struct pci_dev *devices, int id) { bool pciutils_is_vendor_id_present(struct pci_dev *devices, int id) {
for(struct pci_dev *dev=devices; dev != NULL; dev=dev->next) { for(struct pci_dev *dev=devices; dev != NULL; dev=dev->next) {
if(dev->vendor_id == id && dev->device_class == CLASS_VGA_CONTROLLER) { if(dev->vendor_id == id && dev->device_class == CLASS_VGA_CONTROLLER) {
return dev->vendor_id; return true;
} }
} }
printErr("Unable to find a valid device for id %d using pciutils", id); printWarn("Unable to find a valid device for id %d using pciutils", id);
return 0; return false;
} }
uint16_t pciutils_get_pci_device_id(struct pci_dev *devices, int id) { uint16_t pciutils_get_pci_device_id(struct pci_dev *devices, int id) {
@@ -46,12 +46,16 @@ struct pci* get_pci_from_pciutils(struct pci_dev *devices, int id) {
struct pci* pci = (struct pci*) emalloc(sizeof(struct pci)); struct pci* pci = (struct pci*) emalloc(sizeof(struct pci));
// TODO: Refactor this; instead of 2xGet + 1xSet, do it better // TODO: Refactor this; instead of 2xGet + 1xSet, do it better
pci->vendor_id = pciutils_get_pci_vendor_id(devices, id); if(pciutils_is_vendor_id_present(devices, id)) {
pci->vendor_id = id;
pci->device_id = pciutils_get_pci_device_id(devices, id); pci->device_id = pciutils_get_pci_device_id(devices, id);
pciutils_set_pci_bus(pci, devices, id); pciutils_set_pci_bus(pci, devices, id);
return pci; return pci;
} }
else {
return NULL;
}
}
struct pci_dev *get_pci_devices_from_pciutils() { struct pci_dev *get_pci_devices_from_pciutils() {
struct pci_access *pacc; struct pci_access *pacc;

View File

@@ -18,6 +18,12 @@ struct gpu_info* get_gpu_info_intel() {
struct pci_dev *devices = get_pci_devices_from_pciutils(); struct pci_dev *devices = get_pci_devices_from_pciutils();
gpu->pci = get_pci_from_pciutils(devices, PCI_VENDOR_ID_INTEL); gpu->pci = get_pci_from_pciutils(devices, PCI_VENDOR_ID_INTEL);
if(gpu->pci == NULL) {
// No Intel iGPU found in PCI, which means it is not present
return NULL;
}
gpu->arch = get_uarch_from_pci(gpu->pci); gpu->arch = get_uarch_from_pci(gpu->pci);
gpu->name = get_name_from_uarch(gpu->arch); gpu->name = get_name_from_uarch(gpu->arch);
gpu->topo_i = get_topology_info(gpu->arch); gpu->topo_i = get_topology_info(gpu->arch);