summaryrefslogtreecommitdiff
path: root/tests/pm_backlight.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2017-10-10 17:57:29 +0200
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2017-10-12 16:43:06 +0200
commit69fbd44e269bd5e7e751a34e4d846e6cf3fa3eb3 (patch)
treea310cb05af1859abd4f20ca19c24086e17f80b82 /tests/pm_backlight.c
parente9f4c3170c76bb5153e9d1d7212b2256a44b1725 (diff)
tests/pm_backlight: Enable connected output to allow tests to succeed, v4.
If the connected output is disabled before this test is run, then the test will fail because actual_brightness stays at 0 instead of the value of the desired brightness. Fix this by reading intel_backlight/device for the output name, and enable that output at start of this test. Changes since v1: - Enable the connected output, instead of enabling all outputs. Changes since v2: - Set a dummy fb, just in case. Changes since v3: - Use igt_output_get_plane_type, not get_plane. Sample failure: IGT-Version: 1.20-g01c550a27986 (x86_64) (Linux: 4.14.0-rc3-fbconhax+ x86_64) (pm_backlight:1203) CRITICAL: Test assertion failure function test_and_verify, file pm_backlight.c:111: (pm_backlight:1203) CRITICAL: Failed assertion: ({ typeof(0) _a = (0); typeof(val - tolerance) _b = (val - tolerance); _a > _b ? _a : _b; }) <= result (pm_backlight:1203) CRITICAL: error: 91200 > 0 Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Diffstat (limited to 'tests/pm_backlight.c')
-rw-r--r--tests/pm_backlight.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/pm_backlight.c b/tests/pm_backlight.c
index 8258d4e4..a695f909 100644
--- a/tests/pm_backlight.c
+++ b/tests/pm_backlight.c
@@ -155,13 +155,56 @@ igt_main
{
struct context context = {0};
int old;
+ igt_display_t display;
+ struct igt_fb fb;
igt_skip_on_simulation();
igt_fixture {
+ enum pipe pipe;
+ igt_output_t *output;
+ bool found = false;
+ char full_name[32] = {};
+ char *name;
+ drmModeModeInfo *mode;
+ igt_plane_t *primary;
+
/* 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);
+
+ /*
+ * Backlight tests requires the output to be enabled,
+ * try to enable all.
+ */
+ kmstest_set_vt_graphics_mode();
+ igt_display_init(&display, drm_open_driver(DRIVER_INTEL));
+
+ /* should be ../../cardX-$output */
+ igt_assert_lt(12, readlink(BACKLIGHT_PATH "/device", full_name, sizeof(full_name) - 1));
+ name = basename(full_name);
+
+ for_each_pipe_with_valid_output(&display, pipe, output) {
+ if (strcmp(name + 6, output->name))
+ continue;
+
+ found = true;
+ break;
+ }
+
+ igt_assert_f(found, "Could not map \"%s\" to output (%s?)\n", name, name + 6);
+
+ igt_output_set_pipe(output, pipe);
+ mode = igt_output_get_mode(output);
+
+ igt_create_pattern_fb(display.drm_fd,
+ mode->hdisplay, mode->vdisplay,
+ DRM_FORMAT_XRGB8888,
+ LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+ primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+ igt_plane_set_fb(primary, &fb);
+
+ igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
}
igt_subtest("basic-brightness")
@@ -174,5 +217,9 @@ igt_main
igt_fixture {
/* Restore old brightness */
backlight_write(old, "brightness");
+
+ igt_display_fini(&display);
+ igt_remove_fb(display.drm_fd, &fb);
+ close(display.drm_fd);
}
}