Skip to content

Commit 7672dbb

Browse files
committed
drm: Add Content protection type property
This patch adds a DRM ENUM property to the selected connectors. This property is used for mentioning the protected content's type from userspace to kernel HDCP authentication. Type of the stream is decided by the protected content providers. Type 0 content can be rendered on any HDCP protected display wires. But Type 1 content can be rendered only on HDCP2.2 protected paths. So when a userspace sets this property to Type 1 and starts the HDCP enable, kernel will honour it only if HDCP2.2 authentication is through for type 1. Else HDCP enable will be failed. Pekka have completed the Weston DRM-backend review in https://gitlab.freedesktop.org/wayland/weston/merge_requests/48 and the UAPI for HDCP 2.2 looks good. The userspace is accepted in Weston. v2: cp_content_type is replaced with content_protection_type [daniel] check at atomic_set_property is removed [Maarten] v3: %s/content_protection_type/hdcp_content_type [Pekka] v4: property is created for the first requested connector and then reused. [Danvet] v5: kernel doc nits addressed [Daniel] Rebased as part of patch reordering. v6: Kernel docs are modified [pekka] v7: More details in Kernel docs. [pekka] v8: Few more clarification into kernel doc of content type [pekka] v9: Small fixes in coding style. v10: Moving DRM_MODE_HDCP_CONTENT_TYPEx definition to drm_hdcp.h [pekka] Signed-off-by: Ramalingam C <ramalingam.c@intel.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com> Acked-by: Jani Nikula <jani.nikula@intel.com> Link: https://patchwork.freedesktop.org/patch/320957/?series=57232&rev=14
1 parent c123357 commit 7672dbb

7 files changed

Lines changed: 112 additions & 3 deletions

File tree

‎drivers/gpu/drm/drm_atomic_uapi.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
747747
return -EINVAL;
748748
}
749749
state->content_protection = val;
750+
} else if (property == config->hdcp_content_type_property) {
751+
state->hdcp_content_type = val;
750752
} else if (property == connector->colorspace_property) {
751753
state->colorspace = val;
752754
} else if (property == config->writeback_fb_id_property) {
@@ -831,6 +833,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
831833
state->hdr_output_metadata->base.id : 0;
832834
} else if (property == config->content_protection_property) {
833835
*val = state->content_protection;
836+
} else if (property == config->hdcp_content_type_property) {
837+
*val = state->hdcp_content_type;
834838
} else if (property == config->writeback_fb_id_property) {
835839
/* Writeback framebuffer is one-shot, write and forget */
836840
*val = 0;

‎drivers/gpu/drm/drm_connector.c‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,57 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] = {
988988
* is no longer protected and userspace should take appropriate action
989989
* (whatever that might be).
990990
*
991+
* HDCP Content Type:
992+
* This Enum property is used by the userspace to declare the content type
993+
* of the display stream, to kernel. Here display stream stands for any
994+
* display content that userspace intended to display through HDCP
995+
* encryption.
996+
*
997+
* Content Type of a stream is decided by the owner of the stream, as
998+
* "HDCP Type0" or "HDCP Type1".
999+
*
1000+
* The value of the property can be one of the below:
1001+
* - "HDCP Type0": DRM_MODE_HDCP_CONTENT_TYPE0 = 0
1002+
* - "HDCP Type1": DRM_MODE_HDCP_CONTENT_TYPE1 = 1
1003+
*
1004+
* When kernel starts the HDCP authentication (see "Content Protection"
1005+
* for details), it uses the content type in "HDCP Content Type"
1006+
* for performing the HDCP authentication with the display sink.
1007+
*
1008+
* Please note in HDCP spec versions, a link can be authenticated with
1009+
* HDCP 2.2 for Content Type 0/Content Type 1. Where as a link can be
1010+
* authenticated with HDCP1.4 only for Content Type 0(though it is implicit
1011+
* in nature. As there is no reference for Content Type in HDCP1.4).
1012+
*
1013+
* HDCP2.2 authentication protocol itself takes the "Content Type" as a
1014+
* parameter, which is a input for the DP HDCP2.2 encryption algo.
1015+
*
1016+
* In case of Type 0 content protection request, kernel driver can choose
1017+
* either of HDCP spec versions 1.4 and 2.2. When HDCP2.2 is used for
1018+
* "HDCP Type 0", a HDCP 2.2 capable repeater in the downstream can send
1019+
* that content to a HDCP 1.4 authenticated HDCP sink (Type0 link).
1020+
* But if the content is classified as "HDCP Type 1", above mentioned
1021+
* HDCP 2.2 repeater wont send the content to the HDCP sink as it can't
1022+
* authenticate the HDCP1.4 capable sink for "HDCP Type 1".
1023+
*
1024+
* Please note userspace can be ignorant of the HDCP versions used by the
1025+
* kernel driver to achieve the "HDCP Content Type".
1026+
*
1027+
* At current scenario, classifying a content as Type 1 ensures that the
1028+
* content will be displayed only through the HDCP2.2 encrypted link.
1029+
*
1030+
* Note that the HDCP Content Type property is introduced at HDCP 2.2, and
1031+
* defaults to type 0. It is only exposed by drivers supporting HDCP 2.2
1032+
* (hence supporting Type 0 and Type 1). Based on how next versions of
1033+
* HDCP specs are defined content Type could be used for higher versions
1034+
* too.
1035+
*
1036+
* If content type is changed when "Content Protection" is not UNDESIRED,
1037+
* then kernel will disable the HDCP and re-enable with new type in the
1038+
* same atomic commit. And when "Content Protection" is ENABLED, it means
1039+
* that link is HDCP authenticated and encrypted, for the transmission of
1040+
* the Type of stream mentioned at "HDCP Content Type".
1041+
*
9911042
* HDR_OUTPUT_METADATA:
9921043
* Connector property to enable userspace to send HDR Metadata to
9931044
* driver. This metadata is based on the composition and blending

‎drivers/gpu/drm/drm_hdcp.c‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,23 +344,41 @@ static struct drm_prop_enum_list drm_cp_enum_list[] = {
344344
};
345345
DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list)
346346

