Skip to contentSkip to conversation

test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP

PATCH Superseded Manasi Navare 6 participants 20 messages Oct 5, 2018 – Nov 6, 2018

v1 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP

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 <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +1 -0
index c84933f1..c807aad3 100644
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \
tests/kms_dp_dsc.c new file +372 -0

372 lines not on this page · raw message

Signature · 6 lines
2.18.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP

== Series Details ==

== Series Details ==

Series: test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP
URL : https://patchwork.freedesktop.org/series/50652/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4944 -> IGTPW_1920 =

== Summary - SUCCESS ==

No regressions found.

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

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_module_reload@basic-reload:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106248, fdo#106725)

    igt@kms_flip@basic-flip-vs-modeset:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106000)

    
    ==== Possible fixes ====

    igt@pm_rpm@module-reload:
      fi-glk-j4005:       DMESG-WARN (fdo#107726) -> PASS

    
    ==== Warnings ====

    igt@amdgpu/amd_prime@amd-to-i915:
      fi-kbl-8809g:       FAIL (fdo#107341) -> DMESG-FAIL (fdo#107762)

fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725
fdo#107341 https://bugs.freedesktop.org/show_bug.cgi?id=107341
fdo#107726 https://bugs.freedesktop.org/show_bug.cgi?id=107726
fdo#107762 https://bugs.freedesktop.org/show_bug.cgi?id=107762

== Participating hosts (45 -> 38) ==

Missing (7): fi-ilk-m540 fi-byt-squawks fi-icl-u2 fi-bsw-cyan fi-snb-2520m fi-ctg-p8600 fi-gdg-551

== Build changes ==

* IGT: IGT_4670 -> IGTPW_1920

CI_DRM_4944: 66bd263b99fd264b57432c232756baf95b0a6255 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1920: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1920/
IGT_4670: 7e066794d2ea860f4199fd67549080de17b6b852 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

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

#2 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP

In reply to Manasi Navare
== Series Details ==

== Series Details ==

Series: test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP
URL : https://patchwork.freedesktop.org/series/50652/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4670_full -> IGTPW_1920_full =

== Summary - WARNING ==

Minor unknown changes coming with IGTPW_1920_full need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_1920_full, 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/50652/revisions/1/mbox/

== Possible new issues ==

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

=== IGT changes ===

    ==== Warnings ====

    igt@pm_rc6_residency@rc6-accuracy:
      shard-kbl:          SKIP -> PASS
      shard-snb:          PASS -> SKIP

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_suspend@fence-restore-tiled2untiled:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665)

    igt@gem_eio@in-flight-suspend:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665, fdo#106702)

    igt@gem_exec_bad_domains@conflicting-write-domain:
      shard-kbl:          PASS -> DMESG-WARN (fdo#103558, fdo#105602) +6

    igt@gem_ppgtt@blt-vs-render-ctx0:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665, fdo#106023)

    igt@kms_color@pipe-b-ctm-max:
      shard-apl:          PASS -> DMESG-WARN (fdo#103558, fdo#105602) +43

    igt@kms_cursor_crc@cursor-128x128-suspend:
      shard-glk:          PASS -> FAIL (fdo#103232) +2

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-blt:
      shard-kbl:          PASS -> FAIL (fdo#103167) +1

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-cpu:
      shard-apl:          PASS -> FAIL (fdo#103167) +2

    igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-cpu:
      shard-glk:          PASS -> FAIL (fdo#103167) +5

    igt@kms_plane@plane-position-covered-pipe-a-planes:
      shard-kbl:          PASS -> FAIL (fdo#103166)

    igt@kms_plane_multiple@atomic-pipe-a-tiling-y:
      shard-glk:          PASS -> FAIL (fdo#103166) +4

    igt@kms_plane_multiple@atomic-pipe-c-tiling-y:
      shard-apl:          PASS -> FAIL (fdo#103166)

    
    ==== Possible fixes ====

    igt@kms_available_modes_crc@available_mode_test_crc:
      shard-apl:          FAIL (fdo#106641) -> PASS

    igt@kms_busy@extended-pageflip-hang-newfb-render-a:
      shard-glk:          DMESG-WARN (fdo#107956) -> PASS

    igt@kms_cursor_crc@cursor-128x42-random:
      shard-glk:          FAIL (fdo#103232) -> PASS +1

    igt@kms_cursor_crc@cursor-64x21-random:
      shard-apl:          FAIL (fdo#103232) -> PASS +8

    igt@kms_cursor_crc@cursor-64x21-sliding:
      shard-kbl:          FAIL (fdo#103232) -> PASS

    igt@kms_cursor_crc@cursor-64x64-suspend:
      shard-apl:          FAIL (fdo#103191, fdo#103232) -> PASS

    igt@kms_cursor_legacy@cursorb-vs-flipb-toggle:
      shard-glk:          DMESG-WARN (fdo#105763, fdo#106538) -> PASS +2

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt:
      shard-apl:          FAIL (fdo#103167) -> PASS +5

    igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-blt:
      shard-glk:          FAIL (fdo#103167) -> PASS +2

    igt@kms_plane@pixel-format-pipe-a-planes:
      shard-snb:          FAIL (fdo#107749, fdo#103166) -> PASS

    {igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb}:
      shard-glk:          FAIL (fdo#108145) -> PASS

    igt@kms_plane_multiple@atomic-pipe-c-tiling-yf:
      shard-apl:          FAIL (fdo#103166) -> PASS +5
      shard-kbl:          FAIL (fdo#103166) -> PASS +1

    igt@kms_rotation_crc@primary-rotation-180:
      shard-snb:          FAIL (fdo#103925) -> PASS

    igt@kms_universal_plane@universal-plane-pipe-c-functional:
      shard-glk:          FAIL (fdo#103166) -> PASS +4

    
    ==== Warnings ====

    {igt@kms_plane_alpha_blend@pipe-a-alpha-7efc}:
      shard-apl:          FAIL (fdo#108145) -> DMESG-FAIL (fdo#103558, fdo#105602) +1

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#103232 https://bugs.freedesktop.org/show_bug.cgi?id=103232
fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#105763 https://bugs.freedesktop.org/show_bug.cgi?id=105763
fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
fdo#106538 https://bugs.freedesktop.org/show_bug.cgi?id=106538
fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
fdo#106702 https://bugs.freedesktop.org/show_bug.cgi?id=106702
fdo#107749 https://bugs.freedesktop.org/show_bug.cgi?id=107749
fdo#107956 https://bugs.freedesktop.org/show_bug.cgi?id=107956
fdo#108145 https://bugs.freedesktop.org/show_bug.cgi?id=108145

== Participating hosts (6 -> 5) ==

Missing (1): shard-skl

== Build changes ==

* IGT: IGT_4670 -> IGTPW_1920
* Linux: CI_DRM_4933 -> CI_DRM_4944

CI_DRM_4933: 6b7a44d1597791524f46d7ea17620db54dffdc8c @ git://anongit.freedesktop.org/gfx-ci/linux
CI_DRM_4944: 66bd263b99fd264b57432c232756baf95b0a6255 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1920: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1920/
IGT_4670: 7e066794d2ea860f4199fd67549080de17b6b852 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1920/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw
In reply to Manasi Navare
Quoted 19 lines · Manasi Navare

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 <[email protected]>
---
  tests/Makefile.sources |   1 +
  tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
  2 files changed, 373 insertions(+)

create mode 100644 tests/kms_dp_dsc.c

tests/Makefile.sources +0 -0
index c84933f1..c807aad3 100644

tests/Makefile.sources TESTS_progs = \ · line 210

Quoted 4 lines
tests/Makefile.sources +1 -0
@@ -207,6 +207,7 @@ TESTS_progs = \
  	kms_tv_load_detect \
  	kms_universal_plane \
  	kms_vblank \
+	kms_dp_dsc \

Add test in meson build as well.

Quoted 28 lines
tests/Makefile.sources +0 -0
  	meta_test \
  	perf \
  	perf_pmu \
tests/kms_dp_dsc.c new file +19 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Displayport Display Stream Compression test
+ *
+ * Authors:
+ * Manasi Navare <[email protected]>
+ *
+ * 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>

tests/kms_dp_dsc.c line 29

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+#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;

^ Seems to be used only in one place, why not use the macro directly?

Quoted 29 lines
tests/kms_dp_dsc.c new file +29 -0
+
+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);

tests/kms_dp_dsc.c line 68

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	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);

don't we have something similar in igt_debugfs already (igt_debugfs_read)?

Quoted 70 lines
tests/kms_dp_dsc.c new file +70 -0
+
+	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;
+		}https://jira01.devtools.intel.com/browse/GUC-306
+	}
+
+	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;

tests/kms_dp_dsc.c line 148

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+		}
+
+		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)

Need to free the connector here.

Quoted 67 lines
tests/kms_dp_dsc.c new file +67 -0
+			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,

tests/kms_dp_dsc.c line 225

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+				      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);

Why the sleep before checking the return code?

Quoted 87 lines
tests/kms_dp_dsc.c new file +87 -0
+	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);
+			}

tests/kms_dp_dsc.c line 322

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+		}
+	}
+
+	free(connectors);
+	drmModeFreeResources(resources);
+	return ret;
+}
+
+static int opt_handler(int opt, int opt_index, void *opt_dump)
+{

Why not wrapping all the optional prints in igt_debug so you could re-use the --debug option?

Quoted 29 lines
tests/kms_dp_dsc.c new file +29 -0
+	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();
+

tests/kms_dp_dsc.c line 361

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	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);

'test_config' seems to be an output parameter but it is not used in the test.

tests/kms_dp_dsc.c line 367

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);

'ret' is already checked in the subtest also, this would fail if you don't run the subtest.

Comments mostly from a rapid read. You will still need a proper reviewer for the KMS stuff.

Thanks,
Antonio

tests/kms_dp_dsc.c line 372

Quoted 6 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#13 lore raw
In reply to Manasi Navare
Quoted 60 lines · Manasi Navare

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 <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +1 -0
index c84933f1..c807aad3 100644
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \
tests/kms_dp_dsc.c new file +28 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Displayport Display Stream Compression test
+ *
+ * Authors:
+ * Manasi Navare <[email protected]>
+ *
+ * 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;

tests/kms_dp_dsc.c line 38

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+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;
+};

Can kmstest_connector_config be used to simplify this structure?

Quoted 45 lines
tests/kms_dp_dsc.c new file +45 -0
+
+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)

tests/kms_dp_dsc.c line 93

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -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;
+		}
+	}
+

This function could make use of igt_debugfs_simple_read the way kms_psr does to make it cleaner.

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+	free(line);
+	fclose(dsc_support_fp);
+
+	return supported;
+}
+
+static void set_dp_dsc_enable(bool enable, char *test_connector_name)
+{

tests/kms_dp_dsc.c line 111

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	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);

Can we use igt_sysfs_write here?

Quoted 142 lines
tests/kms_dp_dsc.c new file +142 -0
+	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);

tests/kms_dp_dsc.c line 263

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	if (!resources) {
+		igt_warn("drmModeGetResources failed: %s\n", strerror(errno));
+		return -1;
+	}
+
+	connectors = calloc(resources->count_connectors,
+			    sizeof(struct connector));
+	if (!connectors)
+		return -1;
+

Is it possible to use igt_display_t, followed by igt_display_require in igt_fixture? Or is it way too much overhead in collecting all non-required resources?

Quoted 21 lines
tests/kms_dp_dsc.c new file +21 -0
+	/* 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;

tests/kms_dp_dsc.c line 294

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+			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")) {

Will this code path run?

Quoted 63 lines
tests/kms_dp_dsc.c new file +63 -0
+					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();
+	}

tests/kms_dp_dsc.c line 367

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+
+	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);

Is this assert required?

- Radhakrishna(RK) Sripada

Quoted 12 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}
Signature · 6 lines
2.18.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#14 lore raw
Quoted 325 lines · Radhakrishna Sripada
Quoted 60 lines · Manasi Navare

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 <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +1 -0
index c84933f1..c807aad3 100644
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \
tests/kms_dp_dsc.c new file +28 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Displayport Display Stream Compression test
+ *
+ * Authors:
+ * Manasi Navare <[email protected]>
+ *
+ * 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;

tests/kms_dp_dsc.c line 38

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+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;
+};

Can kmstest_connector_config be used to simplify this structure?

Quoted 45 lines
tests/kms_dp_dsc.c new file +45 -0
+
+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)

tests/kms_dp_dsc.c line 93

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -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;
+		}
+	}
+

This function could make use of igt_debugfs_simple_read the way kms_psr does to make it cleaner.

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+	free(line);
+	fclose(dsc_support_fp);
+
+	return supported;
+}
+
+static void set_dp_dsc_enable(bool enable, char *test_connector_name)
+{

tests/kms_dp_dsc.c line 111

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	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);

Can we use igt_sysfs_write here?

Quoted 142 lines
tests/kms_dp_dsc.c new file +142 -0
+	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);

tests/kms_dp_dsc.c line 263

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	if (!resources) {
+		igt_warn("drmModeGetResources failed: %s\n", strerror(errno));
+		return -1;
+	}
+
+	connectors = calloc(resources->count_connectors,
+			    sizeof(struct connector));
+	if (!connectors)
+		return -1;
+

Is it possible to use igt_display_t, followed by igt_display_require in igt_fixture? Or is it way too much overhead in collecting all non-required resources?

Quoted 24 lines
tests/kms_dp_dsc.c new file +24 -0
+	/* 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) {
Quoted 8 lines

tests/kms_dp_dsc.c line 294

Quoted 7 lines
tests/kms_dp_dsc.c new file +7 -0
+				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")) {

Will this code path run?

Ignore the above comment.

Thanks,
RK

Quoted 84 lines
Quoted 63 lines
tests/kms_dp_dsc.c new file +63 -0
+					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();
+	}

tests/kms_dp_dsc.c line 367

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+
+	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);

Is this assert required?

- Radhakrishna(RK) Sripada

Quoted 8 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}
Signature · 1 line
2.18.0
Quoted 4 lines
Quoted 4 lines

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#4 lore raw
In reply to Antonio Argenziano
Quoted 17 lines · Antonio Argenziano
Quoted 14 lines · Manasi Navare

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 <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
Quoted 11 lines

tests/Makefile.sources TESTS_progs = \ · line 210

Quoted 9 lines
tests/Makefile.sources +1 -0
index c84933f1..c807aad3 100644
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	kms_dp_dsc \

Add test in meson build as well.

But I dont see any kms tests added in meson.build file, is there any other file that adds the test names to meson build?

Quoted 33 lines
Quoted 33 lines
tests/Makefile.sources +0 -0
 	meta_test \
 	perf \
 	perf_pmu \
tests/kms_dp_dsc.c new file +23 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Displayport Display Stream Compression test
+ *
+ * Authors:
+ * Manasi Navare <[email protected]>
+ *
+ * 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>
Quoted 8 lines

tests/kms_dp_dsc.c line 29

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+#include <fcntl.h>
+#include <termios.h>
+
+int drm_fd;
+drmModeRes *resources;
+uint64_t tiling = LOCAL_DRM_FORMAT_MOD_NONE;

^ Seems to be used only in one place, why not use the macro directly?

Hmm, yea I could use the macro directly since I dont think any subtests would change the tiling format.

Quoted 34 lines
Quoted 34 lines
tests/kms_dp_dsc.c new file +33 -0
+
+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];
Quoted 8 lines

tests/kms_dp_dsc.c line 68

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+	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);

don't we have something similar in igt_debugfs already (igt_debugfs_read)?

Hmm, yea I think I could be able to use igt_debugfs_read and pass the buf which will be concatenated str with connector_name/file name Eg: DP-1/i915_dsc_support

But I will still need the below while loop in order to parse the supported and enabled strings. I will play with the igt_debugfs_read and strstr to see if I can get rid of this while loop below.

Quoted 75 lines
Quoted 75 lines
tests/kms_dp_dsc.c new file +74 -0
+
+	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;
+		}https://jira01.devtools.intel.com/browse/GUC-306
+	}
+
+	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,
Quoted 8 lines

tests/kms_dp_dsc.c line 148

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+			 kmstest_connector_status_str(connector->connection),
+			 kmstest_connector_type_str(connector->connector_type),
+			 connector->mmWidth, connector->mmHeight,
+			 connector->count_modes);
+
+		if (!connector->count_modes)

Need to free the connector here.

Yes wil add drmModeFreeConnector(connector); here before continue

Quoted 72 lines
Quoted 72 lines
tests/kms_dp_dsc.c new file +71 -0
+			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);
+
Quoted 8 lines

tests/kms_dp_dsc.c line 225

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+	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);

Why the sleep before checking the return code?

This is so that it displays the requested pattern for few secs before cycling to the next connector so that it can be validated visually.
Makes sense?

Quoted 93 lines
Quoted 93 lines
tests/kms_dp_dsc.c new file +92 -0
+	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);
Quoted 8 lines

tests/kms_dp_dsc.c line 322

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	return ret;
+}
+
+static int opt_handler(int opt, int opt_index, void *opt_dump)
+{

Why not wrapping all the optional prints in igt_debug so you could re-use the --debug option?

You mean instead of igt_info and all connector dump prints have them in igt_debug() ?

Quoted 35 lines
Quoted 35 lines
tests/kms_dp_dsc.c new file +34 -0
+	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();
Quoted 8 lines

tests/kms_dp_dsc.c line 361

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	}
+
+	igt_subtest("force_dsc_enable_basic") {
+		strcpy(test_config.test_name,"force_dsc_enable_basic");
+		ret = update_display(&test_config);

'test_config' seems to be an output parameter but it is not used in the test.

test_config is used in the update_display()

Quoted 10 lines

tests/kms_dp_dsc.c line 367

Quoted 7 lines
tests/kms_dp_dsc.c new file +6 -0
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);

'ret' is already checked in the subtest also, this would fail if you don't run the subtest.

If I dont run the subtest, it will use the initialized value of ret which is 0. It will only fail if update_display returns a negative value.

Manasi

Quoted 7 lines

Comments mostly from a rapid read. You will still need a proper reviewer for the KMS stuff.

Thanks,
Antonio

Quoted 6 lines

tests/kms_dp_dsc.c line 372

Quoted 6 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#15 lore raw
In reply to Radhakrishna Sripada
Quoted 64 lines · Radhakrishna Sripada
Quoted 63 lines · Manasi Navare

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 <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +1 -0
index c84933f1..c807aad3 100644
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \
tests/kms_dp_dsc.c new file +31 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Displayport Display Stream Compression test
+ *
+ * Authors:
+ * Manasi Navare <[email protected]>
+ *
+ * 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 {
Quoted 8 lines

tests/kms_dp_dsc.c line 38

Quoted 7 lines
tests/kms_dp_dsc.c new file +7 -0
+	uint32_t id;
+	int mode_valid;
+	drmModeModeInfo mode;
+	drmModeConnector *connector;
+	drmModeEncoder *encoder;
+	int crtc, pipe;
+};

Can kmstest_connector_config be used to simplify this structure?

Usually what I have seen is that kms_connector_config would be used to obtain the config through the kms helpers and then this local struct variables are assigned things from kms_connector_config.
But i will take a look at if I can simplify and use kms_connector_config directly

Quoted 48 lines
Quoted 48 lines
tests/kms_dp_dsc.c new file +48 -0
+
+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;
Quoted 8 lines

tests/kms_dp_dsc.c line 93

Quoted 7 lines
tests/kms_dp_dsc.c new file +7 -0
+		else
+			igt_fail_on_f(true, "Unknown DSC supported status '%s'\n",
+				      supported_str);
+		break;
+		}
+	}
+

This function could make use of igt_debugfs_simple_read the way kms_psr does to make it cleaner.

I iwll look at the igt_debugfs_read() and see if that can be used.

Quoted 11 lines
Quoted 11 lines
tests/kms_dp_dsc.c new file +11 -0
+	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};
Quoted 8 lines

tests/kms_dp_dsc.c line 111

Quoted 7 lines
tests/kms_dp_dsc.c new file +7 -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);

Can we use igt_sysfs_write here?

But this is not a sysfs node, just a debugfs. Will have to see if there is any igt debugfs wrapper

Quoted 146 lines
Quoted 146 lines
tests/kms_dp_dsc.c new file +146 -0
+	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;
+	}
Quoted 8 lines

tests/kms_dp_dsc.c line 263

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+
+	connectors = calloc(resources->count_connectors,
+			    sizeof(struct connector));
+	if (!connectors)
+		return -1;
+

Is it possible to use igt_display_t, followed by igt_display_require in igt_fixture? Or is it way too much overhead in collecting all non-required resources?

Not sure what you mean here. Are you suggesting removing the update_display() function and using igt_display_init instead? But I am not sure how I can set mode per connector in that case like I am doing in update_display with the for loop

Quoted 98 lines
Quoted 21 lines
tests/kms_dp_dsc.c new file +21 -0
+	/* 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;

tests/kms_dp_dsc.c line 294

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+			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")) {

Will this code path run?

Quoted 66 lines
tests/kms_dp_dsc.c new file +66 -0
+					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");
Quoted 8 lines

tests/kms_dp_dsc.c line 367

Quoted 7 lines
tests/kms_dp_dsc.c new file +7 -0
+		ret = update_display(&test_config);
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);

Is this assert required?

The goal is to use this assert to check the ret value of update display.

Manasi

Quoted 10 lines

- Radhakrishna(RK) Sripada

Quoted 8 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}
Signature · 1 line
2.18.0
Quoted 4 lines
Quoted 4 lines

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#5 lore raw
In reply to Manasi Navare
Quoted 30 lines · Manasi Navare
Quoted 17 lines · Antonio Argenziano
Quoted 14 lines · Manasi Navare

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 <[email protected]>
---
  tests/Makefile.sources |   1 +
  tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
  2 files changed, 373 insertions(+)

create mode 100644 tests/kms_dp_dsc.c

Quoted 11 lines

tests/Makefile.sources TESTS_progs = \ · line 210

Quoted 9 lines
tests/Makefile.sources +1 -0
index c84933f1..c807aad3 100644
@@ -207,6 +207,7 @@ TESTS_progs = \
  	kms_tv_load_detect \
  	kms_universal_plane \
  	kms_vblank \
+	kms_dp_dsc \

Add test in meson build as well.

Quoted 2 lines

But I dont see any kms tests added in meson.build file, is there any other file that adds the test names to meson build?

tests/meson.build does have kms tests in my tree. I think that is the only place with tests.

Quoted 94 lines
Quoted 12 lines
Quoted 11 lines
tests/Makefile.sources +0 -0
  	meta_test \
  	perf \
  	perf_pmu \
tests/kms_dp_dsc.c new file +0 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
Quoted 10 lines

tests/kms_dp_dsc.c line 68

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+	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);

don't we have something similar in igt_debugfs already (igt_debugfs_read)?

Hmm, yea I think I could be able to use igt_debugfs_read and pass the buf which will be concatenated str with connector_name/file name Eg: DP-1/i915_dsc_support

But I will still need the below while loop in order to parse the supported and enabled strings. I will play with the igt_debugfs_read and strstr to see if I can get rid of this while loop below.

Quoted 55 lines
Quoted 55 lines
tests/kms_dp_dsc.c new file +53 -0
+
+	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;
+		}https://jira01.devtools.intel.com/browse/GUC-306
+	}
+
+	free(line);
+	fclose(dsc_support_fp);
+
+	return supported;
+}
+
 
+
+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);
+
Quoted 8 lines

tests/kms_dp_dsc.c line 225

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+	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);

Why the sleep before checking the return code?

Quoted 3 lines

This is so that it displays the requested pattern for few secs before cycling to the next connector so that it can be validated visually.
Makes sense?

How does it fail? Should you wait for user input?

Maybe add a comment for that. Is this test always visually validated? I mean can we skip the sleep in an automated run like CI for instance.

Quoted 103 lines
Quoted 94 lines
Quoted 94 lines
tests/kms_dp_dsc.c new file +92 -0
+	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);
Quoted 8 lines

tests/kms_dp_dsc.c line 322

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	return ret;
+}
+
+static int opt_handler(int opt, int opt_index, void *opt_dump)
+{

Why not wrapping all the optional prints in igt_debug so you could re-use the --debug option?

Quoted 1 line

You mean instead of igt_info and all connector dump prints have them in igt_debug() ?

Something like that or returning a string from the dump functions and pint it into an igt_debug() call.

Quoted 58 lines
Quoted 36 lines
Quoted 36 lines
tests/kms_dp_dsc.c new file +34 -0
+	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();
Quoted 8 lines

tests/kms_dp_dsc.c line 361

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	}
+
+	igt_subtest("force_dsc_enable_basic") {
+		strcpy(test_config.test_name,"force_dsc_enable_basic");
+		ret = update_display(&test_config);

'test_config' seems to be an output parameter but it is not used in the test.

test_config is used in the update_display()

Quoted 10 lines

tests/kms_dp_dsc.c line 367

Quoted 7 lines
tests/kms_dp_dsc.c new file +6 -0
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);

'ret' is already checked in the subtest also, this would fail if you don't run the subtest.

Quoted 2 lines

If I dont run the subtest, it will use the initialized value of ret which is 0. It will only fail if update_display returns a negative value.

Sorry, you are right I misread that. But, it will not be this assert to fire if ret != 0 but the one in the subtest. My point was that this statement seems a bit redundant and could be eliminated.

Antonio

Quoted 10 lines

Manasi

Quoted 7 lines

Comments mostly from a rapid read. You will still need a proper reviewer for the KMS stuff.

Thanks,
Antonio

Quoted 6 lines
Quoted 6 lines

tests/kms_dp_dsc.c line 372

Quoted 6 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#6 lore raw
Quoted 33 lines · Antonio Argenziano
Quoted 30 lines · Manasi Navare
Quoted 28 lines · Antonio Argenziano
Quoted 19 lines · Manasi Navare

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 <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +0 -0
index c84933f1..c807aad3 100644

tests/Makefile.sources TESTS_progs = \ · line 210

Quoted 4 lines
tests/Makefile.sources +1 -0
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	kms_dp_dsc \

Add test in meson build as well.

Quoted 5 lines
Quoted 2 lines

But I dont see any kms tests added in meson.build file, is there any other file that adds the test names to meson build?

tests/meson.build does have kms tests in my tree. I think that is the only place with tests.

Ok got it! Thanks.

Quoted 95 lines
Quoted 95 lines
Quoted 13 lines
Quoted 12 lines
tests/Makefile.sources +0 -0
 	meta_test \
 	perf \
 	perf_pmu \
tests/kms_dp_dsc.c new file +0 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
Quoted 10 lines

tests/kms_dp_dsc.c line 68

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+	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);

don't we have something similar in igt_debugfs already (igt_debugfs_read)?

Hmm, yea I think I could be able to use igt_debugfs_read and pass the buf which will be concatenated str with connector_name/file name Eg: DP-1/i915_dsc_support

But I will still need the below while loop in order to parse the supported and enabled strings. I will play with the igt_debugfs_read and strstr to see if I can get rid of this while loop below.

Quoted 63 lines
Quoted 51 lines
tests/kms_dp_dsc.c new file +49 -0
+
+	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;
+		}https://jira01.devtools.intel.com/browse/GUC-306
+	}
+
+	free(line);
+	fclose(dsc_support_fp);
+
+	return supported;
+}
+
 
+
+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,

tests/kms_dp_dsc.c

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+				      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);

Why the sleep before checking the return code?

Quoted 5 lines
Quoted 3 lines

This is so that it displays the requested pattern for few secs before cycling to the next connector so that it can be validated visually.
Makes sense?

How does it fail? Should you wait for user input?

Actually this will fail if drmModeSetCrtc fails say in cases where DSC could not be enabled and then encoder config will fail.

Quoted 4 lines

Maybe add a comment for that. Is this test always visually validated? I mean can we skip the sleep in an automated run like CI for instance.

Yes I will add a comment for this. And yes the DSC output will always need visual validation in terms of corruption etc. But its a good idea to skip the sleep in case of CI. Is there a way to conditionall add sleep or skip sleep()?

Manasi

Quoted 185 lines
Quoted 103 lines
Quoted 94 lines
Quoted 94 lines
tests/kms_dp_dsc.c new file +92 -0
+	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);
Quoted 8 lines

tests/kms_dp_dsc.c line 322

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	return ret;
+}
+
+static int opt_handler(int opt, int opt_index, void *opt_dump)
+{

Why not wrapping all the optional prints in igt_debug so you could re-use the --debug option?

Quoted 1 line

You mean instead of igt_info and all connector dump prints have them in igt_debug() ?

Something like that or returning a string from the dump functions and pint it into an igt_debug() call.

Quoted 58 lines
Quoted 36 lines
Quoted 36 lines
tests/kms_dp_dsc.c new file +34 -0
+	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();
Quoted 8 lines

tests/kms_dp_dsc.c line 361

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	}
+
+	igt_subtest("force_dsc_enable_basic") {
+		strcpy(test_config.test_name,"force_dsc_enable_basic");
+		ret = update_display(&test_config);

'test_config' seems to be an output parameter but it is not used in the test.

test_config is used in the update_display()

Quoted 10 lines

tests/kms_dp_dsc.c line 367

Quoted 7 lines
tests/kms_dp_dsc.c new file +6 -0
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);

'ret' is already checked in the subtest also, this would fail if you don't run the subtest.

Quoted 2 lines

If I dont run the subtest, it will use the initialized value of ret which is 0. It will only fail if update_display returns a negative value.

Sorry, you are right I misread that. But, it will not be this assert to fire if ret != 0 but the one in the subtest. My point was that this statement seems a bit redundant and could be eliminated.

Antonio

Quoted 10 lines

Manasi

Quoted 7 lines

Comments mostly from a rapid read. You will still need a proper reviewer for the KMS stuff.

Thanks,
Antonio

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

tests/kms_dp_dsc.c line 372

Quoted 6 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#9 lore raw
In reply to Antonio Argenziano
Quoted 10 lines · Antonio Argenziano
Quoted 10 lines
Quoted 9 lines

tests/kms_dp_dsc.c line 367

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);

'ret' is already checked in the subtest also, this would fail if you don't run the subtest.

Quoted 6 lines
Quoted 2 lines

If I dont run the subtest, it will use the initialized value of ret which is 0. It will only fail if update_display returns a negative value.

Sorry, you are right I misread that. But, it will not be this assert to fire if ret != 0 but the one in the subtest. My point was that this statement seems a bit redundant and could be eliminated.

It's not only redundant, it's invalid to call igt_assert when not inside an igt_fixture or a subtest. See lib/igt_core.c:1180, igt_can_fail().

Signature · 5 lines
Petri Latvala
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#10 lore raw
Quoted 14 lines · Petri Latvala
Quoted 13 lines · Antonio Argenziano
Quoted 12 lines
Quoted 9 lines

tests/kms_dp_dsc.c line 367

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);

'ret' is already checked in the subtest also, this would fail if you don't run the subtest.

If I dont run the subtest, it will use the initialized value of ret which is 0. It will only fail if update_display returns a negative value.

Quoted 8 lines
Quoted 3 lines

Sorry, you are right I misread that. But, it will not be this assert to fire if ret != 0 but the one in the subtest. My point was that this statement seems a bit redundant and could be eliminated.

It's not only redundant, it's invalid to call igt_assert when not inside an igt_fixture or a subtest. See lib/igt_core.c:1180, igt_can_fail().

Thanks Antonio and Petri for pointing this out.
I will remove the igt_assert from there. The igt_fixture() should already take care of having that after the test right? So I dont need to call it explicitly in igt_fixture()

Manasi

Quoted 4 lines
Signature · 2 lines
-- 
Petri Latvala

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#11 lore raw
Quoted 19 lines · Manasi Navare
Quoted 18 lines · Petri Latvala
Quoted 16 lines · Antonio Argenziano
Quoted 10 lines
Quoted 9 lines

tests/kms_dp_dsc.c line 367

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);

'ret' is already checked in the subtest also, this would fail if you don't run the subtest.

Quoted 2 lines

If I dont run the subtest, it will use the initialized value of ret which is 0. It will only fail if update_display returns a negative value.

Sorry, you are right I misread that. But, it will not be this assert to fire if ret != 0 but the one in the subtest. My point was that this statement seems a bit redundant and could be eliminated.

Quoted 8 lines
Quoted 4 lines

It's not only redundant, it's invalid to call igt_assert when not inside an igt_fixture or a subtest. See lib/igt_core.c:1180, igt_can_fail().

Thanks Antonio and Petri for pointing this out.
I will remove the igt_assert from there. The igt_fixture() should already take care of having that after the test right? So I dont need to call it explicitly in igt_fixture()

You want to call asserts mainly inside the test itself, close(drm_fd) should probably go in a fixture at the end to avoid calling it when listing subtests only.

Antonio

Quoted 6 lines

Manasi

Quoted 4 lines
Signature · 2 lines
-- 
Petri Latvala

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#7 lore raw
In reply to Manasi Navare
Quoted 147 lines · Manasi Navare
Quoted 33 lines · Antonio Argenziano
Quoted 30 lines · Manasi Navare
Quoted 28 lines · Antonio Argenziano
Quoted 19 lines · Manasi Navare

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 <[email protected]>
---
  tests/Makefile.sources |   1 +
  tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
  2 files changed, 373 insertions(+)

create mode 100644 tests/kms_dp_dsc.c

tests/Makefile.sources +0 -0
index c84933f1..c807aad3 100644

tests/Makefile.sources TESTS_progs = \ · line 210

Quoted 4 lines
tests/Makefile.sources +1 -0
@@ -207,6 +207,7 @@ TESTS_progs = \
  	kms_tv_load_detect \
  	kms_universal_plane \
  	kms_vblank \
+	kms_dp_dsc \

Add test in meson build as well.

Quoted 5 lines
Quoted 2 lines

But I dont see any kms tests added in meson.build file, is there any other file that adds the test names to meson build?

tests/meson.build does have kms tests in my tree. I think that is the only place with tests.

Ok got it! Thanks.

Quoted 95 lines
Quoted 95 lines
Quoted 13 lines
Quoted 12 lines
tests/Makefile.sources +0 -0
  	meta_test \
  	perf \
  	perf_pmu \
tests/kms_dp_dsc.c new file +0 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
Quoted 10 lines

tests/kms_dp_dsc.c line 68

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+	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);

don't we have something similar in igt_debugfs already (igt_debugfs_read)?

Hmm, yea I think I could be able to use igt_debugfs_read and pass the buf which will be concatenated str with connector_name/file name Eg: DP-1/i915_dsc_support

But I will still need the below while loop in order to parse the supported and enabled strings. I will play with the igt_debugfs_read and strstr to see if I can get rid of this while loop below.

Quoted 63 lines
Quoted 51 lines
tests/kms_dp_dsc.c new file +49 -0
+
+	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;
+		}https://jira01.devtools.intel.com/browse/GUC-306
+	}
+
+	free(line);
+	fclose(dsc_support_fp);
+
+	return supported;
+}
+
 
+
+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,

tests/kms_dp_dsc.c

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+				      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);

Why the sleep before checking the return code?

Quoted 5 lines
Quoted 3 lines

This is so that it displays the requested pattern for few secs before cycling to the next connector so that it can be validated visually.
Makes sense?

How does it fail? Should you wait for user input?

Actually this will fail if drmModeSetCrtc fails say in cases where DSC could not be enabled and then encoder config will fail.

Quoted 1 line
Quoted 6 lines
Quoted 3 lines

Maybe add a comment for that. Is this test always visually validated? I mean can we skip the sleep in an automated run like CI for instance.

Yes I will add a comment for this. And yes the DSC output will always need visual validation in terms of corruption etc. But its a good idea to skip the sleep in case of CI. Is there a way to conditionall add sleep or skip sleep()?

I don't think we have something like that already, a command-line parameter maybe?

Antonio

Quoted 188 lines

Manasi

Quoted 185 lines
Quoted 103 lines
Quoted 94 lines
Quoted 94 lines
tests/kms_dp_dsc.c new file +92 -0
+	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);
Quoted 8 lines

tests/kms_dp_dsc.c line 322

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	return ret;
+}
+
+static int opt_handler(int opt, int opt_index, void *opt_dump)
+{

Why not wrapping all the optional prints in igt_debug so you could re-use the --debug option?

Quoted 1 line

You mean instead of igt_info and all connector dump prints have them in igt_debug() ?

Something like that or returning a string from the dump functions and pint it into an igt_debug() call.

Quoted 58 lines
Quoted 36 lines
Quoted 36 lines
tests/kms_dp_dsc.c new file +34 -0
+	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();
Quoted 8 lines

tests/kms_dp_dsc.c line 361

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	}
+
+	igt_subtest("force_dsc_enable_basic") {
+		strcpy(test_config.test_name,"force_dsc_enable_basic");
+		ret = update_display(&test_config);

'test_config' seems to be an output parameter but it is not used in the test.

test_config is used in the update_display()

Quoted 10 lines

tests/kms_dp_dsc.c line 367

Quoted 7 lines
tests/kms_dp_dsc.c new file +6 -0
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);

'ret' is already checked in the subtest also, this would fail if you don't run the subtest.

Quoted 2 lines

If I dont run the subtest, it will use the initialized value of ret which is 0. It will only fail if update_display returns a negative value.

Sorry, you are right I misread that. But, it will not be this assert to fire if ret != 0 but the one in the subtest. My point was that this statement seems a bit redundant and could be eliminated.

Antonio

Quoted 10 lines

Manasi

Quoted 7 lines

Comments mostly from a rapid read. You will still need a proper reviewer for the KMS stuff.

Thanks,
Antonio

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

tests/kms_dp_dsc.c line 372

Quoted 6 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#12 lore raw
In reply to Antonio Argenziano
Quoted 27 lines · Antonio Argenziano
Quoted 24 lines · Manasi Navare
Quoted 22 lines · Petri Latvala
Quoted 10 lines · Antonio Argenziano
Quoted 10 lines
Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);

'ret' is already checked in the subtest also, this would fail if you don't run the subtest.

Quoted 6 lines
Quoted 2 lines

If I dont run the subtest, it will use the initialized value of ret which is 0. It will only fail if update_display returns a negative value.

Sorry, you are right I misread that. But, it will not be this assert to fire if ret != 0 but the one in the subtest. My point was that this statement seems a bit redundant and could be eliminated.

It's not only redundant, it's invalid to call igt_assert when not inside an igt_fixture or a subtest. See lib/igt_core.c:1180, igt_can_fail().

Quoted 8 lines
Quoted 3 lines

Thanks Antonio and Petri for pointing this out.
I will remove the igt_assert from there. The igt_fixture() should already take care of having that after the test right? So I dont need to call it explicitly in igt_fixture()

You want to call asserts mainly inside the test itself, close(drm_fd) should probably go in a fixture at the end to avoid calling it when listing subtests only.

Ok, got it! So I can call it in update_display which essentially is the test.

Manasi

Quoted 8 lines

Antonio

Quoted 6 lines

Manasi

Quoted 4 lines
Signature · 2 lines
-- 
Petri Latvala

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#8 lore raw
In reply to Antonio Argenziano
Quoted 58 lines · Antonio Argenziano
Quoted 55 lines · Manasi Navare
Quoted 33 lines · Antonio Argenziano
Quoted 30 lines · Manasi Navare
Quoted 28 lines · Antonio Argenziano
Quoted 19 lines · Manasi Navare

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 <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +0 -0
index c84933f1..c807aad3 100644

tests/Makefile.sources TESTS_progs = \ · line 210

Quoted 4 lines
tests/Makefile.sources +1 -0
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	kms_dp_dsc \

Add test in meson build as well.

Quoted 5 lines
Quoted 2 lines

But I dont see any kms tests added in meson.build file, is there any other file that adds the test names to meson build?

tests/meson.build does have kms tests in my tree. I think that is the only place with tests.

Ok got it! Thanks.

Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
tests/Makefile.sources +0 -0
 	meta_test \
 	perf \
 	perf_pmu \
tests/kms_dp_dsc.c new file +0 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

tests/kms_dp_dsc.c line 68

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+	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);

don't we have something similar in igt_debugfs already (igt_debugfs_read)?

I am thinking of replacing the direct fopenat call by igt_debugfs_open() and then still use the file pointer to pass to getline so that i can scan it line by line.

The problem with using the igt_debugfs_read is that then it copies it in a buffer and then scanning line by line becomes difficult. That will be easy if there is a single line.

Does this sound okay?

Manasi

Quoted 281 lines
Quoted 82 lines
Quoted 72 lines
Quoted 72 lines

Hmm, yea I think I could be able to use igt_debugfs_read and pass the buf which will be concatenated str with connector_name/file name Eg: DP-1/i915_dsc_support

But I will still need the below while loop in order to parse the supported and enabled strings. I will play with the igt_debugfs_read and strstr to see if I can get rid of this while loop below.

Quoted 63 lines
Quoted 51 lines
tests/kms_dp_dsc.c new file +49 -0
+
+	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;
+		}https://jira01.devtools.intel.com/browse/GUC-306
+	}
+
+	free(line);
+	fclose(dsc_support_fp);
+
+	return supported;
+}
+
 
+
+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,

tests/kms_dp_dsc.c

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+				      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);

Why the sleep before checking the return code?

Quoted 5 lines
Quoted 3 lines

This is so that it displays the requested pattern for few secs before cycling to the next connector so that it can be validated visually.
Makes sense?

How does it fail? Should you wait for user input?

Actually this will fail if drmModeSetCrtc fails say in cases where DSC could not be enabled and then encoder config will fail.

Quoted 1 line
Quoted 6 lines
Quoted 3 lines

Maybe add a comment for that. Is this test always visually validated? I mean can we skip the sleep in an automated run like CI for instance.

Yes I will add a comment for this. And yes the DSC output will always need visual validation in terms of corruption etc. But its a good idea to skip the sleep in case of CI. Is there a way to conditionall add sleep or skip sleep()?

I don't think we have something like that already, a command-line parameter maybe?

Antonio

Quoted 187 lines

Manasi

Quoted 185 lines
Quoted 103 lines
Quoted 94 lines
Quoted 94 lines
tests/kms_dp_dsc.c new file +92 -0
+	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);
Quoted 8 lines

tests/kms_dp_dsc.c line 322

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	return ret;
+}
+
+static int opt_handler(int opt, int opt_index, void *opt_dump)
+{

Why not wrapping all the optional prints in igt_debug so you could re-use the --debug option?

Quoted 1 line

You mean instead of igt_info and all connector dump prints have them in igt_debug() ?

Something like that or returning a string from the dump functions and pint it into an igt_debug() call.

Quoted 58 lines
Quoted 36 lines
Quoted 36 lines
tests/kms_dp_dsc.c new file +34 -0
+	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();
Quoted 8 lines

tests/kms_dp_dsc.c line 361

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	}
+
+	igt_subtest("force_dsc_enable_basic") {
+		strcpy(test_config.test_name,"force_dsc_enable_basic");
+		ret = update_display(&test_config);

'test_config' seems to be an output parameter but it is not used in the test.

test_config is used in the update_display()

Quoted 10 lines

tests/kms_dp_dsc.c line 367

Quoted 7 lines
tests/kms_dp_dsc.c new file +6 -0
+		igt_assert_eq(ret, 0);
+	}
+
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);

'ret' is already checked in the subtest also, this would fail if you don't run the subtest.

Quoted 2 lines

If I dont run the subtest, it will use the initialized value of ret which is 0. It will only fail if update_display returns a negative value.

Sorry, you are right I misread that. But, it will not be this assert to fire if ret != 0 but the one in the subtest. My point was that this statement seems a bit redundant and could be eliminated.

Antonio

Quoted 10 lines

Manasi

Quoted 7 lines

Comments mostly from a rapid read. You will still need a proper reviewer for the KMS stuff.

Thanks,
Antonio

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

tests/kms_dp_dsc.c line 372

Quoted 6 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#16 lore raw
In reply to Manasi Navare
Quoted 92 lines · PDT Manasi Navare

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 <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +1 -0
index c84933f1..c807aad3 100644
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \
tests/kms_dp_dsc.c new file +60 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Displayport Display Stream Compression test
+ *
+ * Authors:
+ * Manasi Navare <[email protected]>
+ *
+ * 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;

tests/kms_dp_dsc.c line 70

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	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) {

This loop looks wasteful.

tests/kms_dp_dsc.c line 77

Quoted 7 lines
tests/kms_dp_dsc.c new file +7 -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;

What is the use of this check? If all that we need to know is whether DSC is supported, just check for "Supported: yes"

tests/kms_dp_dsc.c line 86

Quoted 9 lines
tests/kms_dp_dsc.c new file +9 -0
+			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;

Skip the test here.

tests/kms_dp_dsc.c line 94

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+		else
+			igt_fail_on_f(true, "Unknown DSC supported status '%s'\n",
+				      supported_str);
+		break;
+		}
+	}
+
+	free(line);

You could simplify the logic in this function with igt_debugfs_read() and strstr() There are examples in kms_psr.c, kms_fbt_fbcon etc.

tests/kms_dp_dsc.c line 95

Quoted 1 line
tests/kms_dp_dsc.c new file +1 -0
+	fclose(dsc_support_fp);

Open the file once, cache the fd and close it when you are done with the test.

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	return supported;
+}
+
+static void set_dp_dsc_enable(bool enable, char *test_connector_name)

tests/kms_dp_dsc.c line 110

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+{
+	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);

Should be a lot simpler using sysfs_write(). Again, lib/igt_psr.c has examples.

Quoted 105 lines
tests/kms_dp_dsc.c new file +105 -0
+	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,

tests/kms_dp_dsc.c line 225

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+				      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);

Why? If this for manual testing, please use manual(). There are plenty of examples.

tests/kms_dp_dsc.c line 229

Quoted 4 lines
tests/kms_dp_dsc.c new file +4 -0
+	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));

This can't be a warning, the test should fail if the mode can't be set.

tests/kms_dp_dsc.c line 230

Quoted 1 line
tests/kms_dp_dsc.c new file +1 -0
+		igt_remove_fb(drm_fd, &fb_info);

Read back debugfs to check whether DSC was enabled? I'm can't tell what is being tested here.

tests/kms_dp_dsc.c line 243

Quoted 13 lines
tests/kms_dp_dsc.c new file +13 -0
+
+	}
+
+	return ret;
+}
+
+
+/*
+ * Re-probe connectors and do a modeset with and wihout DSC
+ *
+ * Returns:
+ * 0: On Success
+ * -1: On failure

int is pointless, just use a bool return if the function doesn't make use of error codes.

Quoted 4 lines
tests/kms_dp_dsc.c new file +4 -0
+ */
+static int update_display(struct dsc_config *test_config)
+{
+	struct connector *connectors;

tests/kms_dp_dsc.c line 257

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	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;
+	}

Why hand roll IOCTLs when the IGT library provides a lot of these functionality?

Quoted 27 lines
tests/kms_dp_dsc.c new file +27 -0
+
+	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;

tests/kms_dp_dsc.c line 294

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+			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")) {

Hmm, there is just one subtest, what else could this be?

tests/kms_dp_dsc.c line 305

Quoted 11 lines
tests/kms_dp_dsc.c new file +11 -0
+					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);

ret gets overwritten in the next loop, if set_mode fails, then the test should too.

tests/kms_dp_dsc.c line 306

Quoted 1 line
tests/kms_dp_dsc.c new file +1 -0
+					} else {

skip if the panel does not support DSC and do it inside the support check helper.

Quoted 11 lines
tests/kms_dp_dsc.c new file +11 -0
+						igt_info ("DSC is not supported on %s\n",
+							  conn_buf);
+					}
+				}
+				crtc_idx_mask &= ~(1 << c->pipe);
+			}
+		}
+	}
+
+	free(connectors);
+	drmModeFreeResources(resources);

tests/kms_dp_dsc.c line 327

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	return ret;
+}
+
+static int opt_handler(int opt, int opt_index, void *opt_dump)
+{
+	bool *dump = opt_dump;
+
+	switch (opt) {
+	case 'i':
+		*dump = true;

Don't see much point adding an option, if you really want to dump the full mode, just use igt_debug() and run the test with --debug.

tests/kms_dp_dsc.c line 336

Quoted 9 lines
tests/kms_dp_dsc.c new file +9 -0
+		break;
+	default:
+		igt_assert(0);
+	}
+
+	return 0;
+}
+
+int main(int argc, char *argv[])

Remove dump and switch to igt_main

tests/kms_dp_dsc.c line 348

Quoted 12 lines
tests/kms_dp_dsc.c new file +12 -0
+{
+	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);

This won't be needed either.

tests/kms_dp_dsc.c line 354

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		kmstest_set_vt_graphics_mode();
+		drm_fd = drm_open_driver(DRIVER_ANY);

Missing igt_display_require()

tests/kms_dp_dsc.c line 360

Quoted 7 lines
tests/kms_dp_dsc.c new file +6 -0
+		if (opt_dump)
+			dump_info();
 
+	}
+
+	igt_subtest("force_dsc_enable_basic") {
+		strcpy(test_config.test_name,"force_dsc_enable_basic");

Why?

tests/kms_dp_dsc.c line 364

Quoted 4 lines
tests/kms_dp_dsc.c new file +4 -0
+		ret = update_display(&test_config);
+		igt_assert_eq(ret, 0);
+	}
+

The test doesn't make use of display_init() and display_fini() like other kms tests do, what is the reason?

tests/kms_dp_dsc.c line 372

Quoted 9 lines
tests/kms_dp_dsc.c new file +8 -0
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#17 lore raw

Thanks for the review, following are my comments based on our discussion on Friday:

Quoted 35 lines · Dhinakaran Pandiyan
Quoted 34 lines · PDT Manasi Navare

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 <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 372 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +1 -0
index c84933f1..c807aad3 100644
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \
tests/kms_dp_dsc.c new file +2 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
+/*
+ * Copyright © 2017 Intel Corporation
Quoted 8 lines

tests/kms_dp_dsc.c line 10

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+ *
+ * Displayport Display Stream Compression test
+ *
+ * Authors:
+ * Manasi Navare <[email protected]>
+ *
+ * Elements of the modeset code adapted from David Herrmann's
+ * DRM modeset example

I will add more comments here mainly specifying that since we do not have any wy to validate the quality of compression, we are mainly validating the driver configuration for DSC here.

Quoted 62 lines
Quoted 50 lines
tests/kms_dp_dsc.c new file +50 -0
+ *
+ */
+#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;

