Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kunal Joshi <kunal1.joshi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Subject: [PATCH i-g-t 3/5] lib/igt_kms: add function to set link params
Date: Mon,  3 Feb 2025 13:42:39 +0530	[thread overview]
Message-ID: <20250203081241.659139-4-kunal1.joshi@intel.com> (raw)
In-Reply-To: <20250203081241.659139-1-kunal1.joshi@intel.com>

add function to force link rate and lane count
for given output, install exit handle to set auto
at exit

Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com>
---
 lib/igt_kms.c | 33 +++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  2 ++
 2 files changed, 35 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 90f44b4d3..424056252 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -7190,6 +7190,39 @@ void igt_reset_link_params(int drm_fd, igt_output_t *output)
 	drmModeFreeConnector(temp);
 }
 
+/**
+ * igt_set_link_params:
+ * @drm_fd: A drm file descriptor
+ * @output: Target output
+ *
+ * set link rate and lane count to given value, also installs exit handler
+ * to set link rate and lane count to auto on exit
+ */
+void igt_set_link_params(int drm_fd, igt_output_t *output,
+			   char *link_rate, char *lane_count)
+{
+	bool valid;
+	drmModeConnector *temp;
+
+	valid = true;
+	valid = valid && connector_attr_set_debugfs(drm_fd, output->config.connector,
+						    "i915_dp_force_link_rate",
+						    link_rate, "auto", true);
+	valid = valid && connector_attr_set_debugfs(drm_fd, output->config.connector,
+						    "i915_dp_force_lane_count",
+						    lane_count, "auto", true);
+	igt_assert_f(valid, "Unable to set attr or install exit handler\n");
+	dump_connector_attrs();
+	igt_install_exit_handler(reset_connectors_at_exit);
+
+	/*
+	 * To allow callers to always use GetConnectorCurrent we need to force a
+	 * redetection here.
+	 */
+	temp = drmModeGetConnector(drm_fd, output->config.connector->connector_id);
+	drmModeFreeConnector(temp);
+}
+
 /**
  * igt_backlight_read:
  * @result:	Pointer to store the result
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 8810123fb..f696847a4 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -1268,6 +1268,8 @@ bool igt_has_force_link_training_failure_debugfs(int drmfd, igt_output_t *output
 int igt_get_dp_pending_lt_failures(int drm_fd, igt_output_t *output);
 int igt_get_dp_pending_retrain(int drm_fd, igt_output_t *output);
 void igt_reset_link_params(int drm_fd, igt_output_t *output);
+void igt_set_link_params(int drm_fd, igt_output_t *output,
+			   char *link_rate, char *lane_count);
 int igt_backlight_read(int *result, const char *fname, igt_backlight_context_t *context);
 int igt_backlight_write(int value, const char *fname, igt_backlight_context_t *context);
 
-- 
2.25.1


  parent reply	other threads:[~2025-02-03  7:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-03  8:12 [PATCH i-g-t 0/5] add test to validate uhbr/non-uhbr over sst/mst Kunal Joshi
2025-02-03  8:12 ` [PATCH i-g-t 1/5] tests/intel/kms_joiner_helper: add helper for joiner-related functions Kunal Joshi
2025-02-03  8:12 ` [PATCH i-g-t 2/5] tests/intel/kms_mst_helper: add helper for MST-related functions Kunal Joshi
2025-02-10  7:16   ` Nautiyal, Ankit K
2025-02-03  8:12 ` Kunal Joshi [this message]
2025-02-11  9:53   ` [i-g-t,3/5] lib/igt_kms: add function to set link params Murthy, Arun R
2025-02-03  8:12 ` [PATCH i-g-t 4/5] tests/intel/kms_dp_linktraining: add tests for UHBR/NON-UHBR over SST/MST Kunal Joshi
2025-02-04 14:01   ` Sharma, Swati2
2025-02-11 12:39   ` [i-g-t,4/5] " Murthy, Arun R
2025-02-03  8:12 ` [PATCH i-g-t 5/5] HAX: DO NOT MERGE Kunal Joshi
2025-02-04  0:33 ` ✗ i915.CI.BAT: failure for add test to validate uhbr/non-uhbr over sst/mst (rev3) Patchwork
2025-02-04  1:12 ` ✗ Xe.CI.BAT: " Patchwork
2025-02-04  3:07 ` ✗ Xe.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250203081241.659139-4-kunal1.joshi@intel.com \
    --to=kunal1.joshi@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox