Skip to contentSkip to conversation

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

PATCH Superseded Manasi Navare 3 participants 4 messages Dec 4, 2018 Arm/Amlogic Meson SoC support

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 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 two subtests to force the DSC on all the eDP and DP connectors that support it with default parameters. This will be expanded to add more subtests to tweak DSC parameters.

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

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

Cc Petri Latvala <[email protected]>
Cc Antonio Argenziano <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Anusha Srivatsa <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 261 +++++++++++++++++++++++++++++++++++++++++
 tests/meson.build      |   1 +
 3 files changed, 263 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +1 -0
index d007ebc7..2a5b1c7f 100644
@@ -88,6 +88,7 @@ TESTS_progs = \
 	kms_universal_plane \
 	kms_vblank \
 	kms_sequence \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \
tests/kms_dp_dsc.c new file +261 -0

261 lines not on this page · raw message

tests/meson.build +1 -0
index 3020f798..dde4270c 100644
@@ -32,6 +32,7 @@ test_progs = [
 	'kms_cursor_crc',
 	'kms_cursor_legacy',
 	'kms_draw_crc',
+	'kms_dp_dsc',
 	'kms_fbcon_fbt',
 	'kms_fence_pin_leak',
 	'kms_flip',
Signature · 6 lines
2.19.1

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

[igt-dev] ✗ Fi.CI.BAT: failure for test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP (rev3)

== Series Details ==

== Series Details ==

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

== Summary ==

IGT patchset build failed on latest successful build f7271fe4e12b564c25a44ca76ee82bb5e78601b6 chamelium: Fix analog bridge detection memory leak

[121/459] Linking target lib/tests/igt_subtest_group.
[122/459] Linking target lib/tests/igt_assert.
[123/459] Linking target lib/tests/igt_exit_handler.
[124/459] Linking target lib/tests/igt_hdmi_inject.
[125/459] Linking target lib/tests/igt_can_fail.
[126/459] Linking target lib/tests/igt_can_fail_simple.
[127/459] Linking target lib/tests/igt_no_exit.
[128/459] Linking target lib/tests/igt_no_exit_list_only.
[129/459] Linking target lib/tests/igt_no_subtest.
[130/459] Linking target lib/tests/igt_simple_test_subtests.
[131/459] Linking target lib/tests/igt_timeout.
[132/459] Linking target tests/core_auth.
[133/459] Linking target lib/tests/igt_invalid_subtest_name.
[134/459] Linking target tests/core_get_client_auth.
[135/459] Linking target tests/core_getstats.
[136/459] Linking target tests/core_getclient.
[137/459] Linking target tests/core_getversion.
[138/459] Linking target tests/core_setmaster_vs_auth.
[139/459] Linking target tests/core_prop_blob.
[140/459] Linking target tests/drm_import_export.
[141/459] Linking target tests/debugfs_test.
[142/459] Linking target tests/drm_mm.
[143/459] Linking target tests/kms_3d.
[144/459] Linking target tests/drm_read.
[145/459] Linking target tests/kms_atomic.
[146/459] Linking target tests/kms_addfb_basic.
[147/459] Linking target tests/kms_atomic_interruptible.
[148/459] Linking target tests/kms_atomic_transition.
[149/459] Linking target tests/kms_available_modes_crc.
[150/459] Linking target tests/kms_busy.
[151/459] Linking target tests/kms_ccs.
[152/459] Linking target tests/kms_chv_cursor_fail.
[153/459] Linking target tests/kms_color.
[154/459] Linking target tests/kms_concurrent.
[155/459] Linking target tests/kms_content_protection.
[156/459] Linking target tests/kms_crtc_background_color.
[157/459] Linking target tests/kms_cursor_crc.
[158/459] Linking target tests/kms_cursor_legacy.
[159/459] Linking target tests/kms_fbcon_fbt.
[160/459] Compiling C object 'tests/kms_dp_dsc@exe/kms_dp_dsc.c.o'.
FAILED: tests/kms_dp_dsc@exe/kms_dp_dsc.c.o
ccache cc -Itests/kms_dp_dsc@exe -Itests -I../tests -I. -I../ -I../lib/stubs/syscalls -Ilib -I../lib -I../include/drm-uapi -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/igt/include -I/opt/igt/include/libdrm -I/usr/include/x86_64-linux-gnu -I/usr/include -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/home/cidrm/kernel_headers/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -D_GNU_SOURCE -include config.h -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -pthread -MD -MQ 'tests/kms_dp_dsc@exe/kms_dp_dsc.c.o' -MF 'tests/kms_dp_dsc@exe/kms_dp_dsc.c.o.d' -o 'tests/kms_dp_dsc@exe/kms_dp_dsc.c.o' -c ../tests/kms_dp_dsc.c ../tests/kms_dp_dsc.c: In function ‘__real_main203’:
../tests/kms_dp_dsc.c:217:3: error: implicit declaration of function ‘igt_display_init’; did you mean ‘igt_display_fini’? [-Werror=implicit-function-declaration]
igt_display_init(&data.display, data.drm_fd);
^~~~~~~~~~~~~~~~
igt_display_fini
../tests/kms_dp_dsc.c:217:3: warning: nested extern declaration of ‘igt_display_init’ [-Wnested-externs]
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.

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

#2 lore raw
In reply to Manasi Navare
Quoted 35 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 two subtests to force the DSC on all the eDP and DP connectors that support it with default parameters. This will be expanded to add more subtests to tweak DSC parameters.

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

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

Cc Petri Latvala <[email protected]>
Cc Antonio Argenziano <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Anusha Srivatsa <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 261 +++++++++++++++++++++++++++++++++++++++++
 tests/meson.build      |   1 +
 3 files changed, 263 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
tests/Makefile.sources +0 -0
index d007ebc7..2a5b1c7f 100644

tests/Makefile.sources TESTS_progs = \ · line 94

Quoted 7 lines
tests/Makefile.sources +1 -0
@@ -88,6 +88,7 @@ TESTS_progs = \
 	kms_universal_plane \
 	kms_vblank \
 	kms_sequence \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \

Alphabetically ordered please.

Quoted 108 lines
tests/kms_dp_dsc.c new file +102 -0
new file mode 100644
index 00000000..d2710dde
@@ -0,0 +1,261 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Displayport Display Stream Compression test
+ * Until the CRC support is added this needs to be invoked with --interactive
+ * to manually verify if the test pattern is seen without corruption for each
+ * subtest.
+ *
+ * Authors:
+ * Manasi Navare <[email protected]>
+ *
+ */
+#include "igt.h"
+#include "igt_sysfs.h"
+#include <errno.h>
+#include <getopt.h>
+#include <math.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <strings.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <time.h>
+#include <fcntl.h>
+#include <termios.h>
+
+enum dsc_test_type
+{
+	test_basic_dsc_enable
+};
+
+typedef struct {
+	int drm_fd;
+	int debugfs_fd;
+	uint32_t id;
+	igt_display_t display;
+	struct igt_fb fb_test_pattern;
+	igt_output_t *output;
+	int mode_valid;
+	drmModeModeInfo *mode;
+	drmModeConnector *connector;
+	drmModeEncoder *encoder;
+	int crtc;
+	enum pipe pipe;
+	char conn_name[128];
+} data_t;
+
+static inline void manual(const char *expected)
+{
+	igt_debug_manual_check("all", expected);
+}
+
+static bool is_dp_dsc_supported(data_t *data)
+{
+	char file_name[128] = {0};
+	char buf[512];
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_require(igt_debugfs_simple_read(data->debugfs_fd, file_name, buf,
+					    sizeof(buf)) > 0);
+	igt_debugfs_read(data->drm_fd, file_name, buf);
+
+	return strstr(buf, "DSC_Sink_Support: yes");
+
+}
+
+static bool is_dp_fec_supported(data_t *data)
+{
+	char file_name[128] = {0};
+	char buf[512];
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debugfs_read(data->drm_fd, file_name, buf);
+
+	return strstr(buf, "FEC_Sink_Support: yes");
+
+}
+
+static bool is_dp_dsc_enabled(data_t *data)
+{

tests/kms_dp_dsc.c line 112

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+	char file_name[128] = {0};
+	char buf[512];
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debugfs_read(data->drm_fd, file_name, buf);
+
+	return strstr(buf, "DSC_Enabled: yes");
+
+}

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

Quoted 64 lines
tests/kms_dp_dsc.c new file +64 -0
+
+static void force_dp_dsc_enable(data_t *data)
+{
+	char file_name[128] = {0};
+	int ret;
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debug ("Forcing DSC enable on %s\n", data->conn_name);
+	ret = igt_sysfs_write(data->debugfs_fd, file_name, "1", 1);
+	igt_assert_f(ret > 0, "debugfs_write failed");
+}
+
+static void clear_dp_dsc_enable(data_t *data)
+{
+	char file_name[128] = {0};
+	int ret;
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debug ("Clearing DSC enable on %s\n", data->conn_name);
+	ret = igt_sysfs_write(data->debugfs_fd, file_name, "0", 1);
+	igt_assert_f(ret > 0, "debugfs_write failed");
+}
+
+static void test_cleanup(data_t *data) {
+	igt_plane_t *primary;
+
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_display_commit(&data->display);
+
+	igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
+}
+
+
+/*
+ * Re-probe connectors and do a modeset with DSC
+ *
+ */
+static void update_display(data_t *data, enum dsc_test_type test_type)
+{
+	igt_plane_t *primary;
+	data->mode = igt_output_get_mode(data->output);
+	data->connector = data->output->config.connector;
+
+	if (data->connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
+	    data->pipe == PIPE_A) {
+		igt_debug ("DSC not supported on Pipe A on external DP\n");
+		return;
+	}
+
+	if (test_type == test_basic_dsc_enable) {
+		igt_debug ("DSC is supported on %s\n",
+			   data->conn_name);
+		force_dp_dsc_enable(data);
+		igt_create_pattern_fb(data->drm_fd, data->mode->hdisplay,
+				      data->mode->vdisplay,
+				      DRM_FORMAT_XRGB8888,
+				      LOCAL_DRM_FORMAT_MOD_NONE,
+				      &data->fb_test_pattern);
+		primary = igt_output_get_plane_type(data->output,
+						    DRM_PLANE_TYPE_PRIMARY);

tests/kms_dp_dsc.c line 186

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+		igt_plane_set_fb(primary, &data->fb_test_pattern);
+		igt_display_commit(&data->display);
+		/* Until we have CRC check support, manually check if RGB test pattern has no corruption */
+		manual ("RGB test pattern without corruption");
+		igt_assert_f(is_dp_dsc_enabled(data),
+			     "Default DSC enable failed on Connector: %s Pipe: %s",
+			     data->conn_name,
+			     kmstest_pipe_name(data->pipe));
+		clear_dp_dsc_enable(data);
+	}

Can we future-proof this with an

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

tests/kms_dp_dsc.c line 199

Quoted 13 lines
tests/kms_dp_dsc.c new file +13 -0
+
+}
+
+static void run_test(data_t *data, igt_output_t *output,
+		     enum dsc_test_type test_type)
+{
+	enum pipe pipe;
+
+	for_each_pipe_with_valid_output(&data->display, pipe, output) {
+		igt_output_set_pipe(output, pipe);
+		data->pipe = pipe;
+		data->output = output;
+		update_display(data, test_basic_dsc_enable);

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

Quoted 4 lines
tests/kms_dp_dsc.c new file +4 -0
+	}
+}
+
+igt_main

tests/kms_dp_dsc.c line 213

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+{
+	data_t data = {};
+	igt_output_t *output;
+	drmModeRes *res;
+	drmModeConnector *connector;
+	int i, test_conn_cnt, test_cnt;
+	int tests[] = {DRM_MODE_CONNECTOR_eDP, DRM_MODE_CONNECTOR_DisplayPort};
+
+	igt_fixture {
+		igt_skip_on_simulation();

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

tests/kms_dp_dsc.c line 217

Quoted 4 lines
tests/kms_dp_dsc.c new file +4 -0
+		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
+		kmstest_set_vt_graphics_mode();
+		igt_display_init(&data.display, data.drm_fd);

commit 5105f068f6525f4d863719acf754891442eed254

Author: Daniel Vetter <[email protected]>
Date:   Thu Nov 22 10:36:58 2018 +0100

lib/kms: Drop igt_display_init

You need to change this call to igt_display_require.

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

tests/meson.build test_progs = [ · line 36

Quoted 5 lines
tests/meson.build +1 -0
@@ -32,6 +32,7 @@ test_progs = [
 	'kms_cursor_crc',
 	'kms_cursor_legacy',
 	'kms_draw_crc',
+	'kms_dp_dsc',
 	'kms_fbcon_fbt',

Alphabetical ordering off-by-one.

Signature · 5 lines
Petri Latvala
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#3 lore raw
Quoted 31 lines · Petri Latvala
Quoted 30 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 two subtests to force the DSC on all the eDP and DP connectors that support it with default parameters. This will be expanded to add more subtests to tweak DSC parameters.

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

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

Cc Petri Latvala <[email protected]>
Cc Antonio Argenziano <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Anusha Srivatsa <[email protected]>
---
 tests/Makefile.sources |   1 +
 tests/kms_dp_dsc.c     | 261 +++++++++++++++++++++++++++++++++++++++++
 tests/meson.build      |   1 +
 3 files changed, 263 insertions(+)
 create mode 100644 tests/kms_dp_dsc.c
Quoted 14 lines

tests/Makefile.sources TESTS_progs = \ · line 94

Quoted 12 lines
tests/Makefile.sources +1 -0
index d007ebc7..2a5b1c7f 100644
@@ -88,6 +88,7 @@ TESTS_progs = \
 	kms_universal_plane \
 	kms_vblank \
 	kms_sequence \
+	kms_dp_dsc \
 	meta_test \
 	perf \
 	perf_pmu \

Alphabetically ordered please.

Yes will fix this ordering and move kms_dp_dsc up

Quoted 115 lines
Quoted 115 lines
tests/kms_dp_dsc.c new file +107 -0
new file mode 100644
index 00000000..d2710dde
@@ -0,0 +1,261 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Displayport Display Stream Compression test
+ * Until the CRC support is added this needs to be invoked with --interactive
+ * to manually verify if the test pattern is seen without corruption for each
+ * subtest.
+ *
+ * Authors:
+ * Manasi Navare <[email protected]>
+ *
+ */
+#include "igt.h"
+#include "igt_sysfs.h"
+#include <errno.h>
+#include <getopt.h>
+#include <math.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <strings.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <time.h>
+#include <fcntl.h>
+#include <termios.h>
+
+enum dsc_test_type
+{
+	test_basic_dsc_enable
+};
+
+typedef struct {
+	int drm_fd;
+	int debugfs_fd;
+	uint32_t id;
+	igt_display_t display;
+	struct igt_fb fb_test_pattern;
+	igt_output_t *output;
+	int mode_valid;
+	drmModeModeInfo *mode;
+	drmModeConnector *connector;
+	drmModeEncoder *encoder;
+	int crtc;
+	enum pipe pipe;
+	char conn_name[128];
+} data_t;
+
+static inline void manual(const char *expected)
+{
+	igt_debug_manual_check("all", expected);
+}
+
+static bool is_dp_dsc_supported(data_t *data)
+{
+	char file_name[128] = {0};
+	char buf[512];
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_require(igt_debugfs_simple_read(data->debugfs_fd, file_name, buf,
+					    sizeof(buf)) > 0);
+	igt_debugfs_read(data->drm_fd, file_name, buf);
+
+	return strstr(buf, "DSC_Sink_Support: yes");
+
+}
+
+static bool is_dp_fec_supported(data_t *data)
+{
+	char file_name[128] = {0};
+	char buf[512];
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debugfs_read(data->drm_fd, file_name, buf);
+
+	return strstr(buf, "FEC_Sink_Support: yes");
+
+}
+
+static bool is_dp_dsc_enabled(data_t *data)
+{
+	char file_name[128] = {0};
+	char buf[512];
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
Quoted 8 lines

tests/kms_dp_dsc.c line 112

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	igt_debugfs_read(data->drm_fd, file_name, buf);
+
+	return strstr(buf, "DSC_Enabled: yes");
+
+}

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

Yes will do

Quoted 79 lines
Quoted 66 lines
tests/kms_dp_dsc.c new file +64 -0
+
+static void force_dp_dsc_enable(data_t *data)
+{
+	char file_name[128] = {0};
+	int ret;
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debug ("Forcing DSC enable on %s\n", data->conn_name);
+	ret = igt_sysfs_write(data->debugfs_fd, file_name, "1", 1);
+	igt_assert_f(ret > 0, "debugfs_write failed");
+}
+
+static void clear_dp_dsc_enable(data_t *data)
+{
+	char file_name[128] = {0};
+	int ret;
+
+	strcpy(file_name, data->conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debug ("Clearing DSC enable on %s\n", data->conn_name);
+	ret = igt_sysfs_write(data->debugfs_fd, file_name, "0", 1);
+	igt_assert_f(ret > 0, "debugfs_write failed");
+}
+
+static void test_cleanup(data_t *data) {
+	igt_plane_t *primary;
+
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_display_commit(&data->display);
+
+	igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
+}
+
+
+/*
+ * Re-probe connectors and do a modeset with DSC
+ *
+ */
+static void update_display(data_t *data, enum dsc_test_type test_type)
+{
+	igt_plane_t *primary;
+	data->mode = igt_output_get_mode(data->output);
+	data->connector = data->output->config.connector;
+
+	if (data->connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
+	    data->pipe == PIPE_A) {
+		igt_debug ("DSC not supported on Pipe A on external DP\n");
+		return;
+	}
+
+	if (test_type == test_basic_dsc_enable) {
+		igt_debug ("DSC is supported on %s\n",
+			   data->conn_name);
+		force_dp_dsc_enable(data);
+		igt_create_pattern_fb(data->drm_fd, data->mode->hdisplay,
+				      data->mode->vdisplay,
+				      DRM_FORMAT_XRGB8888,
+				      LOCAL_DRM_FORMAT_MOD_NONE,
+				      &data->fb_test_pattern);
+		primary = igt_output_get_plane_type(data->output,
+						    DRM_PLANE_TYPE_PRIMARY);

tests/kms_dp_dsc.c line 186

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+		igt_plane_set_fb(primary, &data->fb_test_pattern);
+		igt_display_commit(&data->display);
+		/* Until we have CRC check support, manually check if RGB test pattern has no corruption */
+		manual ("RGB test pattern without corruption");
+		igt_assert_f(is_dp_dsc_enabled(data),
+			     "Default DSC enable failed on Connector: %s Pipe: %s",
+			     data->conn_name,
+			     kmstest_pipe_name(data->pipe));
+		clear_dp_dsc_enable(data);
+	}

Can we future-proof this with an

Quoted 4 lines

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

Yes thats a good idea

Quoted 18 lines
Quoted 4 lines
tests/kms_dp_dsc.c new file +3 -0
+
+}
+

tests/kms_dp_dsc.c line 199

Quoted 10 lines
tests/kms_dp_dsc.c new file +10 -0
+static void run_test(data_t *data, igt_output_t *output,
+		     enum dsc_test_type test_type)
+{
+	enum pipe pipe;
+
+	for_each_pipe_with_valid_output(&data->display, pipe, output) {
+		igt_output_set_pipe(output, pipe);
+		data->pipe = pipe;
+		data->output = output;
+		update_display(data, test_basic_dsc_enable);

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

Oh yes sorry missed this part when I was modularizing the functions

Quoted 10 lines
Quoted 10 lines
tests/kms_dp_dsc.c new file +9 -0
+	}
+}
+
+igt_main
+{
+	data_t data = {};
+	igt_output_t *output;
+	drmModeRes *res;
+	drmModeConnector *connector;
Quoted 8 lines

tests/kms_dp_dsc.c line 213

Quoted 5 lines
tests/kms_dp_dsc.c new file +5 -0
+	int i, test_conn_cnt, test_cnt;
+	int tests[] = {DRM_MODE_CONNECTOR_eDP, DRM_MODE_CONNECTOR_DisplayPort};
+
+	igt_fixture {
+		igt_skip_on_simulation();

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

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

Quoted 8 lines

tests/kms_dp_dsc.c line 217

Quoted 6 lines
tests/kms_dp_dsc.c new file +4 -0
+		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
+		kmstest_set_vt_graphics_mode();
+		igt_display_init(&data.display, data.drm_fd);

commit 5105f068f6525f4d863719acf754891442eed254

Quoted 7 lines
Author: Daniel Vetter <[email protected]>
Date:   Thu Nov 22 10:36:58 2018 +0100

lib/kms: Drop igt_display_init

You need to change this call to igt_display_require.

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

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

tests/meson.build test_progs = [ · line 36

Quoted 6 lines
tests/meson.build +1 -0
@@ -32,6 +32,7 @@ test_progs = [
 	'kms_cursor_crc',
 	'kms_cursor_legacy',
 	'kms_draw_crc',
+	'kms_dp_dsc',
 	'kms_fbcon_fbt',

Alphabetical ordering off-by-one.

Gotcha, will fix it!
Thanks for the review

Manasi

Quoted 6 lines
Signature · 2 lines
-- 
Petri Latvala

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