Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+112 -3
+4
drivers/gpu/drm/drm_atomic_uapi.c
··· 747 747 return -EINVAL; 748 748 } 749 749 state->content_protection = val; 750 + } else if (property == config->hdcp_content_type_property) { 751 + state->hdcp_content_type = val; 750 752 } else if (property == connector->colorspace_property) { 751 753 state->colorspace = val; 752 754 } else if (property == config->writeback_fb_id_property) { ··· 833 831 state->hdr_output_metadata->base.id : 0; 834 832 } else if (property == config->content_protection_property) { 835 833 *val = state->content_protection; 834 + } else if (property == config->hdcp_content_type_property) { 835 + *val = state->hdcp_content_type; 836 836 } else if (property == config->writeback_fb_id_property) { 837 837 /* Writeback framebuffer is one-shot, write and forget */ 838 838 *val = 0;
+51
drivers/gpu/drm/drm_connector.c
··· 988 988 * is no longer protected and userspace should take appropriate action 989 989 * (whatever that might be). 990 990 * 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 + * 991 1042 * HDR_OUTPUT_METADATA: 992 1043 * Connector property to enable userspace to send HDR Metadata to 993 1044 * driver. This metadata is based on the composition and blending
+35 -1
drivers/gpu/drm/drm_hdcp.c
··· 344 344 }; 345 345 DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list) 346 346 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 + 347 354 /** 348 355 * drm_connector_attach_content_protection_property - attach content protection 349 356 * property 350 357 * 351 358 * @connector: connector to attach CP property on. 359 + * @hdcp_content_type: is HDCP Content Type property needed for connector 352 360 * 353 361 * This is used to add support for content protection on select connectors. 354 362 * Content Protection is intentionally vague to allow for different underlying 355 363 * technologies, however it is most implemented by HDCP. 364 + * 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. 356 374 * 357 375 * The content protection will be set to &drm_connector_state.content_protection 358 376 * ··· 378 360 * Zero on success, negative errno on failure. 379 361 */ 380 362 int drm_connector_attach_content_protection_property( 381 - struct drm_connector *connector) 363 + struct drm_connector *connector, bool hdcp_content_type) 382 364 { 383 365 struct drm_device *dev = connector->dev; 384 366 struct drm_property *prop = ··· 394 376 drm_object_attach_property(&connector->base, prop, 395 377 DRM_MODE_CONTENT_PROTECTION_UNDESIRED); 396 378 dev->mode_config.content_protection_property = prop; 379 + 380 + if (!hdcp_content_type) 381 + return 0; 382 + 383 + prop = dev->mode_config.hdcp_content_type_property; 384 + if (!prop) 385 + prop = drm_property_create_enum(dev, 0, "HDCP Content Type", 386 + drm_hdcp_content_type_enum_list, 387 + ARRAY_SIZE( 388 + drm_hdcp_content_type_enum_list)); 389 + if (!prop) 390 + return -ENOMEM; 391 + 392 + drm_object_attach_property(&connector->base, prop, 393 + DRM_MODE_HDCP_CONTENT_TYPE0); 394 + dev->mode_config.hdcp_content_type_property = prop; 397 395 398 396 return 0; 399 397 }
+3 -1
drivers/gpu/drm/i915/display/intel_hdcp.c
··· 1829 1829 if (!shim) 1830 1830 return -EINVAL; 1831 1831 1832 - ret = drm_connector_attach_content_protection_property(&connector->base); 1832 + ret = 1833 + drm_connector_attach_content_protection_property(&connector->base, 1834 + false); 1833 1835 if (ret) 1834 1836 return ret; 1835 1837
+7
include/drm/drm_connector.h
··· 603 603 unsigned int content_type; 604 604 605 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 + 611 + /** 606 612 * @scaling_mode: Connector property to control the 607 613 * upscaling, mostly used for built-in panels. 608 614 */ ··· 1508 1502 const char *drm_get_tv_subconnector_name(int val); 1509 1503 const char *drm_get_tv_select_name(int val); 1510 1504 const char *drm_get_content_protection_name(int val); 1505 + const char *drm_get_hdcp_content_type_name(int val); 1511 1506 1512 1507 int drm_mode_create_dvi_i_properties(struct drm_device *dev); 1513 1508 int drm_mode_create_tv_margin_properties(struct drm_device *dev);
+6 -1
include/drm/drm_hdcp.h
··· 291 291 bool drm_hdcp_check_ksvs_revoked(struct drm_device *dev, 292 292 u8 *ksvs, u32 ksv_count); 293 293 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 + 295 300 #endif
+6
include/drm/drm_mode_config.h
··· 849 849 */ 850 850 struct drm_property *content_protection_property; 851 851 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 + 852 858 /* dumb ioctl parameters */ 853 859 uint32_t preferred_depth, prefer_shadow; 854 860