From patchwork Tue Nov 1 11:20:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 13026893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7CB69C433FE for ; Tue, 1 Nov 2022 11:20:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C9B910E0F1; Tue, 1 Nov 2022 11:20:31 +0000 (UTC) Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by gabe.freedesktop.org (Postfix) with ESMTPS id B05B210E0F1 for ; Tue, 1 Nov 2022 11:20:28 +0000 (UTC) Received: by mail-pg1-x52a.google.com with SMTP id r18so13112795pgr.12 for ; Tue, 01 Nov 2022 04:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/oxx2mpp4iYPf59kzXTZVyiQQScJKMt68qbvOfaAmNM=; b=Eqla52jjC7tCuORbUcWjhmeHzS8L1UPvKjECAaBzgjHSVR0yuGoYexhXnR3Me8EgVi bThx6Oh6WzpuAaQbTHz4m8oKQe3+RR5dfBhbsAC7EncEqzf+G5Ch5mQxZojQ5euHvdjV 9t4QGpFHPYUw90LG8KpEoCufvce3+djUYKwzc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/oxx2mpp4iYPf59kzXTZVyiQQScJKMt68qbvOfaAmNM=; b=CHMob1U4ILMZ/4XFBL6V6NonhcElrSXjKffBAdzGr5ZaMK2UEb/Vv2fFppxR4UL3hQ bQxt8qbjdbcUqr3+e8o2b0xHleKjEyoaKFsiabXC45EP9EgcVKdtZ4Jpp2y/BWFT8Zl2 87QIVtYb0QWjHqdq27ESKx9MU6hAtuDIypwbBsIkVk4EvY2gNcJ5hzlYGje4vGJoygZf sCVFn8mvhJX1RVHppFdgU2ut6Dfad/qFO2p6upP5KfVfQQWVnojv5T3nIiBJLO7SR+Nq lwyQfxQlm+8HtwIc+rCngsLPCXvMbYPEeMz4vWU7sGiaTOKhWhBwj6s07b/+NJ4e7ec1 jQdw== X-Gm-Message-State: ACrzQf1C8aZQ/IXuFocRN3PxHOKVJGuHnJ/gosjnDvLqCtWyV0ROaNCH D6Cy3c8CidKfwOER4Bsu2zUvRw== X-Google-Smtp-Source: AMsMyM7t7FyTAzhJupkW5XZ7w+f+bCfe00gO9R9x4+Gx3G3qW1ORSZYJg7iWP7VNjQUB9l1O/CNxaA== X-Received: by 2002:a05:6a00:98d:b0:56c:7c5c:da30 with SMTP id u13-20020a056a00098d00b0056c7c5cda30mr19146699pfg.22.1667301628082; Tue, 01 Nov 2022 04:20:28 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:3293:3b11:2be0:504]) by smtp.gmail.com with ESMTPSA id x9-20020a628609000000b00563ce1905f4sm6318084pfd.5.2022.11.01.04.20.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 04:20:27 -0700 (PDT) From: Hsin-Yi Wang To: Robert Foss , Allen Chen Subject: [PATCH] drm/bridge: it6505: handle HDCP request Date: Tue, 1 Nov 2022 19:20:10 +0800 Message-Id: <20221101112009.1067681-1-hsinyi@chromium.org> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , Jonas Karlman , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jernej Skrabec , Pin-yen Lin , Hermes Wu , Laurent Pinchart , Andrzej Hajda , AngeloGioacchino Del Regno Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" it6505 supports HDCP 1.3, but current implementation lacks the update of HDCP status through drm_hdcp_update_content_protection(). it6505 default enables the HDCP. If user set it to undesired then the driver will stop HDCP. Signed-off-by: Hsin-Yi Wang --- drivers/gpu/drm/bridge/ite-it6505.c | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index b929fc766e243..65c6f932cae25 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -423,6 +423,7 @@ struct it6505 { struct extcon_dev *extcon; struct work_struct extcon_wq; int extcon_state; + struct drm_connector *connector; enum drm_connector_status connector_status; enum link_train_status link_state; struct work_struct link_works; @@ -2399,6 +2400,14 @@ static void it6505_irq_hdcp_done(struct it6505 *it6505) DRM_DEV_DEBUG_DRIVER(dev, "hdcp done interrupt"); it6505->hdcp_status = HDCP_AUTH_DONE; + if (it6505->connector) { + struct drm_device *drm_dev = it6505->connector->dev; + + drm_modeset_lock(&drm_dev->mode_config.connection_mutex, NULL); + drm_hdcp_update_content_protection(it6505->connector, + DRM_MODE_CONTENT_PROTECTION_ENABLED); + drm_modeset_unlock(&drm_dev->mode_config.connection_mutex); + } it6505_show_hdcp_info(it6505); } @@ -2931,6 +2940,7 @@ static void it6505_bridge_atomic_enable(struct drm_bridge *bridge, if (WARN_ON(!connector)) return; + it6505->connector = connector; conn_state = drm_atomic_get_new_connector_state(state, connector); if (WARN_ON(!conn_state)) @@ -2974,6 +2984,7 @@ static void it6505_bridge_atomic_disable(struct drm_bridge *bridge, DRM_DEV_DEBUG_DRIVER(dev, "start"); + it6505->connector = NULL; if (it6505->powered) { it6505_drm_dp_link_set_power(&it6505->aux, &it6505->link, DP_SET_POWER_D3); @@ -3028,6 +3039,48 @@ static struct edid *it6505_bridge_get_edid(struct drm_bridge *bridge, return edid; } +static int it6505_connector_atomic_check(struct it6505 *it6505, + struct drm_connector_state *state) +{ + struct device *dev = &it6505->client->dev; + int cp = state->content_protection; + + DRM_DEV_DEBUG_DRIVER(dev, "hdcp connector state:%d, curr hdcp state:%d", + cp, it6505->hdcp_status); + + if (!it6505->hdcp_desired) { + DRM_DEV_DEBUG_DRIVER(dev, "sink not support hdcp"); + return 0; + } + + if (it6505->hdcp_status == HDCP_AUTH_GOING) + return -EINVAL; + + if (cp == DRM_MODE_CONTENT_PROTECTION_UNDESIRED) { + if (it6505->hdcp_status == HDCP_AUTH_DONE) + it6505_stop_hdcp(it6505); + } else if (cp == DRM_MODE_CONTENT_PROTECTION_DESIRED) { + if (it6505->hdcp_status == HDCP_AUTH_IDLE && + it6505->link_state == LINK_OK) + it6505_start_hdcp(it6505); + } else { + DRM_DEV_DEBUG_DRIVER(dev, "invalid to set hdcp enabled"); + return -EINVAL; + } + + return 0; +} + +static int it6505_bridge_atomic_check(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + struct it6505 *it6505 = bridge_to_it6505(bridge); + + return it6505_connector_atomic_check(it6505, conn_state); +} + static const struct drm_bridge_funcs it6505_bridge_funcs = { .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, @@ -3035,6 +3088,7 @@ static const struct drm_bridge_funcs it6505_bridge_funcs = { .attach = it6505_bridge_attach, .detach = it6505_bridge_detach, .mode_valid = it6505_bridge_mode_valid, + .atomic_check = it6505_bridge_atomic_check, .atomic_enable = it6505_bridge_atomic_enable, .atomic_disable = it6505_bridge_atomic_disable, .atomic_pre_enable = it6505_bridge_atomic_pre_enable,