From patchwork Thu Oct 31 23:13:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 3122611 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A35C09F3E3 for ; Thu, 31 Oct 2013 23:25:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 861DA200F4 for ; Thu, 31 Oct 2013 23:31:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4165F200EA for ; Thu, 31 Oct 2013 23:31:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CA755F00B8; Thu, 31 Oct 2013 16:31:24 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 08D33F00B8; Thu, 31 Oct 2013 16:31:22 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Vc1hr-0005QY-FT; Thu, 31 Oct 2013 23:31:15 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Vc1hj-0005Pa-43; Thu, 31 Oct 2013 23:31:07 +0000 X-ACL-Warn: Received: from home.keithp.com ([63.227.221.253] helo=keithp.com) by sog-mx-4.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1Vc1hg-0002zq-5K; Thu, 31 Oct 2013 23:31:06 +0000 Received: from localhost (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id A46A61584008; Thu, 31 Oct 2013 16:13:31 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from keithp.com ([127.0.0.1]) by localhost (keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id XZUGgfu-grV0; Thu, 31 Oct 2013 16:13:27 -0700 (PDT) Received: by keithp.com (Postfix, from userid 1033) id EE44B1584009; Thu, 31 Oct 2013 16:13:18 -0700 (PDT) Received: from miki.keithp.com (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id 1B08714A8037; Thu, 31 Oct 2013 16:13:18 -0700 (PDT) Received: by miki.keithp.com (Postfix, from userid 1001) id 77657B93; Thu, 31 Oct 2013 16:13:17 -0700 (PDT) From: Keith Packard To: mesa3d-dev@lists.sourceforge.net Subject: [PATCH 4/6] dri/intel: Add intel_fd_for_region Date: Thu, 31 Oct 2013 16:13:14 -0700 Message-Id: <1383261196-25093-5-git-send-email-keithp@keithp.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1383261196-25093-1-git-send-email-keithp@keithp.com> References: <1383261196-25093-1-git-send-email-keithp@keithp.com> X-Spam-Score: -0.5 (/) X-Headers-End: 1Vc1hg-0002zq-5K X-BeenThere: dri-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list MIME-Version: 1.0 Cc: dri-devel@lists.sourceforge.net X-BeenThere: dri-devel@lists.freedesktop.org List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Returns a prime file descriptor for the specified region. Signed-off-by: Keith Packard Reviewed-by: Kristian Høgsberg --- src/mesa/drivers/dri/i915/intel_regions.c | 13 +++++++++++++ src/mesa/drivers/dri/i915/intel_regions.h | 4 ++++ src/mesa/drivers/dri/i965/intel_regions.c | 13 +++++++++++++ src/mesa/drivers/dri/i965/intel_regions.h | 4 ++++ 4 files changed, 34 insertions(+) diff --git a/src/mesa/drivers/dri/i915/intel_regions.c b/src/mesa/drivers/dri/i915/intel_regions.c index 9f5b89e..bac997d 100644 --- a/src/mesa/drivers/dri/i915/intel_regions.c +++ b/src/mesa/drivers/dri/i915/intel_regions.c @@ -238,6 +238,19 @@ intel_region_alloc_for_fd(struct intel_screen *screen, return region; } +int +intel_fd_for_region(struct intel_screen *screen, + struct intel_region *region) +{ + int fd; + int ret; + + ret = drm_intel_bo_gem_export_to_prime(region->bo, &fd); + if (ret < 0) + return ret; + return fd; +} + void intel_region_reference(struct intel_region **dst, struct intel_region *src) { diff --git a/src/mesa/drivers/dri/i915/intel_regions.h b/src/mesa/drivers/dri/i915/intel_regions.h index 6bc4a42..84c013a 100644 --- a/src/mesa/drivers/dri/i915/intel_regions.h +++ b/src/mesa/drivers/dri/i915/intel_regions.h @@ -93,6 +93,10 @@ intel_region_alloc_for_fd(struct intel_screen *screen, GLuint width, GLuint height, GLuint pitch, GLuint size, int fd, const char *name); +int +intel_fd_for_region(struct intel_screen *screen, + struct intel_region *region); + bool intel_region_flink(struct intel_region *region, uint32_t *name); diff --git a/src/mesa/drivers/dri/i965/intel_regions.c b/src/mesa/drivers/dri/i965/intel_regions.c index 3920f4f..2e70326 100644 --- a/src/mesa/drivers/dri/i965/intel_regions.c +++ b/src/mesa/drivers/dri/i965/intel_regions.c @@ -238,6 +238,19 @@ intel_region_alloc_for_fd(struct intel_screen *screen, return region; } +int +intel_fd_for_region(struct intel_screen *screen, + struct intel_region *region) +{ + int fd; + int ret; + + ret = drm_intel_bo_gem_export_to_prime(region->bo, &fd); + if (ret < 0) + return ret; + return fd; +} + void intel_region_reference(struct intel_region **dst, struct intel_region *src) { diff --git a/src/mesa/drivers/dri/i965/intel_regions.h b/src/mesa/drivers/dri/i965/intel_regions.h index 05dfef3..f471b94 100644 --- a/src/mesa/drivers/dri/i965/intel_regions.h +++ b/src/mesa/drivers/dri/i965/intel_regions.h @@ -95,6 +95,10 @@ intel_region_alloc_for_fd(struct intel_screen *screen, GLuint size, int fd, const char *name); +int +intel_fd_for_region(struct intel_screen *screen, + struct intel_region *region); + bool intel_region_flink(struct intel_region *region, uint32_t *name);