Skip to contentSkip to conversation

Extend IGT to support Android

PATCH Superseded Jeevaka Prabu Badrappan 2 participants 13 messages Jun 3, 2025

Subsystems (2)

v13 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

v13 cover Extend IGT to support Android

The primary objective of this proposal is to extend the functionality of IGT to Android environments.

Enabling IGT on Android will allow developers to perform comprehensive testing of graphics drivers, ensuring robustness and reliability across different platforms.

By providing stub implementations for libraries that are not natively supported on Android, we will bridge the gap between Android and Linux environments, promoting code reuse and reducing development time.

Changes done:
- Create stub implementations of GLib, libprocps libraries to satisfy IGT dependencies on Android.
- Replace glib hash table with igt hash implementation

Note:
- In case of linux systems, system libraries will be used whereas for Android stubs will be used with reduced test coverage.
- Support will be provided to maintain Android support.

Jeevaka Prabu Badrappan (10):
lib/intel_batchbuffer: handle base64 encode fail tests/intel/*_intel_bb: handle base64 encode fail
lib: Include local igt glib header for Android lib/igt_aux: Include local igt procps header for Android tests/intel: Include local glib header for Android tests/testdisplay: Include local glib header for Android
runner: Include local glib header for Android
tools: Include local glib header for Android tests/intel/xe_create: Conditionally define PAGE_SIZE for non-Android
platforms
lib/igt_device_scan: reuse igt hash

Sapna Singh (1):
include/android: Add stub for procps and glib

 include/android/glib.h     | 44 +++++++++++++++++++++
 include/android/procps.h   | 40 +++++++++++++++++++
 lib/igt_aux.c              |  6 ++-
 lib/igt_chamelium.c        |  4 ++
 lib/igt_core.c             |  4 ++
 lib/igt_device_scan.c      | 78 +++++++++++++++++++-------------------
 lib/igt_rc.h               |  4 ++
 lib/intel_batchbuffer.c    |  7 ++++
 lib/meson.build            |  1 +
 runner/executor.c          |  4 ++
 runner/settings.h          |  4 ++
 tests/intel/api_intel_bb.c |  7 ++++
 tests/intel/gem_ccs.c      |  4 ++
 tests/intel/xe_ccs.c       |  4 ++
 tests/intel/xe_create.c    |  2 +
 tests/intel/xe_intel_bb.c  |  7 ++++
 tests/testdisplay.h        |  4 ++
 tools/igt_dp_compliance.h  |  4 ++
 tools/intel_pm_rpm.c       |  4 ++
 tools/lsgpu.c              |  4 ++
 20 files changed, 197 insertions(+), 39 deletions(-)
 create mode 100644 include/android/glib.h
 create mode 100644 include/android/procps.h
Signature · 1 line
2.49.0
#1 lore raw

PATCH v13 1/11 include/android: Add stub for procps and glib

From: Sapna Singh <[email protected]>

As procps, glib are not available in Android, not able to build igt for Android.

Provided stub implementations so igt can be compiled for both Android and linux from same code base. In case of linux systems, system libraries will be used whereas for Android stubs will be used with reduced test coverage.

---
 include/android/glib.h   | 44 ++++++++++++++++++++++++++++++++++++++++
 include/android/procps.h | 40 ++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 include/android/glib.h
 create mode 100644 include/android/procps.h
include/android/glib.h new file +44 -0
new file mode 100644
index 000000000..c80a16e47
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef _IGT_ANDROID_GLIB_H
+#define _IGT_ANDROID_GLIB_H
+
+#include <stdbool.h>
+#include <stdlib.h>
+
+#define G_KEY_FILE_NONE 0
+#define G_REGEX_OPTIMIZE 0
+
+typedef struct _GError {
+	int code;
+	char *message;
+} GError;
+
+typedef struct _GKeyFile {
+	char *key;
+	char *value;
+} GKeyFile;
+
+typedef int gint;
+typedef size_t gsize;
+typedef char gchar;
+typedef unsigned char guchar;
+typedef void GRegex;
+
+static inline void g_clear_error(GError **error) { }
+static inline void g_error_free(GError *error) { }
+static inline const char *g_get_home_dir(void) { return "/data/local/tmp/igt"; }
+static inline void g_key_file_free(GKeyFile *file) { }
+static inline GKeyFile *g_key_file_new(void) { return NULL; }
+static inline int g_key_file_get_integer(GKeyFile *key_file,
+	const char *group_name, const char *key, GError **error) { return 0; }
+static inline char *g_key_file_get_string(GKeyFile *key_file,
+	const char *group_name, const char *key, GError **error) { return NULL; }
+static inline bool g_key_file_load_from_file(GKeyFile *key_file,
+	const char *file, int flags, GError **error) { return false; }
+static inline GRegex *g_regex_new(const char *pattern, int compile_options,
+	int match_options, GError **error) { return NULL; }
+static inline void g_regex_unref(GRegex *pattern) { };
+static gchar *g_base64_encode(const guchar *data, gsize len) { return NULL; }
+
+#endif /* _IGT_ANDROID_GLIB_H */
include/android/procps.h new file +40 -0
new file mode 100644
index 000000000..f859dffe1
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef _IGT_ANDROID_PROCPS_H
+#define _IGT_ANDROID_PROCPS_H
+
+enum pids_item {
+	PIDS_NOT_IMPLEMENTED = 0,
+};
+
+enum pids_fetch_type {
+	PIDS_FETCH_TASKS_ONLY,
+	PIDS_FETCH_THREADS_TOO
+};
+
+struct pids_result {
+	enum pids_item item;
+	union {
+		unsigned long long ull_int;
+		double real;
+	} result;
+};
+
+struct pids_stack {
+	struct pids_result *head;
+};
+
+struct pids_info;
+
+#define PIDS_VAL(relative_enum, type, stack, info) \
+	((info & 0) | (stack)->head[relative_enum].result.type)
+
+int procps_pids_new(struct pids_info **info, enum pids_item *items, int numitems) { return 0; }
+int procps_pids_unref(struct pids_info **info) { return 0; }
+
+struct pids_stack *procps_pids_get(struct pids_info *info, enum pids_fetch_type which)
+{
+	return NULL;
+}
+
+#endif /* _IGT_ANDROID_PROCPS_H */
Signature · 1 line
2.49.0
#2 lore raw

