From patchwork Fri Feb 26 19:39:54 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: 8441471 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EC695C0553 for ; Fri, 26 Feb 2016 19:40:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 02FB7203A4 for ; Fri, 26 Feb 2016 19:40:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 11EDC203A1 for ; Fri, 26 Feb 2016 19:40:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 534206EB40; Fri, 26 Feb 2016 19:40:14 +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 797FF6EB40 for ; Fri, 26 Feb 2016 19:40:12 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 26 Feb 2016 11:40:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,504,1449561600"; d="scan'208";a="659878516" 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:10 -0800 From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Fri, 26 Feb 2016 16:39:54 -0300 Message-Id: <1456515598-23493-1-git-send-email-paulo.r.zanoni@intel.com> X-Mailer: git-send-email 2.7.0 Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH igt 1/5] lib/igt_kms: add kmstest_get_crtc_idx 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 Move it from pm_rpm.c to lib/igt_kms and remove the hardcoded version from kms_frontbuffer_tracking. I'm also planning to add other callers. Signed-off-by: Paulo Zanoni --- lib/igt_kms.c | 18 ++++++++++++++++++ lib/igt_kms.h | 1 + tests/kms_frontbuffer_tracking.c | 10 +++------- tests/pm_rpm.c | 14 ++------------ 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 90c8da7..285c1b6 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -875,6 +875,24 @@ void kmstest_unset_all_crtcs(int drm_fd, drmModeResPtr resources) } } +/** + * kmstest_get_crtc_idx: get the CRTC index based on its ID + * @res: the libdrm resources + * @crtc_id: the CRTC id + * + * This is useful since a few places of libdrm deal with CRTC masks. + */ +int kmstest_get_crtc_idx(drmModeRes *res, uint32_t crtc_id) +{ + int i; + + for (i = 0; i < res->count_crtcs; i++) + if (res->crtcs[i] == crtc_id) + return i; + + igt_assert(false); +} + /* * A small modeset API */ diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 3f7add5..2cb7c1f 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -150,6 +150,7 @@ bool kmstest_get_property(int drm_fd, uint32_t object_id, uint32_t object_type, const char *name, uint32_t *prop_id, uint64_t *value, drmModePropertyPtr *prop); void kmstest_unset_all_crtcs(int drm_fd, drmModeResPtr resources); +int kmstest_get_crtc_idx(drmModeRes *res, uint32_t crtc_id); /* * A small modeset API diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c index 26e12d0..88bf5a5 100644 --- a/tests/kms_frontbuffer_tracking.c +++ b/tests/kms_frontbuffer_tracking.c @@ -2214,16 +2214,12 @@ static void wait_flip_event(void) static void set_prim_plane_for_params(struct modeset_params *params) { - int rc, i, crtc_index = -1; + int rc, i; + int crtc_idx = kmstest_get_crtc_idx(drm.res, params->crtc_id); uint32_t plane_id = 0; - for (i = 0; i < drm.res->count_crtcs; i++) - if (drm.res->crtcs[i] == params->crtc_id) - crtc_index = i; - igt_assert(crtc_index >= 0); - for (i = 0; i < drm.plane_res->count_planes; i++) - if ((drm.planes[i]->possible_crtcs & (1 << crtc_index)) && + if ((drm.planes[i]->possible_crtcs & (1 << crtc_idx)) && drm.plane_types[i] == DRM_PLANE_TYPE_PRIMARY) plane_id = drm.planes[i]->plane_id; igt_assert(plane_id); diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c index 2aa6c10..eeaf324 100644 --- a/tests/pm_rpm.c +++ b/tests/pm_rpm.c @@ -1681,17 +1681,6 @@ static void test_one_plane(bool dpms, uint32_t plane_id, igt_assert(wait_for_suspended()); } -static int get_crtc_idx(drmModeResPtr res, uint32_t crtc_id) -{ - int i; - - for (i = 0; i < res->count_crtcs; i++) - if (res->crtcs[i] == crtc_id) - return i; - - igt_assert(false); -} - /* This one also triggered WARNs on our driver at some point in time. */ static void planes_subtest(bool universal, bool dpms) { @@ -1699,7 +1688,8 @@ static void planes_subtest(bool universal, bool dpms) drmModePlaneResPtr planes; igt_require(default_mode_params); - crtc_idx = get_crtc_idx(ms_data.res, default_mode_params->crtc_id); + crtc_idx = kmstest_get_crtc_idx(ms_data.res, + default_mode_params->crtc_id); if (universal) { rc = drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES,