gralloc: Add support to RGB compressed format and handle error
1. Add corresponding adreno format for RGB compressed hal format,
as new adreno API adreno_init_memory_layout needs ADRENO_FORMAT to
be passed.
2. Handle the error returned by adreno_init_memory_layout API for the
inappropriate values passed.
Change-Id: Iedcf306583b83ecb80db5495a801f37d2479276b
CRs-Fixed: 2262839
diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp
index 9a25a8e..61e31d6 100644
--- a/gralloc/gr_buf_mgr.cpp
+++ b/gralloc/gr_buf_mgr.cpp
@@ -86,7 +86,10 @@
Error BufferManager::ValidateBufferSize(private_handle_t const *hnd, BufferInfo info) {
unsigned int size, alignedw, alignedh;
info.format = GetImplDefinedFormat(info.usage, info.format);
- GetBufferSizeAndDimensions(info, &size, &alignedw, &alignedh);
+ int ret = GetBufferSizeAndDimensions(info, &size, &alignedw, &alignedh);
+ if (ret < 0) {
+ return Error::BAD_BUFFER;
+ }
auto ion_fd_size = static_cast<unsigned int>(lseek(hnd->fd, 0, SEEK_END));
if (size != ion_fd_size) {
return Error::BAD_VALUE;
@@ -270,6 +273,7 @@
unsigned int size;
unsigned int alignedw, alignedh;
+ int err = 0;
int buffer_type = GetBufferType(format);
BufferInfo info = GetBufferInfo(descriptor);
@@ -277,10 +281,12 @@
info.layer_count = layer_count;
GraphicsMetadata graphics_metadata = {};
- GetBufferSizeAndDimensions(info, &size, &alignedw, &alignedh, &graphics_metadata);
+ err = GetBufferSizeAndDimensions(info, &size, &alignedw, &alignedh, &graphics_metadata);
+ if (err < 0) {
+ return Error::BAD_DESCRIPTOR;
+ }
size = (bufferSize >= size) ? bufferSize : size;
- int err = 0;
uint64_t flags = 0;
auto page_size = UINT(getpagesize());
AllocData data;
@@ -292,7 +298,8 @@
// Allocate buffer memory
err = allocator_->AllocateMem(&data, usage, format);
if (err) {
- ALOGE("gralloc failed to allocate err=%s", strerror(-err));
+ ALOGE("gralloc failed to allocate err=%s format %d size %d WxH %dx%d usage %" PRIu64,
+ strerror(-err), format, size, alignedw, alignedh, usage);
return Error::NO_RESOURCES;
}