From patchwork Thu Oct 3 18:46:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juston Li X-Patchwork-Id: 11173095 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A93651709 for ; Thu, 3 Oct 2019 18:46:59 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9076320862 for ; Thu, 3 Oct 2019 18:46:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9076320862 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C09926EA4A; Thu, 3 Oct 2019 18:46:58 +0000 (UTC) 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 ESMTPS id 596A16EA4A; Thu, 3 Oct 2019 18:46:57 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Oct 2019 11:46:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,253,1566889200"; d="scan'208";a="204052198" Received: from jhli-desk1.jf.intel.com ([10.7.198.166]) by orsmga002.jf.intel.com with ESMTP; 03 Oct 2019 11:46:56 -0700 From: Juston Li To: dri-devel@lists.freedesktop.org, igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Date: Thu, 3 Oct 2019 11:46:27 -0700 Message-Id: <20191003184628.7021-1-juston.li@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 1/2] tests/kms_getfb: Add getfb2 tests 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: Daniel Stone Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Daniel Stone Mirroring addfb2, add tests for the new ioctl which will return us information about framebuffers containing multiple buffers, as well as modifiers. Changes since v1: - Add test that uses getfb2 output to call addfb2 as suggested by Ville Signed-off-by: Daniel Stone Signed-off-by: Juston Li --- tests/kms_getfb.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c index ca0b01c05e5c..848b896b7556 100644 --- a/tests/kms_getfb.c +++ b/tests/kms_getfb.c @@ -228,6 +228,106 @@ static void test_duplicate_handles(int fd) } } +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_any_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], 0); + } + } + 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_subtest("getfb2-into-addfb2") { + struct drm_mode_fb_cmd2 cmd = { }; + + cmd.fb_id = add_basic.fb_id; + do_ioctl(fd, DRM_IOCTL_MODE_GETFB2, &cmd); + do_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &cmd); + + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &cmd.fb_id); + gem_close(fd, cmd.handles[0]); + } + + igt_fixture { + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add_basic.fb_id); + gem_close(fd, add_basic.handles[0]); + } +} + igt_main { int fd; @@ -243,6 +343,9 @@ igt_main igt_subtest_group test_duplicate_handles(fd); + igt_subtest_group + test_getfb2(fd); + igt_fixture close(fd); }