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
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
11 Switch the driver to rely on the internal controller logic for the
14 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
16 drivers/gpu/drm/vc4/vc4_hdmi.c | 44 ++++++++++++++++++++++++++++++++++
17 1 file changed, 44 insertions(+)
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
25 +static irqreturn_t vc4_hdmi_hpd_irq_thread(int irq, void *priv)
27 + struct vc4_hdmi *vc4_hdmi = priv;
28 + struct drm_device *dev = vc4_hdmi->connector.dev;
31 + drm_kms_helper_hotplug_event(dev);
36 +static int vc4_hdmi_hotplug_init(struct vc4_hdmi *vc4_hdmi)
38 + struct platform_device *pdev = vc4_hdmi->pdev;
39 + struct device *dev = &pdev->dev;
42 + if (vc4_hdmi->variant->external_irq_controller) {
43 + ret = devm_request_threaded_irq(dev,
44 + platform_get_irq_byname(pdev, "hpd-connected"),
46 + vc4_hdmi_hpd_irq_thread, IRQF_ONESHOT,
47 + "vc4 hdmi hpd connected", vc4_hdmi);
51 + ret = devm_request_threaded_irq(dev,
52 + platform_get_irq_byname(pdev, "hpd-removed"),
54 + vc4_hdmi_hpd_irq_thread, IRQF_ONESHOT,
55 + "vc4 hdmi hpd disconnected", vc4_hdmi);
59 + connector->polled = DRM_CONNECTOR_POLL_HPD;
65 #ifdef CONFIG_DRM_VC4_HDMI_CEC
66 static irqreturn_t vc4_cec_irq_handler_rx_thread(int irq, void *priv)
68 @@ -2317,6 +2357,10 @@ static int vc4_hdmi_bind(struct device *
70 goto err_destroy_encoder;
72 + ret = vc4_hdmi_hotplug_init(vc4_hdmi);
74 + goto err_destroy_conn;
76 ret = vc4_hdmi_cec_init(vc4_hdmi);
78 goto err_destroy_conn;