From patchwork Thu Dec 4 19:03:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 5439871 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 12E3A9F456 for ; Thu, 4 Dec 2014 19:03:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF810201C0 for ; Thu, 4 Dec 2014 19:03:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BC35620373 for ; Thu, 4 Dec 2014 19:03:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 082246E284; Thu, 4 Dec 2014 11:03:56 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ie0-f182.google.com (mail-ie0-f182.google.com [209.85.223.182]) by gabe.freedesktop.org (Postfix) with ESMTP id 7498F6E089 for ; Thu, 4 Dec 2014 11:03:54 -0800 (PST) Received: by mail-ie0-f182.google.com with SMTP id x19so16349933ier.27 for ; Thu, 04 Dec 2014 11:03:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=x6KlisRkxQaofq9cihpxVg8EPXhqEXuw1ma06gew1rA=; b=DoxQ6INEbb44OgK1cS/Hweqy33Ygw38IOq+W1KlTllceNrQ9XholLjvF32u/BPCkXQ LjKKfOHsAtZOZEoP5U/iD2yGdffaz8Qx4azWUyGBEKvnZLOqyA3NDXpxxmS6nWgOQXq6 VYoPjp6i9N0gf1ywE+prkSSVwxBKvra0d38Fg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=x6KlisRkxQaofq9cihpxVg8EPXhqEXuw1ma06gew1rA=; b=Ey5ydNEVQ1QdmKPwW90NtD+lcXancMuEJQty4sz9bAAV1pwG5ao/z798+TPl0WkRqJ QbJDbuquEez6sMS99Y/Z9qHW6vtBemD761kLF1e7TZCORUt7PKqfF+tNzguMjTA7hakC fmgp96DTcboBwVtTF5BfOrHDopNcdV0AOQqPhpov1ttIMN2WhoOa6YWFd+BPtSNDcIUB neTdAri3CyMsHevqdo4OZGg+sB00FmEOd6Ws37/RxdCA+yxGAJ71PU05BQ9l2pThbNms TM+DzmABluL2m30Ah2ObGZuU8GKvVl1TASJkM4BJagSzqrbYEllTD2mo4ljB5hFyKFiN jOZA== X-Gm-Message-State: ALoCoQnMRTSI7hWzc1G9/uqJSrkikcDFqaTeDCw4eS/z+JN/WyqJr8rdQPiYXT83hkVftsEFW343 X-Received: by 10.50.79.193 with SMTP id l1mr63534079igx.30.1417719833999; Thu, 04 Dec 2014 11:03:53 -0800 (PST) Received: from davidriley-lab.mtv.corp.google.com ([172.22.64.15]) by mx.google.com with ESMTPSA id n2sm4772003igp.16.2014.12.04.11.03.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Dec 2014 11:03:53 -0800 (PST) From: Sean Paul To: ville.syrjala@linux.intel.com, daniel@ffwll.ch, robdclark@gmail.com, dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/2] drm: Add Content Protection properties to drm Date: Thu, 4 Dec 2014 11:03:44 -0800 Message-Id: <1417719824-26499-1-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <20141204100310.GH32117@phenom.ffwll.local> References: <20141204100310.GH32117@phenom.ffwll.local> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add new standard connector properties to track whether content protection (ex: hdcp) is desired by userspace. There are two properties involved, "Content Protection" and "Content Protection KSV". The "Content Protection" property allows userspace to request protection on a connector. Set "Desired" to enable, "Undesired" to disable. The "Content Protection KSV" property reflects the current state of protection. If the KSV is 0, the connection is not protected. Once the driver has enabled protection, it will update the the value with the KSV (or similarly unique identifier, if not using HDCP) of the first-hop device (sink or repeater). Signed-off-by: Sean Paul --- Changes in v2: - Split property into 2 - one for desired/undesired - one for disabled/ksv Documentation/DocBook/drm.tmpl | 27 ++++++++++++++++++++++++-- drivers/gpu/drm/drm_crtc.c | 18 +++++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 44 ++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 3 +++ include/uapi/drm/drm_mode.h | 4 ++++ 5 files changed, 94 insertions(+), 2 deletions(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 85287cb..8aa6828 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2546,8 +2546,8 @@ void intel_crt_init(struct drm_device *dev) Description/Restrictions - DRM - Generic + DRM + Generic “EDID” BLOB | IMMUTABLE 0 @@ -2562,6 +2562,29 @@ void intel_crt_init(struct drm_device *dev) Contains DPMS operation mode value. + “Content Protection” + ENUM + { “Undesired”, “Desired” } + Connector + Contains the current request state of content + protection from userspace. If "Desired", the driver shall + attempt to encrypt the connection, retrying as appropriate. If + "Undesired", userspace does not need the connection to be + protected. + + + + “Content Protection KSV” + RANGE | IMMUTABLE + 40-bit Receiver/Repeater KSV + Connector + Contains the 40-bit KSV (or similarly unique sink + identifier, if not using HDCP) of the first hop device connected + to the connector if content protection is enabled. If content + protection is disabled, this value should be set to 0. + + + “PATH” BLOB | IMMUTABLE 0 diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index de79283..ba78837 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -77,6 +77,13 @@ static const struct drm_prop_enum_list drm_plane_type_enum_list[] = { DRM_PLANE_TYPE_CURSOR, "Cursor" }, }; +static struct drm_prop_enum_list drm_cp_enum_list[] = { + { DRM_MODE_CONTENT_PROTECTION_UNDESIRED, "Undesired" }, + { DRM_MODE_CONTENT_PROTECTION_DESIRED, "Desired" }, +}; + +DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list) + /* * Optional properties */ @@ -1319,6 +1326,8 @@ static int drm_mode_create_standard_connector_properties(struct drm_device *dev) struct drm_property *edid; struct drm_property *dpms; struct drm_property *dev_path; + struct drm_property *cp; + struct drm_property *cp_ksv; /* * Standard properties (apply to all connectors) @@ -1339,6 +1348,15 @@ static int drm_mode_create_standard_connector_properties(struct drm_device *dev) "PATH", 0); dev->mode_config.path_property = dev_path; + cp = drm_property_create_enum(dev, 0, + "Content Protection", drm_cp_enum_list, + ARRAY_SIZE(drm_cp_enum_list)); + dev->mode_config.content_protection_property = cp; + + cp_ksv = drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, + "Content Protection KSV", 0, 0xFFFFFFFFFF); + dev->mode_config.content_protection_ksv_property = cp_ksv; + return 0; } diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index cc3d6d6..c3550f1 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -214,6 +214,48 @@ static ssize_t enabled_show(struct device *device, "disabled"); } +static ssize_t content_protection_show(struct device *device, + struct device_attribute *attr, char *buf) +{ + struct drm_connector *connector = to_drm_connector(device); + struct drm_device *dev = connector->dev; + struct drm_property *prop; + uint64_t cp; + int ret; + + prop = dev->mode_config.content_protection_property; + if (!prop) + return 0; + + ret = drm_object_property_get_value(&connector->base, prop, &cp); + if (ret) + return 0; + + return snprintf(buf, PAGE_SIZE, "%s\n", + drm_get_content_protection_name((int)cp)); +} + +static ssize_t content_protection_ksv_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct drm_connector *connector = to_drm_connector(device); + struct drm_device *dev = connector->dev; + struct drm_property *prop; + uint64_t ksv; + int ret; + + prop = dev->mode_config.content_protection_ksv_property; + if (!prop) + return 0; + + ret = drm_object_property_get_value(&connector->base, prop, &ksv); + if (ret) + return 0; + + return snprintf(buf, PAGE_SIZE, "%llx\n", ksv); +} + static ssize_t edid_show(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) @@ -344,6 +386,8 @@ static struct device_attribute connector_attrs[] = { __ATTR_RO(enabled), __ATTR_RO(dpms), __ATTR_RO(modes), + __ATTR_RO(content_protection), + __ATTR_RO(content_protection_ksv), }; /* These attributes are for both DVI-I connectors and all types of tv-out. */ diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index dd2c16e..3fc0643 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1023,6 +1023,8 @@ struct drm_mode_config { struct drm_property *path_property; struct drm_property *plane_type_property; struct drm_property *rotation_property; + struct drm_property *content_protection_property; + struct drm_property *content_protection_ksv_property; /* DVI-I properties */ struct drm_property *dvi_i_subconnector_property; @@ -1171,6 +1173,7 @@ extern void drm_encoder_cleanup(struct drm_encoder *encoder); extern const char *drm_get_connector_status_name(enum drm_connector_status status); extern const char *drm_get_subpixel_order_name(enum subpixel_order order); extern const char *drm_get_dpms_name(int val); +extern const char *drm_get_content_protection_name(int val); extern const char *drm_get_dvi_i_subconnector_name(int val); extern const char *drm_get_dvi_i_select_name(int val); extern const char *drm_get_tv_subconnector_name(int val); diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 86574b0..e2904f5 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -81,6 +81,10 @@ #define DRM_MODE_DPMS_SUSPEND 2 #define DRM_MODE_DPMS_OFF 3 +/* Content Protection Flags */ +#define DRM_MODE_CONTENT_PROTECTION_UNDESIRED 0 +#define DRM_MODE_CONTENT_PROTECTION_DESIRED 1 + /* Scaling mode options */ #define DRM_MODE_SCALE_NONE 0 /* Unmodified timing (display or software can still scale) */