From nobody Wed Dec 17 09:27:47 2025 Received: from mail-m3298.qiye.163.com (mail-m3298.qiye.163.com [220.197.32.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F06272F83BB for ; Mon, 10 Nov 2025 09:04:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.32.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762765444; cv=none; b=Bi9o1JyKm4Rwup/wj6P72tCTHYALBRGW8mKEaqAxBooPnRBfDcYWd+KvYpCMng7caQB+XzcvFseU1wrCwTGFbrXAcXiIKsd1aBCFM3rlhtToEoT9Vge48TTumbrviQS6hpFytZPnorMOnKq1APosaYucRJxaW3lFmRv3ivDbzPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762765444; c=relaxed/simple; bh=O98FhgpPH9AmIUQ8MrpeFFgnfOqvIBLEm8/jN4cQmbg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jQtsdkFAdxSRyDomhfWNdLf0HZil+GIxji18d/dEj70aXOKSAg1pvp1rLkPOzCXtl8IRXfTNUhtfKzF3GTj7PbzNlV7DhviT2CvKMmyujRzYALiKgjMGPTygbPw5C1y2bCUDCAGGyu7duQ+nA/3WoOKb1IKNvyjxbvplQ/3bAKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com; spf=pass smtp.mailfrom=rock-chips.com; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b=NUWIWey8; arc=none smtp.client-ip=220.197.32.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b="NUWIWey8" Received: from zyb-HP-ProDesk-680-G2-MT.. (unknown [58.22.7.114]) by smtp.qiye.163.com (Hmail) with ESMTP id 29068b50b; Mon, 10 Nov 2025 16:58:43 +0800 (GMT+08:00) From: Damon Ding To: andrzej.hajda@intel.com, neil.armstrong@linaro.org, rfoss@kernel.org Cc: Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, dmitry.baryshkov@oss.qualcomm.com, dianders@chromium.org, m.szyprowski@samsung.com, andy.yan@rock-chips.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Damon Ding Subject: [PATCH v3 1/4] drm/bridge: analogix_dp: Apply DP helper API drm_dp_dpcd_read_link_status() Date: Mon, 10 Nov 2025 16:58:20 +0800 Message-Id: <20251110085823.1197472-2-damon.ding@rock-chips.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251110085823.1197472-1-damon.ding@rock-chips.com> References: <20251110085823.1197472-1-damon.ding@rock-chips.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9a6cfd2f3e03a3kunm91e8d29910ac565 X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZGkhMGFZCS0JJS04fTU5CQ05WFRQJFh oXVRMBExYaEhckFA4PWVdZGBILWUFZTkNVSUlVTFVKSk9ZV1kWGg8SFR0UWUFZT0tIVUpLSU9PT0 hVSktLVUpCS0tZBg++ DKIM-Signature: a=rsa-sha256; b=NUWIWey8vWlRCm2+/SQQjN/ucK09iFzZZuILU2h+TBiT4BBAfo68c2CMBpW0Pd3BIxl4Ewy4HhPh4F71PPN+AmqSoYa9/yr2AyCxw8FZjmQzBa4XPAAZAJFXPJY849+PKkiAzD8EOkLnUzTMICMj95dKW1xe6k9bsk/mYPvofbM=; c=relaxed/relaxed; s=default; d=rock-chips.com; v=1; bh=og7lZ+NbbOS0YUmwxs59NRtyf8yZrXQ1o4bVbOZgqkU=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" Use existing DP helper API to read link status related DPCDs. Signed-off-by: Damon Ding Tested-by: Marek Szyprowski Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/g= pu/drm/bridge/analogix/analogix_dp_core.c index efe534977d12..7bd91f186ff7 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -388,13 +388,13 @@ static int analogix_dp_process_clock_recovery(struct = analogix_dp_device *dp) { int lane, lane_count, retval; u8 voltage_swing, pre_emphasis, training_lane; - u8 link_status[2], adjust_request[2]; + u8 link_status[DP_LINK_STATUS_SIZE], adjust_request[2]; =20 usleep_range(100, 101); =20 lane_count =3D dp->link_train.lane_count; =20 - retval =3D drm_dp_dpcd_read(&dp->aux, DP_LANE0_1_STATUS, link_status, 2); + retval =3D drm_dp_dpcd_read_link_status(&dp->aux, link_status); if (retval < 0) return retval; =20 @@ -454,13 +454,13 @@ static int analogix_dp_process_equalizer_training(str= uct analogix_dp_device *dp) { int lane_count, retval; u32 reg; - u8 link_align, link_status[2], adjust_request[2]; + u8 link_align, link_status[DP_LINK_STATUS_SIZE], adjust_request[2]; =20 usleep_range(400, 401); =20 lane_count =3D dp->link_train.lane_count; =20 - retval =3D drm_dp_dpcd_read(&dp->aux, DP_LANE0_1_STATUS, link_status, 2); + retval =3D drm_dp_dpcd_read_link_status(&dp->aux, link_status); if (retval < 0) return retval; =20 @@ -619,7 +619,7 @@ static int analogix_dp_full_link_train(struct analogix_= dp_device *dp, static int analogix_dp_fast_link_train(struct analogix_dp_device *dp) { int ret; - u8 link_align, link_status[2]; + u8 link_align, link_status[DP_LINK_STATUS_SIZE]; =20 analogix_dp_set_link_bandwidth(dp, dp->link_train.link_rate); ret =3D analogix_dp_wait_pll_locked(dp); @@ -661,8 +661,7 @@ static int analogix_dp_fast_link_train(struct analogix_= dp_device *dp) return ret; } =20 - ret =3D drm_dp_dpcd_read(&dp->aux, DP_LANE0_1_STATUS, link_status, - 2); + ret =3D drm_dp_dpcd_read_link_status(&dp->aux, link_status); if (ret < 0) { DRM_DEV_ERROR(dp->dev, "Read link status failed %d\n", ret); --=20 2.34.1 From nobody Wed Dec 17 09:27:47 2025 Received: from mail-m1973191.qiye.163.com (mail-m1973191.qiye.163.com [220.197.31.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 581C92F531F for ; Mon, 10 Nov 2025 09:04:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762765445; cv=none; b=TXsgkfZLk2BkcpHjrXFJQ+rYECUNvXRAIpIrIdX1RnY6BahEdxler/GKsHfyZB6S1zYkm6Y3tIyaMfLgMjt7JlTIrA1UVOtgDXSE6YTUa6Vqm0sbUhLmQ9wKE9dGpNO1GNbnd0xvA0qgy7iaqp7JJ1nYNkw5k8z9IbXORudXc+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762765445; c=relaxed/simple; bh=yvC+CCFGt3Y5FviGJEXi9s2h/Xa/HmtxK69tea4rtAg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rNgohlm/eIxgQzchGtegwn61toIr52LXkJMC7tECmwIcbz0ygTHjE04rIkX3/EG1ELeFkcQZf3l8saJB7Lpa0gHSbK3ZZDsLJFU9N3y2uBGOfsegxK6ltgcNxnEckIJnCFxMWczUOBghqQNBBUFQquV8vsgBg8NT9V7XVPIF0s8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com; spf=pass smtp.mailfrom=rock-chips.com; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b=isisVvWW; arc=none smtp.client-ip=220.197.31.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b="isisVvWW" Received: from zyb-HP-ProDesk-680-G2-MT.. (unknown [58.22.7.114]) by smtp.qiye.163.com (Hmail) with ESMTP id 29068b519; Mon, 10 Nov 2025 16:58:45 +0800 (GMT+08:00) From: Damon Ding To: andrzej.hajda@intel.com, neil.armstrong@linaro.org, rfoss@kernel.org Cc: Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, dmitry.baryshkov@oss.qualcomm.com, dianders@chromium.org, m.szyprowski@samsung.com, andy.yan@rock-chips.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Damon Ding Subject: [PATCH v3 2/4] drm/bridge: analogix_dp: Apply DP helper API drm_dp_clock_recovery_ok() Date: Mon, 10 Nov 2025 16:58:21 +0800 Message-Id: <20251110085823.1197472-3-damon.ding@rock-chips.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251110085823.1197472-1-damon.ding@rock-chips.com> References: <20251110085823.1197472-1-damon.ding@rock-chips.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9a6cfd38cd03a3kunm91e8d29910ac5a4 X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZQx8dQlZDTx0aShkaSUgeQ05WFRQJFh oXVRMBExYaEhckFA4PWVdZGBILWUFZTkNVSUlVTFVKSk9ZV1kWGg8SFR0UWUFZT0tIVUpLSU9PT0 hVSktLVUpCS0tZBg++ DKIM-Signature: a=rsa-sha256; b=isisVvWW6T9/iEDC2gXGFaFeJK7H2lY8LqNlkzY9ZqHUMxzmokU0h7An+20xhBdN+6EAjERSiNvWcz1WfCDlljQgfEeIAxx+kTX77VVjL+HeAmDL4EQsuxq3kjH5k/HU9vnMcZxHAc84jtC8T2vgvUHqKQ0uYd2gziFnKSLUCLw=; c=relaxed/relaxed; s=default; d=rock-chips.com; v=1; bh=sARP1g8D/HlADCNL1dJQ0QMblSBZD96CIe/D0u1aQxs=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" Use existing DP helper API instead of analogix_dp_clock_recovery_ok() with the same function. Signed-off-by: Damon Ding Tested-by: Marek Szyprowski Reviewed-by: Dmitry Baryshkov --- .../drm/bridge/analogix/analogix_dp_core.c | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/g= pu/drm/bridge/analogix/analogix_dp_core.c index 7bd91f186ff7..d3ab1f416600 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -301,19 +301,6 @@ static unsigned char analogix_dp_get_lane_status(u8 li= nk_status[2], int lane) return (link_value >> shift) & 0xf; } =20 -static int analogix_dp_clock_recovery_ok(u8 link_status[2], int lane_count) -{ - int lane; - u8 lane_status; - - for (lane =3D 0; lane < lane_count; lane++) { - lane_status =3D analogix_dp_get_lane_status(link_status, lane); - if ((lane_status & DP_LANE_CR_DONE) =3D=3D 0) - return -EINVAL; - } - return 0; -} - static int analogix_dp_channel_eq_ok(u8 link_status[2], u8 link_align, int lane_count) { @@ -398,7 +385,7 @@ static int analogix_dp_process_clock_recovery(struct an= alogix_dp_device *dp) if (retval < 0) return retval; =20 - if (analogix_dp_clock_recovery_ok(link_status, lane_count) =3D=3D 0) { + if (drm_dp_clock_recovery_ok(link_status, lane_count)) { /* set training pattern 2 for EQ */ analogix_dp_set_training_pattern(dp, TRAINING_PTN2); =20 @@ -464,7 +451,7 @@ static int analogix_dp_process_equalizer_training(struc= t analogix_dp_device *dp) if (retval < 0) return retval; =20 - if (analogix_dp_clock_recovery_ok(link_status, lane_count)) { + if (!drm_dp_clock_recovery_ok(link_status, lane_count)) { analogix_dp_reduce_link_rate(dp); return -EIO; } @@ -668,8 +655,7 @@ static int analogix_dp_fast_link_train(struct analogix_= dp_device *dp) return ret; } =20 - if (analogix_dp_clock_recovery_ok(link_status, - dp->link_train.lane_count)) { + if (!drm_dp_clock_recovery_ok(link_status, dp->link_train.lane_count)) { DRM_DEV_ERROR(dp->dev, "Clock recovery failed\n"); analogix_dp_reduce_link_rate(dp); return -EIO; --=20 2.34.1 From nobody Wed Dec 17 09:27:47 2025 Received: from mail-m1973170.qiye.163.com (mail-m1973170.qiye.163.com [220.197.31.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64CB5823DD for ; Mon, 10 Nov 2025 08:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.70 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762765141; cv=none; b=nFdfav4nF4PHp5W+LkMVQqBku8NBJQJ4Ffc6Qa0zuHTn7RSPxN8jVvWfJ1a7TiQlmp7bvzEWYYC8bM2rCXv8FYls88jb79Hwfp5oFWMZJjCYlmNUJJKMFs1LWj/r6gstuXPD+VStYE8YIYh13fAMwVQtRT8v23vudtBJgvgWGXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762765141; c=relaxed/simple; bh=CauuCtrNaszlp7OxPzvo67mloy+uPuF28pY7oK0OQ8g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dItvZteJZ8MLe+yyoilSby6tIjzD/B7GqyQ49j57i43omaZlHWNmw+5/Xe/h1LlCDFsPHChoIGFcFllJZR6lZ4PTc8etmXiVrn80IdFzI4vMTgibm5ufGk/lr9vg0KjFU5tJLESMBIZib3jvmYlMOZShyJGff3rbgo6ydgetTTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com; spf=pass smtp.mailfrom=rock-chips.com; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b=HQA2C4dJ; arc=none smtp.client-ip=220.197.31.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b="HQA2C4dJ" Received: from zyb-HP-ProDesk-680-G2-MT.. (unknown [58.22.7.114]) by smtp.qiye.163.com (Hmail) with ESMTP id 29068b52a; Mon, 10 Nov 2025 16:58:48 +0800 (GMT+08:00) From: Damon Ding To: andrzej.hajda@intel.com, neil.armstrong@linaro.org, rfoss@kernel.org Cc: Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, dmitry.baryshkov@oss.qualcomm.com, dianders@chromium.org, m.szyprowski@samsung.com, andy.yan@rock-chips.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Damon Ding Subject: [PATCH v3 3/4] drm/bridge: analogix_dp: Apply DP helper API drm_dp_channel_eq_ok() Date: Mon, 10 Nov 2025 16:58:22 +0800 Message-Id: <20251110085823.1197472-4-damon.ding@rock-chips.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251110085823.1197472-1-damon.ding@rock-chips.com> References: <20251110085823.1197472-1-damon.ding@rock-chips.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9a6cfd428203a3kunm91e8d29910ac5fa X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZGUxJSlZIT0MdH0xOSkoYTBlWFRQJFh oXVRMBExYaEhckFA4PWVdZGBILWUFZTkNVSUlVTFVKSk9ZV1kWGg8SFR0UWUFZT0tIVUpLSEpKQk 1VSktLVUpCWQY+ DKIM-Signature: a=rsa-sha256; b=HQA2C4dJYtRg38FpaqNubCZ013kLk+yIT2eNE9L/yXnFHlW3Shaj9g6SJ5vrwHtYRqQC9XwejjALAhdpLzgSmBezL3gie8cMj3cnS0shQEDoyIsjvmoO+w0yG8IMEpr8zA3zXMGckGNoL78NAV7Gd8HffRYA7YlanSafaxyNlkI=; c=relaxed/relaxed; s=default; d=rock-chips.com; v=1; bh=jGmiTlCG+5VZwO6ZGasoSIwARtRizbq9A5KR+nzRaJ4=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" Use existing DP helper API instead of analogix_dp_channel_eq_ok() with the same function. In addtion, remove unused function analogix_dp_get_lane_status() Signed-off-by: Damon Ding Tested-by: Marek Szyprowski Reviewed-by: Dmitry Baryshkov --- .../drm/bridge/analogix/analogix_dp_core.c | 49 ++----------------- 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/g= pu/drm/bridge/analogix/analogix_dp_core.c index d3ab1f416600..227ef30b8a9e 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -293,33 +293,6 @@ static int analogix_dp_link_start(struct analogix_dp_d= evice *dp) return 0; } =20 -static unsigned char analogix_dp_get_lane_status(u8 link_status[2], int la= ne) -{ - int shift =3D (lane & 1) * 4; - u8 link_value =3D link_status[lane >> 1]; - - return (link_value >> shift) & 0xf; -} - -static int analogix_dp_channel_eq_ok(u8 link_status[2], u8 link_align, - int lane_count) -{ - int lane; - u8 lane_status; - - if ((link_align & DP_INTERLANE_ALIGN_DONE) =3D=3D 0) - return -EINVAL; - - for (lane =3D 0; lane < lane_count; lane++) { - lane_status =3D analogix_dp_get_lane_status(link_status, lane); - lane_status &=3D DP_CHANNEL_EQ_BITS; - if (lane_status !=3D DP_CHANNEL_EQ_BITS) - return -EINVAL; - } - - return 0; -} - static unsigned char analogix_dp_get_adjust_request_voltage(u8 adjust_request[2], int lane) { @@ -441,7 +414,7 @@ static int analogix_dp_process_equalizer_training(struc= t analogix_dp_device *dp) { int lane_count, retval; u32 reg; - u8 link_align, link_status[DP_LINK_STATUS_SIZE], adjust_request[2]; + u8 link_status[DP_LINK_STATUS_SIZE], adjust_request[2]; =20 usleep_range(400, 401); =20 @@ -461,14 +434,9 @@ static int analogix_dp_process_equalizer_training(stru= ct analogix_dp_device *dp) if (retval < 0) return retval; =20 - retval =3D drm_dp_dpcd_readb(&dp->aux, DP_LANE_ALIGN_STATUS_UPDATED, - &link_align); - if (retval < 0) - return retval; - analogix_dp_get_adjust_training_lane(dp, adjust_request); =20 - if (!analogix_dp_channel_eq_ok(link_status, link_align, lane_count)) { + if (drm_dp_channel_eq_ok(link_status, lane_count)) { /* traing pattern Set to Normal */ retval =3D analogix_dp_training_pattern_dis(dp); if (retval < 0) @@ -606,7 +574,7 @@ static int analogix_dp_full_link_train(struct analogix_= dp_device *dp, static int analogix_dp_fast_link_train(struct analogix_dp_device *dp) { int ret; - u8 link_align, link_status[DP_LINK_STATUS_SIZE]; + u8 link_status[DP_LINK_STATUS_SIZE]; =20 analogix_dp_set_link_bandwidth(dp, dp->link_train.link_rate); ret =3D analogix_dp_wait_pll_locked(dp); @@ -640,14 +608,6 @@ static int analogix_dp_fast_link_train(struct analogix= _dp_device *dp) * speed */ if (verify_fast_training) { - ret =3D drm_dp_dpcd_readb(&dp->aux, DP_LANE_ALIGN_STATUS_UPDATED, - &link_align); - if (ret < 0) { - DRM_DEV_ERROR(dp->dev, "Read align status failed %d\n", - ret); - return ret; - } - ret =3D drm_dp_dpcd_read_link_status(&dp->aux, link_status); if (ret < 0) { DRM_DEV_ERROR(dp->dev, "Read link status failed %d\n", @@ -661,8 +621,7 @@ static int analogix_dp_fast_link_train(struct analogix_= dp_device *dp) return -EIO; } =20 - if (analogix_dp_channel_eq_ok(link_status, link_align, - dp->link_train.lane_count)) { + if (!drm_dp_channel_eq_ok(link_status, dp->link_train.lane_count)) { DRM_DEV_ERROR(dp->dev, "Channel EQ failed\n"); analogix_dp_reduce_link_rate(dp); return -EIO; --=20 2.34.1 From nobody Wed Dec 17 09:27:47 2025 Received: from mail-m19731116.qiye.163.com (mail-m19731116.qiye.163.com [220.197.31.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 364D82FE07F for ; Mon, 10 Nov 2025 09:04:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762765450; cv=none; b=jMlvUu24KoKqv4/PH+kJWCRkqqWGEY0tBgqiWEyY/1RqzwvFX+IfF4ArQtoMuOwbEtDb+EFk1K+eJOlFpCYCGc5F2lzzazOEaPm0awzyLmkH8RfGeOKZVHPHI/YD7iaMjyrfLqB89yNPa8KvAiI8jpkVTxdUsKLaEpWbhfeCvso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762765450; c=relaxed/simple; bh=R1tqKA81avXdzlAK6WFcK+NANppncOlrQYe6DN5gepY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IM3KL7XKRSgCd8CCeoObsqa+u1xbY9iVuAR3U7a7msq7+5IJCG2Jy9dPWW6EOg7pRfvKeaO9hQYE6K5AvEjSbu/U8qcsvBgQ4/1ualepl/qLw4Ju2rGfrGEtTgxdr+bI6zSEqR8DjcSAFQACJ6S6Zb/lQSIsE1sneKgYaCHYV/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com; spf=pass smtp.mailfrom=rock-chips.com; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b=O3rVIxIe; arc=none smtp.client-ip=220.197.31.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b="O3rVIxIe" Received: from zyb-HP-ProDesk-680-G2-MT.. (unknown [58.22.7.114]) by smtp.qiye.163.com (Hmail) with ESMTP id 29068b539; Mon, 10 Nov 2025 16:58:50 +0800 (GMT+08:00) From: Damon Ding To: andrzej.hajda@intel.com, neil.armstrong@linaro.org, rfoss@kernel.org Cc: Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, dmitry.baryshkov@oss.qualcomm.com, dianders@chromium.org, m.szyprowski@samsung.com, andy.yan@rock-chips.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Damon Ding Subject: [PATCH v3 4/4] drm/bridge: analogix_dp: Apply DP helper APIs to get adjusted voltages and pre-emphasises Date: Mon, 10 Nov 2025 16:58:23 +0800 Message-Id: <20251110085823.1197472-5-damon.ding@rock-chips.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251110085823.1197472-1-damon.ding@rock-chips.com> References: <20251110085823.1197472-1-damon.ding@rock-chips.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9a6cfd4baf03a3kunm91e8d29910ac63a X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZQhgfSFZNHkpPHx0fGkhLSENWFRQJFh oXVRMBExYaEhckFA4PWVdZGBILWUFZTkNVSUlVTFVKSk9ZV1kWGg8SFR0UWUFZT0tIVUpLSU9PT0 hVSktLVUpCS0tZBg++ DKIM-Signature: a=rsa-sha256; b=O3rVIxIeKj031LO6gC8cXthXGkyG4plX49kBzyYvzXi0wSxDYYzhUhxz7fm1nH6y5ySln8sCkNVijuHvfSYhUxL7WlUdiinr21ebE3cRqy2MpRSWbjfFvyhHdYMEa9Ye1MhmeaKT17LBK0GWTy2WrHi+dDBv1jRubn7w4gAKYQw=; c=relaxed/relaxed; s=default; d=rock-chips.com; v=1; bh=3gW86vskonft7Jl2Q50EbOmDui7TylloSuDk8Dc/iLU=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" Replace analogix_dp_get_adjust_request_voltage() and analogix_dp_get_adjust_request_pre_emphasis() with existing DP helper APIs with the same function. Signed-off-by: Damon Ding Tested-by: Marek Szyprowski Reviewed-by: Dmitry Baryshkov --- .../drm/bridge/analogix/analogix_dp_core.c | 49 ++++--------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/g= pu/drm/bridge/analogix/analogix_dp_core.c index 227ef30b8a9e..6ec3d811b5f0 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -293,25 +293,6 @@ static int analogix_dp_link_start(struct analogix_dp_d= evice *dp) return 0; } =20 -static unsigned char -analogix_dp_get_adjust_request_voltage(u8 adjust_request[2], int lane) -{ - int shift =3D (lane & 1) * 4; - u8 link_value =3D adjust_request[lane >> 1]; - - return (link_value >> shift) & 0x3; -} - -static unsigned char analogix_dp_get_adjust_request_pre_emphasis( - u8 adjust_request[2], - int lane) -{ - int shift =3D (lane & 1) * 4; - u8 link_value =3D adjust_request[lane >> 1]; - - return ((link_value >> shift) & 0xc) >> 2; -} - static void analogix_dp_reduce_link_rate(struct analogix_dp_device *dp) { analogix_dp_training_pattern_dis(dp); @@ -321,17 +302,15 @@ static void analogix_dp_reduce_link_rate(struct analo= gix_dp_device *dp) } =20 static void analogix_dp_get_adjust_training_lane(struct analogix_dp_device= *dp, - u8 adjust_request[2]) + u8 link_status[DP_LINK_STATUS_SIZE]) { int lane, lane_count; u8 voltage_swing, pre_emphasis, training_lane; =20 lane_count =3D dp->link_train.lane_count; for (lane =3D 0; lane < lane_count; lane++) { - voltage_swing =3D analogix_dp_get_adjust_request_voltage( - adjust_request, lane); - pre_emphasis =3D analogix_dp_get_adjust_request_pre_emphasis( - adjust_request, lane); + voltage_swing =3D drm_dp_get_adjust_request_voltage(link_status, lane); + pre_emphasis =3D drm_dp_get_adjust_request_pre_emphasis(link_status, lan= e); training_lane =3D DPCD_VOLTAGE_SWING_SET(voltage_swing) | DPCD_PRE_EMPHASIS_SET(pre_emphasis); =20 @@ -348,7 +327,7 @@ static int analogix_dp_process_clock_recovery(struct an= alogix_dp_device *dp) { int lane, lane_count, retval; u8 voltage_swing, pre_emphasis, training_lane; - u8 link_status[DP_LINK_STATUS_SIZE], adjust_request[2]; + u8 link_status[DP_LINK_STATUS_SIZE]; =20 usleep_range(100, 101); =20 @@ -374,15 +353,10 @@ static int analogix_dp_process_clock_recovery(struct = analogix_dp_device *dp) return 0; } =20 - retval =3D drm_dp_dpcd_read(&dp->aux, DP_ADJUST_REQUEST_LANE0_1, - adjust_request, 2); - if (retval < 0) - return retval; - for (lane =3D 0; lane < lane_count; lane++) { training_lane =3D analogix_dp_get_lane_link_training(dp, lane); - voltage_swing =3D analogix_dp_get_adjust_request_voltage(adjust_request,= lane); - pre_emphasis =3D analogix_dp_get_adjust_request_pre_emphasis(adjust_requ= est, lane); + voltage_swing =3D drm_dp_get_adjust_request_voltage(link_status, lane); + pre_emphasis =3D drm_dp_get_adjust_request_pre_emphasis(link_status, lan= e); =20 if (DPCD_VOLTAGE_SWING_GET(training_lane) =3D=3D voltage_swing && DPCD_PRE_EMPHASIS_GET(training_lane) =3D=3D pre_emphasis) @@ -399,7 +373,7 @@ static int analogix_dp_process_clock_recovery(struct an= alogix_dp_device *dp) } } =20 - analogix_dp_get_adjust_training_lane(dp, adjust_request); + analogix_dp_get_adjust_training_lane(dp, link_status); analogix_dp_set_lane_link_training(dp); =20 retval =3D drm_dp_dpcd_write(&dp->aux, DP_TRAINING_LANE0_SET, @@ -414,7 +388,7 @@ static int analogix_dp_process_equalizer_training(struc= t analogix_dp_device *dp) { int lane_count, retval; u32 reg; - u8 link_status[DP_LINK_STATUS_SIZE], adjust_request[2]; + u8 link_status[DP_LINK_STATUS_SIZE]; =20 usleep_range(400, 401); =20 @@ -429,12 +403,7 @@ static int analogix_dp_process_equalizer_training(stru= ct analogix_dp_device *dp) return -EIO; } =20 - retval =3D drm_dp_dpcd_read(&dp->aux, DP_ADJUST_REQUEST_LANE0_1, - adjust_request, 2); - if (retval < 0) - return retval; - - analogix_dp_get_adjust_training_lane(dp, adjust_request); + analogix_dp_get_adjust_training_lane(dp, link_status); =20 if (drm_dp_channel_eq_ok(link_status, lane_count)) { /* traing pattern Set to Normal */ --=20 2.34.1