[PATCH i-g-t v7 09/48] lib/igt_kms: Expose connector_attr_set and igt_connector_attr_set

Louis Chauvet
2026-02-23T12:08:55Z

Some debugfs helpers need to use connector attributes. Expose those helpers
to allow using them in igt_debugfs.

Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
---
lib/igt_kms.c | 30 +++++++++++++++++++++++-------
lib/igt_kms.h | 6 ++++++
2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 2ea774d79d8a..043d7dd547c2 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -100,8 +100,6 @@
*/
#define IGT_KMS_CONNECTOR_NAME_SIZE 50

-typedef bool (*igt_connector_attr_set)(int dir, const char *attr, const char *value);
-
struct igt_connector_attr {
uint32_t connector_type;
uint32_t connector_type_id;
@@ -1682,11 +1680,29 @@ static void connector_attr_free(struct igt_connector_attr *c)
memset(c, 0, sizeof(*c));
}

-static bool connector_attr_set(int idx, drmModeConnector *connector,
- int dir, igt_connector_attr_set set,
- const char *attr, const char *value,
- const char *reset_value,
- bool force_reset)
+/**
+ * connector_attr_set:
+ * @idx: card index
+ * @connector: libdrm connector
+ * @dir: directory file descriptor
+ * @set: function to set the attribute
+ * @attr: attribute name
+ * @value: attribute value
+ * @reset_value: value to reset the attribute to
+ * @force_reset: whether to force reset the attribute
+ *
+ * Configure a new attribute for @connector on card @idx that can be set
+ * using @set function.
+ * connector_attr_set register this attribute to reset it to the @reset_value
+ * during igt_reset_connector.
+ *
+ * Returns: True on success, false on failure.
+ */
+bool connector_attr_set(int idx, drmModeConnector *connector,
+ int dir, igt_connector_attr_set set,
+ const char *attr, const char *value,
+ const char *reset_value,
+ bool force_reset)
{
struct igt_connector_attr *c;

diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 23b7110fafca..568d863f2dc4 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -1237,6 +1237,12 @@ void igt_parse_connector_tile_blob(drmModePropertyBlobPtr blob,

int igt_connector_sysfs_open(int drm_fd,
drmModeConnector *connector);
+typedef bool (*igt_connector_attr_set)(int dir, const char *attr, const char *value);
+bool connector_attr_set(int idx, drmModeConnector *connector,
+ int dir, igt_connector_attr_set set,
+ const char *attr, const char *value,
+ const char *reset_value,
+ bool force_reset);
uint32_t igt_reduce_format(uint32_t format);

--
2.52.0