From patchwork Fri Feb 26 19:39:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zanoni, Paulo R" X-Patchwork-Id: 8441491 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B8D039F88A for ; Fri, 26 Feb 2016 19:40:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DAA22203A4 for ; Fri, 26 Feb 2016 19:40:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id AEE39203AA for ; Fri, 26 Feb 2016 19:40:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BDD1B6EB89; Fri, 26 Feb 2016 19:40:15 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id B6CB56EB86 for ; Fri, 26 Feb 2016 19:40:14 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 26 Feb 2016 11:40:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,504,1449561600"; d="scan'208";a="659878533" Received: from jholm-mobl.amr.corp.intel.com (HELO panetone.amr.corp.intel.com) ([10.252.138.60]) by FMSMGA003.fm.intel.com with ESMTP; 26 Feb 2016 11:40:13 -0800 From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Fri, 26 Feb 2016 16:39:56 -0300 Message-Id: <1456515598-23493-3-git-send-email-paulo.r.zanoni@intel.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456515598-23493-1-git-send-email-paulo.r.zanoni@intel.com> References: <1456515598-23493-1-git-send-email-paulo.r.zanoni@intel.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH igt 3/5] kms_frontbuffer_tracking: extract find_connector function 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We're going to make our search for connnectors a little more complicated, so extract the function since we're going to call it a few more times. Signed-off-by: Paulo Zanoni --- tests/kms_frontbuffer_tracking.c | 70 ++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c index d641cc7..3b2ca8a 100644 --- a/tests/kms_frontbuffer_tracking.c +++ b/tests/kms_frontbuffer_tracking.c @@ -368,7 +368,8 @@ static void print_mode_info(const char *screen, struct modeset_params *params) } static void init_mode_params(struct modeset_params *params, uint32_t crtc_id, - uint32_t connector_id, drmModeModeInfoPtr mode) + drmModeConnectorPtr connector, + drmModeModeInfoPtr mode) { uint32_t plane_id = 0; int crtc_idx = kmstest_get_crtc_idx(drm.res, crtc_id); @@ -382,7 +383,7 @@ static void init_mode_params(struct modeset_params *params, uint32_t crtc_id, igt_assert(plane_id); params->crtc_id = crtc_id; - params->connector_id = connector_id; + params->connector_id = connector->connector_id; params->mode = mode; params->sprite_id = plane_id; @@ -427,56 +428,61 @@ static bool connector_get_mode(drmModeConnectorPtr c, drmModeModeInfoPtr *mode) return true; } -static bool init_modeset_cached_params(void) +static bool find_connector(bool edp_only, uint32_t forbidden_id, + drmModeConnectorPtr *ret_connector, + drmModeModeInfoPtr *ret_mode) { + drmModeConnectorPtr c = NULL; + drmModeModeInfoPtr mode = NULL; int i; - uint32_t prim_connector_id = 0, scnd_connector_id = 0; - drmModeModeInfoPtr prim_mode = NULL, scnd_mode = NULL; - drmModeModeInfoPtr tmp_mode; - /* First, try to find an eDP monitor since it's the only possible type - * for PSR. */ for (i = 0; i < drm.res->count_connectors; i++) { - if (drm.connectors[i]->connector_type != DRM_MODE_CONNECTOR_eDP) - continue; + c = drm.connectors[i]; - if (connector_get_mode(drm.connectors[i], &tmp_mode)) { - prim_connector_id = drm.res->connectors[i]; - prim_mode = tmp_mode; - } - } - for (i = 0; i < drm.res->count_connectors; i++) { - /* Don't pick again what we just selected on the above loop. */ - if (drm.res->connectors[i] == prim_connector_id) + if (edp_only && c->connector_type != DRM_MODE_CONNECTOR_eDP) + continue; + if (c->connector_id == forbidden_id) + continue; + if (!connector_get_mode(c, &mode)) continue; - if (connector_get_mode(drm.connectors[i], &tmp_mode)) { - if (!prim_connector_id) { - prim_connector_id = drm.res->connectors[i]; - prim_mode = tmp_mode; - } else if (!scnd_connector_id) { - scnd_connector_id = drm.res->connectors[i]; - scnd_mode = tmp_mode; - break; - } - } + *ret_connector = c; + *ret_mode = mode; + return true; } - if (!prim_connector_id) + return false; +} + +static bool init_modeset_cached_params(void) +{ + drmModeConnectorPtr prim_connector = NULL, scnd_connector = NULL; + drmModeModeInfoPtr prim_mode = NULL, scnd_mode = NULL; + + /* First, try to find an eDP monitor since it's the only possible type + * for PSR. */ + find_connector(true, 0, &prim_connector, &prim_mode); + if (!prim_connector) + find_connector(false, 0, &prim_connector, &prim_mode); + + if (!prim_connector) return false; + find_connector(false, prim_connector->connector_id, &scnd_connector, + &scnd_mode); + init_mode_params(&prim_mode_params, drm.res->crtcs[0], - prim_connector_id, prim_mode); + prim_connector, prim_mode); print_mode_info("Primary", &prim_mode_params); - if (!scnd_connector_id) { + if (!scnd_connector) { scnd_mode_params.connector_id = 0; return true; } igt_assert(drm.res->count_crtcs >= 2); init_mode_params(&scnd_mode_params, drm.res->crtcs[1], - scnd_connector_id, scnd_mode); + scnd_connector, scnd_mode); print_mode_info("Secondary", &scnd_mode_params); return true;