Skip to contentSkip to conversation

tests/i915/i915_pm_backlight: Add new subtest to validate dual panel backlight

PATCH In review Nidhi Gupta 5 participants 9 messages Sep 26, 2022 – Dec 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/i915/i915_pm_backlight: Add new subtest to validate dual panel backlight

Since driver can now support multiple eDPs and Debugfs structure for backlight changed per connector the test should then iterate through all eDP connectors.

---
 tests/i915/i915_pm_backlight.c | 70 +++++++++++++++++++---------------
 1 file changed, 39 insertions(+), 31 deletions(-)
tests/i915/i915_pm_backlight.c +39 -31
index cafae7f7..1532193b 100644
@@ -37,25 +37,26 @@
 
 struct context {
 	int max;
+	const char *path;
 };
 
 
 #define TOLERANCE 5 /* percent */
-#define BACKLIGHT_PATH "/sys/class/backlight/intel_backlight"
+#define BACKLIGHT_PATH "/sys/class/backlight"
 
 #define FADESTEPS 10
 #define FADESPEED 100 /* milliseconds between steps */
 
 IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
 
-static int backlight_read(int *result, const char *fname)
+static int backlight_read(int *result, const char *fname, struct context *context)
 {
 	int fd;
 	char full[PATH_MAX];
 	char dst[64];
 	int r, e;
 
-	igt_assert(snprintf(full, PATH_MAX, "%s/%s", BACKLIGHT_PATH, fname) < PATH_MAX);
+	igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname) < PATH_MAX);
 
 	fd = open(full, O_RDONLY);
 	if (fd == -1)
@@ -73,14 +74,14 @@ static int backlight_read(int *result, const char *fname)
 	return errno;
 }
 
-static int backlight_write(int value, const char *fname)
+static int backlight_write(int value, const char *fname, struct context *context)
 {
 	int fd;
 	char full[PATH_MAX];
 	char src[64];
 	int len;
 
-	igt_assert(snprintf(full, PATH_MAX, "%s/%s", BACKLIGHT_PATH, fname) < PATH_MAX);
+	igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname) < PATH_MAX);
 	fd = open(full, O_WRONLY);
 	if (fd == -1)
 		return -errno;
@@ -100,12 +101,12 @@ static void test_and_verify(struct context *context, int val)
 	const int tolerance = val * TOLERANCE / 100;
 	int result;
 
-	igt_assert_eq(backlight_write(val, "brightness"), 0);
-	igt_assert_eq(backlight_read(&result, "brightness"), 0);
+	igt_assert_eq(backlight_write(val, "brightness", context), 0);
+	igt_assert_eq(backlight_read(&result, "brightness", context), 0);
 	/* Check that the exact value sticks */
 	igt_assert_eq(result, val);
 
