Skip to content

Commit b93f19d

Browse files
committed
drm/msm/hdmi: ensure that HDMI is up if HPD is requested
The HDMI block needs to be enabled to properly generate HPD events. Make sure it is not turned off in the disable paths if HPD delivery is enabled. Reviewed-by: Jessica Zhang <[email protected]> Signed-off-by: Dmitry Baryshkov <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/651722/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent 969bbbf commit b93f19d

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

drivers/gpu/drm/msm/hdmi/hdmi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev)
293293
hdmi->pdev = pdev;
294294
hdmi->config = config;
295295
spin_lock_init(&hdmi->reg_lock);
296+
mutex_init(&hdmi->state_mutex);
296297

297298
ret = drm_of_find_panel_or_bridge(pdev->dev.of_node, 1, 0, NULL, &hdmi->next_bridge);
298299
if (ret && ret != -ENODEV)

drivers/gpu/drm/msm/hdmi/hdmi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ struct hdmi {
4141

4242
/* video state: */
4343
bool power_on;
44+
bool hpd_enabled;
45+
struct mutex state_mutex; /* protects two booleans */
4446
unsigned long int pixclock;
4547

4648
void __iomem *mmio;

drivers/gpu/drm/msm/hdmi/hdmi_bridge.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,13 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge,
302302

303303
msm_hdmi_set_timings(hdmi, &crtc_state->adjusted_mode);
304304

305+
mutex_lock(&hdmi->state_mutex);
305306
if (!hdmi->power_on) {
306307
msm_hdmi_phy_resource_enable(phy);
307308
msm_hdmi_power_on(bridge);
308309
hdmi->power_on = true;
309310
}
311+
mutex_unlock(&hdmi->state_mutex);
310312

311313
if (connector->display_info.is_hdmi)
312314
msm_hdmi_audio_update(hdmi);
@@ -332,7 +334,10 @@ static void msm_hdmi_bridge_atomic_post_disable(struct drm_bridge *bridge,
332334
msm_hdmi_hdcp_off(hdmi->hdcp_ctrl);
333335

334336
DBG("power down");
335-
msm_hdmi_set_mode(hdmi, false);
337+
338+
/* Keep the HDMI enabled if the HPD is enabled */
339+
mutex_lock(&hdmi->state_mutex);
340+
msm_hdmi_set_mode(hdmi, hdmi->hpd_enabled);
336341

337342
msm_hdmi_phy_powerdown(phy);
338343

@@ -343,6 +348,7 @@ static void msm_hdmi_bridge_atomic_post_disable(struct drm_bridge *bridge,
343348
msm_hdmi_audio_update(hdmi);
344349
msm_hdmi_phy_resource_disable(phy);
345350
}
351+
mutex_unlock(&hdmi->state_mutex);
346352
}
347353

348354
static void msm_hdmi_set_timings(struct hdmi *hdmi,

drivers/gpu/drm/msm/hdmi/hdmi_hpd.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ int msm_hdmi_hpd_enable(struct drm_bridge *bridge)
7676
if (ret)
7777
return ret;
7878

79+
mutex_lock(&hdmi->state_mutex);
7980
msm_hdmi_set_mode(hdmi, false);
8081
msm_hdmi_phy_reset(hdmi);
8182
msm_hdmi_set_mode(hdmi, true);
8283

84+
hdmi->hpd_enabled = true;
85+
mutex_unlock(&hdmi->state_mutex);
86+
8387
hdmi_write(hdmi, REG_HDMI_USEC_REFTIMER, 0x0001001b);
8488

8589
/* enable HPD events: */
@@ -109,7 +113,10 @@ void msm_hdmi_hpd_disable(struct hdmi *hdmi)
109113
/* Disable HPD interrupt */
110114
hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, 0);
111115

112-
msm_hdmi_set_mode(hdmi, false);
116+
mutex_lock(&hdmi->state_mutex);
117+
hdmi->hpd_enabled = false;
118+
msm_hdmi_set_mode(hdmi, hdmi->power_on);
119+
mutex_unlock(&hdmi->state_mutex);
113120

114121
pm_runtime_put(dev);
115122
}

0 commit comments

Comments
 (0)