Create Content Protection Property and Use it
Subsystems (4)
cover Create Content Protection Property and Use it
From: Mark Yacoub <[email protected]>
Hi all,
Following up to my HDCP patches[1], this series introduces a new connector prop that is required to push the key from user space to a driver that requires a key from user space to enable HDCP on a connector.
Patch 1 is the DRM code that creates this prop.
Patch 2 is the MSM driver making use of the value of this prop.
Thanks,
Mark Yacoub
[1] https://patchwork.freedesktop.org/series/94713/
Mark Yacoub (2):
DRM: Create new Content Protection connector property
dp_hdcp: Get the hdcp key from the connector prop
drivers/gpu/drm/drm_atomic_uapi.c | 9 +++++ drivers/gpu/drm/msm/dp/dp_hdcp.c | 66 ++++++++++++++++++++++++++++--- include/drm/drm_connector.h | 6 +++ include/drm/drm_mode_config.h | 6 +++ 4 files changed, 82 insertions(+), 5 deletions(-)
Signature · 1 line
2.40.0.634.g4ca3ef3211-goog
PATCH 1/2 DRM: Create new Content Protection connector property
From: Mark Yacoub <[email protected]>
[Why]
To enable Protected Content, some drivers require a key to be injected from user space to enable HDCP on the connector.
[How]
Create new "Content Protection Property" of type "Blob"
--- drivers/gpu/drm/drm_atomic_uapi.c | 9 +++++++++ include/drm/drm_connector.h | 6 ++++++ include/drm/drm_mode_config.h | 6 ++++++ 3 files changed, 21 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +9 -0
@@ -749,6 +749,11 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, state->content_protection = val; }else if (property == config->hdcp_content_type_property) { state->hdcp_content_type = val; + }else if (property == config->content_protection_key_property) { + ret =drm_atomic_replace_property_blob_from_id ( + dev, &state->content_protection_key, val,-1 ,-1 , + &replaced); +return ret; }else if (property == connector->colorspace_property) { state->colorspace = val; }else if (property == config->writeback_fb_id_property) {
@@ -843,6 +848,10 @@ 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->content_protection_key_property) { + *val = state->content_protection_key ? + state->content_protection_key->base.id : +0 ; }else if (property == config->writeback_fb_id_property) {/* Writeback framebuffer is one-shot, write and forget */ *val =0 ;
include/drm/drm_connector.h +6 -0
@@ -896,6 +896,12 @@ struct drm_connector_state {*/ unsigned int content_protection; +/** +* @content_protection_key: DRM blob property for holding the Content +* Protection Key injected from user space. +*/ +struct drm_property_blob *content_protection_key; +/** * @colorspace: State variable for Connector property to request * colorspace change on Sink. This is most commonly used to switch
include/drm/drm_mode_config.h +6 -0
@@ -887,6 +887,12 @@ struct drm_mode_config {*/ struct drm_property *hdcp_content_type_property; +/** +* @content_protection_key_property: DRM blob property that receives the +* content protection key from user space to be injected into the kernel. +*/ +struct drm_property *content_protection_key_property; +/* dumb ioctl parameters */ uint32_t preferred_depth, prefer_shadow;
Signature · 1 line
2.40.0.634.g4ca3ef3211-goog
PATCH 2/2 dp_hdcp: Get the hdcp key from the connector prop
In reply to Mark YacoubFrom: Mark Yacoub <[email protected]>
[Why]
To support protected content, the driver requires a key. Currently, it's being injected from debugfs, which is not super useful to run a user space in the wild.
[How]
When the key is needed, fetch the "Content Protection Property" on the connector and get the key blob. Verify that the size is valid and use it.
--- drivers/gpu/drm/msm/dp/dp_hdcp.c | 66 +++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/dp/dp_hdcp.c +61 -5
@@ -117,19 +117,61 @@ static bool dp_hdcp_are_keys_valid(struct drm_connector *connector,return FIELD_GET (DP_HDCP_KEY_STATUS , val) ==DP_HDCP_KEY_STATUS_VALID ; } +static bool dp_hdcp_get_key_from_connector (struct drm_connector *connector, +struct drm_bridge *bridge) +{ +struct drm_property_blob *key_blob; +u8 *raw_key; +int ret; +struct dp_hdcp *hdcp; +struct drm_device *dev = connector->dev; +struct drm_property *prop = + dev->mode_config.content_protection_key_property; + +if (!prop) +return false; + + key_blob = connector->state->content_protection_key; +if (!key_blob) +return false; + + raw_key = key_blob->data; + +if (key_blob->length != +DRM_HDCP_KSV_LEN +DP_HDCP_NUM_KEYS *DP_HDCP_KEY_LEN ) { +drm_dbg_atomic ( + dev, +"[CONNECTOR:%d:%s] Content Protection Key is a blob that we don't expect.\n" , + connector->base.id, connector->name); +return false; + } + + hdcp =dp_display_bridge_to_hdcp (bridge); + ret =dp_hdcp_ingest_key (hdcp, key_blob->data, key_blob->length); +if (ret) +return false; + +return true; +} +static int dp_hdcp_load_keys (struct drm_connector *connector,void *driver_data) {struct drm_bridge *bridge = (struct drm_bridge *)driver_data;struct dp_hdcp *hdcp =dp_display_bridge_to_hdcp (bridge);int i, ret =0 ; +bool is_hdcp_key_valid;mutex_lock (&hdcp->key_lock); + is_hdcp_key_valid = hdcp->key.valid; +mutex_unlock (&hdcp->key_lock); -if (!hdcp->key.valid) { - ret = -ENOENT ; - goto out; +if (!is_hdcp_key_valid && + !dp_hdcp_get_key_from_connector (connector, bridge)) { +return -ENOENT ; } +mutex_lock (&hdcp->key_lock); +dp_catalog_hdcp_write_aksv (hdcp->catalog, hdcp->key.ksv.words);
@@ -139,7 +181,6 @@ static int dp_hdcp_load_keys(struct drm_connector *connector, void *driver_data) }dp_catalog_hdcp_post_write_key (hdcp->catalog); -out:mutex_unlock (&hdcp->key_lock);return ret; }
@@ -346,6 +387,8 @@ int dp_hdcp_attach(struct dp_hdcp *hdcp, struct drm_connector *connector, struct drm_bridge *bridge, struct dp_catalog *catalog) { struct drm_hdcp_helper_data *helper_data; +struct drm_device *dev; +struct drm_property *prop;/* HDCP is not configured for this device */ if (!hdcp->parser->io.dp_controller.hdcp_key.base)
@@ -357,7 +400,20 @@ int dp_hdcp_attach(struct dp_hdcp *hdcp, struct drm_connector *connector,return PTR_ERR (helper_data); helper_data->driver_data = bridge; - hdcp->dev = connector->dev; + + dev = connector->dev; + prop = dev->mode_config.content_protection_key_property; +if (!prop) { + prop =drm_property_create (dev,DRM_MODE_PROP_BLOB , +"Content Protection Key" ,0 ); + } +if (!prop) +return -1 ; +drm_object_attach_property (&connector->base, prop, +DRM_MODE_HDCP_CONTENT_TYPE0 ); + dev->mode_config.content_protection_key_property = prop; + + hdcp->dev = dev; hdcp->connector = connector; hdcp->helper_data = helper_data; hdcp->catalog = catalog;
Signature · 1 line
2.40.0.634.g4ca3ef3211-goog