summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnkit Goyal <layog@google.com>2023-04-04 15:54:09 -0700
committerAnkit Goyal <layog@google.com>2023-04-05 17:37:34 -0700
commit4180098644e9f51ed1b4ce6c0581035c65883461 (patch)
tree644dc22eb6a3cf7b1e854608fd1f650ff1864290
parent1c68ad1661d199a0b2baf71980d2c960f0ef706d (diff)
downloadgchips-4180098644e9f51ed1b4ce6c0581035c65883461.tar.gz
gralloc4: Choose framebuffer-secure for FB if available
Bug: 245053092 Test: gfx-gralloc-alloc-test Change-Id: If72289abf0dde9701456f0d6e3fb09885b6bf529
-rw-r--r--gralloc4/src/allocator/mali_gralloc_ion.cpp40
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 = "")