[PATCH i-g-t v2] lib/igt_kms: Backup connector modes before sorting

Karthik B S karthik.b.s at intel.com
Tue Jan 7 08:33:13 UTC 2025


On 1/3/2025 9:03 PM, Santhosh Reddy Guddati wrote:
> Backup connector modes before sorting to ensure the original mode
> is not changed if the joiner is not found.This will skip updating
> connector->mode[0] if joiner is not available.
>
> v2: Dont sort the modes, instead check for the required modes (Luca Coelho)
>
> Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13287
> Signed-off-by: Santhosh Reddy Guddati <santhosh.reddy.guddati at intel.com>
Reviewed-by: Karthik B S <karthik.b.s at intel.com>
> ---
>   lib/igt_kms.c | 27 +++++++++++++--------------
>   1 file changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index a67d17c4f..95e3059f7 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -6418,14 +6418,13 @@ bool bigjoiner_mode_found(int drm_fd, drmModeConnector *connector,
>   {
>   	bool found = false;
>   
> -	igt_sort_connector_modes(connector, sort_drm_modes_by_res_dsc);
> -	found = igt_bigjoiner_possible(drm_fd, &connector->modes[0], max_dotclock);
> -	if (!found) {
> -		igt_sort_connector_modes(connector, sort_drm_modes_by_clk_dsc);
> -		found = igt_bigjoiner_possible(drm_fd, &connector->modes[0], max_dotclock);
> +	for (int i=0; i< connector->count_modes; i++) {
> +		if (igt_bigjoiner_possible(drm_fd, &connector->modes[i], max_dotclock)) {
> +			*mode = connector->modes[i];
> +			found = true;
> +			break;
> +		}
>   	}
> -	if (found)
> -		*mode = connector->modes[0];
>   	return found;
>   }
>   
> @@ -6462,14 +6461,14 @@ bool ultrajoiner_mode_found(int drm_fd, drmModeConnector *connector,
>   {
>   	bool found = false;
>   
> -	igt_sort_connector_modes(connector, sort_drm_modes_by_res_dsc);
> -	found = igt_ultrajoiner_possible(&connector->modes[0], max_dotclock);
> -	if (!found) {
> -		igt_sort_connector_modes(connector, sort_drm_modes_by_clk_dsc);
> -		found = igt_ultrajoiner_possible(&connector->modes[0], max_dotclock);
> +	for (int i = 0; i < connector->count_modes; i++) {
> +		if (igt_ultrajoiner_possible(&connector->modes[i], max_dotclock)) {
> +			*mode = connector->modes[i];
> +			found = true;
> +			break;
> +		}
>   	}
> -	if (found)
> -		*mode = connector->modes[0];
> +
>   	return found;
>   }
>   


More information about the igt-dev mailing list