|
|
@ -7,7 +7,7 @@ |
|
|
|
#include <sys/types.h> |
|
|
|
#include <sys/types.h> |
|
|
|
#include <sys/stat.h> |
|
|
|
#include <sys/stat.h> |
|
|
|
#include <fcntl.h> |
|
|
|
#include <fcntl.h> |
|
|
|
|
|
|
|
#include <unistd.h> |
|
|
|
#include <linux/ion.h> |
|
|
|
#include <linux/ion.h> |
|
|
|
#include <CL/cl_ext.h> |
|
|
|
#include <CL/cl_ext.h> |
|
|
|
|
|
|
|
|
|
|
@ -64,6 +64,7 @@ VisionBuf visionbuf_allocate(size_t len) { |
|
|
|
|
|
|
|
|
|
|
|
return (VisionBuf){ |
|
|
|
return (VisionBuf){ |
|
|
|
.len = len, |
|
|
|
.len = len, |
|
|
|
|
|
|
|
.mmap_len = ion_alloc.len, |
|
|
|
.addr = addr, |
|
|
|
.addr = addr, |
|
|
|
.handle = ion_alloc.handle, |
|
|
|
.handle = ion_alloc.handle, |
|
|
|
.fd = ion_fd_data.fd, |
|
|
|
.fd = ion_fd_data.fd, |
|
|
@ -73,6 +74,7 @@ VisionBuf visionbuf_allocate(size_t len) { |
|
|
|
VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx, cl_mem *out_mem) { |
|
|
|
VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx, cl_mem *out_mem) { |
|
|
|
VisionBuf r = visionbuf_allocate(len); |
|
|
|
VisionBuf r = visionbuf_allocate(len); |
|
|
|
*out_mem = visionbuf_to_cl(&r, device_id, ctx); |
|
|
|
*out_mem = visionbuf_to_cl(&r, device_id, ctx); |
|
|
|
|
|
|
|
r.buf_cl = *out_mem; |
|
|
|
return r; |
|
|
|
return r; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -137,6 +139,9 @@ void visionbuf_sync(const VisionBuf* buf, int dir) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void visionbuf_free(const VisionBuf* buf) { |
|
|
|
void visionbuf_free(const VisionBuf* buf) { |
|
|
|
|
|
|
|
clReleaseMemObject(buf->buf_cl); |
|
|
|
|
|
|
|
munmap(buf->addr, buf->mmap_len); |
|
|
|
|
|
|
|
close(buf->fd); |
|
|
|
struct ion_handle_data handle_data = { |
|
|
|
struct ion_handle_data handle_data = { |
|
|
|
.handle = buf->handle, |
|
|
|
.handle = buf->handle, |
|
|
|
}; |
|
|
|
}; |
|
|
|