Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EFC17EA4FB7 for ; Mon, 23 Feb 2026 12:09:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1F2710E38E; Mon, 23 Feb 2026 12:09:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="eChLS9zg"; dkim-atps=neutral Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) by gabe.freedesktop.org (Postfix) with ESMTPS id 77F6410E35F for ; Mon, 23 Feb 2026 12:09:20 +0000 (UTC) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 642E74E41032; Mon, 23 Feb 2026 12:09:19 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 3AD525FD43; Mon, 23 Feb 2026 12:09:19 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EF6BA10368FA9; Mon, 23 Feb 2026 13:09:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1771848558; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=f5B2bdz5hVZgZIwljFY/YDABz4DWKzkE9MrOyP3xBbU=; b=eChLS9zgwOeDPUptsRrJ7t89izXJte9Fj/SIe9HUwv2SfokajxDPoftZfu/i0jTlH7PU7+ vQjdvczIh+Led0g9YdhmWk1lEoLwAC/+L+dnAjzEPTGj6KmEJfsdXUrlcZQcUys9Sgy0Sv mH6JycebEJYpD809H/S8vkPEVlpV/UWkoulUPtrnE4LeqebjBvfBUTtKfsY51Vo1nwJH8D 4ssCPwqggVcuisrNzfHI7FhMcB6vCTF251vkRK+HJU9nBeH/vgG2xHPmS5DwZhufdaM6G/ xzcPtzXWtVdCS7wzFXmtujngKxkupWGvtibuF3yKpQVbnqBjEJHvNxCmFoAWHA== From: Louis Chauvet Date: Mon, 23 Feb 2026 13:09:40 +0100 Subject: [PATCH i-g-t v7 33/48] lib/unigraf: add unigraf_get_connector_by_stream MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260223-unigraf-integration-v7-33-73dc9143c8c1@bootlin.com> References: <20260223-unigraf-integration-v7-0-73dc9143c8c1@bootlin.com> In-Reply-To: <20260223-unigraf-integration-v7-0-73dc9143c8c1@bootlin.com> To: igt-dev@lists.freedesktop.org Cc: thomas.petazzoni@bootlin.com, luca.ceresoli@bootlin.com, kory.maincent@bootlin.com, markyacoub@google.com, khaled.almahallawy@intel.com, Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2298; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=YJHIo2kwBjaTy0kWLg+wSW8j3HLjfxsowfzJuMxZG64=; b=owEBiQJ2/ZANAwAIASCtLsZbECziAcsmYgBpnENrYzZcBh9ypROMsRYHamYmLvbaUJhmobREl 7DHaul/Mh2JAk8EAAEIADkWIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCaZxDaxsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMSwyLDIACgkQIK0uxlsQLOIVTw/+OSdYIFCKyyf5ROf8QYaNAmyvrD9lrb0 HmBEP4bWYdS73gSjGY0Chs32S3/npknJKif2Fy4cnvDPn5Dk298zv23QfzCkvUVhm0xuir8Qffk zZd17GVeU/2LO33TKBi8Zm047F92GslOAmu4VfBY13c7hspg3dko+usQBfh7kl0v0V67CAvhgG0 6xYzNVwTW8m6BSvOUHhHCzfl9LyuBDvO4a7xfjC4cWGs2rN058GDq1x01Qq+opgO4588cgjnf9R U1MQOLcVfVG0FtoQ50I5qxdXqjV22a9pfXpL0ZNY+oLmGj6dHR+uGEtL47Ds3TOqdTzdk9x424+ wVyZ04Hix9R+1SJGQIdMVGO5KF2DXtjmQu2u+mf1QBStgznYC83VTJQHIpV0CUg4jCGmpwAZoaO p3t6g+fHKsjdhf6uBG3+R1xIMdC7wkERJVsyVji4nr1JMmjK/dtoRBNBySsid146ycH3tgcEuoE YwKYxZXKO/ODdW1Kz1cR+bp4VHLlgDHmrGHEA5l7wqum4lKND1L4zQB/8xYOv5ZH8zDpObZI/Bp l+2CY/AcAHZmMT+NmmOv/Mgrue6TTAIUrHU67SINpr7pVhmuVsIVQTOYB8wCdEyD116xzhkl796 gF7PZxl9waaGREaHKUxiWDA3HG0JuiLLYpg4UCnEyepO/9EnmACs= X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-Last-TLS-Session-Version: TLSv1.3 X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" As unigraf can emulate MST, we need a way to grab the corresponding DRM connector from the stream id. Signed-off-by: Louis Chauvet --- lib/unigraf/unigraf.c | 41 +++++++++++++++++++++++++++++++++++++++++ lib/unigraf/unigraf.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c index e9c9beb80c44..5d9edb8cd069 100644 --- a/lib/unigraf/unigraf.c +++ b/lib/unigraf/unigraf.c @@ -296,6 +296,47 @@ drmModeConnectorPtr unigraf_get_connector(int drm_fd) return igt_get_connector_from_name(drm_fd, unigraf_connector_name); } +/** + * unigraf_get_connector_id_by_stream() - Get a connector id from a stream id + * @drm_fd: DRM device where the unigraf is attached + * @stream_id: Stream id in the MST streams + */ +int unigraf_get_connector_id_by_stream(int drm_fd, int stream_id) +{ + drmModeConnectorPtr main_connector = unigraf_get_connector(drm_fd); + drmModeResPtr res = drmModeGetResources(drm_fd); + + char *mst_path; + int mst_path_len = asprintf(&mst_path, "mst:%d-", main_connector->connector_id); + + igt_assert(mst_path_len >= 0); + + for (int i = 0; i < res->count_connectors; i++) { + drmModePropertyBlobPtr path_blob = kmstest_get_path_blob(drm_fd, + res->connectors[i]); + + if (!path_blob || path_blob->length < mst_path_len) + continue; + + if (!memcmp(path_blob->data, mst_path, mst_path_len)) { + if (!stream_id) { + drmModeFreePropertyBlob(path_blob); + drmModeFreeResources(res); + drmModeFreeConnector(main_connector); + return res->connectors[i]; + } + stream_id--; + } + + drmModeFreePropertyBlob(path_blob); + } + + drmModeFreeResources(res); + drmModeFreeConnector(main_connector); + + return 0; +} + /** * unigraf_open_device() - Search and open a device. * @drm_fd: File descriptor of the currently used drm device diff --git a/lib/unigraf/unigraf.h b/lib/unigraf/unigraf.h index f22f4c993622..0ed6d1eb2713 100644 --- a/lib/unigraf/unigraf.h +++ b/lib/unigraf/unigraf.h @@ -76,4 +76,6 @@ void unigraf_read_crc(int stream, igt_crc_t *out); bool unigraf_use_crc(void); +int unigraf_get_connector_id_by_stream(int drm_fd, int stream_id); + #endif // UNIGRAF_H -- 2.52.0