From: Maxime Ripard <maxime@cerno.tech>
To: Daniel Vetter <daniel@ffwll.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
David Airlie <airlied@linux.ie>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Michael Turquette <mturquette@baylibre.com>,
Scott Branden <sbranden@broadcom.com>,
Stephen Boyd <sboyd@kernel.org>, Emma Anholt <emma@anholt.net>,
Ray Jui <rjui@broadcom.com>, Maxime Ripard <mripard@kernel.org>
Cc: linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org, Dom Cobley <popcornmix@gmail.com>,
dri-devel@lists.freedesktop.org,
Maxime Ripard <maxime@cerno.tech>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 6/7] drm/vc4: hdmi: Add more checks for 4k resolutions
Date: Tue, 20 Sep 2022 14:50:25 +0200 [thread overview]
Message-ID: <20220815-rpi-fix-4k-60-v2-6-983276b83f62@cerno.tech> (raw)
In-Reply-To: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech>
From: Dom Cobley <popcornmix@gmail.com>
At least the 4096x2160@60Hz mode requires some overclocking that isn't
available by default, even if hdmi_enable_4kp60 is enabled.
Let's add some logic to detect whether we can satisfy the core clock
requirements for that mode, and prevent it from being used otherwise.
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index 09cdbdb7fff0..094ebe8567e2 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -349,6 +349,12 @@ struct vc4_hvs {
* available.
*/
bool vc5_hdmi_enable_scrambling;
+
+ /*
+ * 4096x2160@60 requires a core overclock to work, so register
+ * whether that is sufficient.
+ */
+ bool vc5_hdmi_enable_4096by2160;
};
struct vc4_plane {
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index f367f93ca832..cf1fee6c29f3 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -1476,6 +1476,7 @@ vc4_hdmi_sink_supports_format_bpc(const struct vc4_hdmi *vc4_hdmi,
static enum drm_mode_status
vc4_hdmi_encoder_clock_valid(const struct vc4_hdmi *vc4_hdmi,
+ const struct drm_display_mode *mode,
unsigned long long clock)
{
const struct drm_connector *connector = &vc4_hdmi->connector;
@@ -1488,6 +1489,12 @@ vc4_hdmi_encoder_clock_valid(const struct vc4_hdmi *vc4_hdmi,
if (!vc4->hvs->vc5_hdmi_enable_scrambling && clock > HDMI_14_MAX_TMDS_CLK)
return MODE_CLOCK_HIGH;
+ /* 4096x2160@60 is not reliable without overclocking core */
+ if (!vc4->hvs->vc5_hdmi_enable_4096by2160 &&
+ mode->hdisplay > 3840 && mode->vdisplay >= 2160 &&
+ drm_mode_vrefresh(mode) >= 50)
+ return MODE_CLOCK_HIGH;
+
if (info->max_tmds_clock && clock > (info->max_tmds_clock * 1000))
return MODE_CLOCK_HIGH;
@@ -1522,7 +1529,7 @@ vc4_hdmi_encoder_compute_clock(const struct vc4_hdmi *vc4_hdmi,
unsigned long long clock;
clock = vc4_hdmi_encoder_compute_mode_clock(mode, bpc, fmt);
- if (vc4_hdmi_encoder_clock_valid(vc4_hdmi, clock) != MODE_OK)
+ if (vc4_hdmi_encoder_clock_valid(vc4_hdmi, mode, clock) != MODE_OK)
return -EINVAL;
vc4_state->tmds_char_rate = clock;
@@ -1685,7 +1692,7 @@ vc4_hdmi_encoder_mode_valid(struct drm_encoder *encoder,
(mode->hsync_end % 2) || (mode->htotal % 2)))
return MODE_H_ILLEGAL;
- return vc4_hdmi_encoder_clock_valid(vc4_hdmi, mode->clock * 1000);
+ return vc4_hdmi_encoder_clock_valid(vc4_hdmi, mode, mode->clock * 1000);
}
static const struct drm_encoder_helper_funcs vc4_hdmi_encoder_helper_funcs = {
diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c
index e28a13a75ec2..32f5ab937ace 100644
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
@@ -698,6 +698,9 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
if (max_rate >= 550000000)
hvs->vc5_hdmi_enable_scrambling = true;
+ if (max_rate >= 600000000)
+ hvs->vc5_hdmi_enable_4096by2160 = true;
+
hvs->max_core_rate = max_rate;
ret = clk_prepare_enable(hvs->core_clk);
--
b4 0.10.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-09-20 12:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 12:50 [PATCH v2 0/7] drm/vc4: Fix the core clock behaviour Maxime Ripard
2022-09-20 12:50 ` [PATCH v2 1/7] firmware: raspberrypi: Introduce rpi_firmware_find_node() Maxime Ripard
2022-09-20 12:50 ` [PATCH v2 2/7] firmware: raspberrypi: Move the clock IDs to the firmware header Maxime Ripard
2022-09-20 16:01 ` Stefan Wahren
2022-09-21 9:17 ` Maxime Ripard
2022-09-20 12:50 ` [PATCH v2 3/7] firmware: raspberrypi: Provide a helper to query a clock max rate Maxime Ripard
2022-09-29 0:23 ` Stephen Boyd
2022-10-10 16:52 ` Stefan Wahren
2022-09-20 12:50 ` [PATCH v2 4/7] drm/vc4: hdmi: Fix hdmi_enable_4kp60 detection Maxime Ripard
2022-09-20 12:50 ` [PATCH v2 5/7] drm/vc4: hdmi: Rework hdmi_enable_4kp60 detection code Maxime Ripard
2022-09-20 12:50 ` Maxime Ripard [this message]
2022-09-20 12:50 ` [PATCH v2 7/7] drm/vc4: Make sure we don't end up with a core clock too high Maxime Ripard
2022-10-10 11:44 ` [PATCH v2 0/7] drm/vc4: Fix the core clock behaviour Maxime Ripard
2022-10-10 19:07 ` Florian Fainelli
2022-10-13 8:59 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220815-rpi-fix-4k-60-v2-6-983276b83f62@cerno.tech \
--to=maxime@cerno.tech \
--cc=airlied@linux.ie \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=emma@anholt.net \
--cc=f.fainelli@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=mripard@kernel.org \
--cc=mturquette@baylibre.com \
--cc=popcornmix@gmail.com \
--cc=rjui@broadcom.com \
--cc=sboyd@kernel.org \
--cc=sbranden@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).