From patchwork Thu Sep 26 07:47:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu X-Patchwork-Id: 13812988 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 05605CCFA18 for ; Thu, 26 Sep 2024 07:48:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8DAF610EAE0; Thu, 26 Sep 2024 07:48:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ite.com.tw header.i=@ite.com.tw header.b="gAqoFEgH"; dkim-atps=neutral Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB4E410EADB for ; Thu, 26 Sep 2024 07:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=P9wy6oeXKQX7StHiLFpt66e52YBrrEYLDdgs16DgEek=; b=gAqoFEgHvWlm66CBffdCHMCUgi9Igx/SoeG434Jbw+1IVD6c+CL7y27A tfcI/LIkqIpNo236/h3GzTJNy7jAyupqmBVxO9+c8S1xXesa2u9SZZx7m 4yzCYNO3GgacPnHelqRITwJy39CPGC65I1hLvqj190cdWrbWeWwOW1gP0 8hl6XzNpKlNNsfkUBVSN/+yigMlidrZiyu65195cKQxsHI5Ds/mbsO4GB TcVibFJ1V1St5dAqvfPFNBvWyIAxTYgkhTcP1hXIkhVfyOrcGYWZex45H RXq9NRK17+kuRIGiv27TJ/CAd31dTfuDz2adBljkyzTdTeXvV3TOm75t7 g==; X-CSE-ConnectionGUID: bzEVeNe1RcKaV4q3FI3k6w== X-CSE-MsgGUID: 9KuovFHUTI6z46MVkanT4w== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Sep 2024 15:48:17 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48Q7mDw1042910; Thu, 26 Sep 2024 15:48:13 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Sep 2024 15:48:12 +0800 From: Hermes Wu To: hermes wu CC: Kenneth Hung , 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 , Allen Chen , Hermes Wu , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 01/11] drm/bridge: it6505: change aux max fifo size Date: Thu, 26 Sep 2024 15:47:51 +0800 Message-ID: <20240926074755.22176-2-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926074755.22176-1-Hermes.Wu@ite.com.tw> References: <20240926074755.22176-1-Hermes.Wu@ite.com.tw> MIME-Version: 1.0 X-Originating-IP: [192.168.82.6] X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: 5B6422415040F29640A03F5009CC7BCAA4786C444D41136DE96B06F9D2D240A12002:8 X-MAIL: mse.ite.com.tw 48Q7mDw1042910 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu The hardware aux fifo is 16 byte 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 f372c05360f2..28a8043229d3 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 Thu Sep 26 07:47:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu X-Patchwork-Id: 13812990 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 BBB88CCF9E9 for ; Thu, 26 Sep 2024 07:48:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A3E110EADF; Thu, 26 Sep 2024 07:48:32 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ite.com.tw header.i=@ite.com.tw header.b="JLwBQPLn"; dkim-atps=neutral Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by gabe.freedesktop.org (Postfix) with ESMTPS id B28B810EADC for ; Thu, 26 Sep 2024 07:48:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oNkH/s8qpW5E02FCg3VGS4CSNm0HyAesFRq6kHlLN/8=; b=JLwBQPLnc0sIdAyCfHhHNwel1rPPXtJJ1nIpojo1Vs4ivTSjCn8r/a8P on67bEeCqAKTv7Xrq9exTNFHQK0Kkx4S1puFNG8d9hJPVKZTsrs1GQeMy LBWqqHDmyyCX4WyDYc3m8HGUj+Tv7Yi6GyNTVVN4Hd7LBVIwlMI51884m qtTptmeO+kcCa2xY0q35XZanpJ1RnxXdFPF9DI0EeSa43oOQ8g/FnD5Df TtXd++lTD3XDJxTZ/OcrfEyvAiyOFpdwNnc19xGDi2HwB3fb5uCSIWJvz KjRszuphaIrBFjAxScXZ6M8iy2Wud+jaNR9g9ltzO/SdmVAiKemG6eBig A==; X-CSE-ConnectionGUID: OpN1oIcwTUyGD1ppPDhr/g== X-CSE-MsgGUID: Yp/w1hoIS8iVdZcOyumrUA== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Sep 2024 15:48:17 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48Q7mDSX042911; Thu, 26 Sep 2024 15:48:13 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Sep 2024 15:48:13 +0800 From: Hermes Wu To: hermes wu CC: Kenneth Hung , 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 , Allen Chen , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 02/11] drm/bridge: it6505: fix aux operation for edid read Date: Thu, 26 Sep 2024 15:47:52 +0800 Message-ID: <20240926074755.22176-3-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926074755.22176-1-Hermes.Wu@ite.com.tw> References: <20240926074755.22176-1-Hermes.Wu@ite.com.tw> MIME-Version: 1.0 X-Originating-IP: [192.168.82.6] X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: E99080911418C56DF22DDB100D7294E86E782C6E84D879CFEF356C8A8AAD8B572002:8 X-MAIL: mse.ite.com.tw 48Q7mDSX042911 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu The EDID read operation can reach the maximum size of the AUX FIFO buffer. Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 28a8043229d3..b451d3c2ac1d 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -1078,8 +1078,11 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *it6505, int i, ret_size, ret = 0, request_size; mutex_lock(&it6505->aux_lock); - for (i = 0; i < size; i += 4) { - request_size = min((int)size - i, 4); + for (i = 0; i < size; ) { + if (cmd == CMD_AUX_I2C_EDID_READ) + request_size = min_t(int, (int)size - i, AUX_FIFO_MAX_SIZE); + else + request_size = min_t(int, (int)size - i, 4); ret_size = it6505_aux_operation(it6505, cmd, address + i, buffer + i, request_size, reply); @@ -1088,6 +1091,7 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *it6505, goto aux_op_err; } + i += request_size; ret += ret_size; } From patchwork Thu Sep 26 07:47:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu X-Patchwork-Id: 13812989 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 F31CECCFA19 for ; Thu, 26 Sep 2024 07:48:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0C22510EAE1; Thu, 26 Sep 2024 07:48:26 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ite.com.tw header.i=@ite.com.tw header.b="NZ0/c/C0"; dkim-atps=neutral Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB48D10EADD for ; Thu, 26 Sep 2024 07:48:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hqfWlB74d2KyBDsvh5rqVMLxH4BblDUiZngMTqszblM=; b=NZ0/c/C0iogxmG8Q27mSQonsd2+WVd9nHVlpIDsH1dwo0fomE8KmZPtv 4xwhn2vYYRXIrgf3ey7fmItfOFk4ZaR7Kd2WnzYzfsfUtKtNtBjy85Dai Z3bPf71u968xOiSVADwv7QEChppiQ6XRSX8bNWjxPGbVgupQ5Pq4i2hi2 qSMok7sMR678CXoFhFOpUNTeFY9GjKA0iERa0cGsgBgPdZ2RzUXa7h0aW e9j22ttomrFwMnknIIBbhv5mg2AejwGCgM08Bg+50m5M4ZdQPAGSP93Se T12CyYJnvF+OdHMEv2UeQmIGfiX0Hmk8XxmbZs3sqqcaTJSxXdl2XdznW Q==; X-CSE-ConnectionGUID: kcuaWwUWRmSjLcUvuOP6bA== X-CSE-MsgGUID: 12is0OXSTjunyqdccDc03g== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Sep 2024 15:48:18 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48Q7mFIw042912; Thu, 26 Sep 2024 15:48:15 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Sep 2024 15:48:14 +0800 From: Hermes Wu To: hermes wu CC: Kenneth Hung , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Hermes Wu , Allen Chen , AngeloGioacchino Del Regno , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 03/11] drm/bridge: it6505: add aux operation for HDCP ksv list read Date: Thu, 26 Sep 2024 15:47:53 +0800 Message-ID: <20240926074755.22176-4-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926074755.22176-1-Hermes.Wu@ite.com.tw> References: <20240926074755.22176-1-Hermes.Wu@ite.com.tw> MIME-Version: 1.0 X-Originating-IP: [192.168.82.6] X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: D330B8CCA585850E4F136DAFDD23DD0FA37431D0B4C4FB63A2BCB4BA143484D02002:8 X-MAIL: mse.ite.com.tw 48Q7mFIw042912 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu Add aux operaction command which supports read DPCD KSV FIFO with aux fifo. Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index b451d3c2ac1d..0583abdca75f 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -324,6 +324,9 @@ enum aux_cmd_type { CMD_AUX_NATIVE_READ = 0x0, CMD_AUX_NATIVE_WRITE = 0x5, CMD_AUX_I2C_EDID_READ = 0xB, + + /* KSV list read using AUX native read with FIFO */ + CMD_AUX_GET_KSV_LIST = 0x10, }; enum aux_cmd_reply { @@ -965,7 +968,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 aread */ + 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 */ @@ -1030,7 +1034,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 +1059,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, @@ -1079,7 +1083,7 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *it6505, mutex_lock(&it6505->aux_lock); for (i = 0; i < size; ) { - if (cmd == CMD_AUX_I2C_EDID_READ) + if (cmd == CMD_AUX_I2C_EDID_READ || cmd == CMD_AUX_GET_KSV_LIST) request_size = min_t(int, (int)size - i, AUX_FIFO_MAX_SIZE); else request_size = min_t(int, (int)size - i, 4); From patchwork Thu Sep 26 07:47:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu X-Patchwork-Id: 13812987 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 DB757CCFA13 for ; Thu, 26 Sep 2024 07:48:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 37C1D10EADC; Thu, 26 Sep 2024 07:48:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ite.com.tw header.i=@ite.com.tw header.b="BMkQSlN2"; dkim-atps=neutral Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8754210EADC for ; Thu, 26 Sep 2024 07:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ijDiBw7pXE/kYeGlF5Zmeunc5r3macGsFd6fqhWC56Q=; b=BMkQSlN26YwhkthgXEqqIBa9Y6GRPB737NHQ0919IdcFB6hudmjNja3u FpXAFSxZh20XgDr+4domwGYkJrzgbINDxU3rafiMXxjceDnRtlbFdGp// DLBnFfXeec+ZzMFDD9f9+wg4IfLoqIfMuC763aUtiT8CzqMpHAK5X9DkW LicJvP95od3xHvAmbOFV8ZphA5Xb3Sua8E0t0H+JyYx76xwTk7JfcIpjT BdjLrEjv36aVzmauLbquEdfaaUmCU2JbcECSGxsirW0057T4irV2+ocfl XItlZLLXyKptuWyznG8NGheSSLa5U7Vdw34Cr/yI5mC8xachVQH39++LZ Q==; X-CSE-ConnectionGUID: dmXKpNvIQF6+pbVwgppX0g== X-CSE-MsgGUID: lMeR4MaZRK6/wufTFTGGNQ== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Sep 2024 15:48:21 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48Q7mG0I042933; Thu, 26 Sep 2024 15:48:16 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Sep 2024 15:48:15 +0800 From: Hermes Wu To: hermes wu CC: Kenneth Hung , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Hermes Wu , Allen Chen , AngeloGioacchino Del Regno , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 04/11] drm/bridge: it6505: fix aux command write to aux operaction register Date: Thu, 26 Sep 2024 15:47:54 +0800 Message-ID: <20240926074755.22176-5-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926074755.22176-1-Hermes.Wu@ite.com.tw> References: <20240926074755.22176-1-Hermes.Wu@ite.com.tw> MIME-Version: 1.0 X-Originating-IP: [192.168.82.6] X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: 1BF483AF16F2451C787FAEA0B2DF3355A1826589CCA7A56C5E09E5698954C10E2002:8 X-MAIL: mse.ite.com.tw 48Q7mG0I042933 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu The aux control register command is 4 bits LSB only, adding a MACRO to get correct operaction command. Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 0583abdca75f..d1f5220e04a6 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -329,6 +329,8 @@ enum aux_cmd_type { CMD_AUX_GET_KSV_LIST = 0x10, }; +#define GET_AUX_CONTROL_CODE(cmd) ((cmd) & 0x0F) + enum aux_cmd_reply { REPLY_ACK, REPLY_NACK, @@ -1000,7 +1002,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, GET_AUX_CONTROL_CODE(cmd)); ret = it6505_aux_wait(it6505); if (ret < 0) From patchwork Thu Sep 26 07:50:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu X-Patchwork-Id: 13813000 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 2C68ECCF9E9 for ; Thu, 26 Sep 2024 07:50:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A930110EAE5; Thu, 26 Sep 2024 07:50:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ite.com.tw header.i=@ite.com.tw header.b="Q69UuyHn"; dkim-atps=neutral Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF69D10EAE2 for ; Thu, 26 Sep 2024 07:50:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=/MhsEBOD2/Qogtg45F1mT6RHWB7u2J8P93IBSo1/Tok=; b=Q69UuyHnD2IDo8vtQ/OD2Cyq3UJlik3jMuedhrw0MBj1nMpsKL6Ep4ow /Lod+W1hT+gpGy329bJcvxfJb8K/xvnNGiSuYhDyHUaogcZfIjLxZgSYY gANPfv2Htbho82JzIM7zJxx9L0PycP+/Km1MomQbfJ0iMKq/5qNNcmLWO meAfbjd7HluVsxquKCYolXStFSnUvZYWqFSnM+AFHbFWTdAlKRpzSYoQQ xULZ3JwMA12FC1QpvMMh7l3ZOyAcIeubUL0xN8TU9nR6PzIMTmYhMGnxs DcRAVQC5YW8x9T4SLh9JmWgQvEnrbq+rKwJEzEPoHMeIAGFCo86dFch6c w==; X-CSE-ConnectionGUID: Nll7VDqNQ7eWttAhJ8buvQ== X-CSE-MsgGUID: 060e/ZYdRpSraTD221/REw== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Sep 2024 15:50:42 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48Q7obPR044815; Thu, 26 Sep 2024 15:50:37 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Sep 2024 15:50:37 +0800 From: Hermes Wu To: hermes wu CC: Kenneth Hung , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Allen Chen , AngeloGioacchino Del Regno , Hermes Wu , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 05/11] drm/bridge: it6505: increase supports of HDCP repeater ksv devices Date: Thu, 26 Sep 2024 15:50:14 +0800 Message-ID: <20240926075018.22328-1-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [192.168.82.6] X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: EF65523E155F9F62D73D22204B3A2FFE016E29029054F7626C7FB58BD1C9ECA82002:8 X-MAIL: mse.ite.com.tw 48Q7obPR044815 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu A HDCP source shall support max downstream device to 127. Change definition of MAX_HDCP_DOWN_STREAM_COUNT to 127 Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") 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/ite-it6505.c index d1f5220e04a6..5d5ce12cd054 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -296,7 +296,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 Thu Sep 26 07:50:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu X-Patchwork-Id: 13813002 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 6F899CCFA13 for ; Thu, 26 Sep 2024 07:50:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DCD1310EAE7; Thu, 26 Sep 2024 07:50:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ite.com.tw header.i=@ite.com.tw header.b="TNGNeQQf"; dkim-atps=neutral Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by gabe.freedesktop.org (Postfix) with ESMTPS id AD4EE10EAE2 for ; Thu, 26 Sep 2024 07:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pi+QFeWgKpk+/I68ogVRXcsOGmQVhBx1Tx/8xnU0Dqk=; b=TNGNeQQf/PP4bn1p6KTPEFs8B2JMXtPNw+qK1yNaVng3LEojF/uhJzo7 bNw8pTt7PM6lFDZGHu9MbaKY7iTzN8ddadNtxhPRBzfmsEAWgWjio2rIq TdKHa9BImIvxCJu5AxpJvFWp1+v5KiXL0VpkQ4lBQqx5syd1phdyGN4w7 HNSTFCQvxeU4k5y3Jz1Ve/vxtPIQsNsE8rddEw5FWLTI11PiAqdRM6mi8 HSHSZk44kTo27qKKF/HqWtNzWvke6EB3tA9MtJpOkNY6Ruqn3DFdZX2xU nZ7Gef74wJB94OIgL2vb7Nvol3XEjfG6Z9UCN3LmJdvYGeV02R+vcY2xO Q==; X-CSE-ConnectionGUID: qvw8ssHbTxOTe8c7N5IFpg== X-CSE-MsgGUID: mHTnMsGdS/6YJDX4IjdxpQ== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Sep 2024 15:50:42 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48Q7ocuP044816; Thu, 26 Sep 2024 15:50:38 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Sep 2024 15:50:38 +0800 From: Hermes Wu To: hermes wu CC: Kenneth Hung , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Hermes Wu , Allen Chen , AngeloGioacchino Del Regno , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 06/11] drm/bridge: it6505: fix HDCP Bstatus check. Date: Thu, 26 Sep 2024 15:50:15 +0800 Message-ID: <20240926075018.22328-2-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926075018.22328-1-Hermes.Wu@ite.com.tw> References: <20240926075018.22328-1-Hermes.Wu@ite.com.tw> MIME-Version: 1.0 X-Originating-IP: [192.168.82.6] X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: 1E2CC0F2EB62D09B0282AE46C73472B56B4DF3E7C203867C6794392B923BEB652002:8 X-MAIL: mse.ite.com.tw 48Q7ocuP044816 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu When HDCP is activated, A DisplayPort source receives CP_IRQ from the sink shall check Bstatus from DPCD and process the corresponding value. Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") Signed-off-by: Hermes Wu Reviewed-by: Dmitry Baryshkov --- 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 5d5ce12cd054..d2ec3dfc57d6 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 Thu Sep 26 07:50:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu X-Patchwork-Id: 13813003 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 B6953CCFA15 for ; Thu, 26 Sep 2024 07:50:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EBEF410EAE8; Thu, 26 Sep 2024 07:50:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ite.com.tw header.i=@ite.com.tw header.b="hyRhOUne"; dkim-atps=neutral Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC58F10EAE5 for ; Thu, 26 Sep 2024 07:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TL0RVCovDNNgxWowpAkzwVX4O27zCkE2i956LEsHuhA=; b=hyRhOUnetIMHOvyh4i6jBMNeKwk5ojr7YL3vGrp1bb1X2tKyjjO6EdiT hhNup0WIyp2Ir7tqTeWITtvASzJ+e1KDI+2dkBYoJWmq0z8SCnjkFB8Wz +D5KW7mAES8hsZ64yLap/4mYS+Qk911TwhyMvh3b1ZQrz34u2HZhAwe/g 7vw/ePzpFDSbgYfLHFqU3qZZ5qN6+uEevhqqpYWYnOYSazHYfV+U5eHxJ n0n7BBXyaIouY5+LDOd1axlz9OANEerW1OtZrgPqpyo6aZ8gy48qr0QiZ ReYUE8a7KM4ZVNxpG8hjS8vWYSa2bw7aH6rXFVENah0cXl+w5jbOgUXMY w==; X-CSE-ConnectionGUID: kWp+db1uQ1qBHpH0z7guFA== X-CSE-MsgGUID: 3slr1Z9NTY+4Jt19DJ4+Ng== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Sep 2024 15:50:43 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48Q7ocVs044817; Thu, 26 Sep 2024 15:50:38 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Sep 2024 15:50:38 +0800 From: Hermes Wu To: hermes wu CC: Kenneth Hung , 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 , Allen Chen , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 07/11] drm/bridge: it6505: fix HDCP encription not enable when R0 ready Date: Thu, 26 Sep 2024 15:50:16 +0800 Message-ID: <20240926075018.22328-3-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926075018.22328-1-Hermes.Wu@ite.com.tw> References: <20240926075018.22328-1-Hermes.Wu@ite.com.tw> MIME-Version: 1.0 X-Originating-IP: [192.168.82.6] X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: 0EBEA4471AE5B0C61383775D94A830EAC1652369C823F42BDA0FD3BDEE6158032002:8 X-MAIL: mse.ite.com.tw 48Q7ocVs044817 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu When starting HDCP authentication, HDCP encryption should be enabled on the link when R0' is checked. Change encryption enables time at R0' ready. Hardware HDCP engine trigger changes repeater fail to restart flow. Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") 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 d2ec3dfc57d6..82986f28f653 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 Thu Sep 26 07:50:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu X-Patchwork-Id: 13813004 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 ECA2DCCFA13 for ; Thu, 26 Sep 2024 07:50:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 630B410EAE2; Thu, 26 Sep 2024 07:50:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ite.com.tw header.i=@ite.com.tw header.b="TO1TNtER"; dkim-atps=neutral Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7A02410EAE2 for ; Thu, 26 Sep 2024 07:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=w/ao++Yp0+3fQr8zQsya4C9EhmMYQgHyfnmiUjSwEcg=; b=TO1TNtERBcFmcNDIv3JFx7PllK1EftvpQbCh1KyknslKgY8TQwR31z3F 4ZZnOX38002hETZaebstecXDRnxAN41Ml1haSqh/JqOaYveByJw+s5NVU 53Rq6Jik4N9mwXRzJuenM0hMfBUVJIu7rg8KRO48ybTDrDxiIOH98skr0 aF/DWSUrlWp3IsASWedcGDt6QHSBVXHkC1KDC5STsmwm04HdbKDRbw9f2 h/VRuFq6Xgo1eRtmP8hLqFHqaXoohAGEy2jPcM8IPxREmkZUVpdOxwgZv AzALlccyGwWjSxK6edImxDp5S6niNfLR2HpJJza3QWWATZn2hOpXqGqnq Q==; X-CSE-ConnectionGUID: m9GEeuY1SJCJOAcv2y08QA== X-CSE-MsgGUID: TpHQ18T8Q4CkR5fLpHd27w== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Sep 2024 15:50:43 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48Q7odxq044818; Thu, 26 Sep 2024 15:50:39 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Sep 2024 15:50:39 +0800 From: Hermes Wu To: hermes wu CC: Kenneth Hung , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Hermes Wu , AngeloGioacchino Del Regno , Allen Chen , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 08/11] drm/bridge: it6505: fix HDCP KSV list did not read correctly. Date: Thu, 26 Sep 2024 15:50:17 +0800 Message-ID: <20240926075018.22328-4-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926075018.22328-1-Hermes.Wu@ite.com.tw> References: <20240926075018.22328-1-Hermes.Wu@ite.com.tw> MIME-Version: 1.0 X-Originating-IP: [192.168.82.6] X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: 56B4DD55DEE620601EDE7E589AD9E060D9FD9743076137378FEF4F84D86182ED2002:8 X-MAIL: mse.ite.com.tw 48Q7odxq044818 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu When running the HDCP CTS test on UNIGRAF DPR-100. KSV list must be read from DPCD with 5 byte boundary. The original aux operation using AUX_NATIVE_READ can not read back the KSV list correctly. Change to CMD_AUX_GET_KSV_LIST operaction. Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 46 +++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 82986f28f653..143d58ed1b0e 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -1188,6 +1188,35 @@ 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) +{ + int i, request_size, ret; + struct device *dev = it6505->dev; + enum aux_cmd_reply reply; + + for (i = 0; i < len; ) { + 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; + } + + 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 +1998,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 +2023,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 Thu Sep 26 07:50:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu X-Patchwork-Id: 13813001 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 5C6D9CCF9E9 for ; Thu, 26 Sep 2024 07:50:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CBDAB10EAE6; Thu, 26 Sep 2024 07:50:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ite.com.tw header.i=@ite.com.tw header.b="VuLFxpwi"; dkim-atps=neutral Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by gabe.freedesktop.org (Postfix) with ESMTPS id C56BB10EAE6 for ; Thu, 26 Sep 2024 07:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PVCP9MilW7q0jvEx6yj/TAztvdKdeQdCKopzqtpx9To=; b=VuLFxpwizmaOsXbVb5j1AqYj35wPsTgdFXVHaIaNo7XITtKUi589QQwA S9F15yZaKWMgyxFSbidnfH8DUaIOtxc0ijGjeRb5Q6yYdw3V9IilDkX8t HBA5yOFiBJVdAnqb2cei4jyDfEZMsMykWhvhDKfvvyTZPkeX0BMaeW1rQ 5C0ekYkUAiBCyKHGQkaI8vcvCNzJVW6A1N1C/SLRQtXd9FvSxUiOwy56k iXAbpU5zVVm7DlNcfsrtL9Rr6b/TgwfPEymBbqYSa6K+Mg5f3Jh3eJ23D Qdb7kBTGCV9hJsivbKSfz7+JvsMmdMR20FQlWhzoU2hFloqcEYAsJb+WM A==; X-CSE-ConnectionGUID: hzqdQBP2RYCcZyo2BK80ig== X-CSE-MsgGUID: kMUHUBlaT2OCASFKfFNbvg== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Sep 2024 15:50:44 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48Q7odcn044841; Thu, 26 Sep 2024 15:50:39 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Sep 2024 15:50:39 +0800 From: Hermes Wu To: hermes wu CC: Kenneth Hung , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Hermes Wu , Allen Chen , AngeloGioacchino Del Regno , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 09/11] drm/bridge: it6505: fix HDCP CTS compare V matching without retry Date: Thu, 26 Sep 2024 15:50:18 +0800 Message-ID: <20240926075018.22328-5-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926075018.22328-1-Hermes.Wu@ite.com.tw> References: <20240926075018.22328-1-Hermes.Wu@ite.com.tw> MIME-Version: 1.0 X-Originating-IP: [192.168.82.6] X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: F540AC4C29CA116440D3FC655CC1D324E7A8F68FF7EB7EE80D0BDD5B931A56BE2002:8 X-MAIL: mse.ite.com.tw 48Q7odcn044841 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: , 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. Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") 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 143d58ed1b0e..e75bc1575aa8 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2055,7 +2055,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) { @@ -2064,22 +2064,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 Thu Sep 26 07:51:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu X-Patchwork-Id: 13813005 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 37590CCFA13 for ; Thu, 26 Sep 2024 07:51:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B0B9310EAEB; Thu, 26 Sep 2024 07:51:55 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ite.com.tw header.i=@ite.com.tw header.b="asfD+vFa"; dkim-atps=neutral Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1FFE110EAEB for ; Thu, 26 Sep 2024 07:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zrwVDjPIwKWx8PST3o8tOiny0kwm1JgvIxdDZmxFFbU=; b=asfD+vFaMJisSEf8FYPuLc14WC1njwDz1FHA3Xw4Fq6Tg+MpwnFVCQzz iirPkrrqRU0fX1ZuVly35oGfz6ff/onrau+v1LYoo2/OmzNrElgNS2oSY sy46WcvWhNmiIxAlWU8Zg90heRtzX0Kebx6AWwjSjuLk+RQoZLkHan/B2 WqtzD+cmpCPLig7QGDNtoU34WAiAa06/9qfstGkuXR7XA+0Zx60K5HpfG /XotfC8AwtJ7CIheEczLrgUg4r1W2SKpEqM+/eQM1smmRoEJeZa5YHS1E rAaTCLDWodO9NQCeeV+Na2siWwPqVzI44I59Teh6l/w+iSzoQykTflh5n Q==; X-CSE-ConnectionGUID: EALjjDOoTxC+7L80wk1IbQ== X-CSE-MsgGUID: n2NBaRynTN61+suJEW9SEA== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Sep 2024 15:51:52 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48Q7pnLM046831; Thu, 26 Sep 2024 15:51:49 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Sep 2024 15:51:49 +0800 From: Hermes Wu To: hermes wu CC: Kenneth Hung , 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 , Allen Chen , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 10/11] drm/bridge: it6505: fix HDCP CTS ksv wait timer Date: Thu, 26 Sep 2024 15:51:33 +0800 Message-ID: <20240926075134.22394-1-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [192.168.82.6] X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: BCAD1B799F795BD18B91676EA5CCCD6438D6A0284857668DAB9A24287FB284C92002:8 X-MAIL: mse.ite.com.tw 48Q7pnLM046831 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu When running the HDCP CTS test on UNIGRAF DPR-100. HDCP must disabled after waiting KSV for 5s. Consider system ksv work schedules. The original timer has a chance to expire. Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index e75bc1575aa8..22d9bec3faea 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2093,7 +2093,8 @@ 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; + /* 1B-04 fail, wait to long to Stop encription(5s->3s). */ + unsigned int timeout = 3000; u8 bstatus = 0; bool ksv_list_check; From patchwork Thu Sep 26 07:51:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Wu X-Patchwork-Id: 13813006 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 960C2CCFA13 for ; Thu, 26 Sep 2024 07:52:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B78710EAEC; Thu, 26 Sep 2024 07:52:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=ite.com.tw header.i=@ite.com.tw header.b="qMa568xh"; dkim-atps=neutral Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by gabe.freedesktop.org (Postfix) with ESMTPS id E6E2310EAEB for ; Thu, 26 Sep 2024 07:51:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VQfTwvkp0mFLo1ynhN8FPICXctvCBB4Zz0ztlO9KQC8=; b=qMa568xh7ubTaH1bmpwJWBJO6KZzdx6ljtLUYmgC6xxoLeDFbV0BfH1O KehVIAcO8f/Kjece7k0x8efi5w4SSSH1uvnpYMTvpzGTSpSMrz3H0e9RR HP635e8eGBHZorkMzKIo2oNKxBS1qhKuWdlXMg8KlXZ9jk9xVYNCD81jB IBH1qDOkU18UVV0uKbSh4+Y5DmfZz8+vnU5k+17omCXi4cdVutAtBa5mr Z93LXKyGcHMJ0NbPjXTkoEDbSvb4rviKrLVRVJ5ILjYwGE4d2ho2wHTIk Czt6QGkyCbAgFCN7km4kbNgL+O9MqD6JpDf34c0ut82l88cQhRXT8bvRy g==; X-CSE-ConnectionGUID: bY56xvkyQ7qWq0mOakwiIg== X-CSE-MsgGUID: 4SY1B6hTRnGX9/ZtWQq7vw== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 26 Sep 2024 15:51:53 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48Q7pnXQ046832; Thu, 26 Sep 2024 15:51:49 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Sep 2024 15:51:50 +0800 From: Hermes Wu To: hermes wu CC: Kenneth Hung , 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 , Allen Chen , Hermes Wu , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 11/11] drm/bridge: it6505: Add aux i2c functionality Date: Thu, 26 Sep 2024 15:51:34 +0800 Message-ID: <20240926075134.22394-2-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926075134.22394-1-Hermes.Wu@ite.com.tw> References: <20240926075134.22394-1-Hermes.Wu@ite.com.tw> MIME-Version: 1.0 X-Originating-IP: [192.168.82.6] X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: 68212C2942757DA82E36FA68BA6F93906F1C1EC17AC85C70E7C72A95EFD9B8652002:8 X-MAIL: mse.ite.com.tw 48Q7pnXQ046832 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Hermes Wu Add aux-i2c operaction in order to support the MCCS function. Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") 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/ite-it6505.c index 22d9bec3faea..95a156ff4790 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -266,6 +266,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 @@ -301,6 +313,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 @@ -323,7 +337,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 list read using AUX native read with FIFO */ 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; + 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 */ + for (data_cnt = 0; data_cnt < msg->size; ) { + 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], + equest_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; + } + 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: