[PATCH i-g-t 1/2] lib/igt_kms: move bigjoiner_mode_found to lib.

Modem, Bhanuprakash bhanuprakash.modem at intel.com
Thu Jan 18 09:28:49 UTC 2024


Hi Kunal,

On 12-01-2024 02:25 pm, Kunal Joshi wrote:
> move bigjoiner_mode_found to lib/igt_kms with some modification
> 
> Cc: Karthik B S <karthik.b.s at intel.com>
> Cc: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
> Signed-off-by: Kunal Joshi <kunal1.joshi at intel.com>
> ---
>   lib/igt_kms.c                | 19 +++++++++++++++++++
>   lib/igt_kms.h                |  3 +++
>   tests/intel/kms_big_joiner.c | 14 ++------------
>   3 files changed, 24 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index e4dea1a60..2c55af05f 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -6142,6 +6142,25 @@ bool igt_bigjoiner_possible(drmModeModeInfo *mode, int max_dotclock)
>   		mode->clock > max_dotclock);
>   }
>   
> +/**
> + * bigjoiner_mode_found:
> + * @connector: libdrm connector
> + * @sort_method: comparator method
> + * @mode: libdrm mode
> + *
> + * Returns: True if big joiner found in connector modes
> + */
> +bool bigjoiner_mode_found(int drm_fd, drmModeConnector *connector,
> +			  int (*sort_method)(const void *, const void*),
> +			  drmModeModeInfo *mode)
> +{
> +        igt_sort_connector_modes(connector, sort_method);
> +        *mode = connector->modes[0];

IMHO, Instead of calling this helper multiple times with different sort 
methods, let's consolidate here only. Example below:

bool bigjoiner_mode_found(int drm_fd, drmModeConnector *connector,
                          int max_dotclock)
{
   igt_sort_connector_modes(connector, sort_drm_modes_by_res_dsc);
   if (igt_bigjoiner_possible(&connector->modes[0], max_dotclock))
     return true;

   igt_sort_connector_modes(connector, sort_drm_modes_by_clk_dsc);
   return igt_bigjoiner_possible(&connector->modes[0], max_dotclock);
}

> +
> +        return igt_bigjoiner_possible(mode,
> +				      igt_get_max_dotclock(drm_fd));
> +}
> +
>   /**
>    * igt_check_bigjoiner_support:
>    * @display: a pointer to an #igt_display_t structure
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index b3882808b..9f5676d35 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -1212,6 +1212,9 @@ bool igt_max_bpc_constraint(igt_display_t *display, enum pipe pipe,
>   		igt_output_t *output, int bpc);
>   int igt_get_max_dotclock(int fd);
>   bool igt_bigjoiner_possible(drmModeModeInfo *mode, int max_dotclock);
> +bool bigjoiner_mode_found(int drm_fd, drmModeConnector *connector,
> +                                 int (*sort_method)(const void *, const void*),
> +                                 drmModeModeInfo *mode);
>   bool igt_check_bigjoiner_support(igt_display_t *display);
>   bool igt_parse_mode_string(const char *mode_string, drmModeModeInfo *mode);
>   bool intel_pipe_output_combo_valid(igt_display_t *display);
> diff --git a/tests/intel/kms_big_joiner.c b/tests/intel/kms_big_joiner.c
> index aba2adfbe..1858c6362 100644
> --- a/tests/intel/kms_big_joiner.c
> +++ b/tests/intel/kms_big_joiner.c
> @@ -199,16 +199,6 @@ static void test_dual_display(data_t *data)
>   	igt_display_commit2(display, COMMIT_ATOMIC);
>   }
>   
> -static bool bigjoiner_mode_found(drmModeConnector *connector,
> -				 int (*sort_method)(const void *, const void*),
> -				 drmModeModeInfo *mode)
> -{
> -	igt_sort_connector_modes(connector, sort_method);
> -	*mode = connector->modes[0];
> -
> -	return igt_bigjoiner_possible(mode, max_dotclock);
> -}
> -
>   igt_main
>   {
>   	data_t data;
> @@ -235,8 +225,8 @@ igt_main
>   			 * Bigjoiner will come in to the picture when the
>   			 * resolution > 5K or clock > max-dot-clock.
>   			 */
> -			found = (bigjoiner_mode_found(connector, sort_drm_modes_by_res_dsc, &mode) ||
> -				 bigjoiner_mode_found(connector, sort_drm_modes_by_clk_dsc, &mode)) ?
> +			found = (bigjoiner_mode_found(data.drm_fd, connector, sort_drm_modes_by_res_dsc, &mode) ||
> +				 bigjoiner_mode_found(data.drm_fd, connector, sort_drm_modes_by_clk_dsc, &mode)) ?
>   					true : false;
>   
>   			if (found) {


More information about the igt-dev mailing list