From nobody Sun Nov 24 16:21:13 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 70AB318E359 for ; Mon, 4 Nov 2024 06:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; cv=none; b=UOsFK9WEZy785KsvxgmES+LQ9AlW+0pgIN69hUaotQd0X+AmqeAG4aoi2/RHFnnazJRWH7hWm/c97t3A/knKwvZcq6JuM1TyRgNLLDxl+JdyE4Ei/ub3L3MPtoIpuD2FOspPizjO/M8gDyeQ8nnVAtH5qZtig4vDZy8OahcLlfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; c=relaxed/simple; bh=H/QjnbdWcGZr/3yVhc6hw87LffyFcEIL677anYJofeY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m2dPcQBEikPK4sUPUJj2MBTeN60dF/iIsGEIGW6m9uvSDdwQZgNhKyzAY9QARFV679Rec8FiJAMzVT92SI2ummzn7M2k6WGzsuxUErd/ZagToqfnr6KqkA6xyUlygol3yg+ePN1lU+Khh6lfoXSliPpxACRctvRazsS03yil/rY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P28JK9qP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P28JK9qP" Received: by smtp.kernel.org (Postfix) with ESMTPS id 49D92C4CED6; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730702647; bh=H/QjnbdWcGZr/3yVhc6hw87LffyFcEIL677anYJofeY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=P28JK9qP/OHZ1ya8bSaFlfklLg0nBFffExIla05U1Q9nhFXjpqGWkZs+BM1q+OWVi Dh1quuYZ62OiBVwytmTo0G0To3xtWFnxCRcInzlc3riG6Utxb+Id9Lc7dYeYmxP/9T Q9sI60RcRsPr+7XbTuxCvvdwJ4GFhbhILMKkASgso+Pzt4eR5/mF7q3oavY5RlYuG7 fwrwRaNXR57Xw2keG2u5iUjezZ20NUUyYVeoUjrfpx88m3h+Q0AnmF+NfbboQp/v1f ZIR6LXi9IkMRTJZbrbJcDcRYee752LNZ+leqTSZt0pqEBVINJDBAAnt4EE6+q8mBXc IvKC1r2QzbpRQ== 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 37F55D11183; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Mon, 04 Nov 2024 14:43:31 +0800 Subject: [PATCH v7 01/10] drm/bridge: it6505: Change definition of AUX_FIFO_MAX_SIZE Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241104-v7-upstream-v7-1-8b71fd0f1d2d@ite.com.tw> References: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> In-Reply-To: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@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 , Hermes Wu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Pin-yen Lin , Kenneth Hung , Pet Weng , Hermes Wu , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730702658; l=903; i=Hermes.wu@ite.com.tw; s=20241101; h=from:subject:message-id; bh=Tyri1iviyPfgpFppBgVRv/Ms7xTN8BMh3eiXrgG9mds=; b=lTI2ZtSC6VNL+p4Q4yHm0ZqIiqLYKVMLvEe5vs+1U75vgwn5QWzERYz5K6C82TieoPwrXezr1 aLR0GAvHkItDoDzOOsSSF660O3ICdtfMhw2y+YikN33AiePmMRaH4CX X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=FOYYbsP2Nlw6mjB3rLFYSLmAiENzj4AWQly5XTcDuMM= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241101 with auth_id=268 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw 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") Reviewed-by: Dmitry Baryshkov Signed-off-by: Hermes Wu --- 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/i= te-it6505.c index 7ff17aa14b01e4d9f626424e065131ae2b195c62..3272ca6951f2585f9592834869d= e23ac50ce41a4 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 --=20 2.34.1 From nobody Sun Nov 24 16:21:13 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D0A6D18D633 for ; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702646; cv=none; b=FZozFxsnsv6lfttZraHZ4J++HXFmmeBxnq+nYPSftfhqfVabod5qta2tWPg2xQOeCjwgjreWs97eTBdFbdxo4iU5ALQrRVWGSPl/QXD8KEIN0kcJOJKHnPbkTpb1ajmWWGWLyzlAAU+xE1XW8SobAzDP7FJvj9wFVqFt94UTOkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702646; c=relaxed/simple; bh=SuDEzxxGQ/ta1asAIHNz3x/IkkoMDrKwg/H261/ZP48=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T7/KCW4MI2xVJoBlQ2T0l9zgyJ+ErG77KnmG2SEtPoX3/W/3s3ylml3ujUW3atu+DKr4QKCnY9/ZRtOaxSrEJTdG0hxnvXKAFOx7rOxVzWcfodrbn5xvH7hl45r1PHxMMVVlNC5urp60CQ+LDHYprgg6SctLgBSsMo7jrauB9Fc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LK9ZT56h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LK9ZT56h" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6016DC4AF09; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730702646; bh=SuDEzxxGQ/ta1asAIHNz3x/IkkoMDrKwg/H261/ZP48=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=LK9ZT56hg8TncXc1GQZ/Ks5gEIfvy+KOH47qs1ktMVjcySWgr+dqkIHe7hg1MUhj2 uU55cFE18m5Q4tttbyZszu04b4+wheFJ8CH/5T+oenk7Te2jDvugAtnLhHJj2p0Bof L+0NkIw9lp59wZmOgIgg26BJ486FFaDCY1Aekc3JEkub7EMEhWr8qnqSuM6Yg+VxRL lFtPdrO9ZROz0jXxQEp5OT5TzItugFU9Wi0pswlmew0CwNBINq5YDS5hy/WN627DIa 8CJT1O6Ijsl2x7gtagZo3JZiMjEkQJWxTPBoCyeMykCOMaf/Yv5QZyfCN//EY0FGFs fOh+6cuYUIysw== 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 4D8E7D11185; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Mon, 04 Nov 2024 14:43:32 +0800 Subject: [PATCH v7 02/10] drm/bridge: it6505: improve AUX operation for edid read Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241104-v7-upstream-v7-2-8b71fd0f1d2d@ite.com.tw> References: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> In-Reply-To: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@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 , Hermes Wu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Pin-yen Lin , Kenneth Hung , Pet Weng , Hermes Wu , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730702658; l=1532; i=Hermes.wu@ite.com.tw; s=20241101; h=from:subject:message-id; bh=32P1BrTFeT18E3yzyJHILz0Ri1zpfzlb6udBE3GEmSs=; b=jAs4ALalPFcT/no3nP40m25b5d4wCMZzy9ChzrGptppyfoD/zleahHwKaciyvSguICLiNee66 CacZdXxGEfmA1sLto+u5wJqWVQ1m7IwfxlxbzcRJXLAO7j8jXEfUYg2 X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=FOYYbsP2Nlw6mjB3rLFYSLmAiENzj4AWQly5XTcDuMM= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241101 with auth_id=268 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw 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. Reviewed-by: Dmitry Baryshkov Signed-off-by: Hermes Wu --- 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/i= te-it6505.c index 3272ca6951f2585f9592834869de23ac50ce41a4..9747d7ccf435d536da55c6a3ff7= 9e504b7c724f0 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 =3D 0, request_size; + int fifo_max_size =3D (cmd =3D=3D CMD_AUX_I2C_EDID_READ) ? AUX_FIFO_MAX_S= IZE : 4; =20 mutex_lock(&it6505->aux_lock); - for (i =3D 0; i < size; i +=3D 4) { - request_size =3D min((int)size - i, 4); + i =3D 0; + do { + request_size =3D min_t(int, (int)size - i, fifo_max_size); + ret_size =3D 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; } =20 + i +=3D request_size; ret +=3D ret_size; - } + } while (i < size); =20 aux_op_err: mutex_unlock(&it6505->aux_lock); --=20 2.34.1 From nobody Sun Nov 24 16:21:13 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CF12218D62D for ; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702646; cv=none; b=AmRbOUg+0dblhoo3HHgiB52jFPDBK5Bcv803ZeSBb25LPHBEnewmxhRUfok+JyXDcqiov6+hZmYqqcInH7BDgjgH4FhX8s9Fom9l8JJ+IiUEStWbZB2r1hxpCg750LL/8wTaVPMSk+BPQRUfPf9uvhqXuZW8UelO69fyeZMpqlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702646; c=relaxed/simple; bh=jebMeVHnxHKhzdHUo8lgZOGGKX3f7GBIrJuL6SI9xIc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Cn0Ex39SaiWAtofQE4SsqjN0GSS766kUXwN9ETlQm8GzeeW4vsZpZpxCiIO9KkI5R88oLqGbkbzLnFR/ushTvYTU5avt6EJ9iuhpyewHJTjTlENyfx+h8ejsouzaZy03+0AWxZjXjf1dVXihMXypHHDltHrfwJ6Ry+B5cAEDYl4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Uq6V8Ihm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Uq6V8Ihm" Received: by smtp.kernel.org (Postfix) with ESMTPS id 72464C4CED2; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730702646; bh=jebMeVHnxHKhzdHUo8lgZOGGKX3f7GBIrJuL6SI9xIc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Uq6V8IhmI/nfhDHJTGxnBU8TijQikYASs8X2pAL7ih2k6Q7hIbLxzdQsL0dyIgTDS 9UeJeEmRBESJC4/cdH7IIImeTCqaTDAFJlvsuQfTxyiog1GAmDURhWlNxceU1p/9T7 PYWBQiAJfOE9tfQiiDhnmmvjxIGI5tFlC7LALJ8aj2VZOII9Ve5N3eV9+MXeEYrbPW X/L3yOzMyZ7I4UsT3cHmUpEMvmte2qmikhCb0ypYCaUxwLOoZOwrv6rUuAQWTbfZqA eMnP101kB3adkoB0KuGTjUtOgx1V5/qnunfSiJeRgwD7jR+2B1RrQX1yF4eMM+8uZE LqrmSIV000NUA== 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 63FD2D111B3; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Mon, 04 Nov 2024 14:43:33 +0800 Subject: [PATCH v7 03/10] drm/bridge: it6505: add AUX operation for HDCP KSV list read Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241104-v7-upstream-v7-3-8b71fd0f1d2d@ite.com.tw> References: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> In-Reply-To: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@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 , Hermes Wu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Pin-yen Lin , Kenneth Hung , Pet Weng , Hermes Wu , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730702658; l=3615; i=Hermes.wu@ite.com.tw; s=20241101; h=from:subject:message-id; bh=Qm0Yg8xBTZewdPuvHcs5ADcGIPqmFgB/FG4kqG8Nqvw=; b=Vdbj/KgQsW9ht3RTek7Bd8aNOnnJVm2T9jt3MjZM46NOGiIyDqpfLlK8EFuVsq4rA9bmeyoGU jxJ8gg1DjsCDfP3qVKUAzyV9LOPZvUuOTLg3OaJ9MxUXvfwfeUPvyHu X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=FOYYbsP2Nlw6mjB3rLFYSLmAiENzj4AWQly5XTcDuMM= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241101 with auth_id=268 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw 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. Reviewed-by: Dmitry Baryshkov Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index 9747d7ccf435d536da55c6a3ff79e504b7c724f0..ba37974967767a17b7025595f68= 64f057174efb9 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -19,6 +19,7 @@ #include #include #include +#include =20 #include =20 @@ -126,6 +127,7 @@ #define REG_AUX_OUT_DATA0 0x27 =20 #define REG_AUX_CMD_REQ 0x2B +#define M_AUX_REQ_CMD 0x0F #define AUX_BUSY BIT(5) =20 #define REG_AUX_DATA_0_7 0x2C @@ -324,6 +326,9 @@ enum aux_cmd_type { CMD_AUX_NATIVE_READ =3D 0x0, CMD_AUX_NATIVE_WRITE =3D 0x5, CMD_AUX_I2C_EDID_READ =3D 0xB, + + /* KSV read with AUX FIFO extend from CMD_AUX_NATIVE_READ*/ + CMD_AUX_GET_KSV_LIST =3D 0x10, }; =20 enum aux_cmd_reply { @@ -965,7 +970,8 @@ static ssize_t it6505_aux_operation(struct it6505 *it65= 05, it6505_set_bits(it6505, REG_AUX_CTRL, AUX_USER_MODE, AUX_USER_MODE); =20 aux_op_start: - if (cmd =3D=3D CMD_AUX_I2C_EDID_READ) { + /* HW AUX FIFO supports only EDID and DCPD KSV FIFO area */ + if (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD_AUX_GET_KSV_LIST) { /* AUX EDID FIFO has max length of AUX_FIFO_MAX_SIZE bytes. */ size =3D min_t(size_t, size, AUX_FIFO_MAX_SIZE); /* Enable AUX FIFO read back and clear FIFO */ @@ -996,7 +1002,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it6= 505, size); =20 /* Aux Fire */ - it6505_write(it6505, REG_AUX_CMD_REQ, cmd); + it6505_write(it6505, REG_AUX_CMD_REQ, FIELD_GET(M_AUX_REQ_CMD, cmd)); =20 ret =3D it6505_aux_wait(it6505); if (ret < 0) @@ -1030,7 +1036,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it= 6505, goto aux_op_start; } =20 - if (cmd =3D=3D CMD_AUX_I2C_EDID_READ) { + if (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD_AUX_GET_KSV_LIST) { for (i =3D 0; i < size; i++) { ret =3D it6505_read(it6505, REG_AUX_DATA_FIFO); if (ret < 0) @@ -1055,7 +1061,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it= 6505, ret =3D i; =20 aux_op_err: - if (cmd =3D=3D CMD_AUX_I2C_EDID_READ) { + if (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD_AUX_GET_KSV_LIST) { /* clear AUX FIFO */ it6505_set_bits(it6505, REG_AUX_CTRL, AUX_EN_FIFO_READ | CLR_EDID_FIFO, @@ -1076,7 +1082,8 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *= it6505, size_t size, enum aux_cmd_reply *reply) { int i, ret_size, ret =3D 0, request_size; - int fifo_max_size =3D (cmd =3D=3D CMD_AUX_I2C_EDID_READ) ? AUX_FIFO_MAX_S= IZE : 4; + int fifo_max_size =3D (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD= _AUX_GET_KSV_LIST) ? + AUX_FIFO_MAX_SIZE : 4; =20 mutex_lock(&it6505->aux_lock); i =3D 0; --=20 2.34.1 From nobody Sun Nov 24 16:21:13 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1D1B318DF72 for ; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; cv=none; b=D85EgIp/dC7Ml1/e1KoIdjCfZqMOHCeg9cr8LhuiAfb97pp+2d7OOqo+GLzGQvbb5BtIH6mDSBzfIwzKPxd1guksVaNlYVztQi+D48U2YoD6DfJq/onRDtpQyEqNi30zKXIu710rCIaIDCeu9D92yP4WE+meKmqPs6SSVhYZfSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; c=relaxed/simple; bh=V5YudWXnJ7rHUTU5EwXOV89odpcktqY9hIsiJyNOono=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hdQ0m9e63voN/N7sdoTfdgIhYVS+3qNTcUo1BmOmaKN+wuPdQVnH1FRjt3Ci5cvivdY69aikHla65CZjGBy6q657o3s4YvsEif3IJDHmcEsUbUQyPlI1zLjGYABcjKqjKQYFgHO0Y3wZWqSWKeO0mf8bTYhPTD2+m/Ut5CPDYtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sXZmhw1a; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sXZmhw1a" Received: by smtp.kernel.org (Postfix) with ESMTPS id 85A10C4CED6; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730702646; bh=V5YudWXnJ7rHUTU5EwXOV89odpcktqY9hIsiJyNOono=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=sXZmhw1axFGapV0gBXqiy/0zoNM3gw4ZIZVXAJiJ6hrUmaEUABUrGJTPov9f2EthO TJunML8LsKCU/tXLP4+Yj1eval5qqSrfpRwo8Skkc85x6ZB0CVqvLzcO+nJEXLmFTM CX0Ngd5EmHdYWzZtxVoX6t9v0y5U4FdoXi5QDhKnICh+TSICxPtQZtKaoHwsDh/VoM vQmW2OPP5wwV2zMjBmLY4mDIe+9lbGTmNnvgHKoHC8ny5GwbLyR+gQcUJZ+DUslQD9 cyh14shLX0isbX4fBLU18WDPhCqImpEClEGvnbT5PmOZ84YLo1ZdS5DOn6Hp4s7Rbb cvIA3m3u99G8A== 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 771B5D111AD; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Mon, 04 Nov 2024 14:43:34 +0800 Subject: [PATCH v7 04/10] drm/bridge: it6505: Change definition MAX_HDCP_DOWN_STREAM_COUNT Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241104-v7-upstream-v7-4-8b71fd0f1d2d@ite.com.tw> References: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> In-Reply-To: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@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 , Hermes Wu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Pin-yen Lin , Kenneth Hung , Pet Weng , Hermes Wu , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730702658; l=994; i=Hermes.wu@ite.com.tw; s=20241101; h=from:subject:message-id; bh=LXCX7YKUcq6qewqH/z3sJdCcnXEOYr4Q2Lg8igxzYE4=; b=P+iT0z0dBfYBkX5Foabrt2Xum8ijPioFa24M1Oq18B9ckRPVR4m58R+9YzsklK5GGvUZOw1dP H4tv1W844lmCwy5UwPKTAyMMfgrzVVgvuOgd1bnjoQZcwY2Oj70Bvww X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=FOYYbsP2Nlw6mjB3rLFYSLmAiENzj4AWQly5XTcDuMM= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241101 with auth_id=268 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw 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. Reviewed-by: Dmitry Baryshkov Signed-off-by: Hermes Wu --- 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/i= te-it6505.c index ba37974967767a17b7025595f6864f057174efb9..9a90a36d0421422038b04ad00b2= cb2e326a9cab4 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -298,7 +298,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 --=20 2.34.1 From nobody Sun Nov 24 16:21:13 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1A8BC192B65 for ; Mon, 4 Nov 2024 06:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702648; cv=none; b=e9Uf6y5iQuRO/i9dqdh0l7yI+wfVxu6cBetOeCL17x9VHng21Gfwl4HSyoBD6BhTZ8BFa96c8y9m+eCDAibl3MV4rKO7niyoBbZTnAkblHpA+GAjQqBVqsVNBrPypV3GWEkDo3NgUvzlOajcPOVsvdmGyyEELpFIf+SSUzdV/iw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702648; c=relaxed/simple; bh=O5YKofAFuVF+x8OXZQSiNKkX3T3r8k4gh/EML2qF2tM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bdW7GOStPFVp0OxECVmIc+Q1+dsXc8KesEshJ1aFl9QBQjDxvx+xeXeUJSXa3EM1W27qIBeiDzvzSjo8YSai0pDQqLwNzFY0VsRPQ2DUGXr++KTBdHlbGkhowhdMdfPwnfvThEkuj440tGlnVTpKLs6c7sa4YsPKTM2NbSsHsTw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NSFXhfW1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NSFXhfW1" Received: by smtp.kernel.org (Postfix) with ESMTPS id A8BF0C4CED0; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730702647; bh=O5YKofAFuVF+x8OXZQSiNKkX3T3r8k4gh/EML2qF2tM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=NSFXhfW1N3OXH8zXMWrIa+5aUgeTjrcTy1z6yHPdLhS2RiEdDdxsAAb47Bx2CCRT9 2t0IeFPbYOdLAmXyo6KKrZAu6M5fAcP45oThKhA9b8I7Ct+AcHNoC2a+JHFHEIZLO9 wyqlW3tvSormXJ2N3OXAETgrCKWOy8g547edRabniFLwXM3BCSuQ2BkN5cIXH5w+PB gm/nvKMBfx02x/d0EGZOBC0HPxTQ3AIMQL3mO/265gTmb1Mngv6lr1g0oWdB9nbJpU JC4NaJi2uji9vRC32vLvyetRQKFzWXf6FKpkMZOk8EILc9gSr18Fn/qsqFEqrmCJDm Jm2+GK01E3e2g== 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 9E5B2D111B0; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Mon, 04 Nov 2024 14:43:35 +0800 Subject: [PATCH v7 05/10] drm/bridge: it6505: fix HDCP Bstatus check Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241104-v7-upstream-v7-5-8b71fd0f1d2d@ite.com.tw> References: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> In-Reply-To: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@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 , Hermes Wu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Pin-yen Lin , Kenneth Hung , Pet Weng , Hermes Wu , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730702658; l=1572; i=Hermes.wu@ite.com.tw; s=20241101; h=from:subject:message-id; bh=rnu9ObSyBuaI0l/D8L5MOJqyYmO7JqMRz5DsnO06FUA=; b=C/uXvsj0MrjbvoKC8toRcltBDTz9x/TPWWQjr1q+eFOMvG6C0z9DHyvDOPRmPFzCkygCco2x0 SZzTAThliZeA7E8XyFk/QUX8pQTAA5n9F8V0PNuJp+s1DRDZc/iu4J+ X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=FOYYbsP2Nlw6mjB3rLFYSLmAiENzj4AWQly5XTcDuMM= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241101 with auth_id=268 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw 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 Reviewed-by: Dmitry Baryshkov 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/i= te-it6505.c index 9a90a36d0421422038b04ad00b2cb2e326a9cab4..760eab0b868874f96ccd4d5ec3e= 2f2d4ffb1e41c 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2323,14 +2323,20 @@ static int it6505_process_hpd_irq(struct it6505 *it= 6505) DRM_DEV_DEBUG_DRIVER(dev, "dp_irq_vector =3D 0x%02x", dp_irq_vector); =20 if (dp_irq_vector & DP_CP_IRQ) { - it6505_set_bits(it6505, REG_HDCP_TRIGGER, HDCP_TRIGGER_CPIRQ, - HDCP_TRIGGER_CPIRQ); - bstatus =3D it6505_dpcd_read(it6505, DP_AUX_HDCP_BSTATUS); if (bstatus < 0) return bstatus; =20 DRM_DEV_DEBUG_DRIVER(dev, "Bstatus =3D 0x%02x", bstatus); + + /*Check BSTATUS when recive CP_IRQ */ + if (bstatus & DP_BSTATUS_R0_PRIME_READY && + it6505->hdcp_status =3D=3D 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 =3D=3D HDCP_AUTH_DONE) + it6505_start_hdcp(it6505); } =20 ret =3D drm_dp_dpcd_read_link_status(&it6505->aux, link_status); --=20 2.34.1 From nobody Sun Nov 24 16:21:13 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1E95C18DF7E for ; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; cv=none; b=f/OGVnYuNCLqx+xetZ7VdBRxNQDXu5qLrYH4RqbTS6cHIRJnOw6zMtMch299WSK95MxqkuJkLKRM0KQkgBuqWUVcq6ylGg1sC6eaDocsiUkzoEe9ej+8DwDG8ZalImFBK6FbWBkw0jGyNfKrn4gLf5XJM//+IzGx1FPui6pkBbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; c=relaxed/simple; bh=jR2JMfJCmR1wfBbhPP6zy7q7nwwmkUtFCoBy/b3loG4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XtKIM8PESbNmHYdZWV/GzA/ldobna8nk4VEiQXdCIHjf590cdxecs/KTq553LWIgtBJCB95ZNylpZ8+T4rlqyZn2r2FV70hV9I5fl8+y+1io+uT4pGPk+3K9iBeFrN/uuoWbDtEmw4A73xf4EFcNm957AGGdnZwXhnWrelHK3ws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LAxt+jjM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LAxt+jjM" Received: by smtp.kernel.org (Postfix) with ESMTPS id BD61BC4CED0; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730702646; bh=jR2JMfJCmR1wfBbhPP6zy7q7nwwmkUtFCoBy/b3loG4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=LAxt+jjMikIm0hjB2DMyT/e9Qatz9+6LfDQgpnsUkpqFqpRbF4wlaPvjGFcgObqgD JicTEqiREt/lqgsl7V3kO9UCDtxcw9lgs8Mtl4yW8GYmzCIRla3QoCHrTw4fZpEPxn NHYfwQxYdkYizQhvj5viqJi/FIA551BsWr0/FVEFT/FkTyqWiyxAACYpiwXZWpyUmA PUaLhk2OW8XOOr3PoemVm1ZQ8ye0LAo/XPQ4BZnkcSuZIPY5VDHXnKotsmw0JSHD7h QXSMjTnvW2xJaRbrEvUEbPn3WAK4k4r+v0U6GJUbDwPqnblrJXYwc032r/CdcfmbVq 6JLR4IefUpY7A== 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 B292ED11185; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Mon, 04 Nov 2024 14:43:36 +0800 Subject: [PATCH v7 06/10] drm/bridge: it6505: fix HDCP encryption when R0 ready Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241104-v7-upstream-v7-6-8b71fd0f1d2d@ite.com.tw> References: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> In-Reply-To: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@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 , Hermes Wu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Pin-yen Lin , Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730702658; l=1834; i=Hermes.wu@ite.com.tw; s=20241101; h=from:subject:message-id; bh=sT+HSufURG0ocwd8z5VQGG+kfKlsP8Ww3M5fRH8xXGg=; b=ZH6GYOr4kWn6zBGSHNeEApWJNxLdCuWluDe6uyqVd5OS9UDU2RlwMhZlzDsDCsmX6NfbfD+AZ mhH6cmGfcj8A/7Lo3a/T5eNdGSomVkv5qthhXuOzahJu4aAyyc8MWmg X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=FOYYbsP2Nlw6mjB3rLFYSLmAiENzj4AWQly5XTcDuMM= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241101 with auth_id=268 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw 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/i= te-it6505.c index 760eab0b868874f96ccd4d5ec3e2f2d4ffb1e41c..614fbb6295237708aa5b692de87= ab5548c499da5 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2092,15 +2092,12 @@ static void it6505_hdcp_wait_ksv_list(struct work_s= truct *work) ksv_list_check =3D 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); } =20 static void it6505_hdcp_work(struct work_struct *work) @@ -2473,7 +2470,11 @@ static void it6505_irq_hdcp_ksv_check(struct it6505 = *it6505) { struct device *dev =3D it6505->dev; =20 - 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); } =20 --=20 2.34.1 From nobody Sun Nov 24 16:21:13 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 05E4418D65F for ; Mon, 4 Nov 2024 06:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; cv=none; b=XuaJC5P80Qp1GMYAbCaAGiOjULHerRLUIHadeTt78SRiUE2+w9/F4zL2chGUNe8zEuPh/K+1whRcbJq56qatFfCc7iqxg1qtlLEhmuWborQB/1ioZal2eTjw810CX9w8BsprxyagpHXPURAyf17BsAxmtTa5LPD8mBfT3o8E97M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; c=relaxed/simple; bh=OrW7zJ21stvDnpp/P7e26kdsuNdebpykAQ0uJlts2ec=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Jz2eByVtndaLFiNLSMfaeEKp72Gxv5qfPEirqkNWDQEhwM2Ba62kRNj6SCKsofJB4SPI3UICWVQWkVkr/JUA/L03gczBwgRqA+L5ree8A5BEV0jABj1wbC/dHVjOhgxF0WEITXAiyfPO4UrglgN3I46/oP8Pd9Cwj0OvKmJsdno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pvdEDfPr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pvdEDfPr" Received: by smtp.kernel.org (Postfix) with ESMTPS id D23A3C4CECE; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730702646; bh=OrW7zJ21stvDnpp/P7e26kdsuNdebpykAQ0uJlts2ec=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=pvdEDfPrx5R6YJaDgRPXAXCbVPkob3Rvl4xd3HTbno5wdYndU3olL1sQTdfjfrG3t Ie0tOfLamtMpl5yAzVzD+COqexM4bmUFoPAh6LCmi8hsNK3rUAyjhH+mr9Qugl/AOx H+50GFDMaV6RCwl+QGsLevU+28T/l4KcXPLzM51wlhpgmnoKAMaibyK6756tl702J9 voAYRip0Oy+6IVviwwAe/T6PudbXnwmp9lqU9L25jcu0+UfzDnD/Icd603mIsQufGi 2kBo+HRg+4/h/X12ko70XurFCuR5DaqGDVW9ljexDNGo0BiQ848GYKH/1IvxJ2QMCk wOsiiagF2ENeg== 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 C6538D111AD; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Mon, 04 Nov 2024 14:43:37 +0800 Subject: [PATCH v7 07/10] drm/bridge: it6505: fix HDCP CTS KSV list read with UNIGRAF DPR-100. Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241104-v7-upstream-v7-7-8b71fd0f1d2d@ite.com.tw> References: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> In-Reply-To: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@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 , Hermes Wu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Pin-yen Lin , Kenneth Hung , Pet Weng , Hermes Wu , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730702658; l=3017; i=Hermes.wu@ite.com.tw; s=20241101; h=from:subject:message-id; bh=LkPmWJ3+m9M5J4gwKc6RK5juQw3WKrt44Jh3DJ8DUnY=; b=/4DGNl6gmpJctBFosSW3teRnwAylMwNxDWmHIo/I0uS3ya8Giz7igPIWIDr0M9XMQ/JM+r68N 07XvT2jGbNdBq/0jkfwFWZvcPKkedRW+m5rJQT9Is7PkYfA26gsxVOv X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=FOYYbsP2Nlw6mjB3rLFYSLmAiENzj4AWQly5XTcDuMM= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241101 with auth_id=268 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw 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. Reviewed-by: Dmitry Baryshkov Signed-off-by: Hermes Wu --- 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/i= te-it6505.c index 614fbb6295237708aa5b692de87ab5548c499da5..4ed4899227602a4574a13ffa224= 42dcc4a5c2092 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -1189,6 +1189,37 @@ static int it6505_get_edid_block(void *data, u8 *buf= , unsigned int block, return 0; } =20 +static int it6505_get_ksvlist(struct it6505 *it6505, u8 *buf, size_t len) +{ + struct device *dev =3D it6505->dev; + enum aux_cmd_reply reply; + int request_size, ret; + int i =3D 0; + + do { + request_size =3D min_t(int, (int)len - i, 15); + + ret =3D 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 =3D %d, ret =3D%d", request_size= , ret); + if (ret < 0) + return ret; + + i +=3D request_size; + } while (i < len); + + DRM_DEV_DEBUG_DRIVER(dev, "ksv read cnt =3D %d down_stream_cnt=3D%d ", i,= i / 5); + + for (i =3D 0 ; i < len; i +=3D 5) { + DRM_DEV_DEBUG_DRIVER(dev, "ksv[%d] =3D %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 =3D HBR; @@ -1970,7 +2001,7 @@ static int it6505_setup_sha1_input(struct it6505 *it6= 505, u8 *sha1_input) { struct device *dev =3D it6505->dev; u8 binfo[2]; - int down_stream_count, i, err, msg_count =3D 0; + int down_stream_count, err, msg_count =3D 0; =20 err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_BINFO, binfo, ARRAY_SIZE(binfo)); @@ -1995,18 +2026,11 @@ static int it6505_setup_sha1_input(struct it6505 *i= t6505, u8 *sha1_input) down_stream_count); return 0; } + err =3D it6505_get_ksvlist(it6505, sha1_input, down_stream_count * 5); + if (err < 0) + return err; =20 - for (i =3D 0; i < down_stream_count; i++) { - err =3D 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 +=3D 5; - } + msg_count +=3D down_stream_count * 5; =20 it6505->hdcp_down_stream_count =3D down_stream_count; sha1_input[msg_count++] =3D binfo[0]; --=20 2.34.1 From nobody Sun Nov 24 16:21:13 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5B27A18E050 for ; Mon, 4 Nov 2024 06:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; cv=none; b=rIdSxzuNiltxuu9cgUHEVWKllJe9nUNcTDBmB4/MbWKxRpJIwEsCKojeAGou6ghd3W9+nttnWi9ORP+raeM28+78TgnWPhqzZDY2HKhfPo06g8j/izhrFhLXMwAeqUKZQplS6WKXG1oQA9nfrgXJzZ40AYxlaL6YaZn4I25j23k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; c=relaxed/simple; bh=Zl6JqppBNbMmE/iNTWjkyJ9wCrCrJmqXcVDW5n1uzUE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PgMe70rytuuAUhxJmvCbybbnROmt+6As2ee0dTdTr06WUexeNYCYU9ig06s8of+ShQmmq7JdgQcuunMlzpDHXgd8NYZA7GHZKSb2UpKlA+an9tUMtrtrI1VwC5pMLTMOK3Y4sxTeZYKaAI09SkBNexMvQEKstXLtbeyspWSpNnM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WgEASsS2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WgEASsS2" Received: by smtp.kernel.org (Postfix) with ESMTPS id EF290C4AF0C; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730702647; bh=Zl6JqppBNbMmE/iNTWjkyJ9wCrCrJmqXcVDW5n1uzUE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=WgEASsS2LC2DG/ihtqcBUz9f/HukBNSxv8nOFeffxwfADDeRa4IFinxdm2957xPvT bGNoL0KrNyOAKUDEPk9WE4Q6T30iI99UJYvpe/6qguN/IHRaCSvbgm9Hhe70rxhoha uEAke9ydoZI8CLnmLyiAp+ddK0xphKKRvIxq81CWMYU3T5E4C220JzPe4NaC6HOzrx e9cN1tT1G++7cooUFVPjK3lUsTgXA/LzQohMvfxeDdqWpL1RKyPAduWMc4zH3WaCNk j8zZkbXOnGCncLiPb7t6eVb79pNpHxllfW4xLkDQxkcuhvBPrVf9Y0xhqrBjEMpp0y Up9e8iXSD8LNw== 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 E001BD11185; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Mon, 04 Nov 2024 14:43:38 +0800 Subject: [PATCH v7 08/10] drm/bridge: it6505: fix HDCP CTS compare V matching Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241104-v7-upstream-v7-8-8b71fd0f1d2d@ite.com.tw> References: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> In-Reply-To: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@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 , Hermes Wu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Pin-yen Lin , Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730702658; l=2090; i=Hermes.wu@ite.com.tw; s=20241101; h=from:subject:message-id; bh=ZSAKlMN3TX9Z+Nap4xZYSRAsF5UPHncEdZ0YN4lKi7Q=; b=0RC1LwORg5n2qNKKa8sJE+M5MpcnheMXVmLKiazuSzvFA6rmb+PWeuLh0GWcMbNH7/MOx85P3 1FdmQ1mUfv+ASAarixZchTIpD7edv9+UpmDFOV60Y8+LUosXEP7SeeX X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=FOYYbsP2Nlw6mjB3rLFYSLmAiENzj4AWQly5XTcDuMM= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241101 with auth_id=268 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw 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/i= te-it6505.c index 4ed4899227602a4574a13ffa22442dcc4a5c2092..2b8f208d1e17eebe3287ab0aa71= 180176dd0574e 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2058,7 +2058,7 @@ static bool it6505_hdcp_part2_ksvlist_check(struct it= 6505 *it6505) { struct device *dev =3D it6505->dev; u8 av[5][4], bv[5][4]; - int i, err; + int i, err, retry; =20 i =3D it6505_setup_sha1_input(it6505, it6505->sha1_input); if (i <=3D 0) { @@ -2067,22 +2067,28 @@ static bool it6505_hdcp_part2_ksvlist_check(struct = it6505 *it6505) } =20 it6505_sha1_digest(it6505, it6505->sha1_input, i, (u8 *)av); + /*1B-05 V' must retry 3 times */ + for (retry =3D 0; retry < 3; retry++) { + err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_V_PRIME(0), (u8 *)bv, + sizeof(bv)); =20 - err =3D 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; + } =20 - if (err < 0) { - dev_err(dev, "Read V' value Fail"); - return false; - } + for (i =3D 0; i < 5; i++) { + if (bv[i][3] !=3D av[i][0] || bv[i][2] !=3D av[i][1] || + av[i][1] !=3D av[i][2] || bv[i][0] !=3D av[i][3]) + break; =20 - for (i =3D 0; i < 5; i++) - if (bv[i][3] !=3D av[i][0] || bv[i][2] !=3D av[i][1] || - bv[i][1] !=3D av[i][2] || bv[i][0] !=3D av[i][3]) - return false; + DRM_DEV_DEBUG_DRIVER(dev, "V' all match!! %d, %d", retry, i); + return true; + } + } =20 - DRM_DEV_DEBUG_DRIVER(dev, "V' all match!!"); - return true; + DRM_DEV_DEBUG_DRIVER(dev, "V' NOT match!! %d", retry); + return false; } =20 static void it6505_hdcp_wait_ksv_list(struct work_struct *work) --=20 2.34.1 From nobody Sun Nov 24 16:21:13 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3895E18DF91 for ; Mon, 4 Nov 2024 06:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; cv=none; b=hK+2wRMHqqTFrXB7543VT9h2kGYFU0PXHkKLK0ulv5Fg2Iv6o/Ns6815Ru5JSyr3CHR427ZXzbIwVSsZZnzYMgoTzILDJccZWGrHYwgPIQ2r3KL7P4fWZnQRWRLtqy/GonpmTdENVWuodlhqqYbug/SEciERg4AsfK5dFaHesQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; c=relaxed/simple; bh=v3lSQyy9gXzgX8M13zqUf14k/OSbA7fxqxLe1EaQEtc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X5tTWRCR6aCU3+F+ZzzSFJ8uOk0emwiFok/SqzemFNSmfanwOQuhnDuKkMSEEdj2TNO/+Ntq/LL4+HBwWJzlQzd2F0fYBJVRTAElNCJ6iHzg0pb/OHTR/XKezmmwWiYAGpH4Hi3vpOXxVhH0VhuYe3LHK297Vnwsh/lXIPyosck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o9zvM+o3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o9zvM+o3" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0F1F6C4CED8; Mon, 4 Nov 2024 06:44:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730702647; bh=v3lSQyy9gXzgX8M13zqUf14k/OSbA7fxqxLe1EaQEtc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=o9zvM+o3MizmY2tWs7o0RsHT2TrfH2wa9T6r4/7KiUZ62uZw/eW7Kt/6s71JhNBwg 3Go6Cc7J/DZ1WkY2+/RNetyLgwhHQD/FMbEtaXyP9y7xYXmVFlxLYoPG3oneSyzvnA cGt2/HgYQlgegqoJjnw+14HIOEYxK5PDl+1xxU+4JeRqvdLJL2zSgv6f2aUEGESCPE Wa/XpyM0pspFaB/neXe9OSPvRmJN9xvt9ARuueqoiOTxRGTUL6vkjAyGt6MkezoPXT /z6bQqqq+qIZaXrdI8iQ4j5aim6c4AyukPKWUicNF7FRmN5G7g6TTjWCP7zDVHmABR D85koxr9lgd+Q== 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 06290D111B6; Mon, 4 Nov 2024 06:44:07 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Mon, 04 Nov 2024 14:43:39 +0800 Subject: [PATCH v7 09/10] drm/bridge: it6505: fix HDCP CTS KSV list wait timer Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241104-v7-upstream-v7-9-8b71fd0f1d2d@ite.com.tw> References: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> In-Reply-To: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@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 , Hermes Wu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Pin-yen Lin , Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730702658; l=1723; i=Hermes.wu@ite.com.tw; s=20241101; h=from:subject:message-id; bh=QISr17OTE/349oMqfbcRg7gIss3cy8H02akOrW/SuWA=; b=5wclQJlV2oEcIDMwHjjZwt9btEgTeYh3Wif+2xLf+6CvQ7lDDmauVYlsnjLgZZYm0BKKS2TCE Ihk/KJGMEB3DSfV5wXpAHcvnaPrhxIUgyONBl/+GJs0b07iKDglElcm X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=FOYYbsP2Nlw6mjB3rLFYSLmAiENzj4AWQly5XTcDuMM= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241101 with auth_id=268 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw 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/i= te-it6505.c index 2b8f208d1e17eebe3287ab0aa71180176dd0574e..83e2df618c97f8fe3e59789ffb8= 10ce8639f96bb 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2096,12 +2096,13 @@ static void it6505_hdcp_wait_ksv_list(struct work_s= truct *work) struct it6505 *it6505 =3D container_of(work, struct it6505, hdcp_wait_ksv_list); struct device *dev =3D it6505->dev; - unsigned int timeout =3D 5000; - u8 bstatus =3D 0; + u8 bstatus; bool ksv_list_check; + /* 1B-04 wait ksv list for 5s */ + unsigned long timeout =3D jiffies + + msecs_to_jiffies(5000) + 1; =20 - timeout /=3D 20; - while (timeout > 0) { + for (;;) { if (!it6505_get_sink_hpd_status(it6505)) return; =20 @@ -2110,13 +2111,12 @@ static void it6505_hdcp_wait_ksv_list(struct work_s= truct *work) if (bstatus & DP_BSTATUS_READY) break; =20 - msleep(20); - timeout--; - } + if (time_after(jiffies, timeout)) { + DRM_DEV_DEBUG_DRIVER(dev, "KSV list wait timeout"); + goto timeout; + } =20 - if (timeout =3D=3D 0) { - DRM_DEV_DEBUG_DRIVER(dev, "timeout and ksv list wait failed"); - goto timeout; + msleep(20); } =20 ksv_list_check =3D it6505_hdcp_part2_ksvlist_check(it6505); --=20 2.34.1 From nobody Sun Nov 24 16:21:13 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4E4BA18E02E for ; Mon, 4 Nov 2024 06:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; cv=none; b=B+RTwHNIG+NhNAXFJPGS9GPcw+WgT2gfICnvLI4a2BA1fBE1nI9gEpyOJ0yop50fEGNNqraTIdLIv9BtlKZxmUElRaQ58O/urZSw8t2zggl5CGE8tQEIyqZqXknXvexTkaFYjFP+ungRlfpO1EIYN+MkBr4tdzjuZdqqkGVNrK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702647; c=relaxed/simple; bh=NJj0K2gdXXAJLf7drNqE5H8SvCozOqHpTpJbbKTSkmI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Lf4pEwJm3QaHwxn1VN0dTe+FUSV864MaqFp+Y0wrlLOa4TX4+V/wFtPZXmmWOXQAGL0P60Q6OV4bfabMpOJUYyswWU6LhHcfTwM9Y4fco/0hqV267bNxGggmZK8Tu6UjnE9tM/cuOtAIKLMqzlQ/hwLoOdyNQvQZv8VSw3FiVjA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fra3msms; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fra3msms" Received: by smtp.kernel.org (Postfix) with ESMTPS id 24523C4CEDA; Mon, 4 Nov 2024 06:44:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730702647; bh=NJj0K2gdXXAJLf7drNqE5H8SvCozOqHpTpJbbKTSkmI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fra3msms5YdBzc2coae7HhaOu3fDjRwCIzlBJoxtmGfYt5WDe16E7QAicWS7Njm65 WT5BF7NwKwsSypWlLvBZs8XUkCatqxFTZJ8X6H2ExGuefMXJ3O/GtCoTEeqdEwgzZc Bl0fwtIqrJqXkLGbszTqZXMlb44dzj22ZLwfug+NAcMmyj9FQlVfVLM8gNYdHOQWIa ahHTlslmNHPHRyiBKg3keTd4vfhMueZ5GvMXeDUPgiD42zXuZ7dgXGa016S+wBMxpU qtOpak3NZddM3M1VGh+vRaAs7Z2zbzSxPq4obP7/vc+tL4xSEcUqv/X2/mu6Htjhtq jzcXqZ4JAeHUg== 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 197F0D111B3; Mon, 4 Nov 2024 06:44:07 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Mon, 04 Nov 2024 14:43:40 +0800 Subject: [PATCH v7 10/10] drm/bridge: it6505: add I2C functionality on AUX Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241104-v7-upstream-v7-10-8b71fd0f1d2d@ite.com.tw> References: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> In-Reply-To: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@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 , Hermes Wu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Pin-yen Lin , Kenneth Hung , Pet Weng , Hermes Wu , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730702658; l=6930; i=Hermes.wu@ite.com.tw; s=20241101; h=from:subject:message-id; bh=J4rvU2IuQU84l+7pDQWlWwKvnpve8QmHuGwdiA2w++k=; b=AvxiQg6SF9UmzrBagdxvaSHUrGPFNZNhgSe/rzzrwOSkZmbuqwfgxHxzqsYsAEJwGO8Uv/NbS UQZQjPaYXp/CEOC20KyTlUV1H7l/WxszbWNuMqd4YcRJV2CHFE2q5Yt X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=FOYYbsP2Nlw6mjB3rLFYSLmAiENzj4AWQly5XTcDuMM= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241101 with auth_id=268 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw 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(). Reviewed-by: Dmitry Baryshkov Signed-off-by: Hermes Wu --- 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/i= te-it6505.c index 83e2df618c97f8fe3e59789ffb810ce8639f96bb..c2a846f5d8d9b7251913c82d21f= 7957401e35e5e 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -268,6 +268,18 @@ #define REG_SSC_CTRL1 0x189 #define REG_SSC_CTRL2 0x18A =20 +#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 @@ -303,6 +315,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 @@ -325,7 +339,12 @@ enum aux_cmd_type { CMD_AUX_NATIVE_READ =3D 0x0, CMD_AUX_NATIVE_WRITE =3D 0x5, + CMD_AUX_GI2C_ADR =3D 0x08, + CMD_AUX_GI2C_READ =3D 0x09, + CMD_AUX_GI2C_WRITE =3D 0x0A, CMD_AUX_I2C_EDID_READ =3D 0xB, + CMD_AUX_I2C_READ =3D 0x0D, + CMD_AUX_I2C_WRITE =3D 0x0C, =20 /* KSV read with AUX FIFO extend from CMD_AUX_NATIVE_READ*/ CMD_AUX_GET_KSV_LIST =3D 0x10, @@ -1107,6 +1126,161 @@ static ssize_t it6505_aux_do_transfer(struct it6505= *it6505, return ret; } =20 +static bool it6505_aux_i2c_reply_defer(u8 reply) +{ + if (reply =3D=3D DP_AUX_NATIVE_REPLY_DEFER || reply =3D=3D DP_AUX_I2C_REP= LY_DEFER) + return true; + return false; +} + +static bool it6505_aux_i2c_reply_nack(u8 reply) +{ + if (reply =3D=3D DP_AUX_NATIVE_REPLY_NACK || reply =3D=3D DP_AUX_I2C_REPL= Y_NACK) + return true; + return false; +} + +static int it6505_aux_i2c_wait(struct it6505 *it6505, u8 *reply) +{ + int err =3D 0; + unsigned long timeout; + struct device *dev =3D it6505->dev; + + timeout =3D 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 =3D %X\n", + it6505_aux_op_finished(it6505)); + err =3D -ETIMEDOUT; + goto end_aux_i2c_wait; + } + usleep_range(300, 800); + } while (!it6505_aux_op_finished(it6505)); + + *reply =3D it6505_read(it6505, REG_AUX_USER_REPLY) >> 4; + + if (*reply =3D=3D 0) + goto end_aux_i2c_wait; + + if (it6505_aux_i2c_reply_defer(*reply)) + err =3D -EBUSY; + else if (it6505_aux_i2c_reply_nack(*reply)) + err =3D -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 siz= e, u8 *reply) +{ + int ret, i; + int retry; + + for (retry =3D 0; retry < AUX_I2C_DEFER_RETRY; retry++) { + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_READ); + + ret =3D it6505_aux_i2c_wait(it6505, reply); + if (it6505_aux_i2c_reply_defer(*reply)) + continue; + if (ret >=3D 0) + break; + } + + for (i =3D 0; i < size; i++) + buf[i] =3D it6505_read(it6505, REG_AUX_USER_RXB(0 + i)); + + return size; +} + +static int it6505_aux_i2c_writeb(struct it6505 *it6505, u8 *buf, size_t si= ze, u8 *reply) +{ + int i, ret; + int retry; + + for (i =3D 0; i < size; i++) + it6505_write(it6505, REG_AUX_OUT_DATA0 + i, buf[i]); + + for (retry =3D 0; retry < AUX_I2C_DEFER_RETRY; retry++) { + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_WRITE); + + ret =3D it6505_aux_i2c_wait(it6505, reply); + if (it6505_aux_i2c_reply_defer(*reply)) + continue; + if (ret >=3D 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 =3D 0; + u8 *buffer =3D 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 =3D=3D 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 =3D it6505_aux_i2c_wait(it6505, &msg->reply); + goto end_aux_i2c_transfer; + } + + /* IIC data transfer */ + data_cnt =3D 0; + do { + request_size =3D 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) =3D=3D DP_AUX_I2C_READ) + ret =3D it6505_aux_i2c_readb(it6505, &buffer[data_cnt], + request_size, &msg->reply); + else + ret =3D it6505_aux_i2c_writeb(it6505, &buffer[data_cnt], + request_size, &msg->reply); + + if (ret < 0) + goto end_aux_i2c_transfer; + + data_cnt +=3D request_size; + } while (data_cnt < msg->size); + ret =3D 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 =3D 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) { @@ -1116,9 +1290,8 @@ static ssize_t it6505_aux_transfer(struct drm_dp_aux = *aux, int ret; enum aux_cmd_reply reply; =20 - /* IT6505 doesn't support arbitrary I2C read / write. */ if (is_i2c) - return -EINVAL; + return it6505_aux_i2c_transfer(aux, msg); =20 switch (msg->request) { case DP_AUX_NATIVE_READ: --=20 2.34.1