From patchwork Sat Sep 7 05:54:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 13795090 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B2369CD4846 for ; Sat, 7 Sep 2024 05:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=qj67ertlQRTeftmw+g9h4C2AnGK6C33+Vq5AG+IOQ2c=; b=HLTpr9MJXnmgIxSCZEv8QmwyP2 HUR4i6EEThAHOsWjS0Ke2hX1mQFwbDdZ76H/ENzKuZtvkYbXKOuxfpKm9ucZYoWAGZXgKBzxP6j08 CZCBdSVLExW2Us5BVHaojKUJPtyNp6sQFrMDTG/4P1gaenNhQ5PvehgsctUoC+1T7aGx2BTeetjlX maGzsgO4usmAhV3jt1Dhz80a83dTryrFWl1UTvXq8BYJZ/E0QtAALzuY/JnIbqv4Zb7KdhmOSAzVV bUbOsrYwhsMhJ/oPPFGjPD/k8f3/Mcf58paBlG3Ww9bJ0YBwMubFFhVuCfdEZX0udrB0hKbTtSbnM hFqWt0CQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smoQT-0000000ERUg-2cko; Sat, 07 Sep 2024 05:56:01 +0000 Received: from submarine.notk.org ([62.210.214.84]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smoPS-0000000ERP8-4AOu for linux-arm-kernel@lists.infradead.org; Sat, 07 Sep 2024 05:55:01 +0000 Received: from gaia.codewreck.org (localhost [127.0.0.1]) by submarine.notk.org (Postfix) with ESMTPS id AB4DC14C1E1; Sat, 7 Sep 2024 07:54:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1725688491; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qj67ertlQRTeftmw+g9h4C2AnGK6C33+Vq5AG+IOQ2c=; b=q3O591lE2JGBwdtdtSQntarN2ZlH/P1P3gKgDcxSXQEEQc9LNmyKwIaaBIssWoBYPHvTFy 3zJwvtJFNNpm8t+gcrfv9bnJ7VlXXcHhNL4xSaJX3aIXo+GZhCEj46Ybn5AnamgdC5Evz8 Y+GiT9apL96eIU0cdS6rvt1A9QmD//UR4hkGY7J1QkmJlDYaRFZnD5VXUj7TFFWbPXx7/t 1SPqrofM/N9ewj4zWf32a/xf7RctM4cgi8I7/rJPKGwN0eF3yJAxqzDsYp8CR8rjZSey0/ skv5TflnSFlduQaMa50hrsCiDwEUzkQZA+To0SmhbQw+HrhjBqRfkBpv9sCD+w== Received: from [127.0.0.1] (localhost.lan [::1]) by gaia.codewreck.org (OpenSMTPD) with ESMTP id 6cf0701c; Sat, 7 Sep 2024 05:54:42 +0000 (UTC) From: Dominique Martinet Date: Sat, 07 Sep 2024 14:54:33 +0900 Subject: [PATCH v2] drm/bridge: imx8mp-hdmi-tx: allow 0.5% margin with selected clock MIME-Version: 1.0 Message-Id: <20240907-hdmi-tolerance-v2-1-b9d7abd89f5c@codewreck.org> X-B4-Tracking: v=1; b=H4sIAJjq22YC/zWMwQ7CIBAFf8XsWRqgNFRP/ofpgcAqGwUUsNE0/ Xexibc3L5lZoGAmLHDcLZBxpkIpNpD7HVhv4hUZucYguVT8wDXzLhCr6Y7ZRItMubHnWhk1CA1 NemS80HsLnqfGnkpN+bP1Z/F7/ynFx17wvhNy0GrkTDCXAkV6vrALJleKWE+mtnljFa2PqbMpw LSu6xdNlPD1tgAAAA== To: Liu Ying , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: Adam Ford , Lucas Stach , Frieder Schrempf , dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dominique Martinet X-Mailer: b4 0.14-dev-87f09 X-Developer-Signature: v=1; a=openpgp-sha256; l=2120; i=asmadeus@codewreck.org; h=from:subject:message-id; bh=nqr2dM1v6KRqxdCBlCHE8iSEaSRxPOverS1W33lMLzI=; b=owEBbQKS/ZANAwAIAatOm+xqmOZwAcsmYgBm2+qiwNG20vIXdu+YEeULa01ttlJy2QSvC7+R+ q5lR89eNZCJAjMEAAEIAB0WIQT8g9txgG5a3TOhiE6rTpvsapjmcAUCZtvqogAKCRCrTpvsapjm cCf/EAC4hi6ChKZlBaMMneNhA2qE4PdW2Keg3zZYWMKMWodNjPR+YBT6tLWWHh7AanTLVUyRzaV RdNbsaIL3GBy3Z7IGQ5lQeESlFZ9A9TMOQf8UxEgNPL4bd/oWyE1toTD8nyRqzjNdqjdfBf+iw1 zv/TuvyicWWBKTSj9QNmJc7JQD42fbSMmsEhDZ0PSjViXNx7ZW9mqtLv/OkNePmqYqnNzz08T+v 8V7DxK9Fpf6EH83bJFrJoZ0naeKb5W5UQ9uhCbSsxmYaowdt1ddwLrv+ZuoAvZqumcuEgVbwQYf 3cZdJ0f+hvRtXzT8K1bLCJnk5yuFYHquQE/B4Jytol6LWsf+4igOtrQh3QW/DP+896lV7roSmHW WGBl7yQ1kb63VwlEG6/tvkUYs5z+vKHJpX4VW3GF62qTespjQ9aykP0fUuEKIcockq3jI+WEZev F3l2a/WmXIArf1jA/15TkPtc9AaB3zYrrBf2RJ7OGnx2ecX8Hxaao+nBD3KMNwwPi6lgDXwFauB pTLGt6Xbr38u3xtGbqjerCN+Ri7B2LQADXd6GYDhTeT5Gy0MUOYvs+ANVaXqSdvlj5d9q1kGKpe nuu5hqzt5ZGR7JAm5oHlZi+AwWKlxfqJ165Eg+PtClAPPzxhDXwFTMCKw8/cjMQnhsAU6Mwak1R m88KRhuEw3Hjlaw== X-Developer-Key: i=asmadeus@codewreck.org; a=openpgp; fpr=B894379F662089525B3FB1B9333F1F391BBBB00A X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_225459_488649_7B2FE8D3 X-CRM114-Status: GOOD ( 10.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Dominique Martinet This allows the hdmi driver to pick e.g. 64.8MHz instead of 65Mhz when we cannot output the exact frequency, enabling the imx8mp HDMI output to support more modes Tested-by: Adam Ford #imx8mp-beacon Reviewed-by: Frieder Schrempf Tested-by: Frieder Schrempf Signed-off-by: Dominique Martinet Reviewed-by: Neil Armstrong --- Changes in v2: - Improve comment about the tolerance - Link to v1: https://lore.kernel.org/r/20240904083103.1257480-1-dominique.martinet@atmark-techno.com --- drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- base-commit: 67784a74e258a467225f0e68335df77acd67b7ab change-id: 20240907-hdmi-tolerance-4d83074a4517 Best regards, diff --git a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c index 13bc570c5473..200d65184159 100644 --- a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c +++ b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c @@ -23,6 +23,7 @@ imx8mp_hdmi_mode_valid(struct dw_hdmi *dw_hdmi, void *data, const struct drm_display_mode *mode) { struct imx8mp_hdmi *hdmi = (struct imx8mp_hdmi *)data; + long round_rate; if (mode->clock < 13500) return MODE_CLOCK_LOW; @@ -30,8 +31,14 @@ imx8mp_hdmi_mode_valid(struct dw_hdmi *dw_hdmi, void *data, if (mode->clock > 297000) return MODE_CLOCK_HIGH; - if (clk_round_rate(hdmi->pixclk, mode->clock * 1000) != - mode->clock * 1000) + round_rate = clk_round_rate(hdmi->pixclk, mode->clock * 1000); + /* imx8mp's pixel clock generator (fsl-samsung-hdmi) cannot generate + * all possible frequencies, so allow some tolerance to support more + * modes. + * Allow 0.5% difference allowed in various standards (VESA, CEA861) + * 0.5% = 5/1000 tolerance (mode->clock is 1/1000) + */ + if (abs(round_rate - mode->clock * 1000) > mode->clock * 5) return MODE_CLOCK_RANGE; /* We don't support double-clocked and Interlaced modes */