public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t v4 1/2] lib/debugfs: connector debugfs director
@ 2018-10-22 14:23 Ramalingam C
  2018-10-22 14:23 ` [igt-dev] [PATCH i-g-t v4 2/2] kms_content_protection: Add Content Protection test Ramalingam C
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ramalingam C @ 2018-10-22 14:23 UTC (permalink / raw)
  To: igt-dev, daniel.vetter

Function to open a debugfs director of a connector associated to
a device.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
 lib/igt_debugfs.c | 24 ++++++++++++++++++++++++
 lib/igt_debugfs.h |  1 +
 2 files changed, 25 insertions(+)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index baedc2255ac9..f545e8a3eec9 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -237,6 +237,30 @@ int igt_debugfs_dir(int device)
 }
 
 /**
+ * igt_debugfs_connector_dir:
+ * @device: fd of the device
+ * @conn_name: conenctor name
+ *
+ * This opens the debugfs directory corresponding to connector on the device
+ * for use with igt_sysfs_get() and related functions.
+ *
+ * Returns:
+ * The directory fd, or -1 on failure.
+ */
+int igt_debugfs_connector_dir(int device, char *conn_name)
+{
+	char path[200], base_path[200];
+
+	if (!igt_debugfs_path(device, base_path, sizeof(base_path)))
+		return -1;
+
+	snprintf(path, sizeof(path), "%s/%s", base_path, conn_name);
+
+	igt_debug("Opening debugfs connector directory '%s'\n", path);
+	return open(path, O_RDONLY);
+}
+
+/**
  * igt_debugfs_open:
  * @filename: name of the debugfs node to open
  * @mode: mode bits as used by open()
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index ff8612dc66c2..4c2f992732cf 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -35,6 +35,7 @@ const char *igt_debugfs_mount(void);
 char *igt_debugfs_path(int device, char *path, int pathlen);
 
 int igt_debugfs_dir(int device);
+int igt_debugfs_connector_dir(int device, char *conn_name);
 
 int igt_debugfs_open(int fd, const char *filename, int mode);
 void __igt_debugfs_read(int fd, const char *filename, char *buf, int size);
-- 
2.7.4

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [igt-dev] [PATCH i-g-t v4 2/2] kms_content_protection: Add Content Protection test
  2018-10-22 14:23 [igt-dev] [PATCH i-g-t v4 1/2] lib/debugfs: connector debugfs director Ramalingam C
@ 2018-10-22 14:23 ` Ramalingam C
  2018-10-22 14:56   ` Daniel Vetter
  2018-10-22 14:58 ` [igt-dev] [PATCH i-g-t v4 1/2] lib/debugfs: connector debugfs director Chris Wilson
  2018-10-22 21:07 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v4,1/2] " Patchwork
  2 siblings, 1 reply; 6+ messages in thread
From: Ramalingam C @ 2018-10-22 14:23 UTC (permalink / raw)
  To: igt-dev, daniel.vetter

Pretty simple test:
- picks the hdcp capable output with suitable pipe and apply modeset.
- checks the connected sink's hdcp capability through debugfs
- apply a FB and wait for the flip completion.
- clears the content protection property
- verifies that it clears
- sets the content protection property to desired
- verifies that it transitions to enabled
- incase of timeout three reattempts are implemented
- clear the content protection property and modeset on the crtc

Above steps are repeated on all HDCP capable connectors for both
legacy and atomic subtests.

v2:
  dynamic subtests are dropped [Daniel]
v3:
  debugfs is used to detect the sink's hdcp capability [Daniel]
  data structure is made as global variable.
