From patchwork Mon May 27 01:19:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10961975 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 1A1D21575 for ; Mon, 27 May 2019 01:20:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAD3528A78 for ; Mon, 27 May 2019 01:20:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D951928A96; Mon, 27 May 2019 01:20:01 +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,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 A951728A78 for ; Mon, 27 May 2019 01:20:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4A84897C5; Mon, 27 May 2019 01:19:58 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by gabe.freedesktop.org (Postfix) with ESMTPS id C6F88897B5; Mon, 27 May 2019 01:19:57 +0000 (UTC) Received: by mail-qk1-x744.google.com with SMTP id c70so1357604qkg.7; Sun, 26 May 2019 18:19:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=cH0ROzIVKZ4CFa8UwhQcSW0VGWV08uMKGVVCc45rL1U=; b=h2ecOmBCb+WNvrkdRiqHVGmzo3jAMT0uS8NdAbpakiGkyvD3+8s7rMJTAnmmSJGzr5 jPy/AXgOapBMsl1YiWxXqF7fs7XlDXfrS6Z2FaUfcFDP00Qz9Edw7tOOOIlUcgidJLMI YYLifCFtwYyVtCuWJR0Fm+LdjWsLYDFXb2Ogwy6Ivu8yz7oN6Jlp8xQG+MZQGKB2aARY ABMmVeuPqG2Oga8XlB/kYy7t95rDqspMZEAnxLBJIzv3ycLhlwyKLRYWRpUXdyC7bVY4 aycPKkGYi0JkdU2KyiwagPQPa/z0k8phukG/bW6cXJIybPAyU2c3dECCk5nWxIZ1ACAK MfCg== X-Gm-Message-State: APjAAAUcRZwemHA1rlEbBRw8MhSBipo+XTfsE2UyM41TDHEnY/68reiG SbMQRoOEriRq6BjHk5h06ho2EKju X-Google-Smtp-Source: APXvYqz6jPnUTsgX1RYg/fGk2Y4vK9WyzCOpUljscXFAv244SNMGe7tVgErU1LKz08C/nuaIKmcH2A== X-Received: by 2002:ac8:2b10:: with SMTP id 16mr64816529qtu.58.1558919996710; Sun, 26 May 2019 18:19:56 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.151]) by smtp.gmail.com with ESMTPSA id n190sm3372428qkb.83.2019.05.26.18.19.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 26 May 2019 18:19:55 -0700 (PDT) Date: Sun, 26 May 2019 22:19:51 -0300 From: Rodrigo Siqueira To: Petri Latvala , Arkadiusz Hiler , Chris Wilson , Simon Ser Message-ID: <20190527011951.h2adglmq2g24exov@smtp.gmail.com> MIME-Version: 1.0 User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=cH0ROzIVKZ4CFa8UwhQcSW0VGWV08uMKGVVCc45rL1U=; b=M0tcr3hUwUdBxTk3tPUlp7PTz9Gu7uPBubQpGxOxxG3PAEJPPyTfpNqliRw5Pcb9EQ fRzyUu1qoFe/sptkOu+SeMvKaeNFREZyJWSp4hLlW0q6YXWZVt5qx727Z8iP0f2dLeF+ V//w5nBujF3jcQ2Htf5i1bxuQbC9U9wm+xHJPlDAE8AEYKak7FiPbbWygxzhK7KF1x6u TfiOuSJGqsj1uDRAbpuyBjoKf/VW10oFKbnxF1TBv5ou5ypLp+FDxdKtFdWI3TiapEXE NjuV57rv38tHhmXeye537WqsqqeChss47YnXavRty4K/h5CMSRHeIEPwKvbdvd93NteO Bx1w== Subject: [Intel-gfx] [PATCH V3 i-g-t] lib: Drop __kms_addfb() wrapper 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: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The function __kms_addfb() and drmModeAddFB2WithModifiers() have a similar code. Due to this similarity, this commit replaces all the occurrences of __kms_addfb() by drmModeAddFB2WithModifiers() and adds the required adaptations. V2: Simon Sir - Fix array data copy V1: Arkadiusz Hiler - Fix array initialization - Drop __kms_addfb() Signed-off-by: Rodrigo Siqueira --- lib/igt_aux.h | 3 +++ lib/igt_fb.c | 14 +++++++++----- lib/ioctl_wrappers.c | 33 --------------------------------- lib/ioctl_wrappers.h | 11 ----------- tests/kms_available_modes_crc.c | 14 +++++++++----- tests/kms_draw_crc.c | 10 ++++++---- tests/prime_vgem.c | 14 ++++++++------ 7 files changed, 35 insertions(+), 64 deletions(-) diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 04d22904..2b08a0d4 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -309,4 +309,7 @@ void igt_lsof(const char *dpath); uint64_t vfs_file_max(void); +#define fill_memory(src, value, limit) \ + for (int _i = 0; _i < limit; src[_i] = value, _i++) + #endif /* IGT_AUX_H */ diff --git a/lib/igt_fb.c b/lib/igt_fb.c index d4929019..5f55906b 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -1235,6 +1235,9 @@ igt_create_fb_with_bo_size(int fd, int width, int height, struct igt_fb *fb, uint64_t bo_size, unsigned bo_stride) { + uint32_t handles[4] = {}; + uint64_t modifiers[4] = {}; + /* FIXME allow the caller to pass these in */ enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709; enum igt_color_range color_range = IGT_COLOR_YCBCR_LIMITED_RANGE; @@ -1262,11 +1265,12 @@ igt_create_fb_with_bo_size(int fd, int width, int height, if (fb->modifier || igt_has_fb_modifiers(fd)) flags = LOCAL_DRM_MODE_FB_MODIFIERS; - do_or_die(__kms_addfb(fb->fd, fb->gem_handle, - fb->width, fb->height, - fb->drm_format, fb->modifier, - fb->strides, fb->offsets, fb->num_planes, flags, - &fb->fb_id)); + fill_memory(handles, fb->gem_handle, fb->num_planes); + fill_memory(modifiers, modifier, fb->num_planes); + do_or_die(drmModeAddFB2WithModifiers(fb->fd, fb->width, fb->height, + fb->drm_format, handles, + fb->strides, fb->offsets, + modifiers, &fb->fb_id, flags)); return fb->fb_id; } diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 280fdd62..0f00971d 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -1453,36 +1453,3 @@ void igt_require_fb_modifiers(int fd) { igt_require(igt_has_fb_modifiers(fd)); } - -int __kms_addfb(int fd, uint32_t handle, - uint32_t width, uint32_t height, - uint32_t pixel_format, uint64_t modifier, - uint32_t strides[4], uint32_t offsets[4], - int num_planes, uint32_t flags, uint32_t *buf_id) -{ - struct drm_mode_fb_cmd2 f; - int ret, i; - - if (flags & DRM_MODE_FB_MODIFIERS) - igt_require_fb_modifiers(fd); - - memset(&f, 0, sizeof(f)); - - f.width = width; - f.height = height; - f.pixel_format = pixel_format; - f.flags = flags; - - for (i = 0; i < num_planes; i++) { - f.handles[i] = handle; - f.modifier[i] = modifier; - f.pitches[i] = strides[i]; - f.offsets[i] = offsets[i]; - } - - ret = igt_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &f); - - *buf_id = f.fb_id; - - return ret < 0 ? -errno : ret; -} diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h index 03211c97..4afc3e09 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -209,17 +209,6 @@ struct local_drm_mode_fb_cmd2 { bool igt_has_fb_modifiers(int fd); void igt_require_fb_modifiers(int fd); -/** - * __kms_addfb: - * - * Creates a framebuffer object. - */ -int __kms_addfb(int fd, uint32_t handle, - uint32_t width, uint32_t height, - uint32_t pixel_format, uint64_t modifier, - uint32_t strides[4], uint32_t offsets[4], - int num_planes, uint32_t flags, uint32_t *buf_id); - /** * to_user_pointer: * diff --git a/tests/kms_available_modes_crc.c b/tests/kms_available_modes_crc.c index 50b5522a..275b4b6f 100644 --- a/tests/kms_available_modes_crc.c +++ b/tests/kms_available_modes_crc.c @@ -172,9 +172,10 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, { drmModeModeInfo *mode; uint64_t w, h; + uint32_t handles[4] = {}; + uint64_t modifiers[4] = {}; signed ret, gemsize = 0; unsigned tile_width, tile_height; - int num_planes = 1; uint64_t tiling; int bpp = 0; int i; @@ -225,10 +226,13 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, igt_assert_eq(ret, 0); - ret = __kms_addfb(data->gfx_fd, data->gem_handle, w, h, - format, tiling, data->fb.strides, data->fb.offsets, - num_planes, LOCAL_DRM_MODE_FB_MODIFIERS, - &data->fb.fb_id); + fill_memory(handles, data->gem_handle, 1); + fill_memory(modifiers, tiling, 1); + ret = drmModeAddFB2WithModifiers(data->gfx_fd, w, h, format, + handles, data->fb.strides, + data->fb.offsets, modifiers, + &data->fb.fb_id, + LOCAL_DRM_MODE_FB_MODIFIERS); if(ret < 0) { igt_info("Creating fb for format %s failed, return code %d\n", diff --git a/tests/kms_draw_crc.c b/tests/kms_draw_crc.c index ea14db9a..38f92ab9 100644 --- a/tests/kms_draw_crc.c +++ b/tests/kms_draw_crc.c @@ -155,17 +155,19 @@ static void get_method_crc(enum igt_draw_method method, uint32_t drm_format, static bool format_is_supported(uint32_t format, uint64_t modifier) { - uint32_t gem_handle, fb_id; + uint32_t gem_handle, fb_id, handles[4] = {}; unsigned int offsets[4] = {}; unsigned int strides[4] = {}; + uint64_t modifiers[4] = {}; int ret; gem_handle = igt_create_bo_with_dimensions(drm_fd, 64, 64, format, modifier, 0, NULL, &strides[0], NULL); - ret = __kms_addfb(drm_fd, gem_handle, 64, 64, - format, modifier, strides, offsets, 1, - LOCAL_DRM_MODE_FB_MODIFIERS, &fb_id); + fill_memory(handles, gem_handle, 1); + ret = drmModeAddFB2WithModifiers(drm_fd, 64, 64, format, handles, + strides, offsets, modifiers, &fb_id, + LOCAL_DRM_MODE_FB_MODIFIERS); drmModeRmFB(drm_fd, fb_id); gem_close(drm_fd, gem_handle); diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c index 09e3373b..da15fd14 100644 --- a/tests/prime_vgem.c +++ b/tests/prime_vgem.c @@ -761,6 +761,7 @@ static void test_flip(int i915, int vgem, unsigned hang) for (int i = 0; i < 2; i++) { uint32_t strides[4] = {}; uint32_t offsets[4] = {}; + uint32_t handles[4] = {}; int fd; bo[i].width = mode->hdisplay; @@ -776,12 +777,13 @@ static void test_flip(int i915, int vgem, unsigned hang) strides[0] = bo[i].pitch; /* May skip if i915 has no displays */ - igt_require(__kms_addfb(i915, handle[i], - bo[i].width, bo[i].height, - DRM_FORMAT_XRGB8888, I915_TILING_NONE, - strides, offsets, 1, - LOCAL_DRM_MODE_FB_MODIFIERS, - &fb_id[i]) == 0); + fill_memory(handles, handle[i],1); + igt_require(drmModeAddFB2WithModifiers(i915, bo[i].width, bo[i].height, + DRM_FORMAT_XRGB8888, + handles, strides, offsets, + I915_TILING_NONE, &fb_id[i], + LOCAL_DRM_MODE_FB_MODIFIERS) == 0); + igt_assert(fb_id[i]); }