[igt-dev] [i-g-t V2] lib/igt_kms: New api to iterate over all outputs

Bhanuprakash Modem bhanuprakash.modem at intel.com
Fri Sep 30 09:12:26 UTC 2022


A few KMS tests are trying to run on all outputs irrespective of
their connection status. So add a new helper to iterate over all
outputs.

V2:
- Fix the commit message
- New helper to iterate over all disconnected outputs

Cc: Petri Latvala <petri.latvala at intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
Reviewed-by: Petri Latvala <petri.latvala at intel.com>
---
 lib/igt_kms.h | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 3d78c37f..ca2765e9 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -544,16 +544,37 @@ static inline bool igt_output_is_connected(igt_output_t *output)
 #define for_each_if(condition) if (!(condition)) {} else
 
 /**
- * for_each_connected_output:
+ * for_each_output:
  * @display: a pointer to an #igt_display_t structure
  * @output: The output to iterate.
  *
  * This for loop iterates over all outputs.
  */
-#define for_each_connected_output(display, output)		\
+#define for_each_output(display, output)		\
 	for (int i__ = 0;  assert(igt_can_fail()), i__ < (display)->n_outputs; i__++)	\
-		for_each_if ((((output) = &(display)->outputs[i__]), \
-			      igt_output_is_connected((output))))
+		for_each_if (((output) = (&(display)->outputs[i__])))
+
+/**
+ * for_each_connected_output:
+ * @display: a pointer to an #igt_display_t structure
+ * @output: The output to iterate.
+ *
+ * This for loop iterates over all connected outputs.
+ */
+#define for_each_connected_output(display, output)		\
+	for_each_output((display), (output))	\
+		for_each_if ((igt_output_is_connected((output))))
+
+/**
+ * for_each_disconnected_output:
+ * @display: a pointer to an #igt_display_t structure
+ * @output: The output to iterate.
+ *
+ * This for loop iterates over all disconnected outputs.
+ */
+#define for_each_disconnected_output(display, output)		\
+	for_each_output((display), (output))	\
+		for_each_if ((!(igt_output_is_connected((output)))))
 
 /**
  * for_each_pipe_static:
-- 
2.37.3



More information about the igt-dev mailing list