From patchwork Tue Mar 8 14:51:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 8534971 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7EA2B9F2B4 for ; Tue, 8 Mar 2016 14:52:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E994200D0 for ; Tue, 8 Mar 2016 14:52:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C58D0200D4 for ; Tue, 8 Mar 2016 14:52:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D69996E6FD; Tue, 8 Mar 2016 14:52:24 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 59C2B6E6F9 for ; Tue, 8 Mar 2016 14:52:19 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id n186so4560527wmn.0 for ; Tue, 08 Mar 2016 06:52:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9QsZ/JNCgv2k1xpuo5pEyIsyX1mIt4+rXmI0e2N4wTM=; b=GRPVr1vLbpJpxyd5ZocXmQvRW/WQ8jIyMhSWRZYlshBAP+TCcBt9TABV+Okirnjmbp /8vez9Ai3yBFSitKdty45q/p6Bkxjm0miGIzYY0QwGFz0qfddHMO+JsWsRlmWGmAGQvD rUEB4fdXwR/4vwFK9ol71H0pbpSCEM0GXJlnl82HwMRtO3t3o22/wyz90L9VHnlNou4H fTGemi2M6pc9KQtD6KuTUgTgBwKiJsNyvPz+DmV3wGYV/Id9y0rpxhopaXANN4aKj7EI wuPiDQNIdLvWwqNYw0HeUDBh9h/wHAakbkYZfAbcaIiKFetFjR1MmrYze30s5eiFElAn 6Quw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9QsZ/JNCgv2k1xpuo5pEyIsyX1mIt4+rXmI0e2N4wTM=; b=WcfyR660BAHgERNENuo936WOZSWq8BqQ8kysVb5BAls5Cl7WVvJ6p/MsXq98kL2Vhr dJpDnMQndkGB96MTGJgz1oGieuiPGXcVB8uZAjBYb8SjlBJuzC5L08vykuHG3PJ1YGNB 1JRrW8cXjtMW2J3yPG1fY4b1exvq4XEiy22USVz5+wk/jhlLolcQkkFGppDlwll0qEix FvdA3pUjt3HhUU9oDfp/ArE7Of/YJF93wLiAjWz17Ao2U0JEU8mI3LAN551s4+hDr5TW Cli1Rj7BnCQgCIKsvQVyBbQg3QLIKehvl+aGVnoWmAcinVy6OsCha6Jna7IS6Ue469Zm YiFw== X-Gm-Message-State: AD7BkJIZVnUWkSNxzr+ADr4GUxVAXu+MpP8XuA9LwKtXVL2UMhGrmLP2b5ZWjCp5H97GzQ== X-Received: by 10.28.212.19 with SMTP id l19mr18861635wmg.97.1457448737471; Tue, 08 Mar 2016 06:52:17 -0800 (PST) Received: from cizrna.lan ([109.72.12.208]) by smtp.gmail.com with ESMTPSA id 3sm3781979wmp.14.2016.03.08.06.52.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Mar 2016 06:52:16 -0800 (PST) From: Tomeu Vizoso To: Intel GFX discussion Date: Tue, 8 Mar 2016 15:51:30 +0100 Message-Id: <1457448699-9778-9-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457448699-9778-1-git-send-email-tomeu.vizoso@collabora.com> References: <1457448699-9778-1-git-send-email-tomeu.vizoso@collabora.com> Cc: Daniel Stone , Tomeu Vizoso , Micah Fedke , Gustavo Padovan , Emil Velikov Subject: [Intel-gfx] [i-g-t PATCH v2 08/17] lib: Add helper kmstest_dumb_map_buffer X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Which basically just calls DRM_IOCTL_MODE_MAP_DUMB and is similar to gem_mmap__gtt(). Signed-off-by: Tomeu Vizoso --- Changes in v2: - Add helper kmstest_dumb_map_buffer as suggested by Daniel Vetter lib/igt_kms.c | 16 ++++++++++++++++ lib/igt_kms.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index ee375bffc5e2..a98c22a7f4dc 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -345,6 +345,22 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp, return create.handle; } +void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size, + unsigned prot) +{ + struct drm_mode_map_dumb arg = {}; + void *ptr; + + arg.handle = handle; + + do_ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg); + + ptr = mmap(0, size, prot, MAP_SHARED, fd, arg.offset); + igt_assert(ptr != MAP_FAILED); + + return ptr; +} + /* * Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was * found and nothing was done. diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 45df8b556daf..af794cf2c916 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -158,6 +158,9 @@ uint32_t kmstest_find_crtc_for_connector(int fd, drmModeRes *res, uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp, unsigned *stride, unsigned *size); +void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size, + unsigned prot); + /* * A small modeset API */