From nobody Fri Oct 3 21:56:40 2025 Received: from mail-m32100.qiye.163.com (mail-m32100.qiye.163.com [220.197.32.100]) (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 7549F264A83 for ; Sun, 24 Aug 2025 09:21:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.32.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756027281; cv=none; b=eB83WrEv4Ye3rDq6ZRa2KF7hT5o7kWeCUQ+InuhtJBcHuRDc94PJEaV6AbSDHYD5nv5auzaOlt2C6D7eiSZXq/1Z9QrpvXqlw0My1LF8uOe8Q7P320WpUC9wuF1LJN8Pwe2LMmB1tem9qKPOo64n1Vv5U5B46ptZYoB2bXEmL24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756027281; c=relaxed/simple; bh=abm45pLhmD4Cw1u1AfO8hLgUyTKER6N+f10k8Z/v82E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yr4lyeVdgJlQtmwHnGJXXYVEOOjfOFJco/WlB8tHcjnP64kzOUmdRINCcuVugTpESLtHw7+AaZyio7DSy7ZwA/i3+wQhVrvmC68FoiFxMzwaXk3ZLFOUkuN3ezjZgEKVrSvzOGYso0OBKiaY74JEClAr3vpsb9nVu3tkXFl9deg= 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=K1n5JrAp; arc=none smtp.client-ip=220.197.32.100 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="K1n5JrAp" Received: from zyb-HP-ProDesk-680-G2-MT.. (unknown [58.22.7.114]) by smtp.qiye.163.com (Hmail) with ESMTP id 20643f35e; Sun, 24 Aug 2025 16:45: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 v1 1/4] drm/bridge: analogix_dp: Apply DP helper API drm_dp_dpcd_read_link_status() Date: Sun, 24 Aug 2025 16:45:26 +0800 Message-Id: <20250824084529.3317985-2-damon.ding@rock-chips.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250824084529.3317985-1-damon.ding@rock-chips.com> References: <20250824084529.3317985-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: 0a98db4141d603a3kunm71d2620e2ad685 X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZQhhISVZIQxlLGEsaSE5NS0NWFRQJFh oXVRMBExYaEhckFA4PWVdZGBILWUFZTkNVSUlVTFVKSk9ZV1kWGg8SFR0UWUFZT0tIVUpLSU9PT0 hVSktLVUpCS0tZBg++ DKIM-Signature: a=rsa-sha256; b=K1n5JrApL/05epZmMybeDKhmJCxEMLp8NBC30EVU8UMDmFq4k5yofuq07olJpJJzOWY5EleEKLYTnPz2l6cBAa4g5uSblUevRrGpnWUN768DJjXf/bJgwxYHfZ/nAtTQGMMGb5+byYJ0fKg988/pSKOGW46miurC0Uu8o72WsPQ=; c=relaxed/relaxed; s=default; d=rock-chips.com; v=1; bh=ee2Cm9agIGFWMrQ8tfeANTYqKDJm3XAtCYn236nugoU=; 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 --- 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 ed35e567d117..6a3f3fb0ec0a 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 Fri Oct 3 21:56:40 2025 Received: from mail-m15598.qiye.163.com (mail-m15598.qiye.163.com [101.71.155.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 CF5AF1FDE14 for ; Sun, 24 Aug 2025 09:01:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=101.71.155.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756026074; cv=none; b=sK48hYkbeFAHXmQUrsNWFzqJt+m25LZFnkdndwbuV6+5ZH4pvOQBzsPZQVvtYOVDb3Rivm+RYJdLx/jGlNoqOlsOCeUAZmTRFyoFw2QW3W9w0vFAql8Yrr9BR0xqjg/Vi0tH3M0/2uopnQ1ikJgKKZk47TwrHWx7R5GNK6x91jY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756026074; c=relaxed/simple; bh=bCJ+s9Hfyt/deCAZFlqnwvcg5Wh8bF0bpYDdqeEANRc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Sgr4JNvJ0rRqVGtQLYuWI0/qC23aRycRCcPUaIRViRVFTMm6mWYpSVw2qssjgBvYEAlV0DKNjAyxR4EtkiX0NdcN+DqWO7X75DS5qU6OJAzCtZg64BAPMN9ODIvzAKZ12aOQX9hOigOZsvbuMknMzMo9JaF+1q6haKGkqe9fj3M= 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=VeaQFn94; arc=none smtp.client-ip=101.71.155.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="VeaQFn94" Received: from zyb-HP-ProDesk-680-G2-MT.. (unknown [58.22.7.114]) by smtp.qiye.163.com (Hmail) with ESMTP id 20643f361; Sun, 24 Aug 2025 16:45: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 v1 2/4] drm/bridge: analogix_dp: Apply DP helper API drm_dp_clock_recovery_ok() Date: Sun, 24 Aug 2025 16:45:27 +0800 Message-Id: <20250824084529.3317985-3-damon.ding@rock-chips.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250824084529.3317985-1-damon.ding@rock-chips.com> References: <20250824084529.3317985-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: 0a98db41480603a3kunm71d2620e2ad69e X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZGUIaQ1YeTEsfQk8aGB0aGk5WFRQJFh oXVRMBExYaEhckFA4PWVdZGBILWUFZTkNVSUlVTFVKSk9ZV1kWGg8SFR0UWUFZT0tIVUpLSEpKQk 1VSktLVUpCWQY+ DKIM-Signature: a=rsa-sha256; b=VeaQFn94L+wyz4Rw5Y5kZepE9VGCGXUo/WWA6xLCSDGtYdqwZpU2XIjQ4sy7TTeejHbHjzzF08a2XgcQtDeqEBfb75jjfSvahXubBRWjyjx1lTmANWQLwafiH5FWPohNAgPxeIjva5nEwgy9GacnfDl2NdyqzeP2SNnoTaC1GGo=; c=relaxed/relaxed; s=default; d=rock-chips.com; v=1; bh=A9bgi49Xgv4Om5tHr8MtwDx3tD7Zaj9Nr4+eowxlYhU=; 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 --- .../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 6a3f3fb0ec0a..fde190eac34e 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 Fri Oct 3 21:56:40 2025 Received: from mail-m19731120.qiye.163.com (mail-m19731120.qiye.163.com [220.197.31.120]) (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 5483125BEE6 for ; Sun, 24 Aug 2025 08:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.120 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756025467; cv=none; b=j1F9jqQ7CXBdFV1Bp5+RzXS3ZaZXBm7pukXf1g0nKKxaSK66SsJJlCXjqo7NaXdIb0BBtmVuJil2ioaoWS3bKQgeuKrKKANTa1OqAsb4RjS1ca79cnp01UJze9iO8zrxV+Qs1tkb+4CFGyeNehIaqhwRGWY4sEB9IVoxPamVMS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756025467; c=relaxed/simple; bh=IEH/IGo/3teuaRRpsuAGorHH37GwxfFMFIa87GWZT5c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Dg0HMGoJ6oYWQm2KIo3k0mlJY7NJni1Sup7I+Hpl/HyWEDFp/IElVySgMW0SWo5NLbdfkXmdflNu6sl9g9VXN+GGHFuEzEWCmwmUpWt3mlxfWglAf9W5B9/HENmSfQO2YXbQSpCVwVejYki0Hrmo7AnFJV1nfnpRbvjpsbgZa6Q= 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=BwKenBrL; arc=none smtp.client-ip=220.197.31.120 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="BwKenBrL" Received: from zyb-HP-ProDesk-680-G2-MT.. (unknown [58.22.7.114]) by smtp.qiye.163.com (Hmail) with ESMTP id 20643f363; Sun, 24 Aug 2025 16:45:46 +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 v1 3/4] drm/bridge: analogix_dp: Apply DP helper API drm_dp_channel_eq_ok() Date: Sun, 24 Aug 2025 16:45:28 +0800 Message-Id: <20250824084529.3317985-4-damon.ding@rock-chips.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250824084529.3317985-1-damon.ding@rock-chips.com> References: <20250824084529.3317985-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: 0a98db414e4603a3kunm71d2620e2ad6a9 X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZQxhCGFZKSRgdSE4eSE5CTkhWFRQJFh oXVRMBExYaEhckFA4PWVdZGBILWUFZTkNVSUlVTFVKSk9ZV1kWGg8SFR0UWUFZT0tIVUpLSEpKQk 1VSktLVUpCWQY+ DKIM-Signature: a=rsa-sha256; b=BwKenBrLxWevdvV/ixXPRfPsB6EWXQbqMejb+wf1M7vg00HdI15vBDRc7/+vhNpcLbDxGI1wIQvEQqSheapUR3VaXvQxaI3MpXHlQOKZgxpg3OLwhYUWF11mMOYxSNcXdTDpo81RP7UrM9BxT1YWJuye3DtIUj9n28wS2v+1IMw=; c=relaxed/relaxed; s=default; d=rock-chips.com; v=1; bh=sVIZVnZf9b9QQ+QfeX3l4+4DYZYTcsTOBXDyFq0XOL0=; 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 --- .../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 fde190eac34e..1f1de45ca46f 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 Fri Oct 3 21:56:40 2025 Received: from mail-m1973190.qiye.163.com (mail-m1973190.qiye.163.com [220.197.31.90]) (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 387221A08AF for ; Sun, 24 Aug 2025 09:21:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756027283; cv=none; b=VdQZZ6ZBK1hxXkCMUHAwFYhrgwbsI/R1DuO6k6IzP1RHVpqobzqB3lXlXTL7kL8Gj3rrOBEAjJy6RvnJdPXpbiTaBKFQje05LBxpzSmNlA0H7mnuDgDsWwSE57O3zQzzG3zEroxScGl7xGbR8k/JQFRYMu8U1OaenMboBZpdDpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756027283; c=relaxed/simple; bh=mfVRrHmv4sGE3Cny/Fa2tpBElryJ3vH3BK2M7R2/qE0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Cuhkcex8M5kfgwjiP+xzlfgOoA4PtgevAlRxpiD+gM3szKntHVOOmCMXM7mOLHILTd8NnEyI6U/fI3RcZBy2G3jy5d2rMI+NPJ7qkLjX64YVqDR4QjU1szzbOKRQhXRL15Vk65AJEW5zYR5V6z8r1A0vepy96lW6lAlMVFrmnRw= 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=ZOEDpcnP; arc=none smtp.client-ip=220.197.31.90 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="ZOEDpcnP" Received: from zyb-HP-ProDesk-680-G2-MT.. (unknown [58.22.7.114]) by smtp.qiye.163.com (Hmail) with ESMTP id 20643f365; Sun, 24 Aug 2025 16:45: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 v1 4/4] drm/bridge: analogix_dp: Apply DP helper APIs to get adjusted voltages and pre-emphasises Date: Sun, 24 Aug 2025 16:45:29 +0800 Message-Id: <20250824084529.3317985-5-damon.ding@rock-chips.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250824084529.3317985-1-damon.ding@rock-chips.com> References: <20250824084529.3317985-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: 0a98db41548e03a3kunm71d2620e2ad6b6 X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZGhoZS1YfTE8eQxpDThgeH0tWFRQJFh oXVRMBExYaEhckFA4PWVdZGBILWUFZTkNVSUlVTFVKSk9ZV1kWGg8SFR0UWUFZT0tIVUpLSU9PT0 hVSktLVUpCS0tZBg++ DKIM-Signature: a=rsa-sha256; b=ZOEDpcnPHqH823UJe5r3Lo3NYSXOB5iqcHX0Oea1xUfyUrlM06B/cbbOgwrCjLr7gMKuwUGi34iG1u/W08QWIpt4fgI4TP5vwtVgXvjCvwt8E4vaMAPzU0OlYNY2U4SlC1t0LxsZm9Ms3aCcXR4PRVjLC8vYicehFhPo0wRQ4aw=; c=relaxed/relaxed; s=default; d=rock-chips.com; v=1; bh=H9gnri70RQHNgzhmdocW9YCmiDbR/FZ20L7aXI26Dwg=; 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 --- .../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 1f1de45ca46f..a6d4935234c2 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