[Intel-gfx] [PATCH v2 2/8] drm: Add Content protection type property

2019-03-08 Thread Ramalingam C
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.

v2:
  cp_content_type is replaced with content_protection_type [daniel]
  check at atomic_set_property is removed [Maarten]

Signed-off-by: Ramalingam C 
---
 drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
 drivers/gpu/drm/drm_connector.c   | 63 +++
 include/drm/drm_connector.h   | 15 
 include/uapi/drm/drm_mode.h   |  4 ++
 4 files changed, 86 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c 
b/drivers/gpu/drm/drm_atomic_uapi.c
index 4eb81f10bc54..f383d4be5a92 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -746,6 +746,8 @@ static int drm_atomic_connector_set_property(struct 
drm_connector *connector,
return -EINVAL;
}
state->content_protection = val;
+   } else if (property == connector->content_protection_type_property) {
+   state->content_protection_type = val;
} else if (property == connector->colorspace_property) {
state->colorspace = val;
} else if (property == config->writeback_fb_id_property) {
@@ -822,6 +824,8 @@ drm_atomic_connector_get_property(struct drm_connector 
*connector,
*val = state->scaling_mode;
} else if (property == connector->content_protection_property) {
*val = state->content_protection;
+   } else if (property == connector->content_protection_type_property) {
+   *val = state->content_protection_type;
} else if (property == config->writeback_fb_id_property) {
/* Writeback framebuffer is one-shot, write and forget */
*val = 0;
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 07d65a16c623..4ce0830e9fb4 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -853,6 +853,13 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] 
= {
{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-P3_RGB_Theater" },
 };
 
+static struct drm_prop_enum_list drm_content_protection_type_enum_list[] = {
+   { DRM_MODE_CONTENT_PROTECTION_TYPE0, "Type 0" },
+   { DRM_MODE_CONTENT_PROTECTION_TYPE1, "Type 1" },
+};
+DRM_ENUM_NAME_FN(drm_get_content_protection_type_name,
+drm_content_protection_type_enum_list)
+
 /**
  * DOC: standard connector properties
  *
@@ -958,6 +965,23 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] 
= {
  *   the value transitions from ENABLED to DESIRED. This signifies the link
  *   is no longer protected and userspace should take appropriate action
  *   (whatever that might be).
+ * Content_protection_type:
+ * This property is used by the userspace to configure the kernel with
+ * upcoming stream's content type. Content Type of a stream is decided by
+ * the owner of the stream, as Type 0 or Type 1.
+ *
+ * The value of the property can be one the below:
+ *   - DRM_MODE_CONTENT_PROTECTION_TYPE0 = 0
+ * Type 0 streams can be transmitted on a link which is encrypted
+ * with HDCP 1.4 or HDCP 2.2.
+ *   - DRM_MODE_CONTENT_PROTECTION_TYPE1 = 1
+ * Type 1 streams can be transmitted on a link which is encrypted
+ * only with HDCP2.2.
+ *
+ * Please note this content type is introduced at HDCP2.2 and used in its
+ * authentication process. If content type is changed when
+ * content_protection is not UNDESIRED, then kernel will disable the HDCP
+ * and re-enable with new type in the same atomic commit
  *
  * max bpc:
  * This range property is used by userspace to limit the bit depth. When
@@ -1547,6 +1571,45 @@ int drm_connector_attach_content_protection_property(
 }
 EXPORT_SYMBOL(drm_connector_attach_content_protection_property);
 
+/**
+ * drm_connector_attach_content_protection_type_property - attach content
+ * protection type property
+ *
+ * @connector: connector to attach content protection type property on.
+ *
+ * This is used to add support for sending the protected content's stream type
+ * from userspace to kernel on selected connectors. Protected content provider
+ * will decide their type of their content and declare the same to kernel.
+ *
+ * This information will be used during the HDCP2.2 authentication.
+ *
+ * Content type will be set to _connector_state.content_protection_type.
+ *
+ * Returns:
+ * 

[Intel-gfx] [PATCH v2 2/8] drm: Add Content protection type property

2019-03-08 Thread Ramalingam C
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.

v2:
  cp_content_type is replaced with content_protection_type [daniel]
  check at atomic_set_property is removed [Maarten]

Signed-off-by: Ramalingam C 
---
 drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
 drivers/gpu/drm/drm_connector.c   | 63 +++
 include/drm/drm_connector.h   | 15 
 include/uapi/drm/drm_mode.h   |  4 ++
 4 files changed, 86 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c 
b/drivers/gpu/drm/drm_atomic_uapi.c
index 4eb81f10bc54..f383d4be5a92 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -746,6 +746,8 @@ static int drm_atomic_connector_set_property(struct 
drm_connector *connector,
return -EINVAL;
}
state->content_protection = val;
+   } else if (property == connector->content_protection_type_property) {
+   state->content_protection_type = val;
} else if (property == connector->colorspace_property) {
state->colorspace = val;
} else if (property == config->writeback_fb_id_property) {
@@ -822,6 +824,8 @@ drm_atomic_connector_get_property(struct drm_connector 
*connector,
*val = state->scaling_mode;
} else if (property == connector->content_protection_property) {
*val = state->content_protection;
+   } else if (property == connector->content_protection_type_property) {
+   *val = state->content_protection_type;
} else if (property == config->writeback_fb_id_property) {
/* Writeback framebuffer is one-shot, write and forget */
*val = 0;
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 07d65a16c623..4ce0830e9fb4 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -853,6 +853,13 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] 
= {
{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-P3_RGB_Theater" },
 };
 
+static struct drm_prop_enum_list drm_content_protection_type_enum_list[] = {
+   { DRM_MODE_CONTENT_PROTECTION_TYPE0, "Type 0" },
+   { DRM_MODE_CONTENT_PROTECTION_TYPE1, "Type 1" },
+};
+DRM_ENUM_NAME_FN(drm_get_content_protection_type_name,
+drm_content_protection_type_enum_list)
+
 /**
  * DOC: standard connector properties
  *
@@ -958,6 +965,23 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] 
= {
  *   the value transitions from ENABLED to DESIRED. This signifies the link
  *   is no longer protected and userspace should take appropriate action
  *   (whatever that might be).
+ * Content_protection_type:
+ * This property is used by the userspace to configure the kernel with
+ * upcoming stream's content type. Content Type of a stream is decided by
+ * the owner of the stream, as Type 0 or Type 1.
+ *
+ * The value of the property can be one the below:
+ *   - DRM_MODE_CONTENT_PROTECTION_TYPE0 = 0
+ * Type 0 streams can be transmitted on a link which is encrypted
+ * with HDCP 1.4 or HDCP 2.2.
+ *   - DRM_MODE_CONTENT_PROTECTION_TYPE1 = 1
+ * Type 1 streams can be transmitted on a link which is encrypted
+ * only with HDCP2.2.
+ *
+ * Please note this content type is introduced at HDCP2.2 and used in its
+ * authentication process. If content type is changed when
+ * content_protection is not UNDESIRED, then kernel will disable the HDCP
+ * and re-enable with new type in the same atomic commit
  *
  * max bpc:
  * This range property is used by userspace to limit the bit depth. When
@@ -1547,6 +1571,45 @@ int drm_connector_attach_content_protection_property(
 }
 EXPORT_SYMBOL(drm_connector_attach_content_protection_property);
 
+/**
+ * drm_connector_attach_content_protection_type_property - attach content
+ * protection type property
+ *
+ * @connector: connector to attach content protection type property on.
+ *
+ * This is used to add support for sending the protected content's stream type
+ * from userspace to kernel on selected connectors. Protected content provider
+ * will decide their type of their content and declare the same to kernel.
+ *
+ * This information will be used during the HDCP2.2 authentication.
+ *
+ * Content type will be set to _connector_state.content_protection_type.
+ *
+ * Returns:
+ *