Add new drmOpenRender function

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 <frank.binns@imgtec.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
main
Frank Binns 2015-01-14 14:07:51 +00:00 committed by Emil Velikov
parent ad8bbfd3c7
commit 0c5aaeef51
2 changed files with 40 additions and 2 deletions

View File

@ -87,6 +87,7 @@
#define DRM_NODE_CONTROL 0 #define DRM_NODE_CONTROL 0
#define DRM_NODE_PRIMARY 1 #define DRM_NODE_PRIMARY 1
#define DRM_NODE_RENDER 2
static drmServerInfoPtr drm_server_info; 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) static int drmOpenDevice(long dev, int minor, int type)
{ {
stat_t st; stat_t st;
const char *dev_name;
char buf[64]; char buf[64];
int fd; int fd;
mode_t devmode = DRM_DEV_MODE, serv_mode; 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; uid_t user = DRM_DEV_UID;
gid_t group = DRM_DEV_GID, serv_group; 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); drmMsg("drmOpenDevice: node name is %s\n", buf);
if (drm_server_info) { if (drm_server_info) {
@ -417,11 +433,26 @@ static int drmOpenMinor(int minor, int create, int type)
{ {
int fd; int fd;
char buf[64]; char buf[64];
const char *dev_name;
if (create) if (create)
return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type); 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) if ((fd = open(buf, O_RDWR, 0)) >= 0)
return fd; return fd;
return -errno; return -errno;
@ -646,6 +677,11 @@ int drmOpenControl(int minor)
return drmOpenMinor(minor, 0, DRM_NODE_CONTROL); 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(). * Free the version information returned by drmGetVersion().
* *

View File

@ -79,6 +79,7 @@ extern "C" {
#define DRM_DIR_NAME "/dev/dri" #define DRM_DIR_NAME "/dev/dri"
#define DRM_DEV_NAME "%s/card%d" #define DRM_DEV_NAME "%s/card%d"
#define DRM_CONTROL_DEV_NAME "%s/controlD%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_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
#define DRM_ERR_NO_DEVICE (-1001) #define DRM_ERR_NO_DEVICE (-1001)
@ -552,6 +553,7 @@ do { register unsigned int __old __asm("o0"); \
extern int drmAvailable(void); extern int drmAvailable(void);
extern int drmOpen(const char *name, const char *busid); extern int drmOpen(const char *name, const char *busid);
extern int drmOpenControl(int minor); extern int drmOpenControl(int minor);
extern int drmOpenRender(int minor);
extern int drmClose(int fd); extern int drmClose(int fd);
extern drmVersionPtr drmGetVersion(int fd); extern drmVersionPtr drmGetVersion(int fd);
extern drmVersionPtr drmGetLibVersion(int fd); extern drmVersionPtr drmGetLibVersion(int fd);