diff options
author | Russell King <rmk@arm.linux.org.uk> | 2015-06-12 19:41:16 +0100 |
---|---|---|
committer | Russell King <rmk@arm.linux.org.uk> | 2015-06-29 12:58:35 +0100 |
commit | 9cd088f787aad8bea8dfa1d233dbf05375a21845 (patch) | |
tree | dc93dc207e540e269a088da976b4dc2e2c220218 | |
parent | 3eed819606b37fdbf9e0ae7f6c226fd5e8037d6d (diff) |
etnadrm: add support for retrieving the bo size
Add support for retrieving the bo size from bos, including dmabuf and
usermem bos. This is needed for Xvbo support.
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
-rw-r--r-- | etnaviv/etnadrm.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/etnaviv/etnadrm.c b/etnaviv/etnadrm.c index a2cc27b..edd975e 100644 --- a/etnaviv/etnadrm.c +++ b/etnaviv/etnadrm.c @@ -435,12 +435,21 @@ struct etna_bo *etna_bo_new(struct viv_conn *conn, size_t bytes, uint32_t flags) struct etna_bo *etna_bo_from_dmabuf(struct viv_conn *conn, int fd, int prot) { struct etna_bo *mem; + off_t size; int err; mem = etna_bo_alloc(conn); if (!mem) return NULL; + size = lseek(fd, 0, SEEK_END); + if (size == (off_t)-1) { + free(mem); + return NULL; + } + + mem->size = size; + err = drmPrimeFDToHandle(conn->fd, fd, &mem->handle); if (err) { free(mem); @@ -490,6 +499,7 @@ struct etna_bo *etna_bo_from_usermem_prot(struct viv_conn *conn, void *memory, s free(mem); mem = NULL; } else { + mem->size = size; mem->handle = req.handle; mem->is_usermem = TRUE; } @@ -527,6 +537,11 @@ uint32_t etna_bo_handle(struct etna_bo *bo) return bo->handle; } +uint32_t etna_bo_size(struct etna_bo *bo) +{ + return bo->size; +} + struct _gcoCMDBUF { void *logical; |