v4:
  debugfs file from connector's debugfs dir is used [Daniel]

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
 lib/igt_kms.c                  |   1 +
 lib/igt_kms.h                  |   1 +
 tests/Makefile.sources         |   1 +
 tests/kms_content_protection.c | 301 +++++++++++++++++++++++++++++++++++++++++
 tests/meson.build              |   1 +
 5 files changed, 305 insertions(+)
 create mode 100644 tests/kms_content_protection.c

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 62d8468415c6..4231996c65ca 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -194,6 +194,7 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
 	[IGT_CONNECTOR_CRTC_ID] = "CRTC_ID",
 	[IGT_CONNECTOR_DPMS] = "DPMS",
 	[IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB",
+	[IGT_CONNECTOR_CONTENT_PROTECTION] = "Content Protection",
 };
 
 /*
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 3a12f2782eed..aa068e58e607 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -120,6 +120,7 @@ enum igt_atomic_connector_properties {
        IGT_CONNECTOR_CRTC_ID,
        IGT_CONNECTOR_DPMS,
        IGT_CONNECTOR_BROADCAST_RGB,
+       IGT_CONNECTOR_CONTENT_PROTECTION,
        IGT_NUM_CONNECTOR_PROPS
 };
 
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index c84933f1d971..5af68a61df51 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -174,6 +174,7 @@ TESTS_progs = \
 	kms_chv_cursor_fail \
 	kms_color \
 	kms_concurrent \
+	kms_content_protection\
 	kms_crtc_background_color \
 	kms_cursor_crc \
 	kms_cursor_legacy \
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
new file mode 100644
index 000000000000..e8de7d359d09
--- /dev/null
+++ b/tests/kms_content_protection.c
@@ -0,0 +1,301 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include <poll.h>
+#include "igt.h"
+#include "igt_sysfs.h"
+
+IGT_TEST_DESCRIPTION("Test content protection (HDCP)");
+
+struct data {
+	int drm_fd;
+	igt_display_t display;
+} data;
+
+
+static void flip_handler(int fd, unsigned int sequence, unsigned int tv_sec,
+			 unsigned int tv_usec, void *_data)
+{
+	igt_debug("Flip event received.\n");
+}
+
+static int wait_flip_event(void)
+{
+	int rc;
+	drmEventContext evctx;
+	struct pollfd pfd;
+
+	evctx.version = 2;
+	evctx.vblank_handler = NULL;
+	evctx.page_flip_handler = flip_handler;
+
+	pfd.fd = data.drm_fd;
+	pfd.events = POLLIN;
+	pfd.revents = 0;
+
+	rc = poll(&pfd, 1, 1000);
+	switch (rc) {
+	case 0:
+		igt_info("Poll timeout. 1Sec.\n");
+		rc = -ETIMEDOUT;
+		break;
+	case 1:
+		rc = drmHandleEvent(data.drm_fd, &evctx);
+		igt_assert_eq(rc, 0);
+		rc = 0;
+		break;
+	default:
+		igt_info("Unexpected poll rc %d\n", rc);
+		rc = -1;
+		break;
+	}
+
+	return rc;
+}
+
+static bool
+wait_for_prop_value(igt_output_t *output, uint64_t expected,
+		    uint32_t timeout_mSec)
+{
+	uint64_t val;
+	int i;
+
+	for (i = 0; i < timeout_mSec; i++) {
+		val = igt_output_get_prop(output,
+					  IGT_CONNECTOR_CONTENT_PROTECTION);
+		if (val == expected)
+			return true;
+		usleep(1000);
+	}
+	igt_info("prop_value mismatch %ld != %ld\n", val, expected);
+
+	return false;
+}
+
+static void
+commit_display_and_wait_for_flip(enum igt_commit_style s)
+{
+	int ret;
+	uint32_t flag;
+
+	if (s == COMMIT_ATOMIC) {
+		flag = DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_ALLOW_MODESET;
+		igt_display_commit_atomic(&data.display, flag, NULL);
+
+		ret = wait_flip_event();
+		igt_assert_f(!ret, "wait_flip_event failed. %d\n", ret);
+	} else {
+		igt_display_commit2(&data.display, s);
+
+		/* Wait for 50mSec */
+		usleep(50 * 1000);
+	}
+}
+
+static void
+test_cp_enable_disable(const enum pipe pipe, igt_output_t *output,
+		       enum igt_commit_style s)
+{
+	igt_display_t *display = &data.display;
+	drmModeModeInfo mode;
+	igt_plane_t *primary;
+	struct igt_fb red, green;
+	bool ret;
+	int retry = 3;
+
+	igt_assert(kmstest_get_connector_default_mode(
+			display->drm_fd, output->config.connector, &mode));
+
+	igt_output_override_mode(output, &mode);
+	igt_output_set_pipe(output, pipe);
+
+	igt_create_color_fb(display->drm_fd, mode.hdisplay, mode.vdisplay,
+			    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			    1.f, 0.f, 0.f, &red);
+	igt_create_color_fb(display->drm_fd, mode.hdisplay, mode.vdisplay,
+			    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			    0.f, 1.f, 0.f, &green);
+
+	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+	igt_display_commit2(display, s);
+
+	igt_plane_set_fb(primary, &red);
+
+	/* Wait for Flip completion before starting the HDCP authentication */
+	commit_display_and_wait_for_flip(s);
+
+	do {
+		igt_output_set_prop_value(output,
+					  IGT_CONNECTOR_CONTENT_PROTECTION, 0);
+		igt_display_commit2(display, s);
+
+		/* Wait for HDCP to be disabled for fresh start. */
+		ret = wait_for_prop_value(output, 0, 1000);
+		igt_assert_f(ret, "Content Protection not cleared\n");
+
+		igt_output_set_prop_value(output,
+					  IGT_CONNECTOR_CONTENT_PROTECTION, 1);
+		igt_display_commit2(display, s);
+
+		/* Wait for 18000mSec (3 authentication * 6Sec) */
+		ret = wait_for_prop_value(output, 2, 18000);
+		if (ret) {
+			igt_plane_set_fb(primary, &green);
+			igt_display_commit2(display, s);
+		}
+
+		if (!ret && --retry)
+			igt_debug("Retry (%d/2) ...\n", 3 - retry);
+	} while (retry && !ret);
+
+	igt_assert_f(ret, "Content Protection not enabled\n");
+
+	igt_output_set_prop_value(output, IGT_CONNECTOR_CONTENT_PROTECTION, 0);
+	igt_plane_set_fb(primary, &red);
+	igt_display_commit2(display, s);
+
+	/* Wait for HDCP to be disabled, before crtc off */
+	wait_for_prop_value(output, 0, 1000);
+
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+}
+
+static bool igt_pipe_is_free(igt_display_t *display, enum pipe pipe)
+{
+	int i;
+
+	for (i = 0; i < display->n_outputs; i++)
+		if (display->outputs[i].pending_pipe == pipe)
+			return false;
+
+	return true;
+}
+
+static void
+test_content_protection_on_output(igt_output_t *output,
+				  enum igt_commit_style s)
+{
+	igt_display_t *display = &data.display;
+	enum pipe pipe;
+
+	for_each_pipe(display, pipe) {
+		if (!igt_pipe_connector_valid(pipe, output))
+			continue;
+
+		/*
+		 * If previous subtest of connector failed, pipe
+		 * attached to that connector is not released.
+		 * Because of that we have to choose the non
+		 * attached pipe for this subtest.
+		 */
+		if (!igt_pipe_is_free(display, pipe))
+			continue;
+
+		test_cp_enable_disable(pipe, output, s);
+
+		/*
+		 * Testing a output with a pipe is enough for HDCP
+		 * testing. No ROI in testing the connector with other
+		 * pipes. So Break the loop on pipe.
+		 */
+		break;
+	}
+
+}
+
+static void __debugfs_read(int fd, const char *param, char *buf, int len)
+{
+	len = igt_debugfs_simple_read(fd, param, buf, len);
+	if (len < 0)
+		igt_assert_eq(len, -ENODEV);
+}
+
+#define debugfs_read(fd, p, arr) __debugfs_read(fd, p, arr, sizeof(arr))
+
+#define MAX_SINK_HDCP_CAP_BUF_LEN	500
+static bool sink_hdcp_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);
+	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, "HDCP1.4");
+}
+
+
+static void
+test_content_protection(enum igt_commit_style s)
+{
+	igt_display_t *display = &data.display;
+	igt_output_t *output;
+	int valid_tests = 0;
+
+	for_each_connected_output(display, output) {
+		if (!output->props[IGT_CONNECTOR_CONTENT_PROTECTION])
+			continue;
+
+		igt_info("CP Test execution on %s\n", output->name);
+		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);
+		valid_tests++;
+	}
+
+	igt_require_f(valid_tests, "No connector found with HDCP capability\n");
+}
+
+igt_main
+{
+	igt_fixture {
+		igt_skip_on_simulation();
+
+		data.drm_fd = drm_open_driver(DRIVER_ANY);
+
+		igt_display_init(&data.display, data.drm_fd);
+	}
+
+	igt_subtest("legacy")
+		test_content_protection(COMMIT_LEGACY);
+
+	igt_subtest("atomic") {
+		igt_require(data.display.is_atomic);
+		test_content_protection(COMMIT_ATOMIC);
+	}
+
+	igt_fixture
+		igt_display_fini(&data.display);
+}
diff --git a/tests/meson.build b/tests/meson.build
index 17deb945ec95..a74de4ff0ece 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -149,6 +149,7 @@ test_progs = [
 	'kms_chv_cursor_fail',
 	'kms_color',
 	'kms_concurrent',
+	'kms_content_protection',
 	'kms_crtc_background_color',
 	'kms_cursor_crc',
 	'kms_cursor_legacy',
-- 
2.7.4

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v4 2/2] kms_content_protection: Add Content Protection test
  2018-10-22 14:23 ` [igt-dev] [PATCH i-g-t v4 2/2] kms_content_protection: Add Content Protection test Ramalingam C
@ 2018-10-22 14:56   ` Daniel Vetter
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2018-10-22 14:56 UTC (permalink / raw)
  To: Ramalingam C; +Cc: igt-dev

