summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJordan Justen <[email protected]>2018-02-09 19:06:12 -0800
committerJordan Justen <[email protected]>2018-02-27 11:15:10 -0800
commit8ff89250ffc24ef908f0c1b8b0b96820c49a492f (patch)
treef8d47835632d842e2776606b2736aaed9551e228 /src
parentc2134f94c8a819cd100e503cf56cbe6fe11a6a2f (diff)
intel/common: Add gen_device_name_to_pci_device_id
Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Scott D Phillips <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/intel/common/gen_device_info.c19
-rw-r--r--src/intel/common/gen_device_info.h1
2 files changed, 14 insertions, 6 deletions
diff --git a/src/intel/common/gen_device_info.c b/src/intel/common/gen_device_info.c
index 113a9dca1ff..ef0ae4ce8c3 100644
--- a/src/intel/common/gen_device_info.c
+++ b/src/intel/common/gen_device_info.c
@@ -30,8 +30,13 @@
#include "compiler/shader_enums.h"
#include "util/macros.h"
-static int
-parse_devid_override(const char *devid_override)
+/**
+ * Get the PCI ID for the device name.
+ *
+ * Returns -1 if the device is not known.
+ */
+int
+gen_device_name_to_pci_device_id(const char *name)
{
static const struct {
const char *name;
@@ -54,11 +59,11 @@ parse_devid_override(const char *devid_override)
};
for (unsigned i = 0; i < ARRAY_SIZE(name_map); i++) {
- if (!strcmp(name_map[i].name, devid_override))
+ if (!strcmp(name_map[i].name, name))
return name_map[i].pci_id;
}
- return strtol(devid_override, NULL, 0);
+ return -1;
}
/**
@@ -72,8 +77,10 @@ gen_get_pci_device_id_override(void)
{
if (geteuid() == getuid()) {
const char *devid_override = getenv("INTEL_DEVID_OVERRIDE");
- if (devid_override)
- return parse_devid_override(devid_override);
+ if (devid_override) {
+ const int id = gen_device_name_to_pci_device_id(devid_override);
+ return id >= 0 ? id : strtol(devid_override, NULL, 0);
+ }
}
return -1;
diff --git a/src/intel/common/gen_device_info.h b/src/intel/common/gen_device_info.h
index 6a96143cebb..3e9c087f58c 100644
--- a/src/intel/common/gen_device_info.h
+++ b/src/intel/common/gen_device_info.h
@@ -200,6 +200,7 @@ struct gen_device_info
((devinfo)->is_broxton || (devinfo)->is_geminilake)
int gen_get_pci_device_id_override(void);
+int gen_device_name_to_pci_device_id(const char *name);
bool gen_get_device_info(int devid, struct gen_device_info *devinfo);
const char *gen_get_device_name(int devid);