From 9c49ea272cd546f2cbd0742f26d39f17caf24a06 Mon Sep 17 00:00:00 2001 From: Martin Liu Date: Wed, 12 Apr 2023 22:19:13 +0800 Subject: Separate camera and App dmabuf heap allocation path If a device supports camera GCMA dmabuf heap, then we direct the camera's buffer allocation to use GCMA heap. Thus, we can have a better allocation latency for the camera burst allocation. Bug: 275481134 Test: camera shot and check gcma_camera heap has been used from camera by checking lsof output Change-Id: Iefde6230fc9f44ce271637aed6e0c8084f94b39b Signed-off-by: Martin Liu --- gralloc4/src/allocator/mali_gralloc_ion.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/gralloc4/src/allocator/mali_gralloc_ion.cpp b/gralloc4/src/allocator/mali_gralloc_ion.cpp index 8bfc6d8..183d8a0 100644 --- a/gralloc4/src/allocator/mali_gralloc_ion.cpp +++ b/gralloc4/src/allocator/mali_gralloc_ion.cpp @@ -60,6 +60,8 @@ static const char kDmabufVframeSecureHeapName[] = "vframe-secure"; static const char kDmabufVstreamSecureHeapName[] = "vstream-secure"; static const char kDmabufVscalerSecureHeapName[] = "vscaler-secure"; static const char kDmabufFramebufferSecureHeapName[] = "framebuffer-secure"; +static const char kDmabufGcmaCameraHeapName[] = "gcma_camera"; +static const char kDmabufGcmaCameraUncachedHeapName[] = "gcma_camera-uncached"; BufferAllocator& get_allocator() { static BufferAllocator allocator; @@ -116,7 +118,7 @@ std::string select_dmabuf_heap(uint64_t usage) }, }}; - static const std::array inexact_usage_heaps = + static const std::array inexact_usage_heaps = {{ // If GPU, use vframe-secure { @@ -146,6 +148,18 @@ std::string select_dmabuf_heap(uint64_t usage) kDmabufSensorDirectHeapName }, + // Camera GCMA heap + { + GRALLOC_USAGE_HW_CAMERA_WRITE, + find_first_available_heap({kDmabufGcmaCameraUncachedHeapName, kDmabufSystemUncachedHeapName}) + }, + + // Camera GCMA heap + { + GRALLOC_USAGE_HW_CAMERA_READ, + find_first_available_heap({kDmabufGcmaCameraUncachedHeapName, kDmabufSystemUncachedHeapName}) + }, + // Catchall to system { 0, @@ -165,7 +179,10 @@ std::string select_dmabuf_heap(uint64_t usage) { if ((usage & heap.usage_bits) == heap.usage_bits) { - if (heap.name == kDmabufSystemUncachedHeapName && + if (heap.name == kDmabufGcmaCameraUncachedHeapName && + ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)) + return kDmabufGcmaCameraHeapName; + else if (heap.name == kDmabufSystemUncachedHeapName && ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)) return kDmabufSystemHeapName; -- cgit v1.2.3