summaryrefslogtreecommitdiff
path: root/gralloc4/src/core/mali_gralloc_bufferallocation.cpp
diff options
context:
space:
mode:
authorAnkit Goyal <layog@google.com>2021-04-27 21:16:28 +0800
committerAnkit Goyal <layog@google.com>2021-05-06 18:05:42 +0800
commitef4a92714086e07f61392b10f8c74d0e12f549e4 (patch)
tree876f3c57d09f6ecd8d881d7b6c1a8b5ccb40aaab /gralloc4/src/core/mali_gralloc_bufferallocation.cpp
parent04198b0eb43d28aa4d8e4e985986b69c24d564d0 (diff)
downloadgchips-ef4a92714086e07f61392b10f8c74d0e12f549e4.tar.gz
Convert BO CPU_READ_OFTEN to CPU_READ_RARELY
Bug: 157775531 Test: AV1 video playback Change-Id: I05046ea004630a80ae22ea6a2625e4a29cb052ce
Diffstat (limited to 'gralloc4/src/core/mali_gralloc_bufferallocation.cpp')
-rw-r--r--gralloc4/src/core/mali_gralloc_bufferallocation.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp
index 0e538cf..d0f2410 100644
--- a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp
+++ b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp
@@ -464,6 +464,28 @@ static void update_yv12_stride(int8_t plane,
}
#endif
+/*
+ * Modify usage flag when BO is the producer
+ *
+ * BO cannot use the flags CPU_READ_RARELY as Codec layer redefines those flags
+ * for some internal usage. So, when BO is sending CPU_READ_OFTEN, it still
+ * expects to allocate an uncached buffer and this procedure convers the OFTEN
+ * flag to RARELY.
+ */
+static uint64_t update_usage_for_BO(uint64_t usage) {
+ MALI_GRALLOC_LOGV("Hacking CPU RW flags for BO");
+ if (usage & hidl_common::BufferUsage::CPU_READ_OFTEN) {
+ usage &= ~(static_cast<uint64_t>(hidl_common::BufferUsage::CPU_READ_OFTEN));
+ usage |= hidl_common::BufferUsage::CPU_READ_RARELY;
+ }
+
+ if (usage & hidl_common::BufferUsage::CPU_WRITE_OFTEN) {
+ usage &= ~(static_cast<uint64_t>(hidl_common::BufferUsage::CPU_WRITE_OFTEN));
+ usage |= hidl_common::BufferUsage::CPU_WRITE_RARELY;
+ }
+ return usage;
+}
+
/*
* Calculate allocation size.
@@ -1005,6 +1027,14 @@ int mali_gralloc_buffer_allocate(const gralloc_buffer_descriptor_t *descriptors,
{
buffer_descriptor_t * const bufDescriptor = (buffer_descriptor_t *)(descriptors[i]);
+ assert(bufDescriptor->producer_usage == bufDescriptor->consumer_usage);
+ uint64_t usage = bufDescriptor->producer_usage;
+ if ((usage & hidl_common::BufferUsage::VIDEO_DECODER) && (usage & GRALLOC_USAGE_GOOGLE_IP_BO)) {
+ usage = update_usage_for_BO(usage);
+ bufDescriptor->producer_usage = usage;
+ bufDescriptor->consumer_usage = usage;
+ }
+
/* Derive the buffer size from descriptor parameters */
err = mali_gralloc_derive_format_and_size(bufDescriptor);
if (err != 0)