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,
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 @@ bool Allocator::CheckForBufferSharing(uint32_t num_descriptors,
*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 @@ int Allocator::GetImplDefinedFormat(gralloc1_producer_usage_t prod_usage,
/* 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 @@ void Allocator::GetIonHeapInfo(gralloc1_producer_usage_t prod_usage,
return;
}
} // namespace gralloc1