diff options
author | Jammy Zhou | 2015-02-02 04:06:27 -0600 |
---|---|---|
committer | Alex Deucher | 2015-02-12 17:36:52 -0600 |
commit | dbc8b11db6f3fcbe2a76487bb0b1930908226a17 (patch) | |
tree | 50616ecce60e9cb8c2856aa16b20cc076730be18 /xf86drm.c | |
parent | f1adc4b375a16b07f560b86a34e617984049c422 (diff) | |
download | external-libdrm-dbc8b11db6f3fcbe2a76487bb0b1930908226a17.tar.gz external-libdrm-dbc8b11db6f3fcbe2a76487bb0b1930908226a17.tar.xz external-libdrm-dbc8b11db6f3fcbe2a76487bb0b1930908226a17.zip |
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.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -2567,6 +2567,7 @@ static struct { | |||
2567 | char *BusID; | 2567 | char *BusID; |
2568 | int fd; | 2568 | int fd; |
2569 | int refcount; | 2569 | int refcount; |
2570 | int type; | ||
2570 | } connection[DRM_MAX_FDS]; | 2571 | } connection[DRM_MAX_FDS]; |
2571 | 2572 | ||
2572 | static int nr_fds = 0; | 2573 | static int nr_fds = 0; |
@@ -2575,23 +2576,30 @@ int drmOpenOnce(void *unused, | |||
2575 | const char *BusID, | 2576 | const char *BusID, |
2576 | int *newlyopened) | 2577 | int *newlyopened) |
2577 | { | 2578 | { |
2579 | return drmOpenOnceWithType(BusID, newlyopened, DRM_NODE_PRIMARY); | ||
2580 | } | ||
2581 | |||
2582 | int drmOpenOnceWithType(const char *BusID, int *newlyopened, int type) | ||
2583 | { | ||
2578 | int i; | 2584 | int i; |
2579 | int fd; | 2585 | int fd; |
2580 | 2586 | ||
2581 | for (i = 0; i < nr_fds; i++) | 2587 | for (i = 0; i < nr_fds; i++) |
2582 | if (strcmp(BusID, connection[i].BusID) == 0) { | 2588 | if ((strcmp(BusID, connection[i].BusID) == 0) && |
2589 | (connection[i].type == type)) { | ||
2583 | connection[i].refcount++; | 2590 | connection[i].refcount++; |
2584 | *newlyopened = 0; | 2591 | *newlyopened = 0; |
2585 | return connection[i].fd; | 2592 | return connection[i].fd; |
2586 | } | 2593 | } |
2587 | 2594 | ||
2588 | fd = drmOpen(unused, BusID); | 2595 | fd = drmOpenWithType(NULL, BusID, type); |
2589 | if (fd <= 0 || nr_fds == DRM_MAX_FDS) | 2596 | if (fd <= 0 || nr_fds == DRM_MAX_FDS) |
2590 | return fd; | 2597 | return fd; |
2591 | 2598 | ||
2592 | connection[nr_fds].BusID = strdup(BusID); | 2599 | connection[nr_fds].BusID = strdup(BusID); |
2593 | connection[nr_fds].fd = fd; | 2600 | connection[nr_fds].fd = fd; |
2594 | connection[nr_fds].refcount = 1; | 2601 | connection[nr_fds].refcount = 1; |
2602 | connection[nr_fds].type = type; | ||
2595 | *newlyopened = 1; | 2603 | *newlyopened = 1; |
2596 | 2604 | ||
2597 | if (0) | 2605 | if (0) |