Received: by 10.223.164.202 with SMTP id h10csp157482wrb; Wed, 29 Nov 2017 19:10:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMbGM7Xntt4oVig0t2tcwYrkJhWzWlYcTLEjhtQzHedUOIRkgPmim0gdGGTygjFp9OV9qBRG X-Received: by 10.84.130.98 with SMTP id 89mr1104957plc.232.1512011409058; Wed, 29 Nov 2017 19:10:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512011409; cv=none; d=google.com; s=arc-20160816; b=uBJtO+7Ut3tfLPPgfgkGNEWdV0Ceh6amyAUHyM7n60VZTaF3uDzD1qcuOCjjfP6m3V rnTna319byB7aVb3Oghogda1CwCcogC/Rdi+hPtcIbEKzHhylamN89lrsM/lGUAIFTq7 ZTvmBCHNuPAzq84AOAvOqKPfoFh3bROQF0/Jfk3hVQUTA9W94c4riPggybujWod5EJH4 RtdzHkI/IncqgDA4b3oWCDucym/saV2bsR/AASwxvH15xu49IhN/L5LwvA/Qr6Tjqy4C ZEMWCr4UyqMH98tZokhhpunzeNklTfnpv6r09HtD25/90ej7Qh4gZj40Q2y0Gm9IEdEz R0UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=uEGyBrnqyLd23mwYBxHWweFYCp9bsiunG9qVd4iEUnA=; b=FwGZt1wdXnxVC5g9HWF8QeDiSVVcFONbx65Q6db14E/f4L7wfey1ocwwnLgC/3fbvP Ara1EhaV2H+5TWuqkRGaRkjT0HAq1G/d/W/4X2I3nRynSgjr/CVndYeQhYpUYCLQWKur ozAkHUxM7Og9zDmnbjnYdfs0sR1shjLIGS30Elfiu0pRpjNmSOUcbUWq7dwIC+0LiaFp 4sfdDvzf6lFfIfSlF6H104K3IQ8/kDtLajRRfWf4U1+TCSWeu1d5lt3LfdWXJrK/rUAu vlnsjHESA1rSj70MFG9k9MDLOVTmawt1aY2R01Eu0vVeO+/Peg38b4tDHZbXWsPKUCMk tb5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=H7sXO3jj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si2290744plt.685.2017.11.29.19.09.55; Wed, 29 Nov 2017 19:10:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=H7sXO3jj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224AbdK3DJq (ORCPT + 99 others); Wed, 29 Nov 2017 22:09:46 -0500 Received: from mail-yw0-f195.google.com ([209.85.161.195]:39693 "EHLO mail-yw0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752939AbdK3DJo (ORCPT ); Wed, 29 Nov 2017 22:09:44 -0500 Received: by mail-yw0-f195.google.com with SMTP id y187so2192661ywg.6 for ; Wed, 29 Nov 2017 19:09:44 -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; bh=uEGyBrnqyLd23mwYBxHWweFYCp9bsiunG9qVd4iEUnA=; b=H7sXO3jjz2utxD6REIYw+zZToLtO8IqUZiwEsv2I5cjsaogsEbXGPUYSrnlzzUiBiG 57COyb84tpF/fohjVIG1fNXNKXJ0T5Zvo2LDYJI5DMUmXk1KS8ugDd7l8Q1TbXQ78enu wc55IE5ThvExzcoUbKnp7w5POAOe+yb21lLgw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uEGyBrnqyLd23mwYBxHWweFYCp9bsiunG9qVd4iEUnA=; b=rRmwtIFJAPAEKuPalXpQQl3XS/s0Xyc4rX03I9KSFliIfRjqUQ64GhdUheWA5e/jwy 8xKGyiqbIQT+kKyMKAVVPbpEEFe+W2BuTe7x7ycHK0/UtafQTU7tXQiW4eF8Wo2Eb2BI v0fFTVNTovUmnTXXRErDHJOc4q/qls8icq2uhVLwd5cpYgMjtKnKGPcVywZ/QyWsMqpu c3O0O1gEJ55q1u+HYyWzsokLJ6fufQ9K84jPIPRTq7WsIXJcT1Gvt+5fZJEk8U4V5BlL p0MVVgAZ+QBGOxdIZ0LtNLJQzo5jxV65SljMCoHXeTJc6urRKz58/nPux3nsXFRsYHlU urlw== X-Gm-Message-State: AJaThX6hrX/mT3E/AyqIDw0hXBQr95EYnr65I2PbhFTqjE0z4voZxhdf TSm2292N/Bo1jau5dTvw+zIP5w== X-Received: by 10.129.166.193 with SMTP id d184mr639243ywh.241.1512011383918; Wed, 29 Nov 2017 19:09:43 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:d3af:69ac:1964:28e8]) by smtp.gmail.com with ESMTPSA id u24sm1460752ywh.84.2017.11.29.19.09.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 19:09:43 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Sean Paul , Daniel Vetter , Jani Nikula , Gustavo Padovan , David Airlie , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [RFC PATCH 1/6] drm: Add Content Protection property Date: Wed, 29 Nov 2017 22:08:56 -0500 Message-Id: <20171130030907.26848-2-seanpaul@chromium.org> X-Mailer: git-send-email 2.15.0.531.g2ccb3012c9-goog In-Reply-To: <20171130030907.26848-1-seanpaul@chromium.org> References: <20171130030907.26848-1-seanpaul@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds a new optional connector property to allow userspace to enable protection over the content it is displaying. This will typically be implemented by the driver using HDCP. The property is a tri-state with the following values: - OFF: Self explanatory, no content protection - DESIRED: Userspace requests that the driver enable protection - ENABLED: Once the driver has authenticated the link, it sets this value The driver is responsible for downgrading ENABLED to DESIRED if the link becomes unprotected. The driver should also maintain the desiredness of protection across hotplug/dpms/suspend. If this looks familiar, I posted [1] this 3 years ago. We have been using this in ChromeOS across exynos, mediatek, and rockchip over that time. Signed-off-by: Sean Paul [1] https://lists.freedesktop.org/archives/dri-devel/2014-December/073336.html --- drivers/gpu/drm/drm_atomic.c | 8 ++++++++ drivers/gpu/drm/drm_connector.c | 43 +++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 29 +++++++++++++++++++++++++++ include/drm/drm_connector.h | 16 +++++++++++++++ include/uapi/drm/drm_mode.h | 4 ++++ 5 files changed, 100 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 37445d50816a..2212793eefa6 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1185,6 +1185,12 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, state->picture_aspect_ratio = val; } else if (property == connector->scaling_mode_property) { state->scaling_mode = val; + } else if (property == connector->content_protection_property) { + if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) { + DRM_DEBUG_KMS("only drivers can set CP Enabled\n"); + return -EINVAL; + } + state->content_protection = val; } else if (connector->funcs->atomic_set_property) { return connector->funcs->atomic_set_property(connector, state, property, val); @@ -1264,6 +1270,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = state->picture_aspect_ratio; } else if (property == connector->scaling_mode_property) { *val = state->scaling_mode; + } else if (property == connector->content_protection_property) { + *val = state->content_protection; } else if (connector->funcs->atomic_get_property) { return connector->funcs->atomic_get_property(connector, state, property, val); diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 704fc8934616..de2345a4a125 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -698,6 +698,13 @@ static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = { DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name, drm_tv_subconnector_enum_list) +static struct drm_prop_enum_list drm_cp_enum_list[] = { + { DRM_MODE_CONTENT_PROTECTION_OFF, "Off" }, + { 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) + /** * DOC: standard connector properties * @@ -1046,6 +1053,42 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector, } EXPORT_SYMBOL(drm_connector_attach_scaling_mode_property); +/** + * drm_connector_attach_content_protection_property - attach content protection + * property + * + * @connector: connector to attach CP property on. + * + * This is used to add support for content protection on select connectors. + * Content Protection is intentionally vague to allow for different underlying + * technologies, however it is most implemented by HDCP. + * + * The content protection will be set to &drm_connector_state.content_protection + * + * Returns: + * Zero on success, negative errno on failure. + */ +int drm_connector_attach_content_protection_property( + struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + struct drm_property *prop; + + prop = drm_property_create_enum(dev, 0, "Content Protection", + drm_cp_enum_list, + ARRAY_SIZE(drm_cp_enum_list)); + if (!prop) + return -ENOMEM; + + drm_object_attach_property(&connector->base, prop, + DRM_MODE_CONTENT_PROTECTION_OFF); + + connector->content_protection_property = prop; + + return 0; +} +EXPORT_SYMBOL(drm_connector_attach_content_protection_property); + /** * drm_mode_create_aspect_ratio_property - create aspect ratio property * @dev: DRM device diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 1c5b5ce1fd7f..e8e15756dc59 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -21,6 +21,7 @@ #include #include #include "drm_internal.h" +#include "drm_crtc_internal.h" #define to_drm_minor(d) dev_get_drvdata(d) #define to_drm_connector(d) dev_get_drvdata(d) @@ -229,16 +230,44 @@ static ssize_t modes_show(struct device *device, return written; } +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; + + drm_modeset_lock_all(dev); + + prop = connector->content_protection_property; + if (!prop) { + drm_modeset_unlock_all(dev); + return 0; + } + + ret = drm_object_property_get_value(&connector->base, prop, &cp); + drm_modeset_unlock_all(dev); + if (ret) + return 0; + + return snprintf(buf, PAGE_SIZE, "%s\n", + drm_get_content_protection_name((int)cp)); +} + 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 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, NULL }; diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 1543212b0449..ec6ea3953002 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -375,6 +375,12 @@ struct drm_connector_state { * upscaling, mostly used for built-in panels. */ unsigned int scaling_mode; + + /** + * @content_protection: Connector property to request content + * protection. This is most commonly used for HDCP. + */ + unsigned int content_protection; }; /** @@ -722,6 +728,7 @@ struct drm_cmdline_mode { * @tile_h_size: horizontal size of this tile. * @tile_v_size: vertical size of this tile. * @scaling_mode_property: Optional atomic property to control the upscaling. + * @content_protection_property: Optional property to control content protection * * Each connector may be connected to one or more CRTCs, or may be clonable by * another connector if they can share a CRTC. Each connector also has a specific @@ -812,6 +819,12 @@ struct drm_connector { struct drm_property *scaling_mode_property; + /** + * @content_protection_property: DRM ENUM property for content + * protection + */ + struct drm_property *content_protection_property; + /** * @path_blob_ptr: * @@ -1012,6 +1025,7 @@ const char *drm_get_dvi_i_subconnector_name(int val); 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); int drm_mode_create_dvi_i_properties(struct drm_device *dev); int drm_mode_create_tv_properties(struct drm_device *dev, @@ -1020,6 +1034,8 @@ int drm_mode_create_tv_properties(struct drm_device *dev, int drm_mode_create_scaling_mode_property(struct drm_device *dev); int drm_connector_attach_scaling_mode_property(struct drm_connector *connector, u32 scaling_mode_mask); +int drm_connector_attach_content_protection_property( + struct drm_connector *connector); int drm_mode_create_aspect_ratio_property(struct drm_device *dev); int drm_mode_create_suggested_offset_properties(struct drm_device *dev); diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 5597a87154e5..03f4d22305c2 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -173,6 +173,10 @@ extern "C" { DRM_MODE_REFLECT_X | \ DRM_MODE_REFLECT_Y) +/* Content Protection Flags */ +#define DRM_MODE_CONTENT_PROTECTION_OFF 0 +#define DRM_MODE_CONTENT_PROTECTION_DESIRED 1 +#define DRM_MODE_CONTENT_PROTECTION_ENABLED 2 struct drm_mode_modeinfo { __u32 clock; -- 2.15.0.531.g2ccb3012c9-goog From 1586635040847387015@xxx Wed Dec 13 02:44:47 +0000 2017 X-GM-THRID: 1586632849983522392 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread