[PATCH i-g-t 1/3] lib/kms: don't special case igt_get_single_output_for_crtc() implementation

Jani Nikula
2026-03-23T12:06:46Z

igt_get_single_output_for_crtc() can be trivially implemented in a more
generic way using for_each_crtc_with_single_output() instead of using
__igt_pipe_populate_outputs() and its implementation details directly.

Do so to make it all easier to understand, and to make refactoring
for_each_crtc_with_single_output() and __igt_pipe_populate_outputs()
easier.

Arguably the iteration is slower, but the bulk of the work is done in
__igt_pipe_populate_outputs() anyway, and we're talking about O(n)
search where n is 16.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
lib/igt_kms.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 481b893fc025..b835584bef1e 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3665,12 +3665,15 @@ igt_output_t **__igt_pipe_populate_outputs(igt_display_t *display, igt_output_t
*/
igt_output_t *igt_get_single_output_for_crtc(igt_crtc_t *crtc)
{
- igt_display_t *display = crtc->display;
- igt_output_t *chosen_outputs[igt_display_n_crtcs(display)];
+ igt_output_t *output;
+ igt_crtc_t *iter;

- __igt_pipe_populate_outputs(display, chosen_outputs);
+ for_each_crtc_with_single_output(crtc->display, iter, output) {
+ if (iter == crtc)
+ return output;
+ }

- return chosen_outputs[crtc->pipe];
+ return NULL;
}

static igt_output_t *igt_crtc_get_output(igt_crtc_t *crtc)
--
2.47.3