[igt-dev] [PATCH i-g-t 10/11] lib/kms: Convert pipe id flags for a vblank using crtc offset

Mohammed Khajapasha mohammed.khajapasha at intel.com
Sat Jul 11 18:04:56 UTC 2020


In i915 with non-contiguous pipes display, pipes always not same
as crtc index in display pipes array. Hence reading pipe id flags
for a vblank event using crtc offset.

Signed-off-by: Mohammed Khajapasha <mohammed.khajapasha at intel.com>
---
 lib/igt_kms.c | 48 ++++++++++++++++++++++++++++++++----------------
 lib/igt_kms.h | 14 +++++++++++---
 2 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 467df3ae..3b32a2d4 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1985,6 +1985,8 @@ void igt_display_require(igt_display_t *display, int drm_fd)
 
 		pipe->enabled = true;
 		pipe->crtc_id = resources->crtcs[i];
+		/* offset of a pipe in crtcs list */
+		pipe->crtc_offset = i;
 	}
 
 	drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
@@ -4133,18 +4135,22 @@ void igt_pipe_request_out_fence(igt_pipe_t *pipe)
 /**
  * igt_wait_for_vblank_count:
  * @drm_fd: A drm file descriptor
- * @pipe: Pipe to wait_for_vblank on
+ * @crtc_offset: offset of a Pipe to wait_for_vblank on
  * @count: Number of vblanks to wait on
  *
+ * In i915, with non-contiguous pipe display, pipe mapping always
+ * not same with crtc mapping, passing crtc offset of a pipe to
+ * read vblank count for a pipe, in i915 pipe is i915's crtc object id.
+ *
  * Waits for a given number of vertical blank intervals
  */
-void igt_wait_for_vblank_count(int drm_fd, enum pipe pipe, int count)
+void igt_wait_for_vblank_count(int drm_fd, int crtc_offset, int count)
 {
 	drmVBlank wait_vbl;
 	uint32_t pipe_id_flag;
 
 	memset(&wait_vbl, 0, sizeof(wait_vbl));
-	pipe_id_flag = kmstest_get_vbl_flag(pipe);
+	pipe_id_flag = kmstest_get_vbl_flag(crtc_offset);
 
 	wait_vbl.request.type = DRM_VBLANK_RELATIVE;
 	wait_vbl.request.type |= pipe_id_flag;
@@ -4156,13 +4162,17 @@ void igt_wait_for_vblank_count(int drm_fd, enum pipe pipe, int count)
 /**
  * igt_wait_for_vblank:
  * @drm_fd: A drm file descriptor
- * @pipe: Pipe to wait_for_vblank on
+ * @crtc_offset: offset of a Pipe to wait_for_vblank on
+ *
+ * In i915, with non-contiguous pipe display, pipe mapping always
+ * not same with crtc mapping, passing crtc offset of a pipe to
+ * read vblank count for a pipe.
  *
  * Waits for 1 vertical blank intervals
  */
-void igt_wait_for_vblank(int drm_fd, enum pipe pipe)
+void igt_wait_for_vblank(int drm_fd, int crtc_offset)
 {
-	igt_wait_for_vblank_count(drm_fd, pipe, 1);
+	igt_wait_for_vblank_count(drm_fd, crtc_offset, 1);
 }
 
 /**
@@ -4385,22 +4395,28 @@ void igt_cleanup_uevents(struct udev_monitor *mon)
 
 /**
  * kmstest_get_vbl_flag:
- * @pipe_id: Pipe to convert to flag representation.
+ * @crtc_offset: CRTC offset to convert into pipe flag representation.
  *
- * Convert a pipe id into the flag representation
- * expected in DRM while processing DRM_IOCTL_WAIT_VBLANK.
+ * In i915, with non-contiguous pipe display, pipe mapping always
+ * not same with crtc mapping, pipe is enum id of i915's crtc object
+ * passing crtc offset of a pipe to convert into the pipe flag
+ * representation expected in DRM while processing DRM_IOCTL_WAIT_VBLANK.
  */
-uint32_t kmstest_get_vbl_flag(uint32_t pipe_id)
+uint32_t kmstest_get_vbl_flag(int crtc_offset)
 {
-	if (pipe_id == 0)
-		return 0;
-	else if (pipe_id == 1)
-		return _DRM_VBLANK_SECONDARY;
+	uint32_t pipe_id;
+
+	if (crtc_offset == 0)
+		pipe_id = 0;
+	else if (crtc_offset == 1)
+		pipe_id = _DRM_VBLANK_SECONDARY;
 	else {
-		uint32_t pipe_flag = pipe_id << 1;
+		uint32_t pipe_flag = crtc_offset << 1;
 		igt_assert(!(pipe_flag & ~DRM_VBLANK_HIGH_CRTC_MASK));
-		return pipe_flag;
+		pipe_id = pipe_flag;
 	}
+
+	return pipe_id;
 }
 
 static inline const uint32_t *
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 7109c9a5..162c4850 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -338,8 +338,14 @@ typedef struct igt_plane {
 	int format_mod_count;
 } igt_plane_t;
 
+/*
+ * In i915, with non-contiguous pipe display, a pipe is not always
+ * same as a crtc mapping in display, pipe is enum id of a i915's crtc object
+ * using crtc offset to get the offset of a pipe from mode config list
+ */
 struct igt_pipe {
 	igt_display_t *display;
+	/* Id of a pipe object */
 	enum pipe pipe;
 	/* pipe is enabled or not */
 	bool enabled;
@@ -354,6 +360,8 @@ struct igt_pipe {
 	uint64_t values[IGT_NUM_CRTC_PROPS];
 
 	uint32_t crtc_id;
+	/* crtc offset of a pipe in mode config list */
+	uint32_t crtc_offset;
 
 	int32_t out_fence_fd;
 };
@@ -448,8 +456,8 @@ void igt_fb_set_position(struct igt_fb *fb, igt_plane_t *plane,
 void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,
 	uint32_t w, uint32_t h);
 
-void igt_wait_for_vblank(int drm_fd, enum pipe pipe);
-void igt_wait_for_vblank_count(int drm_fd, enum pipe pipe, int count);
+void igt_wait_for_vblank(int drm_fd, int crtc_offset);
+void igt_wait_for_vblank_count(int drm_fd, int crtc_offset, int count);
 
 static inline bool igt_output_is_connected(igt_output_t *output)
 {
@@ -769,7 +777,7 @@ void igt_pipe_refresh(igt_display_t *display, enum pipe pipe, bool force);
 void igt_enable_connectors(int drm_fd);
 void igt_reset_connectors(void);
 
-uint32_t kmstest_get_vbl_flag(uint32_t pipe_id);
+uint32_t kmstest_get_vbl_flag(int crtc_offset);
 
 const struct edid *igt_kms_get_base_edid(void);
 const struct edid *igt_kms_get_alt_edid(void);
-- 
2.24.1



More information about the igt-dev mailing list