All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP
@ 2018-10-05 23:34 Manasi Navare
  2018-10-06  1:53 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 28+ messages in thread
From: Manasi Navare @ 2018-10-05 23:34 UTC (permalink / raw)
  To: igt-dev; +Cc: Manasi Navare, Anusha Srivatsa

This patch adds a basic kms test to validate the display stream
compression functionality if supported on DP/eDP connector.
Currently this has only one subtest to force the DSC on all
the connectors that support it with default parameters.
This will be expanded to add more subtests to tweak DSC parameters.

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     | 372 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index c84933f1..c807aad3 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	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..d0fd2ae3
--- /dev/null
+++ b/tests/kms_dp_dsc.c
@@ -0,0 +1,372 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Displayport Display Stream Compression test
+ *
+ * Authors:
+ * Manasi Navare <manasi.d.navare@intel.com>
+ *
+ * Elements of the modeset code adapted from David Herrmann's
+ * DRM modeset example
+ *
+ */
+#include "igt.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>
+
+int drm_fd;
+drmModeRes *resources;
+uint64_t tiling = LOCAL_DRM_FORMAT_MOD_NONE;
+
+struct connector {
+	uint32_t id;
+	int mode_valid;
+	drmModeModeInfo mode;
+	drmModeConnector *connector;
+	drmModeEncoder *encoder;
+	int crtc, pipe;
+};
+
+struct dsc_config {
+	char test_name[128];
+	int mode_width;
+	int mode_height;
+	int bpp;
+	int depth;
+	bool dsc_supported;
+	bool dsc_enable;
+};
+
+static FILE *fopenat(int dir, const char *name, const char *mode)
+{
+	int fd = openat(dir, name, O_RDWR);
+	return fdopen(fd, mode);
+}
+
+static bool get_dp_dsc_support(char *test_connector_name)
+{
+	int dir = igt_debugfs_dir(drm_fd);
+	FILE *dsc_support_fp = NULL;
+	char *line = NULL;
+	size_t line_size = 0;
+	char buf[128] = {0}, supported_str[5], enabled_str[5];
+	bool supported = false;
+
+	strcpy(buf, test_connector_name);
+	strcat(buf, "/i915_dsc_support");
+	dsc_support_fp = fopenat(dir, buf, "r");
+	igt_require(dsc_support_fp);
+
+	while (getline(&line, &line_size, dsc_support_fp) > 0) {
+		char *support, *enabled;
+
+		enabled = strstr(line, "Enabled: ");
+		igt_assert_eq(sscanf(enabled, "Enabled: %s", enabled_str), 1);
+		if (strcmp(enabled_str, "yes") == 0) {
+			igt_info("DSC is enabled on %s\n", test_connector_name);
+			supported = true;
+			break;
+		} else {
+			getline(&line, &line_size, dsc_support_fp);
+			support = strstr(line, "Supported: ");
+		igt_assert_eq(sscanf(support, "Supported: %s", supported_str), 1);
+		if (strcmp(supported_str, "yes") == 0)
+			supported = true;
+		else if (strcmp(supported_str, "no") == 0)
+			supported = false;
+		else
+			igt_fail_on_f(true, "Unknown DSC supported status '%s'\n",
+				      supported_str);
+		break;
+		}
+	}
+
+	free(line);
+	fclose(dsc_support_fp);
+
+	return supported;
+}
+
+static void set_dp_dsc_enable(bool enable, char *test_connector_name)
+{
+	int dir = igt_debugfs_dir(drm_fd);
+	FILE *dsc_enable_fp = NULL;
+	char buf[128] = {0};
+
+	strcpy(buf, test_connector_name);
+	strcat(buf, "/i915_dsc_support");
+	dsc_enable_fp = fopenat(dir, buf, "w+");
+	igt_require(dsc_enable_fp);
+	rewind(dsc_enable_fp);
+	igt_info("Setting DSC_ENABLE to %s for %s\n", (enable) ? "true" : "false", test_connector_name);
+	fprintf(dsc_enable_fp, "%d", enable);
+	fflush(dsc_enable_fp);
+	fclose(dsc_enable_fp);
+}
+
+static void dump_connectors_fd(int drmfd)
+{
+	int i, j;
+
+	drmModeRes *mode_resources = drmModeGetResources(drmfd);
+
+        if (!mode_resources) {
+		igt_warn("drmModeGetResources failed: %s\n", strerror(errno));
+		return;
+	}
+
+	igt_info("Connectors:\n");
+	igt_info("id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\n");
+	for (i = 0; i < mode_resources->count_connectors; i++) {
+		drmModeConnector *connector;
+
+		connector = drmModeGetConnectorCurrent(drmfd,
+						       mode_resources->connectors[i]);
+		if (!connector) {
+			igt_warn("could not get connector %i: %s\n",
+				 mode_resources->connectors[i], strerror(errno));
+			continue;
+		}
+
+		igt_info("%d\t%d\t%s\t%s\t%dx%d\t\t%d\n",
+			 connector->connector_id, connector->encoder_id,
+			 kmstest_connector_status_str(connector->connection),
+			 kmstest_connector_type_str(connector->connector_type),
+			 connector->mmWidth, connector->mmHeight,
+			 connector->count_modes);
+
+		if (!connector->count_modes)
+			continue;
+
+		igt_info("  modes:\n");
+		igt_info("  name refresh (Hz) hdisp hss hse htot vdisp ""vss vse vtot flags type clock\n");
+		for (j = 0; j < connector->count_modes; j++){
+			igt_info("[%d]", j);
+			kmstest_dump_mode(&connector->modes[j]);
+		}
+
+		drmModeFreeConnector(connector);
+	}
+	igt_info("\n");
+
+	drmModeFreeResources(mode_resources);
+}
+
+static void dump_crtcs_fd(int drmfd)
+{
+	int i;
+	drmModeRes *mode_resources = drmModeGetResources(drmfd);
+
+	igt_info("CRTCs:\n");
+	igt_info("id\tfb\tpos\tsize\n");
+	for (i = 0; i < mode_resources->count_crtcs; i++) {
+		drmModeCrtc *crtc;
+
+		crtc = drmModeGetCrtc(drmfd, mode_resources->crtcs[i]);
+		if (!crtc) {
+			igt_warn("could not get crtc %i: %s\n",
+				 mode_resources->crtcs[i], strerror(errno));
+			continue;
+		}
+		igt_info("%d\t%d\t(%d,%d)\t(%dx%d)\n",
+			 crtc->crtc_id, crtc->buffer_id, crtc->x,
+			 crtc->y, crtc->width, crtc->height);
+		kmstest_dump_mode(&crtc->mode);
+
+		drmModeFreeCrtc(crtc);
+	}
+	igt_info("\n");
+
+	drmModeFreeResources(mode_resources);
+}
+
+static void dump_info(void)
+{
+	dump_connectors_fd(drm_fd);
+	dump_crtcs_fd(drm_fd);
+}
+
+static int
+set_mode(struct connector *c, struct dsc_config *test_config, bool set_mode)
+{
+	unsigned int fb_id = 0;
+	struct igt_fb fb_info;
+	int ret = 0;
+
+	if (!set_mode) {
+		ret = drmModeSetCrtc(drm_fd, c->crtc, 0, 0, 0,
+				     NULL, 0, NULL);
+		if (ret)
+			igt_warn("Failed to unset mode");
+		return ret;
+	}
+
+	fb_id = igt_create_pattern_fb(drm_fd, test_config->mode_width,
+				      test_config->mode_height,
+				      igt_bpp_depth_to_drm_format(test_config->bpp,
+								  test_config->depth),
+				      tiling, &fb_info);
+
+	igt_info("CRTC(%u):[%d]", c->crtc, 0);
+	kmstest_dump_mode(&c->mode);
+	drmModeSetCrtc(drm_fd, c->crtc, -1, 0, 0, NULL, 0, NULL);
+	ret = drmModeSetCrtc(drm_fd, c->crtc, fb_id, 0, 0,
+			     &c->id, 1, &c->mode);
+	sleep(5);
+	if (ret < 0) {
+		igt_warn("Failed to set mode (%dx%d@%dHz): %s\n",
+			 test_config->mode_width, test_config->mode_height,
+			 c->mode.vrefresh, strerror(errno));
+		igt_remove_fb(drm_fd, &fb_info);
+
+	}
+
+	return ret;
+}
+
+
+/*
+ * Re-probe connectors and do a modeset with and wihout DSC
+ *
+ * Returns:
+ * 0: On Success
+ * -1: On failure
+ */
+static int update_display(struct dsc_config *test_config)
+{
+	struct connector *connectors;
+	struct kmstest_connector_config config;
+	int cnt, conn_cnt = 0, ret = 0, edp_cnt = 0, dp_cnt = 0;
+	unsigned long crtc_idx_mask = -1UL;
+	char conn_buf[128] = {0};
+
+	resources = drmModeGetResources(drm_fd);
+	if (!resources) {
+		igt_warn("drmModeGetResources failed: %s\n", strerror(errno));
+		return -1;
+	}
+
+	connectors = calloc(resources->count_connectors,
+			    sizeof(struct connector));
+	if (!connectors)
+		return -1;
+
+	/* Find any connected displays */
+	for (cnt = 0; cnt < resources->count_connectors; cnt++) {
+		struct connector *c = &connectors[cnt];
+		c->id = resources->connectors[cnt];
+		if(!kmstest_get_connector_config(drm_fd, c->id, crtc_idx_mask,
+						&config)) {
+			c->mode_valid = 0;
+			continue;
+		}
+		c->connector = config.connector;
+		c->encoder = config.encoder;
+		c->mode = config.default_mode;
+		c->crtc = config.crtc->crtc_id;
+		c->pipe = config.pipe;
+		c->mode_valid = 1;
+
+		if (c->connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
+		    c->connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+
+			if (c->connector->connector_type == DRM_MODE_CONNECTOR_eDP)
+				conn_cnt = ++ edp_cnt;
+			else
+				conn_cnt = ++ dp_cnt;
+			if (c->connector->connection == DRM_MODE_CONNECTED) {
+				sprintf(conn_buf, "%s-%d",
+					kmstest_connector_type_str(c->connector->connector_type),
+					conn_cnt);
+				test_config->dsc_supported =
+					get_dp_dsc_support(conn_buf);
+				if (!strcmp(test_config->test_name,
+					    "force_dsc_enable_basic")) {
+					if (test_config->dsc_supported) {
+						igt_info ("DSC is supported on %s\n",
+							  conn_buf);
+						test_config->mode_width = c->mode.hdisplay;
+						test_config->mode_height = c->mode.vdisplay;
+						test_config->bpp = 32;
+						test_config->depth = 24;
+						set_dp_dsc_enable(test_config->dsc_enable,
+							  conn_buf);
+						ret = set_mode(c, test_config,
+							       true);
+					} else {
+						igt_info ("DSC is not supported on %s\n",
+							  conn_buf);
+					}
+				}
+				crtc_idx_mask &= ~(1 << c->pipe);
+			}
+		}
+	}
+
+	free(connectors);
+	drmModeFreeResources(resources);
+	return ret;
+}
+
+static int opt_handler(int opt, int opt_index, void *opt_dump)
+{
+	bool *dump = opt_dump;
+
+	switch (opt) {
+	case 'i':
+		*dump = true;
+		break;
+	default:
+		igt_assert(0);
+	}
+
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	const char *help_str =
+		"  --info\t\tDump Information about connectors. (still needs DRM access)\n";
+	static struct option long_options[] = {
+		{"info", 0, 0, 'i'},
+		{0, 0, 0, 0}
+	};
+	int ret = 0;
+	struct dsc_config test_config;
+	bool opt_dump = false;
+	igt_subtest_init_parse_opts(&argc, argv, "", long_options, help_str,
+				    opt_handler, &opt_dump);
+
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		kmstest_set_vt_graphics_mode();
+		drm_fd = drm_open_driver(DRIVER_ANY);
+		if (opt_dump)
+			dump_info();
+	}
+
+	igt_subtest("force_dsc_enable_basic") {
+		strcpy(test_config.test_name,"force_dsc_enable_basic");
+		ret = update_display(&test_config);
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}
-- 
2.18.0

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread
* [igt-dev] [PATCH i-g-t] test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP
@ 2018-12-13  0:57 Anusha
  2018-12-17 12:00 ` Petri Latvala
  0 siblings, 1 reply; 28+ messages in thread
From: Anusha @ 2018-12-13  0:57 UTC (permalink / raw)
  To: igt-dev
  Cc: Anusha Srivatsa, Petri Latvala, Manasi Navare, Dhinakaran Pandiyan

From: Manasi Navare <manasi.d.navare@intel.com>

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.

v6: (from Anusha)
* Fix run_test() (Petri)
* Fix update_display() to avoid leaks. (Petri)
v5:
* Fix test cleanup to avoid crash (Petri)
v4:
* Future proof for more test types (Petri)
* Fix alphabetical order (Petri)
* s/igt_display_init/igt_display_require (Petri)
* Remove blank lines after return (Petri)
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: 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     | 264 +++++++++++++++++++++++++++++++++++++++++
 tests/meson.build      |   1 +
 3 files changed, 266 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index eedde1e8..a3c24c99 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -54,6 +54,7 @@ TESTS_progs = \
 	kms_crtc_background_color \
 	kms_cursor_crc \
 	kms_cursor_legacy \
+	kms_dp_dsc \
 	kms_draw_crc \
 	kms_fbcon_fbt \
 	kms_fence_pin_leak \
diff --git a/tests/kms_dp_dsc.c b/tests/kms_dp_dsc.c
new file mode 100644
index 00000000..884a7717
--- /dev/null
+++ b/tests/kms_dp_dsc.c
@@ -0,0 +1,264 @@
+/*
+ * 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;
+
+	if (data->output) {
+	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);
+		/* Clear the fb in order to avoid leaks */
+		igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
+		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);
+	} else {
+		igt_assert(!"Unknown test type\n");
+	}
+}
+
+static void run_test(data_t *data, igt_output_t *output,
+		     enum dsc_test_type test_type)
+{
+	enum pipe pipe;
+
+	for_each_pipe_static(pipe) {
+		if (igt_pipe_connector_valid(pipe, output)) {
+			igt_output_set_pipe(output, pipe);
+			data->pipe = pipe;
+			data->output = output;
+			update_display(data, test_type);
+		}
+	}
+}
+
+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 {
+		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_require(&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 b8a6e61b..e14ab2b4 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -25,6 +25,7 @@ test_progs = [
 	'kms_crtc_background_color',
 	'kms_cursor_crc',
 	'kms_cursor_legacy',
+	'kms_dp_dsc',
 	'kms_draw_crc',
 	'kms_fbcon_fbt',
 	'kms_fence_pin_leak',
-- 
2.17.0

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread
* [igt-dev] [PATCH i-g-t] test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP
@ 2018-12-20 19:10 Anusha
  2018-12-21 12:14 ` Petri Latvala
  0 siblings, 1 reply; 28+ messages in thread
