[PATCH i-g-t 02/14] lib/igt_kms: add helper to get current link rate/ lane count for connector

B, Jeevan jeevan.b at intel.com
Tue Aug 27 05:38:59 UTC 2024


> -----Original Message-----
> From: igt-dev <igt-dev-bounces at lists.freedesktop.org> On Behalf Of Kunal
> Joshi
> Sent: Monday, August 26, 2024 1:36 AM
> To: igt-dev at lists.freedesktop.org
> Cc: Joshi, Kunal1 <kunal1.joshi at intel.com>
> Subject: [PATCH i-g-t 02/14] lib/igt_kms: add helper to get current link rate/
> lane count for connector
> 
> i915_dp_force_(lane_count/link_rate) debugfs files expoose current link
Fix typo /expoose /Expose  
> rate/lane count for connector.add helper to get current link rate/ lane count
> for connector
> 
> Signed-off-by: Kunal Joshi <kunal1.joshi at intel.com>
> ---
>  lib/igt_kms.c | 58
> +++++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/igt_kms.h |  2 ++
>  2 files changed, 60 insertions(+)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c index dd530dbab..4ef7f4d7f
> 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -6705,3 +6705,61 @@ int get_num_scalers(igt_display_t *display,
> enum pipe pipe)
> 
>  	return num_scalers;
>  }
> +
> +/**
> + * igt_get_dp_link_rate_set_for_output:
> + * @drm_fd: A drm file descriptor
> + * @output: Target output
> + *
> + * Returns: Link rate set for the output.
> + */
> +enum dp_link_rate igt_get_dp_link_rate_set_for_output(int drm_fd,
> +igt_output_t *output) {
> +	char buf[512];
> +	int dir, res;
> +	int link_rate;
> +
> +	igt_require_f(output->name, "Invalid output");
> +	dir = igt_debugfs_connector_dir(drm_fd, output->name,
> O_RDONLY);
> +	igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector
> %s\n",
> +				 igt_output_name(output));
> +	res = igt_debugfs_simple_read(dir, "i915_dp_force_link_rate", buf,
> sizeof(buf));
> +	close(dir);
> +	igt_require(res > 0);
> +
> +	if (strstr(buf, "[auto]"))
> +		igt_assert(sscanf(strstr(buf, "*") - 6, "%d", &link_rate) == 1);
> +	else
> +		igt_assert(sscanf(strstr(buf, "[") + 1, "%d", &link_rate) == 1);
> +
> +	return link_rate;
> +}
> +
> +/**
> + * igt_get_dp_lane_count_set_for_output:
> + * @drm_fd: A drm file descriptor
> + * @output: Target output
> + *
> + * Returns: Lane count set for the output.
> + */
> +enum dp_lane_count igt_get_dp_lane_count_set_for_output(int drm_fd,
> +igt_output_t *output) {
> +	char buf[512];
> +	int dir, res;
> +	int lane_count;
> +
> +	igt_require_f(output->name, "Invalid output");
> +	dir = igt_debugfs_connector_dir(drm_fd, output->name,
> O_RDONLY);
> +	igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector
> %s\n",
> +				 igt_output_name(output));
> +	res = igt_debugfs_simple_read(dir, "i915_dp_force_lane_count", buf,
> sizeof(buf));
> +	close(dir);
> +	igt_require(res > 0);
> +
> +	if (strstr(buf, "[auto]"))
> +		igt_assert(sscanf(strstr(buf, "*") - 2, "%d", &lane_count) ==
> 1);
> +	else
> +		igt_assert(sscanf(strstr(buf, "[") + 1, "%d", &lane_count) ==
> 1);
> +
> +	return lane_count;
> +}
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 999921f9f..9d42a2b35
> 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -1247,5 +1247,7 @@ bool
> intel_pipe_output_combo_valid(igt_display_t *display);  bool
> igt_check_output_is_dp_mst(igt_output_t *output);  int
> igt_get_dp_mst_connector_id(igt_output_t *output);  int
> get_num_scalers(igt_display_t *display, enum pipe pipe);
> +enum dp_link_rate igt_get_dp_link_rate_set_for_output(int drm_fd,
> +igt_output_t *output); enum dp_lane_count
> +igt_get_dp_lane_count_set_for_output(int drm_fd, igt_output_t *output);
> 
>  #endif /* __IGT_KMS_H__ */
> --
> 2.34.1



More information about the igt-dev mailing list