From patchwork Wed Jan 18 19:30:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Yacoub X-Patchwork-Id: 13106987 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 71A37C38159 for ; Wed, 18 Jan 2023 19:30:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D3EFC10E815; Wed, 18 Jan 2023 19:30:35 +0000 (UTC) Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by gabe.freedesktop.org (Postfix) with ESMTPS id 399E510E815 for ; Wed, 18 Jan 2023 19:30:33 +0000 (UTC) Received: by mail-qt1-x829.google.com with SMTP id j9so7914377qtv.4 for ; Wed, 18 Jan 2023 11:30:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m5dWctpXCBFMYgl532Q3MiGbvh8gB6Ly1fRkfstE0vk=; b=EOKk6O/69sW4M7bfR7Bjtxdy9axfuMxRbYczDAbKOAgFlxCGZFNHQzfaecsa9X1aC8 okMj3L6ATTz6QT61g2h1eyPPJHA9FPue9Yd+Fco2ZsNHtbphvo3r5P1fdn/iDeWDhys7 WVG+Ae/TmYaf/wn8m1i84vE2gzH3cuk9p9b5k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m5dWctpXCBFMYgl532Q3MiGbvh8gB6Ly1fRkfstE0vk=; b=0CyKTnJ/YwspQkL3mkeUuAcHV5dQ0ruIrtyGYsJROJmVWhLnbz7410JEL1PBe3PJCP 7wk5UiPR5/mRjOIsCeBA/YtiLh6lvawf8/dCS2Q/lXEp3SJNoroo/ck/FDPokA+sDB8Y hDzVQSX66p/4Td04cChzks6ueVAQAXjQw9GEtJ1JgcEMxZn3Ge2L2MmFMWSnoBOldHbn x9GUuAaMfZywynVzIU49k3eB77VL54u+ETnIa+zSTZyuhgVNo3ssNMoCenUQe9BqEbpL UpcPvj1jyVkB23OmQJK1xCb0B23BZc4luV/e4NPn9M2AqxvjdlgwAGV+hWTD3tjSfmmz o3ZA== X-Gm-Message-State: AFqh2koXxiQJXJjRWD1ZrLyoYJWcuMmiANYzRnIUFMnLYU7d90/02xgk XOAHSyAWrKoUM/BBA1lfARWHow== X-Google-Smtp-Source: AMrXdXtndBb0E8gZDRjYuGpBHi1LHc4kBoV4/8YoveySawhPGPE+EzzW7zT3+AyjUsKV2XUybmpAlw== X-Received: by 2002:ac8:75cd:0:b0:3a6:a7a2:57b with SMTP id z13-20020ac875cd000000b003a6a7a2057bmr11626751qtq.6.1674070232166; Wed, 18 Jan 2023 11:30:32 -0800 (PST) Received: from localhost (29.46.245.35.bc.googleusercontent.com. [35.245.46.29]) by smtp.gmail.com with UTF8SMTPSA id m20-20020ac866d4000000b003a6a7a20575sm17826693qtp.73.2023.01.18.11.30.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jan 2023 11:30:31 -0800 (PST) From: Mark Yacoub X-Google-Original-From: Mark Yacoub To: quic_khsieh@quicinc.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org Date: Wed, 18 Jan 2023 19:30:07 +0000 Message-Id: <20230118193015.911074-3-markyacoub@google.com> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230118193015.911074-1-markyacoub@google.com> References: <20230118193015.911074-1-markyacoub@google.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 02/10] drm/hdcp: Avoid changing crtc state in hdcp atomic check X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_sbillaka@quicinc.com, konrad.dybcio@somainline.org, bjorn.andersson@linaro.org, krzysztof.kozlowski+dt@linaro.org, airlied@gmail.com, hbh25y@gmail.com, marex@denx.de, abhinavk@codeaurora.org, javierm@redhat.com, agross@kernel.org, quic_jesszhan@quicinc.com, daniel@ffwll.ch, Jani Nikula , lucas.demarchi@intel.com, quic_abhinavk@quicinc.com, swboyd@chromium.org, robh+dt@kernel.org, christophe.jaillet@wanadoo.fr, maxime@cerno.tech, rodrigo.vivi@intel.com, johan+linaro@kernel.org, markyacoub@chromium.org, andersson@kernel.org, dianders@chromium.org, tzimmermann@suse.de, dmitry.baryshkov@linaro.org, seanpaul@chromium.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Sean Paul Instead of forcing a modeset in the hdcp atomic check, simply return true if the content protection value is changing and let the driver decide whether a modeset is required or not. Acked-by: Jani Nikula Reviewed-by: Rodrigo Vivi Signed-off-by: Sean Paul Signed-off-by: Mark Yacoub Link: https://patchwork.freedesktop.org/patch/msgid/20210913175747.47456-3-sean@poorly.run #v1 Link: https://patchwork.freedesktop.org/patch/msgid/20210915203834.1439-3-sean@poorly.run #v2 Link: https://patchwork.freedesktop.org/patch/msgid/20211001151145.55916-3-sean@poorly.run #v3 Link: https://patchwork.freedesktop.org/patch/msgid/20211105030434.2828845-3-sean@poorly.run #v4 Link: https://patchwork.freedesktop.org/patch/msgid/20220411204741.1074308-3-sean@poorly.run #v5 Changes in v2: -None Changes in v3: -None Changes in v4: -None Changes in v5: -None Changes in V6: -Rebase: modifications in drm_hdcp_helper.c instead of drm_hdcp.c --- drivers/gpu/drm/display/drm_hdcp_helper.c | 33 +++++++++++++++------ drivers/gpu/drm/i915/display/intel_atomic.c | 6 ++-- include/drm/display/drm_hdcp_helper.h | 2 +- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/display/drm_hdcp_helper.c b/drivers/gpu/drm/display/drm_hdcp_helper.c index 7d910523b05f..a3896b0904b5 100644 --- a/drivers/gpu/drm/display/drm_hdcp_helper.c +++ b/drivers/gpu/drm/display/drm_hdcp_helper.c @@ -428,11 +428,14 @@ EXPORT_SYMBOL(drm_hdcp_update_content_protection); * @connector: drm_connector on which content protection state needs an update * * This function can be used by display drivers to perform an atomic check on the - * hdcp state elements. If hdcp state has changed, this function will set - * mode_changed on the crtc driving the connector so it can update its hardware - * to match the hdcp state. + * hdcp state elements. If hdcp state has changed in a manner which requires the + * driver to enable or disable content protection, this function will return + * true. + * + * Returns: + * true if the driver must enable/disable hdcp, false otherwise */ -void drm_hdcp_atomic_check(struct drm_connector *connector, +bool drm_hdcp_atomic_check(struct drm_connector *connector, struct drm_atomic_state *state) { struct drm_connector_state *new_conn_state, *old_conn_state; @@ -450,10 +453,12 @@ void drm_hdcp_atomic_check(struct drm_connector *connector, * If the connector is being disabled with CP enabled, mark it * desired so it's re-enabled when the connector is brought back */ - if (old_hdcp == DRM_MODE_CONTENT_PROTECTION_ENABLED) + if (old_hdcp == DRM_MODE_CONTENT_PROTECTION_ENABLED) { new_conn_state->content_protection = DRM_MODE_CONTENT_PROTECTION_DESIRED; - return; + return true; + } + return false; } new_crtc_state = @@ -465,9 +470,19 @@ void drm_hdcp_atomic_check(struct drm_connector *connector, */ if (drm_atomic_crtc_needs_modeset(new_crtc_state) && (old_hdcp == DRM_MODE_CONTENT_PROTECTION_ENABLED && - new_hdcp != DRM_MODE_CONTENT_PROTECTION_UNDESIRED)) + new_hdcp != DRM_MODE_CONTENT_PROTECTION_UNDESIRED)) { new_conn_state->content_protection = DRM_MODE_CONTENT_PROTECTION_DESIRED; + return true; + } + + /* + * Coming back from disable or changing CRTC with DESIRED state requires + * that the driver try CP enable. + */ + if (new_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED && + new_conn_state->crtc != old_conn_state->crtc) + return true; /* * Nothing to do if content type is unchanged and one of: @@ -482,9 +497,9 @@ void drm_hdcp_atomic_check(struct drm_connector *connector, new_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED)) { if (old_conn_state->hdcp_content_type == new_conn_state->hdcp_content_type) - return; + return false; } - new_crtc_state->mode_changed = true; + return true; } EXPORT_SYMBOL(drm_hdcp_atomic_check); diff --git a/drivers/gpu/drm/i915/display/intel_atomic.c b/drivers/gpu/drm/i915/display/intel_atomic.c index 8a473199c4bf..a2067cbae2d5 100644 --- a/drivers/gpu/drm/i915/display/intel_atomic.c +++ b/drivers/gpu/drm/i915/display/intel_atomic.c @@ -123,8 +123,6 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn, to_intel_digital_connector_state(old_state); struct drm_crtc_state *crtc_state; - drm_hdcp_atomic_check(conn, state); - if (!new_state->crtc) return 0; @@ -140,8 +138,8 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn, new_conn_state->base.picture_aspect_ratio != old_conn_state->base.picture_aspect_ratio || new_conn_state->base.content_type != old_conn_state->base.content_type || new_conn_state->base.scaling_mode != old_conn_state->base.scaling_mode || - new_conn_state->base.privacy_screen_sw_state != old_conn_state->base.privacy_screen_sw_state || - !drm_connector_atomic_hdr_metadata_equal(old_state, new_state)) + !drm_connector_atomic_hdr_metadata_equal(old_state, new_state) || + drm_hdcp_atomic_check(conn, state)) crtc_state->mode_changed = true; return 0; diff --git a/include/drm/display/drm_hdcp_helper.h b/include/drm/display/drm_hdcp_helper.h index dd02b2e72a50..cb2cc5002f65 100644 --- a/include/drm/display/drm_hdcp_helper.h +++ b/include/drm/display/drm_hdcp_helper.h @@ -19,7 +19,7 @@ int drm_hdcp_check_ksvs_revoked(struct drm_device *dev, u8 *ksvs, u32 ksv_count) int drm_connector_attach_content_protection_property(struct drm_connector *connector, bool hdcp_content_type); void drm_hdcp_update_content_protection(struct drm_connector *connector, u64 val); -void drm_hdcp_atomic_check(struct drm_connector *connector, +bool drm_hdcp_atomic_check(struct drm_connector *connector, struct drm_atomic_state *state); #endif