PATCH v13 2/11 lib/intel_batchbuffer: handle base64 encode fail

In reply to Jeevaka Prabu Badrappan

g_base64_encode function returns a newly allocated string containing the Base64 encoded data. Upon failure, null can be returned.

When g_base64_encode function fails, exit the calling function.

---
 lib/intel_batchbuffer.c | 3 +++
 1 file changed, 3 insertions(+)
lib/intel_batchbuffer.c +3 -0
index f7569e768..a0c3fe340 100644
@@ -2348,6 +2348,9 @@ static void intel_bb_dump_base64(struct intel_bb *ibb, int linelen)
 
 	igt_info("--- bb ---\n");
 	pos = str = g_base64_encode((const guchar *) ibb->batch, ibb->size);
+	if (!str)
+		return;
+
 	outsize = strlen(str);
 
 	while (outsize > 0) {
Signature · 1 line
2.49.0
#3 lore raw

PATCH v13 3/11 tests/intel/*_intel_bb: handle base64 encode fail

In reply to Jeevaka Prabu Badrappan

g_base64_encode function returns a newly allocated string containing the Base64 encoded data. Upon failure, null can be returned.

When g_base64_encode function fails, exit the calling function with error.

---
 tests/intel/api_intel_bb.c | 3 +++
 tests/intel/xe_intel_bb.c  | 3 +++
 2 files changed, 6 insertions(+)
tests/intel/api_intel_bb.c +3 -0
index 4a1c9be91..63e171e16 100644
@@ -944,6 +944,9 @@ static int dump_base64(const char *name, struct intel_buf *buf)
 
 		igt_info("--- %s ---\n", name);
 		pos = str = g_base64_encode(destbuf, outsize);
+		if (!str)
+			return -1;
+
 		outsize = strlen(str);
 		while (pos) {
 			char line[LINELEN + 1];
tests/intel/xe_intel_bb.c +3 -0
index d8bd7b519..c673eb11e 100644
@@ -595,6 +595,9 @@ static int dump_base64(const char *name, struct intel_buf *buf)
 
 		igt_info("--- %s ---\n", name);
 		pos = str = g_base64_encode(destbuf, outsize);
+		if (!str)
+			return -1;
+
 		outsize = strlen(str);
 		while (pos) {
 			char line[LINELEN + 1];
Signature · 1 line
2.49.0
#4 lore raw

Re: [PATCH i-g-t v13 03/11] tests/intel/*_intel_bb: handle base64 encode fail

Hi Jeevaka,

Quoted 18 lines · Jeevaka Prabu Badrappan

g_base64_encode function returns a newly allocated string containing the Base64 encoded data. Upon failure, null can be returned.

When g_base64_encode function fails, exit the calling function with error.

---
 tests/intel/api_intel_bb.c | 3 +++
 tests/intel/xe_intel_bb.c  | 3 +++
 2 files changed, 6 insertions(+)
tests/intel/api_intel_bb.c +0 -0
index 4a1c9be91..63e171e16 100644

tests/intel/api_intel_bb.c static int dump_base64(const char *name, struct intel_buf *buf) · line 950

Quoted 7 lines
tests/intel/api_intel_bb.c +3 -0
@@ -944,6 +944,9 @@ static int dump_base64(const char *name, struct intel_buf *buf)
 
 		igt_info("--- %s ---\n", name);
 		pos = str = g_base64_encode(destbuf, outsize);
+		if (!str)
+			return -1;
+
 		outsize = strlen(str);

Sorry, I was thinking it was correct while it is not, remove above and replace these line with:
outsize = str ? strlen(str) : 0;

Quoted 7 lines
tests/intel/api_intel_bb.c +0 -0
 		while (pos) {
 			char line[LINELEN + 1];
tests/intel/xe_intel_bb.c +0 -0
index d8bd7b519..c673eb11e 100644

tests/intel/xe_intel_bb.c static int dump_base64(const char *name, struct intel_buf *buf) · line 601

Quoted 7 lines
tests/intel/xe_intel_bb.c +3 -0
@@ -595,6 +595,9 @@ static int dump_base64(const char *name, struct intel_buf *buf)
 
 		igt_info("--- %s ---\n", name);
 		pos = str = g_base64_encode(destbuf, outsize);
+		if (!str)
+			return -1;
+
 		outsize = strlen(str);

Same here.

Regards,
Kamil

Quoted 5 lines
tests/intel/xe_intel_bb.c +0 -0
 		while (pos) {
 			char line[LINELEN + 1];
Signature · 1 line
2.49.0
#5 lore raw

PATCH v13 4/11 lib: Include local igt glib header for Android

In reply to Jeevaka Prabu Badrappan

As glib is not available in Android, added local igt glib header to build igt for Android.

---
 lib/igt_chamelium.c     | 4 ++++
 lib/igt_core.c          | 4 ++++
 lib/igt_rc.h            | 4 ++++
 lib/intel_batchbuffer.c | 4 ++++
 4 files changed, 16 insertions(+)
lib/igt_chamelium.c +4 -0
index a96e36b5b..d19a78ffa 100644
@@ -33,7 +33,11 @@
 #include <xmlrpc-c/base.h>
 #include <xmlrpc-c/client.h>
 #include <pthread.h>
+#ifndef ANDROID
 #include <glib.h>
+#else
+#include "android/glib.h"
+#endif
 #include <pixman.h>
 #include <cairo.h>
 
lib/igt_core.c +4 -0
index b06cdfd89..c2674a272 100644
@@ -55,7 +55,11 @@
 #include <limits.h>
 #include <locale.h>
 #include <uwildmat/uwildmat.h>
+#ifndef ANDROID
 #include <glib.h>
+#else
+#include "android/glib.h"
+#endif
 
 #include "drmtest.h"
 #include "i915/gem_create.h"
lib/igt_rc.h +4 -0
index 53e5ce669..d871b3b26 100644
@@ -25,7 +25,11 @@
 #ifndef IGT_RC_H
 #define IGT_RC_H
 
+#ifndef ANDROID
 #include <glib.h>
+#else
+#include "android/glib.h"
+#endif
 
 extern GKeyFile *igt_key_file;
 
lib/intel_batchbuffer.c +4 -0
index a0c3fe340..4bc1cf5b6 100644
@@ -26,7 +26,11 @@
  **************************************************************************/
 
 #include <search.h>
+#ifndef ANDROID
 #include <glib.h>
+#else
+#include "android/glib.h"
+#endif
 
 #include "gpgpu_fill.h"
 #include "huc_copy.h"
Signature · 1 line
2.49.0
#6 lore raw

PATCH v13 5/11 lib/igt_aux: Include local igt procps header for Android

In reply to Jeevaka Prabu Badrappan

As procps is not available in Android, added local stub procps header to build igt for Android. Inclusion of libproc2/pids.h is now conditional, based on the HAVE_LIBPROC2 definition, ensuring that it is only included when the library is available.

---
 lib/igt_aux.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/igt_aux.c +5 -1
index 2905824a5..83809e770 100644
@@ -55,8 +55,12 @@
 
 #ifdef HAVE_LIBPROCPS
 #  include <proc/readproc.h>
-#else
+#elif HAVE_LIBPROC2
 #  include <libproc2/pids.h>
+#else
+#  ifdef ANDROID
+#    include "android/procps.h"
+#  endif
 #endif
 
 #include <dirent.h>
Signature · 1 line
2.49.0
#7 lore raw

PATCH v13 6/11 tests/intel: Include local glib header for Android

In reply to Jeevaka Prabu Badrappan

As glib is not available in Android, added local stub header to build igt for Android.

---
 tests/intel/api_intel_bb.c | 4 ++++
 tests/intel/gem_ccs.c      | 4 ++++
 tests/intel/xe_ccs.c       | 4 ++++
 tests/intel/xe_intel_bb.c  | 4 ++++
 4 files changed, 16 insertions(+)
tests/intel/api_intel_bb.c +4 -0
index 63e171e16..ec8e166e4 100644
@@ -35,7 +35,11 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+#ifdef ANDROID
+#include "android/glib.h"
+#else
 #include <glib.h>
+#endif
 #include <zlib.h>
 #include "intel_bufops.h"
 #include "i915/gem_vm.h"
tests/intel/gem_ccs.c +4 -0
index af1e85f6a..a84a47cc4 100644
@@ -4,7 +4,11 @@
  */
 
 #include <errno.h>
+#ifdef ANDROID
+#include "android/glib.h"
+#else
 #include <glib.h>
+#endif
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <malloc.h>
tests/intel/xe_ccs.c +4 -0
index e154bf4dc..bff5b5772 100644
@@ -4,7 +4,11 @@
  */
 
 #include <errno.h>
+#ifdef ANDROID
+#include "android/glib.h"
+#else
 #include <glib.h>
+#endif
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <malloc.h>
tests/intel/xe_intel_bb.c +4 -0
index c673eb11e..48c999f19 100644
@@ -6,7 +6,11 @@
 #include <cairo.h>
 #include <errno.h>
 #include <fcntl.h>
+#ifdef ANDROID
+#include "android/glib.h"
+#else
 #include <glib.h>
+#endif
 #include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
Signature · 1 line
2.49.0
#8 lore raw

PATCH v13 7/11 tests/testdisplay: Include local glib header for Android

In reply to Jeevaka Prabu Badrappan

As glib is not available in Android, added local stub header to build igt for Android.

---
 tests/testdisplay.h | 4 ++++
 1 file changed, 4 insertions(+)
tests/testdisplay.h +4 -0
index 27f8209e2..0f606c028 100644
@@ -24,7 +24,11 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#ifdef ANDROID
+#include "android/glib.h"
+#else
 #include <glib.h>
+#endif
 
 extern int drm_fd;
 
Signature · 1 line
2.49.0
#9 lore raw

PATCH v13 8/11 runner: Include local glib header for Android

In reply to Jeevaka Prabu Badrappan

As glib is not available in Android, added local stub header to build igt for Android.

---
 runner/executor.c | 4 ++++
 runner/settings.h | 4 ++++
 2 files changed, 8 insertions(+)
runner/executor.c +4 -0
index 41f521e56..784d9eb5f 100644
@@ -1,7 +1,11 @@
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
+#ifdef ANDROID
+#include "android/glib.h"
+#else
 #include <glib.h>
+#endif
 #ifdef __linux__
 #include <linux/watchdog.h>
 #endif
runner/settings.h +4 -0
index 1f0b85318..ccdc7281b 100644
@@ -5,7 +5,11 @@
 #include <stddef.h>
 #include <sys/types.h>
 #include <stdio.h>
+#ifdef ANDROID
+#include "android/glib.h"
+#else
 #include <glib.h>
+#endif
 
 #include "igt_list.h"
 #include "igt_vec.h"
Signature · 1 line
2.49.0
#10 lore raw

PATCH v13 9/11 tools: Include local glib header for Android

In reply to Jeevaka Prabu Badrappan

As glib is not available in Android, added local glib stub header to build igt for Android.

---
 tools/igt_dp_compliance.h | 4 ++++
 tools/intel_pm_rpm.c      | 4 ++++
 tools/lsgpu.c             | 4 ++++
 3 files changed, 12 insertions(+)
tools/igt_dp_compliance.h +4 -0
index 5b1688039..226a13662 100644
@@ -28,7 +28,11 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#ifdef ANDROID
+#include "android/glib.h"
+#else
 #include <glib.h>
+#endif
 
 extern int drm_fd;
 
tools/intel_pm_rpm.c +4 -0
index 9622f0552..c1cc54b82 100644
@@ -24,7 +24,11 @@
 
 #include <errno.h>
 #include <getopt.h>
+#ifdef ANDROID
+#include "android/glib.h"
+#else
 #include <glib.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
tools/lsgpu.c +4 -0
index e68390083..6cfbf3142 100644
@@ -24,7 +24,11 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#ifdef ANDROID
+#include "android/glib.h"
+#else
 #include <glib.h>
+#endif
 #include <libudev.h>
 #include <string.h>
 #include <signal.h>
Signature · 1 line
2.49.0
#11 lore raw

PATCH v13 10/11 tests/intel/xe_create: Conditionally define PAGE_SIZE for non-Android platforms

In reply to Jeevaka Prabu Badrappan

Ensure PAGE_SIZE is defined only if it is not already defined, addressing compatibility with Android where PAGE_SIZE is predefined.

---
 tests/intel/xe_create.c | 2 ++
 1 file changed, 2 insertions(+)
tests/intel/xe_create.c +2 -0
index b22084c84..e8b8bb025 100644
@@ -18,7 +18,9 @@
 #include "xe/xe_ioctl.h"
 #include "xe/xe_query.h"
 
+#ifndef PAGE_SIZE
 #define PAGE_SIZE 0x1000
+#endif
 
 static struct param {
 	unsigned int quantity;
Signature · 1 line
2.49.0
#12 lore raw

PATCH v13 11/11 lib/igt_device_scan: reuse igt hash

In reply to Jeevaka Prabu Badrappan

As glib is not available in Android, replace the glib hash functions by reusing the igt hash functions.

---
 lib/igt_device_scan.c | 78 ++++++++++++++++++++++---------------------
 lib/meson.build       |  1 +
 2 files changed, 41 insertions(+), 38 deletions(-)
lib/igt_device_scan.c +40 -38
index 45faabc45..e1cebfaed 100644
@@ -26,12 +26,12 @@
 #include "igt_core.h"
 #include "igt_device_scan.h"
 #include "igt_list.h"
+#include "igt_map.h"
 #include "intel_chipset.h"
 
 #include <ctype.h>
 #include <dirent.h>
 #include <fcntl.h>
-#include <glib.h>
 #include <libudev.h>
 #ifdef __linux__
 #include <linux/limits.h>
@@ -224,8 +224,8 @@ struct igt_device {
 	/* Point to vendor spec if can be found */
 
 	/* Properties / sysattrs rewriten from udev lists */
-	GHashTable *props_ht;
-	GHashTable *attrs_ht;
+	struct igt_map *props_map;
+	struct igt_map *attrs_map;
 
 	/* Most usable variables from udev device */
 	char *subsystem;
@@ -464,6 +464,11 @@ static bool is_on_blacklist(const char *what)
 
 }
 
+static int key_equals(const void *key1, const void *key2)
+{
+	return strcmp((char *)key1, (char *)key2) == 0;
+}
+
 static struct igt_device *igt_device_new(void)
 {
 	struct igt_device *dev;
@@ -472,14 +477,14 @@ static struct igt_device *igt_device_new(void)
 	if (!dev)
 		return NULL;
 
-	dev->attrs_ht = g_hash_table_new_full(g_str_hash, g_str_equal,
-					      free, free);
-	dev->props_ht = g_hash_table_new_full(g_str_hash, g_str_equal,
-					      free, free);
+	dev->attrs_map = igt_map_create(igt_map_hash_32, key_equals);
+	dev->props_map = igt_map_create(igt_map_hash_32, key_equals);
 
-	if (dev->attrs_ht && dev->props_ht)
+	if (dev->attrs_map && dev->props_map)
 		return dev;
 
+	igt_map_destroy(dev->attrs_map, NULL);
+	igt_map_destroy(dev->props_map, NULL);
 	free(dev);
 
 	return NULL;
@@ -491,7 +496,7 @@ static void igt_device_add_prop(struct igt_device *dev,
 	if (!key || !value)
 		return;
 
-	g_hash_table_insert(dev->props_ht, strdup(key), strdup(value));
+	igt_map_insert(dev->props_map, strdup(key), strdup(value));
 }
 
 static void igt_device_add_attr(struct igt_device *dev,
@@ -525,7 +530,7 @@ static void igt_device_add_attr(struct igt_device *dev,
 		v++;
 	}
 
-	g_hash_table_insert(dev->attrs_ht, strdup(key), strdup(v));
+	igt_map_insert(dev->attrs_map, strdup(key), strdup(v));
 }
 
 /* Iterate over udev properties list and rewrite it to igt_device properties
@@ -585,19 +590,30 @@ static void get_attrs_limited(struct udev_device *dev, struct igt_device *idev)
 	}
 }
 
-#define get_prop(dev, prop) ((char *) g_hash_table_lookup(dev->props_ht, prop))
-#define get_attr(dev, attr) ((char *) g_hash_table_lookup(dev->attrs_ht, attr))
+#define get_prop(dev, prop) ((char *) igt_map_search((dev)->props_map, prop))
+#define get_attr(dev, attr) ((char *) igt_map_search((dev)->attrs_map, attr))
 #define get_prop_subsystem(dev) get_prop(dev, "SUBSYSTEM")
 #define is_drm_subsystem(dev)  (strequal(get_prop_subsystem(dev), "drm"))
 #define is_pci_subsystem(dev)  (strequal(get_prop_subsystem(dev), "pci"))
 
-static void print_ht(GHashTable *ht);
+static inline void _print_key_value(const char *k, const char *v)
+{
+	printf("%-32s: %s\n", k, v);
+}
+
 static void dump_props_and_attrs(const struct igt_device *dev)
 {
+	struct igt_map_entry *entry;
+
 	printf("\n[properties]\n");
-	print_ht(dev->props_ht);
+	igt_map_foreach(dev->props_map, entry) {
+		_print_key_value((char *)entry->key, (char *)entry->data);
+	}
+
 	printf("\n[attributes]\n");
-	print_ht(dev->attrs_ht);
+	igt_map_foreach(dev->attrs_map, entry) {
+		_print_key_value((char *)entry->key, (char *)entry->data);
+	}
 	printf("\n");
 }
 
@@ -949,7 +965,7 @@ static struct igt_device *duplicate_device(struct igt_device *dev) {
 	return dup;
 }
 
-static gint devs_compare(const void *a, const void *b)
+static int devs_compare(const void *a, const void *b)
 {
 	struct igt_device *dev1, *dev2;
 	int ret;
@@ -1076,6 +1092,12 @@ static void scan_drm_devices(bool limit_attrs)
 	}
 }
 
+static void free_key_value(struct igt_map_entry *entry)
+{
+	free((char *)entry->key);
+	free(entry->data);
+}
+
 static void igt_device_free(struct igt_device *dev)
 {
 	free(dev->codename);
@@ -1088,8 +1110,8 @@ static void igt_device_free(struct igt_device *dev)
 	free(dev->device);
 	free(dev->driver);
 	free(dev->pci_slot_name);
-	g_hash_table_destroy(dev->attrs_ht);
-	g_hash_table_destroy(dev->props_ht);
+	igt_map_destroy(dev->attrs_map, free_key_value);
+	igt_map_destroy(dev->props_map, free_key_value);
 }
 
 void igt_devices_free(void)
@@ -1323,26 +1345,6 @@ igt_devs_print_user(struct igt_list_head *view,
 	}
 }
 
-static inline void _print_key_value(const char* k, const char *v)
-{
-	printf("%-32s: %s\n", k, v);
-}
-
-static void print_ht(GHashTable *ht)
-{
-	GList *keys = g_hash_table_get_keys(ht);
-
-	keys = g_list_sort(keys, (GCompareFunc) strcmp);
-	while (keys) {
-		char *k = (char *) keys->data;
-		char *v = g_hash_table_lookup(ht, k);
-
-		_print_key_value(k, v);
-		keys = g_list_next(keys);
-	}
-	g_list_free(keys);
-}
-
 static void
 igt_devs_print_detail(struct igt_list_head *view,
 		      const struct igt_devices_print_format *fmt)
lib/meson.build +1 -0
index f54198051..b134416eb 100644
@@ -306,6 +306,7 @@ scan_dep = [
 lib_igt_device_scan_build = static_library('igt_device_scan',
 	['igt_device_scan.c',
 	'igt_list.c',
+	'igt_map.c',
 	'igt_tools_stub.c',
 	'intel_device_info.c',
 	'intel_cmds_info.c',
Signature · 1 line
2.49.0