[PATCH i-g-t v3 4/5] lib/igt_pm: Move check_dpms to igt_pm lib
Reddy Guddati, Santhosh
santhosh.reddy.guddati at intel.com
Fri Jul 25 09:50:30 UTC 2025
________________________________
From: B S, Karthik <karthik.b.s at intel.com>
Sent: Wednesday, July 23, 2025 11:23 AM
To: igt-dev at lists.freedesktop.org <igt-dev at lists.freedesktop.org>
Cc: Reddy Guddati, Santhosh <santhosh.reddy.guddati at intel.com>; Murthy, Arun R <arun.r.murthy at intel.com>; B, Jeevan <jeevan.b at intel.com>; B S, Karthik <karthik.b.s at intel.com>
Subject: [PATCH i-g-t v3 4/5] lib/igt_pm: Move check_dpms to igt_pm lib
The check_dpms function in kms_pm_backlight.c is moved to igt_pm lib
to make it accessible to other subtests which need to perform a
simple DPMS toggle.
Signed-off-by: Karthik B S <karthik.b.s at intel.com>
---
lib/igt_pm.c | 21 +++++++++++++++++++++
lib/igt_pm.h | 1 +
tests/intel/kms_pm_backlight.c | 20 ++------------------
3 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 7f9cbd69a..cf1c442f8 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -1487,3 +1487,24 @@ bool igt_has_pci_pm_capability(struct pci_device *pci_dev)
return (offset > 0);
}
+
+/**
+ * igt_pm_dpms_toggle:
+ * @output: igt output for which DPMS toggle has to be performed
+ *
+ * Toggles the DPMS state of output to OFF and then back ON.
+ */
+void igt_pm_dpms_toggle(igt_output_t *output)
+{
+ igt_require(igt_setup_runtime_pm(output->display->drm_fd));
+
+ kmstest_set_connector_dpms(output->display->drm_fd,
+ output->config.connector,
+ DRM_MODE_DPMS_OFF);
+ igt_require(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED));
+
+ kmstest_set_connector_dpms(output->display->drm_fd,
+ output->config.connector,
+ DRM_MODE_DPMS_ON);
+ igt_assert(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_ACTIVE));
+}
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index c73972f2a..e931e51af 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -98,5 +98,6 @@ uint64_t igt_pm_get_runtime_active_time(struct pci_device *pci_dev);
int igt_pm_get_runtime_usage(struct pci_device *pci_dev);
void igt_pm_ignore_slpc_efficient_freq(int i915, int gtfd, bool val);
bool igt_has_pci_pm_capability(struct pci_device *pci_dev);
+void igt_pm_dpms_toggle(igt_output_t *output);
LGTM,
Reviewed-by: Santhosh Reddy Guddati <santhosh.reddy.guddati at intel.com>
#endif /* IGT_PM_H */
diff --git a/tests/intel/kms_pm_backlight.c b/tests/intel/kms_pm_backlight.c
index 9b341c73a..a0ecf2b0e 100644
--- a/tests/intel/kms_pm_backlight.c
+++ b/tests/intel/kms_pm_backlight.c
@@ -142,22 +142,6 @@ static void test_fade(igt_backlight_context_t *context)
}
}
-static void
-check_dpms(igt_output_t *output)
-{
- igt_require(igt_setup_runtime_pm(output->display->drm_fd));
-
- kmstest_set_connector_dpms(output->display->drm_fd,
- output->config.connector,
- DRM_MODE_DPMS_OFF);
- igt_require(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED));
-
- kmstest_set_connector_dpms(output->display->drm_fd,
- output->config.connector,
- DRM_MODE_DPMS_ON);
- igt_assert(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_ACTIVE));
-}
-
static void check_dpms_cycle(igt_backlight_context_t *context)
{
int max, val_1, val_2;
@@ -168,7 +152,7 @@ static void check_dpms_cycle(igt_backlight_context_t *context)
igt_backlight_write(max / 2, "brightness", context);
igt_backlight_read(&val_1, "actual_brightness", context);
- check_dpms(context->output);
+ igt_pm_dpms_toggle(context->output);
igt_backlight_read(&val_2, "actual_brightness", context);
igt_assert_eq(val_1, val_2);
@@ -310,7 +294,7 @@ igt_main
test_setup(display, &contexts->output[j]);
if (tests[i].flags == TEST_DPMS)
- check_dpms(contexts[j].output);
+ igt_pm_dpms_toggle(contexts[j].output);
if (tests[i].flags == TEST_SUSPEND)
check_suspend(contexts[j].output);
--
2.43.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/igt-dev/attachments/20250725/952cacab/attachment-0001.htm>
More information about the igt-dev
mailing list