-	igt_assert_eq(backlight_read(&result, "actual_brightness"), 0);
+	igt_assert_eq(backlight_read(&result, "actual_brightness", context), 0);
 	/* Some rounding may happen depending on hw */
 	igt_assert_f(result >= max(0, val - tolerance) &&
 		     result <= min(context->max, val + tolerance),
@@ -124,16 +125,16 @@ static void test_bad_brightness(struct context *context)
 {
 	int val;
 	/* First write some sane value */
-	backlight_write(context->max / 2, "brightness");
+	backlight_write(context->max / 2, "brightness", context);
 	/* Writing invalid values should fail and not change the value */
-	igt_assert_lt(backlight_write(-1, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(-1, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
-	igt_assert_lt(backlight_write(context->max + 1, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(context->max + 1, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
-	igt_assert_lt(backlight_write(INT_MAX, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(INT_MAX, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
 }
 
@@ -186,6 +187,7 @@ igt_main
 	igt_display_t display;
 	igt_output_t *output;
 	struct igt_fb fb;
+	char paths[][50] = { "intel_backlight", "card0-eDP-2-backlight" };
 
 	igt_fixture {
 		enum pipe pipe;
@@ -203,11 +205,14 @@ igt_main
 		igt_display_require(&display, drm_open_driver(DRIVER_INTEL));
 
 		/* Get the max value and skip the whole test if sysfs interface not available */
-		igt_skip_on(backlight_read(&old, "brightness"));
-		igt_assert(backlight_read(&context.max, "max_brightness") > -1);
+		for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
+			context.path = paths[i];
+			igt_skip_on(backlight_read(&old, "brightness", &context));
+			igt_assert(backlight_read(&context.max, "max_brightness", &context) > -1);
+		}
 
 		/* should be ../../cardX-$output */
-		igt_assert_lt(12, readlink(BACKLIGHT_PATH "/device", full_name, sizeof(full_name) - 1));
+		igt_assert_lt(12, readlink(BACKLIGHT_PATH "/intel_backlight/device", full_name, sizeof(full_name) - 1));
 		name = basename(full_name);
 
 		for_each_pipe_with_valid_output(&display, pipe, output) {
@@ -234,22 +239,25 @@ igt_main
 		igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
 		igt_pm_enable_sata_link_power_management();
 	}
+	for (size_t j = 0; j < sizeof(paths) / sizeof(paths[0]); j++) {
+		context.path = paths[j];
+
+		igt_subtest("basic-brightness")
+			test_brightness(&context);
+		igt_subtest("bad-brightness")
+			test_bad_brightness(&context);
+		igt_subtest("fade")
+			test_fade(&context);
+		igt_subtest("fade_with_dpms")
+			test_fade_with_dpms(&context, output);
+		igt_subtest("fade_with_suspend")
+			test_fade_with_suspend(&context, output);
 
-	igt_subtest("basic-brightness")
-		test_brightness(&context);
-	igt_subtest("bad-brightness")
-		test_bad_brightness(&context);
-	igt_subtest("fade")
-		test_fade(&context);
-	igt_subtest("fade_with_dpms")
-		test_fade_with_dpms(&context, output);
-	igt_subtest("fade_with_suspend")
-		test_fade_with_suspend(&context, output);
-
-	igt_fixture {
 		/* Restore old brightness */
-		backlight_write(old, "brightness");
+                backlight_write(old, "brightness", &context);
+	}
 
+	igt_fixture {
 		igt_display_fini(&display);
 		igt_remove_fb(display.drm_fd, &fb);
 		igt_pm_restore_sata_link_power_management();
Signature · 1 line
2.36.0
#1 lore raw

[igt-dev] ✗ Fi.CI.BUILD: failure for tests/i915/i915_pm_backlight: Add new subtest to validate dual panel backlight (rev3)

== Series Details ==

== Series Details ==

Series: tests/i915/i915_pm_backlight: Add new subtest to validate dual panel backlight (rev3)
URL : https://patchwork.freedesktop.org/series/108246/
State : failure

== Summary ==

IGT patchset build failed on latest successful build dcb1d7a8822e62935f4fe3f2e6a04caaee669369 Revert "tests/kms_concurrent: remove an AMD device check"

299/331 testcase check amdgpu/amd_bypass              OK               0.22s
300/331 testcase check amdgpu/amd_deadlock            OK               0.22s
301/331 testcase check amdgpu/amd_color               OK               0.21s
302/331 testcase check amdgpu/amd_cs_nop              OK               0.21s
303/331 testcase check amdgpu/amd_hotplug             OK               0.20s
304/331 testcase check amdgpu/amd_info                OK               0.20s
305/331 testcase check amdgpu/amd_prime               OK               0.19s
306/331 testcase check amdgpu/amd_max_bpc             OK               0.17s
307/331 testcase check amdgpu/amd_module_load         OK               0.16s
308/331 testcase check amdgpu/amd_mem_leak            OK               0.16s
309/331 testcase check amdgpu/amd_link_settings       OK               0.16s
310/331 testcase check amdgpu/amd_vrr_range           OK               0.15s
311/331 testcase check amdgpu/amd_mode_switch         OK               0.15s
312/331 testcase check amdgpu/amd_dp_dsc              OK               0.14s
313/331 testcase check amdgpu/amd_psr                 OK               0.14s
314/331 testcase check amdgpu/amd_plane               OK               0.13s
315/331 testcase check amdgpu/amd_ilr                 OK               0.13s
316/331 runner_json                                   OK               0.12s
317/331 assembler test/mov                            OK               0.11s
318/331 assembler test/frc                            OK               0.11s
319/331 assembler test/regtype                        OK               0.10s
320/331 assembler test/rndd                           OK               0.09s
321/331 assembler test/rndu                           OK               0.08s
322/331 assembler test/rnde                           OK               0.07s
323/331 assembler test/rnde-intsrc                    OK               0.07s
324/331 assembler test/rndz                           OK               0.06s
325/331 assembler test/lzd                            OK               0.05s
326/331 assembler test/not                            OK               0.05s
327/331 assembler test/immediate                      OK               0.04s
328/331 lib igt_nesting                               OK               2.23s
329/331 lib igt_fork                                  OK               2.71s
330/331 testcase check gem_concurrent_all             OK               4.71s
331/331 runner                                        OK               5.20s

Summary of Failures:

242/331 testcase check i915_pm_backlight FAIL 0.29s exit status 1

Ok:                 327 
Expected Fail:      3   
Fail:               1   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0   

Full log written to /home/cidrm/igt-gpu-tools/build/meson-logs/testlog.txt
FAILED: meson-test
/usr/bin/meson test --no-rebuild --print-errorlogs
ninja: build stopped: subcommand failed.

#2 lore raw
In reply to Nidhi Gupta
Quoted 120 lines · Nidhi Gupta

Since driver can now support multiple eDPs and Debugfs structure for backlight changed per connector the test should then iterate through all eDP connectors.

---
 tests/i915/i915_pm_backlight.c | 70 +++++++++++++++++++------------- --

 1 file changed, 39 insertions(+), 31 deletions(-)
tests/i915/i915_pm_backlight.c +0 -0
index cafae7f7..1532193b 100644
@@ -37,25 +37,26 @@


 struct context {
        int max;
+       const char *path;
 };


 #define TOLERANCE 5 /* percent */

tests/i915/i915_pm_backlight.c +1 -1
-#define BACKLIGHT_PATH "/sys/class/backlight/intel_backlight"
+#define BACKLIGHT_PATH "/sys/class/backlight"


 #define FADESTEPS 10
 #define FADESPEED 100 /* milliseconds between steps */
 IGT_TEST_DESCRIPTION("Basic backlight sysfs test");

tests/i915/i915_pm_backlight.c +1 -1
-static int backlight_read(int *result, const char *fname)
+static int backlight_read(int *result, const char *fname, struct

context *context)
 {
        int fd;
        char full[PATH_MAX];
        char dst[64];
        int r, e;

-       igt_assert(snprintf(full, PATH_MAX, "%s/%s", BACKLIGHT_PATH, fname) < PATH_MAX);
+       igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname) < PATH_MAX);

        fd = open(full, O_RDONLY);
        if (fd == -1)

tests/i915/i915_pm_backlight.c +0 -0
@@ -73,14 +74,14 @@ static int backlight_read(int *result, const char
 *fname)
         return errno;
  }

tests/i915/i915_pm_backlight.c +1 -1
-static int backlight_write(int value, const char *fname)
+static int backlight_write(int value, const char *fname, struct

context *context)
 {
        int fd;
        char full[PATH_MAX];
        char src[64];
        int len;

-       igt_assert(snprintf(full, PATH_MAX, "%s/%s", BACKLIGHT_PATH, fname) < PATH_MAX);
+       igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname) < PATH_MAX);
        fd = open(full, O_WRONLY);
        if (fd == -1)
                return -errno;

tests/i915/i915_pm_backlight.c +0 -0
@@ -100,12 +101,12 @@ static void test_and_verify(struct context
 *context, int val)
         const int tolerance = val * TOLERANCE / 100;
         int result;


-       igt_assert_eq(backlight_write(val, "brightness"), 0); -       igt_assert_eq(backlight_read(&result, "brightness"), 0); +       igt_assert_eq(backlight_write(val, "brightness", context), 0);
+       igt_assert_eq(backlight_read(&result, "brightness", context), 0);
        /* Check that the exact value sticks */ igt_assert_eq(result, val);

-       igt_assert_eq(backlight_read(&result, "actual_brightness"), 0);
+       igt_assert_eq(backlight_read(&result, "actual_brightness", context), 0);
        /* Some rounding may happen depending on hw */ igt_assert_f(result >= max(0, val - tolerance) && result <= min(context->max, val + tolerance),

tests/i915/i915_pm_backlight.c +1 -1
@@ -124,16 +125,16 @@ static void test_bad_brightness(struct context
 *context)
  {
         int val;
         /* First write some sane value */
-       backlight_write(context->max / 2, "brightness");
+       backlight_write(context->max / 2, "brightness", context);
         /* Writing invalid values should fail and not change the

value */
-       igt_assert_lt(backlight_write(-1, "brightness"), 0); -       backlight_read(&val, "brightness");
+       igt_assert_lt(backlight_write(-1, "brightness", context), 0); +       backlight_read(&val, "brightness", context); igt_assert_eq(val, context->max / 2);
-       igt_assert_lt(backlight_write(context->max + 1, "brightness"), 0);
-       backlight_read(&val, "brightness");
+       igt_assert_lt(backlight_write(context->max + 1, "brightness", context), 0);
+       backlight_read(&val, "brightness", context); igt_assert_eq(val, context->max / 2);
-       igt_assert_lt(backlight_write(INT_MAX, "brightness"), 0); -       backlight_read(&val, "brightness");
+       igt_assert_lt(backlight_write(INT_MAX, "brightness", context), 0);
+       backlight_read(&val, "brightness", context); igt_assert_eq(val, context->max / 2);
 }

tests/i915/i915_pm_backlight.c igt_main · line 191

Quoted 5 lines
tests/i915/i915_pm_backlight.c +1 -0
@@ -186,6 +187,7 @@ igt_main
         igt_display_t display;
         igt_output_t *output;
         struct igt_fb fb;
+       char paths[][50] = { "intel_backlight", "card0-eDP-2-
 backlight" };

const char *paths[] = {"intel_backlight","card0-eDP-2-backlight"};

Quoted 6 lines


        igt_fixture {
                enum pipe pipe;

tests/i915/i915_pm_backlight.c +0 -0
@@ -203,11 +205,14 @@ igt_main
                 igt_display_require(&display,
 drm_open_driver(DRIVER_INTEL));
Quoted 8 lines


                /* Get the max value and skip the whole test if sysfs interface not available */
-               igt_skip_on(backlight_read(&old, "brightness")); -               igt_assert(backlight_read(&context.max, "max_brightness") > -1);
+               for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {

ARRAY_SIZE

Quoted 6 lines

+                       context.path = paths[i];
+                       igt_skip_on(backlight_read(&old, "brightness", &context));
+                       igt_assert(backlight_read(&context.max, "max_brightness", &context) > -1);
+               }

I don't think we want to skip completely if second panel is missing.

How about using dynamic approach? Add check if context.path exists and add dynamic subtest based on that. See patch set from Jeevan here as an example:

https://patchwork.freedesktop.org/series/108299/

Quoted 51 lines


                /* should be ../../cardX-$output */
-               igt_assert_lt(12, readlink(BACKLIGHT_PATH "/device", full_name, sizeof(full_name) - 1));
+               igt_assert_lt(12, readlink(BACKLIGHT_PATH "/intel_backlight/device", full_name, sizeof(full_name) - 1)); name = basename(full_name);

                for_each_pipe_with_valid_output(&display, pipe, output) {

tests/i915/i915_pm_backlight.c +0 -0
@@ -234,22 +239,25 @@ igt_main

                igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); igt_pm_enable_sata_link_power_management(); }
+       for (size_t j = 0; j < sizeof(paths) / sizeof(paths[0]); j++) {
+               context.path = paths[j];
+
+               igt_subtest("basic-brightness")
+                       test_brightness(&context);
+               igt_subtest("bad-brightness")
+                       test_bad_brightness(&context);
+               igt_subtest("fade")
+                       test_fade(&context);
+               igt_subtest("fade_with_dpms")
+                       test_fade_with_dpms(&context, output); +               igt_subtest("fade_with_suspend")
+                       test_fade_with_suspend(&context, output);
-       igt_subtest("basic-brightness")
-               test_brightness(&context);
-       igt_subtest("bad-brightness")
-               test_bad_brightness(&context);
-       igt_subtest("fade")
-               test_fade(&context);
-       igt_subtest("fade_with_dpms")
-               test_fade_with_dpms(&context, output);
-       igt_subtest("fade_with_suspend")
-               test_fade_with_suspend(&context, output); -
-       igt_fixture {
                /* Restore old brightness */
-               backlight_write(old, "brightness");
+                backlight_write(old, "brightness", &context); +       }

+       igt_fixture {
                igt_display_fini(&display); igt_remove_fb(display.drm_fd, &fb); igt_pm_restore_sata_link_power_management();

author Reviewed-by
#3 lore raw

Re: [igt-dev] [PATCH i-g-t, v5, 05/52] tests/kms_atomic_interruptible: Add support for Bigjoiner

Quoted 10 lines · Bhanuprakash Modem

This patch will add a check to Skip the subtest if a selected pipe/output combo won't support Bigjoiner or 8K mode.

Example:
* Pipe-D wont support a mode > 5K
* To use 8K mode on a pipe then consecutive pipe must be available & free.

V2: - Use updated helper name

---
 tests/kms_atomic_interruptible.c | 40 ++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
Quoted 112 lines
tests/kms_atomic_interruptible.c +19 -0
index f461a15c..74b2e246 100644
@@ -82,11 +82,15 @@  static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t
 	igt_plane_t *primary, *plane;
 	int block;
 
+	igt_info("Using (pipe %s + %s) to run the subtest.\n",
+		 kmstest_pipe_name(pipe), igt_output_name(output));
+
 	/*
 	 * Make sure we start with everything disabled to force a real modeset.
 	 * igt_display_require only sets sw state, and assumes the first test
 	 * doesn't care about hw state.
 	 */
+	igt_display_reset(display);
 	igt_display_commit2(display, COMMIT_ATOMIC);
 
 	igt_output_set_pipe(output, pipe);
@@ -265,6 +269,21 @@  static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t
 	igt_remove_fb(display->drm_fd, &fb);
 }
 
+static bool pipe_output_combo_valid(igt_display_t *display,
+				    enum pipe pipe, igt_output_t *output)
+{
+	bool ret = true;
+
+	igt_display_reset(display);
+
+	igt_output_set_pipe(output, pipe);
+	if (!i915_pipe_output_combo_valid(display))
+		ret = false;
+	igt_output_set_pipe(output, PIPE_NONE);
+
+	return ret;
+}
+

igt_main

{
	igt_display_t display;
tests/kms_atomic_interruptible.c +21 -0
@@ -286,6 +305,9 @@  igt_main
 	igt_describe("Tests the interrupt properties of legacy modeset");
 	igt_subtest_with_dynamic("legacy-setmode") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_legacy_modeset, DRM_PLANE_TYPE_PRIMARY);
 			break;
@@ -295,6 +317,9 @@  igt_main
 	igt_describe("Tests the interrupt properties of atomic modeset");
 	igt_subtest_with_dynamic("atomic-setmode") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_atomic_modeset, DRM_PLANE_TYPE_PRIMARY);
 			break;
@@ -304,6 +329,9 @@  igt_main
 	igt_describe("Tests the interrupt properties for DPMS");
 	igt_subtest_with_dynamic("legacy-dpms") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_legacy_dpms, DRM_PLANE_TYPE_PRIMARY);
 			break;
@@ -313,6 +341,9 @@  igt_main
 	igt_describe("Tests the interrupt properties for pageflip");
 	igt_subtest_with_dynamic("legacy-pageflip") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_pageflip, DRM_PLANE_TYPE_PRIMARY);
 			break;
@@ -322,6 +353,9 @@  igt_main
 	igt_describe("Tests the interrupt properties for cursor");
 	igt_subtest_with_dynamic("legacy-cursor") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_setcursor, DRM_PLANE_TYPE_CURSOR);
 			break;
@@ -331,6 +365,9 @@  igt_main
 	igt_describe("Tests the interrupt properties for primary plane");
 	igt_subtest_with_dynamic("universal-setplane-primary") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_setplane, DRM_PLANE_TYPE_PRIMARY);
 			break;
@@ -340,6 +377,9 @@  igt_main
 	igt_describe("Tests the interrupt properties for cursor plane");
 	igt_subtest_with_dynamic("universal-setplane-cursor") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_setplane, DRM_PLANE_TYPE_CURSOR);
 			break;
author Reviewed-by
#4 lore raw

Re: [igt-dev] [i-g-t v5 05/52] tests/kms_atomic_interruptible: Add support for Bigjoiner

Quoted 10 lines · Bhanuprakash Modem

This patch will add a check to Skip the subtest if a selected pipe/output combo won't support Bigjoiner or 8K mode.

Example:
* Pipe-D wont support a mode > 5K
* To use 8K mode on a pipe then consecutive pipe must be available & free.

V2: - Use updated helper name

---
 tests/kms_atomic_interruptible.c | 40 ++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
Quoted 112 lines
tests/kms_atomic_interruptible.c +18 -0
index f461a15c..74b2e246 100644
@@ -82,11 +82,15 @@  static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t
 	igt_plane_t *primary, *plane;
 	int block;
 
+	igt_info("Using (pipe %s + %s) to run the subtest.\n",
+		 kmstest_pipe_name(pipe), igt_output_name(output));
+
 	/*
 	 * Make sure we start with everything disabled to force a real modeset.
 	 * igt_display_require only sets sw state, and assumes the first test
 	 * doesn't care about hw state.
 	 */
+	igt_display_reset(display);
 	igt_display_commit2(display, COMMIT_ATOMIC);
 
 	igt_output_set_pipe(output, pipe);
@@ -265,6 +269,21 @@  static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t
 	igt_remove_fb(display->drm_fd, &fb);
 }
 
+static bool pipe_output_combo_valid(igt_display_t *display,
+				    enum pipe pipe, igt_output_t *output) {
+	bool ret = true;
+
+	igt_display_reset(display);
+
+	igt_output_set_pipe(output, pipe);
+	if (!i915_pipe_output_combo_valid(display))
+		ret = false;
+	igt_output_set_pipe(output, PIPE_NONE);
+
+	return ret;
+}
+

igt_main

{
	igt_display_t display;
tests/kms_atomic_interruptible.c +21 -0
@@ -286,6 +305,9 @@  igt_main
 	igt_describe("Tests the interrupt properties of legacy modeset");
 	igt_subtest_with_dynamic("legacy-setmode") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_legacy_modeset, DRM_PLANE_TYPE_PRIMARY);
 			break;
@@ -295,6 +317,9 @@  igt_main
 	igt_describe("Tests the interrupt properties of atomic modeset");
 	igt_subtest_with_dynamic("atomic-setmode") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_atomic_modeset, DRM_PLANE_TYPE_PRIMARY);
 			break;
@@ -304,6 +329,9 @@  igt_main
 	igt_describe("Tests the interrupt properties for DPMS");
 	igt_subtest_with_dynamic("legacy-dpms") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_legacy_dpms, DRM_PLANE_TYPE_PRIMARY);
 			break;
@@ -313,6 +341,9 @@  igt_main
 	igt_describe("Tests the interrupt properties for pageflip");
 	igt_subtest_with_dynamic("legacy-pageflip") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_pageflip, DRM_PLANE_TYPE_PRIMARY);
 			break;
@@ -322,6 +353,9 @@  igt_main
 	igt_describe("Tests the interrupt properties for cursor");
 	igt_subtest_with_dynamic("legacy-cursor") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_setcursor, DRM_PLANE_TYPE_CURSOR);
 			break;
@@ -331,6 +365,9 @@  igt_main
 	igt_describe("Tests the interrupt properties for primary plane");
 	igt_subtest_with_dynamic("universal-setplane-primary") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_setplane, DRM_PLANE_TYPE_PRIMARY);
 			break;
