From patchwork Tue Jul 11 22:48:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim.bride@linux.intel.com X-Patchwork-Id: 9835623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9B5D7602BD for ; Tue, 11 Jul 2017 22:51:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8110728548 for ; Tue, 11 Jul 2017 22:51:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75F52285C2; Tue, 11 Jul 2017 22:51:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08A8F285C3 for ; Tue, 11 Jul 2017 22:51:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B63E6E336; Tue, 11 Jul 2017 22:51:11 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 908D56E326 for ; Tue, 11 Jul 2017 22:51:07 +0000 (UTC) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 11 Jul 2017 15:51:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,347,1496127600"; d="scan'208";a="123996636" Received: from shiv.jf.intel.com ([10.54.75.141]) by orsmga005.jf.intel.com with ESMTP; 11 Jul 2017 15:51:06 -0700 From: Jim Bride To: intel-gfx@lists.freedesktop.org Date: Tue, 11 Jul 2017 15:48:35 -0700 Message-Id: <1499813316-15038-11-git-send-email-jim.bride@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499813316-15038-1-git-send-email-jim.bride@linux.intel.com> References: <1499813316-15038-1-git-send-email-jim.bride@linux.intel.com> Subject: [Intel-gfx] [PATCH IGT 10/11] lib: Add igt_psr_find_good_mode() and modify tests to use it. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jim Bride --- lib/igt_psr.c | 34 +++++++++++++++++++++++++++++++++ lib/igt_psr.h | 2 ++ tests/kms_fbcon_fbt.c | 4 ++++ tests/kms_frontbuffer_tracking.c | 2 +- tests/kms_psr_sink_crc.c | 41 ++++++++++++++++++++++++++++++---------- 5 files changed, 72 insertions(+), 11 deletions(-) diff --git a/lib/igt_psr.c b/lib/igt_psr.c index 178842e..2fda467 100644 --- a/lib/igt_psr.c +++ b/lib/igt_psr.c @@ -138,3 +138,37 @@ bool igt_psr_valid_connector(drmModeConnectorPtr connector) { return (connector->connector_type == DRM_MODE_CONNECTOR_eDP); } + +/** + * igt_psr_find_good_mode + * @connector: a drmModeConnector pointer to find the mode on + * @mode: a drmModeModePtr pointer that is set to the matching mode + * + * Returns true (and populates *mode with the match) if a valid + * PSR mdoe is found, and false otherwise. + */ +bool igt_psr_find_good_mode(drmModeConnectorPtr connector, + drmModeModeInfoPtr *mode) +{ + int i; + + if (!connector->count_modes) { + igt_warn("no modes for connector %d.\n", + connector->connector_id); + return false; + } else { + igt_debug("Connector has %d modes.\n", connector->count_modes); + } + + for (i = 0; i < connector->count_modes; i++) { + if ((connector->modes[i].vtotal - + connector->modes[i].vdisplay) >= 36) { + igt_debug("Mode %d good for PSR.\n", i); + *mode = &(connector->modes[i]); + return true; + } else { + igt_debug("Throwing out mode %d\n", i); + } + } + return false; +} diff --git a/lib/igt_psr.h b/lib/igt_psr.h index 08bccef..f4c0a6b 100644 --- a/lib/igt_psr.h +++ b/lib/igt_psr.h @@ -34,5 +34,7 @@ bool igt_psr_active(int fd); bool igt_psr_await_status(int fd, bool active); void igt_psr_print_status(int fd); bool igt_psr_valid_connector(drmModeConnectorPtr connector); +bool igt_psr_find_good_mode(drmModeConnectorPtr connector, + drmModeModeInfoPtr *mode); #endif /* IGT_PSR_H */ diff --git a/tests/kms_fbcon_fbt.c b/tests/kms_fbcon_fbt.c index cba632e..32f363f 100644 --- a/tests/kms_fbcon_fbt.c +++ b/tests/kms_fbcon_fbt.c @@ -125,6 +125,10 @@ 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) { + if (igt_psr_find_good_mode(c, &mode)) + break; + } mode = &c->modes[0]; break; } diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c index 6f52c49..fe50cc7 100644 --- a/tests/kms_frontbuffer_tracking.c +++ b/tests/kms_frontbuffer_tracking.c @@ -435,7 +435,7 @@ static bool connector_get_mode(drmModeConnectorPtr c, drmModeModeInfoPtr *mode) if (opt.small_modes) *mode = get_connector_smallest_mode(c); else - *mode = &c->modes[0]; + igt_assert(igt_psr_find_good_mode(c, mode)); return true; } diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c index da8c173..eb1bbb3 100644 --- a/tests/kms_psr_sink_crc.c +++ b/tests/kms_psr_sink_crc.c @@ -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; @@ -99,6 +99,7 @@ static void setup_output(data_t *data) igt_display_t *display = &data->display; igt_output_t *output; enum pipe pipe; + drmModeModeInfoPtr mode = NULL; for_each_pipe_with_valid_output(display, pipe, output) { drmModeConnectorPtr c = output->config.connector; @@ -106,10 +107,14 @@ static void setup_output(data_t *data) if (!igt_psr_valid_connector(c)) 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,33 @@ 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); + if (running_with_psr_disabled) + igt_psr_disable(); + else + igt_psr_enable(); } static void display_fini(data_t *data) { + igt_output_override_mode(data->output, NULL); igt_display_fini(&data->display); } @@ -487,19 +515,12 @@ int main(int argc, char *argv[]) data.drm_fd = drm_open_driver_master(DRIVER_INTEL); kmstest_set_vt_graphics_mode(); data.devid = intel_get_drm_devid(data.drm_fd); - - if (running_with_psr_disabled) - igt_psr_disable(); - else - igt_psr_enable(); - - igt_skip_on(!psr_possible(&data)); - data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd, 4096); igt_assert(data.bufmgr); drm_intel_bufmgr_gem_enable_reuse(data.bufmgr); display_init(&data); + igt_skip_on(!psr_possible(&data)); } igt_subtest("psr_basic") {