Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/4] lib/igt_kms: Add igt_connector_sysfs_open()
@ 2019-12-03 15:35 Ville Syrjala
  2019-12-03 15:35 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_kms: Don't leak fds when forcing connector multiple times Ville Syrjala
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Ville Syrjala @ 2019-12-03 15:35 UTC (permalink / raw)
  To: igt-dev

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a helper to open the sysfs directory for a connector.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/igt_kms.c | 34 ++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  3 +++
 2 files changed, 37 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 44647a2263bd..74ae98d774f1 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -965,6 +965,40 @@ static void reset_connectors_at_exit(int sig)
 	igt_reset_connectors();
 }
 
+static char *kmstest_connector_dirname(int idx,
+				       uint32_t connector_type,
+				       uint32_t connector_type_id,
+				       char *name, int namelen)
+{
+	snprintf(name, namelen, "card%d-%s-%d", idx,
+		 kmstest_connector_type_str(connector_type),
+		 connector_type_id);
+
+	return name;
+}
+
+int igt_connector_sysfs_open(int drm_fd,
+			     drmModeConnector *connector)
+{
+	char name[80];
+	int dir, conn_dir;
+
+	dir = igt_sysfs_open(drm_fd);
+	if (dir < 0)
+		return dir;
+
+	if (!kmstest_connector_dirname(igt_device_get_card_index(drm_fd),
+				       connector->connector_type,
+				       connector->connector_type_id,
+				       name, sizeof(name)))
+		return -1;
+
+	conn_dir = openat(dir, name, O_RDONLY);
+	close(dir);
+
+	return conn_dir;
+}
+
 /**
  * kmstest_force_connector:
  * @fd: drm file descriptor
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 3f798392f8a0..6c919e92f488 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -844,4 +844,7 @@ static inline bool igt_vblank_before(uint32_t a, uint32_t b)
 void igt_parse_connector_tile_blob(drmModePropertyBlobPtr blob,
 		igt_tile_info_t *tile);
 
+int igt_connector_sysfs_open(int drm_fd,
+			     drmModeConnector *connector);
+
 #endif /* __IGT_KMS_H__ */
-- 
2.23.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-12-04 16:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-03 15:35 [igt-dev] [PATCH i-g-t 1/4] lib/igt_kms: Add igt_connector_sysfs_open() Ville Syrjala
2019-12-03 15:35 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_kms: Don't leak fds when forcing connector multiple times Ville Syrjala
2019-12-03 16:24   ` Chris Wilson
2019-12-03 15:35 ` [igt-dev] [PATCH i-g-t 3/4] lib/igt_kms: Rework forced connector handling Ville Syrjala
2019-12-03 16:25   ` Chris Wilson
2019-12-03 15:35 ` [igt-dev] [PATCH i-g-t 4/4] tests/kms_dp_aux_dev: Add drm_dp_aux test Ville Syrjala
2019-12-03 16:32   ` Chris Wilson
2019-12-03 16:51     ` Ville Syrjälä
2019-12-03 16:16 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/4] lib/igt_kms: Add igt_connector_sysfs_open() Patchwork
2019-12-03 16:22 ` [igt-dev] [PATCH i-g-t 1/4] " Chris Wilson
2019-12-04 16:55   ` Ville Syrjälä
2019-12-03 23:34 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,1/4] " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox