[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEXTbpcnuJykS8GPeNb8eRDwuDjMuHBSd7H9+aboYkfg5Ub_Fg@mail.gmail.com>
Date: Thu, 19 Dec 2024 20:18:20 +0800
From: Pin-yen Lin <treapking@...omium.org>
To: Xin Ji <xji@...logixsemi.com>
Cc: Andrzej Hajda <andrzej.hajda@...el.com>, Neil Armstrong <neil.armstrong@...aro.org>,
Robert Foss <rfoss@...nel.org>, Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
Jonas Karlman <jonas@...boo.se>, Jernej Skrabec <jernej.skrabec@...il.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>, David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
bliang@...logixsemi.com, qwen@...logixsemi.com,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] drm/bridge:anx7625: Update HDCP content status
On Thu, Dec 19, 2024 at 3:04 PM Xin Ji <xji@...logixsemi.com> wrote:
>
> 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 <xji@...logixsemi.com>
Tested-by: Pin-yen Lin <treapking@...omium.org>
> ---
> drivers/gpu/drm/bridge/analogix/anx7625.c | 73 +++++++++--------------
> 1 file changed, 29 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index a2675b121fe4..1871262d5a97 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -2137,49 +2137,6 @@ static void hdcp_check_work_func(struct work_struct *work)
> drm_modeset_unlock(&drm_dev->mode_config.connection_mutex);
> }
>
> -static int anx7625_connector_atomic_check(struct anx7625_data *ctx,
> - struct drm_connector_state *state)
> -{
> - struct device *dev = ctx->dev;
> - int cp;
> -
> - dev_dbg(dev, "hdcp state check\n");
> - cp = state->content_protection;
> -
> - if (cp == ctx->hdcp_cp)
> - return 0;
> -
> - if (cp == DRM_MODE_CONTENT_PROTECTION_DESIRED) {
> - if (ctx->dp_en) {
> - dev_dbg(dev, "enable HDCP\n");
> - anx7625_hdcp_enable(ctx);
> -
> - queue_delayed_work(ctx->hdcp_workqueue,
> - &ctx->hdcp_work,
> - msecs_to_jiffies(2000));
> - }
> - }
> -
> - if (cp == DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
> - if (ctx->hdcp_cp != DRM_MODE_CONTENT_PROTECTION_ENABLED) {
> - dev_err(dev, "current CP is not ENABLED\n");
> - return -EINVAL;
> - }
> - anx7625_hdcp_disable(ctx);
> - ctx->hdcp_cp = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
> - drm_hdcp_update_content_protection(ctx->connector,
> - ctx->hdcp_cp);
> - dev_dbg(dev, "update CP to UNDESIRE\n");
> - }
> -
> - if (cp == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
> - dev_err(dev, "Userspace illegal set to PROTECTION ENABLE\n");
> - return -EINVAL;
> - }
> -
> - return 0;
> -}
> -
> static int anx7625_bridge_attach(struct drm_bridge *bridge,
> enum drm_bridge_attach_flags flags)
> {
> @@ -2416,7 +2373,7 @@ static int anx7625_bridge_atomic_check(struct drm_bridge *bridge,
> anx7625_bridge_mode_fixup(bridge, &crtc_state->mode,
> &crtc_state->adjusted_mode);
>
> - return anx7625_connector_atomic_check(ctx, conn_state);
> + return 0;
> }
>
> static void anx7625_bridge_atomic_enable(struct drm_bridge *bridge,
> @@ -2425,6 +2382,7 @@ static void anx7625_bridge_atomic_enable(struct drm_bridge *bridge,
> struct anx7625_data *ctx = bridge_to_anx7625(bridge);
> struct device *dev = ctx->dev;
> struct drm_connector *connector;
> + struct drm_connector_state *conn_state;
>
> dev_dbg(dev, "drm atomic enable\n");
>
> @@ -2439,6 +2397,22 @@ static void anx7625_bridge_atomic_enable(struct drm_bridge *bridge,
> _anx7625_hpd_polling(ctx, 5000 * 100);
>
> anx7625_dp_start(ctx);
> +
> + conn_state = drm_atomic_get_new_connector_state(state->base.state, connector);
> +
> + if (WARN_ON(!conn_state))
> + return;
> +
> + if (conn_state->content_protection == DRM_MODE_CONTENT_PROTECTION_DESIRED) {
> + if (ctx->dp_en) {
> + dev_dbg(dev, "enable HDCP\n");
> + anx7625_hdcp_enable(ctx);
> +
> + queue_delayed_work(ctx->hdcp_workqueue,
> + &ctx->hdcp_work,
> + msecs_to_jiffies(2000));
> + }
> + }
> }
>
> static void anx7625_bridge_atomic_disable(struct drm_bridge *bridge,
> @@ -2449,6 +2423,17 @@ static void anx7625_bridge_atomic_disable(struct drm_bridge *bridge,
>
> dev_dbg(dev, "drm atomic disable\n");
>
> + flush_workqueue(ctx->hdcp_workqueue);
> +
> + if (ctx->connector &&
> + ctx->hdcp_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
> + anx7625_hdcp_disable(ctx);
> + ctx->hdcp_cp = DRM_MODE_CONTENT_PROTECTION_DESIRED;
> + drm_hdcp_update_content_protection(ctx->connector,
> + ctx->hdcp_cp);
> + dev_dbg(dev, "update CP to DESIRE\n");
> + }
> +
> ctx->connector = NULL;
> anx7625_dp_stop(ctx);
>
> --
> 2.25.1
>
Powered by blists - more mailing lists