kernel: bump 6.1 to 6.1.66
[openwrt/staging/stintel.git] / target / linux / bcm27xx / patches-6.1 / 950-0458-drm-vc4_hdmi-Allow-hotplug-detect-to-be-forced.patch
1 From d75b03d83ecc46b2f0ea13b7934cf3a093914388 Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Wed, 1 Jun 2022 15:43:51 +0100
4 Subject: [PATCH] drm/vc4_hdmi: Allow hotplug detect to be forced
5
6 See: https://forum.libreelec.tv/thread/24783-tv-avr-turns-back-on-right-after-turning-them-off
7
8 While the kernel provides a :D flag for assuming device is connected,
9 it doesn't stop this function from being called and generating a cec_phys_addr_invalidate
10 message when hotplug is deasserted.
11
12 That message provokes a flurry of CEC messages which for many users results in the TV
13 switching back on again and it's very hard to get it to stay switched off.
14
15 It seems to only occur with an AVR and TV connected but has been observed across a
16 number of manufacturers.
17
18 The issue started with https://github.com/raspberrypi/linux/pull/4371
19 and this provides an optional way of getting back the old behaviour
20
21 Signed-off-by: Dom Cobley <popcornmix@gmail.com>
22 ---
23 drivers/gpu/drm/vc4/vc4_hdmi.c | 10 +++++++++-
24 1 file changed, 9 insertions(+), 1 deletion(-)
25
26 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
27 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
28 @@ -41,6 +41,8 @@
29 #include <linux/component.h>
30 #include <linux/gpio/consumer.h>
31 #include <linux/i2c.h>
32 +#include <linux/module.h>
33 +#include <linux/moduleparam.h>
34 #include <linux/of_address.h>
35 #include <linux/of_platform.h>
36 #include <linux/pm_runtime.h>
37 @@ -113,6 +115,10 @@
38
39 #define HDMI_14_MAX_TMDS_CLK (340 * 1000 * 1000)
40
41 +/* bit field to force hotplug detection. bit0 = HDMI0 */
42 +static int force_hotplug = 0;
43 +module_param(force_hotplug, int, 0644);
44 +
45 static const char * const output_format_str[] = {
46 [VC4_HDMI_OUTPUT_RGB] = "RGB",
47 [VC4_HDMI_OUTPUT_YUV420] = "YUV 4:2:0",
48 @@ -475,7 +481,9 @@ static int vc4_hdmi_connector_detect_ctx
49
50 WARN_ON(pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev));
51
52 - if (vc4_hdmi->hpd_gpio) {
53 + if (force_hotplug & BIT(vc4_hdmi->encoder.type - VC4_ENCODER_TYPE_HDMI0))
54 + status = connector_status_connected;
55 + else if (vc4_hdmi->hpd_gpio) {
56 if (gpiod_get_value_cansleep(vc4_hdmi->hpd_gpio))
57 status = connector_status_connected;
58 } else {