@@ -340,6 +377,9 @@  igt_main
 	igt_describe("Tests the interrupt properties for cursor plane");
 	igt_subtest_with_dynamic("universal-setplane-cursor") {
 		for_each_pipe_with_valid_output(&display, pipe, output) {
+			if (!pipe_output_combo_valid(&display, pipe, output))
+				continue;
+
 			igt_dynamic_f("%s-pipe-%s", igt_output_name(output), kmstest_pipe_name(pipe))
 				run_plane_test(&display, pipe, output, test_setplane, DRM_PLANE_TYPE_CURSOR);
 			break;
author Reviewed-by
#5 lore raw

Re: [igt-dev] [i-g-t v5 06/52] tests/kms_atomic_transition: Add support for Bigjoiner

In reply to Gupta, Nidhi1
Quoted 10 lines · Bhanuprakash Modem

This patch will add a check to Skip the subtest if a selected pipe/output combo won't support Bigjoiner or 8K mode.

Example:
* Pipe-D wont support a mode > 5K
* To use 8K mode on a pipe then consecutive pipe must be available & free.

V2: - Use updated helper name

Quoted 106 lines

---
tests/kms_atomic_transition.c | 50 ++++++++++++++++++++++++++++++++---

1 file changed, 46 insertions(+), 4 deletions(-)
tests/kms_atomic_transition.c +46 -4
index 6d2ebbbf..5285585f 100644
@@ -68,6 +68,10 @@  run_primary_test(data_t *data, enum pipe pipe, igt_output_t *output)
 	unsigned flags = DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET;
 
 	igt_display_reset(&data->display);
+
+	igt_info("Using (pipe %s + %s) to run the subtest.\n",
+		 kmstest_pipe_name(pipe), igt_output_name(output));
+
 	igt_output_set_pipe(output, pipe);
 	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
 
@@ -487,6 +491,9 @@  run_transition_test(data_t *data, enum pipe pipe, igt_output_t *output,
 	unsigned flags = 0;
 	int ret;
 
+	igt_info("Using (pipe %s + %s) to run the subtest.\n",
+		 kmstest_pipe_name(pipe), igt_output_name(output));
+
 	if (fencing)
 		prepare_fencing(data, pipe);
 	else
@@ -753,8 +760,13 @@  static unsigned set_combinations(data_t *data, unsigned mask, struct igt_fb *fb)
 			if (output->pending_pipe != PIPE_NONE)
 				continue;
 
-			mode = igt_output_get_mode(output);
-			break;
+			igt_output_set_pipe(output, pipe);
+			if (i915_pipe_output_combo_valid(&data->display)) {
+				mode = igt_output_get_mode(output);
+				break;
+			} else {
+				igt_output_set_pipe(output, PIPE_NONE);
+			}
 		}
 
 		if (!mode)
@@ -840,8 +852,17 @@  retry:
 				continue;
 
 			igt_output_set_pipe(output, i);
-			mode = igt_output_get_mode(output);
-			break;
+			if (i915_pipe_output_combo_valid(&data->display)) {
+				mode = igt_output_get_mode(output);
+
+				igt_info("(pipe %s + %s), mode:",
+					 kmstest_pipe_name(i), igt_output_name(output));
+				kmstest_dump_mode(mode);
+
+				break;
+			} else {
+				igt_output_set_pipe(output, PIPE_NONE);
+			}
 		}
 
 		if (mode) {
@@ -980,6 +1001,21 @@  static void run_modeset_transition(data_t *data, int requested_outputs, bool non
 	igt_remove_fb(data->drm_fd, &data->fbs[1]);
 }
 
+static bool pipe_output_combo_valid(igt_display_t *display,
+				    enum pipe pipe, igt_output_t *output)
+{
+	bool ret = true;
+
+	igt_display_reset(display);
+
+	igt_output_set_pipe(output, pipe);
+	if (!i915_pipe_output_combo_valid(display))
+		ret = false;
+	igt_output_set_pipe(output, PIPE_NONE);
+
+	return ret;
+}
+
 static int opt_handler(int opt, int opt_index, void *_data)
 {
 	data_t *data = _data;
@@ -1079,6 +1115,9 @@  igt_main_args("", long_opts, help_str, opt_handler, &data)
 			if (pipe_count == 2 * count && !data.extended)
 				break;
 
+			if (!pipe_output_combo_valid(&data.display, pipe, output))
+				continue;
+
 			pipe_count++;
 			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe), igt_output_name(output))
 				run_primary_test(&data, pipe, output);
@@ -1108,6 +1147,9 @@  igt_main_args("", long_opts, help_str, opt_handler, &data)
 				if (pipe_count == 2 * count && !data.extended)
 					break;
 
+				if (!pipe_output_combo_valid(&data.display, pipe, output))
+					continue;
+
 				pipe_count++;
 				igt_dynamic_f("pipe-%s-%s",
 					      kmstest_pipe_name(pipe),
#6 lore raw
In reply to Nidhi Gupta
Quoted 101 lines · Nidhi Gupta

Since driver can now support multiple eDPs and Debugfs structure for backlight changed per connector the test should then iterate through all eDP connectors.

---
 tests/i915/i915_pm_backlight.c | 70 +++++++++++++++++++---------------
 1 file changed, 39 insertions(+), 31 deletions(-)
tests/i915/i915_pm_backlight.c +16 -15
index cafae7f7..1532193b 100644
@@ -37,25 +37,26 @@
 
 struct context {
 	int max;
+	const char *path;
 };
 
 
 #define TOLERANCE 5 /* percent */
-#define BACKLIGHT_PATH "/sys/class/backlight/intel_backlight"
+#define BACKLIGHT_PATH "/sys/class/backlight"
 
 #define FADESTEPS 10
 #define FADESPEED 100 /* milliseconds between steps */
 
 IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
 
-static int backlight_read(int *result, const char *fname)
+static int backlight_read(int *result, const char *fname, struct context *context)
 {
 	int fd;
 	char full[PATH_MAX];
 	char dst[64];
 	int r, e;
 
-	igt_assert(snprintf(full, PATH_MAX, "%s/%s", BACKLIGHT_PATH, fname) < PATH_MAX);
+	igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname) < PATH_MAX);
 
 	fd = open(full, O_RDONLY);
 	if (fd == -1)
@@ -73,14 +74,14 @@ static int backlight_read(int *result, const char *fname)
 	return errno;
 }
 
