bcm27xx: 6.1: add kernel patches
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-6.1 / 950-0453-drm-vc4-hdmi-Fix-hdmi_enable_4kp60-detection.patch
1 From 98bd7718d38db5c3e8e8af83f30f9cab0d3c140d Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Thu, 24 Mar 2022 11:57:57 +0100
4 Subject: [PATCH] drm/vc4: hdmi: Fix hdmi_enable_4kp60 detection
5
6 In order to support higher HDMI frequencies, users have to set the
7 hdmi_enable_4kp60 parameter in their config.txt file.
8
9 We were detecting this so far by calling clk_round_rate() on the core
10 clock with the frequency we're supposed to run at when one of those
11 modes is enabled. Whether or not the parameter was enabled could then be
12 inferred by the returned rate since the maximum clock rate reported by
13 the firmware was one of the side effect of setting that parameter.
14
15 However, the recent clock rework we did changed what clk_round_rate()
16 was returning to always return the minimum allowed, and thus this test
17 wasn't reliable anymore.
18
19 Let's use the new clk_get_max_rate() function to reliably determine the
20 maximum rate allowed on that clock and fix the 4k@60Hz output.
21
22 Fixes: e9d6cea2af1c ("clk: bcm: rpi: Run some clocks at the minimum rate allowed")
23 Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
24 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
25 ---
26 drivers/gpu/drm/vc4/vc4_hdmi.c | 3 ++-
27 1 file changed, 2 insertions(+), 1 deletion(-)
28
29 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
30 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
31 @@ -46,6 +46,7 @@
32 #include <linux/pm_runtime.h>
33 #include <linux/rational.h>
34 #include <linux/reset.h>
35 +#include <soc/bcm2835/raspberrypi-clocks.h>
36 #include <sound/dmaengine_pcm.h>
37 #include <sound/hdmi-codec.h>
38 #include <sound/pcm_drm_eld.h>
39 @@ -3695,7 +3696,7 @@ static int vc4_hdmi_bind(struct device *
40
41 if (variant->max_pixel_clock == 600000000) {
42 struct vc4_dev *vc4 = to_vc4_dev(drm);
43 - long max_rate = clk_round_rate(vc4->hvs->core_clk, 550000000);
44 + unsigned int max_rate = rpi_firmware_clk_get_max_rate(vc4->hvs->core_clk);
45
46 if (max_rate < 550000000)
47 vc4_hdmi->disable_4kp60 = true;