bcm27xx: switch to 5.15
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.10 / 950-0601-drm-vc4-hdmi-Rely-on-interrupts-to-handle-hotplug.patch
1 From 263d69b2c6ff1d1de6c3788d1b01760d4a1ebd9d Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Thu, 29 Apr 2021 11:08:52 +0200
4 Subject: [PATCH] drm/vc4: hdmi: Rely on interrupts to handle hotplug
5
6 DRM currently polls for the HDMI connector status every 10s, which can
7 be an issue when we connect/disconnect a display quickly or the device
8 on the other end only issues a hotplug pulse (for example on EDID
9 change).
10
11 Switch the driver to rely on the internal controller logic for the
12 BCM2711/RPi4.
13
14 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
15 ---
16 drivers/gpu/drm/vc4/vc4_hdmi.c | 44 ++++++++++++++++++++++++++++++++++
17 1 file changed, 44 insertions(+)
18
19 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
20 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
21 @@ -1690,6 +1690,46 @@ static int vc4_hdmi_audio_init(struct vc
22
23 }
24
25 +static irqreturn_t vc4_hdmi_hpd_irq_thread(int irq, void *priv)
26 +{
27 + struct vc4_hdmi *vc4_hdmi = priv;
28 + struct drm_device *dev = vc4_hdmi->connector.dev;
29 +
30 + if (dev)
31 + drm_kms_helper_hotplug_event(dev);
32 +
33 + return IRQ_HANDLED;
34 +}
35 +
36 +static int vc4_hdmi_hotplug_init(struct vc4_hdmi *vc4_hdmi)
37 +{
38 + struct platform_device *pdev = vc4_hdmi->pdev;
39 + struct device *dev = &pdev->dev;
40 + int ret;
41 +
42 + if (vc4_hdmi->variant->external_irq_controller) {
43 + ret = devm_request_threaded_irq(dev,
44 + platform_get_irq_byname(pdev, "hpd-connected"),
45 + NULL,
46 + vc4_hdmi_hpd_irq_thread, IRQF_ONESHOT,
47 + "vc4 hdmi hpd connected", vc4_hdmi);
48 + if (ret)
49 + return ret;
50 +
51 + ret = devm_request_threaded_irq(dev,
52 + platform_get_irq_byname(pdev, "hpd-removed"),
53 + NULL,
54 + vc4_hdmi_hpd_irq_thread, IRQF_ONESHOT,
55 + "vc4 hdmi hpd disconnected", vc4_hdmi);
56 + if (ret)
57 + return ret;
58 +
59 + connector->polled = DRM_CONNECTOR_POLL_HPD;
60 + }
61 +
62 + return 0;
63 +}
64 +
65 #ifdef CONFIG_DRM_VC4_HDMI_CEC
66 static irqreturn_t vc4_cec_irq_handler_rx_thread(int irq, void *priv)
67 {
68 @@ -2317,6 +2357,10 @@ static int vc4_hdmi_bind(struct device *
69 if (ret)
70 goto err_destroy_encoder;
71
72 + ret = vc4_hdmi_hotplug_init(vc4_hdmi);
73 + if (ret)
74 + goto err_destroy_conn;
75 +
76 ret = vc4_hdmi_cec_init(vc4_hdmi);
77 if (ret)
78 goto err_destroy_conn;