From patchwork Wed Oct 16 07:54:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu via B4 Relay X-Patchwork-Id: 13837849 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 5CAA5D20684 for ; Wed, 16 Oct 2024 07:54:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A427310E6AD; Wed, 16 Oct 2024 07:54:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="ZhaTvycV"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE24E10E6A9 for ; Wed, 16 Oct 2024 07:54:13 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5E2835C5ADF; Wed, 16 Oct 2024 07:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 6965DC4AF09; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729065252; bh=OSwFL9mlnhjJaXGcg2Cq/PchumX9pUvEZoNUhnGlojE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ZhaTvycVF+SuSaGailU+cxW20qvoL4Jo/5hPU23XDs+Hy5N82L8ZPu+19WHAgKUpj syrHCX0F+Jf785AbUKCj5vSdZOro5jU4pOk0s9CC3Gn5hZSTHBfIt1ITEmt6Piqdkx H0aNJLtmlYZKWycF4UUmUbfHzrVO662bLjAhXoURb9y5P6t7ryDyuVE0Qw1C3uDm+W /CuCu0UjBRis+p+fXm2o99p+KnNx/Ov+9aWy0GFpH8wnBDyoYZY33bFJ1S6ynXFojw +Beay6b21sJxsGeN8SYC9sZGb1S9UBFF6Z10FykTAcFpnID7FVxHILHpJxYa9fMpj5 GNmnDXT4qZsoQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52B92D206AB; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Wed, 16 Oct 2024 15:54:13 +0800 Subject: [PATCH v6 01/10] drm/bridge: it6505: Change definition of AUX_FIFO_MAX_SIZE MIME-Version: 1.0 Message-Id: <20241016-upstream-v6-v6-1-4d93a0c46de1@ite.com.tw> References: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> In-Reply-To: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Pin-yen Lin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729065263; l=842; i=Hermes.wu@ite.com.tw; s=20241016; h=from:subject:message-id; bh=/GxCXKfDVzA54tJySiQh9RTDiRxXSmoD1seNualt4Bc=; b=Iav1qrUpaoLa1HrMvzluz9qcafJhiQ3CBIo3wUzLV1IaZlQfhspjaHRIMQvIztFRr0yR9i6TI jrVHvH/4iz3C929mC+TAU3Rf/G3EJrH7Mil1PMQEdGL+2X97RwC7L/b X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=kV18uQEXox+1WccdQceCbMlJKN+BBNUk3N8VsoULcQ0= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241016 with auth_id=250 X-Original-From: Hermes Wu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Hermes.wu@ite.com.tw Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu The hardware AUX FIFO is 16 bytes Change definition of AUX_FIFO_MAX_SIZE to 16 Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") Signed-off-by: Hermes Wu Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/ite-it6505.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 7ff17aa14b01e4d9f626424e065131ae2b195c62..3272ca6951f2585f9592834869de23ac50ce41a4 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -300,7 +300,7 @@ #define MAX_CR_LEVEL 0x03 #define MAX_EQ_LEVEL 0x03 #define AUX_WAIT_TIMEOUT_MS 15 -#define AUX_FIFO_MAX_SIZE 32 +#define AUX_FIFO_MAX_SIZE 16 #define PIXEL_CLK_DELAY 1 #define PIXEL_CLK_INVERSE 0 #define ADJUST_PHASE_THRESHOLD 80000 From patchwork Wed Oct 16 07:54:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu via B4 Relay X-Patchwork-Id: 13837850 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 D94F7D206B1 for ; Wed, 16 Oct 2024 07:54:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B427910E6A9; Wed, 16 Oct 2024 07:54:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="I9t2ekzg"; dkim-atps=neutral Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by gabe.freedesktop.org (Postfix) with ESMTPS id B1E5D10E6AA for ; Wed, 16 Oct 2024 07:54:13 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id E2423A416F6; Wed, 16 Oct 2024 07:54:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 81E87C4CED0; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729065252; bh=byUvTUmBe3ucrhmaZKyE7qNvMWkXkPLvh0ygtdtnhrY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=I9t2ekzgFTdNaqnvl6XkfL1A9w82D6mPPCMsEhDaxJ6S3PuysprdfCfSzbdQIWD1c CsIe/SxM2arR2ftULtzWW0XT5JZAnXrmuq3u+UGzTjaqyKGYNjFBBaaoGCyTOqaW58 +67ohwYq56c2qgxhZf1Dpg9WZc7vAWvxrCOacyVfscUoDXPOrAJ5Qf6JA0E1eVD705 Ti8qCKC70xxxZKhlLW0qf4JZnHssYT89xxCPUUkIJp+jYyaDz4G0d2LrbHy5tu1HKj oD7madnZbf4Qd3cx90Kg9I12r1fqRQiQZH5HgIVwQni2sdQwWiDYQr0mnzLuRbWRU8 jf7ODSQZyKdDw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 784ADD20684; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Wed, 16 Oct 2024 15:54:14 +0800 Subject: [PATCH v6 02/10] drm/bridge: it6505: improve AUX operation for edid read MIME-Version: 1.0 Message-Id: <20241016-upstream-v6-v6-2-4d93a0c46de1@ite.com.tw> References: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> In-Reply-To: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Pin-yen Lin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729065263; l=1471; i=Hermes.wu@ite.com.tw; s=20241016; h=from:subject:message-id; bh=DsF7JOpVrJV3KlaD250GuWi9WoMmd/kBUwDp0jcn0es=; b=QsZmTaceZO+ah8EObq3Tqo04UxLpfWswspNydQZGRfnY4isMz45zI9fWxFm0UrWAqfCsk83y6 7ePoxjJKBGqB8mf0ruv1m0C+TpLatDwpk3XrGL1xCItHSSnQRmhcd0p X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=kV18uQEXox+1WccdQceCbMlJKN+BBNUk3N8VsoULcQ0= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241016 with auth_id=250 X-Original-From: Hermes Wu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Hermes.wu@ite.com.tw Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu The original AUX operation using data registers is limited to 4 bytes. The AUX operation command CMD_AUX_I2C_EDID_READ uses AUX FIFO and is capable of reading 16 bytes. This improves the speed of EDID read. Signed-off-by: Hermes Wu Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/ite-it6505.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 3272ca6951f2585f9592834869de23ac50ce41a4..9747d7ccf435d536da55c6a3ff79e504b7c724f0 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -1076,10 +1076,13 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *it6505, size_t size, enum aux_cmd_reply *reply) { int i, ret_size, ret = 0, request_size; + int fifo_max_size = (cmd == CMD_AUX_I2C_EDID_READ) ? AUX_FIFO_MAX_SIZE : 4; mutex_lock(&it6505->aux_lock); - for (i = 0; i < size; i += 4) { - request_size = min((int)size - i, 4); + i = 0; + do { + request_size = min_t(int, (int)size - i, fifo_max_size); + ret_size = it6505_aux_operation(it6505, cmd, address + i, buffer + i, request_size, reply); @@ -1088,8 +1091,9 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *it6505, goto aux_op_err; } + i += request_size; ret += ret_size; - } + } while (i < size); aux_op_err: mutex_unlock(&it6505->aux_lock); From patchwork Wed Oct 16 07:54:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu via B4 Relay X-Patchwork-Id: 13837856 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 D41C0D206B1 for ; Wed, 16 Oct 2024 07:54:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2405510E6B5; Wed, 16 Oct 2024 07:54:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="pZRIFBjs"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id E80A310E6A9 for ; Wed, 16 Oct 2024 07:54:13 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7BA345C5B2A; Wed, 16 Oct 2024 07:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 92E68C4CED6; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729065252; bh=n93E6iCB1bU0i/bh9gsTxfittNpS+aSp/DTC6Czk6DI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=pZRIFBjsPkbV1eS2C/0/Oy1b42+CP0YWUZ1hmYF7JfVNufVNqhG+gHSKit1UBf4cr WM/2g5/5E+CW6ftXr3TZv1hXxTDlmqI88JQQJqjxiygS3uFu2DxZD0trQXr9UGXnKE TETY62t5ubiTpmvDpSrSxOLYcCIhZU2jS+nO0dAbPeSlwETyikCN0iqLM5zFaXt/Bb 23excqWIXxPqR37BATb/vs6R3pUPh9SU5ImMkGaez3pWZlA3Mn2K/zDoEHzGTLbxDT YAEEBL+aT8IAZd12PjnEe6nc/9sPcZThEV/tmNmsBySB+6aFtrMSGbqhgu8SGnFwpR OR+gM6YVOGGxg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89D25D206AB; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Wed, 16 Oct 2024 15:54:15 +0800 Subject: [PATCH v6 03/10] drm/bridge: it6505: add AUX operation for HDCP KSV list read MIME-Version: 1.0 Message-Id: <20241016-upstream-v6-v6-3-4d93a0c46de1@ite.com.tw> References: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> In-Reply-To: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Pin-yen Lin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729065263; l=3378; i=Hermes.wu@ite.com.tw; s=20241016; h=from:subject:message-id; bh=/fXuff/9Svbqq/yjBT5j6wJt5HiXdNiMkfV4cxh+1Hc=; b=hgM8V5HmaMpSlfa6wZQTlCWcl87TVKfQieSoZzkUfFgJdSlxP+CyEWIUhodpDPZt7RZQSrTEW e0biuS01fhpAgmpl84QOlj9qUzISbNCVue2iWR3FdHhe8dckvKAmJGv X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=kV18uQEXox+1WccdQceCbMlJKN+BBNUk3N8VsoULcQ0= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241016 with auth_id=250 X-Original-From: Hermes Wu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Hermes.wu@ite.com.tw Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu HDCP KSV list readback can choose to use AUX FIFO or general data register. For some DisplayPort devices, the KSV list must be read in 5 byte boundaries. The original AUX read command does not support these devices. The AUX command operation control register "REG_AUX_CMD_REQ" uses b[3:0] as AUX operacion control, and b[7:4] are status bits and read only. To change KSV read operation uses "CMD_AUX_NATIVE_READ" from using the data registers to using AUX FIFO. The extended command "CMD_AUX_GET_KSV_LIST" is added as "CMD_AUX_NATIVE_READ" with the 0x10 flag which selects AUX FIFO mode. Signed-off-by: Hermes Wu Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/ite-it6505.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 9747d7ccf435d536da55c6a3ff79e504b7c724f0..4e6ec1695ae45111d06026d7548d108fac9e5219 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -126,6 +126,7 @@ #define REG_AUX_OUT_DATA0 0x27 #define REG_AUX_CMD_REQ 0x2B +#define M_AUX_REQ_CMD 0x0F #define AUX_BUSY BIT(5) #define REG_AUX_DATA_0_7 0x2C @@ -324,6 +325,9 @@ enum aux_cmd_type { CMD_AUX_NATIVE_READ = 0x0, CMD_AUX_NATIVE_WRITE = 0x5, CMD_AUX_I2C_EDID_READ = 0xB, + + /* KSV read with AUX FIFO extend from CMD_AUX_NATIVE_READ*/ + CMD_AUX_GET_KSV_LIST = 0x10, }; enum aux_cmd_reply { @@ -965,7 +969,8 @@ static ssize_t it6505_aux_operation(struct it6505 *it6505, it6505_set_bits(it6505, REG_AUX_CTRL, AUX_USER_MODE, AUX_USER_MODE); aux_op_start: - if (cmd == CMD_AUX_I2C_EDID_READ) { + /* HW AUX FIFO supports only EDID and DCPD KSV FIFO area */ + if (cmd == CMD_AUX_I2C_EDID_READ || cmd == CMD_AUX_GET_KSV_LIST) { /* AUX EDID FIFO has max length of AUX_FIFO_MAX_SIZE bytes. */ size = min_t(size_t, size, AUX_FIFO_MAX_SIZE); /* Enable AUX FIFO read back and clear FIFO */ @@ -996,7 +1001,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it6505, size); /* Aux Fire */ - it6505_write(it6505, REG_AUX_CMD_REQ, cmd); + it6505_write(it6505, REG_AUX_CMD_REQ, FIELD_GET(M_AUX_REQ_CMD, cmd)); ret = it6505_aux_wait(it6505); if (ret < 0) @@ -1030,7 +1035,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it6505, goto aux_op_start; } - if (cmd == CMD_AUX_I2C_EDID_READ) { + if (cmd == CMD_AUX_I2C_EDID_READ || cmd == CMD_AUX_GET_KSV_LIST) { for (i = 0; i < size; i++) { ret = it6505_read(it6505, REG_AUX_DATA_FIFO); if (ret < 0) @@ -1055,7 +1060,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it6505, ret = i; aux_op_err: - if (cmd == CMD_AUX_I2C_EDID_READ) { + if (cmd == CMD_AUX_I2C_EDID_READ || cmd == CMD_AUX_GET_KSV_LIST) { /* clear AUX FIFO */ it6505_set_bits(it6505, REG_AUX_CTRL, AUX_EN_FIFO_READ | CLR_EDID_FIFO, @@ -1076,7 +1081,8 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *it6505, size_t size, enum aux_cmd_reply *reply) { int i, ret_size, ret = 0, request_size; - int fifo_max_size = (cmd == CMD_AUX_I2C_EDID_READ) ? AUX_FIFO_MAX_SIZE : 4; + int fifo_max_size = (cmd == CMD_AUX_I2C_EDID_READ || cmd == CMD_AUX_GET_KSV_LIST) ? + AUX_FIFO_MAX_SIZE : 4; mutex_lock(&it6505->aux_lock); i = 0; From patchwork Wed Oct 16 07:54:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu via B4 Relay X-Patchwork-Id: 13837854 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 5980ED20684 for ; Wed, 16 Oct 2024 07:54:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0276C10E6B0; Wed, 16 Oct 2024 07:54:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="fivgGyuZ"; dkim-atps=neutral Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by gabe.freedesktop.org (Postfix) with ESMTPS id 39AA010E6A9 for ; Wed, 16 Oct 2024 07:54:14 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 17BEFA42730; Wed, 16 Oct 2024 07:54:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id A533DC4CED3; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729065252; bh=eNQDCFdkqiiyXv5hOp43aJIAbtM5c7kbCWij3kA8BiY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fivgGyuZcm74gREXYcqgKPFcKt2V1bUMzsmtcXvWJobJFum/GfDifOrFLj78h3m7U BtHLkwXV27iyzE5lwJkCmBCz0GBCCXjwW84ZGmPWAtOjhoDxnSffn5syxBCErr5Ypu cKnn2UCmC7KPV55Pv9Yvffa2jYWAkz5DLLFzcGdWggFV32GqW6BnunqNNgaEVHhmNm e3LHi+kY0PQ0GVVZCczHgAlcfrqSRlM0Dj2d+EIoPPpXd3nc/3Gnbw5LPJtIiw89t0 pmkdQ1VIg6UVF3ncZ2wCAGgV4j6t6UwuxXL7S/TcuixO4pD4O6wkDd4g6qy7f5OXm0 2F40OciyycacQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98BDBD206B1; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Wed, 16 Oct 2024 15:54:16 +0800 Subject: [PATCH v6 04/10] drm/bridge: it6505: Change definition MAX_HDCP_DOWN_STREAM_COUNT MIME-Version: 1.0 Message-Id: <20241016-upstream-v6-v6-4-4d93a0c46de1@ite.com.tw> References: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> In-Reply-To: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Pin-yen Lin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729065263; l=933; i=Hermes.wu@ite.com.tw; s=20241016; h=from:subject:message-id; bh=3ddSzRZW1dYqw+zVd/zP+vvAOPYLASxqzo1lBP2m1T8=; b=5+v3Tps6Ngx9FCOsycV1P077I4wPNRbn7LG5ac5D0CZPa1acwEYmmGhoudhocSfSXhw2HfMyr CGpjWfDuD26Dmz9Rk9lGsqUgC0O7ylNw0lRJ2akJEzBqkvZp+lQvT7X X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=kV18uQEXox+1WccdQceCbMlJKN+BBNUk3N8VsoULcQ0= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241016 with auth_id=250 X-Original-From: Hermes Wu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Hermes.wu@ite.com.tw Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu A HDCP source device shall support max downstream to 127 devices. Change definition MAX_HDCP_DOWN_STREAM_COUNT to 127 KSVs shall save for DRM blocked devices check. This results in struct it6505 growth by ~0.5 KiB. Signed-off-by: Hermes Wu Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/ite-it6505.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 4e6ec1695ae45111d06026d7548d108fac9e5219..1159725f6871e5912aa6c2660823bee67115143e 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -297,7 +297,7 @@ #define MAX_LANE_COUNT 4 #define MAX_LINK_RATE HBR #define AUTO_TRAIN_RETRY 3 -#define MAX_HDCP_DOWN_STREAM_COUNT 10 +#define MAX_HDCP_DOWN_STREAM_COUNT 127 #define MAX_CR_LEVEL 0x03 #define MAX_EQ_LEVEL 0x03 #define AUX_WAIT_TIMEOUT_MS 15 From patchwork Wed Oct 16 07:54:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu via B4 Relay X-Patchwork-Id: 13837851 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 5E094D20684 for ; Wed, 16 Oct 2024 07:54:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B88E410E6AE; Wed, 16 Oct 2024 07:54:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="s6wlyl30"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2143F10E6AA for ; Wed, 16 Oct 2024 07:54:14 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8BC685C5BBA; Wed, 16 Oct 2024 07:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id B4145C4CEDA; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729065252; bh=KPrIiUCCJvcpVV496icokuhP6hghnoZ7VLpEGBD0vAg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=s6wlyl30aTN6Sb6cBsi4iXTnSgAHhTp7FgL+Dx4+B8S8pWQmGVw5TciicJHEXZ9KP d2PilA1apRW27J0mRBLNq6GxccaOOuVJrqT+VaeLBV8bu0m1goRjcGEh7Pt+3h8UQL G9cEWfed+ElahOe+1+Kzg4TYA5Qc1u/nETUvA8QNoqL6x4p0/rMog+UA4s88Hn9KW2 Di6afsDhTUeElkn72LRuhWZfAGduw1+tCqtxu1trYxNxNnkr3t2YO5G1iVH8RawXDX 3zralsVdjOc63PlPBmkuH0XlbAvRh6ftyPvJuAzzE6gWSdlMhSlbccol1Zh+iYEuP7 jXgOYejNa6s9A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABF90D206B0; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Wed, 16 Oct 2024 15:54:17 +0800 Subject: [PATCH v6 05/10] drm/bridge: it6505: fix HDCP Bstatus check MIME-Version: 1.0 Message-Id: <20241016-upstream-v6-v6-5-4d93a0c46de1@ite.com.tw> References: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> In-Reply-To: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Pin-yen Lin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729065263; l=1511; i=Hermes.wu@ite.com.tw; s=20241016; h=from:subject:message-id; bh=Hdhgn2iSLeVVknrOzDCehQJFmQa5IML+EAJRH7ql5B0=; b=KmiRnZAqgwt29C/uSmasEHlJzvn/1X8tZctI0vzUChO5ZLG8v2pd4zYAzfN1XZAiGCBhWY0zq 0wY4lvw6MsOBnsVkZLVHChV4MzV+JiRPb1y36wmMynqpZjfi8yTsBDe X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=kV18uQEXox+1WccdQceCbMlJKN+BBNUk3N8VsoULcQ0= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241016 with auth_id=250 X-Original-From: Hermes Wu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Hermes.wu@ite.com.tw Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu When HDCP is activated, a DisplayPort source receiving CP_IRQ from the sink shall check Bstatus from DPCD and process the corresponding value Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 1159725f6871e5912aa6c2660823bee67115143e..65c17e53e05f3bc2a647474cba7d9d7e737f11b8 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2322,14 +2322,20 @@ static int it6505_process_hpd_irq(struct it6505 *it6505) DRM_DEV_DEBUG_DRIVER(dev, "dp_irq_vector = 0x%02x", dp_irq_vector); if (dp_irq_vector & DP_CP_IRQ) { - it6505_set_bits(it6505, REG_HDCP_TRIGGER, HDCP_TRIGGER_CPIRQ, - HDCP_TRIGGER_CPIRQ); - bstatus = it6505_dpcd_read(it6505, DP_AUX_HDCP_BSTATUS); if (bstatus < 0) return bstatus; DRM_DEV_DEBUG_DRIVER(dev, "Bstatus = 0x%02x", bstatus); + + /*check BSTATUS when recive CP_IRQ */ + if (bstatus & DP_BSTATUS_R0_PRIME_READY && + it6505->hdcp_status == HDCP_AUTH_GOING) + it6505_set_bits(it6505, REG_HDCP_TRIGGER, HDCP_TRIGGER_CPIRQ, + HDCP_TRIGGER_CPIRQ); + else if (bstatus & (DP_BSTATUS_REAUTH_REQ | DP_BSTATUS_LINK_FAILURE) && + it6505->hdcp_status == HDCP_AUTH_DONE) + it6505_start_hdcp(it6505); } ret = drm_dp_dpcd_read_link_status(&it6505->aux, link_status); From patchwork Wed Oct 16 07:54:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu via B4 Relay X-Patchwork-Id: 13837852 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 843FBD206B1 for ; Wed, 16 Oct 2024 07:54:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B056E10E6AC; Wed, 16 Oct 2024 07:54:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="SWge3eLO"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 754B010E6A9 for ; Wed, 16 Oct 2024 07:54:14 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B50C45C5C05; Wed, 16 Oct 2024 07:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id C6DCEC4CED9; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729065252; bh=Vb+2n+MAUfgAIp8TePUzygedx1r8RBKo1kmKaDIUJB8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=SWge3eLOBKqWEdzGtCGv23f56qRiQYCyMicx53kG1ueWm8hD2b1KZmEX64i5+r3MS DkFIT7hgI5S34e1wym/NJ+40kuXJnFpzjg5hwQn8E4xaD89/zmB/HZ1Ul1t1sVdcWu AH8mrYDLRk8+VE7LxjW+UN/MF9lID7LLx0m5EqogRZHo9Z/s25WVScXxqYeJQjg3FA UjE95QYEqdmE5ODSLqU72QIonFRGCjZzxDaxKhd4JAO3jVqZXsBXvtCptElvgjcPnb 21UaFpHpa7pYT6rIkYXyrnFTibSnomzh6Ns4iWqp4hIp1lnoE8ecL/nzEstO8iYbak vTCYbjnch2zkw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB9D7D20684; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Wed, 16 Oct 2024 15:54:18 +0800 Subject: [PATCH v6 06/10] drm/bridge: it6505: fix HDCP encryption when R0 ready MIME-Version: 1.0 Message-Id: <20241016-upstream-v6-v6-6-4d93a0c46de1@ite.com.tw> References: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> In-Reply-To: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Pin-yen Lin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729065263; l=1834; i=Hermes.wu@ite.com.tw; s=20241016; h=from:subject:message-id; bh=qR/Gpw52l5zLkqw/wfFTDrG6OM+qapW0KVFY2MBecyA=; b=Hu13NgyYtDaKX6ChWU8xiKMrGhUKfKUtC61YZjDWNkCcgZEZQv1ifNETnsEi2C98ig6wUv0P6 rCO2Xb7PtuSBqqA+fypGrs4anb/we3lrHybjNgXndbB6OQw0Jsjpysp X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=kV18uQEXox+1WccdQceCbMlJKN+BBNUk3N8VsoULcQ0= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241016 with auth_id=250 X-Original-From: Hermes Wu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Hermes.wu@ite.com.tw Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu When starting HDCP authentication, HDCP encryption should be enabled when R0'is checked. Change encryption enables time at R0' ready. The hardware HDCP engine trigger is changed and the repeater KSV fails will restart HDCP. Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 65c17e53e05f3bc2a647474cba7d9d7e737f11b8..85626b49a048a1178676ed616130a522ca314152 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2091,15 +2091,12 @@ static void it6505_hdcp_wait_ksv_list(struct work_struct *work) ksv_list_check = it6505_hdcp_part2_ksvlist_check(it6505); DRM_DEV_DEBUG_DRIVER(dev, "ksv list ready, ksv list check %s", ksv_list_check ? "pass" : "fail"); - if (ksv_list_check) { - it6505_set_bits(it6505, REG_HDCP_TRIGGER, - HDCP_TRIGGER_KSV_DONE, HDCP_TRIGGER_KSV_DONE); + + if (ksv_list_check) return; - } + timeout: - it6505_set_bits(it6505, REG_HDCP_TRIGGER, - HDCP_TRIGGER_KSV_DONE | HDCP_TRIGGER_KSV_FAIL, - HDCP_TRIGGER_KSV_DONE | HDCP_TRIGGER_KSV_FAIL); + it6505_start_hdcp(it6505); } static void it6505_hdcp_work(struct work_struct *work) @@ -2472,7 +2469,11 @@ static void it6505_irq_hdcp_ksv_check(struct it6505 *it6505) { struct device *dev = it6505->dev; - DRM_DEV_DEBUG_DRIVER(dev, "HDCP event Interrupt"); + DRM_DEV_DEBUG_DRIVER(dev, "HDCP repeater R0 event Interrupt"); + /* 1B01 HDCP encription should start when R0 is ready*/ + it6505_set_bits(it6505, REG_HDCP_TRIGGER, + HDCP_TRIGGER_KSV_DONE, HDCP_TRIGGER_KSV_DONE); + schedule_work(&it6505->hdcp_wait_ksv_list); } From patchwork Wed Oct 16 07:54:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu via B4 Relay X-Patchwork-Id: 13837857 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 8EB77D20684 for ; Wed, 16 Oct 2024 07:54:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 96FB110E6B3; Wed, 16 Oct 2024 07:54:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="fVDvWBAm"; dkim-atps=neutral Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4BFDB10E6AC for ; Wed, 16 Oct 2024 07:54:14 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 3CE84A429BF; Wed, 16 Oct 2024 07:54:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id D3123C4CECE; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729065252; bh=3/AamiyrIYhBdVOlu9ElIgKN5r16P+kbe+BSQtba8g4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fVDvWBAmL9lqeIoSYZ8MvKNQhDaBIIm0guy62aZ1Zb4+LGNBNHS9BsagTOge+A4Dt 2Te0bUV7pdyk4lz/JqdFEZp7R7wAMSOQwwc7sE0200CWYXIgN5bp5agOhIL23glNac h1HzZbtOZVm06/+FM22EZvli9NjVqZbSjcA5HVRsTWmAhijZRFsA350GmlbFHlUHQd SpXCWocv/Fb2e0YceiinLeDDuGm1s2QVaFFOL6W8zjHh9h4Q03rMabEGYeQj2gzC3S CoQJE+VwOqIgpEToP5KNYcAxV4MOYvCgrcllsTH+3o3x32CyzwXkmUeO67zJCeL2Pq Aa532HNfS7tNQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB8FFD206AB; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Wed, 16 Oct 2024 15:54:19 +0800 Subject: [PATCH v6 07/10] drm/bridge: it6505: fix HDCP CTS KSV list read with UNIGRAF DPR-100. MIME-Version: 1.0 Message-Id: <20241016-upstream-v6-v6-7-4d93a0c46de1@ite.com.tw> References: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> In-Reply-To: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Pin-yen Lin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729065263; l=2956; i=Hermes.wu@ite.com.tw; s=20241016; h=from:subject:message-id; bh=+V21HG3VVxkOkslhvoDICqbbbWGD4xtrVrwwYpVZ5VE=; b=0bKDdOl3LcNCuPrzr4p1kkdxq7KZQG4I1H1BzDtHfhPR2nD+NFLiVuiQb+qzFMAjKnbqmH28M YPTcqnQby4uAdmjfHNJlcKglRmPOI4cSYu5wwYgZ0pkqyzu2/BAC2Oy X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=kV18uQEXox+1WccdQceCbMlJKN+BBNUk3N8VsoULcQ0= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241016 with auth_id=250 X-Original-From: Hermes Wu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Hermes.wu@ite.com.tw Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu When running the HDCP CTS test with UNIGRAF DPR-100. KSV list must be read from DP_AUX_HDCP_KSV_FIFO in an AUX request, and can not separate with multiple read requests. The AUX operation command "CMD_AUX_GET_KSV_LIST" reads the KSV list with AUX FIFO and is able to read DP_AUX_HDCP_KSV_FIFO in an AUX request. Add it6505_get_ksvlist() which uses CMD_AUX_GET_KSV_LIST operation to read the KSV list. Signed-off-by: Hermes Wu Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/ite-it6505.c | 48 +++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 85626b49a048a1178676ed616130a522ca314152..40fb47f4954331d63681066fb3af19f0f57bb929 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -1188,6 +1188,37 @@ static int it6505_get_edid_block(void *data, u8 *buf, unsigned int block, return 0; } +static int it6505_get_ksvlist(struct it6505 *it6505, u8 *buf, size_t len) +{ + struct device *dev = it6505->dev; + enum aux_cmd_reply reply; + int request_size, ret; + int i = 0; + + do { + request_size = min_t(int, (int)len - i, 15); + + ret = it6505_aux_do_transfer(it6505, CMD_AUX_GET_KSV_LIST, + DP_AUX_HDCP_KSV_FIFO, + buf + i, request_size, &reply); + + DRM_DEV_DEBUG_DRIVER(dev, "request_size = %d, ret =%d", request_size, ret); + if (ret < 0) + return ret; + + i += request_size; + } while (i < len); + + DRM_DEV_DEBUG_DRIVER(dev, "ksv read cnt = %d down_stream_cnt=%d ", i, i / 5); + + for (i = 0 ; i < len; i += 5) { + DRM_DEV_DEBUG_DRIVER(dev, "ksv[%d] = %02X%02X%02X%02X%02X", + i / 5, buf[i], buf[i + 1], buf[i + 2], buf[i + 3], buf[i + 4]); + } + + return len; +} + static void it6505_variable_config(struct it6505 *it6505) { it6505->link_rate_bw_code = HBR; @@ -1969,7 +2000,7 @@ static int it6505_setup_sha1_input(struct it6505 *it6505, u8 *sha1_input) { struct device *dev = it6505->dev; u8 binfo[2]; - int down_stream_count, i, err, msg_count = 0; + int down_stream_count, err, msg_count = 0; err = it6505_get_dpcd(it6505, DP_AUX_HDCP_BINFO, binfo, ARRAY_SIZE(binfo)); @@ -1994,18 +2025,11 @@ static int it6505_setup_sha1_input(struct it6505 *it6505, u8 *sha1_input) down_stream_count); return 0; } + err = it6505_get_ksvlist(it6505, sha1_input, down_stream_count * 5); + if (err < 0) + return err; - for (i = 0; i < down_stream_count; i++) { - err = it6505_get_dpcd(it6505, DP_AUX_HDCP_KSV_FIFO + - (i % 3) * DRM_HDCP_KSV_LEN, - sha1_input + msg_count, - DRM_HDCP_KSV_LEN); - - if (err < 0) - return err; - - msg_count += 5; - } + msg_count += down_stream_count * 5; it6505->hdcp_down_stream_count = down_stream_count; sha1_input[msg_count++] = binfo[0]; From patchwork Wed Oct 16 07:54:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu via B4 Relay X-Patchwork-Id: 13837859 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 34131D206B3 for ; Wed, 16 Oct 2024 07:54:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C0A2510E6B6; Wed, 16 Oct 2024 07:54:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="XDGXEiea"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5B8BB10E6AA for ; Wed, 16 Oct 2024 07:54:14 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A8DD45C5BF8; Wed, 16 Oct 2024 07:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id E2EB8C4CED7; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729065252; bh=oPCRUpLGMx61HeGBVmDtTagHLW4mYnC+zOcvc9PEJPc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=XDGXEieaGDn9mjXqiW74u9UAF1dVAMNtVXnvlleAkoMVdXRvHF+P81iEl49Dz8lsS i41GqAiSEJ8coyCVwSgY9Ke3TGlMHtkRZaHeZUz0elsmPoxHZJyFpN8m4pdli6wjoN yaqVzHxv7PyojRjRNSER4hOOW7YLEB45gQp0tS41YtMxiOx8jYdeANU3pKLLs8aBl5 RaPKWBcfDCtF/rMOka60rci7S/O3kRQcYpUX/3FRqJKRjpyagNaAce5iaX7OIf8rr/ asz2ST7vZ/NDJQ9H/oQOOMmvP3EYI7MGdx/SezqFNl0sLmC45kpva4VyJVrI+xnVBT O+pZmYbgoRrHg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB002D206B1; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Wed, 16 Oct 2024 15:54:20 +0800 Subject: [PATCH v6 08/10] drm/bridge: it6505: fix HDCP CTS compare V matching MIME-Version: 1.0 Message-Id: <20241016-upstream-v6-v6-8-4d93a0c46de1@ite.com.tw> References: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> In-Reply-To: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Pin-yen Lin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729065263; l=2090; i=Hermes.wu@ite.com.tw; s=20241016; h=from:subject:message-id; bh=vVGOPh2gUmJR+gDRTv9xrafnNiddtntN9yPHXoZ0A7Y=; b=OhDMy/DGwZCFCTXSW4O5wIhEi0wj63lfX8wE8fgG/wVL5mzlXwX5mi906+fCnd3oxkJtwrf+S hffdaKRx9ELDya2dnsW8IkAP4XiJAKhCP0NG/iL2O3ns/4Cl+c0ani0 X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=kV18uQEXox+1WccdQceCbMlJKN+BBNUk3N8VsoULcQ0= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241016 with auth_id=250 X-Original-From: Hermes Wu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Hermes.wu@ite.com.tw Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu When HDCP negotiation with a repeater device. Checking SHA V' matching must retry 3 times before restarting HDCP. Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 40fb47f4954331d63681066fb3af19f0f57bb929..439cca455ecf91b5f83b0add416db7f099f9a34d 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2057,7 +2057,7 @@ static bool it6505_hdcp_part2_ksvlist_check(struct it6505 *it6505) { struct device *dev = it6505->dev; u8 av[5][4], bv[5][4]; - int i, err; + int i, err, retry; i = it6505_setup_sha1_input(it6505, it6505->sha1_input); if (i <= 0) { @@ -2066,22 +2066,28 @@ static bool it6505_hdcp_part2_ksvlist_check(struct it6505 *it6505) } it6505_sha1_digest(it6505, it6505->sha1_input, i, (u8 *)av); + /*1B-05 V' must retry 3 times */ + for (retry = 0; retry < 3; retry++) { + err = it6505_get_dpcd(it6505, DP_AUX_HDCP_V_PRIME(0), (u8 *)bv, + sizeof(bv)); - err = it6505_get_dpcd(it6505, DP_AUX_HDCP_V_PRIME(0), (u8 *)bv, - sizeof(bv)); + if (err < 0) { + dev_err(dev, "Read V' value Fail %d", retry); + continue; + } - if (err < 0) { - dev_err(dev, "Read V' value Fail"); - return false; - } + for (i = 0; i < 5; i++) { + if (bv[i][3] != av[i][0] || bv[i][2] != av[i][1] || + av[i][1] != av[i][2] || bv[i][0] != av[i][3]) + break; - for (i = 0; i < 5; i++) - if (bv[i][3] != av[i][0] || bv[i][2] != av[i][1] || - bv[i][1] != av[i][2] || bv[i][0] != av[i][3]) - return false; + DRM_DEV_DEBUG_DRIVER(dev, "V' all match!! %d, %d", retry, i); + return true; + } + } - DRM_DEV_DEBUG_DRIVER(dev, "V' all match!!"); - return true; + DRM_DEV_DEBUG_DRIVER(dev, "V' NOT match!! %d", retry); + return false; } static void it6505_hdcp_wait_ksv_list(struct work_struct *work) From patchwork Wed Oct 16 07:54:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu via B4 Relay X-Patchwork-Id: 13837858 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 728F4D206AC for ; Wed, 16 Oct 2024 07:54:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5B4310E6B4; Wed, 16 Oct 2024 07:54:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="e1bhhl3c"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 989F310E6AA for ; Wed, 16 Oct 2024 07:54:14 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EC1F25C5C68; Wed, 16 Oct 2024 07:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id F2DE0C4CEDE; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729065253; bh=40jFRzyCuak9rdF0lRbTymXhl036JNQc0hKEdgqQU6g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=e1bhhl3cbP9gG7qPwu/jU0/mlwc+kg1xWBfiMMUjPJ45ZzQJzJJFiXzerPtzcc0Sz +sYpzmHn6xDWOFYkpNBLIcUo0OT4tWaO+Gl74eO5DrjkkKtSwT49iJ6syigvFldJKS GA2laiJOZ46iF7iSDfT/0VNai9i8FAE3SqsQGvasuq/Jg9UUWY54IBBNNlGD3qhZnH JrhlzVJLPOEmjA+YNADajPICI5Frk8JGdx3K6+ylbSo5/+YaQmaf0CemK/1AsC+ehq fPso0Ugx15nz65qnmC/Svmeh7gPJcbZoRu6KS6Q54rrUBYbUH+FJG6SghuwPnKkl0X HxB6giad59Ahg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAF1DD206B3; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Wed, 16 Oct 2024 15:54:21 +0800 Subject: [PATCH v6 09/10] drm/bridge: it6505: fix HDCP CTS KSV list wait timer MIME-Version: 1.0 Message-Id: <20241016-upstream-v6-v6-9-4d93a0c46de1@ite.com.tw> References: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> In-Reply-To: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Pin-yen Lin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729065263; l=1723; i=Hermes.wu@ite.com.tw; s=20241016; h=from:subject:message-id; bh=yH/tB2UOyeGhezoE5wVSTIRUshi6Pg5ZgPiTxoFH1OM=; b=fQMddfSAdSKAS/tH+eQ/ekgbcJ+FvTts96lgvvhymX4BlfjOlJG0AuvTraZiYE7fxCXrgFuqA OSv0rIq2zwyBjw/OwBPV7fxQEffvkhw6VIZ4orUhjTxjSURg4OorcJo X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=kV18uQEXox+1WccdQceCbMlJKN+BBNUk3N8VsoULcQ0= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241016 with auth_id=250 X-Original-From: Hermes Wu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Hermes.wu@ite.com.tw Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu HDCP must disabled encryption and restart authentication after waiting KSV for 5s. The original method uses a counter in a waitting loop that may wait much longer than it is supposed to. Use time_after() for KSV wait timeout. Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 439cca455ecf91b5f83b0add416db7f099f9a34d..4fc2147e9788501f0161180fc865072ab965ecbf 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2095,12 +2095,13 @@ static void it6505_hdcp_wait_ksv_list(struct work_struct *work) struct it6505 *it6505 = container_of(work, struct it6505, hdcp_wait_ksv_list); struct device *dev = it6505->dev; - unsigned int timeout = 5000; - u8 bstatus = 0; + u8 bstatus; bool ksv_list_check; + /* 1B-04 wait ksv list for 5s */ + unsigned long timeout = jiffies + + msecs_to_jiffies(5000) + 1; - timeout /= 20; - while (timeout > 0) { + for (;;) { if (!it6505_get_sink_hpd_status(it6505)) return; @@ -2109,13 +2110,12 @@ static void it6505_hdcp_wait_ksv_list(struct work_struct *work) if (bstatus & DP_BSTATUS_READY) break; - msleep(20); - timeout--; - } + if (time_after(jiffies, timeout)) { + DRM_DEV_DEBUG_DRIVER(dev, "KSV list wait timeout"); + goto timeout; + } - if (timeout == 0) { - DRM_DEV_DEBUG_DRIVER(dev, "timeout and ksv list wait failed"); - goto timeout; + msleep(20); } ksv_list_check = it6505_hdcp_part2_ksvlist_check(it6505); From patchwork Wed Oct 16 07:54:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu via B4 Relay X-Patchwork-Id: 13837853 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 77BC0D206AC for ; Wed, 16 Oct 2024 07:54:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C519810E6AF; Wed, 16 Oct 2024 07:54:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="RcubLegV"; dkim-atps=neutral Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by gabe.freedesktop.org (Postfix) with ESMTPS id A021B10E6AC for ; Wed, 16 Oct 2024 07:54:14 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 4824DA429D3; Wed, 16 Oct 2024 07:54:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 0ED2EC4CEE1; Wed, 16 Oct 2024 07:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729065253; bh=6GLNfhT3dwFCU0ldrvAxlBEYAVhF9inTvSCRJuALhUM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RcubLegV69nSYpNMFnLbBsCv8k9HLfxrkW9RxkM5SGKPouHMPfq6VY6FlriMWQ2f+ WIao5bt1lDyzAOlGXv4wAw6OgJ2+Nidv3dLQ+ZGXcUZ595d8C32TxejRDslvtsqlcA wTp3yxXYw3UwIok4HUz8ycO2uZrYgv44VchaTx6fzveYjLEtfcTF8ZJxp/wRz2b89w UlLFy4c8iHlUmVGVvLI7B7AW7j7ljqkDckJNiP3avA//llOFkOPfiz76aE6tepgQjT vro+McEqbRPs30ytrXJpLW79OTWLY8IPlEokqULOKX27aIkgMTb5SGBIJKptcon8ry 475zkvpmd2jmQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0774BD20684; Wed, 16 Oct 2024 07:54:13 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Wed, 16 Oct 2024 15:54:22 +0800 Subject: [PATCH v6 10/10] drm/bridge: it6505: add I2C functionality on AUX MIME-Version: 1.0 Message-Id: <20241016-upstream-v6-v6-10-4d93a0c46de1@ite.com.tw> References: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> In-Reply-To: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Pin-yen Lin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729065263; l=6869; i=Hermes.wu@ite.com.tw; s=20241016; h=from:subject:message-id; bh=gC24eYRJHnPLzseZNt75kdykjMNImvebHR8wNIWmjqI=; b=/kQxXDYIYkHFaB4DOWo4CSEL55oW2OyDK3DQrzHNVSJCp0K1DYMGJGZJj/9YfmCW5kfLW1v9c MPetwk5YNYxA6Pidpt1t3vCqVBqFiEV+yg5TJ2I5ixWB8Yr7e7zjvmQ X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=kV18uQEXox+1WccdQceCbMlJKN+BBNUk3N8VsoULcQ0= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241016 with auth_id=250 X-Original-From: Hermes Wu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Hermes.wu@ite.com.tw Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu DisplayPort AUX protocol supports I2C transport which is capable of reading EDID or supports MCCS. In drm_dp_helper, drm_dp_i2c_xfer() packs I2C requests into a sequence of AUX requests. it6505_aux_i2c_operation() is implemented to match drm_dp_i2c_xfer() operactions. it6505_aux_i2c_transfer() adds I2C functionality for it6505_aux_transfer(). Signed-off-by: Hermes Wu Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/ite-it6505.c | 177 +++++++++++++++++++++++++++++++++++- 1 file changed, 175 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 4fc2147e9788501f0161180fc865072ab965ecbf..04e17737f0d7228e5178984aefe124f88bce0825 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -267,6 +267,18 @@ #define REG_SSC_CTRL1 0x189 #define REG_SSC_CTRL2 0x18A +#define REG_AUX_USER_CTRL 0x190 +#define EN_USER_AUX BIT(0) +#define USER_AUX_DONE BIT(1) +#define AUX_EVENT BIT(4) + +#define REG_AUX_USER_DATA_REC 0x191 +#define M_AUX_IN_REC 0xF0 +#define M_AUX_OUT_REC 0x0F + +#define REG_AUX_USER_REPLY 0x19A +#define REG_AUX_USER_RXB(n) (n + 0x19B) + #define RBR DP_LINK_BW_1_62 #define HBR DP_LINK_BW_2_7 #define HBR2 DP_LINK_BW_5_4 @@ -302,6 +314,8 @@ #define MAX_EQ_LEVEL 0x03 #define AUX_WAIT_TIMEOUT_MS 15 #define AUX_FIFO_MAX_SIZE 16 +#define AUX_I2C_MAX_SIZE 4 +#define AUX_I2C_DEFER_RETRY 4 #define PIXEL_CLK_DELAY 1 #define PIXEL_CLK_INVERSE 0 #define ADJUST_PHASE_THRESHOLD 80000 @@ -324,7 +338,12 @@ enum aux_cmd_type { CMD_AUX_NATIVE_READ = 0x0, CMD_AUX_NATIVE_WRITE = 0x5, + CMD_AUX_GI2C_ADR = 0x08, + CMD_AUX_GI2C_READ = 0x09, + CMD_AUX_GI2C_WRITE = 0x0A, CMD_AUX_I2C_EDID_READ = 0xB, + CMD_AUX_I2C_READ = 0x0D, + CMD_AUX_I2C_WRITE = 0x0C, /* KSV read with AUX FIFO extend from CMD_AUX_NATIVE_READ*/ CMD_AUX_GET_KSV_LIST = 0x10, @@ -1106,6 +1125,161 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *it6505, return ret; } +static bool it6505_aux_i2c_reply_defer(u8 reply) +{ + if (reply == DP_AUX_NATIVE_REPLY_DEFER || reply == DP_AUX_I2C_REPLY_DEFER) + return true; + return false; +} + +static bool it6505_aux_i2c_reply_nack(u8 reply) +{ + if (reply == DP_AUX_NATIVE_REPLY_NACK || reply == DP_AUX_I2C_REPLY_NACK) + return true; + return false; +} + +static int it6505_aux_i2c_wait(struct it6505 *it6505, u8 *reply) +{ + int err = 0; + unsigned long timeout; + struct device *dev = it6505->dev; + + timeout = jiffies + msecs_to_jiffies(AUX_WAIT_TIMEOUT_MS) + 1; + + do { + if (it6505_read(it6505, REG_AUX_USER_CTRL) & AUX_EVENT) + break; + if (time_after(jiffies, timeout)) { + dev_err(dev, "Timed out waiting AUX I2C, BUSY = %X\n", + it6505_aux_op_finished(it6505)); + err = -ETIMEDOUT; + goto end_aux_i2c_wait; + } + usleep_range(300, 800); + } while (!it6505_aux_op_finished(it6505)); + + *reply = it6505_read(it6505, REG_AUX_USER_REPLY) >> 4; + + if (*reply == 0) + goto end_aux_i2c_wait; + + if (it6505_aux_i2c_reply_defer(*reply)) + err = -EBUSY; + else if (it6505_aux_i2c_reply_nack(*reply)) + err = -ENXIO; + +end_aux_i2c_wait: + it6505_set_bits(it6505, REG_AUX_USER_CTRL, USER_AUX_DONE, USER_AUX_DONE); + return err; +} + +static int it6505_aux_i2c_readb(struct it6505 *it6505, u8 *buf, size_t size, u8 *reply) +{ + int ret, i; + int retry; + + for (retry = 0; retry < AUX_I2C_DEFER_RETRY; retry++) { + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_READ); + + ret = it6505_aux_i2c_wait(it6505, reply); + if (it6505_aux_i2c_reply_defer(*reply)) + continue; + if (ret >= 0) + break; + } + + for (i = 0; i < size; i++) + buf[i] = it6505_read(it6505, REG_AUX_USER_RXB(0 + i)); + + return size; +} + +static int it6505_aux_i2c_writeb(struct it6505 *it6505, u8 *buf, size_t size, u8 *reply) +{ + int i, ret; + int retry; + + for (i = 0; i < size; i++) + it6505_write(it6505, REG_AUX_OUT_DATA0 + i, buf[i]); + + for (retry = 0; retry < AUX_I2C_DEFER_RETRY; retry++) { + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_WRITE); + + ret = it6505_aux_i2c_wait(it6505, reply); + if (it6505_aux_i2c_reply_defer(*reply)) + continue; + if (ret >= 0) + break; + } + return size; +} + +static ssize_t it6505_aux_i2c_operation(struct it6505 *it6505, + struct drm_dp_aux_msg *msg) +{ + int ret; + ssize_t request_size, data_cnt = 0; + u8 *buffer = msg->buffer; + + /* set AUX user mode */ + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_USER_MODE | AUX_NO_SEGMENT_WR, AUX_USER_MODE); + it6505_set_bits(it6505, REG_AUX_USER_CTRL, EN_USER_AUX, EN_USER_AUX); + /* clear AUX FIFO */ + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_EN_FIFO_READ | CLR_EDID_FIFO, + AUX_EN_FIFO_READ | CLR_EDID_FIFO); + + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_EN_FIFO_READ | CLR_EDID_FIFO, 0x00); + + it6505_write(it6505, REG_AUX_ADR_0_7, 0x00); + it6505_write(it6505, REG_AUX_ADR_8_15, msg->address << 1); + + if (msg->size == 0) { + /* IIC Start/STOP dummy write */ + it6505_write(it6505, REG_AUX_ADR_16_19, msg->request); + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_ADR); + ret = it6505_aux_i2c_wait(it6505, &msg->reply); + goto end_aux_i2c_transfer; + } + + /* IIC data transfer */ + data_cnt = 0; + do { + request_size = min_t(ssize_t, msg->size - data_cnt, AUX_I2C_MAX_SIZE); + it6505_write(it6505, REG_AUX_ADR_16_19, + msg->request | ((request_size - 1) << 4)); + if ((msg->request & DP_AUX_I2C_READ) == DP_AUX_I2C_READ) + ret = it6505_aux_i2c_readb(it6505, &buffer[data_cnt], + request_size, &msg->reply); + else + ret = it6505_aux_i2c_writeb(it6505, &buffer[data_cnt], + request_size, &msg->reply); + + if (ret < 0) + goto end_aux_i2c_transfer; + + data_cnt += request_size; + } while (data_cnt < msg->size); + ret = data_cnt; +end_aux_i2c_transfer: + + it6505_set_bits(it6505, REG_AUX_USER_CTRL, EN_USER_AUX, 0); + it6505_set_bits(it6505, REG_AUX_CTRL, AUX_USER_MODE, 0); + return ret; +} + +static ssize_t it6505_aux_i2c_transfer(struct drm_dp_aux *aux, + struct drm_dp_aux_msg *msg) +{ + struct it6505 *it6505 = container_of(aux, struct it6505, aux); + + guard(mutex)(&it6505->aux_lock); + return it6505_aux_i2c_operation(it6505, msg); +} + static ssize_t it6505_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) { @@ -1115,9 +1289,8 @@ static ssize_t it6505_aux_transfer(struct drm_dp_aux *aux, int ret; enum aux_cmd_reply reply; - /* IT6505 doesn't support arbitrary I2C read / write. */ if (is_i2c) - return -EINVAL; + return it6505_aux_i2c_transfer(aux, msg); switch (msg->request) { case DP_AUX_NATIVE_READ: