Skip to contentSkip to conversation

test/kms: Use bare number of crtc index to get a pipe

RFC Superseded Mohammed Khajapasha 1 participant 2 messages Mar 18, 2020 Library code

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover test/kms: Use bare number of crtc index to get a pipe

In non-continous pipe display,
1. if PIPE_B,C is disabled in kernel, PIPE_A & PIPE_D get registered with 0,1 indexes in display pipes[] array and kmstest_pipe_name() always prints PIPE_B for enum pipe 1 which is actually PIPE_D in kernel.
2. And in kernel the possible_crtc bit map is based on crtc index and for PIPE_D second least bit set in possible_crtc, macro for_each_pipe_with_valid_output() with enum pipe index always assumes PIPE_B for second least bit in possible_crtc but it is PIPE_D in kernel.

To avoid this using bare number of crtc index
to get a pipe from display->pipes[] array to support non-continuous pipe display.
This is a sample change to review on usage of bare number of
https://patchwork.freedesktop.org/series/74431/
crtc index for each pipe, based upon the review the patch series will be updated with this change.

Mohammed Khajapasha (1):
test/kms: Use bare number of crtc index to get a pipe

 lib/igt_kms.c                 |  22 ++--
 lib/igt_kms.h                 |  26 ++---
 tests/kms_atomic_transition.c | 196 +++++++++++++++++-----------------
 3 files changed, 121 insertions(+), 123 deletions(-)
Signature · 6 lines
2.24.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

RFC 1/1 test/kms: Use bare number of crtc index to get a pipe

In non-continous pipe display,
1. if PIPE_B,C is disabled in kernel, PIPE_A & PIPE_D get registered with 0,1 indexes in display pipes[] array and kmstest_pipe_name() always prints PIPE_B for enum pipe 1 which is actually PIPE_D in kernel.
2. And in kernel the possible_crtc bit map is based on crtc index and for PIPE_D second least bit set in possible_crtc, macro for_each_pipe_with_valid_output() with enum pipe index always assumes PIPE_B for second least bit in possible_crtc but it is PIPE_D in kernel.

To avoid this using bare number of crtc index to get a pipe from display->pipes[] array to support non-continuous pipe display.

This is a sample change to review on usage of bare number of crtc index for each pipe, based upon the review the patch series
https://patchwork.freedesktop.org/series/74431/
will be updated with this change.

---
 lib/igt_kms.c                 |  22 ++--
 lib/igt_kms.h                 |  26 ++---
 tests/kms_atomic_transition.c | 196 +++++++++++++++++-----------------
 3 files changed, 121 insertions(+), 123 deletions(-)
lib/igt_kms.c +11 -11
index 849aa346..c2c35c07 100644
@@ -2255,7 +2255,7 @@ report_dup:
 static igt_pipe_t *igt_output_get_driving_pipe(igt_output_t *output)
 {
 	igt_display_t *display = output->display;
-	enum pipe pipe;
+	int idx;
 
 	if (output->pending_pipe == PIPE_NONE) {
 		/*
@@ -2267,12 +2267,12 @@ static igt_pipe_t *igt_output_get_driving_pipe(igt_output_t *output)
 		 * Otherwise, return the pending pipe (ie the pipe that should
 		 * drive this output after the commit()
 		 */
-		pipe = output->pending_pipe;
+		idx = output->pending_pipe;
 	}
 
-	igt_assert(pipe >= 0 && pipe < display->n_pipes);
+	igt_assert(idx >= 0 && idx < display->n_pipes);
 
-	return &display->pipes[pipe];
+	return &display->pipes[idx];
 }
 
 static igt_plane_t *igt_pipe_get_plane(igt_pipe_t *pipe, int plane_idx)
@@ -3660,13 +3660,13 @@ void igt_output_override_mode(igt_output_t *output, const drmModeModeInfo *mode)
 /*
  * igt_output_set_pipe:
  * @output: Target output for which the pipe is being set to
- * @pipe: Display pipe to set to
+ * @idx: Index for a Display pipe to be set
  *
  * This function sets a @pipe to a specific @output connector by
  * setting the CRTC_ID property of the @pipe. The pipe
  * is only activated for all pipes except PIPE_NONE.
  */
-void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
+void igt_output_set_pipe(igt_output_t *output, int idx)
 {
 	igt_display_t *display = output->display;
 	igt_pipe_t *old_pipe = NULL, *pipe_obj = NULL;;
@@ -3676,12 +3676,12 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
 	if (output->pending_pipe != PIPE_NONE)
 		old_pipe = igt_output_get_driving_pipe(output);
 
-	if (pipe != PIPE_NONE)
-		pipe_obj = &display->pipes[pipe];
+	if (idx != PIPE_NONE)
+		pipe_obj = &display->pipes[idx];
 
 	LOG(display, "%s: set_pipe(%s)\n", igt_output_name(output),
-	    kmstest_pipe_name(pipe));
-	output->pending_pipe = pipe;
+	    kmstest_pipe_name(display->pipes[idx].pipe));
+	output->pending_pipe = idx;
 
 	if (old_pipe) {
 		igt_output_t *old_output;
@@ -3697,7 +3697,7 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
 		}
 	}
 
