diff options
author | Ankit Goyal <layog@google.com> | 2023-04-07 21:25:30 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-04-07 21:25:30 +0000 |
commit | 6f9e7ef8875b835af9c72e9b562be8639367f46d (patch) | |
tree | 31d7d476cb6102f3ab456f50d642d45b86dfaadf | |
parent | 14b7242a56497acaa81672df0b6cad14640fb616 (diff) | |
parent | cb7b2c0643e7eec8c59183ebdd0b1b64be56bc85 (diff) | |
download | gchips-6f9e7ef8875b835af9c72e9b562be8639367f46d.tar.gz |
Merge changes from topic "gralloc-no-ion" into udc-dev am: cb7b2c0643
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/google/gchips/+/22465471
Change-Id: Ief4a76bc6db1be219149fcb6f156b859a5f8ddbd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | gralloc4/src/allocator/mali_gralloc_ion.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/gralloc4/src/allocator/mali_gralloc_ion.cpp b/gralloc4/src/allocator/mali_gralloc_ion.cpp index 634e336..8bfc6d8 100644 --- a/gralloc4/src/allocator/mali_gralloc_ion.cpp +++ b/gralloc4/src/allocator/mali_gralloc_ion.cpp @@ -59,12 +59,23 @@ static const char kDmabufFaceauthModelHeapName[] = "famodel-secure"; static const char kDmabufVframeSecureHeapName[] = "vframe-secure"; static const char kDmabufVstreamSecureHeapName[] = "vstream-secure"; static const char kDmabufVscalerSecureHeapName[] = "vscaler-secure"; +static const char kDmabufFramebufferSecureHeapName[] = "framebuffer-secure"; BufferAllocator& get_allocator() { static BufferAllocator allocator; return allocator; } +std::string find_first_available_heap(const std::initializer_list<std::string>&& options) { + static auto available_heaps = BufferAllocator::GetDmabufHeapList(); + + for (const auto& heap: options) + if (available_heaps.find(heap) != available_heaps.end()) + return heap; + + return ""; +} + std::string select_dmabuf_heap(uint64_t usage) { struct HeapSpecifier @@ -73,8 +84,7 @@ std::string select_dmabuf_heap(uint64_t usage) std::string name; }; - // exact match required - static const std::array<HeapSpecifier, 5> faceauth_heaps = + static const std::array<HeapSpecifier, 6> exact_usage_heaps = {{ // Faceauth heaps { // isp_image_heap @@ -98,9 +108,15 @@ std::string select_dmabuf_heap(uint64_t usage) GRALLOC_USAGE_PROTECTED | GS101_GRALLOC_USAGE_TPU_OUTPUT | GS101_GRALLOC_USAGE_TPU_INPUT, kDmabufFaceauthTpuHeapName }, + + { + GRALLOC_USAGE_PROTECTED | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER | + GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_FB, + find_first_available_heap({kDmabufFramebufferSecureHeapName, kDmabufVframeSecureHeapName}) + }, }}; - static const std::array<HeapSpecifier, 6> other_heaps = + static const std::array<HeapSpecifier, 6> inexact_usage_heaps = {{ // If GPU, use vframe-secure { @@ -137,7 +153,7 @@ std::string select_dmabuf_heap(uint64_t usage) } }}; - for (const HeapSpecifier &heap : faceauth_heaps) + for (const HeapSpecifier &heap : exact_usage_heaps) { if (usage == heap.usage_bits) { @@ -145,21 +161,19 @@ std::string select_dmabuf_heap(uint64_t usage) } } - std::string heap_name; - for (const HeapSpecifier &heap : other_heaps) + for (const HeapSpecifier &heap : inexact_usage_heaps) { if ((usage & heap.usage_bits) == heap.usage_bits) { - heap_name = heap.name; - break; + if (heap.name == kDmabufSystemUncachedHeapName && + ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)) + return kDmabufSystemHeapName; + + return heap.name; } } - if (heap_name == kDmabufSystemUncachedHeapName && - ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)) - heap_name = kDmabufSystemHeapName; - - return heap_name; + return ""; } int alloc_from_dmabuf_heap(uint64_t usage, size_t size, const std::string& buffer_name = "") |