From patchwork Wed Sep 4 08:31:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 13790081 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 B7CEACD3431 for ; Wed, 4 Sep 2024 08:39:11 +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:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=wl5lFlZZmqmzzNDLDZabcElQI0pBWjUywY0vrZnCNgA=; b=NfBp2wCbGwCG8py7rNSOd+pxUc HEhxT9b/l5exlQw0JQ5WukXWRxcvQgV+OhptosmTndC1YMaGSdsH4uddt6auwux8Z+vxlWu0g5rL8 3lbpv/ED7+yHmuy6X+wivHN6m0xxIM8AnZ6DEzdM2aTgT7AemndzRbofkSfi51vB5uhMvwUVhLoR9 ACERdkcRwSmKcA+HabbihqUmB/3gC5ezZb/zuAV1xrOn7H9sS0MmwCHEqbW9KDrhdNol0d+sYE6Eu lWdI+umePCxdkJbNMLdIx9RlV6tRYnUdi+z6+p8gGiS0bZUvVU1coRq2kHPjkZq+2shS6pL/myBQs 8Kmzm+Xw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sllXY-00000003SMw-1XU3; Wed, 04 Sep 2024 08:39:00 +0000 Received: from gw2.atmark-techno.com ([35.74.137.57]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sllQ7-00000003Poy-0kVe for linux-arm-kernel@lists.infradead.org; Wed, 04 Sep 2024 08:31:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=atmark-techno.com; s=gw2_bookworm; t=1725438677; bh=12N3q46XQiecPb2oufmrGICQCBcT5ecdudDGcuTf44E=; h=From:To:Cc:Subject:Date:From; b=S0fQW4Z6i/OgBYUCChLy6U61Iaj4/VONcrY2HG9h2Y95UM4I87RVYUjcrT7MGCwE7 o06Ghj4yb1GwjjXoXsdXcoGnYe4aiRrP0e1VBgl0yQdZz5Z8+to7g8g+AsbOnxAYMW X5+facao5fPLUrbOyrLh43faSH15UGexYm80H5CKtsP5uvM6cURG4a+Jzcqn0oIGQS tJD4XTq6SwuXgRyHhRzP1sVcC5K4Mx/iWDKW5yZRT/Ll29vo0o3qNe1bm4UWtcAPee w6hdu+N3HVEjkPgYekuH0RLvbZDbgMJ5HAmtIHNSRbsGgLi0rN2NcBBKnqyik4zdhE mwANDj0ZGXDOQ== Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id D062E680 for ; Wed, 4 Sep 2024 17:31:17 +0900 (JST) Authentication-Results: gw2.atmark-techno.com; dkim=pass (2048-bit key; unprotected) header.d=atmark-techno.com header.i=@atmark-techno.com header.a=rsa-sha256 header.s=google header.b=fG9P0g/i; dkim-atps=neutral Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 712303B1 for ; Wed, 4 Sep 2024 17:31:15 +0900 (JST) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2039ce56280so68797435ad.3 for ; Wed, 04 Sep 2024 01:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atmark-techno.com; s=google; t=1725438674; x=1726043474; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wl5lFlZZmqmzzNDLDZabcElQI0pBWjUywY0vrZnCNgA=; b=fG9P0g/iWjYVL+p0m5pS4EQX9bv5ZM7btIQKMZ9YbFRmcrl0wJoCNFkzR1ZGoSl3NG dPQ4qeDXP2RRGtgZnUfiGyGv4t9KdjSKNBnGKFx+J7efrECyJuvAMcLeNgL9svpJCD9K yMWJl5cLl0gATw3vzrBipWoh9HddQ+ob8+CE2u4GTA2Gmk8zTA12/y4Sm5/vWWOSPMDg 6LQWhRyaEnZR/uToicjfQlvB8a4S9ScJ9381pv2Bwbz+/JiP3vrgznoF1G3p77ifM4qo YFI0Onx9h3yaeR/deVgOhzRFVCmqXdhSG2f1iyCLryyFK3uDhKMaXNDBZUE9VsJSoKL5 Cdew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725438674; x=1726043474; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wl5lFlZZmqmzzNDLDZabcElQI0pBWjUywY0vrZnCNgA=; b=vhlcfTw44JHeyQ8I5nK0QKmnZJ1IHItzFJVMQP9DtCxBvByDdeBvtOo8H3x479cM7D f7nHof2Pl0UhfeF25f8fqFnt8PnaD6v95FzlUVLmyE3eaOOTv/9salVMgdCzpFLN55gh MKuPr0fvDZ3vkhetb0Sx2fe1Sl4quvmtz1CJKxM+CSndWNyAcKF1H4/4enJP0sleGGYQ DoyFEw6CO17AchPmS6vmQWCYDRsQnDAzcq/eRdbPp9zjAR/Cu9oJiSf9eOfMQ7CdQdfs S1ZD3XJogpjpmchOPWSKCq8BuDjlCPG7iQADuDdEekY/rQgWkebEB9TlvaNSTmItvOkC Pg+w== X-Forwarded-Encrypted: i=1; AJvYcCVFItI+puJzrjBncUTMU8EkJNDD3aqi4NdX3Fii2hwHdeFHnVyyxhxm7dPQNu5vPmEs0IP48EUIjlDlBI4lHrXG@lists.infradead.org X-Gm-Message-State: AOJu0Ywpmm7beTC/nFTELGHThw+S3my4ty7HEoBqz5aeLT2kp9uOqxRO JbfasdAODAWH/CA/jhNHmR0kHFgnv7GGwGay3s+h3zvN/W80vbJVuYrKFxsBphD8efNOmzl6QW8 uK/lJmU9kKWV2wiUbHzsP6vEG++/hrxzM30gcLhdPmdRD/o4rz//Vd90c4Ueg7P9a0JgRDpf16w == X-Received: by 2002:a17:902:d2d0:b0:205:5544:bad6 with SMTP id d9443c01a7336-20584230d75mr94740775ad.55.1725438674423; Wed, 04 Sep 2024 01:31:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgJbK93rPoTGn7e+5VtWYSo3ES6TsSkat4XXudfYHMjSL/FnAwD5lW7dBeTsvIE7zMeiGN1A== X-Received: by 2002:a17:902:d2d0:b0:205:5544:bad6 with SMTP id d9443c01a7336-20584230d75mr94740425ad.55.1725438674064; Wed, 04 Sep 2024 01:31:14 -0700 (PDT) Received: from pc-0182.atmarktech (117.209.187.35.bc.googleusercontent.com. [35.187.209.117]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206ae968f78sm9198335ad.119.2024.09.04.01.31.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Sep 2024 01:31:13 -0700 (PDT) Received: from [::1] (helo=pc-0182.atmark.tech) by pc-0182.atmarktech with esmtp (Exim 4.96) (envelope-from ) id 1sllPz-005H8O-2o; Wed, 04 Sep 2024 17:31:11 +0900 From: Dominique Martinet 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 , Dominique Martinet , dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/bridge: imx8mp-hdmi-tx: allow 0.5% margin with selected clock Date: Wed, 4 Sep 2024 17:31:01 +0900 Message-Id: <20240904083103.1257480-1-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240904_013119_349552_A5E4B250 X-CRM114-Status: GOOD ( 14.75 ) 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 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 Signed-off-by: Dominique Martinet Reviewed-by: Frieder Schrempf Tested-by: Frieder Schrempf Tested-by: Adam Ford #imx8mp-beacon --- This completes the patch series sent by Adam Ford here: https://lkml.kernel.org/r/20240904023310.163371-1-aford173@gmail.com and makes the cheap screens we recommend work with our imx8mp board without further kludging. drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c index 13bc570c5473..9431cd5e06c3 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,9 @@ 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); + /* accept 0.5% = 1/200 = 5/1000 tolerance */ + if (abs(round_rate - mode->clock * 1000) > mode->clock * 5) return MODE_CLOCK_RANGE; /* We don't support double-clocked and Interlaced modes */