Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kunal Joshi <kunal1.joshi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kunal Joshi <kunal1.joshi@intel.com>,
	Nemesa Garg <nemesa.garg@intel.com>,
	Arun R Murthy <arun.r.murthy@intel.com>
Subject: [igt-dev] [PATCH i-g-t 1/2] lib/igt_debugfs: added helper to enable/disable dark screen detection
Date: Wed, 15 Nov 2023 12:12:52 +0530	[thread overview]
Message-ID: <20231115064253.1680913-2-kunal1.joshi@intel.com> (raw)
In-Reply-To: <20231115064253.1680913-1-kunal1.joshi@intel.com>

added helper function for dark screen detection

v2: Fix indentation (JP)
    Reduce complexity and redundancy (JP)

Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Cc: Nemesa Garg <nemesa.garg@intel.com>
Cc: Arun R Murthy <arun.r.murthy@intel.com>
Cc: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com>
Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com>
---
 lib/igt_debugfs.c | 23 +++++++++++++++++++++++
 lib/igt_debugfs.h |  2 ++
 2 files changed, 25 insertions(+)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index a7b54bae5..c4a8b532d 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -743,3 +743,26 @@ void __igt_debugfs_dump(int device, const char *filename, int level)
 	igt_log(IGT_LOG_DOMAIN, level, "%s:\n%s\n", filename, contents);
 	free(contents);
 }
+
+bool igt_is_dark_screen_supported(int drm_fd, enum pipe pipe)
+{
+	char buf[256];
+	int dir;
+
+	dir = igt_debugfs_pipe_dir(drm_fd, pipe, O_DIRECTORY);
+	igt_require_fd(dir);
+	igt_debugfs_simple_read(dir, "i915_darkscreen_status", buf, sizeof(buf));
+	close(dir);
+	return (*buf == '0' || *buf == '1');
+}
+
+ssize_t igt_set_dark_screen_detection(int drm_fd, enum pipe pipe, bool enable)
+{
+	char buf[2];
+	int dir;
+
+	snprintf(buf, sizeof(buf), "%d", enable ? 1 : 0);
+	dir = igt_debugfs_pipe_dir(drm_fd, pipe, O_DIRECTORY);
+	igt_require_fd(dir);
+	return igt_sysfs_write(dir, "i915_darkscreen_status", buf, sizeof(buf) - 1);
+}
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 3e6194ade..68f25be59 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -77,6 +77,8 @@ void igt_hpd_storm_reset(int fd);
 bool igt_hpd_storm_detected(int fd);
 void igt_require_hpd_storm_ctl(int fd);
 bool igt_ignore_long_hpd(int fd, bool enable);
+bool igt_is_dark_screen_supported(int drm_fd, enum pipe pipe);
+ssize_t igt_set_dark_screen_detection(int drm_fd, enum pipe pipe, bool enable);
 
 /*
  * Drop caches
-- 
2.25.1

  reply	other threads:[~2023-11-15  6:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-15  6:42 [igt-dev] [PATCH i-g-t 0/2] add new subtests for dark screen detection Kunal Joshi
2023-11-15  6:42 ` Kunal Joshi [this message]
2023-11-16 11:40   ` [igt-dev] [PATCH i-g-t 1/2] lib/igt_debugfs: added helper to enable/disable " Juha-Pekka Heikkila
2023-11-15  6:42 ` [igt-dev] [PATCH i-g-t 2/2] tests/kms_pipe_crc_basic: added new subtest for darkscreen detection Kunal Joshi
2023-11-15  7:36 ` [igt-dev] ✗ Fi.CI.BAT: failure for add new subtests for dark screen detection (rev2) Patchwork
2023-11-15  8:16 ` [igt-dev] ✓ CI.xeBAT: success " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2023-11-23  6:29 [igt-dev] [PATCH i-g-t 0/2] add new subtests for dark screen detection Kunal Joshi
2023-11-23  6:29 ` [igt-dev] [PATCH i-g-t 1/2] lib/igt_debugfs: added helper to enable/disable " Kunal Joshi
2023-11-28 16:12   ` Juha-Pekka Heikkila
2023-11-17  7:03 [igt-dev] [PATCH i-g-t 0/2] add new subtests for " Kunal Joshi
2023-11-17  7:03 ` [igt-dev] [PATCH i-g-t 1/2] lib/igt_debugfs: added helper to enable/disable " Kunal Joshi
2023-11-22 21:01   ` Juha-Pekka Heikkila
2023-11-02  6:23 [igt-dev] [PATCH i-g-t 0/2] add new subtests for " Kunal Joshi
2023-11-02  6:23 ` [igt-dev] [PATCH i-g-t 1/2] lib/igt_debugfs: added helper to enable/disable " Kunal Joshi
2023-11-14 17:37   ` Juha-Pekka Heikkila

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=20231115064253.1680913-2-kunal1.joshi@intel.com \
    --to=kunal1.joshi@intel.com \
    --cc=arun.r.murthy@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=nemesa.garg@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