tests/kms_dp_dsc.c line 70

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	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) {

This loop looks wasteful.

Quoted 8 lines

tests/kms_dp_dsc.c line 77

Quoted 7 lines
tests/kms_dp_dsc.c new file +7 -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;

What is the use of this check? If all that we need to know is whether DSC is supported, just check for "Supported: yes"

Well the idea was to just ignore Supported value if Enabled is true because that means it was already enabled by default. But our discussion makes me think that if we are just validating the configuration, I can just read Supported here and force DSC and then after modeset, read back the value of Enabled to check that it was enabled. But even in the case where it cannot be enabled, thats just because our platform probably doesnt support the configuration. So its not a test fail really.

May be the real pass fail test would be if its enabled == yes, then disable DSC and enable again and check if it is enabled and test this for all configurations.
What do you think?

Quoted 11 lines

tests/kms_dp_dsc.c line 86

Quoted 10 lines
tests/kms_dp_dsc.c new file +9 -0
+			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;

Skip the test here.

Quoted 11 lines

tests/kms_dp_dsc.c line 94

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+		else
+			igt_fail_on_f(true, "Unknown DSC supported status '%s'\n",
+				      supported_str);
+		break;
+		}
+	}
+
+	free(line);

You could simplify the logic in this function with igt_debugfs_read() and strstr() There are examples in kms_psr.c, kms_fbt_fbcon etc.