-	igt_output_set_prop_value(output, IGT_CONNECTOR_CRTC_ID, pipe == PIPE_NONE ? 0 : display->pipes[pipe].crtc_id);
+	igt_output_set_prop_value(output, IGT_CONNECTOR_CRTC_ID, idx == PIPE_NONE ? 0 : display->pipes[idx].crtc_id);
 
 	igt_output_refresh(output);
 
lib/igt_kms.h +13 -13
index b534ae64..bcef88b6 100644
@@ -362,7 +362,7 @@ typedef struct {
 	struct kmstest_connector_config config;
 	char *name;
 	bool force_reprobe;
-	enum pipe pending_pipe;
+	int pending_pipe;
 	bool use_override_mode;
 	drmModeModeInfo override_mode;
 
@@ -415,7 +415,7 @@ void igt_display_require_output_on_pipe(igt_display_t *display, enum pipe pipe);
 const char *igt_output_name(igt_output_t *output);
 drmModeModeInfo *igt_output_get_mode(igt_output_t *output);
 void igt_output_override_mode(igt_output_t *output, const drmModeModeInfo *mode);
-void igt_output_set_pipe(igt_output_t *output, enum pipe pipe);
+void igt_output_set_pipe(igt_output_t *output, int idx);
 igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx);
 igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type);
 int igt_output_count_plane_type(igt_output_t *output, int plane_type);
@@ -467,9 +467,9 @@ static inline bool igt_output_is_connected(igt_output_t *output)
  *
  * Checks whether the given pipe and output can be used together.
  */
-#define igt_pipe_connector_valid(pipe, output) \
+#define igt_pipe_connector_valid(idx, output) \
 	(igt_output_is_connected((output)) && \
-	       (output->config.valid_crtc_idx_mask & (1 << (pipe))))
+	       (output->config.valid_crtc_idx_mask & (1 << (idx))))
 
 #define for_each_if(condition) if (!(condition)) {} else
 
@@ -517,7 +517,7 @@ static inline bool igt_output_is_connected(igt_output_t *output)
 /**
  * for_each_pipe_with_valid_output:
  * @display: a pointer to an #igt_display_t structure
- * @pipe: The pipe for which this @pipe / @output combination is valid.
+ * @idx: The CRTC index for which this @pipe / @output combination is valid.
  * @output: The output for which this @pipe / @output combination is valid.
  *
  * This for loop is called over all connected outputs. This function
@@ -527,12 +527,12 @@ static inline bool igt_output_is_connected(igt_output_t *output)
  * for_each_pipe_with_single_output(), if you only need an
  * output for a single pipe, use igt_get_single_output_for_pipe().
  */
-#define for_each_pipe_with_valid_output(display, pipe, output) \
-	for (int con__ = (pipe) = 0; \
-	     assert(igt_can_fail()), (pipe) < igt_display_get_n_pipes((display)) && con__ < (display)->n_outputs; \
-	     con__ = (con__ + 1 < (display)->n_outputs) ? con__ + 1 : (pipe = pipe + 1, 0)) \
+#define for_each_pipe_with_valid_output(display, idx, output) \
+	for (int con__ = (idx) = 0; \
+	     assert(igt_can_fail()), (idx) < igt_display_get_n_pipes((display)) && con__ < (display)->n_outputs; \
+	     con__ = (con__ + 1 < (display)->n_outputs) ? con__ + 1 : (idx = idx + 1, 0)) \
 		for_each_if ((((output) = &(display)->outputs[con__]), \
-			     igt_pipe_connector_valid((pipe), (output))))
+			     igt_pipe_connector_valid((idx), (output))))
 
 igt_output_t **__igt_pipe_populate_outputs(igt_display_t *display,
 					   igt_output_t **chosen_outputs);
@@ -568,9 +568,9 @@ igt_output_t **__igt_pipe_populate_outputs(igt_display_t *display,
 	for_each_connected_output((display), (output)) \
 		for_each_if (igt_pipe_connector_valid((pipe), (output)))
 
-#define for_each_plane_on_pipe(display, pipe, plane)			\
-	for (int j__ = 0; assert(igt_can_fail()), (plane) = &(display)->pipes[(pipe)].planes[j__], \
-		     j__ < (display)->pipes[(pipe)].n_planes; j__++)
+#define for_each_plane_on_pipe(display, idx, plane)			\
+	for (int j__ = 0; assert(igt_can_fail()), (plane) = &(display)->pipes[(idx)].planes[j__], \
+		     j__ < (display)->pipes[(idx)].n_planes; j__++)
 
 #define IGT_FIXED(i,f)	((i) << 16 | (f))
 
tests/kms_atomic_transition.c +97 -99

536 lines not on this page · raw message

Signature · 6 lines
2.24.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev