From patchwork Fri Apr 5 08:43:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 10887051 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 DDD3E1515 for ; Fri, 5 Apr 2019 08:42:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8B6D28AA1 for ; Fri, 5 Apr 2019 08:42:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA40928B04; Fri, 5 Apr 2019 08:42:02 +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=unavailable 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 345C328AA1 for ; Fri, 5 Apr 2019 08:42:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6F2DF6E318; Fri, 5 Apr 2019 08:41:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0FD806E2BC; Fri, 5 Apr 2019 08:41:46 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2019 01:41:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,310,1549958400"; d="scan'208";a="146807024" Received: from ram-dut.iind.intel.com ([10.223.34.157]) by FMSMGA003.fm.intel.com with ESMTP; 05 Apr 2019 01:41:44 -0700 From: Ramalingam C To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH v4 12/13] drm: Add CP downstream_info property Date: Fri, 5 Apr 2019 14:13:01 +0530 Message-Id: <20190405084302.5548-13-ramalingam.c@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190405084302.5548-1-ramalingam.c@intel.com> References: <20190405084302.5548-1-ramalingam.c@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gwan-gyeong.mun@intel.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a optional CP downstream info blob property to the connectors. This enables the Userspace to read the information of HDCP authenticated downstream topology. Driver will update this blob with all downstream information at the end of the authentication. In case userspace configures this platform as repeater, then this information is needed for the authentication with upstream HDCP transmitter. v2: s/cp_downstream/content_protection_downstream [daniel] v3: s/content_protection_downstream/hdcp_topology [daniel] v4: hdcp_topology_info struct is added with explicit padding [Daniel] Signed-off-by: Ramalingam C --- drivers/gpu/drm/drm_atomic_uapi.c | 3 ++ drivers/gpu/drm/drm_connector.c | 20 ++++++++++ drivers/gpu/drm/drm_hdcp.c | 65 +++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 6 +++ include/drm/drm_hdcp.h | 6 +++ include/drm/drm_mode_config.h | 6 +++ include/uapi/drm/drm_mode.h | 37 ++++++++++++++++++ 7 files changed, 143 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index fa50fac2e952..3a1858d5730c 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -826,6 +826,9 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = state->content_protection; } else if (property == config->hdcp_content_type_property) { *val = state->hdcp_content_type; + } else if (property == config->hdcp_topology_property) { + *val = connector->hdcp_topology_blob_ptr ? + connector->hdcp_topology_blob_ptr->base.id : 0; } 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 436cf8e764cc..033ced774d37 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -246,6 +246,7 @@ int drm_connector_init(struct drm_device *dev, mutex_init(&connector->mutex); connector->edid_blob_ptr = NULL; connector->tile_blob_ptr = NULL; + connector->hdcp_topology_blob_ptr = NULL; connector->status = connector_status_unknown; connector->display_info.panel_orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; @@ -972,6 +973,25 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] = { * authentication process. If content type is changed when * content_protection is not UNDESIRED, then kernel will disable the HDCP * and re-enable with new type in the same atomic commit + * HDCP Topology: + * This blob property is used to pass the HDCP downstream topology details + * of a HDCP encrypted connector, from kernel to userspace. + * This provides all required information to userspace, so that userspace + * can implement the HDCP repeater using the kernel as downstream ports of + * the repeater. as illustrated below: + * + * HDCP Repeaters + * +--------------------------------------------------------------+ + * | | + * | | | + * | Userspace HDCP Receiver +-----> KMD HDCP transmitters | + * | (Upstream Port) <------+ (Downstream Ports) | + * | | | + * | | + * +--------------------------------------------------------------+ + * + * Kernel will populate this blob only when the HDCP authentication is + * successful. * * max bpc: * This range property is used by userspace to limit the bit depth. When diff --git a/drivers/gpu/drm/drm_hdcp.c b/drivers/gpu/drm/drm_hdcp.c index 38c90c053cdd..3f57ca424a1b 100644 --- a/drivers/gpu/drm/drm_hdcp.c +++ b/drivers/gpu/drm/drm_hdcp.c @@ -444,3 +444,68 @@ void drm_hdcp_update_content_protection(struct drm_connector *connector, dev->mode_config.content_protection_property); } EXPORT_SYMBOL(drm_hdcp_update_content_protection); + +/** + * drm_connector_attach_hdcp_topology_property - attach hdcp topology property + * + * @connector: connector to attach hdcp topology property with. + * + * This is used to add support for hdcp topology support on select connectors. + * When Intel platform is configured as repeater, this downstream info is used + * by userspace, to complete the repeater authentication of HDCP specification + * with upstream HDCP transmitter. + * + * The blob_id of the hdcp topology info will be set to + * &drm_connector_state.hdcp_topology + * + * Returns: + * Zero on success, negative errno on failure. + */ +int drm_connector_attach_hdcp_topology_property(struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + struct drm_property *prop = dev->mode_config.hdcp_topology_property; + + if (!prop) + prop = drm_property_create(dev, DRM_MODE_PROP_BLOB | + DRM_MODE_PROP_IMMUTABLE, + "HDCP Topology", 0); + if (!prop) + return -ENOMEM; + + drm_object_attach_property(&connector->base, prop, 0); + dev->mode_config.hdcp_topology_property = prop; + return 0; +} +EXPORT_SYMBOL(drm_connector_attach_hdcp_topology_property); + +/** + * drm_connector_update_hdcp_topology_property - update the hdcp topology + * property of a connector + * @connector: drm connector, the topology is associated to + * @hdcp_topology_info: new content for the blob of hdcp_topology_property + * + * This function creates a new blob modeset object and assigns its id to the + * connector's hdcp_topology_property. + * + * Returns: + * Zero on success, negative errno on failure. + */ +int +drm_connector_update_hdcp_topology_property(struct drm_connector *connector, + const struct hdcp_topology_info *info) +{ + struct drm_device *dev = connector->dev; + int ret; + + if (!info) + return -EINVAL; + + ret = drm_property_replace_global_blob(dev, + &connector->hdcp_topology_blob_ptr, + sizeof(struct hdcp_topology_info), + info, &connector->base, + dev->mode_config.hdcp_topology_property); + return ret; +} +EXPORT_SYMBOL(drm_connector_update_hdcp_topology_property); diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index ed68af1a3f8f..66229a4bee35 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1012,6 +1012,12 @@ struct drm_connector { /** @properties: property tracking for this connector */ struct drm_object_properties properties; + /** + * @hdcp_topology_blob_ptr: DRM BLOB pointer for hdcp downstream + * topology information. + */ + struct drm_property_blob *hdcp_topology_blob_ptr; + /** * @scaling_mode_property: Optional atomic property to control the * upscaling. See drm_connector_attach_content_protection_property(). diff --git a/include/drm/drm_hdcp.h b/include/drm/drm_hdcp.h index f0ef42247f2c..fdd65a14f4db 100644 --- a/include/drm/drm_hdcp.h +++ b/include/drm/drm_hdcp.h @@ -299,11 +299,17 @@ struct hdcp2_srm_header { } __packed; struct drm_connector; +struct hdcp_topology_info; bool drm_hdcp_ksvs_revocated(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); +int drm_connector_attach_hdcp_topology_property( + struct drm_connector *connector); +int drm_connector_update_hdcp_topology_property( + struct drm_connector *connector, + const struct hdcp_topology_info *info); #endif diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index b359b5b71eb9..4349b614fa15 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -848,6 +848,12 @@ struct drm_mode_config { */ struct drm_property *hdcp_content_type_property; + /** + * @hdcp_topology_property: DRM BLOB property for hdcp downstream + * topology information. + */ + struct drm_property *hdcp_topology_property; + /* dumb ioctl parameters */ uint32_t preferred_depth, prefer_shadow; diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 44412e8b77cd..251865679dfc 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -214,6 +214,43 @@ extern "C" { #define DRM_MODE_HDCP_CONTENT_TYPE0 0 #define DRM_MODE_HDCP_CONTENT_TYPE1 1 +#define DRM_MODE_HDCP_KSV_LEN 5 +#define DRM_MODE_HDCP_MAX_DEVICE_CNT 127 +#define DRM_MODE_HDCP14_IN_FORCE (1 << 0) +#define DRM_MODE_HDCP22_IN_FORCE (1 << 1) + +struct hdcp_topology_info { + /* Version of HDCP authenticated (1.4/2.2) */ + __u32 ver_in_force; + + /* Applicable only for HDCP2.2 */ + __u32 content_type; + + /* KSV of immediate HDCP Sink. In Little-Endian Format. */ + __u8 bksv[DRM_MODE_HDCP_KSV_LEN]; + + /* Whether Immediate HDCP sink is a repeater? */ + __u8 is_repeater; + + /* Depth received from immediate downstream repeater */ + __u8 depth; + __u8 pad1; + + /* Device count received from immediate downstream repeater */ + __u32 device_count; + + /* + * Max buffer required to hold ksv list received from immediate + * repeater. In this array first device_count * DRM_MODE_HDCP_KSV_LEN + * will hold the valid ksv bytes. + * If authentication specification is + * HDCP1.4 - each KSV's Bytes will be in Little-Endian format. + * HDCP2.2 - each KSV's Bytes will be in Big-Endian format. + */ + __u8 ksv_list[DRM_MODE_HDCP_KSV_LEN * DRM_MODE_HDCP_MAX_DEVICE_CNT]; + __u8 pad2[5]; +} __packed; + struct drm_mode_modeinfo { __u32 clock; __u16 hdisplay;