summaryrefslogtreecommitdiff
path: root/xf86drm.c
diff options
context:
space:
mode:
authorJammy Zhou <Jammy.Zhou@amd.com>2015-02-02 18:06:27 +0800
committerAlex Deucher <alexander.deucher@amd.com>2015-02-12 18:36:52 -0500
commitdbc8b11db6f3fcbe2a76487bb0b1930908226a17 (patch)
tree50616ecce60e9cb8c2856aa16b20cc076730be18 /xf86drm.c
parentf1adc4b375a16b07f560b86a34e617984049c422 (diff)
Add new drmOpenOnceWithType function (v2)
v2: call drmOpenOnceWithType in drmOpenOnce, and drop unused param for drmOpenOnceWithType Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Diffstat (limited to 'xf86drm.c')
-rw-r--r--xf86drm.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/xf86drm.c b/xf86drm.c
index e60c4899..d85115ca 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2567,6 +2567,7 @@ static struct {
char *BusID;
int fd;
int refcount;
+ int type;
} connection[DRM_MAX_FDS];
static int nr_fds = 0;
@@ -2575,23 +2576,30 @@ int drmOpenOnce(void *unused,
const char *BusID,
int *newlyopened)
{
+ return drmOpenOnceWithType(BusID, newlyopened, DRM_NODE_PRIMARY);
+}
+
+int drmOpenOnceWithType(const char *BusID, int *newlyopened, int type)
+{
int i;
int fd;
for (i = 0; i < nr_fds; i++)
- if (strcmp(BusID, connection[i].BusID) == 0) {
+ if ((strcmp(BusID, connection[i].BusID) == 0) &&
+ (connection[i].type == type)) {
connection[i].refcount++;
*newlyopened = 0;
return connection[i].fd;
}
- fd = drmOpen(unused, BusID);
+ fd = drmOpenWithType(NULL, BusID, type);
if (fd <= 0 || nr_fds == DRM_MAX_FDS)
return fd;
connection[nr_fds].BusID = strdup(BusID);
connection[nr_fds].fd = fd;
connection[nr_fds].refcount = 1;
+ connection[nr_fds].type = type;
*newlyopened = 1;
if (0)