Skip to content

Commit a253b0b

Browse files
Xin-ANXsuperna9999
authored andcommitted
drm/bridge:anx7625: Update HDCP content status
When user enabled HDCP feature, userspace will set HDCP content to DRM_MODE_CONTENT_PROTECTION_DESIRED. Next, anx7625 will update HDCP content to DRM_MODE_CONTENT_PROTECTION_ENABLED if down stream support HDCP feature. As anx7625 bridge IC will be power down after call .atomic_disable(), then all HDCP status will be lost on chip. So we should reestablish HDCP again in .atomic_enable(), and update hdcp content to DESIRE if current HDCP content is ENABLE in .atomic_disable(). v4: - Change HDCP content value to DESIRED if HDCP status is ENABLE in bridge interface .atomic_enable(). v3: - Move hdcp content value checking from bridge interface .atomic_check() to .atomic_enable() v2: - Add more details in commit message Signed-off-by: Xin Ji <[email protected]> Tested-by: Pin-yen Lin <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 74ef952 commit a253b0b

File tree

1 file changed

+29
-44
lines changed

1 file changed

+29
-44
lines changed

drivers/gpu/drm/bridge/analogix/anx7625.c

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,49 +2139,6 @@ static void hdcp_check_work_func(struct work_struct *work)
21392139
drm_modeset_unlock(&drm_dev->mode_config.connection_mutex);
21402140
}
21412141

2142-
static int anx7625_connector_atomic_check(struct anx7625_data *ctx,
2143-
struct drm_connector_state *state)
2144-
{
2145-
struct device *dev = ctx->dev;
2146-
int cp;
2147-
2148-
dev_dbg(dev, "hdcp state check\n");
2149-
cp = state->content_protection;
2150-
2151-
if (cp == ctx->hdcp_cp)
2152-
return 0;
2153-
2154-
if (cp == DRM_MODE_CONTENT_PROTECTION_DESIRED) {
2155-
if (ctx->dp_en) {
2156-
dev_dbg(dev, "enable HDCP\n");
2157-
anx7625_hdcp_enable(ctx);
2158-
2159-
queue_delayed_work(ctx->hdcp_workqueue,
2160-
&ctx->hdcp_work,
2161-
msecs_to_jiffies(2000));
2162-
}
2163-
}
2164-
2165-
if (cp == DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
2166-
if (ctx->hdcp_cp != DRM_MODE_CONTENT_PROTECTION_ENABLED) {
2167-
dev_err(dev, "current CP is not ENABLED\n");
2168-
return -EINVAL;
2169-
}
2170-
anx7625_hdcp_disable(ctx);
2171-
ctx->hdcp_cp = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
2172-
drm_hdcp_update_content_protection(ctx->connector,
2173-
ctx->hdcp_cp);
2174-
dev_dbg(dev, "update CP to UNDESIRE\n");
2175-
}
2176-
2177-
if (cp == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
2178-
dev_err(dev, "Userspace illegal set to PROTECTION ENABLE\n");
2179-
return -EINVAL;
2180-
}
2181-
2182-
return 0;
2183-
}
2184-
21852142
static int anx7625_bridge_attach(struct drm_bridge *bridge,
21862143
enum drm_bridge_attach_flags flags)
21872144
{
@@ -2418,7 +2375,7 @@ static int anx7625_bridge_atomic_check(struct drm_bridge *bridge,
24182375
anx7625_bridge_mode_fixup(bridge, &crtc_state->mode,
24192376
&crtc_state->adjusted_mode);
24202377

2421-
return anx7625_connector_atomic_check(ctx, conn_state);
2378+
return 0;
24222379
}
24232380

24242381
static void anx7625_bridge_atomic_enable(struct drm_bridge *bridge,
@@ -2427,6 +2384,7 @@ static void anx7625_bridge_atomic_enable(struct drm_bridge *bridge,
24272384
struct anx7625_data *ctx = bridge_to_anx7625(bridge);
24282385
struct device *dev = ctx->dev;
24292386
struct drm_connector *connector;
2387+
struct drm_connector_state *conn_state;
24302388

24312389
dev_dbg(dev, "drm atomic enable\n");
24322390

@@ -2441,6 +2399,22 @@ static void anx7625_bridge_atomic_enable(struct drm_bridge *bridge,
24412399
_anx7625_hpd_polling(ctx, 5000 * 100);
24422400

24432401
anx7625_dp_start(ctx);
2402+
2403+
conn_state = drm_atomic_get_new_connector_state(state->base.state, connector);
2404+
2405+
if (WARN_ON(!conn_state))
2406+
return;
2407+
2408+
if (conn_state->content_protection == DRM_MODE_CONTENT_PROTECTION_DESIRED) {
2409+
if (ctx->dp_en) {
2410+
dev_dbg(dev, "enable HDCP\n");
2411+
anx7625_hdcp_enable(ctx);
2412+
2413+
queue_delayed_work(ctx->hdcp_workqueue,
2414+
&ctx->hdcp_work,
2415+
msecs_to_jiffies(2000));
2416+
}
2417+
}
24442418
}
24452419

24462420
static void anx7625_bridge_atomic_disable(struct drm_bridge *bridge,
@@ -2451,6 +2425,17 @@ static void anx7625_bridge_atomic_disable(struct drm_bridge *bridge,
24512425

24522426
dev_dbg(dev, "drm atomic disable\n");
24532427

2428+
flush_workqueue(ctx->hdcp_workqueue);
2429+
2430+
if (ctx->connector &&
2431+
ctx->hdcp_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
2432+
anx7625_hdcp_disable(ctx);
2433+
ctx->hdcp_cp = DRM_MODE_CONTENT_PROTECTION_DESIRED;
2434+
drm_hdcp_update_content_protection(ctx->connector,
2435+
ctx->hdcp_cp);
2436+
dev_dbg(dev, "update CP to DESIRE\n");
2437+
}
2438+
24542439
ctx->connector = NULL;
24552440
anx7625_dp_stop(ctx);
24562441

0 commit comments

Comments
 (0)