Yes will do that, thanks for pointing out.

Quoted 4 lines

tests/kms_dp_dsc.c line 95

Quoted 2 lines
tests/kms_dp_dsc.c new file +1 -0
+	fclose(dsc_support_fp);

Open the file once, cache the fd and close it when you are done with the test.

Ok

Quoted 125 lines
Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	return supported;
+}
+
+static void set_dp_dsc_enable(bool enable, char *test_connector_name)

tests/kms_dp_dsc.c line 110

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+{
+	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);

Should be a lot simpler using sysfs_write(). Again, lib/igt_psr.c has examples.

Quoted 108 lines
tests/kms_dp_dsc.c new file +108 -0
+	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);
Quoted 8 lines

tests/kms_dp_dsc.c line 225

Quoted 7 lines
tests/kms_dp_dsc.c new file +7 -0
+
+	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);

Why? If this for manual testing, please use manual(). There are plenty of examples.

Manual testing for visually testing results of compression since we dont have any CRC ways to check this. But I will probably remove this since it was for my debug purposes and code validation.

Quoted 10 lines

tests/kms_dp_dsc.c line 229

Quoted 5 lines
tests/kms_dp_dsc.c new file +4 -0
+	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));

This can't be a warning, the test should fail if the mode can't be set.

tests/kms_dp_dsc.c line 230