From: Anusha @ 2018-12-20 19:10 UTC (permalink / raw)
  To: igt-dev
  Cc: Anusha Srivatsa, Petri Latvala, Manasi Navare, Dhinakaran Pandiyan

From: Manasi Navare <manasi.d.navare@intel.com>

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.

v7: (from Anusha)
* Code Style changes.(Petri)
* Use for_each_pipe() instead of for_each_pipe_static().(Petri)
* Correct logic by avoiding skipping of inner for loop completely.(Petri)
v6: (from Anusha)
* Fix run_test() (Petri)
* Fix update_display() to avoid leaks. (Petri)
v5:
* Fix test cleanup to avoid crash (Petri)
v4:
* Future proof for more test types (Petri)
* Fix alphabetical order (Petri)
* s/igt_display_init/igt_display_require (Petri)
* Remove blank lines after return (Petri)
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: 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     | 266 +++++++++++++++++++++++++++++++++++++++++
 tests/meson.build      |   1 +
 3 files changed, 268 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index eedde1e8..a3c24c99 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -54,6 +54,7 @@ TESTS_progs = \
 	kms_crtc_background_color \
 	kms_cursor_crc \
 	kms_cursor_legacy \
+	kms_dp_dsc \
 	kms_draw_crc \
 	kms_fbcon_fbt \
 	kms_fence_pin_leak \
