From patchwork Wed Dec 3 19:57:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 5432951 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4EC5BBEEA8 for ; Wed, 3 Dec 2014 19:58:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 40B0820272 for ; Wed, 3 Dec 2014 19:58:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 383B2201ED for ; Wed, 3 Dec 2014 19:57:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75F786E024; Wed, 3 Dec 2014 11:57:58 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ig0-f181.google.com (mail-ig0-f181.google.com [209.85.213.181]) by gabe.freedesktop.org (Postfix) with ESMTP id 6EEF26E024 for ; Wed, 3 Dec 2014 11:57:57 -0800 (PST) Received: by mail-ig0-f181.google.com with SMTP id l13so14323600iga.2 for ; Wed, 03 Dec 2014 11:57:57 -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=VTGz7BH/Xs0SudenFVr/5QR4icthx8yKgHQLEgxjxuk=; b=RxtczNEwBCl1nBExYDCz+WzrRFfFN4a5e8IZRGcjR4H1eX7sH1Dc/y9Bicvcntea5Q PjSLnZ5YmF8Xhztq6sHxo87TABY22Ln7Lp/t2NgB/z40IuoYV2fe9bDh2mh1oi37EGo0 VDCV5ej2D1bZq77evGi2YUS1UHVWomnKzwEpk= 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=VTGz7BH/Xs0SudenFVr/5QR4icthx8yKgHQLEgxjxuk=; b=HwTMFLHmuC+4L4BudsxrhLxCgvwOJbzLsh2DEERxXe+9ETyMxad3Irruexa5FlOVLm Mw8WxKN3B9XdaP6eMhlUqmeaqBpEIMAX0HPJ2DZKstVjZsvHd2X4EIXKw51+WnbK8qar atXoD3iadxvJ0mc2LaCY5C1tLF5wLfSXO2h2RU5G014AwZDGe+47PNfykgwN9K/YIf4A QogUMqMiYDSorALj4NsPu02q0ukMgB/fAcqOq6Mdo9unFWhHIo44AXhc5yhN9W1mxdgL x4iWRjYbOC1drr3c9MHxYJmEo32MONxRprkAajherRPxsjbYEDKdHmz9XyuoxcJRyH2e Hr8Q== X-Gm-Message-State: ALoCoQl/dTKFc3exvCBcQswQ60mwmi0m4jA7QuUhaXGGmfcDHYjiB5pl0WFpr98/93DT9ymIj12r X-Received: by 10.42.29.6 with SMTP id p6mr8431787icc.85.1417636677091; Wed, 03 Dec 2014 11:57:57 -0800 (PST) Received: from davidriley-lab.mtv.corp.google.com ([172.22.64.15]) by mx.google.com with ESMTPSA id ck1sm5041863igb.0.2014.12.03.11.57.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Dec 2014 11:57:56 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm: Add Content Protection Desired property to drm Date: Wed, 3 Dec 2014 11:57:41 -0800 Message-Id: <1417636661-31579-2-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1417636661-31579-1-git-send-email-seanpaul@chromium.org> References: <1417636661-31579-1-git-send-email-seanpaul@chromium.org> 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 a new standard connector property to track whether content protection (ex: hdcp) is desired by userspace. While there are 3 possible states for the property, userspace should only change the value to desired or undesired. Upon setting the value to desired, the driver is responsible for protecting the link and setting the value to enabled. Disabling protection should happen immediately. Cc: Rob Clark Signed-off-by: Sean Paul --- Documentation/DocBook/drm.tmpl | 19 +++++++++++++++++-- drivers/gpu/drm/drm_crtc.c | 14 ++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 22 ++++++++++++++++++++++ include/drm/drm_crtc.h | 2 ++ include/uapi/drm/drm_mode.h | 5 +++++ 5 files changed, 60 insertions(+), 2 deletions(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 85287cb..86633f2 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,21 @@ void intel_crt_init(struct drm_device *dev) Contains DPMS operation mode value. + “Content Protection” + ENUM + { “Undesired”, “Desired”, “Enabled” } + Connector + Contains the current state of content protection on + the link. User space should set this property to "Desired" to + enable protection. Once the driver has authenticated the + connection, it shall set the value to "Enabled". To disable + protection, user space shall set the value to "Undesired", which + will tear down the encryption. If at any point the link becomes + unprotected, the driver shall transition from "Enabled" down to + "Desired" and may retry if appropriate. + + + “PATH” BLOB | IMMUTABLE 0 diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index de79283..5df5b7b 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -77,6 +77,14 @@ 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_MODE_CONTENT_PROTECTION_ENABLED, "Enabled" }, +}; + +DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list) + /* * Optional properties */ @@ -1319,6 +1327,7 @@ 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 *content_protection; /* * Standard properties (apply to all connectors) @@ -1339,6 +1348,11 @@ static int drm_mode_create_standard_connector_properties(struct drm_device *dev) "PATH", 0); dev->mode_config.path_property = dev_path; + content_protection = drm_property_create_enum(dev, 0, + "Content Protection", drm_cp_enum_list, + ARRAY_SIZE(drm_cp_enum_list)); + dev->mode_config.content_protection_property = content_protection; + return 0; } diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index cc3d6d6..b4019b5 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -214,6 +214,27 @@ 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 edid_show(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) @@ -344,6 +365,7 @@ static struct device_attribute connector_attrs[] = { __ATTR_RO(enabled), __ATTR_RO(dpms), __ATTR_RO(modes), + __ATTR_RO(content_protection), }; /* 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..b185f13 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1023,6 +1023,7 @@ 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; /* DVI-I properties */ struct drm_property *dvi_i_subconnector_property; @@ -1171,6 +1172,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..e1f0e41 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -81,6 +81,11 @@ #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 +#define DRM_MODE_CONTENT_PROTECTION_ENABLED 2 + /* Scaling mode options */ #define DRM_MODE_SCALE_NONE 0 /* Unmodified timing (display or software can still scale) */