Skip to content

Commit 42e984a

Browse files
committed
drm/vc4: hdmi: Rely on interrupts to handle hotplug
DRM currently polls for the HDMI connector status every 10s, which can be an issue when we connect/disconnect a display quickly or the device on the other end only issues a hotplug pulse (for example on EDID change). Switch the driver to rely on the internal controller logic for the BCM2711/RPi4. Signed-off-by: Maxime Ripard <[email protected]>
1 parent b7cd586 commit 42e984a

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,6 +2138,46 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
21382138

21392139
}
21402140

2141+
static irqreturn_t vc4_hdmi_hpd_irq_thread(int irq, void *priv)
2142+
{
2143+
struct vc4_hdmi *vc4_hdmi = priv;
2144+
struct drm_device *dev = vc4_hdmi->connector.dev;
2145+
2146+
if (dev)
2147+
drm_kms_helper_hotplug_event(dev);
2148+
2149+
return IRQ_HANDLED;
2150+
}
2151+
2152+
static int vc4_hdmi_hotplug_init(struct vc4_hdmi *vc4_hdmi)
2153+
{
2154+
struct platform_device *pdev = vc4_hdmi->pdev;
2155+
struct device *dev = &pdev->dev;
2156+
int ret;
2157+
2158+
if (vc4_hdmi->variant->external_irq_controller) {
2159+
ret = devm_request_threaded_irq(dev,
2160+
platform_get_irq_byname(pdev, "hpd-connected"),
2161+
NULL,
2162+
vc4_hdmi_hpd_irq_thread, IRQF_ONESHOT,
2163+
"vc4 hdmi hpd connected", vc4_hdmi);
2164+
if (ret)
2165+
return ret;
2166+
2167+
ret = devm_request_threaded_irq(dev,
2168+
platform_get_irq_byname(pdev, "hpd-removed"),
2169+
NULL,
2170+
vc4_hdmi_hpd_irq_thread, IRQF_ONESHOT,
2171+
"vc4 hdmi hpd disconnected", vc4_hdmi);
2172+
if (ret)
2173+
return ret;
2174+
2175+
connector->polled = DRM_CONNECTOR_POLL_HPD;
2176+
}
2177+
2178+
return 0;
2179+
}
2180+
21412181
#ifdef CONFIG_DRM_VC4_HDMI_CEC
21422182
static irqreturn_t vc4_cec_irq_handler_rx_thread(int irq, void *priv)
21432183
{
@@ -2728,6 +2768,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
27282768
if (ret)
27292769
goto err_destroy_encoder;
27302770

2771+
ret = vc4_hdmi_hotplug_init(vc4_hdmi);
2772+
if (ret)
2773+
goto err_destroy_conn;
2774+
27312775
ret = vc4_hdmi_cec_init(vc4_hdmi);
27322776
if (ret)
27332777
goto err_destroy_conn;

0 commit comments

Comments
 (0)