From patchwork Tue Feb 26 07:36:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 10829613 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D1EFA1805 for ; Tue, 26 Feb 2019 07:42:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C40A82AA7E for ; Tue, 26 Feb 2019 07:42:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B86772AAA8; Tue, 26 Feb 2019 07:42: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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 33AB72AA7E for ; Tue, 26 Feb 2019 07:42:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BF22689C82; Tue, 26 Feb 2019 07:42:04 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 200FE89B95; Tue, 26 Feb 2019 07:42:03 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Feb 2019 23:42:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,414,1544515200"; d="scan'208";a="125259422" Received: from mint-dev.iind.intel.com ([10.223.25.164]) by fmsmga007.fm.intel.com with ESMTP; 25 Feb 2019 23:42:01 -0800 From: Ramalingam C To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, uma.shankar@intel.com Date: Tue, 26 Feb 2019 13:06:00 +0530 Message-Id: <1551166569-19683-2-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551166569-19683-1-git-send-email-ramalingam.c@intel.com> References: <1551166569-19683-1-git-send-email-ramalingam.c@intel.com> Subject: [Intel-gfx] [PATCH 01/10] drm: Add CP content type property 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a DRM ENUM property to the selected connectors. This property is used for pass the protected content's type from userspace to kernel HDCP authentication. Type of the stream is decided by the protected content providers as Type 0/1. Type 0 content can be rendered on any HDCP protected display wires. But Type 1 content can be rendered only on HDCP2.2 protected paths. So upon a content protection request with Type 1 as Content type from userspace, Kernel will declare success only if the HDCP2.2 authentication is successful. Signed-off-by: Ramalingam C --- drivers/gpu/drm/drm_atomic_uapi.c | 10 ++++++ drivers/gpu/drm/drm_connector.c | 64 +++++++++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 15 +++++++++ include/uapi/drm/drm_mode.h | 4 +++ 4 files changed, 93 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 4eb81f10bc54..5289486565ce 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -746,6 +746,14 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, return -EINVAL; } state->content_protection = val; + } else if (property == connector->cp_content_type_property) { + if (state->content_protection != + DRM_MODE_CONTENT_PROTECTION_UNDESIRED && + state->cp_content_type != val) { + DRM_DEBUG_KMS("Disable CP, then change Type\n"); + return -EINVAL; + } + state->cp_content_type = val; } else if (property == connector->colorspace_property) { state->colorspace = val; } else if (property == config->writeback_fb_id_property) { @@ -822,6 +830,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = state->scaling_mode; } else if (property == connector->content_protection_property) { *val = state->content_protection; + } else if (property == connector->cp_content_type_property) { + *val = state->cp_content_type; } else if (property == config->writeback_fb_id_property) { /* Writeback framebuffer is one-shot, write and forget */ *val = 0; diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 07d65a16c623..5d7738e1e977 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -853,6 +853,13 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] = { { DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-P3_RGB_Theater" }, }; +static struct drm_prop_enum_list drm_cp_content_type_enum_list[] = { + { DRM_MODE_CP_CONTENT_TYPE0, "Type 0" }, + { DRM_MODE_CP_CONTENT_TYPE1, "Type 1" }, +}; + +DRM_ENUM_NAME_FN(drm_get_cp_content_type_name, drm_cp_content_type_enum_list) + /** * DOC: standard connector properties * @@ -958,6 +965,25 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] = { * the value transitions from ENABLED to DESIRED. This signifies the link * is no longer protected and userspace should take appropriate action * (whatever that might be). + * CP_Content_Type: + * This property is used by the userspace to configure the kernel with + * upcoming stream's content type. Content Type of a stream is decided by + * the owner of the stream, as Type 0 or Type 1. + * + * The value of the property can be one the below: + * - DRM_MODE_CP_CONTENT_TYPE0 = 0 + * Type 0 streams can be transmitted on a link which is encrypted + * with HDCP 1.4 or HDCP 2.2. + * - DRM_MODE_CP_CONTENT_TYPE1 = 1 + * Type 1 streams can be transmitted on a link which is encrypted + * only with HDCP2.2. + * + * Please note this content type is introduced at HDCP2.2 and used in its + * authentication process. + * + * Guideline for programming: + * - Property state can be changed only when "Content Protection state is + * DRM_MODE_CONTENT_PROTECTION_UNDESIRED. * * max bpc: * This range property is used by userspace to limit the bit depth. When @@ -1548,6 +1574,44 @@ int drm_connector_attach_content_protection_property( EXPORT_SYMBOL(drm_connector_attach_content_protection_property); /** + * drm_connector_attach_cp_content_type_property - attach cp content type + * property + * + * @connector: connector to attach cp content type property on. + * + * This is used to add support for sending the protected content's stream type + * from userspace to kernel on selected connectors. Protected content provider + * will decide their type of their content and declare the same to kernel. + * + * This information will be used during the HDCP2.2 authentication. + * + * Content type will be set to &drm_connector_state.cp_content_type. + * + * Returns: + * Zero on success, negative errno on failure. + */ +int +drm_connector_attach_cp_content_type_property(struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + struct drm_property *prop; + + prop = drm_property_create_enum(dev, 0, "CP_Content_Type", + drm_cp_content_type_enum_list, + ARRAY_SIZE( + drm_cp_content_type_enum_list)); + if (!prop) + return -ENOMEM; + + drm_object_attach_property(&connector->base, prop, + DRM_MODE_CP_CONTENT_TYPE0); + connector->cp_content_type_property = prop; + + return 0; +} +EXPORT_SYMBOL(drm_connector_attach_cp_content_type_property); + +/** * drm_mode_create_aspect_ratio_property - create aspect ratio property * @dev: DRM device * diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index c8061992d6cb..820feb7f0b42 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -519,6 +519,12 @@ struct drm_connector_state { unsigned int content_type; /** + * @cp_content_type: Connector property to pass the type of protected + * content. This is most commonly used for HDCP. + */ + unsigned int cp_content_type; + + /** * @scaling_mode: Connector property to control the * upscaling, mostly used for built-in panels. */ @@ -1036,6 +1042,12 @@ struct drm_connector { struct drm_property *colorspace_property; /** + * @cp_content_type_property: DRM ENUM property for type of + * Protected Content. + */ + struct drm_property *cp_content_type_property; + + /** * @path_blob_ptr: * * DRM blob property data for the DP MST path property. This should only @@ -1294,6 +1306,7 @@ const char *drm_get_dvi_i_select_name(int val); const char *drm_get_tv_subconnector_name(int val); const char *drm_get_tv_select_name(int val); const char *drm_get_content_protection_name(int val); +const char *drm_get_cp_content_type_name(int val); int drm_mode_create_dvi_i_properties(struct drm_device *dev); int drm_mode_create_tv_margin_properties(struct drm_device *dev); @@ -1309,6 +1322,8 @@ int drm_connector_attach_vrr_capable_property( struct drm_connector *connector); int drm_connector_attach_content_protection_property( struct drm_connector *connector); +int drm_connector_attach_cp_content_type_property( + struct drm_connector *connector); int drm_mode_create_aspect_ratio_property(struct drm_device *dev); int drm_mode_create_colorspace_property(struct drm_connector *connector); int drm_mode_create_content_type_property(struct drm_device *dev); diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index a439c2e67896..8504e3110e19 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -210,6 +210,10 @@ extern "C" { #define DRM_MODE_CONTENT_PROTECTION_DESIRED 1 #define DRM_MODE_CONTENT_PROTECTION_ENABLED 2 +/* Content Type classification for HDCP2.2 vs others */ +#define DRM_MODE_CP_CONTENT_TYPE0 0 +#define DRM_MODE_CP_CONTENT_TYPE1 1 + struct drm_mode_modeinfo { __u32 clock; __u16 hdisplay;