[PATCH i-g-t 2/7] tests/intel/kms_mst_helper: add helper for MST-related functions

Sharma, Swati2 swati2.sharma at intel.com
Fri Feb 14 07:13:29 UTC 2025


Hi Kunal,

On 11-02-2025 11:35 pm, Kunal Joshi wrote:
> Add helper to centralize commonly used MST-related logic.
> Move find_mst_outputs to lib.
>
> v2: fix docs (Ankit)
>      split patch (Ankit)
>
> Signed-off-by: Kunal Joshi <kunal1.joshi at intel.com>
> ---
>   tests/intel/kms_dp_linktrain_fallback.c | 38 +++-----------------
>   tests/intel/kms_mst_helper.c            | 48 +++++++++++++++++++++++++
>   tests/intel/kms_mst_helper.h            | 15 ++++++++
>   tests/meson.build                       |  1 +
>   4 files changed, 69 insertions(+), 33 deletions(-)
>   create mode 100644 tests/intel/kms_mst_helper.c
>   create mode 100644 tests/intel/kms_mst_helper.h
>
> diff --git a/tests/intel/kms_dp_linktrain_fallback.c b/tests/intel/kms_dp_linktrain_fallback.c
> index edf9409b6..145bf2fc5 100644
> --- a/tests/intel/kms_dp_linktrain_fallback.c
> +++ b/tests/intel/kms_dp_linktrain_fallback.c
> @@ -16,6 +16,7 @@
>   #include <sys/types.h>
>   #include "igt_sysfs.h"
>   #include "igt.h"
> +#include "kms_mst_helper.h"
>   
>   /**
>    * SUBTEST: dp-fallback
> @@ -47,35 +48,6 @@ typedef int (*condition_check_fn)(int drm_fd, igt_output_t *output);
>   
>   IGT_TEST_DESCRIPTION("Test link training fallback");
>   
> -static int find_mst_outputs(int drm_fd, igt_display_t *display,
> -			    igt_output_t *output,
> -			    igt_output_t *mst_outputs[],
> -			    int *num_mst_outputs)
> -{
> -	int output_root_id, root_id;
> -	igt_output_t *connector_output;
> -
> -	if (!igt_check_output_is_dp_mst(output))
> -		return -EINVAL;
> -
> -	output_root_id = igt_get_dp_mst_connector_id(output);
> -	if (output_root_id == -EINVAL)
> -		return -EINVAL;
> -	/*
> -	 * If output is MST check all other connected output which shares
> -	 * same path and fill mst_outputs and num_mst_outputs
> -	 */
> -	for_each_connected_output(display, connector_output) {
> -		if (!igt_check_output_is_dp_mst(connector_output))
> -			continue;
> -
> -		root_id = igt_get_dp_mst_connector_id(connector_output);
> -		if (((*num_mst_outputs) < IGT_MAX_PIPES) && root_id == output_root_id)
> -			mst_outputs[(*num_mst_outputs)++] = connector_output;
> -	}
> -	return 0;
> -}
> -
>   static bool setup_mst_outputs(data_t *data, igt_output_t *mst_output[],
>   			      int *output_count)
>   {
> @@ -90,10 +62,10 @@ static bool setup_mst_outputs(data_t *data, igt_output_t *mst_output[],
>   		    traversed_mst_outputs[i] == data->output->config.connector->connector_id)
>   			return false;
>   
> -	igt_assert_f(find_mst_outputs(data->drm_fd, &data->display,
> -				      data->output, mst_output,
> -				      output_count) == 0,
> -				      "Unable to find mst outputs or given optput is not mst\n");
> +	igt_assert_f(igt_find_all_mst_output_in_topology(data->drm_fd, &data->display,
> +							 data->output, mst_output,
> +							 output_count) == 0,
> +							 "Unable to find mst outputs or given optput is not mst\n");
Please fix the typo here too.
>   
>   	for (i = 0; i < *output_count; i++) {
>   		output = mst_output[i];
> diff --git a/tests/intel/kms_mst_helper.c b/tests/intel/kms_mst_helper.c
> new file mode 100644
> index 000000000..c12bf0703
> --- /dev/null
> +++ b/tests/intel/kms_mst_helper.c
> @@ -0,0 +1,48 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +
> +#include "kms_mst_helper.h"
> +
> +/*
> + * @drm_fd: DRM file descriptor
> + * @display: pointer to #igt_display_t structure
> + * @output: target output
> + * @mst_outputs: filled with mst output of same toplogy as @output
> + * @num_mst_outputs: filled with count of mst outputs found in topology
> + *
> + * Iterates over all connected outputs and adds each DP MST
> + * output that shares the same MST connector ID as @output
> + * into @mst_outputs.
> + *
> + * Returns: 0 on success, -error on failure
> + */
> +int igt_find_all_mst_output_in_topology(int drm_fd, igt_display_t *display,
> +					igt_output_t *output,
> +					igt_output_t *mst_outputs[],
> +					int *num_mst_outputs)
> +{
> +        int output_root_id, root_id;
> +        igt_output_t *connector_output;
> +
> +        if (!igt_check_output_is_dp_mst(output))
> +                return -EINVAL;
> +
> +        output_root_id = igt_get_dp_mst_connector_id(output);
> +        if (output_root_id == -EINVAL)
> +                return -EINVAL;
> +        /*
> +         * If output is MST check all other connected output which shares
> +         * same path and fill mst_outputs and num_mst_outputs
> +         */
> +        for_each_connected_output(display, connector_output) {
> +                if (!igt_check_output_is_dp_mst(connector_output))
> +                        continue;
> +
> +                root_id = igt_get_dp_mst_connector_id(connector_output);
> +                if (((*num_mst_outputs) < IGT_MAX_PIPES) && root_id == output_root_id)
> +                        mst_outputs[(*num_mst_outputs)++] = connector_output;
> +        }
> +        return 0;
> +}
> diff --git a/tests/intel/kms_mst_helper.h b/tests/intel/kms_mst_helper.h
> new file mode 100644
> index 000000000..5b62b979b
> --- /dev/null
> +++ b/tests/intel/kms_mst_helper.h
> @@ -0,0 +1,15 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +
> +#ifndef KMS_MST_HELPER_H
> +#define KMS_MST_HELPER_H
> +
> +#include "igt.h"
> +
> +int igt_find_all_mst_output_in_topology(int drm_fd, igt_display_t *display,
> +                                        igt_output_t *output,
> +                                        igt_output_t *mst_outputs[],
> +                                        int *num_mst_outputs);
> +#endif
> diff --git a/tests/meson.build b/tests/meson.build
> index 33dffad31..a6f6ad560 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -366,6 +366,7 @@ extra_sources = {
>   	'kms_chamelium_edid': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
>   	'kms_chamelium_frames': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
>   	'kms_chamelium_hpd': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
> +	'kms_dp_linktrain_fallback': [ join_paths ('intel', 'kms_mst_helper.c') ],
>   	'kms_dsc': [ join_paths ('intel', 'kms_dsc_helper.c') ],
>   	'kms_psr2_sf':  [ join_paths ('intel', 'kms_dsc_helper.c') ],
>   }



More information about the igt-dev mailing list