Quoted 1 line
tests/kms_dp_dsc.c new file +1 -0
+		igt_remove_fb(drm_fd, &fb_info);

Read back debugfs to check whether DSC was enabled? I'm can't tell what is being tested here.

Sure can add this for the test strategy of disabling and then enabling, just to validate the driver.

Quoted 15 lines

tests/kms_dp_dsc.c line 243

Quoted 13 lines
tests/kms_dp_dsc.c new file +13 -0
+
+	}
+
+	return ret;
+}
+
+
+/*
+ * Re-probe connectors and do a modeset with and wihout DSC
+ *
+ * Returns:
+ * 0: On Success
+ * -1: On failure

int is pointless, just use a bool return if the function doesn't make use of error codes.

Quoted 16 lines
Quoted 4 lines
tests/kms_dp_dsc.c new file +4 -0
+ */
+static int update_display(struct dsc_config *test_config)
+{
+	struct connector *connectors;

tests/kms_dp_dsc.c line 257

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	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;
+	}

Why hand roll IOCTLs when the IGT library provides a lot of these functionality?

I will take a look at the library functions, but since the DSC enabling logic is inserted per connector it was hard to use igt lib functions.

Quoted 71 lines
Quoted 27 lines
tests/kms_dp_dsc.c new file +27 -0
+
+	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;

tests/kms_dp_dsc.c line 294

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+			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")) {

Hmm, there is just one subtest, what else could this be?

tests/kms_dp_dsc.c line 305

Quoted 11 lines
tests/kms_dp_dsc.c new file +11 -0
+					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);

ret gets overwritten in the next loop, if set_mode fails, then the test should too.

tests/kms_dp_dsc.c line 306

Quoted 1 line
tests/kms_dp_dsc.c new file +1 -0
+					} else {

skip if the panel does not support DSC and do it inside the support check helper.

Quoted 15 lines
tests/kms_dp_dsc.c new file +15 -0
+						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)
Quoted 8 lines

tests/kms_dp_dsc.c line 327

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+{
+	bool *dump = opt_dump;
+
+	switch (opt) {
+	case 'i':
+		*dump = true;

Don't see much point adding an option, if you really want to dump the full mode, just use igt_debug() and run the test with --debug.

Hmm ok will test what --debug dumps and if thats enough.

Quoted 34 lines

tests/kms_dp_dsc.c line 336

Quoted 10 lines
tests/kms_dp_dsc.c new file +9 -0
+		break;
+	default:
+		igt_assert(0);
+	}
+
+	return 0;
+}
+
+int main(int argc, char *argv[])

Remove dump and switch to igt_main

tests/kms_dp_dsc.c line 348

Quoted 12 lines
tests/kms_dp_dsc.c new file +12 -0
+{
+	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);

This won't be needed either.

tests/kms_dp_dsc.c line 354

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		kmstest_set_vt_graphics_mode();
+		drm_fd = drm_open_driver(DRIVER_ANY);

Missing igt_display_require()

Quoted 8 lines

tests/kms_dp_dsc.c line 360

Quoted 7 lines
tests/kms_dp_dsc.c new file +6 -0
+		if (opt_dump)
+			dump_info();
 
+	}
+
+	igt_subtest("force_dsc_enable_basic") {
+		strcpy(test_config.test_name,"force_dsc_enable_basic");

Why?

This is to pass the test name, more tests will be added with diff names.

Manasi

Quoted 5 lines

tests/kms_dp_dsc.c line 364

Quoted 4 lines
tests/kms_dp_dsc.c new file +4 -0
+		ret = update_display(&test_config);
+		igt_assert_eq(ret, 0);
+	}
+

The test doesn't make use of display_init() and display_fini() like other kms tests do, what is the reason?

Quoted 13 lines

tests/kms_dp_dsc.c line 372

Quoted 9 lines
tests/kms_dp_dsc.c new file +8 -0
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#18 lore raw
Quoted 33 lines · Manasi Navare

Thanks for the review, following are my comments based on our discussion on Friday:

Quoted 29 lines · Dhinakaran Pandiyan
Quoted 28 lines · PDT Manasi Navare

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 <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 372
+++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +1 -0
index c84933f1..c807aad3 100644
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \
Quoted 8 lines
Quoted 8 lines

tests/kms_dp_dsc.c line 2

Quoted 8 lines
tests/kms_dp_dsc.c new file +2 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
+/*
+ * Copyright © 2017 Intel Corporation

You might want to fix the date here.

Quoted 8 lines
Quoted 8 lines

tests/kms_dp_dsc.c line 10

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+ *
+ * Displayport Display Stream Compression test
+ *
+ * Authors:
+ * Manasi Navare <[email protected]>
+ *
+ * Elements of the modeset code adapted from David Herrmann's
+ * DRM modeset example

Missing license.

Quoted 92 lines

I will add more comments here mainly specifying that since we do not have any wy to validate
the quality of compression, we are mainly validating the driver configuration for DSC here.

Quoted 64 lines
Quoted 51 lines
tests/kms_dp_dsc.c new file +40 -0
+ *
+ */
+#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)

tests/kms_dp_dsc.c new file +10 -0
+{
+	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;

tests/kms_dp_dsc.c line 70

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	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) {

This loop looks wasteful.

Quoted 12 lines

tests/kms_dp_dsc.c

Quoted 9 lines
tests/kms_dp_dsc.c new file +4 -0
+		char *support, *enabled;
+
+		enabled = strstr(line, "Enabled: ");
+		igt_assert_eq(sscanf(enabled, "Enabled: %s",

enabled_str), 1);

tests/kms_dp_dsc.c new file +2 -0
+		if (strcmp(enabled_str, "yes") == 0) {
+			igt_info("DSC is enabled on %s\n",

test_connector_name);

tests/kms_dp_dsc.c new file +1 -0
+			supported = true;

What is the use of this check? If all that we need to know is whether DSC is supported, just check for "Supported: yes"

Well the idea was to just ignore Supported value if Enabled is true because that means it was already enabled by default.
But our discussion makes me think that if we are just validating the configuration, I can just read Supported here and force DSC and then after modeset, read back the value of Enabled to check that it was enabled. But even in the case where it cannot be enabled, thats just because our platform probably doesnt support the configuration. So its not a test fail really.

Quoted 4 lines

May be the real pass fail test would be if its enabled == yes, then disable DSC and enable again and check if it is enabled and test this for all configurations.
What do you think?

That doesn't tell us much.

If we want to just validate encoder->compute_config(), I'd recommend enumerating a subtest for each valid bpp (based on bspec) and failing the test if the driver does not enable DSC when it is expected to. Related comment below.

But, we should really get a panel in CI that needs DSC for the preferred mode and demonstrate that the mode works because DSC was enabled.

Quoted 253 lines
Quoted 14 lines

tests/kms_dp_dsc.c line 86

Quoted 12 lines
tests/kms_dp_dsc.c new file +5 -0
+			break;
+		} else {
+			getline(&line, &line_size, dsc_support_fp);
+			support = strstr(line, "Supported: ");
+		igt_assert_eq(sscanf(support, "Supported: %s",

supported_str), 1);

tests/kms_dp_dsc.c new file +4 -0
+		if (strcmp(supported_str, "yes") == 0)
+			supported = true;
+		else if (strcmp(supported_str, "no") == 0)
+			supported = false;

Skip the test here.

Quoted 13 lines

tests/kms_dp_dsc.c line 94

Quoted 9 lines
tests/kms_dp_dsc.c new file +2 -0
+		else
+			igt_fail_on_f(true, "Unknown DSC supported

status '%s'\n",

tests/kms_dp_dsc.c new file +6 -0
+				      supported_str);
+		break;
+		}
+	}
+
+	free(line);

You could simplify the logic in this function with igt_debugfs_read() and strstr()
There are examples in kms_psr.c, kms_fbt_fbcon etc.

Yes will do that, thanks for pointing out.

Quoted 6 lines

tests/kms_dp_dsc.c line 95

Quoted 2 lines
tests/kms_dp_dsc.c new file +1 -0
+	fclose(dsc_support_fp);

Open the file once, cache the fd and close it when you are done with the test.

Ok

Quoted 142 lines
Quoted 6 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	return supported;
+}
+
+static void set_dp_dsc_enable(bool enable, char

*test_connector_name)

tests/kms_dp_dsc.c line 110

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+{
+	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);

Should be a lot simpler using sysfs_write(). Again, lib/igt_psr.c has examples.

Quoted 122 lines
tests/kms_dp_dsc.c new file +1 -0
+	igt_info("Setting DSC_ENABLE to %s for %s\n", (enable) ? "true"

: "false", test_connector_name);

tests/kms_dp_dsc.c new file +13 -0
+	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));

tests/kms_dp_dsc.c new file +10 -0
+		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-
Quoted 1 line

connectors[i]);

tests/kms_dp_dsc.c new file +3 -0
+		if (!connector) {
+			igt_warn("could not get connector %i: %s\n",
+				 mode_resources->connectors[i],

strerror(errno));

tests/kms_dp_dsc.c new file +5 -0
+			continue;
+		}
+
+		igt_info("%d\t%d\t%s\t%s\t%dx%d\t\t%d\n",
+			 connector->connector_id, connector-
Quoted 1 line

encoder_id,

tests/kms_dp_dsc.c new file +1 -0
+			 kmstest_connector_status_str(connector-
Quoted 1 line

connection),

tests/kms_dp_dsc.c new file +1 -0
+			 kmstest_connector_type_str(connector-
Quoted 1 line

connector_type),

tests/kms_dp_dsc.c new file +8 -0
+			 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");

tests/kms_dp_dsc.c new file +26 -0
+		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));

tests/kms_dp_dsc.c new file +22 -0
+			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)

tests/kms_dp_dsc.c new file +16 -0
+{
+	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,

tests/kms_dp_dsc.c new file +1 -0
+								  test_

config->depth),

tests/kms_dp_dsc.c new file +3 -0
+				      tiling, &fb_info);
+
+	igt_info("CRTC(%u):[%d]", c->crtc, 0);
Quoted 8 lines

tests/kms_dp_dsc.c line 225

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -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);

Why? If this for manual testing, please use manual(). There are plenty of examples.

Manual testing for visually testing results of compression since we dont have any CRC ways to check this.
But I will probably remove this since it was for my debug purposes and code validation.

Quoted 10 lines

tests/kms_dp_dsc.c line 229

Quoted 6 lines
tests/kms_dp_dsc.c new file +3 -0
+	if (ret < 0) {
+		igt_warn("Failed to set mode (%dx%d@%dHz): %s\n",
+			 test_config->mode_width, test_config-
Quoted 1 line

mode_height,

tests/kms_dp_dsc.c new file +1 -0
+			 c->mode.vrefresh, strerror(errno));

This can't be a warning, the test should fail if the mode can't be set.

Quoted 4 lines

tests/kms_dp_dsc.c line 230

Quoted 1 line
tests/kms_dp_dsc.c new file +1 -0
+		igt_remove_fb(drm_fd, &fb_info);

Read back debugfs to check whether DSC was enabled? I'm can't tell what is being tested here.

Sure can add this for the test strategy of disabling and then enabling, just to validate the driver.

Quoted 27 lines

tests/kms_dp_dsc.c line 243

Quoted 13 lines
tests/kms_dp_dsc.c new file +13 -0
+
+	}
+
+	return ret;
+}
+
+
+/*
+ * Re-probe connectors and do a modeset with and wihout DSC
+ *
+ * Returns:
+ * 0: On Success
+ * -1: On failure

int is pointless, just use a bool return if the function doesn't make use of error codes.

Quoted 10 lines

+ */