347+
static struct drm_prop_enum_list drm_hdcp_content_type_enum_list[] = {
348+
{ DRM_MODE_HDCP_CONTENT_TYPE0, "HDCP Type0" },
349+
{ DRM_MODE_HDCP_CONTENT_TYPE1, "HDCP Type1" },
350+
};
351+
DRM_ENUM_NAME_FN(drm_get_hdcp_content_type_name,
352+
drm_hdcp_content_type_enum_list)
353+
347354
/**
348355
* drm_connector_attach_content_protection_property - attach content protection
349356
* property
350357
*
351358
* @connector: connector to attach CP property on.
359+
* @hdcp_content_type: is HDCP Content Type property needed for connector
352360
*
353361
* This is used to add support for content protection on select connectors.
354362
* Content Protection is intentionally vague to allow for different underlying
355363
* technologies, however it is most implemented by HDCP.
356364
*
365+
* When hdcp_content_type is true enum property called HDCP Content Type is
366+
* created (if it is not already) and attached to the connector.
367+
*
368+
* This property is used for sending the protected content's stream type
369+
* from userspace to kernel on selected connectors. Protected content provider
370+
* will decide their type of their content and declare the same to kernel.
371+
*
372+
* Content type will be used during the HDCP 2.2 authentication.
373+
* Content type will be set to &drm_connector_state.hdcp_content_type.
374+
*
357375
* The content protection will be set to &drm_connector_state.content_protection
358376
*
359377
* Returns:
360378
* Zero on success, negative errno on failure.
361379
*/
362380
int drm_connector_attach_content_protection_property(
363-
struct drm_connector *connector)
381+
struct drm_connector *connector, bool hdcp_content_type)
364382
{
365383
struct drm_device *dev = connector->dev;
366384
struct drm_property *prop =
@@ -377,6 +395,22 @@ int drm_connector_attach_content_protection_property(
377395
DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
378396
dev->mode_config.content_protection_property = prop;
379397

398+
if (!hdcp_content_type)
399+
return 0;
400+
401+
prop = dev->mode_config.hdcp_content_type_property;
402+
if (!prop)
403+
prop = drm_property_create_enum(dev, 0, "HDCP Content Type",
404+
drm_hdcp_content_type_enum_list,
405+
ARRAY_SIZE(
406+
drm_hdcp_content_type_enum_list));
407+
if (!prop)
408+
return -ENOMEM;
409+
410+
drm_object_attach_property(&connector->base, prop,
411+
DRM_MODE_HDCP_CONTENT_TYPE0);
412+
dev->mode_config.hdcp_content_type_property = prop;
413+
380414
return 0;
381415
}
382416
EXPORT_SYMBOL(drm_connector_attach_content_protection_property);

‎drivers/gpu/drm/i915/display/intel_hdcp.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,9 @@ int intel_hdcp_init(struct intel_connector *connector,
18291829
if (!shim)
18301830
return -EINVAL;
18311831

1832-
ret = drm_connector_attach_content_protection_property(&connector->base);
1832+
ret =
1833+
drm_connector_attach_content_protection_property(&connector->base,
1834+
false);
18331835
if (ret)
18341836
return ret;
18351837

‎include/drm/drm_connector.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,12 @@ struct drm_connector_state {
602602
*/
603603
unsigned int content_type;
604604

605+
/**
606+
* @hdcp_content_type: Connector property to pass the type of
607+
* protected content. This is most commonly used for HDCP.
608+
*/
609+
unsigned int hdcp_content_type;
610+
605611
/**
606612
* @scaling_mode: Connector property to control the
607613
* upscaling, mostly used for built-in panels.
@@ -1502,6 +1508,7 @@ const char *drm_get_dvi_i_select_name(int val);
15021508
const char *drm_get_tv_subconnector_name(int val);
15031509
const char *drm_get_tv_select_name(int val);
15041510
const char *drm_get_content_protection_name(int val);
1511+
const char *drm_get_hdcp_content_type_name(int val);
15051512

15061513
int drm_mode_create_dvi_i_properties(struct drm_device *dev);
15071514
int drm_mode_create_tv_margin_properties(struct drm_device *dev);

‎include/drm/drm_hdcp.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,5 +291,10 @@ struct drm_connector;
291291
bool drm_hdcp_check_ksvs_revoked(struct drm_device *dev,
292292
u8 *ksvs, u32 ksv_count);
293293
int drm_connector_attach_content_protection_property(
294-
struct drm_connector *connector);
294+
struct drm_connector *connector, bool hdcp_content_type);
295+
296+
/* Content Type classification for HDCP2.2 vs others */
297+
#define DRM_MODE_HDCP_CONTENT_TYPE0 0
298+
#define DRM_MODE_HDCP_CONTENT_TYPE1 1
299+
295300
#endif

‎include/drm/drm_mode_config.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,12 @@ struct drm_mode_config {
849849
*/
850850
struct drm_property *content_protection_property;
851851

852+
/**
853+
* @hdcp_content_type_property: DRM ENUM property for type of
854+
* Protected Content.
855+
*/
856+
struct drm_property *hdcp_content_type_property;
857+
852858
/* dumb ioctl parameters */
853859
uint32_t preferred_depth, prefer_shadow;
854860

0 commit comments

Comments
 (0)