[igt-dev] [PATCH i-g-t 1/2] lib/igt_debugfs: added helper to enable/disable dark screen detection
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Tue Nov 28 16:12:36 UTC 2023
Hi,
On 23.11.2023 8.29, Kunal Joshi wrote:
> added helper function for dark screen detection
>
> v2: Fix indentation (JP)
> Reduce complexity and redundancy (JP)
>
> v3: Close fd (JP)
> Use ternary operator (JP)
>
> v4: Added comments for functions (JP)
>
> Cc: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> Cc: Nemesa Garg <nemesa.garg at intel.com>
> Cc: Arun R Murthy <arun.r.murthy at intel.com>
> Cc: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
> Signed-off-by: Kunal Joshi <kunal1.joshi at intel.com>
> ---
> lib/igt_debugfs.c | 39 +++++++++++++++++++++++++++++++++++++++
> lib/igt_debugfs.h | 2 ++
> 2 files changed, 41 insertions(+)
>
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index a7b54bae5..323030b19 100644
> --- a/lib/igt_debugfs.c
> +++ b/lib/igt_debugfs.c
> @@ -743,3 +743,42 @@ 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);
> }
> +
> +/**
> + * igt_is_dark_screen_supported:
> + * @drm_fd: fd of the device
> + * @pipe: display pipe
> + *
> + * Returns true if dark screen detection supported on platform
> + */
> +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');
> +}
> +
> +/**
> + * igt_set_dark_screen_detection:
> + * @drm_fd: fd of the device
> + * @pipe: display pipe
> + * @enable: bool to enable/disable dark screen detection
> + *
> + * Enable/Disable dark screen detection for given @pipe
please include here also comment for the meaning of return value. With that
Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> + */
> +ssize_t igt_set_dark_screen_detection(int drm_fd, enum pipe pipe, bool enable)
> +{
> + int dir;
> + int size;
> +
> + dir = igt_debugfs_pipe_dir(drm_fd, pipe, O_DIRECTORY);
> + igt_require_fd(dir);
> + size = igt_sysfs_write(dir, "i915_darkscreen_status", enable ? "1" : "0", 1);
> + close(dir);
> + return size;
> +}
> 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
More information about the igt-dev
mailing list