From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id A2D9310E4F4 for ; Thu, 10 Aug 2023 08:17:58 +0000 (UTC) From: Swati Sharma To: igt-dev@lists.freedesktop.org Date: Thu, 10 Aug 2023 13:47:41 +0530 Message-Id: <20230810081743.1065566-3-swati2.sharma@intel.com> In-Reply-To: <20230810081743.1065566-1-swati2.sharma@intel.com> References: <20230810081743.1065566-1-swati2.sharma@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [v2 2/4] lib/igt_kms: add helper for dp-mst connector id List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: Helper is added which returns dp-mst connector id. v2: -use connector_path instead of blob (Bhanu) -rewrite helper (Bhanu/Ankit) Signed-off-by: Swati Sharma --- lib/igt_kms.c | 34 ++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 1 + 2 files changed, 35 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index b3a9375ee..e6c26bf0b 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -6060,3 +6060,37 @@ bool igt_check_output_is_dp_mst(int drm_fd, igt_output_t *output) return true; } + +static int parse_path_connector(char *connector_path) +{ + int connector_id; + char *encoder; + + encoder = strtok(connector_path, ":"); + igt_assert_f(!strcmp(encoder, "mst"), "PATH connector property expected to have 'mst'\n"); + + connector_id = atoi(strtok(NULL, "-")); + + return connector_id; +} + +/** + * igt_get_dp_mst_connector_id + * @drmfd: Handle to open drm device + * @output: Target output + * + * Returns: connector id if output is dp-mst, else -EINVAL. + */ +int igt_get_dp_mst_connector_id(int drm_fd, igt_output_t *output) +{ + int connector_id; + char *connector_path; + + if (!igt_check_output_is_dp_mst(drm_fd, output)) + return -EINVAL; + + connector_path = output->config.connector_path; + connector_id = parse_path_connector(connector_path); + + return connector_id; +} diff --git a/lib/igt_kms.h b/lib/igt_kms.h index d8d6ccfe5..d83186613 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -1014,5 +1014,6 @@ bool igt_check_bigjoiner_support(igt_display_t *display); bool igt_parse_mode_string(const char *mode_string, drmModeModeInfo *mode); bool i915_pipe_output_combo_valid(igt_display_t *display); bool igt_check_output_is_dp_mst(int drmfd, igt_output_t *output); +int igt_get_dp_mst_connector_id(int drmfd, igt_output_t *output); #endif /* __IGT_KMS_H__ */ -- 2.25.1