From patchwork Fri Mar 31 22:12:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Yacoub X-Patchwork-Id: 13196656 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 A71C6C761A6 for ; Fri, 31 Mar 2023 22:12:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 77A6610E436; Fri, 31 Mar 2023 22:12:40 +0000 (UTC) Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by gabe.freedesktop.org (Postfix) with ESMTPS id BCD6610F331 for ; Fri, 31 Mar 2023 22:12:22 +0000 (UTC) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5416698e889so441357437b3.2 for ; Fri, 31 Mar 2023 15:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1680300742; 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=41g0gNip8PYtsk9bkFs48ZdWfSIXcjOsD7LB6Xshlhc=; b=lHoMWIFJTuqI+8Cwf2cHlVcCn/m4jjolUFhI/WQbjtrqeI/y/RQdSMCUS5dRtKjPDb DlYjsOvV/xD5u3tQVGIShaYjyddVjs0gbX1g0+nKv3YfRrFw3cVlycus6fwJF0Zj8bWv hCFALCWenLouG3eC+5I+lZSlO9QWPFxR7oe+g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680300742; 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=41g0gNip8PYtsk9bkFs48ZdWfSIXcjOsD7LB6Xshlhc=; b=gNDye+8wwaG72dhB65quT/rE6+beUgVoMr7OZPhgYTYPZ+mkcRztxUSTOx1Llu6fZk hv1/HKViKt7NoINxWINB8Ntzr01R38V8rbHNfgAR358MMeYrd14seg48sEXilJ/gzFhA LUZ9bOVLmdK4nhhxN70az8OaQO5J0MS3L4U7iozESXpTmE0oBo512Ils0wK6RhMB3tgw f4P2S55n/TjTTx3kFfjppwRnkkJKNuSpq3wPAYV0n0ACsNC1nM5gTtEPU7JBk+ltSCnr TYLGBjCuWpnSBRWDjhZcuCEGBovERGuvxfm/EYvKb+xUujB3SKOtK1f+j0KrStFjFurt tZSQ== X-Gm-Message-State: AAQBX9fn71EdtFGhFlRNV0LvfkyC2NjR3B9RtkpYBGUAMPSJbbOgIRuH JESkBpA2cfEBQaSDYjk9yludrw== X-Google-Smtp-Source: AKy350aWWLZitIc4NBmciDyuRlAlsMqjsbroWOg1uVcQuHufgHyzzdwjAPbP0Au4zEn/DHJnbrYMYw== X-Received: by 2002:a81:7508:0:b0:544:e183:762d with SMTP id q8-20020a817508000000b00544e183762dmr29564744ywc.37.1680300742109; Fri, 31 Mar 2023 15:12:22 -0700 (PDT) Received: from localhost ([2620:0:1035:15:a8f6:869a:3ef5:e1d]) by smtp.gmail.com with UTF8SMTPSA id bj5-20020a05690c044500b00545a0818501sm763457ywb.145.2023.03.31.15.12.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 Mar 2023 15:12:21 -0700 (PDT) From: Mark Yacoub X-Google-Original-From: Mark Yacoub To: David Airlie , Daniel Vetter Date: Fri, 31 Mar 2023 18:12:05 -0400 Message-Id: <20230331221213.1691997-4-markyacoub@google.com> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog In-Reply-To: <20230331221213.1691997-1-markyacoub@google.com> References: <20230331221213.1691997-1-markyacoub@google.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v8 03/10] drm/hdcp: Update property value on content type and user changes 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: Jani Nikula , Mark Yacoub , intel-gfx@lists.freedesktop.org, dianders@chromium.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, seanpaul@chromium.org, Rodrigo Vivi , freedreno@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Sean Paul Update the connector's property value in 2 cases which were previously missed: 1- Content type changes. The value should revert back to DESIRED from ENABLED in case the driver must re-authenticate the link due to the new content type. 2- Userspace sets value to DESIRED while ENABLED. In this case, the value should be reset immediately to ENABLED since the link is actively being encrypted. To accommodate these changes, I've split up the conditionals to make things a bit more clear (as much as one can with this mess of state). Acked-by: Jani Nikula Reviewed-by: Rodrigo Vivi Signed-off-by: Sean Paul Signed-off-by: Mark Yacoub --- Changes in v2: -None Changes in v3: -Fixed indentation issue identified by 0-day Changes in v4: -None Changes in v5: -None Changes in v6: -Rebased: modifications in drm_hdcp_helper.c instead of drm_hdcp.c Changes in v7: -Rebased as function name has changed. Changes in v8: -None drivers/gpu/drm/display/drm_hdcp_helper.c | 29 +++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/display/drm_hdcp_helper.c b/drivers/gpu/drm/display/drm_hdcp_helper.c index 34baf2b97cd87..3ee1a6ae26c53 100644 --- a/drivers/gpu/drm/display/drm_hdcp_helper.c +++ b/drivers/gpu/drm/display/drm_hdcp_helper.c @@ -480,21 +480,30 @@ bool drm_hdcp_has_changed(struct drm_connector *connector, return true; /* - * Nothing to do if content type is unchanged and one of: - * - state didn't change - * - HDCP was activated since the last commit - * - attempting to set to desired while already enabled + * Content type changes require an HDCP disable/enable cycle. */ - if (old_hdcp == new_hdcp || - (old_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED && + if (new_conn_state->hdcp_content_type != + old_conn_state->hdcp_content_type) { + new_conn_state->content_protection = + DRM_MODE_CONTENT_PROTECTION_DESIRED; + return true; + } + + /* + * Ignore meaningless state changes: + * - HDCP was activated since the last commit + * - Attempting to set to desired while already enabled + */ + if ((old_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED && new_hdcp == DRM_MODE_CONTENT_PROTECTION_ENABLED) || (old_hdcp == DRM_MODE_CONTENT_PROTECTION_ENABLED && new_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED)) { - if (old_conn_state->hdcp_content_type == - new_conn_state->hdcp_content_type) - return false; + new_conn_state->content_protection = + DRM_MODE_CONTENT_PROTECTION_ENABLED; + return false; } - return true; + /* Finally, if state changes, we need action */ + return old_hdcp != new_hdcp; } EXPORT_SYMBOL(drm_hdcp_has_changed);