aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Packard2017-03-16 20:11:05 -0500
committerDave Airlie2017-12-17 18:04:02 -0600
commitc4171535389d72e9135c9615cecd07b346fd6d7e (patch)
tree6f60211c60b039c06a2ed9372f97e0376ca5bad8 /xf86drmMode.c
parent5889f6ba1a250777ff8b6ba96a35dba3f02071ff (diff)
downloadexternal-libdrm-c4171535389d72e9135c9615cecd07b346fd6d7e.tar.gz
external-libdrm-c4171535389d72e9135c9615cecd07b346fd6d7e.tar.xz
external-libdrm-c4171535389d72e9135c9615cecd07b346fd6d7e.zip
drm: Add drm mode lease ioctl wrappers [v3]
drmModeCreateLease drmModeListLessees drmModeGetLease drmModeRevokeLease Changes for v2: Remove lessee id from GetLease Remove lessor_id from ListLeases Add revoke Renumber to track kernel rebase on drm-next Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'xf86drmMode.c')
-rw-r--r--xf86drmMode.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 2b3887b3..eddad8c4 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1485,3 +1485,92 @@ drmModeDestroyPropertyBlob(int fd, uint32_t id)
1485 destroy.blob_id = id; 1485 destroy.blob_id = id;
1486 return DRM_IOCTL(fd, DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy); 1486 return DRM_IOCTL(fd, DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy);
1487} 1487}
1488
1489int
1490drmModeCreateLease(int fd, const uint32_t *objects, int num_objects, int flags, uint32_t *lessee_id)
1491{
1492 struct drm_mode_create_lease create;
1493 int ret;
1494
1495 memclear(create);
1496 create.object_ids = (uintptr_t) objects;
1497 create.object_count = num_objects;
1498 create.flags = flags;
1499
1500 ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_CREATE_LEASE, &create);
1501 if (ret == 0) {
1502 *lessee_id = create.lessee_id;
1503 return create.fd;
1504 }
1505 return -errno;
1506}
1507
1508drmModeLesseeListPtr
1509drmModeListLessees(int fd)
1510{
1511 struct drm_mode_list_lessees list;
1512 uint32_t count;
1513 drmModeLesseeListPtr ret;
1514
1515 memclear(list);
1516
1517 if (DRM_IOCTL(fd, DRM_IOCTL_MODE_LIST_LESSEES, &list))
1518 return NULL;
1519
1520 count = list.count_lessees;
1521 ret = drmMalloc(sizeof (drmModeLesseeListRes) + count * sizeof (ret->lessees[0]));
1522 if (!ret)
1523 return NULL;
1524
1525 list.lessees_ptr = VOID2U64(&ret->lessees[0]);
1526 if (DRM_IOCTL(fd, DRM_IOCTL_MODE_LIST_LESSEES, &list)) {
1527 drmFree(ret);
1528 return NULL;
1529 }
1530
1531 ret->count = count;
1532 return ret;
1533}
1534
1535drmModeObjectListPtr
1536drmModeGetLease(int fd)
1537{
1538 struct drm_mode_get_lease get;
1539 uint32_t count;
1540 drmModeObjectListPtr ret;
1541
1542 memclear(get);
1543
1544 if (DRM_IOCTL(fd, DRM_IOCTL_MODE_GET_LEASE, &get))
1545 return NULL;
1546
1547 count = get.count_objects;
1548 ret = drmMalloc(sizeof (drmModeObjectListRes) + count * sizeof (ret->objects[0]));
1549 if (!ret)
1550 return NULL;
1551
1552 get.objects_ptr = VOID2U64(&ret->objects[0]);
1553 if (DRM_IOCTL(fd, DRM_IOCTL_MODE_GET_LEASE, &get)) {
1554 drmFree(ret);
1555 return NULL;
1556 }
1557
1558 ret->count = count;
1559 return ret;
1560}
1561
1562int
1563drmModeRevokeLease(int fd, uint32_t lessee_id)
1564{
1565 struct drm_mode_revoke_lease revoke;
1566 int ret;
1567
1568 memclear(revoke);
1569
1570 revoke.lessee_id = lessee_id;
1571
1572 ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_REVOKE_LEASE, &revoke);
1573 if (ret == 0)
1574 return 0;
1575 return -errno;
1576}