From patchwork Wed Jan 14 14:07:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Binns X-Patchwork-Id: 5631751 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 66210C058E for ; Wed, 14 Jan 2015 14:08:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 87A8620270 for ; Wed, 14 Jan 2015 14:08:21 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EC3B42026F for ; Wed, 14 Jan 2015 14:08:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C458B6E39C; Wed, 14 Jan 2015 06:08:18 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailapp01.imgtec.com (mailapp01.imgtec.com [195.59.15.196]) by gabe.freedesktop.org (Postfix) with ESMTP id 6739B6E39C for ; Wed, 14 Jan 2015 06:08:18 -0800 (PST) Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id EA2BE435959B8 for ; Wed, 14 Jan 2015 14:08:13 +0000 (GMT) Received: from frankbinns-dev.kl.imgtec.org (192.168.169.99) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 14 Jan 2015 14:08:16 +0000 From: Frank Binns To: Subject: [PATCH libdrm 2/2] Add new drmOpenRender function Date: Wed, 14 Jan 2015 14:07:51 +0000 Message-ID: <1421244471-31081-2-git-send-email-frank.binns@imgtec.com> X-Mailer: git-send-email 1.8.5.4.gfdaaaa2 In-Reply-To: <1421244471-31081-1-git-send-email-frank.binns@imgtec.com> References: <1421244471-31081-1-git-send-email-frank.binns@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.169.99] Cc: rufus.hamade@imgtec.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Add a new function, drmOpenRender, that can be used to open render nodes. This can be used in the same way that drmOpenControl is used to open control nodes. Signed-off-by: Frank Binns --- xf86drm.c | 40 ++++++++++++++++++++++++++++++++++++++-- xf86drm.h | 2 ++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/xf86drm.c b/xf86drm.c index a23d029..345325a 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -87,6 +87,7 @@ #define DRM_NODE_CONTROL 0 #define DRM_NODE_PRIMARY 1 +#define DRM_NODE_RENDER 2 static drmServerInfoPtr drm_server_info; @@ -305,6 +306,7 @@ static int chown_check_return(const char *path, uid_t owner, gid_t group) static int drmOpenDevice(long dev, int minor, int type) { stat_t st; + const char *dev_name; char buf[64]; int fd; mode_t devmode = DRM_DEV_MODE, serv_mode; @@ -312,7 +314,21 @@ static int drmOpenDevice(long dev, int minor, int type) uid_t user = DRM_DEV_UID; gid_t group = DRM_DEV_GID, serv_group; - sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, minor); + switch (type) { + case DRM_NODE_PRIMARY: + dev_name = DRM_DEV_NAME; + break; + case DRM_NODE_CONTROL: + dev_name = DRM_CONTROL_DEV_NAME; + break; + case DRM_NODE_RENDER: + dev_name = DRM_RENDER_DEV_NAME; + break; + default: + return -EINVAL; + }; + + sprintf(buf, dev_name, DRM_DIR_NAME, minor); drmMsg("drmOpenDevice: node name is %s\n", buf); if (drm_server_info) { @@ -417,11 +433,26 @@ static int drmOpenMinor(int minor, int create, int type) { int fd; char buf[64]; + const char *dev_name; if (create) return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type); - sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, minor); + switch (type) { + case DRM_NODE_PRIMARY: + dev_name = DRM_DEV_NAME; + break; + case DRM_NODE_CONTROL: + dev_name = DRM_CONTROL_DEV_NAME; + break; + case DRM_NODE_RENDER: + dev_name = DRM_RENDER_DEV_NAME; + break; + default: + return -EINVAL; + }; + + sprintf(buf, dev_name, DRM_DIR_NAME, minor); if ((fd = open(buf, O_RDWR, 0)) >= 0) return fd; return -errno; @@ -646,6 +677,11 @@ int drmOpenControl(int minor) return drmOpenMinor(minor, 0, DRM_NODE_CONTROL); } +int drmOpenRender(int minor) +{ + return drmOpenMinor(minor, 0, DRM_NODE_RENDER); +} + /** * Free the version information returned by drmGetVersion(). * diff --git a/xf86drm.h b/xf86drm.h index c024cc4..bfd0670 100644 --- a/xf86drm.h +++ b/xf86drm.h @@ -79,6 +79,7 @@ extern "C" { #define DRM_DIR_NAME "/dev/dri" #define DRM_DEV_NAME "%s/card%d" #define DRM_CONTROL_DEV_NAME "%s/controlD%d" +#define DRM_RENDER_DEV_NAME "%s/renderD%d" #define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */ #define DRM_ERR_NO_DEVICE (-1001) @@ -552,6 +553,7 @@ do { register unsigned int __old __asm("o0"); \ extern int drmAvailable(void); extern int drmOpen(const char *name, const char *busid); extern int drmOpenControl(int minor); +extern int drmOpenRender(int minor); extern int drmClose(int fd); extern drmVersionPtr drmGetVersion(int fd); extern drmVersionPtr drmGetLibVersion(int fd);