From patchwork Fri Mar 23 13:46:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Stone X-Patchwork-Id: 10304751 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 B869960385 for ; Fri, 23 Mar 2018 13:46:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A576428EA9 for ; Fri, 23 Mar 2018 13:46:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98A7128EAB; Fri, 23 Mar 2018 13:46:33 +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 E6A8728EA9 for ; Fri, 23 Mar 2018 13:46:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C2A796E5EA; Fri, 23 Mar 2018 13:46:26 +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 150056E559; Fri, 23 Mar 2018 13:46:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: daniels) with ESMTPSA id E2DC2265642 From: Daniel Stone To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH i-g-t 3/3] tests/kms_getfb: Add getfb2 tests Date: Fri, 23 Mar 2018 13:46:16 +0000 Message-Id: <20180323134616.16058-3-daniels@collabora.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323134616.16058-1-daniels@collabora.com> References: <20180323134616.16058-1-daniels@collabora.com> 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 Mirroring addfb2, add tests for the new ioctl which will return us information about framebuffers containing multiple buffers, as well as modifiers. Signed-off-by: Daniel Stone Reviewed-by: Ville Syrjälä --- tests/kms_getfb.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c index a9852626..b8583694 100644 --- a/tests/kms_getfb.c +++ b/tests/kms_getfb.c @@ -186,7 +186,96 @@ static void test_duplicate_handles(int fd) do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add.fb_id); gem_close(fd, add.handles[0]); } +} + +static void test_getfb2(int fd) +{ + struct drm_mode_fb_cmd2 add_basic = {}; + + igt_fixture { + struct drm_mode_fb_cmd2 get = {}; + + add_basic.width = 1024; + add_basic.height = 1024; + add_basic.pixel_format = DRM_FORMAT_XRGB8888; + add_basic.pitches[0] = 1024*4; + add_basic.handles[0] = igt_create_bo_with_dimensions(fd, 1024, 1024, + DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL); + igt_assert(add_basic.handles[0]); + do_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &add_basic); + + get.fb_id = add_basic.fb_id; + do_ioctl(fd, DRM_IOCTL_MODE_GETFB2, &get); + igt_assert_neq_u32(get.handles[0], 0); + gem_close(fd, get.handles[0]); + } + + igt_subtest("getfb2-handle-zero") { + struct drm_mode_fb_cmd2 get = {}; + do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB2, &get, ENOENT); + } + + igt_subtest("getfb2-handle-closed") { + struct drm_mode_fb_cmd2 add = add_basic; + struct drm_mode_fb_cmd2 get = { }; + + add.handles[0] = igt_create_bo_with_dimensions(fd, 1024, 1024, + DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL); + igt_assert(add.handles[0]); + do_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &add); + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add.fb_id); + get.fb_id = add.fb_id; + do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB2, &get, ENOENT); + gem_close(fd, add.handles[0]); + } + + igt_subtest("getfb2-handle-not-fb") { + 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); + } + + igt_subtest("getfb2-accept-ccs") { + struct drm_mode_fb_cmd2 add_ccs = { }; + struct drm_mode_fb_cmd2 get = { }; + int i; + + get_ccs_fb(fd, &add_ccs); + igt_require(add_ccs.fb_id != 0); + get.fb_id = add_ccs.fb_id; + do_ioctl(fd, DRM_IOCTL_MODE_GETFB2, &get); + + igt_assert_eq_u32(get.width, add_ccs.width); + igt_assert_eq_u32(get.height, add_ccs.height); + igt_assert(get.flags & DRM_MODE_FB_MODIFIERS); + + for (i = 0; i < ARRAY_SIZE(get.handles); i++) { + igt_assert_eq_u32(get.pitches[i], add_ccs.pitches[i]); + igt_assert_eq_u32(get.offsets[i], add_ccs.offsets[i]); + if (add_ccs.handles[i] != 0) { + igt_assert_neq_u32(get.handles[i], 0); + igt_assert_neq_u32(get.handles[i], + add_ccs.handles[i]); + igt_assert_eq_u64(get.modifier[i], + add_ccs.modifier[i]); + } else { + igt_assert_eq_u32(get.handles[i], 0); + igt_assert_eq_u64(get.modifier[i], + DRM_FORMAT_MOD_INVALID); + } + } + igt_assert_eq_u32(get.handles[0], get.handles[1]); + + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &get.fb_id); + gem_close(fd, add_ccs.handles[0]); + gem_close(fd, get.handles[0]); + } + + igt_fixture { + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add_basic.fb_id); + gem_close(fd, add_basic.handles[0]); + } } igt_main @@ -200,6 +289,8 @@ igt_main test_duplicate_handles(fd); + test_getfb2(fd); + igt_fixture close(fd); }