From patchwork Thu Oct 29 02:09:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 7515481 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 2B439BEEA4 for ; Thu, 29 Oct 2015 02:13:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 223FE20930 for ; Thu, 29 Oct 2015 02:13:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 07EA720952 for ; Thu, 29 Oct 2015 02:13:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C06816E322; Wed, 28 Oct 2015 19:13:52 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id C14EF6E322 for ; Wed, 28 Oct 2015 19:13:50 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 28 Oct 2015 19:13:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,212,1444719600"; d="scan'208";a="590016106" Received: from orsmsx109.amr.corp.intel.com ([10.22.240.7]) by FMSMGA003.fm.intel.com with ESMTP; 28 Oct 2015 19:13:50 -0700 Received: from vkasired-desk2.fm.intel.com (10.22.254.138) by ORSMSX109.amr.corp.intel.com (10.22.240.7) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 28 Oct 2015 19:13:49 -0700 From: Vivek Kasireddy To: Date: Wed, 28 Oct 2015 19:09:54 -0700 Message-ID: <1446084594-2976-1-git-send-email-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 X-Originating-IP: [10.22.254.138] Cc: Vivek Kasireddy Subject: [Intel-gfx] [PATCH] lib/igt_kms: Introduce get_first_connected_output to retrieve a valid output 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: , 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 In some cases, we just need one valid output to perform a test. This macro can help in these situations by avoiding iterating over all the outputs. Suggested-by: Matt Roper CC: Tvrtko Ursulin CC: Matt Roper Signed-off-by: Vivek Kasireddy --- lib/igt_kms.h | 5 +++++ tests/kms_rotation_crc.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 09c08aa..6847beb 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -278,6 +278,11 @@ void igt_wait_for_vblank(int drm_fd, enum pipe pipe); for (int i__ = 0; (plane) = &(display)->pipes[(pipe)].planes[i__], \ i__ < (display)->pipes[(pipe)].n_planes; i__++) +#define get_first_connected_output(display, output) \ + for (int i__ = 0; i__ < (display)->n_outputs; i__++) \ + if ((output = &(display)->outputs[i__]), output->valid) \ + break + /* * Can be used with igt_output_set_pipe() to mean we don't care about the pipe * that should drive this output diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c index 31cece2..3f0a3ef 100644 --- a/tests/kms_rotation_crc.c +++ b/tests/kms_rotation_crc.c @@ -272,14 +272,15 @@ static void test_plane_rotation_ytiled_obj(data_t *data, enum igt_plane plane_ty int bpp = igt_drm_format_to_bpp(format); enum igt_commit_style commit = COMMIT_LEGACY; int fd = data->gfx_fd; - igt_output_t *output = &display->outputs[0]; + igt_output_t *output = NULL; igt_plane_t *plane; drmModeModeInfo *mode; unsigned int stride, size, w, h; uint32_t gem_handle; int ret; - igt_require(output != NULL && output->valid == true); + get_first_connected_output(display, output); + igt_require(output != NULL); plane = igt_output_get_plane(output, plane_type); igt_require(igt_plane_supports_rotation(plane));