tests/kms_dp_dsc.c new file +9 -0
+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);
Quoted 8 lines

tests/kms_dp_dsc.c

Quoted 5 lines
tests/kms_dp_dsc.c new file +2 -0
+	if (!resources) {
+		igt_warn("drmModeGetResources failed: %s\n",

strerror(errno));

tests/kms_dp_dsc.c new file +2 -0
+		return -1;
+	}

Why hand roll IOCTLs when the IGT library provides a lot of these functionality?

I will take a look at the library functions, but since the DSC enabling logic is inserted per connector
it was hard to use igt lib functions.

Quoted 8 lines
Quoted 8 lines

tests/kms_dp_dsc.c line 265

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+
+	connectors = calloc(resources->count_connectors,
+			    sizeof(struct connector));
+	if (!connectors)
+		return -1;
+
+	/* Find any connected displays */
+	for (cnt = 0; cnt < resources->count_connectors; cnt++) {

Separate sub-test for each connector, we want to know which one fails.

Quoted 48 lines
Quoted 48 lines
Quoted 35 lines
tests/kms_dp_dsc.c new file +3 -0
+		struct connector *c = &connectors[cnt];
+		c->id = resources->connectors[cnt];
+		if(!kmstest_get_connector_config(drm_fd, c->id,

crtc_idx_mask,

tests/kms_dp_dsc.c new file +12 -0
+						&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 ||

tests/kms_dp_dsc.c new file +1 -0
+		    c->connector->connector_type ==

DRM_MODE_CONNECTOR_eDP) {

tests/kms_dp_dsc.c new file +2 -0
+
+			if (c->connector->connector_type ==

DRM_MODE_CONNECTOR_eDP)

tests/kms_dp_dsc.c new file +4 -0
+				conn_cnt = ++ edp_cnt;
+			else
+				conn_cnt = ++ dp_cnt;
+			if (c->connector->connection ==

DRM_MODE_CONNECTED) {

tests/kms_dp_dsc.c new file +2 -0
+				sprintf(conn_buf, "%s-%d",
+					kmstest_connector_type_str(c-
Quoted 1 line

connector->connector_type),

tests/kms_dp_dsc.c new file +5 -0
+					conn_cnt);
+				test_config->dsc_supported =
+					get_dp_dsc_support(conn_buf);
+				if (!strcmp(test_config->test_name,
+					    "force_dsc_enable_basic"))
Quoted 1 line

{

Hmm, there is just one subtest, what else could this be?

Quoted 8 lines
tests/kms_dp_dsc.c new file +1 -0
+					if (test_config->dsc_supported) 

{

tests/kms_dp_dsc.c new file +1 -0
+						igt_info ("DSC is

supported on %s\n",

tests/kms_dp_dsc.c new file +2 -0
+							  conn_buf);
+						test_config->mode_width 

= c->mode.hdisplay;

tests/kms_dp_dsc.c new file +1 -0
+						test_config-
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

mode_height = c->mode.vdisplay;

tests/kms_dp_dsc.c new file +2 -0
+						test_config->bpp = 32;
+						test_config->depth =

24;

Are there other such test configurations for which the kernel is expected to enable DSC? If yes, generate a subtest for each valid combination.

Quoted 91 lines
Quoted 33 lines

tests/kms_dp_dsc.c line 305

Quoted 6 lines
tests/kms_dp_dsc.c new file +1 -0
+						set_dp_dsc_enable(test_

config->dsc_enable,

tests/kms_dp_dsc.c new file +2 -0
+							  conn_buf);
+						ret = set_mode(c,

test_config,

tests/kms_dp_dsc.c new file +1 -0
+							       true);

ret gets overwritten in the next loop, if set_mode fails, then the test should too.

tests/kms_dp_dsc.c

Quoted 1 line
tests/kms_dp_dsc.c new file +1 -0
+					} else {

skip if the panel does not support DSC and do it inside the support check helper.

Quoted 18 lines
tests/kms_dp_dsc.c new file +1 -0
+						igt_info ("DSC is not

supported on %s\n",

tests/kms_dp_dsc.c new file +16 -0
+							  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;
Quoted 8 lines

tests/kms_dp_dsc.c line 327

Quoted 4 lines
tests/kms_dp_dsc.c new file +4 -0
+
+	switch (opt) {
+	case 'i':
+		*dump = true;

Don't see much point adding an option, if you really want to dump the full mode, just use igt_debug()
and run the test with --debug.

Hmm ok will test what --debug dumps and if thats enough.

Quoted 38 lines

tests/kms_dp_dsc.c line 336

Quoted 10 lines
tests/kms_dp_dsc.c new file +9 -0
+		break;
+	default:
+		igt_assert(0);
+	}
+
+	return 0;
+}
+
+int main(int argc, char *argv[])

Remove dump and switch to igt_main

Quoted 13 lines
tests/kms_dp_dsc.c new file +3 -0
+{
+	const char *help_str =
+		"  --info\t\tDump Information about connectors. (still

needs DRM access)\n";

tests/kms_dp_dsc.c new file +8 -0
+	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,

tests/kms_dp_dsc.c line 348

Quoted 1 line
tests/kms_dp_dsc.c new file +1 -0
+				    opt_handler, &opt_dump);

This won't be needed either.

tests/kms_dp_dsc.c line 354

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		kmstest_set_vt_graphics_mode();
+		drm_fd = drm_open_driver(DRIVER_ANY);

Missing igt_display_require()

Quoted 8 lines

tests/kms_dp_dsc.c line 360

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+		if (opt_dump)
+			dump_info();
+	}
+
+	igt_subtest("force_dsc_enable_basic") {
+		strcpy(test_config.test_name,"force_dsc_enable_basic");

Why?

Quoted 3 lines

This is to pass the test name, more tests will be added with diff names.

Let's not add things that are not needed now. Also, please use enums and/or boolean flags to setup the test configuration. That is what IGTs typically do, passing a string and comparing isn't efficient.

Quoted 23 lines

Manasi

Quoted 20 lines

tests/kms_dp_dsc.c line 364

Quoted 4 lines
tests/kms_dp_dsc.c new file +4 -0
+		ret = update_display(&test_config);
+		igt_assert_eq(ret, 0);
+	}
+

The test doesn't make use of display_init() and display_fini() like other kms tests do, what is the reason?

Quoted 9 lines
tests/kms_dp_dsc.c new file +8 -0
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#19 lore raw
Quoted 150 lines · Dhinakaran Pandiyan
Quoted 33 lines · Manasi Navare

Thanks for the review, following are my comments based on our discussion on Friday:

Quoted 29 lines · Dhinakaran Pandiyan
Quoted 28 lines · PDT Manasi Navare

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 <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 372
+++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +1 -0
index c84933f1..c807aad3 100644
@@ -207,6 +207,7 @@ TESTS_progs = \
 	kms_tv_load_detect \
 	kms_universal_plane \
 	kms_vblank \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \
Quoted 8 lines
Quoted 8 lines

tests/kms_dp_dsc.c line 2

Quoted 8 lines
tests/kms_dp_dsc.c new file +2 -0
new file mode 100644
index 00000000..d0fd2ae3
@@ -0,0 +1,372 @@
+/*
+ * Copyright © 2017 Intel Corporation

You might want to fix the date here.

Quoted 8 lines
Quoted 8 lines

tests/kms_dp_dsc.c line 10

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+ *
+ * Displayport Display Stream Compression test
+ *
+ * Authors:
+ * Manasi Navare <[email protected]>
+ *
+ * Elements of the modeset code adapted from David Herrmann's
+ * DRM modeset example

Missing license.

Quoted 92 lines

I will add more comments here mainly specifying that since we do not have any wy to validate
the quality of compression, we are mainly validating the driver configuration for DSC here.

Quoted 64 lines
Quoted 51 lines
tests/kms_dp_dsc.c new file +40 -0
+ *
+ */
+#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)

tests/kms_dp_dsc.c new file +10 -0
+{
+	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;

tests/kms_dp_dsc.c line 70

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	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) {

This loop looks wasteful.

Quoted 12 lines

tests/kms_dp_dsc.c

Quoted 9 lines
tests/kms_dp_dsc.c new file +4 -0
+		char *support, *enabled;
+
+		enabled = strstr(line, "Enabled: ");
+		igt_assert_eq(sscanf(enabled, "Enabled: %s",

enabled_str), 1);

tests/kms_dp_dsc.c new file +2 -0
+		if (strcmp(enabled_str, "yes") == 0) {
+			igt_info("DSC is enabled on %s\n",

test_connector_name);

tests/kms_dp_dsc.c new file +1 -0
+			supported = true;

What is the use of this check? If all that we need to know is whether DSC is supported, just check for "Supported: yes"

Well the idea was to just ignore Supported value if Enabled is true because that means it was already enabled by default.
But our discussion makes me think that if we are just validating the configuration, I can just read Supported here and force DSC and then after modeset, read back the value of Enabled to check that it was enabled. But even in the case where it cannot be enabled, thats just because our platform probably doesnt support the configuration. So its not a test fail really.

Quoted 4 lines

May be the real pass fail test would be if its enabled == yes, then disable DSC and enable again and check if it is enabled and test this for all configurations.
What do you think?

Quoted 6 lines

That doesn't tell us much.

If we want to just validate encoder->compute_config(), I'd recommend enumerating a subtest for each valid bpp (based on bspec) and failing the test if the driver does not enable DSC when it is expected to. Related comment below.

Yes thats why this basic subtest is validating the bpc = 8 or depth = 24. Anusha is working on adding a debugfs node that exposes supported color depths. Then we add a test for each supported color depth.

Quoted 4 lines

But, we should really get a panel in CI that needs DSC for the preferred mode and demonstrate that the mode works because DSC was enabled.

Yes the panel I am using for testing and which I believe is the same that was
shipped to CI needs DSC to work since its perferred mode is 1920 x 1080 @90Hz and
I just checked that it needs DSC by default to output a display, without DSC it will reject the mode and give a modeset failure.
So now in this case, the pass fail would be disable -> enable-> read Enabled bit and if yes then test passed else fail.

Manasi

Quoted 412 lines
Quoted 254 lines
Quoted 15 lines

tests/kms_dp_dsc.c line 86

Quoted 13 lines
tests/kms_dp_dsc.c new file +5 -0
+			break;
+		} else {
+			getline(&line, &line_size, dsc_support_fp);
+			support = strstr(line, "Supported: ");
+		igt_assert_eq(sscanf(support, "Supported: %s",

supported_str), 1);

tests/kms_dp_dsc.c new file +4 -0
+		if (strcmp(supported_str, "yes") == 0)
+			supported = true;
+		else if (strcmp(supported_str, "no") == 0)
+			supported = false;

Skip the test here.

Quoted 13 lines

tests/kms_dp_dsc.c line 94

Quoted 9 lines
tests/kms_dp_dsc.c new file +2 -0
+		else
+			igt_fail_on_f(true, "Unknown DSC supported

status '%s'\n",

tests/kms_dp_dsc.c new file +6 -0
+				      supported_str);
+		break;
+		}
+	}
+
+	free(line);

You could simplify the logic in this function with igt_debugfs_read() and strstr()
There are examples in kms_psr.c, kms_fbt_fbcon etc.

Yes will do that, thanks for pointing out.

Quoted 6 lines

tests/kms_dp_dsc.c line 95

Quoted 2 lines
tests/kms_dp_dsc.c new file +1 -0
+	fclose(dsc_support_fp);

Open the file once, cache the fd and close it when you are done with the test.

Ok

Quoted 142 lines
Quoted 6 lines
tests/kms_dp_dsc.c new file +5 -0
+
+	return supported;
+}
+
+static void set_dp_dsc_enable(bool enable, char

*test_connector_name)

tests/kms_dp_dsc.c line 110

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+{
+	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);

Should be a lot simpler using sysfs_write(). Again, lib/igt_psr.c has examples.

Quoted 122 lines
tests/kms_dp_dsc.c new file +1 -0
+	igt_info("Setting DSC_ENABLE to %s for %s\n", (enable) ? "true"

: "false", test_connector_name);

tests/kms_dp_dsc.c new file +13 -0
+	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));

tests/kms_dp_dsc.c new file +10 -0
+		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-
Quoted 1 line

connectors[i]);

