gralloc1: Support GPU_DATA_BUFFER and SENSOR_DIRECT_DATA
* These buffers can have any RGB format
* Should not use UBWC
* Should be uncached
* 4k aligned
CRs-Fixed: 2037674
Change-Id: I49c88b1914f8a4247137ae5b64276f0346977a71
diff --git a/libgralloc1/gr_allocator.cpp b/libgralloc1/gr_allocator.cpp
index 5e3ee9b..045cc63 100644
--- a/libgralloc1/gr_allocator.cpp
+++ b/libgralloc1/gr_allocator.cpp
@@ -96,7 +96,7 @@
int Allocator::AllocateMem(AllocData *alloc_data, gralloc1_producer_usage_t prod_usage,
gralloc1_consumer_usage_t cons_usage) {
int ret;
- alloc_data->uncached = UseUncached(prod_usage);
+ alloc_data->uncached = UseUncached(prod_usage, cons_usage);
// After this point we should have the right heap set, there is no fallback
GetIonHeapInfo(prod_usage, cons_usage, &alloc_data->heap_id, &alloc_data->alloc_type,
@@ -158,7 +158,8 @@
*max_index = -1;
for (uint32_t i = 0; i < num_descriptors; i++) {
// Check Cached vs non-cached and all the ION flags
- cur_uncached = UseUncached(descriptors[i]->GetProducerUsage());
+ cur_uncached = UseUncached(descriptors[i]->GetProducerUsage(),
+ descriptors[i]->GetConsumerUsage());
GetIonHeapInfo(descriptors[i]->GetProducerUsage(), descriptors[i]->GetConsumerUsage(),
&cur_heap_id, &cur_alloc_type, &cur_ion_flags);
@@ -225,22 +226,27 @@
/* The default policy is to return cached buffers unless the client explicity
* sets the PRIVATE_UNCACHED flag or indicates that the buffer will be rarely
* read or written in software. */
-// TODO(user) : As of now relying only on producer usage
-bool Allocator::UseUncached(gralloc1_producer_usage_t usage) {
- if ((usage & GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED) ||
- (usage & GRALLOC1_PRODUCER_USAGE_PROTECTED)) {
+bool Allocator::UseUncached(gralloc1_producer_usage_t prod_usage,
+ gralloc1_consumer_usage_t cons_usage) {
+ if ((prod_usage & GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED) ||
+ (prod_usage & GRALLOC1_PRODUCER_USAGE_PROTECTED)) {
return true;
}
// CPU read rarely
- if ((usage & GRALLOC1_PRODUCER_USAGE_CPU_READ) &&
- !(usage & GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN)) {
+ if ((prod_usage & GRALLOC1_PRODUCER_USAGE_CPU_READ) &&
+ !(prod_usage & GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN)) {
return true;
}
// CPU write rarely
- if ((usage & GRALLOC1_PRODUCER_USAGE_CPU_WRITE) &&
- !(usage & GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN)) {
+ if ((prod_usage & GRALLOC1_PRODUCER_USAGE_CPU_WRITE) &&
+ !(prod_usage & GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN)) {
+ return true;
+ }
+
+ if ((prod_usage & GRALLOC1_PRODUCER_USAGE_SENSOR_DIRECT_DATA) ||
+ (cons_usage & GRALLOC1_CONSUMER_USAGE_GPU_DATA_BUFFER)) {
return true;
}
@@ -302,5 +308,4 @@
return;
}
-
} // namespace gralloc1
diff --git a/libgralloc1/gr_allocator.h b/libgralloc1/gr_allocator.h
index 6f9de30..d57f50e 100644
--- a/libgralloc1/gr_allocator.h
+++ b/libgralloc1/gr_allocator.h
@@ -61,7 +61,7 @@
ssize_t *max_index);
int GetImplDefinedFormat(gralloc1_producer_usage_t prod_usage,
gralloc1_consumer_usage_t cons_usage, int format);
- bool UseUncached(gralloc1_producer_usage_t usage);
+ bool UseUncached(gralloc1_producer_usage_t prod_usage, gralloc1_consumer_usage_t cons_usage);
private:
void GetIonHeapInfo(gralloc1_producer_usage_t prod_usage, gralloc1_consumer_usage_t cons_usage,
diff --git a/libgralloc1/gr_buf_mgr.cpp b/libgralloc1/gr_buf_mgr.cpp
index e0d44e7..4c3f7d4 100644
--- a/libgralloc1/gr_buf_mgr.cpp
+++ b/libgralloc1/gr_buf_mgr.cpp
@@ -454,7 +454,7 @@
flags |= private_handle_t::PRIV_FLAGS_DISP_CONSUMER;
}
- if (!allocator_->UseUncached(prod_usage)) {
+ if (!allocator_->UseUncached(prod_usage, cons_usage)) {
flags |= private_handle_t::PRIV_FLAGS_CACHED;
}
@@ -499,7 +499,7 @@
data.align = GetDataAlignment(format, prod_usage, cons_usage);
data.size = ALIGN(size, data.align);
data.handle = (uintptr_t) handle;
- data.uncached = allocator_->UseUncached(prod_usage);
+ data.uncached = allocator_->UseUncached(prod_usage, cons_usage);
// Allocate buffer memory
err = allocator_->AllocateMem(&data, prod_usage, cons_usage);