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
This commit is contained in:
Naseer Ahmed
2017-04-20 16:52:40 -04:00
parent 8651417754
commit fe6342e5bc
3 changed files with 19 additions and 14 deletions

View File

@@ -96,7 +96,7 @@ Allocator::~Allocator() {
int Allocator::AllocateMem(AllocData *alloc_data, gralloc1_producer_usage_t prod_usage, int Allocator::AllocateMem(AllocData *alloc_data, gralloc1_producer_usage_t prod_usage,
gralloc1_consumer_usage_t cons_usage) { gralloc1_consumer_usage_t cons_usage) {
int ret; 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 // 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, GetIonHeapInfo(prod_usage, cons_usage, &alloc_data->heap_id, &alloc_data->alloc_type,
@@ -158,7 +158,8 @@ bool Allocator::CheckForBufferSharing(uint32_t num_descriptors,
*max_index = -1; *max_index = -1;
for (uint32_t i = 0; i < num_descriptors; i++) { for (uint32_t i = 0; i < num_descriptors; i++) {
// Check Cached vs non-cached and all the ION flags // 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(), GetIonHeapInfo(descriptors[i]->GetProducerUsage(), descriptors[i]->GetConsumerUsage(),
&cur_heap_id, &cur_alloc_type, &cur_ion_flags); &cur_heap_id, &cur_alloc_type, &cur_ion_flags);
@@ -225,22 +226,27 @@ int Allocator::GetImplDefinedFormat(gralloc1_producer_usage_t prod_usage,
/* The default policy is to return cached buffers unless the client explicity /* 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 * sets the PRIVATE_UNCACHED flag or indicates that the buffer will be rarely
* read or written in software. */ * read or written in software. */
// TODO(user) : As of now relying only on producer usage bool Allocator::UseUncached(gralloc1_producer_usage_t prod_usage,
bool Allocator::UseUncached(gralloc1_producer_usage_t usage) { gralloc1_consumer_usage_t cons_usage) {
if ((usage & GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED) || if ((prod_usage & GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED) ||
(usage & GRALLOC1_PRODUCER_USAGE_PROTECTED)) { (prod_usage & GRALLOC1_PRODUCER_USAGE_PROTECTED)) {
return true; return true;
} }
// CPU read rarely // CPU read rarely
if ((usage & GRALLOC1_PRODUCER_USAGE_CPU_READ) && if ((prod_usage & GRALLOC1_PRODUCER_USAGE_CPU_READ) &&
!(usage & GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN)) { !(prod_usage & GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN)) {
return true; return true;
} }
// CPU write rarely // CPU write rarely
if ((usage & GRALLOC1_PRODUCER_USAGE_CPU_WRITE) && if ((prod_usage & GRALLOC1_PRODUCER_USAGE_CPU_WRITE) &&
!(usage & GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN)) { !(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; return true;
} }
@@ -302,5 +308,4 @@ void Allocator::GetIonHeapInfo(gralloc1_producer_usage_t prod_usage,
return; return;
} }
} // namespace gralloc1 } // namespace gralloc1

View File

@@ -61,7 +61,7 @@ class Allocator {
ssize_t *max_index); ssize_t *max_index);
int GetImplDefinedFormat(gralloc1_producer_usage_t prod_usage, int GetImplDefinedFormat(gralloc1_producer_usage_t prod_usage,
gralloc1_consumer_usage_t cons_usage, int format); 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: private:
void GetIonHeapInfo(gralloc1_producer_usage_t prod_usage, gralloc1_consumer_usage_t cons_usage, void GetIonHeapInfo(gralloc1_producer_usage_t prod_usage, gralloc1_consumer_usage_t cons_usage,

View File

@@ -454,7 +454,7 @@ int BufferManager::GetHandleFlags(int format, gralloc1_producer_usage_t prod_usa
flags |= private_handle_t::PRIV_FLAGS_DISP_CONSUMER; 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; flags |= private_handle_t::PRIV_FLAGS_CACHED;
} }
@@ -499,7 +499,7 @@ int BufferManager::AllocateBuffer(const BufferDescriptor &descriptor, buffer_han
data.align = GetDataAlignment(format, prod_usage, cons_usage); data.align = GetDataAlignment(format, prod_usage, cons_usage);
data.size = ALIGN(size, data.align); data.size = ALIGN(size, data.align);
data.handle = (uintptr_t) handle; data.handle = (uintptr_t) handle;
data.uncached = allocator_->UseUncached(prod_usage); data.uncached = allocator_->UseUncached(prod_usage, cons_usage);
// Allocate buffer memory // Allocate buffer memory
err = allocator_->AllocateMem(&data, prod_usage, cons_usage); err = allocator_->AllocateMem(&data, prod_usage, cons_usage);