[android]: use new ioctl to detect heap status

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@551 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2016-01-28 01:18:05 +00:00
parent 569d932fa1
commit 75c4f0b8ac

View File

@@ -177,6 +177,7 @@ typedef struct {
#define VPU_IOC_MAGIC 'l'
#define VPU_IOC_PROBE_IOMMU_STATUS _IOR(VPU_IOC_MAGIC, 5, unsigned long)
#define VPU_IOC_PROBE_HEAP_STATUS _IOR(VPU_IOC_MAGIC, 6, unsigned long)
const char *dev_ion = "/dev/ion";
const char *dev_vpu = "/dev/vpu_service";
static RK_S32 ion_heap_id = -1;
@@ -214,27 +215,34 @@ MPP_RET os_allocator_ion_open(void **ctx, size_t alignment)
* if there is vpu_service then check the iommu_enable status
*/
if (ion_heap_id < 0) {
int iommu_enabled = -2;
int use_vmalloc_heap = 0;
int vpu_fd = open(dev_vpu, O_RDWR);
if (vpu_fd >= 0) {
int ret = ioctl(vpu_fd, VPU_IOC_PROBE_IOMMU_STATUS, &iommu_enabled);
int ret = ioctl(vpu_fd, VPU_IOC_PROBE_HEAP_STATUS, &use_vmalloc_heap);
if (ret) {
iommu_enabled = 0;
mpp_err("can not get iommu status, disable iommu\n");
int iommu_enabled = -1;
mpp_err("mpp can not get heap status\n");
ret = ioctl(vpu_fd, VPU_IOC_PROBE_IOMMU_STATUS, &iommu_enabled);
if (ret) {
mpp_err("mpp can not get iommu status\n");
} else {
use_vmalloc_heap = iommu_enabled;
}
}
close(vpu_fd);
} else {
iommu_enabled = 0;
}
if (!iommu_enabled) {
ion_heap_mask = (1 << ION_HEAP_TYPE_DMA);
ion_heap_id = ION_HEAP_TYPE_DMA;
} else {
if (use_vmalloc_heap) {
ion_heap_mask = (1 << ION_HEAP_TYPE_SYSTEM);
ion_heap_id = ION_HEAP_TYPE_SYSTEM;
} else {
ion_heap_mask = (1 << ION_HEAP_TYPE_DMA);
ion_heap_id = ION_HEAP_TYPE_DMA;
}
mpp_log("using ion heap %s\n", (ion_heap_id == ION_HEAP_TYPE_SYSTEM) ?
mpp_log("using ion heap %s\n", (use_vmalloc_heap) ?
("ION_HEAP_TYPE_SYSTEM") : ("ION_HEAP_TYPE_DMA"));
}
p->alignment = alignment;