int alloc (size_t size) const;
int dealloc (int dmabuf) const;
+ int getMemoryStatus (size_t *alloc, size_t *free) const;
void *mmap (int dmabuf, size_t size) const;
int munmap (void *addr, size_t size) const;
int alloc (size_t size) const;
int dealloc (int dmabuf) const;
+ int getMemoryStatus (size_t *alloc, size_t *free) const;
void *mmap (int dmabuf, size_t size) const;
int munmap (void *addr, size_t size) const;
if (!this->initialized())
return -EPERM;
- ret= ioctl (this->getDeviceFD (), TRINITY_IOCTL_HWMEM_DEALLOC, &dmabuf);
+ ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_HWMEM_DEALLOC, &dmabuf);
if (ret < 0)
return -errno;
}
/**
+ * @brief get the current memory status
+ * @param[out] alloc_total The size of allocated memory until now
+ * @param[out] free_total The size of freed memory until now
+ * @return 0 if no error. otherwise a negatice error value
+ */
+int
+TrinityVisionAPI::getMemoryStatus (size_t *alloc_total, size_t *free_total) const
+{
+ struct trinity_memory_stat stat;
+ int ret;
+
+ if (!initialized())
+ return -EPERM;
+
+ if (alloc_total == nullptr || free_total == nullptr)
+ return -EINVAL;
+
+ ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_MEMORY_STATUS, &stat);
+ if (ret < 0)
+ return -errno;
+
+ *alloc_total = stat.total_alloc_mem;
+ *free_total = stat.total_freed_mem;
+
+ return 0;
+}
+
+/**
* @brief do mmap() for the dmabuf fd
* @param[in] dmabuf dmabuf fd
* @param[in] size size to be mmapped
if (!this->initialized())
return -EPERM;
- ret= ioctl (this->getDeviceFD (), TRINITY_IOCTL_HWMEM_DEALLOC, &dmabuf);
+ ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_HWMEM_DEALLOC, &dmabuf);
if (ret < 0)
return -errno;
}
/**
+ * @brief get the current memory status
+ * @param[out] alloc_total The size of allocated memory until now
+ * @param[out] free_total The size of freed memory until now
+ * @return 0 if no error. otherwise a negatice error value
+ */
+int
+TrinityVision2API::getMemoryStatus (size_t *alloc_total, size_t *free_total) const
+{
+ struct trinity_memory_stat stat;
+ int ret;
+
+ if (!initialized())
+ return -EPERM;
+
+ if (alloc_total == nullptr || free_total == nullptr)
+ return -EINVAL;
+
+ ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_MEMORY_STATUS, &stat);
+ if (ret < 0)
+ return -errno;
+
+ *alloc_total = stat.total_alloc_mem;
+ *free_total = stat.total_freed_mem;
+
+ return 0;
+}
+
+/**
* @brief do mmap() for the dmabuf fd
* @param[in] dmabuf dmabuf fd
* @param[in] size size to be mmapped