From patchwork Wed May 27 11:01:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nautiyal, Ankit K" X-Patchwork-Id: 11572613 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9F7290 for ; Wed, 27 May 2020 11:06:46 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C29AF2075A for ; Wed, 27 May 2020 11:06:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C29AF2075A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF19B6E2D7; Wed, 27 May 2020 11:06:45 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id BF2D66E2D7 for ; Wed, 27 May 2020 11:06:42 +0000 (UTC) IronPort-SDR: vB2X4F4GYtL6SM2ynXSudlaK58j5RpPlnucjBixBpO7K6vc99YsQn/p04rucIYGXjZp1Ue/ECa ciKZSIvly92Q== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2020 04:06:42 -0700 IronPort-SDR: Njs3wOb7544eVNXjNJO/4HaLt1dbc0MYNmj2aLkucwsdlO+Uqnhz2HtqzEy8AFE+6nanDmqVlP WlJbF6IYmlTQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,441,1583222400"; d="scan'208";a="375994969" Received: from unknown (HELO linux-akn.iind.intel.com) ([10.223.34.148]) by fmsmga001.fm.intel.com with ESMTP; 27 May 2020 04:06:40 -0700 From: Ankit Nautiyal To: intel-gfx@lists.freedesktop.org Date: Wed, 27 May 2020 16:31:31 +0530 Message-Id: <20200527110132.16679-2-ankit.k.nautiyal@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200527110132.16679-1-ankit.k.nautiyal@intel.com> References: <20200527110132.16679-1-ankit.k.nautiyal@intel.com> Subject: [Intel-gfx] [RFC 1/2] drm/i915: Add support for considering HDCP ver requested via debugfs 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@intel.com, martin.peres@intel.com MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" For testing and debugging each HDCP version separately, a debugfs entry for requesting a specific version is required. The vesion requested via debugfs needs to be stored in hdcp structure. This can then be considered while enabling HDCP, provided the platform and the display supports the requested version. This patch adds the support for storing the version requested as a 32bit flag. The default value is set to signify that any of the HDCP version can be used. If a specific HDCP version is requested through the debugfs, the driver chooses that version, instead of policy of choosing the highest HDCP version supported. Signed-off-by: Ankit Nautiyal --- drivers/gpu/drm/i915/display/intel_display_types.h | 10 ++++++++++ drivers/gpu/drm/i915/display/intel_hdcp.c | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 9488449e4b94..cfa641c70717 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -408,6 +408,16 @@ struct intel_hdcp { * Hence caching the transcoder here. */ enum transcoder cpu_transcoder; + + /* + * HDCP version requested from debugfs i915_hdcp_ver_request. + * Kernel will read these bits and entertain the request, as per + * the HDCP capability of the panel and platform. + */ +#define HDCP_VERSION_1_4 0x01 +#define HDCP_VERSION_2_2 0x02 +#define HDCP_VERSION_MASK 0x03 + u32 debugfs_ver_request; }; struct intel_connector { diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c index 2cbc4619b4ce..951401046804 100644 --- a/drivers/gpu/drm/i915/display/intel_hdcp.c +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c @@ -1977,6 +1977,8 @@ int intel_hdcp_init(struct intel_connector *connector, if (!shim) return -EINVAL; + hdcp->debugfs_ver_request = HDCP_VERSION_MASK; + if (is_hdcp2_supported(dev_priv)) intel_hdcp2_init(connector, shim); @@ -2023,7 +2025,8 @@ int intel_hdcp_enable(struct intel_connector *connector, * Considering that HDCP2.2 is more secure than HDCP1.4, If the setup * is capable of HDCP2.2, it is preferred to use HDCP2.2. */ - if (intel_hdcp2_capable(connector)) { + if ((hdcp->debugfs_ver_request & HDCP_VERSION_2_2) && + intel_hdcp2_capable(connector)) { ret = _intel_hdcp2_enable(connector); if (!ret) check_link_interval = DRM_HDCP2_CHECK_PERIOD_MS; @@ -2033,7 +2036,8 @@ int intel_hdcp_enable(struct intel_connector *connector, * When HDCP2.2 fails and Content Type is not Type1, HDCP1.4 will * be attempted. */ - if (ret && intel_hdcp_capable(connector) && + if (ret && (hdcp->debugfs_ver_request & HDCP_VERSION_1_4) && + intel_hdcp_capable(connector) && hdcp->content_type != DRM_MODE_HDCP_CONTENT_TYPE1) { ret = _intel_hdcp_enable(connector); } From patchwork Wed May 27 11:01:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nautiyal, Ankit K" X-Patchwork-Id: 11572615 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C10E60D for ; Wed, 27 May 2020 11:06:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 54B872075A for ; Wed, 27 May 2020 11:06:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54B872075A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EFDF66E2D8; Wed, 27 May 2020 11:06:45 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id BC1156E2D7 for ; Wed, 27 May 2020 11:06:44 +0000 (UTC) IronPort-SDR: wegdHOAfkV73Dl12dA0hwa3x1F8ok7ousOUqFJtSyN83CbXUoV6ZyL+v5m7In2H3UwDoWYs4JA YWIF0I5fvyAQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2020 04:06:44 -0700 IronPort-SDR: wJTY4ufHUn4vznItWwdoboefwewFPJy3o8CXxFwCa4k1BvlsYBPM5EMtxmBNca1G1m+sKd8teW eREgRz2MjRNg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,441,1583222400"; d="scan'208";a="375994977" Received: from unknown (HELO linux-akn.iind.intel.com) ([10.223.34.148]) by fmsmga001.fm.intel.com with ESMTP; 27 May 2020 04:06:42 -0700 From: Ankit Nautiyal To: intel-gfx@lists.freedesktop.org Date: Wed, 27 May 2020 16:31:32 +0530 Message-Id: <20200527110132.16679-3-ankit.k.nautiyal@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200527110132.16679-1-ankit.k.nautiyal@intel.com> References: <20200527110132.16679-1-ankit.k.nautiyal@intel.com> Subject: [Intel-gfx] [RFC 2/2] drm/i915: Add a new debugfs to request HDCP version 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@intel.com, martin.peres@intel.com MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" As per the current HDCP design, the driver selects the highest version of HDCP that can be used to satisfy the content-protection requirements of the user. Due to this, the content-protection tests cannot test a lower version of HDCP, if the platform and the display panel, both support higher HDCP version. To provide some support for testing and debugging, a per-connector debugfs is required to set the HDCP version via debugfs that the kernel can consider, while enabling HDCP. This patch adds a new debugfs entry for each connector that supports HDCP. For enforcing a particular HDCP version for a connector, the user can write into the debugfs for that connector. To make design simple, the HDCP version request can only be made via debugfs, if there is no ongoing request for Content-Protection for the connector. The tests are expected to make sure that HDCP is disabled before making HDCP version request via the debugfs for the connector. Otherwise, the write request to the debugfs will be failed. Signed-off-by: Ankit Nautiyal --- .../drm/i915/display/intel_display_debugfs.c | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c b/drivers/gpu/drm/i915/display/intel_display_debugfs.c index 70525623bcdf..e65abca1a1fa 100644 --- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c +++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c @@ -2185,6 +2185,102 @@ static const struct file_operations i915_dsc_fec_support_fops = { .write = i915_dsc_fec_support_write }; +static int i915_hdcp_ver_request_show(struct seq_file *m, void *data) +{ + + struct drm_connector *connector = m->private; + struct intel_connector *intel_connector = to_intel_connector(connector); + u64 hdcp_ver_flag; + + if (connector->status != connector_status_connected) + return -ENODEV; + + /* HDCP is supported by connector */ + if (!intel_connector->hdcp.shim) + return -EINVAL; + + hdcp_ver_flag = intel_connector->hdcp.debugfs_ver_request; + seq_printf(m, "HDCP_VER_FLAGS: %llu\n", hdcp_ver_flag); + + seq_printf(m, "Requested Versions:\n"); + if (hdcp_ver_flag & HDCP_VERSION_1_4) + seq_printf(m, "HDCP1.4\n"); + if (hdcp_ver_flag & HDCP_VERSION_2_2) + seq_printf(m, "HDCP2.2\n"); + + return 0; +} + +static int i915_hdcp_ver_request_open(struct inode *inode, + struct file *file) +{ + return single_open(file, i915_hdcp_ver_request_show, + inode->i_private); +} + +static int intel_hdcp_debugfs_ver_set(struct intel_connector *connector, u64 val) +{ + struct intel_hdcp *hdcp = &connector->hdcp; + + if (!hdcp->shim || val > HDCP_VERSION_MASK) + return -EINVAL; + + if (hdcp->value != DRM_MODE_CONTENT_PROTECTION_UNDESIRED) + return -EINVAL; + + hdcp->debugfs_ver_request = val; + return 0; +} + +static ssize_t i915_hdcp_ver_request_write(struct file *file, + const char __user *ubuf, + size_t len, loff_t *offp) +{ + unsigned int hdcp_ver = 0; + int ret; + struct drm_connector *connector = + ((struct seq_file *)file->private_data)->private; + struct intel_connector *intel_con = to_intel_connector(connector); + struct drm_i915_private *i915 = to_i915(connector->dev); + char tmp[16]; + + if (len == 0) + return 0; + + if (len >= sizeof(tmp)) + return -EINVAL; + + if (copy_from_user(tmp, ubuf, len)) + return -EFAULT; + + tmp[len] = '\0'; + + + drm_dbg(&i915->drm, + "Copied %zu bytes from user to request hdcp ver\n", len); + + ret = kstrtouint(tmp, 10, &hdcp_ver); + if (ret < 0) + return ret; + + drm_dbg(&i915->drm, "Got %u for HDCP version\n", hdcp_ver); + ret = intel_hdcp_debugfs_ver_set(intel_con, hdcp_ver); + if (ret < 0) + return ret; + + *offp += len; + return len; +} + +static const struct file_operations i915_hdcp_ver_request_fops = { + .owner = THIS_MODULE, + .open = i915_hdcp_ver_request_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = i915_hdcp_ver_request_write +}; + /** * intel_connector_debugfs_add - add i915 specific connector debugfs files * @connector: pointer to a registered drm_connector @@ -2215,6 +2311,8 @@ int intel_connector_debugfs_add(struct drm_connector *connector) connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { debugfs_create_file("i915_hdcp_sink_capability", S_IRUGO, root, connector, &i915_hdcp_sink_capability_fops); + debugfs_create_file("i915_hdcp_version_request", S_IRUGO, root, + connector, &i915_hdcp_ver_request_fops); } if (INTEL_GEN(dev_priv) >= 10 &&