On Mon, Oct 22, 2018 at 07:53:49PM +0530, Ramalingam C wrote:
> Pretty simple test:
> - picks the hdcp capable output with suitable pipe and apply modeset.
> - checks the connected sink's hdcp capability through debugfs
> - apply a FB and wait for the flip completion.
> - clears the content protection property
> - verifies that it clears
> - sets the content protection property to desired
> - verifies that it transitions to enabled
> - incase of timeout three reattempts are implemented
> - clear the content protection property and modeset on the crtc
> 
> Above steps are repeated on all HDCP capable connectors for both
> legacy and atomic subtests.
> 
> v2:
>   dynamic subtests are dropped [Daniel]
> v3:
>   debugfs is used to detect the sink's hdcp capability [Daniel]
>   data structure is made as global variable.
> v4:
>   debugfs file from connector's debugfs dir is used [Daniel]
> 
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>

I think both patches are good enough for merging. On both:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Need to wait for CI to approve them too, then we can pull them in.
-Daniel

> ---
>  lib/igt_kms.c                  |   1 +
>  lib/igt_kms.h                  |   1 +
>  tests/Makefile.sources         |   1 +
>  tests/kms_content_protection.c | 301 +++++++++++++++++++++++++++++++++++++++++
>  tests/meson.build              |   1 +
>  5 files changed, 305 insertions(+)
>  create mode 100644 tests/kms_content_protection.c
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 62d8468415c6..4231996c65ca 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -194,6 +194,7 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
>  	[IGT_CONNECTOR_CRTC_ID] = "CRTC_ID",
>  	[IGT_CONNECTOR_DPMS] = "DPMS",
>  	[IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB",
> +	[IGT_CONNECTOR_CONTENT_PROTECTION] = "Content Protection",
>  };
>  
>  /*
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 3a12f2782eed..aa068e58e607 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -120,6 +120,7 @@ enum igt_atomic_connector_properties {
>         IGT_CONNECTOR_CRTC_ID,
>         IGT_CONNECTOR_DPMS,
>         IGT_CONNECTOR_BROADCAST_RGB,
> +       IGT_CONNECTOR_CONTENT_PROTECTION,
>         IGT_NUM_CONNECTOR_PROPS
>  };
>  
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index c84933f1d971..5af68a61df51 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -174,6 +174,7 @@ TESTS_progs = \
>  	kms_chv_cursor_fail \
>  	kms_color \
>  	kms_concurrent \
> +	kms_content_protection\
>  	kms_crtc_background_color \
>  	kms_cursor_crc \
>  	kms_cursor_legacy \
> diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
> new file mode 100644
> index 000000000000..e8de7d359d09
> --- /dev/null
> +++ b/tests/kms_content_protection.c
> @@ -0,0 +1,301 @@
> +/*
> + * Copyright © 2018 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + */
> +
> +#include <poll.h>
> +#include "igt.h"
> +#include "igt_sysfs.h"
> +
> +IGT_TEST_DESCRIPTION("Test content protection (HDCP)");
> +
> +struct data {
> +	int drm_fd;
> +	igt_display_t display;
> +} data;
> +
> +
> +static void flip_handler(int fd, unsigned int sequence, unsigned int tv_sec,
> +			 unsigned int tv_usec, void *_data)
> +{
> +	igt_debug("Flip event received.\n");
> +}
> +
> +static int wait_flip_event(void)
> +{
> +	int rc;
> +	drmEventContext evctx;
> +	struct pollfd pfd;
> +
> +	evctx.version = 2;
> +	evctx.vblank_handler = NULL;
> +	evctx.page_flip_handler = flip_handler;
> +
> +	pfd.fd = data.drm_fd;
> +	pfd.events = POLLIN;
> +	pfd.revents = 0;
> +
> +	rc = poll(&pfd, 1, 1000);
> +	switch (rc) {
> +	case 0:
> +		igt_info("Poll timeout. 1Sec.\n");
> +		rc = -ETIMEDOUT;
> +		break;
> +	case 1:
> +		rc = drmHandleEvent(data.drm_fd, &evctx);
> +		igt_assert_eq(rc, 0);
> +		rc = 0;
> +		break;
> +	default:
> +		igt_info("Unexpected poll rc %d\n", rc);
> +		rc = -1;
> +		break;
> +	}
> +
> +	return rc;
> +}
> +
> +static bool
> +wait_for_prop_value(igt_output_t *output, uint64_t expected,
> +		    uint32_t timeout_mSec)
> +{
> +	uint64_t val;
> +	int i;
> +
> +	for (i = 0; i < timeout_mSec; i++) {
> +		val = igt_output_get_prop(output,
> +					  IGT_CONNECTOR_CONTENT_PROTECTION);
> +		if (val == expected)
> +			return true;
> +		usleep(1000);
> +	}
> +	igt_info("prop_value mismatch %ld != %ld\n", val, expected);
> +
> +	return false;
> +}
> +
> +static void
> +commit_display_and_wait_for_flip(enum igt_commit_style s)
> +{
> +	int ret;
> +	uint32_t flag;
> +
> +	if (s == COMMIT_ATOMIC) {
> +		flag = DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_ALLOW_MODESET;
> +		igt_display_commit_atomic(&data.display, flag, NULL);
> +
> +		ret = wait_flip_event();
> +		igt_assert_f(!ret, "wait_flip_event failed. %d\n", ret);
> +	} else {
> +		igt_display_commit2(&data.display, s);
> +
> +		/* Wait for 50mSec */
> +		usleep(50 * 1000);
> +	}
> +}
> +
> +static void
> +test_cp_enable_disable(const enum pipe pipe, igt_output_t *output,
> +		       enum igt_commit_style s)
> +{
> +	igt_display_t *display = &data.display;
> +	drmModeModeInfo mode;
> +	igt_plane_t *primary;
> +	struct igt_fb red, green;
> +	bool ret;
> +	int retry = 3;
> +
> +	igt_assert(kmstest_get_connector_default_mode(
> +			display->drm_fd, output->config.connector, &mode));
> +
> +	igt_output_override_mode(output, &mode);
> +	igt_output_set_pipe(output, pipe);
> +
> +	igt_create_color_fb(display->drm_fd, mode.hdisplay, mode.vdisplay,
> +			    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +			    1.f, 0.f, 0.f, &red);
> +	igt_create_color_fb(display->drm_fd, mode.hdisplay, mode.vdisplay,
> +			    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +			    0.f, 1.f, 0.f, &green);
> +
> +	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
> +	igt_display_commit2(display, s);
> +
> +	igt_plane_set_fb(primary, &red);
> +
> +	/* Wait for Flip completion before starting the HDCP authentication */
> +	commit_display_and_wait_for_flip(s);
> +
> +	do {
> +		igt_output_set_prop_value(output,
> +					  IGT_CONNECTOR_CONTENT_PROTECTION, 0);
> +		igt_display_commit2(display, s);
> +
> +		/* Wait for HDCP to be disabled for fresh start. */
> +		ret = wait_for_prop_value(output, 0, 1000);
> +		igt_assert_f(ret, "Content Protection not cleared\n");
> +
> +		igt_output_set_prop_value(output,
> +					  IGT_CONNECTOR_CONTENT_PROTECTION, 1);
> +		igt_display_commit2(display, s);
> +
> +		/* Wait for 18000mSec (3 authentication * 6Sec) */
> +		ret = wait_for_prop_value(output, 2, 18000);
> +		if (ret) {
> +			igt_plane_set_fb(primary, &green);
> +			igt_display_commit2(display, s);
> +		}
> +
> +		if (!ret && --retry)
> +			igt_debug("Retry (%d/2) ...\n", 3 - retry);
> +	} while (retry && !ret);
> +
> +	igt_assert_f(ret, "Content Protection not enabled\n");
> +
> +	igt_output_set_prop_value(output, IGT_CONNECTOR_CONTENT_PROTECTION, 0);
> +	igt_plane_set_fb(primary, &red);
> +	igt_display_commit2(display, s);
> +
> +	/* Wait for HDCP to be disabled, before crtc off */
> +	wait_for_prop_value(output, 0, 1000);
> +
> +	igt_plane_set_fb(primary, NULL);
> +	igt_output_set_pipe(output, PIPE_NONE);
> +}
> +
> +static bool igt_pipe_is_free(igt_display_t *display, enum pipe pipe)
> +{
> +	int i;
> +
> +	for (i = 0; i < display->n_outputs; i++)
> +		if (display->outputs[i].pending_pipe == pipe)
> +			return false;
> +
> +	return true;
> +}
> +
> +static void
> +test_content_protection_on_output(igt_output_t *output,
> +				  enum igt_commit_style s)
> +{
> +	igt_display_t *display = &data.display;
> +	enum pipe pipe;
> +
> +	for_each_pipe(display, pipe) {
> +		if (!igt_pipe_connector_valid(pipe, output))
> +			continue;
> +
> +		/*
> +		 * If previous subtest of connector failed, pipe
> +		 * attached to that connector is not released.
> +		 * Because of that we have to choose the non
> +		 * attached pipe for this subtest.
> +		 */
> +		if (!igt_pipe_is_free(display, pipe))
> +			continue;
> +
> +		test_cp_enable_disable(pipe, output, s);
> +
> +		/*
> +		 * Testing a output with a pipe is enough for HDCP
> +		 * testing. No ROI in testing the connector with other
> +		 * pipes. So Break the loop on pipe.
> +		 */
> +		break;
> +	}
> +
> +}
> +
> +static void __debugfs_read(int fd, const char *param, char *buf, int len)
> +{
> +	len = igt_debugfs_simple_read(fd, param, buf, len);
> +	if (len < 0)
> +		igt_assert_eq(len, -ENODEV);
> +}
> +
> +#define debugfs_read(fd, p, arr) __debugfs_read(fd, p, arr, sizeof(arr))
> +
> +#define MAX_SINK_HDCP_CAP_BUF_LEN	500
> +static bool sink_hdcp_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);
> +	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, "HDCP1.4");
> +}
> +
> +
> +static void
> +test_content_protection(enum igt_commit_style s)
> +{
> +	igt_display_t *display = &data.display;
> +	igt_output_t *output;
> +	int valid_tests = 0;
> +
> +	for_each_connected_output(display, output) {
> +		if (!output->props[IGT_CONNECTOR_CONTENT_PROTECTION])
> +			continue;
> +
> +		igt_info("CP Test execution on %s\n", output->name);
> +		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);
> +		valid_tests++;
> +	}
> +
> +	igt_require_f(valid_tests, "No connector found with HDCP capability\n");
> +}
> +
> +igt_main
> +{
> +	igt_fixture {
> +		igt_skip_on_simulation();
> +
> +		data.drm_fd = drm_open_driver(DRIVER_ANY);
> +
> +		igt_display_init(&data.display, data.drm_fd);
> +	}
> +
> +	igt_subtest("legacy")
> +		test_content_protection(COMMIT_LEGACY);
> +
> +	igt_subtest("atomic") {
> +		igt_require(data.display.is_atomic);
> +		test_content_protection(COMMIT_ATOMIC);
> +	}
> +
> +	igt_fixture
> +		igt_display_fini(&data.display);
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 17deb945ec95..a74de4ff0ece 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -149,6 +149,7 @@ test_progs = [
>  	'kms_chv_cursor_fail',
>  	'kms_color',
>  	'kms_concurrent',
> +	'kms_content_protection',
>  	'kms_crtc_background_color',
>  	'kms_cursor_crc',
>  	'kms_cursor_legacy',
> -- 
> 2.7.4
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v4 1/2] lib/debugfs: connector debugfs director
  2018-10-22 14:23 [igt-dev] [PATCH i-g-t v4 1/2] lib/debugfs: connector debugfs director Ramalingam C
  2018-10-22 14:23 ` [igt-dev] [PATCH i-g-t v4 2/2] kms_content_protection: Add Content Protection test Ramalingam C
@ 2018-10-22 14:58 ` Chris Wilson
  2018-10-22 16:32   ` C, Ramalingam
  2018-10-22 21:07 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v4,1/2] " Patchwork
  2 siblings, 1 reply; 6+ messages in thread
From: Chris Wilson @ 2018-10-22 14:58 UTC (permalink / raw)
  To: Ramalingam C, daniel.vetter, igt-dev

Quoting Ramalingam C (2018-10-22 15:23:48)
> Function to open a debugfs director of a connector associated to
> a device.
> 
> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> ---
>  lib/igt_debugfs.c | 24 ++++++++++++++++++++++++
>  lib/igt_debugfs.h |  1 +
>  2 files changed, 25 insertions(+)
> 
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index baedc2255ac9..f545e8a3eec9 100644
> --- a/lib/igt_debugfs.c
> +++ b/lib/igt_debugfs.c
> @@ -237,6 +237,30 @@ int igt_debugfs_dir(int device)
>  }
>  
>  /**
> + * igt_debugfs_connector_dir:
> + * @device: fd of the device
> + * @conn_name: conenctor name
> + *
> + * This opens the debugfs directory corresponding to connector on the device
> + * for use with igt_sysfs_get() and related functions.
> + *
> + * Returns:
> + * The directory fd, or -1 on failure.
> + */
> +int igt_debugfs_connector_dir(int device, char *conn_name)
> +{
> +       char path[200], base_path[200];
> +
> +       if (!igt_debugfs_path(device, base_path, sizeof(base_path)))
> +               return -1;

Why not use the debugfs_dir and openat? String ops not required.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v4 1/2] lib/debugfs: connector debugfs director
  2018-10-22 14:58 ` [igt-dev] [PATCH i-g-t v4 1/2] lib/debugfs: connector debugfs director Chris Wilson
@ 2018-10-22 16:32   ` C, Ramalingam
  0 siblings, 0 replies; 6+ messages in thread
From: C, Ramalingam @ 2018-10-22 16:32 UTC (permalink / raw)
  To: Chris Wilson, daniel.vetter, igt-dev


[-- Attachment #1.1: Type: text/plain, Size: 1900 bytes --]


On 10/22/2018 8:28 PM, Chris Wilson wrote:
> Quoting Ramalingam C (2018-10-22 15:23:48)
>> Function to open a debugfs director of a connector associated to
>> a device.
>>
>> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
>> ---
>>   lib/igt_debugfs.c | 24 ++++++++++++++++++++++++
>>   lib/igt_debugfs.h |  1 +
>>   2 files changed, 25 insertions(+)
>>
>> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
>> index baedc2255ac9..f545e8a3eec9 100644
>> --- a/lib/igt_debugfs.c
>> +++ b/lib/igt_debugfs.c
>> @@ -237,6 +237,30 @@ int igt_debugfs_dir(int device)
>>   }
>>   
>>   /**
>> + * igt_debugfs_connector_dir:
>> + * @device: fd of the device
>> + * @conn_name: conenctor name
>> + *
>> + * This opens the debugfs directory corresponding to connector on the device
>> + * for use with igt_sysfs_get() and related functions.
>> + *
>> + * Returns:
>> + * The directory fd, or -1 on failure.
>> + */
>> +int igt_debugfs_connector_dir(int device, char *conn_name)
>> +{
>> +       char path[200], base_path[200];
>> +
>> +       if (!igt_debugfs_path(device, base_path, sizeof(base_path)))
>> +               return -1;
> Why not use the debugfs_dir and openat? String ops not required.

Chris,

Do you mean this way?

int igt_debugfs_connector_dir(int device, char *conn_name)
{
         int dir, ret;
                                                                                 
         dir = igt_debugfs_dir(device);
         if (dir < 0)
                 return dir;
                                                                                 
         ret = openat(dir, conn_name, O_RDONLY);
                                                                                 
         close(dir);
                                                                                 
         return ret;
}

--Ram

> -Chris

[-- Attachment #1.2: Type: text/html, Size: 3890 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v4,1/2] lib/debugfs: connector debugfs director
  2018-10-22 14:23 [igt-dev] [PATCH i-g-t v4 1/2] lib/debugfs: connector debugfs director Ramalingam C
  2018-10-22 14:23 ` [igt-dev] [PATCH i-g-t v4 2/2] kms_content_protection: Add Content Protection test Ramalingam C
  2018-10-22 14:58 ` [igt-dev] [PATCH i-g-t v4 1/2] lib/debugfs: connector debugfs director Chris Wilson
@ 2018-10-22 21:07 ` Patchwork
  2 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2018-10-22 21:07 UTC (permalink / raw)
  To: Ramalingam C; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,v4,1/2] lib/debugfs: connector debugfs director
URL   : https://patchwork.freedesktop.org/series/51331/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_5013 -> IGTPW_1972 =

== Summary - FAILURE ==

  Serious unknown changes coming with IGTPW_1972 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1972, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/51331/revisions/1/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1972:

  === IGT changes ===

    ==== Possible regressions ====

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
      fi-apl-guc:         PASS -> DMESG-WARN

    
== Known issues ==

  Here are the changes found in IGTPW_1972 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_store@basic-all:
      fi-icl-u:           NOTRUN -> DMESG-WARN (fdo#107724) +25

    igt@gem_exec_store@basic-bsd:
      fi-icl-u:           NOTRUN -> DMESG-WARN (fdo#107732) +7

    igt@gem_exec_suspend@basic-s3:
      fi-icl-u:           NOTRUN -> DMESG-WARN (fdo#108512)

    igt@gem_exec_suspend@basic-s4-devices:
      fi-icl-u2:          PASS -> DMESG-WARN (fdo#108070, fdo#107732) +1

    igt@gem_flink_basic@flink-lifetime:
      fi-icl-u2:          PASS -> DMESG-WARN (fdo#107732) +8

    igt@kms_flip@basic-flip-vs-dpms:
      fi-skl-6700hq:      PASS -> DMESG-WARN (fdo#105998)

    igt@kms_flip@basic-plain-flip:
      fi-ilk-650:         PASS -> DMESG-WARN (fdo#106387)

    igt@kms_frontbuffer_tracking@basic:
      fi-byt-clapper:     PASS -> FAIL (fdo#103167)

    
    ==== Possible fixes ====

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-b:
      fi-byt-clapper:     FAIL (fdo#107362) -> PASS

    
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#105998 https://bugs.freedesktop.org/show_bug.cgi?id=105998
  fdo#106387 https://bugs.freedesktop.org/show_bug.cgi?id=106387
  fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
  fdo#107724 https://bugs.freedesktop.org/show_bug.cgi?id=107724
  fdo#107732 https://bugs.freedesktop.org/show_bug.cgi?id=107732
  fdo#108070 https://bugs.freedesktop.org/show_bug.cgi?id=108070
  fdo#108512 https://bugs.freedesktop.org/show_bug.cgi?id=108512


== Participating hosts (41 -> 47) ==

  Additional (10): fi-icl-u fi-skl-guc fi-bdw-gvtdvm fi-glk-dsi fi-gdg-551 fi-pnv-d510 fi-ivb-3520m fi-kbl-7560u fi-byt-n2820 fi-snb-2600 
  Missing    (4): fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-ivb-3770 


== Build changes ==

    * IGT: IGT_4684 -> IGTPW_1972

  CI_DRM_5013: 0008b23799728680da3d6d871d46f746a3f69c35 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1972: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1972/
  IGT_4684: 6f27fddc6dd79c0486181b64201c6773c5c42a24 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@kms_content_protection@atomic
+igt@kms_content_protection@legacy

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1972/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-10-22 21:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-22 14:23 [igt-dev] [PATCH i-g-t v4 1/2] lib/debugfs: connector debugfs director Ramalingam C
2018-10-22 14:23 ` [igt-dev] [PATCH i-g-t v4 2/2] kms_content_protection: Add Content Protection test Ramalingam C
2018-10-22 14:56   ` Daniel Vetter
2018-10-22 14:58 ` [igt-dev] [PATCH i-g-t v4 1/2] lib/debugfs: connector debugfs director Chris Wilson
2018-10-22 16:32   ` C, Ramalingam
2018-10-22 21:07 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v4,1/2] " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox