From patchwork Sun Nov 22 13:42:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yakir Yang X-Patchwork-Id: 7676211 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E715BBF90C for ; Sun, 22 Nov 2015 13:45:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E5E2220662 for ; Sun, 22 Nov 2015 13:45:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD24A20647 for ; Sun, 22 Nov 2015 13:45:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a0UvQ-0000VQ-GZ; Sun, 22 Nov 2015 13:43:28 +0000 Received: from lucky1.263xmail.com ([211.157.147.132]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a0UvI-0000SY-4w; Sun, 22 Nov 2015 13:43:25 +0000 Received: from ykk?rock-chips.com (unknown [192.168.167.131]) by lucky1.263xmail.com (Postfix) with SMTP id 606BE5BF9D; Sun, 22 Nov 2015 21:42:50 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 497D6419; Sun, 22 Nov 2015 21:42:46 +0800 (CST) X-RL-SENDER: ykk@rock-chips.com X-FST-TO: rmk+kernel@arm.linux.org.uk X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: ykk@rock-chips.com X-UNIQUE-TAG: <547a0f1a73f7e188961cb77082a6b3d8> X-ATTACHMENT-NUM: 0 X-SENDER: ykk@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 2774TSBRHW; Sun, 22 Nov 2015 21:42:47 +0800 (CST) From: Yakir Yang To: Russell King , Vladimir Zapolskiy , Thierry Reding , Philipp Zabel , Andy Yan Subject: [RFC PATCH v1 1/2] drm: Add Content Protection properties to drm Date: Sun, 22 Nov 2015 21:42:48 +0800 Message-Id: <1448199768-5066-1-git-send-email-ykk@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448199077-10221-1-git-send-email-ykk@rock-chips.com> References: <1448199077-10221-1-git-send-email-ykk@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151122_054324_886649_D923C061 X-CRM114-Status: GOOD ( 12.45 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabio Estevam , devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, David Airlie , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Sean Paul , Yakir Yang , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 From: Sean Paul 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 Signed-off-by: Yakir Yang --- drivers/gpu/drm/drm_crtc.c | 21 +++++++++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 3 +++ include/uapi/drm/drm_mode.h | 4 ++++ 4 files changed, 74 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 32dd134..de7ae6a 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -78,6 +78,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 */ @@ -1470,6 +1477,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev) return -ENOMEM; dev->mode_config.prop_mode_id = prop; + prop = drm_property_create_enum(dev, 0, + "Content Protection", drm_cp_enum_list, + ARRAY_SIZE(drm_cp_enum_list)); + if (!prop) + return -ENOMEM; + dev->mode_config.content_protection_property = prop; + + prop = drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, + "Content Protection KSV", 0, + 0xFFFFFFFFFF); + if (!prop) + return -ENOMEM; + dev->mode_config.content_protection_ksv_property = prop; + return 0; } diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index c75f022..dc122b8 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -248,6 +248,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) @@ -399,12 +441,16 @@ static DEVICE_ATTR_RW(status); static DEVICE_ATTR_RO(enabled); static DEVICE_ATTR_RO(dpms); static DEVICE_ATTR_RO(modes); +static DEVICE_ATTR_RO(content_protection); +static DEVICE_ATTR_RO(content_protection_ksv); static struct attribute *connector_dev_attrs[] = { &dev_attr_status.attr, &dev_attr_enabled.attr, &dev_attr_dpms.attr, &dev_attr_modes.attr, + &dev_attr_content_protection.attr, + &dev_attr_content_protection_ksv.attr, NULL }; diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 173535a..ba2bc37 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1118,6 +1118,8 @@ struct drm_mode_config { struct drm_property *prop_crtc_id; struct drm_property *prop_active; struct drm_property *prop_mode_id; + struct drm_property *content_protection_property; + struct drm_property *content_protection_ksv_property; /* DVI-I properties */ struct drm_property *dvi_i_subconnector_property; @@ -1286,6 +1288,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 6c11ca4..7b08342 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) */