-static int backlight_write(int value, const char *fname)
+static int backlight_write(int value, const char *fname, struct context *context)
 {
 	int fd;
 	char full[PATH_MAX];
 	char src[64];
 	int len;
 
-	igt_assert(snprintf(full, PATH_MAX, "%s/%s", BACKLIGHT_PATH, fname) < PATH_MAX);
+	igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname) < PATH_MAX);
 	fd = open(full, O_WRONLY);
 	if (fd == -1)
 		return -errno;
@@ -100,12 +101,12 @@ static void test_and_verify(struct context *context, int val)
 	const int tolerance = val * TOLERANCE / 100;
 	int result;
 
-	igt_assert_eq(backlight_write(val, "brightness"), 0);
-	igt_assert_eq(backlight_read(&result, "brightness"), 0);
+	igt_assert_eq(backlight_write(val, "brightness", context), 0);
+	igt_assert_eq(backlight_read(&result, "brightness", context), 0);
 	/* Check that the exact value sticks */
 	igt_assert_eq(result, val);
 
-	igt_assert_eq(backlight_read(&result, "actual_brightness"), 0);
+	igt_assert_eq(backlight_read(&result, "actual_brightness", context), 0);
 	/* Some rounding may happen depending on hw */
 	igt_assert_f(result >= max(0, val - tolerance) &&
 		     result <= min(context->max, val + tolerance),
@@ -124,16 +125,16 @@ static void test_bad_brightness(struct context *context)
 {
 	int val;
 	/* First write some sane value */
-	backlight_write(context->max / 2, "brightness");
+	backlight_write(context->max / 2, "brightness", context);
 	/* Writing invalid values should fail and not change the value */
-	igt_assert_lt(backlight_write(-1, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(-1, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
-	igt_assert_lt(backlight_write(context->max + 1, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(context->max + 1, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
-	igt_assert_lt(backlight_write(INT_MAX, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(INT_MAX, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
 }
 

tests/i915/i915_pm_backlight.c igt_main · line 190

Quoted 4 lines
tests/i915/i915_pm_backlight.c +1 -0
@@ -186,6 +187,7 @@ igt_main
 	igt_display_t display;
 	igt_output_t *output;
 	struct igt_fb fb;
+	char paths[][50] = { "intel_backlight", "card0-eDP-2-backlight" };

Hardcoding "intel_backlight" is ok but is it possible to construct that other name from the used device? "eDP-2" is easy with igt_output_name, but I'm not sure how to elegantly get "card0" out of an fd...

Also consider having dynamic subtests instead for each output that has backlight controls available.

Signature · 1 line
Petri Latvala
Quoted 63 lines
tests/i915/i915_pm_backlight.c +22 -16
 	igt_fixture {
 		enum pipe pipe;
@@ -203,11 +205,14 @@ igt_main
 		igt_display_require(&display, drm_open_driver(DRIVER_INTEL));
 
 		/* Get the max value and skip the whole test if sysfs interface not available */
-		igt_skip_on(backlight_read(&old, "brightness"));
-		igt_assert(backlight_read(&context.max, "max_brightness") > -1);
+		for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
+			context.path = paths[i];
+			igt_skip_on(backlight_read(&old, "brightness", &context));
+			igt_assert(backlight_read(&context.max, "max_brightness", &context) > -1);
+		}
 
 		/* should be ../../cardX-$output */
-		igt_assert_lt(12, readlink(BACKLIGHT_PATH "/device", full_name, sizeof(full_name) - 1));
+		igt_assert_lt(12, readlink(BACKLIGHT_PATH "/intel_backlight/device", full_name, sizeof(full_name) - 1));
 		name = basename(full_name);
 
 		for_each_pipe_with_valid_output(&display, pipe, output) {
@@ -234,22 +239,25 @@ igt_main
 		igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
 		igt_pm_enable_sata_link_power_management();
 	}
+	for (size_t j = 0; j < sizeof(paths) / sizeof(paths[0]); j++) {
+		context.path = paths[j];
+
+		igt_subtest("basic-brightness")
+			test_brightness(&context);
+		igt_subtest("bad-brightness")
+			test_bad_brightness(&context);
+		igt_subtest("fade")
+			test_fade(&context);
+		igt_subtest("fade_with_dpms")
+			test_fade_with_dpms(&context, output);
+		igt_subtest("fade_with_suspend")
+			test_fade_with_suspend(&context, output);
 
-	igt_subtest("basic-brightness")
-		test_brightness(&context);
-	igt_subtest("bad-brightness")
-		test_bad_brightness(&context);
-	igt_subtest("fade")
-		test_fade(&context);
-	igt_subtest("fade_with_dpms")
-		test_fade_with_dpms(&context, output);
-	igt_subtest("fade_with_suspend")
-		test_fade_with_suspend(&context, output);
-
-	igt_fixture {
 		/* Restore old brightness */
-		backlight_write(old, "brightness");
+                backlight_write(old, "brightness", &context);
+	}
 
+	igt_fixture {
 		igt_display_fini(&display);
 		igt_remove_fb(display.drm_fd, &fb);
 		igt_pm_restore_sata_link_power_management();
Signature · 1 line
2.36.0
#7 lore raw
Quoted 101 lines · Petri Latvala
Quoted 100 lines · Nidhi Gupta

Since driver can now support multiple eDPs and Debugfs structure for backlight changed per connector the test should then iterate through all eDP connectors.

---
 tests/i915/i915_pm_backlight.c | 70 +++++++++++++++++++---------------
 1 file changed, 39 insertions(+), 31 deletions(-)
tests/i915/i915_pm_backlight.c +16 -15
index cafae7f7..1532193b 100644
@@ -37,25 +37,26 @@
 
 struct context {
 	int max;
+	const char *path;
 };
 
 
 #define TOLERANCE 5 /* percent */
-#define BACKLIGHT_PATH "/sys/class/backlight/intel_backlight"
+#define BACKLIGHT_PATH "/sys/class/backlight"
 
 #define FADESTEPS 10
 #define FADESPEED 100 /* milliseconds between steps */
 
 IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
 
-static int backlight_read(int *result, const char *fname)
+static int backlight_read(int *result, const char *fname, struct context *context)
 {
 	int fd;
 	char full[PATH_MAX];
 	char dst[64];
 	int r, e;
 
-	igt_assert(snprintf(full, PATH_MAX, "%s/%s", BACKLIGHT_PATH, fname) < PATH_MAX);
+	igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname) < PATH_MAX);
 
 	fd = open(full, O_RDONLY);
 	if (fd == -1)
@@ -73,14 +74,14 @@ static int backlight_read(int *result, const char *fname)
 	return errno;
 }
 
-static int backlight_write(int value, const char *fname)
+static int backlight_write(int value, const char *fname, struct context *context)
 {
 	int fd;
 	char full[PATH_MAX];
 	char src[64];
 	int len;
 
-	igt_assert(snprintf(full, PATH_MAX, "%s/%s", BACKLIGHT_PATH, fname) < PATH_MAX);
+	igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname) < PATH_MAX);
 	fd = open(full, O_WRONLY);
 	if (fd == -1)
 		return -errno;
@@ -100,12 +101,12 @@ static void test_and_verify(struct context *context, int val)
 	const int tolerance = val * TOLERANCE / 100;
 	int result;
 
-	igt_assert_eq(backlight_write(val, "brightness"), 0);
-	igt_assert_eq(backlight_read(&result, "brightness"), 0);
+	igt_assert_eq(backlight_write(val, "brightness", context), 0);
+	igt_assert_eq(backlight_read(&result, "brightness", context), 0);
 	/* Check that the exact value sticks */
 	igt_assert_eq(result, val);
 
-	igt_assert_eq(backlight_read(&result, "actual_brightness"), 0);
+	igt_assert_eq(backlight_read(&result, "actual_brightness", context), 0);
 	/* Some rounding may happen depending on hw */
 	igt_assert_f(result >= max(0, val - tolerance) &&
 		     result <= min(context->max, val + tolerance),
@@ -124,16 +125,16 @@ static void test_bad_brightness(struct context *context)
 {
 	int val;
 	/* First write some sane value */
-	backlight_write(context->max / 2, "brightness");
+	backlight_write(context->max / 2, "brightness", context);
 	/* Writing invalid values should fail and not change the value */
-	igt_assert_lt(backlight_write(-1, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(-1, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
-	igt_assert_lt(backlight_write(context->max + 1, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(context->max + 1, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
-	igt_assert_lt(backlight_write(INT_MAX, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(INT_MAX, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
 }
 
Quoted 10 lines

tests/i915/i915_pm_backlight.c igt_main · line 190

Quoted 5 lines
tests/i915/i915_pm_backlight.c +1 -0
@@ -186,6 +187,7 @@ igt_main
 	igt_display_t display;
 	igt_output_t *output;
 	struct igt_fb fb;
+	char paths[][50] = { "intel_backlight", "card0-eDP-2-backlight" };

Hardcoding "intel_backlight" is ok but is it possible to construct that other name from the used device? "eDP-2" is easy with igt_output_name, but I'm not sure how to elegantly get "card0" out of an fd...

They're symlinks of the form:

intel_backlight -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight

so should be possible to figure out.

BR,
Jani.

Quoted 4 lines

Also consider having dynamic subtests instead for each output that has backlight controls available.

Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
#8 lore raw
In reply to Nidhi Gupta
Quoted 149 lines · Nidhi Gupta

Since driver can now support multiple eDPs and Debugfs structure for backlight changed per connector the test should then iterate through all eDP connectors.

---
 tests/i915/i915_pm_backlight.c | 70 +++++++++++++++++++---------------
 1 file changed, 39 insertions(+), 31 deletions(-)
tests/i915/i915_pm_backlight.c +36 -23
index cafae7f7..1532193b 100644
@@ -37,25 +37,26 @@
 
 struct context {
 	int max;
+	const char *path;
 };
 
 
 #define TOLERANCE 5 /* percent */
-#define BACKLIGHT_PATH "/sys/class/backlight/intel_backlight"
+#define BACKLIGHT_PATH "/sys/class/backlight"
 
 #define FADESTEPS 10
 #define FADESPEED 100 /* milliseconds between steps */
 
 IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
 
-static int backlight_read(int *result, const char *fname)
+static int backlight_read(int *result, const char *fname, struct context *context)
 {
 	int fd;
 	char full[PATH_MAX];
 	char dst[64];
 	int r, e;
 
-	igt_assert(snprintf(full, PATH_MAX, "%s/%s", BACKLIGHT_PATH, fname) < PATH_MAX);
+	igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname) < PATH_MAX);
 
 	fd = open(full, O_RDONLY);
 	if (fd == -1)
@@ -73,14 +74,14 @@ static int backlight_read(int *result, const char *fname)
 	return errno;
 }
 
-static int backlight_write(int value, const char *fname)
+static int backlight_write(int value, const char *fname, struct context *context)
 {
 	int fd;
 	char full[PATH_MAX];
 	char src[64];
 	int len;
 
-	igt_assert(snprintf(full, PATH_MAX, "%s/%s", BACKLIGHT_PATH, fname) < PATH_MAX);
+	igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname) < PATH_MAX);
 	fd = open(full, O_WRONLY);
 	if (fd == -1)
 		return -errno;
@@ -100,12 +101,12 @@ static void test_and_verify(struct context *context, int val)
 	const int tolerance = val * TOLERANCE / 100;
 	int result;
 
-	igt_assert_eq(backlight_write(val, "brightness"), 0);
-	igt_assert_eq(backlight_read(&result, "brightness"), 0);
+	igt_assert_eq(backlight_write(val, "brightness", context), 0);
+	igt_assert_eq(backlight_read(&result, "brightness", context), 0);
 	/* Check that the exact value sticks */
 	igt_assert_eq(result, val);
 
-	igt_assert_eq(backlight_read(&result, "actual_brightness"), 0);
+	igt_assert_eq(backlight_read(&result, "actual_brightness", context), 0);
 	/* Some rounding may happen depending on hw */
 	igt_assert_f(result >= max(0, val - tolerance) &&
 		     result <= min(context->max, val + tolerance),
@@ -124,16 +125,16 @@ static void test_bad_brightness(struct context *context)
 {
 	int val;
 	/* First write some sane value */
-	backlight_write(context->max / 2, "brightness");
+	backlight_write(context->max / 2, "brightness", context);
 	/* Writing invalid values should fail and not change the value */
-	igt_assert_lt(backlight_write(-1, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(-1, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
-	igt_assert_lt(backlight_write(context->max + 1, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(context->max + 1, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
-	igt_assert_lt(backlight_write(INT_MAX, "brightness"), 0);
-	backlight_read(&val, "brightness");
+	igt_assert_lt(backlight_write(INT_MAX, "brightness", context), 0);
+	backlight_read(&val, "brightness", context);
 	igt_assert_eq(val, context->max / 2);
 }
 
@@ -186,6 +187,7 @@ igt_main
 	igt_display_t display;
 	igt_output_t *output;
 	struct igt_fb fb;
+	char paths[][50] = { "intel_backlight", "card0-eDP-2-backlight" };
 
 	igt_fixture {
 		enum pipe pipe;
@@ -203,11 +205,14 @@ igt_main
 		igt_display_require(&display, drm_open_driver(DRIVER_INTEL));
 
 		/* Get the max value and skip the whole test if sysfs interface not available */
-		igt_skip_on(backlight_read(&old, "brightness"));
-		igt_assert(backlight_read(&context.max, "max_brightness") > -1);
+		for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
+			context.path = paths[i];
+			igt_skip_on(backlight_read(&old, "brightness", &context));
+			igt_assert(backlight_read(&context.max, "max_brightness", &context) > -1);
+		}
 
 		/* should be ../../cardX-$output */
-		igt_assert_lt(12, readlink(BACKLIGHT_PATH "/device", full_name, sizeof(full_name) - 1));
+		igt_assert_lt(12, readlink(BACKLIGHT_PATH "/intel_backlight/device", full_name, sizeof(full_name) - 1));
 		name = basename(full_name);
 
 		for_each_pipe_with_valid_output(&display, pipe, output) {
@@ -234,22 +239,25 @@ igt_main
 		igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
 		igt_pm_enable_sata_link_power_management();
 	}
+	for (size_t j = 0; j < sizeof(paths) / sizeof(paths[0]); j++) {
+		context.path = paths[j];
+
+		igt_subtest("basic-brightness")
+			test_brightness(&context);
+		igt_subtest("bad-brightness")
+			test_bad_brightness(&context);
+		igt_subtest("fade")
+			test_fade(&context);
+		igt_subtest("fade_with_dpms")
+			test_fade_with_dpms(&context, output);
+		igt_subtest("fade_with_suspend")
+			test_fade_with_suspend(&context, output);
 
-	igt_subtest("basic-brightness")
-		test_brightness(&context);
-	igt_subtest("bad-brightness")
-		test_bad_brightness(&context);
-	igt_subtest("fade")

tests/i915/i915_pm_backlight.c igt_main · line 257

Quoted 10 lines
tests/i915/i915_pm_backlight.c +1 -8
-		test_fade(&context);
-	igt_subtest("fade_with_dpms")
-		test_fade_with_dpms(&context, output);
-	igt_subtest("fade_with_suspend")
-		test_fade_with_suspend(&context, output);
-
-	igt_fixture {
 		/* Restore old brightness */
-		backlight_write(old, "brightness");
+                backlight_write(old, "brightness", &context);

Also, this backlight_write is outside of a fixture or subtest, you can't do that.

Signature · 1 line
Petri Latvala
Quoted 9 lines
tests/i915/i915_pm_backlight.c +2 -0
+	}
 
+	igt_fixture {
 		igt_display_fini(&display);
 		igt_remove_fb(display.drm_fd, &fb);
 		igt_pm_restore_sata_link_power_management();
Signature · 1 line
2.36.0