summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Konieczny <kamil.konieczny@linux.intel.com>2024-08-05 16:37:04 +0200
committerKamil Konieczny <kamil.konieczny@linux.intel.com>2024-08-07 15:47:19 +0200
commit3ff4045afd05237c1b637e88e360e38f6a6d025d (patch)
treec8e79c625f6d227382391edb102d754c2ee2c7ca
parentb3b843cd415c06e02f5447937a7e2d1a361a7b80 (diff)
lib/drmtest: add function for retriving chipset
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@linux.intel.com> Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
-rw-r--r--lib/drmtest.c21
-rw-r--r--lib/drmtest.h2
2 files changed, 23 insertions, 0 deletions
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