[igt-dev] [PATCH i-g-t v4 11/21] lib/drmtest: Add get_intel_driver() helper
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Wed Jul 12 17:12:21 UTC 2023
In libraries with i915 and Xe code divergence we might use
is_xe_device() or is_i915_device() to distinct code paths.
But to avoid additional open and string compare we can cache
this information in data structures.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Reviewed-by: Karolina Stolarek <karolina.stolarek at intel.com>
---
lib/drmtest.c | 10 ++++++++++
lib/drmtest.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 5cdb0196d3..e1da66c877 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -151,6 +151,16 @@ bool is_intel_device(int fd)
return is_i915_device(fd) || is_xe_device(fd);
}
+enum intel_driver get_intel_driver(int fd)
+{
+ if (is_xe_device(fd))
+ return INTEL_DRIVER_XE;
+ else if (is_i915_device(fd))
+ return INTEL_DRIVER_I915;
+
+ igt_assert_f(0, "Device is not handled by Intel driver\n");
+}
+
static char _forced_driver[16] = "";
/**
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 9c3ea5d14c..97ab6e759e 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -124,6 +124,7 @@ bool is_nouveau_device(int fd);
bool is_vc4_device(int fd);
bool is_xe_device(int fd);
bool is_intel_device(int fd);
+enum intel_driver get_intel_driver(int fd);
/**
* do_or_die:
--
2.34.1
More information about the igt-dev
mailing list