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: 13634 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2895030wru; Tue, 1 Nov 2022 04:23:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4UKBOHr/kbgXL1BVkT2kTtCeToE2IhRc0/onhN+qhnkiSj2pEGeNvDZ1rf2RA2rhoZCN5u X-Received: by 2002:a17:906:fd82:b0:770:7e61:3707 with SMTP id xa2-20020a170906fd8200b007707e613707mr17497146ejb.143.1667301832761; Tue, 01 Nov 2022 04:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667301832; cv=none; d=google.com; s=arc-20160816; b=LOPrbMjFautAyqDO1Pa+xojioEsehN77PTzD7hrDxWVCiwujrMyDi26bNOhraiF+Mp wtcx3+PQDOFkjxQF1HQAepV2at83wV87MjC3yxHthLPwwoyanM6v606ruJCi4Ym0OKgr j1MAgmZpxmusXDaP6hQAB9sMiBxsr1aJTx/A4nk7KEdtJzAIIltfrynHyYQI2uYuRyH1 lMM3DCRrL9AgGhJRBhy5dycAwe7SEZQa+9/50pYZfT7T/+ykXN6CbUEYgzbRqw3+40FG GT5nMLk6knsTlge4cWS318mkBaV/qTtYUuEAZkUAdbCIzHcZ6W8rIOXunz5LFrDNeOPM OFrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/oxx2mpp4iYPf59kzXTZVyiQQScJKMt68qbvOfaAmNM=; b=GaUPGOOOR9Kl/gV0fsg1ABEhyctlE0i3Vjft5urEXwZGxoDUBo+ej0FMKqSJZpr4ER f5kxgtLl6oNyPZxMsGm14CePRrqO4l7bIIYJvO1b5I69y1NXL5XCYPGAhzCmIuJHRR0b 1ArBD0ocFUc7oHEIpk3Dc1wojj9cduo88qy6u7NRTYSqpRdVG4huhjn4w9B9L3AHfzqG tRidLbVu20SOWSa+1LVwzKI3MB0XZJKUVjhmkMQOociStWavVbh8S+P+BULTwcm8NBDe vAw2z7n/yFLtUiCqoLTZrJbd9KJzJCJOGVymQr8wtcm30ecMgp+oepkzbjI+R1Bg2B31 ohow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Eqla52jj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o7-20020a056402038700b004636ec90769si4733132edv.33.2022.11.01.04.23.29; Tue, 01 Nov 2022 04:23:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Eqla52jj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229742AbiKALUc (ORCPT + 99 others); Tue, 1 Nov 2022 07:20:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbiKALUa (ORCPT ); Tue, 1 Nov 2022 07:20:30 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C529B65B3 for ; Tue, 1 Nov 2022 04:20:28 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id m6so13215526pfb.0 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=5GKcPtPBdzldOzzqkMiK1F4QqBVZ9wSWab+nUl6gjL1oTK9O8S+5mZjPukTbqYjGtw lr7W3/9wmfvwFluI/yWHJlpwLDTSNMXp0UlZ6kAgMFuHirkQKZm0Pu2GOXN21U30k7mj Se55yQwp3FTBPzQhnL8CJkXqtOZC1zRsh76jKB3acCEbwbQTaZqC/DhjOZEi9x3kMeK1 gR2WuNu08Y7/TZIEtJhvlF7PIgD2M3wX8PvuOS+Rxwz8lowedKf5f2oMubqA9kL2t0tT twsiel0UZxyThyfGetkPiR1pzCuCi5TLsnRyEADaUQQM65sxMnxqvUuV4edGP6VWDsFo EKNQ== X-Gm-Message-State: ACrzQf3Ur9FNmbfTb4c1HDY+QS0OQ3EmWYhrt1822aAfMxlqABaSoIIF 65F+IXAJLAxe8FkMsIiM6NZbMw== 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 Cc: Andrzej Hajda , Neil Armstrong , Pin-yen Lin , Laurent Pinchart , AngeloGioacchino Del Regno , Hermes Wu , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org 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-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748292686998366529?= X-GMAIL-MSGID: =?utf-8?q?1748292686998366529?= 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,