diff --git a/tests/kms_dp_dsc.c b/tests/kms_dp_dsc.c
new file mode 100644
index 00000000..c9a387ed
--- /dev/null
+++ b/tests/kms_dp_dsc.c
@@ -0,0 +1,266 @@
+/*
+ * 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;
+
+	if (data->output) {
+		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);
+		/* Clear the fb in order to avoid leaks */
+		igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
+		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);
+	} else {
+		igt_assert(!"Unknown test type\n");
+	}
+}
+
+static void run_test(data_t *data, igt_output_t *output,
+		     enum dsc_test_type test_type)
+{
+	enum pipe pipe;
+
+	for_each_pipe(&data->display, pipe) {
+
+		if (igt_pipe_connector_valid(pipe, output)) {
+			igt_output_set_pipe(output, pipe);
+			data->pipe = pipe;
+			data->output = output;
+			update_display(data, test_type);
+		}
+	}
+}
+
+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 {
+		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_require(&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);
+				if(!is_dp_dsc_supported(&data))
+					igt_debug("DSC not supported on connector %s \n",
+						  data.conn_name);
+					break;
+				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 b8a6e61b..e14ab2b4 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -25,6 +25,7 @@ test_progs = [
 	'kms_crtc_background_color',
 	'kms_cursor_crc',
 	'kms_cursor_legacy',
+	'kms_dp_dsc',
 	'kms_draw_crc',
 	'kms_fbcon_fbt',
 	'kms_fence_pin_leak',
-- 
2.19.2

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

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

end of thread, other threads:[~2018-12-21 16:54 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-05 23:34 [igt-dev] [PATCH i-g-t] test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP Manasi Navare
2018-10-06  1:53 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-10-06 10:14 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-10-10 15:48 ` [igt-dev] [PATCH i-g-t] " Antonio Argenziano
2018-10-16 18:47   ` Manasi Navare
2018-10-16 21:14     ` Antonio Argenziano
2018-10-16 21:37       ` Manasi Navare
2018-10-17 20:38         ` Antonio Argenziano
2018-10-26 23:28           ` Manasi Navare
2018-10-17  7:48       ` Petri Latvala
2018-10-17 16:01         ` Manasi Navare
2018-10-17 16:49           ` Antonio Argenziano
2018-10-20  0:06             ` Manasi Navare
2018-10-11 21:21 ` Radhakrishna Sripada
2018-10-12  7:20   ` Radhakrishna Sripada
2018-10-16 19:11   ` Manasi Navare
2018-11-02 22:39 ` Dhinakaran Pandiyan
2018-11-05 20:58   ` Manasi Navare
2018-11-05 23:22     ` Dhinakaran Pandiyan
2018-11-06  0:29       ` Manasi Navare
2018-12-13  0:57 Anusha
2018-12-17 12:00 ` Petri Latvala
2018-12-17 19:44   ` Srivatsa, Anusha
2018-12-18 12:12     ` Petri Latvala
2018-12-20 19:09       ` Srivatsa, Anusha
2018-12-20 19:10 Anusha
2018-12-21 12:14 ` Petri Latvala
2018-12-21 16:57   ` Manasi Navare

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.