[igt-dev] [PATCH i-g-t v5 1/6] kms_content_protection: Content type support

Ramalingam C ramalingam.c at intel.com
Thu Apr 18 08:48:37 UTC 2019


Adds a connector property called "CP_Content_Type"

Content Type takes two values which classifies the content stream:
	Type 0: Stream that can be tranmitted on HDCP1.4/HDCP2.2
	Type 1: Stream that needs HDCP2.2 encryption only.

So when Type 1 is set KMD is forced to enable HDCP2.2 only.

For Type 0 request, Kernel chooses the highest capable HDCP version
(v2.2) first. If that fails, then it fall back to the next availble
version(v1.4) before abondoning HDCP autehntication attempts.

Please note content_type is allowed to be updated when "Content
Protection" is in UNDESIRED state.

v2:
  s/cp_content_type/content_ptotection_type [danvet]
v3:
  s/content_protection_type/HDCP Content Type [Pekka]

Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
---
 lib/igt_kms.c                  |  1 +
 lib/igt_kms.h                  |  1 +
 tests/kms_content_protection.c | 77 ++++++++++++++++++++++++++++------
 3 files changed, 66 insertions(+), 13 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index df9aafd24bf8..18f0556687de 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -222,6 +222,7 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
 	[IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB",
 	[IGT_CONNECTOR_CONTENT_PROTECTION] = "Content Protection",
 	[IGT_CONNECTOR_VRR_CAPABLE] = "vrr_capable",
+	[IGT_CONNECTOR_HDCP_CONTENT_TYPE] = "HDCP Content Type",
 };
 
 /*
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 38bdc08f3d50..b1430a517305 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -123,6 +123,7 @@ enum igt_atomic_connector_properties {
        IGT_CONNECTOR_BROADCAST_RGB,
        IGT_CONNECTOR_CONTENT_PROTECTION,
        IGT_CONNECTOR_VRR_CAPABLE,
+       IGT_CONNECTOR_HDCP_CONTENT_TYPE,
        IGT_NUM_CONNECTOR_PROPS
 };
 
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index ae6ab497ea21..8f0fca07c986 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -40,6 +40,13 @@ struct data {
 #define CP_DESIRED				1
 #define CP_ENABLED				2
 
+/*
+ * HDCP_CONTENT_TYPE_0 can be handled on both HDCP1.4 and HDCP2.2. Where as
+ * HDCP_CONTENT_TYPE_1 can be handled only through HDCP2.2.
+ */
+#define HDCP_CONTENT_TYPE_0				0
+#define HDCP_CONTENT_TYPE_1				1
+
 #define LIC_PERIOD_MSEC				(4 * 1000)
 /* Kernel retry count=3, Max time per authentication allowed = 6Sec */
 #define KERNEL_AUTH_TIME_ALLOWED_MSEC		(3 *  6 * 1000)
@@ -155,7 +162,8 @@ static void modeset_with_fb(const enum pipe pipe, igt_output_t *output,
 	commit_display_and_wait_for_flip(s);
 }
 