tests/kms_dp_dsc.c new file +3 -0
+		if (!connector) {
+			igt_warn("could not get connector %i: %s\n",
+				 mode_resources->connectors[i],

strerror(errno));

tests/kms_dp_dsc.c new file +5 -0
+			continue;
+		}
+
+		igt_info("%d\t%d\t%s\t%s\t%dx%d\t\t%d\n",
+			 connector->connector_id, connector-
Quoted 1 line

encoder_id,

tests/kms_dp_dsc.c new file +1 -0
+			 kmstest_connector_status_str(connector-
Quoted 1 line

connection),

tests/kms_dp_dsc.c new file +1 -0
+			 kmstest_connector_type_str(connector-
Quoted 1 line

connector_type),

tests/kms_dp_dsc.c new file +8 -0
+			 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");

tests/kms_dp_dsc.c new file +26 -0
+		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));

tests/kms_dp_dsc.c new file +22 -0
+			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)

tests/kms_dp_dsc.c new file +16 -0
+{
+	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,

tests/kms_dp_dsc.c new file +1 -0
+								  test_

config->depth),

tests/kms_dp_dsc.c new file +3 -0
+				      tiling, &fb_info);
+
+	igt_info("CRTC(%u):[%d]", c->crtc, 0);
Quoted 8 lines

tests/kms_dp_dsc.c line 225

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -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);

Why? If this for manual testing, please use manual(). There are plenty of examples.

Manual testing for visually testing results of compression since we dont have any CRC ways to check this.
But I will probably remove this since it was for my debug purposes and code validation.

Quoted 10 lines

tests/kms_dp_dsc.c line 229

Quoted 6 lines
tests/kms_dp_dsc.c new file +3 -0
+	if (ret < 0) {
+		igt_warn("Failed to set mode (%dx%d@%dHz): %s\n",
+			 test_config->mode_width, test_config-
Quoted 1 line

mode_height,

tests/kms_dp_dsc.c new file +1 -0
+			 c->mode.vrefresh, strerror(errno));

This can't be a warning, the test should fail if the mode can't be set.

Quoted 4 lines

tests/kms_dp_dsc.c line 230

Quoted 1 line
tests/kms_dp_dsc.c new file +1 -0
+		igt_remove_fb(drm_fd, &fb_info);

Read back debugfs to check whether DSC was enabled? I'm can't tell what is being tested here.

Sure can add this for the test strategy of disabling and then enabling, just to validate the driver.

Quoted 27 lines

tests/kms_dp_dsc.c line 243

Quoted 13 lines
tests/kms_dp_dsc.c new file +13 -0
+
+	}
+
+	return ret;
+}
+
+
+/*
+ * Re-probe connectors and do a modeset with and wihout DSC
+ *
+ * Returns:
+ * 0: On Success
+ * -1: On failure

int is pointless, just use a bool return if the function doesn't make use of error codes.

Quoted 10 lines

+ */

tests/kms_dp_dsc.c new file +9 -0
+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);
Quoted 8 lines

tests/kms_dp_dsc.c

Quoted 5 lines
tests/kms_dp_dsc.c new file +2 -0
+	if (!resources) {
+		igt_warn("drmModeGetResources failed: %s\n",

strerror(errno));

tests/kms_dp_dsc.c new file +2 -0
+		return -1;
+	}

Why hand roll IOCTLs when the IGT library provides a lot of these functionality?

I will take a look at the library functions, but since the DSC enabling logic is inserted per connector
it was hard to use igt lib functions.

Quoted 8 lines
Quoted 8 lines

tests/kms_dp_dsc.c line 265

Quoted 8 lines
tests/kms_dp_dsc.c new file +8 -0
+
+	connectors = calloc(resources->count_connectors,
+			    sizeof(struct connector));
+	if (!connectors)
+		return -1;
+
+	/* Find any connected displays */
+	for (cnt = 0; cnt < resources->count_connectors; cnt++) {

Separate sub-test for each connector, we want to know which one fails.

Quoted 48 lines
Quoted 48 lines
Quoted 35 lines
tests/kms_dp_dsc.c new file +3 -0
+		struct connector *c = &connectors[cnt];
+		c->id = resources->connectors[cnt];
+		if(!kmstest_get_connector_config(drm_fd, c->id,

crtc_idx_mask,

tests/kms_dp_dsc.c new file +12 -0
+						&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 ||

tests/kms_dp_dsc.c new file +1 -0
+		    c->connector->connector_type ==

DRM_MODE_CONNECTOR_eDP) {

tests/kms_dp_dsc.c new file +2 -0
+
+			if (c->connector->connector_type ==

DRM_MODE_CONNECTOR_eDP)

tests/kms_dp_dsc.c new file +4 -0
+				conn_cnt = ++ edp_cnt;
+			else
+				conn_cnt = ++ dp_cnt;
+			if (c->connector->connection ==

DRM_MODE_CONNECTED) {

tests/kms_dp_dsc.c new file +2 -0
+				sprintf(conn_buf, "%s-%d",
+					kmstest_connector_type_str(c-
Quoted 1 line

connector->connector_type),

tests/kms_dp_dsc.c new file +5 -0
+					conn_cnt);
+				test_config->dsc_supported =
+					get_dp_dsc_support(conn_buf);
+				if (!strcmp(test_config->test_name,
+					    "force_dsc_enable_basic"))
Quoted 1 line

{

Hmm, there is just one subtest, what else could this be?

Quoted 8 lines
tests/kms_dp_dsc.c new file +1 -0
+					if (test_config->dsc_supported) 

{

tests/kms_dp_dsc.c new file +1 -0
+						igt_info ("DSC is

supported on %s\n",

tests/kms_dp_dsc.c new file +2 -0
+							  conn_buf);
+						test_config->mode_width 

= c->mode.hdisplay;

tests/kms_dp_dsc.c new file +1 -0
+						test_config-
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

mode_height = c->mode.vdisplay;

tests/kms_dp_dsc.c new file +2 -0
+						test_config->bpp = 32;
+						test_config->depth =

24;

Are there other such test configurations for which the kernel is expected to enable DSC? If yes, generate a subtest for each valid combination.

Quoted 91 lines
Quoted 33 lines

tests/kms_dp_dsc.c line 305

Quoted 6 lines
tests/kms_dp_dsc.c new file +1 -0
+						set_dp_dsc_enable(test_

config->dsc_enable,

tests/kms_dp_dsc.c new file +2 -0
+							  conn_buf);
+						ret = set_mode(c,

test_config,

tests/kms_dp_dsc.c new file +1 -0
+							       true);

ret gets overwritten in the next loop, if set_mode fails, then the test should too.

tests/kms_dp_dsc.c

Quoted 1 line
tests/kms_dp_dsc.c new file +1 -0
+					} else {

skip if the panel does not support DSC and do it inside the support check helper.

Quoted 18 lines
tests/kms_dp_dsc.c new file +1 -0
+						igt_info ("DSC is not

supported on %s\n",

tests/kms_dp_dsc.c new file +16 -0
+							  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;
Quoted 8 lines

tests/kms_dp_dsc.c line 327

Quoted 4 lines
tests/kms_dp_dsc.c new file +4 -0
+
+	switch (opt) {
+	case 'i':
+		*dump = true;

Don't see much point adding an option, if you really want to dump the full mode, just use igt_debug()
and run the test with --debug.

Hmm ok will test what --debug dumps and if thats enough.

Quoted 46 lines

tests/kms_dp_dsc.c line 336

Quoted 10 lines
tests/kms_dp_dsc.c new file +9 -0
+		break;
+	default:
+		igt_assert(0);
+	}
+
+	return 0;
+}
+
+int main(int argc, char *argv[])

Remove dump and switch to igt_main

Quoted 13 lines
tests/kms_dp_dsc.c new file +3 -0
+{
+	const char *help_str =
+		"  --info\t\tDump Information about connectors. (still

needs DRM access)\n";

tests/kms_dp_dsc.c new file +8 -0
+	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,

tests/kms_dp_dsc.c line 348

Quoted 1 line
tests/kms_dp_dsc.c new file +1 -0
+				    opt_handler, &opt_dump);

This won't be needed either.

tests/kms_dp_dsc.c line 354

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		kmstest_set_vt_graphics_mode();
+		drm_fd = drm_open_driver(DRIVER_ANY);

Missing igt_display_require()

tests/kms_dp_dsc.c line 360

Quoted 6 lines
tests/kms_dp_dsc.c new file +6 -0
+		if (opt_dump)
+			dump_info();
+	}
+
+	igt_subtest("force_dsc_enable_basic") {
+		strcpy(test_config.test_name,"force_dsc_enable_basic");

Why?

Quoted 32 lines
Quoted 3 lines

This is to pass the test name, more tests will be added with diff names.

Let's not add things that are not needed now. Also, please use enums and/or boolean flags to setup the test configuration. That is what IGTs typically do, passing a string and comparing isn't efficient.

Quoted 23 lines

Manasi

Quoted 20 lines

tests/kms_dp_dsc.c line 364

Quoted 4 lines
tests/kms_dp_dsc.c new file +4 -0
+		ret = update_display(&test_config);
+		igt_assert_eq(ret, 0);
+	}
+

The test doesn't make use of display_init() and display_fini() like other kms tests do, what is the reason?

Quoted 9 lines
tests/kms_dp_dsc.c new file +8 -0
+	close(drm_fd);
+
+	igt_assert_eq(ret, 0);
+
+	igt_info("DSC testing done\n");
+	igt_exit();
+
+}

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev