@@ -103,8 +103,9 @@ static bool fbc_is_enabled(int fd)
return strstr(buf, "FBC enabled\n");
}
-static bool fbc_wait_until_enabled(int fd)
+static bool fbc_wait_until_enabled(int fd, bool enabled)
{
+ enabled = enabled;
return igt_wait(fbc_is_enabled(fd), 5000, 1);
}
@@ -124,6 +125,13 @@ static void set_mode_for_one_screen(struct drm_info *drm, struct igt_fb *fb,
if (c->connection == DRM_MODE_CONNECTED && c->count_modes &&
connector_possible(c)) {
+ if (c->connector_type == DRM_MODE_CONNECTOR_eDP) {
+ bool bret;
+
+ bret = igt_psr_find_good_mode(c, &mode);
+ if (bret)
+ break;
+ }
mode = &c->modes[0];
break;
}
@@ -147,35 +155,9 @@ static void set_mode_for_one_screen(struct drm_info *drm, struct igt_fb *fb,
igt_assert_eq(rc, 0);
}
-static bool psr_supported_on_chipset(int fd)
-{
- char buf[256];
-
- igt_debugfs_read(fd, "i915_edp_psr_status", buf);
- return strstr(buf, "Sink_Support: yes\n");
-}
-
-static bool connector_can_psr(drmModeConnectorPtr connector)
-{
- return (connector->connector_type == DRM_MODE_CONNECTOR_eDP);
-}
-
-static bool psr_is_enabled(int fd)
-{
- char buf[256];
-
- igt_debugfs_read(fd, "i915_edp_psr_status", buf);
- return strstr(buf, "\nActive: yes\n");
-}
-
-static bool psr_wait_until_enabled(int fd)
-{
- return igt_wait(psr_is_enabled(fd), 5000, 1);
-}
-
struct feature {
bool (*supported_on_chipset)(int fd);
- bool (*wait_until_enabled)(int fd);
+ bool (*wait_until_enabled)(int fd, bool status);
bool (*connector_possible_fn)(drmModeConnectorPtr connector);
const char *param_name;
} fbc = {
@@ -184,9 +166,9 @@ struct feature {
.connector_possible_fn = connector_can_fbc,
.param_name = "enable_fbc",
}, psr = {
- .supported_on_chipset = psr_supported_on_chipset,
- .wait_until_enabled = psr_wait_until_enabled,
- .connector_possible_fn = connector_can_psr,
+ .supported_on_chipset = igt_psr_sink_support,
+ .wait_until_enabled = igt_psr_await_status,
+ .connector_possible_fn = igt_psr_valid_connector,
.param_name = "enable_psr",
};
@@ -210,17 +192,17 @@ static void subtest(struct feature *feature, bool suspend)
kmstest_unset_all_crtcs(drm.fd, drm.res);
wait_user("Modes unset.");
- igt_assert(!feature->wait_until_enabled(drm.fd));
+ igt_assert(!feature->wait_until_enabled(drm.fd, true));
set_mode_for_one_screen(&drm, &fb, feature->connector_possible_fn);
wait_user("Screen set.");
- igt_assert(feature->wait_until_enabled(drm.fd));
+ igt_assert(feature->wait_until_enabled(drm.fd, true));
if (suspend) {
igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
SUSPEND_TEST_NONE);
sleep(5);
- igt_assert(feature->wait_until_enabled(drm.fd));
+ igt_assert(feature->wait_until_enabled(drm.fd, true));
}
igt_remove_fb(drm.fd, &fb);
@@ -230,13 +212,13 @@ static void subtest(struct feature *feature, bool suspend)
sleep(3);
wait_user("Back to fbcon.");
- igt_assert(!feature->wait_until_enabled(drm.fd));
+ igt_assert(!feature->wait_until_enabled(drm.fd, true));
if (suspend) {
igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
SUSPEND_TEST_NONE);
sleep(5);
- igt_assert(!feature->wait_until_enabled(drm.fd));
+ igt_assert(!feature->wait_until_enabled(drm.fd, true));
}
}
@@ -266,7 +248,7 @@ igt_main
subtest(&fbc, true);
igt_subtest("psr-suspend")
subtest(&psr, true);
-
+
igt_fixture
teardown_environment();
}
@@ -70,7 +70,7 @@ typedef struct {
uint32_t crtc_id;
igt_display_t display;
drm_intel_bufmgr *bufmgr;
- struct igt_fb fb_green, fb_white;
+ struct igt_fb fb_green, fb_white, fb_blue;;
igt_plane_t *primary, *sprite, *cursor;
int mod_size;
int mod_stride;
@@ -78,6 +78,7 @@ typedef struct {
igt_output_t *output;
} data_t;
+
static void create_cursor_fb(data_t *data)
{
cairo_t *cr;
@@ -93,11 +94,11 @@ static void create_cursor_fb(data_t *data)
igt_assert(cairo_status(cr) == 0);
}
-
static void setup_output(data_t *data)
{
igt_display_t *display = &data->display;
igt_output_t *output;
+ drmModeModeInfoPtr mode = NULL;
enum pipe pipe;
for_each_pipe_with_valid_output(display, pipe, output) {
@@ -106,11 +107,15 @@ static void setup_output(data_t *data)
if (c->connector_type != DRM_MODE_CONNECTOR_eDP)
continue;
+ if (!igt_psr_find_good_mode(c, &mode))
+ continue;
+
+ igt_assert(mode != NULL);
+ igt_output_override_mode(output, mode);
igt_output_set_pipe(output, pipe);
data->crtc_id = output->config.crtc->crtc_id;
data->output = output;
- data->mode = igt_output_get_mode(output);
-
+ data->mode = &output->override_mode;
return;
}
}
@@ -119,10 +124,31 @@ static void display_init(data_t *data)
{
igt_display_init(&data->display, data->drm_fd);
setup_output(data);
+
+ /* We need to be able to do a modeset before we enable PSR to
+ * ensure that we are running at a mode such that PSR setup can
+ * complete within a single vblank interval.
+ */
+ igt_debug("Selected mode:\n");
+ kmstest_dump_mode(data->mode);
+ igt_create_color_fb(data->drm_fd,
+ data->mode->hdisplay, data->mode->vdisplay,
+ DRM_FORMAT_XRGB8888,
+ LOCAL_I915_FORMAT_MOD_X_TILED,
+ 0.0, .0, 1.0,
+ &data->fb_blue);
+
+ data->primary = igt_output_get_plane_type(data->output,
+ DRM_PLANE_TYPE_PRIMARY);
+ igt_plane_set_fb(data->primary, &data->fb_blue);
+ igt_display_commit(&data->display);
+ igt_set_module_param_int("enable_psr", running_with_psr_disabled ?
+ 0 : 1);
}
static void display_fini(data_t *data)
{
+ igt_output_override_mode(data->output, NULL);
igt_display_fini(&data->display);
}
@@ -494,8 +520,6 @@ int main(int argc, char *argv[])
kmstest_set_vt_graphics_mode();
data.devid = intel_get_drm_devid(data.drm_fd);
- igt_set_module_param_int("enable_psr", running_with_psr_disabled ?
- 0 : 1);
igt_skip_on(!psr_possible(&data));
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Jim Bride <jim.bride@linux.intel.com> --- tests/kms_fbcon_fbt.c | 56 ++++++++++++++++-------------------------------- tests/kms_psr_sink_crc.c | 36 +++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 43 deletions(-)