public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Swati Sharma <swati2.sharma@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: petri.latvala@intel.com
Subject: [igt-dev] [PATCH i-g-t 2/8] Move wrapper functions from kms_dsc to kms_dsc_helper
Date: Mon,  9 Jan 2023 20:58:25 +0530	[thread overview]
Message-ID: <20230109152832.3310-3-swati2.sharma@intel.com> (raw)
In-Reply-To: <20230109152832.3310-1-swati2.sharma@intel.com>

To add dsc concurrent tests, these wrapper functions can be
reused. Lets create separate helper file to avoid code duplication.

Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
---
 tests/i915/kms_dsc.c        | 130 +----------------------------------
 tests/i915/kms_dsc_helper.c | 131 ++++++++++++++++++++++++++++++++++++
 tests/i915/kms_dsc_helper.h |  65 ++++++++++++++++++
 tests/meson.build           |  10 ++-
 4 files changed, 207 insertions(+), 129 deletions(-)
 create mode 100644 tests/i915/kms_dsc_helper.c
 create mode 100644 tests/i915/kms_dsc_helper.h

diff --git a/tests/i915/kms_dsc.c b/tests/i915/kms_dsc.c
index 330fc050b..0db6cc2ef 100644
--- a/tests/i915/kms_dsc.c
+++ b/tests/i915/kms_dsc.c
@@ -29,22 +29,8 @@
  * Manasi Navare <manasi.d.navare@intel.com>
  *
  */
-#include "igt.h"
-#include "igt_sysfs.h"
-#include <errno.h>
-#include <getopt.h>
-#include <math.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <strings.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <time.h>
-#include <fcntl.h>
-#include <termios.h>
-
-#define HDISPLAY_5K	5120
+
+#include "kms_dsc_helper.h"
 
 IGT_TEST_DESCRIPTION("Test to validate display stream compression");
 
@@ -53,20 +39,6 @@ enum dsc_test_type {
 	TEST_DSC_BPC
 };
 
-typedef struct {
-	int drm_fd;
-	uint32_t devid;
-	igt_display_t display;
-	struct igt_fb fb_test_pattern;
-	igt_output_t *output;
-	int input_bpc;
-	int n_pipes;
-	enum pipe pipe;
-} data_t;
-
-bool force_dsc_en_orig;
-int force_dsc_restore_fd = -1;
-
 const struct {
 	const int format;
 	const char format_str[20];
@@ -84,56 +56,6 @@ static inline void manual(const char *expected)
 	igt_debug_interactive_mode_check("all", expected);
 }
 
-static void force_dsc_enable(data_t *data)
-{
-	int ret;
-
-	igt_debug("Forcing DSC enable on %s\n", data->output->name);
-	ret = igt_force_dsc_enable(data->drm_fd,
-				   data->output->name);
-	igt_assert_f(ret > 0, "debugfs_write failed");
-}
-
-static void force_dsc_enable_bpc(data_t *data)
-{
-	int ret;
-
-	igt_debug("Forcing input DSC BPC to %d on %s\n",
-		  data->input_bpc, data->output->name);
-	ret = igt_force_dsc_enable_bpc(data->drm_fd,
-				       data->output->name,
-				       data->input_bpc);
-	igt_assert_f(ret > 0, "debugfs_write failed");
-}
-
-static void save_force_dsc_en(data_t *data)
-{
-	force_dsc_en_orig =
-		igt_is_force_dsc_enabled(data->drm_fd,
-					 data->output->name);
-	force_dsc_restore_fd =
-		igt_get_dsc_debugfs_fd(data->drm_fd,
-				       data->output->name);
-	igt_assert(force_dsc_restore_fd >= 0);
-}
-
-static void restore_force_dsc_en(void)
-{
-	if (force_dsc_restore_fd < 0)
-		return;
-
-	igt_debug("Restoring DSC enable\n");
-	igt_assert(write(force_dsc_restore_fd, force_dsc_en_orig ? "1" : "0", 1) == 1);
-
-	close(force_dsc_restore_fd);
-	force_dsc_restore_fd = -1;
-}
-
-static void kms_dsc_exit_handler(int sig)
-{
-	restore_force_dsc_en();
-}
-
 static drmModeModeInfo *get_highres_mode(igt_output_t *output)
 {
 	drmModeConnector *connector = output->config.connector;
@@ -146,26 +68,6 @@ static drmModeModeInfo *get_highres_mode(igt_output_t *output)
 	return highest_mode;
 }
 
