From patchwork Fri Mar 23 13:46:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Stone X-Patchwork-Id: 10304749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 14B3660385 for ; Fri, 23 Mar 2018 13:46:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0585B288AE for ; Fri, 23 Mar 2018 13:46:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE73D28EA2; Fri, 23 Mar 2018 13:46: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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY 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 7907228EA0 for ; Fri, 23 Mar 2018 13:46:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9616B6E506; Fri, 23 Mar 2018 13:46:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85C556E4FF; Fri, 23 Mar 2018 13:46:21 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: daniels) with ESMTPSA id 4C0682655DF From: Daniel Stone To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH i-g-t 1/3] tests/kms_getfb: Split property-ID get into helper Date: Fri, 23 Mar 2018 13:46:14 +0000 Message-Id: <20180323134616.16058-1-daniels@collabora.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: References: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We'll want to reuse this, so split it out into a (smaller!) helper. Signed-off-by: Daniel Stone Reviewed-by: Ville Syrjälä --- tests/kms_getfb.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c index c5968e75..a9852626 100644 --- a/tests/kms_getfb.c +++ b/tests/kms_getfb.c @@ -72,6 +72,23 @@ static void get_ccs_fb(int fd, struct drm_mode_fb_cmd2 *ret) gem_close(fd, add.handles[0]); } +/** + * Find and return an arbitrary valid property ID. + */ +static uint32_t get_prop_id(int fd) +{ + igt_display_t display; + + igt_display_init(&display, fd); + for (int i = 0; i < display.n_outputs; i++) { + igt_output_t *output = &display.outputs[i]; + if (output->props[IGT_CONNECTOR_DPMS] != 0) + return output->props[IGT_CONNECTOR_DPMS]; + } + + return 0; +} + static void test_handle_input(int fd) { struct drm_mode_fb_cmd2 add = {}; @@ -111,23 +128,8 @@ static void test_handle_input(int fd) } igt_subtest("getfb-handle-not-fb") { - struct drm_mode_fb_cmd get = { }; - uint32_t prop_id = 0; - igt_display_t display; - - /* Find a valid property ID to use. */ - igt_display_init(&display, fd); - for (int i = 0; i < display.n_outputs; i++) { - igt_output_t *output = &display.outputs[i]; - - if (output->props[IGT_CONNECTOR_DPMS] != 0) { - prop_id = output->props[IGT_CONNECTOR_DPMS]; - break; - } - } - igt_require(prop_id > 0); - - get.fb_id = prop_id; + struct drm_mode_fb_cmd get = { .fb_id = get_prop_id(fd) }; + igt_require(get.fb_id > 0); do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB, &get, ENOENT); } }