From patchwork Thu Nov 5 01:34:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 7556451 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 9CBF79F327 for ; Thu, 5 Nov 2015 01:37:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D903420815 for ; Thu, 5 Nov 2015 01:37:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EBB1420814 for ; Thu, 5 Nov 2015 01:37:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B1586E979; Wed, 4 Nov 2015 17:37:51 -0800 (PST) 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 9D0056E2D6 for ; Wed, 4 Nov 2015 17:37:49 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 04 Nov 2015 17:37:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,245,1444719600"; d="scan'208";a="827456425" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by fmsmga001.fm.intel.com with ESMTP; 04 Nov 2015 17:37:41 -0800 Received: from vkasired-desk2.fm.intel.com (10.22.254.140) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 4 Nov 2015 17:37:41 -0800 From: Vivek Kasireddy To: Date: Wed, 4 Nov 2015 17:34:05 -0800 Message-ID: <1446687245-5345-1-git-send-email-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.22.254.140] Cc: Vivek Kasireddy , Thomas Wood Subject: [Intel-gfx] [PATCH] igt/igt_kms: Introduce get_first_connected_output (v2) 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, T_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 (connected) output to perform a test. This macro can help in these situations by not having to put the test code inside a for loop that iterates over all the outputs. v2: Added a brief documentation for this macro. Suggested-by: Matt Roper Cc: Thomas Wood Signed-off-by: Vivek Kasireddy --- lib/igt_kms.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 09c08aa..91fa206 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -278,6 +278,18 @@ 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__++) +/** + * get_first_connected_output: + * @display: Initialized igt_display_t type object + * @output: igt_output_t type object + * + * Returns: First valid (connected) output. + */ +#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