From patchwork Fri Sep 14 20:13:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10601189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 300DD14DB for ; Fri, 14 Sep 2018 20:13:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 188262B9EE for ; Fri, 14 Sep 2018 20:13:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CB102BA80; Fri, 14 Sep 2018 20:13:25 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 BD5F72B9EE for ; Fri, 14 Sep 2018 20:13:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C4596E7DB; Fri, 14 Sep 2018 20:13:23 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF9176E080; Fri, 14 Sep 2018 20:13:20 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 13774244-1500050 for multiple; Fri, 14 Sep 2018 21:13:07 +0100 From: Chris Wilson To: igt-dev@lists.freedesktop.org Date: Fri, 14 Sep 2018 21:13:08 +0100 Message-Id: <20180914201310.19527-3-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180914201310.19527-1-chris@chris-wilson.co.uk> References: <20180914201310.19527-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 3/5] lib: Report if kms is enabled on the display X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Some drivers may have disabled KMS or there may simply nothing attached to the device. In either case KMS is unusable and we may prefer to skip. Signed-off-by: Chris Wilson --- lib/igt_kms.c | 14 ++++++++++++-- lib/igt_kms.h | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 4563bfd9d..9710bcae1 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1843,8 +1843,9 @@ static void igt_fill_display_format_mod(igt_display_t *display); * Initialize @display and allocate the various resources required. Use * #igt_display_fini to release the resources when they are no longer required. * + * Returns: true if the display has outputs and pipes available, false otherwise */ -void igt_display_init(igt_display_t *display, int drm_fd) +bool igt_display_init(igt_display_t *display, int drm_fd) { drmModeRes *resources; drmModePlaneRes *plane_resources; @@ -1857,7 +1858,8 @@ void igt_display_init(igt_display_t *display, int drm_fd) display->drm_fd = drm_fd; resources = drmModeGetResources(display->drm_fd); - igt_assert(resources); + if (!resources) + goto out; /* * We cache the number of pipes, that number is a physical limit of the @@ -2004,7 +2006,15 @@ void igt_display_init(igt_display_t *display, int drm_fd) /* Set reasonable default values for every object in the display. */ igt_display_reset(display); +out: LOG_UNINDENT(display); + + return display->n_pipes && display->n_outputs; +} + +void igt_display_require(igt_display_t *display, int drm_fd) +{ + igt_require(igt_display_init(display, drm_fd)); } /** diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 3862efa28..73624399b 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -378,7 +378,8 @@ struct igt_display { int format_mod_count; }; -void igt_display_init(igt_display_t *display, int drm_fd); +bool igt_display_init(igt_display_t *display, int drm_fd); +void igt_display_require(igt_display_t *display, int drm_fd); void igt_display_fini(igt_display_t *display); void igt_display_reset(igt_display_t *display); int igt_display_commit2(igt_display_t *display, enum igt_commit_style s);