[i-g-t 3/5] lib/dsc: Reset DSC bpc to default on exit
Bhanuprakash Modem
bhanuprakash.modem at intel.com
Tue Aug 13 12:06:16 UTC 2024
Add support to force the DSC bpc to default on exit.
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
lib/igt_dsc.c | 16 ++++++++++++++++
lib/igt_dsc.h | 1 +
tests/intel/kms_dsc_helper.c | 9 ++++++++-
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/lib/igt_dsc.c b/lib/igt_dsc.c
index 229cd3298..409807b92 100644
--- a/lib/igt_dsc.c
+++ b/lib/igt_dsc.c
@@ -141,6 +141,22 @@ int igt_force_dsc_enable_bpc(int drmfd, char *connector_name, int bpc)
return write_dsc_debugfs(drmfd, connector_name, "i915_dsc_bpc", buf);
}
+/**
+ * igt_get_dsc_bpc_debugfs_fd:
+ * @drmfd: A drm file descriptor
+ * @connector_name: Name of the libdrm connector we're going to use
+ *
+ * Returns: fd of the DSC BPC debugfs for the given connector, else returns -1.
+ */
+int igt_get_dsc_bpc_debugfs_fd(int drmfd, char *connector_name)
+{
+ char file_name[128] = {0};
+
+ sprintf(file_name, "%s/i915_dsc_bpc", connector_name);
+
+ return openat(igt_debugfs_dir(drmfd), file_name, O_WRONLY);
+}
+
/**
* igt_get_dsc_debugfs_fd:
* @drmfd: A drm file descriptor
diff --git a/lib/igt_dsc.h b/lib/igt_dsc.h
index 7ab0917ec..1f3ea6920 100644
--- a/lib/igt_dsc.h
+++ b/lib/igt_dsc.h
@@ -18,6 +18,7 @@ bool igt_is_force_dsc_enabled(int drmfd, char *connector_name);
int igt_force_dsc_enable(int drmfd, char *connector_name);
int igt_force_dsc_enable_bpc(int drmfd, char *connector_name, int bpc);
int igt_get_dsc_debugfs_fd(int drmfd, char *connector_name);
+int igt_get_dsc_bpc_debugfs_fd(int drmfd, char *connector_name);
bool igt_is_dsc_output_format_supported_by_sink(int drmfd, char *connector_name,
enum dsc_output_format output_format);
int igt_force_dsc_output_format(int drmfd, char *connector_name,
diff --git a/tests/intel/kms_dsc_helper.c b/tests/intel/kms_dsc_helper.c
index 0de09b8e9..53bc1cc33 100644
--- a/tests/intel/kms_dsc_helper.c
+++ b/tests/intel/kms_dsc_helper.c
@@ -6,6 +6,7 @@
#include "kms_dsc_helper.h"
static bool force_dsc_en_orig;
+static bool force_dsc_en_bpc_orig;
static bool force_dsc_fractional_bpp_en_orig;
static int force_dsc_restore_fd = -1;
static int force_dsc_fractional_bpp_restore_fd = -1;
@@ -33,6 +34,8 @@ void save_force_dsc_en(int drmfd, igt_output_t *output)
{
force_dsc_en_orig =
igt_is_force_dsc_enabled(drmfd, output->name);
+ force_dsc_en_bpc_orig =
+ igt_get_dsc_bpc_debugfs_fd(drmfd, output->name);
force_dsc_restore_fd =
igt_get_dsc_debugfs_fd(drmfd, output->name);
igt_assert_lte(0, force_dsc_restore_fd);
@@ -45,8 +48,12 @@ void restore_force_dsc_en(void)
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);
+
+ igt_debug("Restoring DSC BPC enable\n");
+ igt_assert(write(force_dsc_en_bpc_orig, "0", 1) == 1);
+ close(force_dsc_en_bpc_orig);
+
force_dsc_restore_fd = -1;
}
--
2.43.2
More information about the igt-dev
mailing list