-static bool test_cp_enable(igt_output_t *output, enum igt_commit_style s)
+static bool test_cp_enable(igt_output_t *output, enum igt_commit_style s,
+			   int content_type)
 {
 	igt_display_t *display = &data.display;
 	igt_plane_t *primary;
@@ -165,6 +173,10 @@ static bool test_cp_enable(igt_output_t *output, enum igt_commit_style s)
 
 	igt_output_set_prop_value(output,
 				  IGT_CONNECTOR_CONTENT_PROTECTION, CP_DESIRED);
+	if (output->props[IGT_CONNECTOR_HDCP_CONTENT_TYPE])
+		igt_output_set_prop_value(output,
+					  IGT_CONNECTOR_HDCP_CONTENT_TYPE,
+					  content_type);
 	igt_display_commit2(display, s);
 
 	ret = wait_for_prop_value(output, CP_ENABLED,
@@ -201,13 +213,14 @@ static void test_cp_disable(igt_output_t *output, enum igt_commit_style s)
 }
 
 static void test_cp_enable_with_retry(igt_output_t *output,
-				      enum igt_commit_style s, int retry)
+				      enum igt_commit_style s, int retry,
+				      int content_type)
 {
 	bool ret;
 
 	do {
 		test_cp_disable(output, s);
-		ret = test_cp_enable(output, s);
+		ret = test_cp_enable(output, s, content_type);
 
 		if (!ret && --retry)
 			igt_debug("Retry (%d/2) ...\n", 3 - retry);
@@ -241,7 +254,7 @@ static void test_cp_lic(igt_output_t *output)
 
 static void test_content_protection_on_output(igt_output_t *output,
 					      enum igt_commit_style s,
-					      bool dpms_test)
+					      bool dpms_test, int content_type)
 {
 	igt_display_t *display = &data.display;
 	igt_plane_t *primary;
@@ -262,7 +275,7 @@ static void test_content_protection_on_output(igt_output_t *output,
 			continue;
 
 		modeset_with_fb(pipe, output, s);
-		test_cp_enable_with_retry(output, s, 3);
+		test_cp_enable_with_retry(output, s, 3, content_type);
 		test_cp_lic(output);
 
 		if (dpms_test) {
@@ -277,7 +290,8 @@ static void test_content_protection_on_output(igt_output_t *output,
 			ret = wait_for_prop_value(output, CP_ENABLED,
 						  KERNEL_AUTH_TIME_ALLOWED_MSEC);
 			if (!ret)
-				test_cp_enable_with_retry(output, s, 2);
+				test_cp_enable_with_retry(output, s,
+							  2, content_type);
 		}
 
 		test_cp_disable(output, s);
@@ -304,7 +318,8 @@ static void __debugfs_read(int fd, const char *param, char *buf, int len)
 
 #define debugfs_read(fd, p, arr) __debugfs_read(fd, p, arr, sizeof(arr))
 
-#define MAX_SINK_HDCP_CAP_BUF_LEN	500
+#define MAX_SINK_HDCP_CAP_BUF_LEN	5000
+
 static bool sink_hdcp_capable(igt_output_t *output)
 {
 	char buf[MAX_SINK_HDCP_CAP_BUF_LEN];
@@ -322,9 +337,26 @@ static bool sink_hdcp_capable(igt_output_t *output)
 	return strstr(buf, "HDCP1.4");
 }
 
+static bool sink_hdcp2_capable(igt_output_t *output)
+{
+	char buf[MAX_SINK_HDCP_CAP_BUF_LEN];
+	int fd;
+
+	fd = igt_debugfs_connector_dir(data.drm_fd, output->name, O_RDONLY);
+	if (fd < 0)
+		return false;
+
+	debugfs_read(fd, "i915_hdcp_sink_capability", buf);
+	close(fd);
+
+	igt_debug("Sink capability: %s\n", buf);
+
+	return strstr(buf, "HDCP2.2");
+}
 
 static void
-test_content_protection(enum igt_commit_style s, bool dpms_test)
+test_content_protection(enum igt_commit_style s, bool dpms_test,
+			int content_type)
 {
 	igt_display_t *display = &data.display;
 	igt_output_t *output;
@@ -334,14 +366,24 @@ test_content_protection(enum igt_commit_style s, bool dpms_test)
 		if (!output->props[IGT_CONNECTOR_CONTENT_PROTECTION])
 			continue;
 
+		if (!output->props[IGT_CONNECTOR_HDCP_CONTENT_TYPE] &&
+		    content_type)
+			continue;
+
 		igt_info("CP Test execution on %s\n", output->name);
-		if (!sink_hdcp_capable(output)) {
+
+		if (content_type && !sink_hdcp2_capable(output)) {
+			igt_info("\tSkip %s (Sink has no HDCP2.2 support)\n",
+				 output->name);
+			continue;
+		} else if (!sink_hdcp_capable(output)) {
 			igt_info("\tSkip %s (Sink has no HDCP support)\n",
 				 output->name);
 			continue;
 		}
 
-		test_content_protection_on_output(output, s, dpms_test);
+		test_content_protection_on_output(output, s, dpms_test,
+						  content_type);
 		valid_tests++;
 	}
 
@@ -359,16 +401,25 @@ igt_main
 	}
 
 	igt_subtest("legacy")
-		test_content_protection(COMMIT_LEGACY, false);
+		test_content_protection(COMMIT_LEGACY, false,
+					HDCP_CONTENT_TYPE_0);
 
 	igt_subtest("atomic") {
 		igt_require(data.display.is_atomic);
-		test_content_protection(COMMIT_ATOMIC, false);
+		test_content_protection(COMMIT_ATOMIC, false,
+					HDCP_CONTENT_TYPE_0);
 	}
 
 	igt_subtest("atomic-dpms") {
 		igt_require(data.display.is_atomic);
-		test_content_protection(COMMIT_ATOMIC, true);
+		test_content_protection(COMMIT_ATOMIC, true,
+					HDCP_CONTENT_TYPE_0);
+	}
+
+	igt_subtest("type1") {
+		igt_require(data.display.is_atomic);
+		test_content_protection(COMMIT_ATOMIC, false,
+					HDCP_CONTENT_TYPE_1);
 	}
 
 	igt_fixture
-- 
2.19.1



More information about the igt-dev mailing list