diff --git a/gralloc_priv.h b/gralloc_priv.h index 5b04c8e..6e781aa 100644 --- a/gralloc_priv.h +++ b/gralloc_priv.h @@ -40,6 +40,7 @@ enum { /* gralloc usage bit indicating a pmem_adsp allocation should be used */ GRALLOC_USAGE_PRIVATE_PMEM_ADSP = GRALLOC_USAGE_PRIVATE_0, GRALLOC_USAGE_PRIVATE_PMEM = GRALLOC_USAGE_PRIVATE_1, + GRALLOC_USAGE_PRIVATE_ASHMEM = GRALLOC_USAGE_PRIVATE_2, }; /* numbers of max buffers for page flipping */ diff --git a/mapper.cpp b/mapper.cpp index 5e194c7..5b7a6e4 100644 --- a/mapper.cpp +++ b/mapper.cpp @@ -340,18 +340,22 @@ int gralloc_perform(struct gralloc_module_t const* module, size_t offset = va_arg(args, size_t); void* base = va_arg(args, void*); - // validate that it's indeed a pmem buffer - pmem_region region; - if (ioctl(fd, PMEM_GET_SIZE, ®ion) < 0) { - break; - } - native_handle_t** handle = va_arg(args, native_handle_t**); + int memoryFlags = va_arg(args, int); + if (memoryFlags == GRALLOC_USAGE_PRIVATE_PMEM) { + // validate that it's indeed a pmem buffer + pmem_region region; + if (ioctl(fd, PMEM_GET_SIZE, ®ion) < 0) { + break; + } + } private_handle_t* hnd = (private_handle_t*)native_handle_create( private_handle_t::sNumFds, private_handle_t::sNumInts); hnd->magic = private_handle_t::sMagic; hnd->fd = fd; - hnd->flags = private_handle_t::PRIV_FLAGS_USES_PMEM; + hnd->flags = (memoryFlags == GRALLOC_USAGE_PRIVATE_PMEM) ? + private_handle_t::PRIV_FLAGS_USES_PMEM : + private_handle_t::PRIV_FLAGS_USES_ASHMEM; hnd->size = size; hnd->offset = offset; hnd->base = intptr_t(base) + offset;