Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp637379rdd; Tue, 9 Jan 2024 15:15:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhBve+lahLuzxV+cdO+SRcdej8nzGSDX4Uy4Us4NO9qH4F3VonkJtSPY/H3FHTgoCdHXtS X-Received: by 2002:a05:6a00:6a05:b0:6d9:dfeb:b68e with SMTP id hy5-20020a056a006a0500b006d9dfebb68emr192782pfb.38.1704842124585; Tue, 09 Jan 2024 15:15:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704842124; cv=none; d=google.com; s=arc-20160816; b=F89vazkrcU0k0hwbiSrR1zVc3wxX9DWBVd2sHpVoG7kTd/vhI2orlZqBu91595UTSp H3wpaC4v7/G8L/yjGJzTqXsIKkyqYwtFJvyuWrWZDvkeBryVBXSonOGgc9YwUyHmQdre i5iPrtqrDxR2JoAqgR4Ldmc9pLdKGLWCMXU/hfZ+TvSzjY9xxuBabNbdsnZg/baScpY8 Ek2S2Lfa4WRbC1yPLFVpouaRYVV/d1asvLcKCSfaagNdkVFPXIc/4vCx3leNUvNky++q tY5u8T95fTswN33QXX5sbHE/Ly1L+xdrNre7CrJrTm6Uvfwy/X8KvXFs4xzWZbtIAfny QSNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=SB32//xbcW4q0bnp0pdqAtTjcsxtx9ia49ME4uFhsuI=; fh=X14P1r/SkKVqghV+0DSQ3KzRmQc9w36Ntylgx1JAqqk=; b=0vAO7sHmEbrVKw2dOXDUFD1BMJSGQhaaGItf3hazHt9SEjNF8nsGkpaSWMWX98fWb1 JMZWGHC1s+gj5/4HB0W1tsoD45PinkjzxWLHb2jaDDXISAXta3X90M2VBkvfzahJxUpC m7EIhulm1/k9nkglNI5W55vGJW1sC/b/TEB3ClV1hhGBl64IC4GahQph9U5Rw9c1BWmp 4oSQGCJDNynw+exVjzB+hJRwVorhSuidyd9/ksvh6bdn14fORNLmE7I3rMnWY/s2PhEA 5A1WydTLvD3Hhq8U/jM81IXKzCDALZVYCBATrPrxqBwEQ1/yGFi+U1pBF7KWkDyvh6Kv /RPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=giEdhK26; spf=pass (google.com: domain of linux-kernel+bounces-21522-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21522-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j17-20020a63e751000000b005cdfa675225si2227963pgk.833.2024.01.09.15.15.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 15:15:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21522-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=giEdhK26; spf=pass (google.com: domain of linux-kernel+bounces-21522-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21522-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 420C4285A7D for ; Tue, 9 Jan 2024 23:15:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59B3D3EA88; Tue, 9 Jan 2024 23:07:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="giEdhK26" Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 022F83EA74 for ; Tue, 9 Jan 2024 23:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-40e4d1e0e5eso15182375e9.3 for ; Tue, 09 Jan 2024 15:07:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704841630; x=1705446430; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=SB32//xbcW4q0bnp0pdqAtTjcsxtx9ia49ME4uFhsuI=; b=giEdhK26zqyzqw9zYaEOAPE7nzqp1A0cd/Z4R14GIefyFZZ7hrOf8XRjrpskX/ZLMu +T8xPsLDtepQM5gtpNupCcQvrFbSqhLTn2OBefcrXNifZc9uKtCScz8b5vHSS39hq1Mh rgK/1faOnZdBsTlYR6MT02PQu2Ca5+9kodpcgx7F/kZUWYpdJt972r9I57q1HJJgzns4 rmJWvZxONtFMdYxvJ2FnfBPqQ05b2QxvCCUtUNLqsFz+oK8VzfeYe9wNCahQvsd8QNZE MOunrENzGD1qEYq7dEkTtBnhbwUn/ire0LdlQHxZLUO3OBYRVsUs9fAybZE4smST5Kjo J6gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704841630; x=1705446430; 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=SB32//xbcW4q0bnp0pdqAtTjcsxtx9ia49ME4uFhsuI=; b=MM1vz3RRHX9YwEvj3pMEEu6lyZ++ukmCu/8EKddY+L3WIWAumtQ39/iKmCDJngEsnD e5VosiDCXgz5o/jDW/antmUgzPGuEPy5hf1mHuqx64TKRg2GzZbMre5W+P/51+WxLpY0 3SQH1dXzcndPdfccALx1dkmjKnN9XQMDEC/terivsH1Mal08ghvJo3xMrmIywFAmEpkR XCfQ5K9n6T24+KNm1kO0eQHn6itSq9rOZSZB+MmXfhmmLsrbbBWJ3QWyy+2mv2pD1uO4 5yc/hoigiK60WuOn/WZpQcSC5aZDZ4DWMdw/Jx5KTLiqjDiOqkRgyu7DeEWPvRO8vWdG Dnzg== X-Gm-Message-State: AOJu0YzZBLsPWrsgec28V0jk/tqJ7P48K5sGPdwTO0/MtG6+Ih6ag7Eo C3YbykE3CipBSRdS7UgAyjE= X-Received: by 2002:a05:600c:3c8b:b0:40e:53f4:f979 with SMTP id bg11-20020a05600c3c8b00b0040e53f4f979mr22910wmb.164.1704841629893; Tue, 09 Jan 2024 15:07:09 -0800 (PST) Received: from toolbox.. ([87.200.95.144]) by smtp.gmail.com with ESMTPSA id z10-20020a05600c0a0a00b0040e486bc0dfsm54021wmp.27.2024.01.09.15.07.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 15:07:09 -0800 (PST) From: Christian Hewitt To: Neil Armstrong , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Christian Hewitt Subject: [PATCH] drm/meson: vclk: fix calculation of 59.94 fractional rates Date: Tue, 9 Jan 2024 23:07:04 +0000 Message-Id: <20240109230704.4120561-1-christianshewitt@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Playing 4K media with 59.94 fractional rate (typically VP9) causes the screen to lose sync with the following error reported in the system log: [ 89.610280] Fatal Error, invalid HDMI vclk freq 593406 Modetest shows the following: 3840x2160 59.94 3840 4016 4104 4400 2160 2168 2178 2250 593407 flags: xxxx, xxxx, drm calculated value -------------------------------------^ Change the fractional rate calculation to stop DIV_ROUND_CLOSEST rounding down which results in vclk freq failing to match correctly. Fixes: e5fab2ec9ca4 ("drm/meson: vclk: add support for YUV420 setup") Signed-off-by: Christian Hewitt --- I'm unable to give a better mathematical description of the fix as I can barely read code. The change was inspired by [0] which I chanced upon while looking at how other dw-hdmi drivers handle fractional rates. [0] https://github.com/torvalds/linux/commit/4f510aa10468954b1da4e94689c38ac6ea8d3627 drivers/gpu/drm/meson/meson_vclk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_vclk.c b/drivers/gpu/drm/meson/meson_vclk.c index 2a82119eb58e..2a942dc6a6dc 100644 --- a/drivers/gpu/drm/meson/meson_vclk.c +++ b/drivers/gpu/drm/meson/meson_vclk.c @@ -790,13 +790,13 @@ meson_vclk_vic_supported_freq(struct meson_drm *priv, unsigned int phy_freq, FREQ_1000_1001(params[i].pixel_freq)); DRM_DEBUG_DRIVER("i = %d phy_freq = %d alt = %d\n", i, params[i].phy_freq, - FREQ_1000_1001(params[i].phy_freq/10)*10); + FREQ_1000_1001(params[i].phy_freq/1000)*1000); /* Match strict frequency */ if (phy_freq == params[i].phy_freq && vclk_freq == params[i].vclk_freq) return MODE_OK; /* Match 1000/1001 variant */ - if (phy_freq == (FREQ_1000_1001(params[i].phy_freq/10)*10) && + if (phy_freq == (FREQ_1000_1001(params[i].phy_freq/1000)*1000) && vclk_freq == FREQ_1000_1001(params[i].vclk_freq)) return MODE_OK; } @@ -1070,7 +1070,7 @@ void meson_vclk_setup(struct meson_drm *priv, unsigned int target, for (freq = 0 ; params[freq].pixel_freq ; ++freq) { if ((phy_freq == params[freq].phy_freq || - phy_freq == FREQ_1000_1001(params[freq].phy_freq/10)*10) && + phy_freq == FREQ_1000_1001(params[freq].phy_freq/1000)*1000) && (vclk_freq == params[freq].vclk_freq || vclk_freq == FREQ_1000_1001(params[freq].vclk_freq))) { if (vclk_freq != params[freq].vclk_freq) -- 2.34.1