From patchwork Wed Feb 14 14:13:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 10219111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA26560467 for ; Wed, 14 Feb 2018 14:21:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B658288FC for ; Wed, 14 Feb 2018 14:21:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 902FD28FEE; Wed, 14 Feb 2018 14:21:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 47DFD288FC for ; Wed, 14 Feb 2018 14:21:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B0EA86E42B; Wed, 14 Feb 2018 14:21:01 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id C2A936E42D for ; Wed, 14 Feb 2018 14:20:59 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2018 06:20:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,512,1511856000"; d="scan'208";a="204077037" Received: from mint-dev.iind.intel.com ([10.223.25.164]) by fmsmga005.fm.intel.com with ESMTP; 14 Feb 2018 06:20:57 -0800 From: Ramalingam C To: seanpaul@chromium.org, intel-gfx@lists.freedesktop.org, rodrigo.vivi@intel.com, daniel.vetter@ffwll.ch Date: Wed, 14 Feb 2018 19:43:46 +0530 Message-Id: <1518617638-21684-32-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518617638-21684-1-git-send-email-ramalingam.c@intel.com> References: <1518617638-21684-1-git-send-email-ramalingam.c@intel.com> Subject: [Intel-gfx] [PATCH 31/43] drm/i915: Implement HDCP2.2 En/Dis-able X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tomas.winkler@intel.com MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Implements a sequence of enabling and disabling the HDCP2.2 (auth and encryption). Signed-off-by: Ramalingam C --- drivers/gpu/drm/i915/intel_hdcp.c | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c index 6a0506cdefd5..8bf30513713a 100644 --- a/drivers/gpu/drm/i915/intel_hdcp.c +++ b/drivers/gpu/drm/i915/intel_hdcp.c @@ -22,6 +22,9 @@ #define HDCP2_LC_RETRY_CNT 3 #define TIME_FOR_ENCRYPT_STATUS_CHANGE 32 +static int _intel_hdcp2_enable(struct intel_hdcp *hdcp); +static int _intel_hdcp2_disable(struct intel_hdcp *hdcp); + static int intel_hdcp_poll_ksv_fifo(struct intel_digital_port *intel_dig_port, const struct intel_hdcp_shim *shim) { @@ -1386,3 +1389,70 @@ static int hdcp2_disable_encryption(struct intel_hdcp *hdcp) return ret; } + +static int hdcp2_authenticate_and_encrypt(struct intel_hdcp *hdcp) +{ + int ret, i, tries = 3; + + for (i = 0; i < tries; i++) { + ret = hdcp2_authenticate_sink(hdcp); + if (!ret) + break; + + /* Clearing the mei hdcp session */ + hdcp2_deauthenticate_port(hdcp); + DRM_DEBUG_KMS("HDCP2.2 Reauth %d of %d\n", i + 1, tries); + } + + if (!ret) { + + /* + * Ensuring the required 200mSec min time interval between + * Session Key Exchange and encryption. + */ + msleep(HDCP_2_2_DELAY_BEFORE_ENCRYPTION_EN); + ret = hdcp2_enable_encryption(hdcp); + if (ret < 0) + DRM_DEBUG_KMS("Encryption Enable Failed. %d\n", ret); + } + + return ret; +} + +static int _intel_hdcp2_disable(struct intel_hdcp *hdcp) +{ + int ret; + + DRM_ERROR("[%s:%d] HDCP2.2 is being Disabled\n", + hdcp->connector->base.name, hdcp->connector->base.base.id); + + ret = hdcp2_disable_encryption(hdcp); + + hdcp2_deauthenticate_port(hdcp); + + return ret; +} + +static int _intel_hdcp2_enable(struct intel_hdcp *hdcp) +{ + struct intel_connector *connector = hdcp->connector; + int ret; + + DRM_INFO("[%s:%d] HDCP2.2 is being enabled. Type: %d\n", + connector->base.name, connector->base.base.id, + hdcp->content_type); + + ret = hdcp2_authenticate_and_encrypt(hdcp); + if (ret) { + DRM_ERROR("HDCP2 Enabling Failed. (%d)\n", ret); + return ret; + } + + DRM_INFO("[%s:%d] HDCP2.2 is enabled. Type %d\n", connector->base.name, + connector->base.base.id, hdcp->content_type); + + hdcp->hdcp_value = DRM_MODE_CONTENT_PROTECTION_ENABLED; + schedule_work(&hdcp->hdcp_prop_work); + + return 0; +}