-static bool check_dsc_on_connector(data_t *data)
-{
-	igt_output_t *output = data->output;
-
-	if (!igt_is_dsc_supported(data->drm_fd, output->name)) {
-		igt_debug("DSC not supported on connector %s\n",
-			  output->name);
-		return false;
-	}
-
-	if (!output_is_internal_panel(output) &&
-	    !igt_is_fec_supported(data->drm_fd, output->name)) {
-		igt_debug("DSC cannot be enabled without FEC on %s\n",
-			  output->name);
-		return false;
-	}
-
-	return true;
-}
-
 static bool check_big_joiner_pipe_constraint(data_t *data)
 {
 	igt_output_t *output = data->output;
@@ -181,34 +83,6 @@ static bool check_big_joiner_pipe_constraint(data_t *data)
 	return true;
 }
 
-static bool check_gen11_dp_constraint(data_t *data)
-{
-	igt_output_t *output = data->output;
-	uint32_t devid = intel_get_drm_devid(data->drm_fd);
-	drmModeConnector *connector = output->config.connector;
-
-	if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) &&
-	    (data->pipe == PIPE_A) && IS_GEN11(devid)) {
-		igt_debug("DSC not supported on pipe A on external DP in gen11 platforms\n");
-		return false;
-	}
-
-	return true;
-}
-
-/* Max DSC Input BPC for ICL is 10 and for TGL+ is 12 */
-static bool check_gen11_bpc_constraint(data_t *data)
-{
-	uint32_t devid = intel_get_drm_devid(data->drm_fd);
-
-	if (IS_GEN11(devid) && data->input_bpc == 12) {
-		igt_debug("Input bpc 12 not supported on gen11 platforms\n");
-		return false;
-	}
-
-	return true;
-}
-
 static void test_cleanup(data_t *data)
 {
 	igt_output_t *output = data->output;
diff --git a/tests/i915/kms_dsc_helper.c b/tests/i915/kms_dsc_helper.c
new file mode 100644
index 000000000..183a31457
--- /dev/null
+++ b/tests/i915/kms_dsc_helper.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright © 2023 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.
+ *
+ */
+
+#include "kms_dsc_helper.h"
+
+bool force_dsc_en_orig;
+int force_dsc_restore_fd = -1;
+
+void force_dsc_enable(data_t *data)
+{
+	int ret;
+
+	igt_debug("Forcing DSC enable on %s\n", data->output->name);
+	ret = igt_force_dsc_enable(data->drm_fd,
+				   data->output->name);
+	igt_assert_f(ret > 0, "debugfs_write failed");
+}
+
+void force_dsc_enable_bpc(data_t *data)
+{
+	int ret;
+
+	igt_debug("Forcing input DSC BPC to %d on %s\n",
+		  data->input_bpc, data->output->name);
+	ret = igt_force_dsc_enable_bpc(data->drm_fd,
+				       data->output->name,
+				       data->input_bpc);
+	igt_assert_f(ret > 0, "debugfs_write failed");
+}
+
+void save_force_dsc_en(data_t *data)
+{
+	force_dsc_en_orig =
+		igt_is_force_dsc_enabled(data->drm_fd,
+					 data->output->name);
+	force_dsc_restore_fd =
+		igt_get_dsc_debugfs_fd(data->drm_fd,
+				       data->output->name);
+	igt_assert(force_dsc_restore_fd >= 0);
+}
+
+void restore_force_dsc_en(void)
+{
+	if (force_dsc_restore_fd < 0)
+		return;
+
+	igt_debug("Restoring DSC enable\n");
+	igt_assert(write(force_dsc_restore_fd, force_dsc_en_orig ? "1" : "0", 1) == 1);
+
+	close(force_dsc_restore_fd);
+	force_dsc_restore_fd = -1;
+}
+
+void kms_dsc_exit_handler(int sig)
+{
+	restore_force_dsc_en();
+}
+
+bool check_dsc_on_connector(data_t *data)
+{
+	igt_output_t *output = data->output;
+
+	if (!igt_is_dsc_supported(data->drm_fd, output->name)) {
+		igt_debug("DSC not supported on connector %s\n",
+			  output->name);
+		return false;
+	}
+
+	if (!output_is_internal_panel(output) &&
+	    !igt_is_fec_supported(data->drm_fd, output->name)) {
+		igt_debug("DSC cannot be enabled without FEC on %s\n",
+			  output->name);
+		return false;
+	}
+
+	return true;
+}
+
+bool check_gen11_dp_constraint(data_t *data)
+{
+	igt_output_t *output = data->output;
+	uint32_t devid = intel_get_drm_devid(data->drm_fd);
+	drmModeConnector *connector = output->config.connector;
+
+	if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) &&
+	    (data->pipe == PIPE_A) && IS_GEN11(devid)) {
+		igt_debug("DSC not supported on pipe A on external DP in gen11 platforms\n");
+		return false;
+	}
+
+	return true;
+}
+
+/* Max DSC Input BPC for ICL is 10 and for TGL+ is 12 */
+bool check_gen11_bpc_constraint(data_t *data)
+{
+	uint32_t devid = intel_get_drm_devid(data->drm_fd);
+
+	if (IS_GEN11(devid) && data->input_bpc == 12) {
+		igt_debug("Input bpc 12 not supported on gen11 platforms\n");
+		return false;
+	}
+
+	return true;
+}
diff --git a/tests/i915/kms_dsc_helper.h b/tests/i915/kms_dsc_helper.h
new file mode 100644
index 000000000..0d93f7369
--- /dev/null
+++ b/tests/i915/kms_dsc_helper.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright © 2023 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.
+ *
+ */
+
+#ifndef IGT_KMS_DSC_HELPER_H
+#define IGT_KMS_DSC_HELPER_H
+
+#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>
+
+#define HDISPLAY_5K	5120
+
+typedef struct {
+	int drm_fd;
+	uint32_t devid;
+	igt_display_t display;
+	struct igt_fb fb_test_pattern;
+	igt_output_t *output;
+	int input_bpc;
+	int n_pipes;
+	enum pipe pipe;
+} data_t;
+
+void force_dsc_enable_bpc(data_t *data);
+void force_dsc_enable(data_t *data);
+void save_force_dsc_en(data_t *data);
+void restore_force_dsc_en(void);
+void kms_dsc_exit_handler(int sig);
+bool check_dsc_on_connector(data_t *data);
+bool check_gen11_dp_constraint(data_t *data);
+bool check_gen11_bpc_constraint(data_t *data);
+
+#endif
diff --git a/tests/meson.build b/tests/meson.build
index cb4289985..e63d62249 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -221,7 +221,6 @@ i915_progs = [
 	'kms_ccs',
 	'kms_cdclk',
 	'kms_draw_crc',
-	'kms_dsc',
 	'kms_fbcon_fbt',
 	'kms_fence_pin_leak',
 	'kms_flip_scaled_crc',
@@ -424,6 +423,15 @@ test_executables += executable('kms_color',
 	   install : true)
 test_list += 'kms_color'
 
+test_executables += executable('kms_dsc',
+	   [ join_paths('i915', 'kms_dsc.c'), join_paths ('i915', 'kms_dsc_helper.c')],
+	   dependencies : test_deps,
+	   install_dir : libexecdir,
+	   install_rpath : libexecdir_rpathdir,
+	   install : true)
+test_list += 'kms_dsc'
+
+
 if chamelium.found()
        test_executables += executable('kms_color_chamelium',
                              [ 'chamelium/kms_color_chamelium.c', 'kms_color_helper.c' ],
-- 
2.25.1

  parent reply	other threads:[~2023-01-09 15:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09 15:28 [igt-dev] [PATCH i-g-t 0/8] VDSC YCbCr420 + Fractional BPP Swati Sharma
2023-01-09 15:28 ` [igt-dev] [PATCH i-g-t 1/8] lib/dsc: Move VDSC functions to separate lib file Swati Sharma
2023-01-09 15:28 ` Swati Sharma [this message]
2023-01-10 10:54   ` [igt-dev] [PATCH i-g-t 2/8] Move wrapper functions from kms_dsc to kms_dsc_helper Hogander, Jouni
2023-01-09 15:28 ` [igt-dev] [PATCH i-g-t 3/8] lib/dsc: Add helpers for VDSC YCbCr420 debugfs entry Swati Sharma
2023-01-09 15:28 ` [igt-dev] [PATCH i-g-t 4/8] tests/i915/kms_dsc: Prep work for extending val support for VDSC YCbCr420 Swati Sharma
2023-01-09 15:28 ` [igt-dev] [PATCH i-g-t 5/8] tests/i915/kms_dsc: Enable validation " Swati Sharma
2023-01-10 11:56   ` Hogander, Jouni
2023-01-11  6:38     ` Swati Sharma
2023-01-09 15:28 ` [igt-dev] [PATCH i-g-t 6/8] lib/dsc: Add helpers for VDSC Fractional BPP debugfs entry Swati Sharma
2023-01-09 15:28 ` [igt-dev] [PATCH i-g-t 7/8] tests/i915/kms_dsc: Enable validation for VDSC Fractional BPP Swati Sharma
2023-01-09 15:28 ` [igt-dev] [PATCH i-g-t 8/8] tests/i915/kms_dsc: Add test summary Swati Sharma
2023-01-09 18:04 ` [igt-dev] ✗ GitLab.Pipeline: warning for VDSC YCbCr420 + Fractional BPP (rev2) Patchwork
2023-01-09 18:34 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-01-10  1:34 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230109152832.3310-3-swati2.sharma@intel.com \
    --to=swati2.sharma@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox