summaryrefslogtreecommitdiff
path: root/src/etnaviv/viv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/etnaviv/viv.c')
-rw-r--r--src/etnaviv/viv.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/etnaviv/viv.c b/src/etnaviv/viv.c
index 7a9e544..b3f6225 100644
--- a/src/etnaviv/viv.c
+++ b/src/etnaviv/viv.c
@@ -49,6 +49,27 @@
#endif
//#define DEBUG
+union rmk_gcabi_header {
+ uint32_t padding[16];
+ struct {
+ uint32_t zero;
+#ifdef GCABI_HAS_HARDWARE_TYPE
+ uint32_t hwtype;
+#endif
+ uint32_t status;
+ } v4;
+};
+
+/* rmk's extension for importing dmabufs */
+struct viv_dmabuf_map {
+ union rmk_gcabi_header hdr;
+ uint64_t info;
+ uint64_t address;
+ int32_t fd;
+ uint32_t prot;
+};
+#define IOC_GDMABUF_MAP _IOWR('_', 0, struct viv_dmabuf_map)
+
const char *galcore_device[] = {"/dev/gal3d", "/dev/galcore", "/dev/graphics/galcore", NULL};
#define INTERFACE_SIZE (sizeof(gcsHAL_INTERFACE))
@@ -578,6 +599,23 @@ int viv_free_contiguous(struct viv_conn *conn, size_t bytes, viv_addr_t physical
return viv_invoke(conn, &id);
}
+int viv_map_dmabuf(struct viv_conn *conn, int fd, viv_usermem_t *info, viv_addr_t *address, int prot)
+{
+ struct viv_dmabuf_map map = {
+#ifdef GCABI_HAS_HARDWARE_TYPE
+ .hdr.v4.hwtype = (gceHARDWARE_TYPE)conn->hw_type,
+#endif
+ .fd = fd,
+ .prot = prot,
+ };
+ int ret = viv_ioctl(conn, IOC_GDMABUF_MAP, &map, sizeof(map));
+ if(ret < 0 || map.hdr.v4.status)
+ return -1;
+ *info = VIV_TO_HANDLE(map.info);
+ *address = map.address;
+ return VIV_STATUS_OK;
+}
+
int viv_map_user_memory(struct viv_conn *conn, void *memory, size_t size, viv_usermem_t *info, viv_addr_t *address)
{
gcsHAL_INTERFACE id = {