Re: [PATCH i-g-t v2 07/23] lib/kms: Add igt_crtc_for_crtc_id()

Jani Nikula
2026-02-23T11:46:58Z

On Sat, 21 Feb 2026, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Introduce igt_crtc_for_crtc_id() as a helper to return the
> appropriate igt_crtc_t* for a given KMS CRTC ID. This will
> be useful for kms_lease which will need to match the CRTCs
> between the lessor and lessee (each has a different view of
> the same KMS objects, and thus also different igt_display_t).
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
> lib/igt_kms.c | 12 ++++++++++++
> lib/igt_kms.h | 1 +
> 2 files changed, 13 insertions(+)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 5c48796040a2..bec96f2677ad 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -7952,3 +7952,15 @@ bool igt_has_lobf_debugfs(int drmfd, igt_output_t *output)
> buf, sizeof(buf));
> return res == 0;
> }
> +
> +igt_crtc_t *igt_crtc_for_crtc_id(igt_display_t *display, uint32_t crtc_id)
> +{
> + igt_crtc_t *crtc;
> +
> + for_each_crtc(display, crtc) {
> + if (crtc->crtc_id == crtc_id)
> + return crtc;
> + }
> +
> + return NULL;
> +}
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index dedc3f88055b..5a2dd87b509f 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -582,6 +582,7 @@ static inline igt_crtc_t *igt_crtc_for_pipe(igt_display_t *display, enum pipe pi
>
> return &display->crtcs[pipe];
> }
> +igt_crtc_t *igt_crtc_for_crtc_id(igt_display_t *display, uint32_t crtc_id);
>
> typedef struct _igt_pipe_crc igt_pipe_crc_t;
> igt_pipe_crc_t *igt_crtc_crc_new(igt_crtc_t *crtc, const char *source);

--
Jani Nikula, Intel