Jordan Justen <jordan.l.jus...@intel.com> writes: > Signed-off-by: Jordan Justen <jordan.l.jus...@intel.com> > --- > src/intel/common/gen_device_info.c | 51 > ++++++++++++++++++++++++++++++++++++++ > src/intel/common/gen_device_info.h | 1 + > 2 files changed, 52 insertions(+) > > diff --git a/src/intel/common/gen_device_info.c > b/src/intel/common/gen_device_info.c > index c0eb7c3c356..1e0cac8e537 100644 > --- a/src/intel/common/gen_device_info.c > +++ b/src/intel/common/gen_device_info.c > @@ -24,10 +24,61 @@ > #include <assert.h> > #include <stdio.h> > #include <stdlib.h> > +#include <string.h> > +#include <unistd.h> > #include "gen_device_info.h" > #include "compiler/shader_enums.h" > #include "util/macros.h" > > +static int > +parse_devid_override(const char *devid_override) > +{ > + static const struct { > + const char *name; > + int pci_id; > + } name_map[] = { > + { "brw", 0x2a02 }, > + { "g4x", 0x2a42 }, > + { "ilk", 0x0042 }, > + { "snb", 0x0126 }, > + { "ivb", 0x016a }, > + { "hsw", 0x0d2e }, > + { "byt", 0x0f33 }, > + { "bdw", 0x162e }, > + { "chv", 0x22B3 }, > + { "skl", 0x1912 }, > + { "bxt", 0x5A85 }, > + { "kbl", 0x5912 }, > + { "glk", 0x3185 }, > + { "cnl", 0x5a52 }, > + }; > + > + for (unsigned i = 0; i < ARRAY_SIZE(name_map); i++) { > + if (!strcmp(name_map[i].name, devid_override)) > + return name_map[i].pci_id; > + } > + > + return strtol(devid_override, NULL, 0); > +} > + > +/** > + * Get the overridden PCI ID for the device. This is set with the > + * INTEL_DEVID_OVERRIDE environment variable. > + * > + * Returns -1 if the override is not set. > + */ > +int > +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); > + } > + > + return -1;
Would it maybe make sense to always return -1 ifndef DEBUG or something? Is this useful functionality to the world at large? It looks like patches 2 & 5 could maybe be squashed too. With the comment in patch 3 fixed and some thought on the other points, series is Reviewed-by: Scott D Phillips <scott.d.phill...@intel.com> > +} > + > static const struct gen_device_info gen_device_info_i965 = { > .gen = 4, > .has_negative_rhw_bug = true, > diff --git a/src/intel/common/gen_device_info.h > b/src/intel/common/gen_device_info.h > index 30ddd905be1..f3f2daa966c 100644 > --- a/src/intel/common/gen_device_info.h > +++ b/src/intel/common/gen_device_info.h > @@ -199,6 +199,7 @@ struct gen_device_info > #define gen_device_info_is_9lp(devinfo) \ > ((devinfo)->is_broxton || (devinfo)->is_geminilake) > > +int gen_get_pci_device_id_override(void); > bool gen_get_device_info(int devid, struct gen_device_info *devinfo); > const char *gen_get_device_name(int devid); > > -- > 2.15.1 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev