[i-g-t,v3] test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP

Submitted by Manasi Navare on Dec. 4, 2018, 3:10 a.m.

Details

Message ID 20181204031051.29182-1-manasi.d.navare@intel.com
State New
Series "test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP"
Headers show

Commit Message

Manasi Navare Dec. 4, 2018, 3:10 a.m.
This patch adds a basic kms test to validate the display stream
compression functionality if supported on DP/eDP connector.
Currently this has only two subtests to force the DSC on all
the eDP and DP connectors that support it with default parameters.
This will be expanded to add more subtests to tweak DSC parameters.

This uses the debugfs nodes added in the patch:
https://patchwork.freedesktop.org/series/53449/

v3:
* Use array of connectors and loop through (Petri)
* Also check for FEC on DP connectors (Manasi)
* Add a Pipe_A restriction on DP (Ville)
v2:
* Use IGT wrappers for all (DK, Antonio)
* Split into two subtests for eDP and DP types (Petri)

Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 261 +++++++++++++++++++++++++++++++++++++++++
 tests/meson.build      |   1 +
 3 files changed, 263 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c

Patch hide | download patch | download mbox

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index d007ebc7..2a5b1c7f 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -88,6 +88,7 @@  TESTS_progs = \
 	kms_universal_plane \
 	kms_vblank \
 	kms_sequence \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \
diff --git a/tests/kms_dp_dsc.c b/tests/kms_dp_dsc.c
new file mode 100644
index 00000000..d2710dde
--- /dev/null
+++ b/tests/kms_dp_dsc.c
@@ -0,0 +1,261 @@ 
+/*
+ * 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.
+ *
+ * Displayport Display Stream Compression test
+ * Until the CRC support is added this needs to be invoked with --interactive
+ * to manually verify if the test pattern is seen without corruption for each
+ * subtest.
+ *
+ * Authors:
+ * Manasi Navare <manasi.d.navare@intel.com>
+ *
+ */
+#include "igt.h"
+#include "igt_sysfs.h"
+#include <errno.h>
+#include <getopt.h>
+#include <math.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <strings.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <time.h>
+#include <fcntl.h>
+#include <termios.h>
+
+enum dsc_test_type
+{
+	test_basic_dsc_enable
+};
+
+typedef struct {
+	int drm_fd;
+	int debugfs_fd;
+	uint32_t id;
+	igt_display_t display;
+	struct igt_fb fb_test_pattern;
+	igt_output_t *output;
+	int mode_valid;
+	drmModeModeInfo *mode;
+	drmModeConnector *connector;
+	drmModeEncoder *encoder;
+	int crtc;
+	enum pipe pipe;
+	char conn_name[128];
+} data_t;
+
+static inline void manual(const char *expected)
+{
+	igt_debug_manual_check("all", expected);
+}
+
+static bool is_dp_dsc_supported(data_t *data)
+{
+	char file_name[128] = {0};
+	char buf[512];
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_require(igt_debugfs_simple_read(data->debugfs_fd, file_name, buf,
+					    sizeof(buf)) > 0);
+	igt_debugfs_read(data->drm_fd, file_name, buf);
+
+	return strstr(buf, "DSC_Sink_Support: yes");
+
+}
+
+static bool is_dp_fec_supported(data_t *data)
+{
+	char file_name[128] = {0};
+	char buf[512];
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debugfs_read(data->drm_fd, file_name, buf);
+
+	return strstr(buf, "FEC_Sink_Support: yes");
+
+}
+
+static bool is_dp_dsc_enabled(data_t *data)
+{
+	char file_name[128] = {0};
+	char buf[512];
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debugfs_read(data->drm_fd, file_name, buf);
+
+	return strstr(buf, "DSC_Enabled: yes");
+
+}
+
+static void force_dp_dsc_enable(data_t *data)
+{
+	char file_name[128] = {0};
+	int ret;
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debug ("Forcing DSC enable on %s\n", data->conn_name);
+	ret = igt_sysfs_write(data->debugfs_fd, file_name, "1", 1);
+	igt_assert_f(ret > 0, "debugfs_write failed");
+}
+
+static void clear_dp_dsc_enable(data_t *data)
+{
+	char file_name[128] = {0};
+	int ret;
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debug ("Clearing DSC enable on %s\n", data->conn_name);
+	ret = igt_sysfs_write(data->debugfs_fd, file_name, "0", 1);
+	igt_assert_f(ret > 0, "debugfs_write failed");
+}
+
+static void test_cleanup(data_t *data) {
+	igt_plane_t *primary;
+
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_display_commit(&data->display);
+
+	igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
+}
+
+
+/*
+ * Re-probe connectors and do a modeset with DSC
+ *
+ */
+static void update_display(data_t *data, enum dsc_test_type test_type)
+{
+	igt_plane_t *primary;
+	data->mode = igt_output_get_mode(data->output);
+	data->connector = data->output->config.connector;
+
+	if (data->connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
+	    data->pipe == PIPE_A) {
+		igt_debug ("DSC not supported on Pipe A on external DP\n");
+		return;
+	}
+
+	if (test_type == test_basic_dsc_enable) {
+		igt_debug ("DSC is supported on %s\n",
+			   data->conn_name);
+		force_dp_dsc_enable(data);
+		igt_create_pattern_fb(data->drm_fd, data->mode->hdisplay,
+				      data->mode->vdisplay,
+				      DRM_FORMAT_XRGB8888,
+				      LOCAL_DRM_FORMAT_MOD_NONE,
+				      &data->fb_test_pattern);
+		primary = igt_output_get_plane_type(data->output,
+						    DRM_PLANE_TYPE_PRIMARY);
+		igt_plane_set_fb(primary, &data->fb_test_pattern);
+		igt_display_commit(&data->display);
+		/* Until we have CRC check support, manually check if RGB test pattern has no corruption */
+		manual ("RGB test pattern without corruption");
+		igt_assert_f(is_dp_dsc_enabled(data),
+			     "Default DSC enable failed on Connector: %s Pipe: %s",
+			     data->conn_name,
+			     kmstest_pipe_name(data->pipe));
+		clear_dp_dsc_enable(data);
+	}
+
+}
+
+static void run_test(data_t *data, igt_output_t *output,
+		     enum dsc_test_type test_type)
+{
+	enum pipe pipe;
+
+	for_each_pipe_with_valid_output(&data->display, pipe, output) {
+		igt_output_set_pipe(output, pipe);
+		data->pipe = pipe;
+		data->output = output;
+		update_display(data, test_basic_dsc_enable);
+	}
+}
+
+igt_main
+{
+	data_t data = {};
+	igt_output_t *output;
+	drmModeRes *res;
+	drmModeConnector *connector;
+	int i, test_conn_cnt, test_cnt;
+	int tests[] = {DRM_MODE_CONNECTOR_eDP, DRM_MODE_CONNECTOR_DisplayPort};
+
+	igt_fixture {
+		igt_skip_on_simulation();
+		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
+		kmstest_set_vt_graphics_mode();
+		igt_display_init(&data.display, data.drm_fd);
+		igt_display_require_output(&data.display);
+		igt_require(res = drmModeGetResources(data.drm_fd));
+	}
+
+	for (test_cnt = 0; test_cnt < ARRAY_SIZE(tests); test_cnt++) {
+
+		igt_subtest_f("basic-dsc-enable-%s",
+			      kmstest_connector_type_str(tests[test_cnt])) {
+			test_conn_cnt = 0;
+			for (i = 0; i < res->count_connectors; i++) {
+				connector = drmModeGetConnectorCurrent(data.drm_fd,
+								       res->connectors[i]);
+				if (connector->connection != DRM_MODE_CONNECTED ||
+				    connector->connector_type !=
+				    tests[test_cnt])
+					continue;
+				test_conn_cnt++;
+				output = igt_output_from_connector(&data.display, connector);
+				sprintf(data.conn_name, "%s-%d",
+					kmstest_connector_type_str(connector->connector_type),
+					test_conn_cnt);
+				igt_require_f(is_dp_dsc_supported(&data),
+					      "DSC not supported on connector %s \n",
+					      data.conn_name);
+				if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort)
+					igt_require_f(is_dp_fec_supported(&data),
+						      "DSC cannot be enabled without FEC on %s\n",
+						      data.conn_name);
+				run_test(&data, output, test_basic_dsc_enable);
+			}
+			test_cleanup(&data);
+			igt_skip_on(test_conn_cnt == 0);
+		}
+	}
+
+	igt_fixture {
+		drmModeFreeConnector(connector);
+		drmModeFreeResources(res);
+		close(data.debugfs_fd);
+		close(data.drm_fd);
+		igt_display_fini(&data.display);
+	}
+	igt_exit();
+}
diff --git a/tests/meson.build b/tests/meson.build
index 3020f798..dde4270c 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -32,6 +32,7 @@  test_progs = [
 	'kms_cursor_crc',
 	'kms_cursor_legacy',
 	'kms_draw_crc',
+	'kms_dp_dsc',
 	'kms_fbcon_fbt',
 	'kms_fence_pin_leak',
 	'kms_flip',

Comments

Petri Latvala Dec. 4, 2018, 11:07 a.m.
On Mon, Dec 03, 2018 at 07:10:51PM -0800, Manasi Navare wrote:
> This patch adds a basic kms test to validate the display stream
> compression functionality if supported on DP/eDP connector.
> Currently this has only two subtests to force the DSC on all
> the eDP and DP connectors that support it with default parameters.
> This will be expanded to add more subtests to tweak DSC parameters.
> 
> This uses the debugfs nodes added in the patch:
> https://patchwork.freedesktop.org/series/53449/
> 
> v3:
> * Use array of connectors and loop through (Petri)
> * Also check for FEC on DP connectors (Manasi)
> * Add a Pipe_A restriction on DP (Ville)
> v2:
> * Use IGT wrappers for all (DK, Antonio)
> * Split into two subtests for eDP and DP types (Petri)
> 
> Cc: Petri Latvala <petri.latvala@intel.com>
> Cc: Antonio Argenziano <antonio.argenziano@intel.com>
> Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> ---
>  tests/Makefile.sources |   1 +
>  tests/kms_dp_dsc.c     | 261 +++++++++++++++++++++++++++++++++++++++++
>  tests/meson.build      |   1 +
>  3 files changed, 263 insertions(+)
>  create mode 100644 tests/kms_dp_dsc.c
> 
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index d007ebc7..2a5b1c7f 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -88,6 +88,7 @@ TESTS_progs = \
>  	kms_universal_plane \
>  	kms_vblank \
>  	kms_sequence \
> +	kms_dp_dsc \
>  	meta_test \
>  	perf \
>  	perf_pmu \

Alphabetically ordered please.


> diff --git a/tests/kms_dp_dsc.c b/tests/kms_dp_dsc.c
> new file mode 100644
> index 00000000..d2710dde
> --- /dev/null
> +++ b/tests/kms_dp_dsc.c
> @@ -0,0 +1,261 @@
> +/*
> + * 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.
> + *
> + * Displayport Display Stream Compression test
> + * Until the CRC support is added this needs to be invoked with --interactive
> + * to manually verify if the test pattern is seen without corruption for each
> + * subtest.
> + *
> + * Authors:
> + * Manasi Navare <manasi.d.navare@intel.com>
> + *
> + */
> +#include "igt.h"
> +#include "igt_sysfs.h"
> +#include <errno.h>
> +#include <getopt.h>
> +#include <math.h>
> +#include <stdint.h>
> +#include <stdbool.h>
> +#include <strings.h>
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <signal.h>
> +#include <time.h>
> +#include <fcntl.h>
> +#include <termios.h>
> +
> +enum dsc_test_type
> +{
> +	test_basic_dsc_enable
> +};
> +
> +typedef struct {
> +	int drm_fd;
> +	int debugfs_fd;
> +	uint32_t id;
> +	igt_display_t display;
> +	struct igt_fb fb_test_pattern;
> +	igt_output_t *output;
> +	int mode_valid;
> +	drmModeModeInfo *mode;
> +	drmModeConnector *connector;
> +	drmModeEncoder *encoder;
> +	int crtc;
> +	enum pipe pipe;
> +	char conn_name[128];
> +} data_t;
> +
> +static inline void manual(const char *expected)
> +{
> +	igt_debug_manual_check("all", expected);
> +}
> +
> +static bool is_dp_dsc_supported(data_t *data)
> +{
> +	char file_name[128] = {0};
> +	char buf[512];
> +
> +	strcpy(file_name, data->conn_name);
> +	strcat(file_name, "/i915_dsc_fec_support");
> +	igt_require(igt_debugfs_simple_read(data->debugfs_fd, file_name, buf,
> +					    sizeof(buf)) > 0);
> +	igt_debugfs_read(data->drm_fd, file_name, buf);
> +
> +	return strstr(buf, "DSC_Sink_Support: yes");
> +
> +}
> +
> +static bool is_dp_fec_supported(data_t *data)
> +{
> +	char file_name[128] = {0};
> +	char buf[512];
> +
> +	strcpy(file_name, data->conn_name);
> +	strcat(file_name, "/i915_dsc_fec_support");
> +	igt_debugfs_read(data->drm_fd, file_name, buf);
> +
> +	return strstr(buf, "FEC_Sink_Support: yes");
> +
> +}
> +
> +static bool is_dp_dsc_enabled(data_t *data)
> +{
> +	char file_name[128] = {0};
> +	char buf[512];
> +
> +	strcpy(file_name, data->conn_name);
> +	strcat(file_name, "/i915_dsc_fec_support");
> +	igt_debugfs_read(data->drm_fd, file_name, buf);
> +
> +	return strstr(buf, "DSC_Enabled: yes");
> +
> +}

Remove extra empty lines after return statements in the above three
functions.


> +
> +static void force_dp_dsc_enable(data_t *data)
> +{
> +	char file_name[128] = {0};
> +	int ret;
> +
> +	strcpy(file_name, data->conn_name);
> +	strcat(file_name, "/i915_dsc_fec_support");
> +	igt_debug ("Forcing DSC enable on %s\n", data->conn_name);
> +	ret = igt_sysfs_write(data->debugfs_fd, file_name, "1", 1);
> +	igt_assert_f(ret > 0, "debugfs_write failed");
> +}
> +
> +static void clear_dp_dsc_enable(data_t *data)
> +{
> +	char file_name[128] = {0};
> +	int ret;
> +
> +	strcpy(file_name, data->conn_name);
> +	strcat(file_name, "/i915_dsc_fec_support");
> +	igt_debug ("Clearing DSC enable on %s\n", data->conn_name);
> +	ret = igt_sysfs_write(data->debugfs_fd, file_name, "0", 1);
> +	igt_assert_f(ret > 0, "debugfs_write failed");
> +}
> +
> +static void test_cleanup(data_t *data) {
> +	igt_plane_t *primary;
> +
> +	primary = igt_output_get_plane_type(data->output,
> +					    DRM_PLANE_TYPE_PRIMARY);
> +	igt_plane_set_fb(primary, NULL);
> +	igt_display_commit(&data->display);
> +
> +	igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
> +}
> +
> +
> +/*
> + * Re-probe connectors and do a modeset with DSC
> + *
> + */
> +static void update_display(data_t *data, enum dsc_test_type test_type)
> +{
> +	igt_plane_t *primary;
> +	data->mode = igt_output_get_mode(data->output);
> +	data->connector = data->output->config.connector;
> +
> +	if (data->connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> +	    data->pipe == PIPE_A) {
> +		igt_debug ("DSC not supported on Pipe A on external DP\n");
> +		return;
> +	}
> +
> +	if (test_type == test_basic_dsc_enable) {
> +		igt_debug ("DSC is supported on %s\n",
> +			   data->conn_name);
> +		force_dp_dsc_enable(data);
> +		igt_create_pattern_fb(data->drm_fd, data->mode->hdisplay,
> +				      data->mode->vdisplay,
> +				      DRM_FORMAT_XRGB8888,
> +				      LOCAL_DRM_FORMAT_MOD_NONE,
> +				      &data->fb_test_pattern);
> +		primary = igt_output_get_plane_type(data->output,
> +						    DRM_PLANE_TYPE_PRIMARY);
> +		igt_plane_set_fb(primary, &data->fb_test_pattern);
> +		igt_display_commit(&data->display);
> +		/* Until we have CRC check support, manually check if RGB test pattern has no corruption */
> +		manual ("RGB test pattern without corruption");
> +		igt_assert_f(is_dp_dsc_enabled(data),
> +			     "Default DSC enable failed on Connector: %s Pipe: %s",
> +			     data->conn_name,
> +			     kmstest_pipe_name(data->pipe));
> +		clear_dp_dsc_enable(data);
> +	}

Can we future-proof this with an

} else {
 igt_assert(!"Unknown test type");
}


> +
> +}
> +
> +static void run_test(data_t *data, igt_output_t *output,
> +		     enum dsc_test_type test_type)
> +{
> +	enum pipe pipe;
> +
> +	for_each_pipe_with_valid_output(&data->display, pipe, output) {
> +		igt_output_set_pipe(output, pipe);
> +		data->pipe = pipe;
> +		data->output = output;
> +		update_display(data, test_basic_dsc_enable);

Should this be passing the test_type parameter instead of hardcoding
test_basic_dsc_enable?


> +	}
> +}
> +
> +igt_main
> +{
> +	data_t data = {};
> +	igt_output_t *output;
> +	drmModeRes *res;
> +	drmModeConnector *connector;
> +	int i, test_conn_cnt, test_cnt;
> +	int tests[] = {DRM_MODE_CONNECTOR_eDP, DRM_MODE_CONNECTOR_DisplayPort};
> +
> +	igt_fixture {
> +		igt_skip_on_simulation();

Remove igt_skip_on_simulation if there's not a good reason for
it. When in doubt, there isn't.


> +		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
> +		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
> +		kmstest_set_vt_graphics_mode();
> +		igt_display_init(&data.display, data.drm_fd);

commit 5105f068f6525f4d863719acf754891442eed254
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Thu Nov 22 10:36:58 2018 +0100

    lib/kms: Drop igt_display_init


You need to change this call to igt_display_require.



> +		igt_display_require_output(&data.display);
> +		igt_require(res = drmModeGetResources(data.drm_fd));
> +	}
> +
> +	for (test_cnt = 0; test_cnt < ARRAY_SIZE(tests); test_cnt++) {
> +
> +		igt_subtest_f("basic-dsc-enable-%s",
> +			      kmstest_connector_type_str(tests[test_cnt])) {
> +			test_conn_cnt = 0;
> +			for (i = 0; i < res->count_connectors; i++) {
> +				connector = drmModeGetConnectorCurrent(data.drm_fd,
> +								       res->connectors[i]);
> +				if (connector->connection != DRM_MODE_CONNECTED ||
> +				    connector->connector_type !=
> +				    tests[test_cnt])
> +					continue;
> +				test_conn_cnt++;
> +				output = igt_output_from_connector(&data.display, connector);
> +				sprintf(data.conn_name, "%s-%d",
> +					kmstest_connector_type_str(connector->connector_type),
> +					test_conn_cnt);
> +				igt_require_f(is_dp_dsc_supported(&data),
> +					      "DSC not supported on connector %s \n",
> +					      data.conn_name);
> +				if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort)
> +					igt_require_f(is_dp_fec_supported(&data),
> +						      "DSC cannot be enabled without FEC on %s\n",
> +						      data.conn_name);
> +				run_test(&data, output, test_basic_dsc_enable);
> +			}
> +			test_cleanup(&data);
> +			igt_skip_on(test_conn_cnt == 0);
> +		}
> +	}
> +
> +	igt_fixture {
> +		drmModeFreeConnector(connector);
> +		drmModeFreeResources(res);
> +		close(data.debugfs_fd);
> +		close(data.drm_fd);
> +		igt_display_fini(&data.display);
> +	}
> +	igt_exit();
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 3020f798..dde4270c 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -32,6 +32,7 @@ test_progs = [
>  	'kms_cursor_crc',
>  	'kms_cursor_legacy',
>  	'kms_draw_crc',
> +	'kms_dp_dsc',
>  	'kms_fbcon_fbt',

Alphabetical ordering off-by-one.
Manasi Navare Dec. 4, 2018, 7:08 p.m.
On Tue, Dec 04, 2018 at 01:07:23PM +0200, Petri Latvala wrote:
> On Mon, Dec 03, 2018 at 07:10:51PM -0800, Manasi Navare wrote:
> > This patch adds a basic kms test to validate the display stream
> > compression functionality if supported on DP/eDP connector.
> > Currently this has only two subtests to force the DSC on all
> > the eDP and DP connectors that support it with default parameters.
> > This will be expanded to add more subtests to tweak DSC parameters.
> > 
> > This uses the debugfs nodes added in the patch:
> > https://patchwork.freedesktop.org/series/53449/
> > 
> > v3:
> > * Use array of connectors and loop through (Petri)
> > * Also check for FEC on DP connectors (Manasi)
> > * Add a Pipe_A restriction on DP (Ville)
> > v2:
> > * Use IGT wrappers for all (DK, Antonio)
> > * Split into two subtests for eDP and DP types (Petri)
> > 
> > Cc: Petri Latvala <petri.latvala@intel.com>
> > Cc: Antonio Argenziano <antonio.argenziano@intel.com>
> > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
> > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > ---
> >  tests/Makefile.sources |   1 +
> >  tests/kms_dp_dsc.c     | 261 +++++++++++++++++++++++++++++++++++++++++
> >  tests/meson.build      |   1 +
> >  3 files changed, 263 insertions(+)
> >  create mode 100644 tests/kms_dp_dsc.c
> > 
> > diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> > index d007ebc7..2a5b1c7f 100644
> > --- a/tests/Makefile.sources
> > +++ b/tests/Makefile.sources
> > @@ -88,6 +88,7 @@ TESTS_progs = \
> >  	kms_universal_plane \
> >  	kms_vblank \
> >  	kms_sequence \
> > +	kms_dp_dsc \
> >  	meta_test \
> >  	perf \
> >  	perf_pmu \
> 
> Alphabetically ordered please.

Yes will fix this ordering and move kms_dp_dsc up

> 
> 
> > diff --git a/tests/kms_dp_dsc.c b/tests/kms_dp_dsc.c
> > new file mode 100644
> > index 00000000..d2710dde
> > --- /dev/null
> > +++ b/tests/kms_dp_dsc.c
> > @@ -0,0 +1,261 @@
> > +/*
> > + * 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.
> > + *
> > + * Displayport Display Stream Compression test
> > + * Until the CRC support is added this needs to be invoked with --interactive
> > + * to manually verify if the test pattern is seen without corruption for each
> > + * subtest.
> > + *
> > + * Authors:
> > + * Manasi Navare <manasi.d.navare@intel.com>
> > + *
> > + */
> > +#include "igt.h"
> > +#include "igt_sysfs.h"
> > +#include <errno.h>
> > +#include <getopt.h>
> > +#include <math.h>
> > +#include <stdint.h>
> > +#include <stdbool.h>
> > +#include <strings.h>
> > +#include <unistd.h>
> > +#include <stdlib.h>
> > +#include <signal.h>
> > +#include <time.h>
> > +#include <fcntl.h>
> > +#include <termios.h>
> > +
> > +enum dsc_test_type
> > +{
> > +	test_basic_dsc_enable
> > +};
> > +
> > +typedef struct {
> > +	int drm_fd;
> > +	int debugfs_fd;
> > +	uint32_t id;
> > +	igt_display_t display;
> > +	struct igt_fb fb_test_pattern;
> > +	igt_output_t *output;
> > +	int mode_valid;
> > +	drmModeModeInfo *mode;
> > +	drmModeConnector *connector;
> > +	drmModeEncoder *encoder;
> > +	int crtc;
> > +	enum pipe pipe;
> > +	char conn_name[128];
> > +} data_t;
> > +
> > +static inline void manual(const char *expected)
> > +{
> > +	igt_debug_manual_check("all", expected);
> > +}
> > +
> > +static bool is_dp_dsc_supported(data_t *data)
> > +{
> > +	char file_name[128] = {0};
> > +	char buf[512];
> > +
> > +	strcpy(file_name, data->conn_name);
> > +	strcat(file_name, "/i915_dsc_fec_support");
> > +	igt_require(igt_debugfs_simple_read(data->debugfs_fd, file_name, buf,
> > +					    sizeof(buf)) > 0);
> > +	igt_debugfs_read(data->drm_fd, file_name, buf);
> > +
> > +	return strstr(buf, "DSC_Sink_Support: yes");
> > +
> > +}
> > +
> > +static bool is_dp_fec_supported(data_t *data)
> > +{
> > +	char file_name[128] = {0};
> > +	char buf[512];
> > +
> > +	strcpy(file_name, data->conn_name);
> > +	strcat(file_name, "/i915_dsc_fec_support");
> > +	igt_debugfs_read(data->drm_fd, file_name, buf);
> > +
> > +	return strstr(buf, "FEC_Sink_Support: yes");
> > +
> > +}
> > +
> > +static bool is_dp_dsc_enabled(data_t *data)
> > +{
> > +	char file_name[128] = {0};
> > +	char buf[512];
> > +
> > +	strcpy(file_name, data->conn_name);
> > +	strcat(file_name, "/i915_dsc_fec_support");
> > +	igt_debugfs_read(data->drm_fd, file_name, buf);
> > +
> > +	return strstr(buf, "DSC_Enabled: yes");
> > +
> > +}
> 
> Remove extra empty lines after return statements in the above three
> functions.

Yes will do

> 
> 
> > +
> > +static void force_dp_dsc_enable(data_t *data)
> > +{
> > +	char file_name[128] = {0};
> > +	int ret;
> > +
> > +	strcpy(file_name, data->conn_name);
> > +	strcat(file_name, "/i915_dsc_fec_support");
> > +	igt_debug ("Forcing DSC enable on %s\n", data->conn_name);
> > +	ret = igt_sysfs_write(data->debugfs_fd, file_name, "1", 1);
> > +	igt_assert_f(ret > 0, "debugfs_write failed");
> > +}
> > +
> > +static void clear_dp_dsc_enable(data_t *data)
> > +{
> > +	char file_name[128] = {0};
> > +	int ret;
> > +
> > +	strcpy(file_name, data->conn_name);
> > +	strcat(file_name, "/i915_dsc_fec_support");
> > +	igt_debug ("Clearing DSC enable on %s\n", data->conn_name);
> > +	ret = igt_sysfs_write(data->debugfs_fd, file_name, "0", 1);
> > +	igt_assert_f(ret > 0, "debugfs_write failed");
> > +}
> > +
> > +static void test_cleanup(data_t *data) {
> > +	igt_plane_t *primary;
> > +
> > +	primary = igt_output_get_plane_type(data->output,
> > +					    DRM_PLANE_TYPE_PRIMARY);
> > +	igt_plane_set_fb(primary, NULL);
> > +	igt_display_commit(&data->display);
> > +
> > +	igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
> > +}
> > +
> > +
> > +/*
> > + * Re-probe connectors and do a modeset with DSC
> > + *
> > + */
> > +static void update_display(data_t *data, enum dsc_test_type test_type)
> > +{
> > +	igt_plane_t *primary;
> > +	data->mode = igt_output_get_mode(data->output);
> > +	data->connector = data->output->config.connector;
> > +
> > +	if (data->connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> > +	    data->pipe == PIPE_A) {
> > +		igt_debug ("DSC not supported on Pipe A on external DP\n");
> > +		return;
> > +	}
> > +
> > +	if (test_type == test_basic_dsc_enable) {
> > +		igt_debug ("DSC is supported on %s\n",
> > +			   data->conn_name);
> > +		force_dp_dsc_enable(data);
> > +		igt_create_pattern_fb(data->drm_fd, data->mode->hdisplay,
> > +				      data->mode->vdisplay,
> > +				      DRM_FORMAT_XRGB8888,
> > +				      LOCAL_DRM_FORMAT_MOD_NONE,
> > +				      &data->fb_test_pattern);
> > +		primary = igt_output_get_plane_type(data->output,
> > +						    DRM_PLANE_TYPE_PRIMARY);
> > +		igt_plane_set_fb(primary, &data->fb_test_pattern);
> > +		igt_display_commit(&data->display);
> > +		/* Until we have CRC check support, manually check if RGB test pattern has no corruption */
> > +		manual ("RGB test pattern without corruption");
> > +		igt_assert_f(is_dp_dsc_enabled(data),
> > +			     "Default DSC enable failed on Connector: %s Pipe: %s",
> > +			     data->conn_name,
> > +			     kmstest_pipe_name(data->pipe));
> > +		clear_dp_dsc_enable(data);
> > +	}
> 
> Can we future-proof this with an
> 
> } else {
>  igt_assert(!"Unknown test type");
> }
>

Yes thats a good idea
 
> 
> > +
> > +}
> > +
> > +static void run_test(data_t *data, igt_output_t *output,
> > +		     enum dsc_test_type test_type)
> > +{
> > +	enum pipe pipe;
> > +
> > +	for_each_pipe_with_valid_output(&data->display, pipe, output) {
> > +		igt_output_set_pipe(output, pipe);
> > +		data->pipe = pipe;
> > +		data->output = output;
> > +		update_display(data, test_basic_dsc_enable);
> 
> Should this be passing the test_type parameter instead of hardcoding
> test_basic_dsc_enable?
>

Oh yes sorry missed this part when I was modularizing the functions
 
> 
> > +	}
> > +}
> > +
> > +igt_main
> > +{
> > +	data_t data = {};
> > +	igt_output_t *output;
> > +	drmModeRes *res;
> > +	drmModeConnector *connector;
> > +	int i, test_conn_cnt, test_cnt;
> > +	int tests[] = {DRM_MODE_CONNECTOR_eDP, DRM_MODE_CONNECTOR_DisplayPort};
> > +
> > +	igt_fixture {
> > +		igt_skip_on_simulation();
> 
> Remove igt_skip_on_simulation if there's not a good reason for
> it. When in doubt, there isn't.

But we cant test the display on simulation so it will have to be skipped.

> 
> 
> > +		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
> > +		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
> > +		kmstest_set_vt_graphics_mode();
> > +		igt_display_init(&data.display, data.drm_fd);
> 
> commit 5105f068f6525f4d863719acf754891442eed254
> Author: Daniel Vetter <daniel.vetter@ffwll.ch>
> Date:   Thu Nov 22 10:36:58 2018 +0100
> 
>     lib/kms: Drop igt_display_init
> 
> 
> You need to change this call to igt_display_require.

Okay will do, do I also need igt_display_require_output() call after this?

> 
> 
> 
> > +		igt_display_require_output(&data.display);
> > +		igt_require(res = drmModeGetResources(data.drm_fd));
> > +	}
> > +
> > +	for (test_cnt = 0; test_cnt < ARRAY_SIZE(tests); test_cnt++) {
> > +
> > +		igt_subtest_f("basic-dsc-enable-%s",
> > +			      kmstest_connector_type_str(tests[test_cnt])) {
> > +			test_conn_cnt = 0;
> > +			for (i = 0; i < res->count_connectors; i++) {
> > +				connector = drmModeGetConnectorCurrent(data.drm_fd,
> > +								       res->connectors[i]);
> > +				if (connector->connection != DRM_MODE_CONNECTED ||
> > +				    connector->connector_type !=
> > +				    tests[test_cnt])
> > +					continue;
> > +				test_conn_cnt++;
> > +				output = igt_output_from_connector(&data.display, connector);
> > +				sprintf(data.conn_name, "%s-%d",
> > +					kmstest_connector_type_str(connector->connector_type),
> > +					test_conn_cnt);
> > +				igt_require_f(is_dp_dsc_supported(&data),
> > +					      "DSC not supported on connector %s \n",
> > +					      data.conn_name);
> > +				if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort)
> > +					igt_require_f(is_dp_fec_supported(&data),
> > +						      "DSC cannot be enabled without FEC on %s\n",
> > +						      data.conn_name);
> > +				run_test(&data, output, test_basic_dsc_enable);
> > +			}
> > +			test_cleanup(&data);
> > +			igt_skip_on(test_conn_cnt == 0);
> > +		}
> > +	}
> > +
> > +	igt_fixture {
> > +		drmModeFreeConnector(connector);
> > +		drmModeFreeResources(res);
> > +		close(data.debugfs_fd);
> > +		close(data.drm_fd);
> > +		igt_display_fini(&data.display);
> > +	}
> > +	igt_exit();
> > +}
> > diff --git a/tests/meson.build b/tests/meson.build
> > index 3020f798..dde4270c 100644
> > --- a/tests/meson.build
> > +++ b/tests/meson.build
> > @@ -32,6 +32,7 @@ test_progs = [
> >  	'kms_cursor_crc',
> >  	'kms_cursor_legacy',
> >  	'kms_draw_crc',
> > +	'kms_dp_dsc',
> >  	'kms_fbcon_fbt',
> 
> Alphabetical ordering off-by-one.

Gotcha, will fix it!
Thanks for the review

Manasi

> 
> 
> 
> 
> -- 
> Petri Latvala