[PATCH i-g-t v1 1/7] lib/drmtest: add function for retriving chipset
Kamil Konieczny
kamil.konieczny at linux.intel.com
Fri Jun 7 15:36:13 UTC 2024
A few tests uses chipset value for control and checks, so
instead of testing it with, for example, is_intel_driver(),
allow to retrieve it once and give it back to test.
Signed-off-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
---
lib/drmtest.c | 21 +++++++++++++++++++++
lib/drmtest.h | 2 ++
2 files changed, 23 insertions(+)
diff --git a/lib/drmtest.c b/lib/drmtest.c
index f8810da43..8ea96ba76 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -241,6 +241,27 @@ static void modulename_to_chipset(const char *name, unsigned int *chip)
}
}
+/**
+ * drm_get_chipset:
+ * @fd: a drm file descriptor
+ *
+ * Returns:
+ * chipset if driver name found in modules[] array, for example: DRIVER_INTEL
+ * DRIVER_ANY if drm device name not known
+ */
+unsigned int drm_get_chipset(int fd)
+{
+ unsigned int chip = DRIVER_ANY;
+ char name[32] = "";
+
+ if (__get_drm_device_name(fd, name, sizeof(name) - 1))
+ return chip;
+
+ modulename_to_chipset(name, &chip);
+
+ return chip;
+}
+
static const char *chipset_to_str(int chipset)
{
switch (chipset) {
diff --git a/lib/drmtest.h b/lib/drmtest.h
index bbe5f252f..4d9b60882 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -72,6 +72,8 @@ enum intel_driver {
void __set_forced_driver(const char *name);
+unsigned int drm_get_chipset(int fd);
+
/**
* ARRAY_SIZE:
* @arr: static array
--
2.43.0
More information about the igt-dev
mailing list