summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Chen <intervigil@gmail.com>2018-03-03 19:35:53 -0800
committerEthan Chen <intervigil@gmail.com>2018-03-03 19:37:15 -0800
commit6e7faf65529eb027b4e298711ba3f03ea2264d74 (patch)
treec9a66e8eef6502f60d7f27182fa6954d4c321c85
parent8648766e0bf9cafffe975eabb8a8090204775183 (diff)
parent3f8274c9c4e6e411a7bb14b4753112ccdf3e7c02 (diff)
downloadandroid_hardware_qcom_display-lineage-15.1-caf-8952.tar.gz
android_hardware_qcom_display-lineage-15.1-caf-8952.tar.bz2
android_hardware_qcom_display-lineage-15.1-caf-8952.zip
Merge remote-tracking branch 'caf/LA.BR.1.3.7_rb1.9' into lineage-15.1-caf-8952lineage-15.1-caf-8952
Change-Id: I63dba27802b5dd21326f30e2dce26f2fc8a55b8b
-rwxr-xr-xlibgralloc/alloc_controller.cpp15
-rw-r--r--libgralloc/gpu.cpp16
-rw-r--r--libgralloc/gr.h9
-rwxr-xr-xlibgralloc/gralloc_priv.h38
-rw-r--r--libgralloc/mapper.cpp15
5 files changed, 76 insertions, 17 deletions
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 44a040feb..082558c4e 100755
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -153,6 +153,18 @@ int AdrenoMemInfo::isMacroTilingSupportedByGPU()
}
+void AdrenoMemInfo::getUnalignedWidthAndHeight(const private_handle_t *hnd, int& unaligned_w,
+ int& unaligned_h) {
+ MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
+ if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
+ unaligned_w = metadata->bufferDim.sliceWidth;
+ unaligned_h = metadata->bufferDim.sliceHeight;
+ } else {
+ unaligned_w = hnd->unaligned_width;
+ unaligned_h = hnd->unaligned_height;
+ }
+}
+
bool isUncompressedRgbFormat(int format)
{
bool is_rgb_format = false;
@@ -665,7 +677,6 @@ unsigned int getBufferSizeAndDimensions(int width, int height, int format,
return size;
}
-
void getBufferAttributes(int width, int height, int format, int usage,
int& alignedw, int &alignedh, int& tiled, unsigned int& size)
{
@@ -812,7 +823,7 @@ int alloc_buffer(private_handle_t **pHnd, int w, int h, int format, int usage)
private_handle_t* hnd = new private_handle_t(data.fd, data.size,
data.allocType, 0, format,
- alignedw, alignedh);
+ alignedw, alignedh, -1, 0, 0, w, h);
hnd->base = (uint64_t) data.base;
hnd->offset = data.offset;
hnd->gpuaddr = 0;
diff --git a/libgralloc/gpu.cpp b/libgralloc/gpu.cpp
index 7def5b618..5e89a0e23 100644
--- a/libgralloc/gpu.cpp
+++ b/libgralloc/gpu.cpp
@@ -54,6 +54,16 @@ int gpu_context_t::gralloc_alloc_buffer(unsigned int size, int usage,
{
int err = 0;
int flags = 0;
+ int alignedw = 0;
+ int alignedh = 0;
+
+ AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width,
+ height,
+ format,
+ usage,
+ alignedw,
+ alignedh);
+
size = roundUpToPageSize(size);
alloc_data data;
data.offset = 0;
@@ -176,8 +186,8 @@ int gpu_context_t::gralloc_alloc_buffer(unsigned int size, int usage,
flags |= data.allocType;
uint64_t eBaseAddr = (uint64_t)(eData.base) + eData.offset;
private_handle_t *hnd = new private_handle_t(data.fd, size, flags,
- bufferType, format, width, height, eData.fd, eData.offset,
- eBaseAddr);
+ bufferType, format, alignedw, alignedh,
+ eData.fd, eData.offset, eBaseAddr, width, height);
hnd->offset = data.offset;
hnd->base = (uint64_t)(data.base) + data.offset;
@@ -350,7 +360,7 @@ int gpu_context_t::alloc_impl(int w, int h, int format, int usage,
err = gralloc_alloc_framebuffer(usage, pHandle);
} else {
err = gralloc_alloc_buffer(size, usage, pHandle, bufferType,
- grallocFormat, alignedw, alignedh);
+ grallocFormat, w, h);
}
if (err < 0) {
diff --git a/libgralloc/gr.h b/libgralloc/gr.h
index 4ca935090..d08ea4cf5 100644
--- a/libgralloc/gr.h
+++ b/libgralloc/gr.h
@@ -132,6 +132,15 @@ class AdrenoMemInfo : public android::Singleton <AdrenoMemInfo>
int tileEnabled, int& alignedw, int &alignedh);
/*
+ * Function to compute unaligned width and unaligned height based on
+ * private handle
+ *
+ * @return unaligned width, unaligned height
+ */
+ void getUnalignedWidthAndHeight(const private_handle_t *hnd, int& unaligned_w,
+ int& unaligned_h);
+
+ /*
* Function to return whether GPU support MacroTile feature
*
* @return >0 : supported
diff --git a/libgralloc/gralloc_priv.h b/libgralloc/gralloc_priv.h
index c7a91ef52..026d5c01a 100755
--- a/libgralloc/gralloc_priv.h
+++ b/libgralloc/gralloc_priv.h
@@ -214,9 +214,11 @@ struct private_handle_t : public native_handle {
// The gpu address mapped into the mmu.
uint64_t gpuaddr __attribute__((aligned(8)));
int format;
- int width;
- int height;
+ int width; // holds aligned width of the actual buffer allocated
+ int height; // holds aligned height of the actual buffer allocated
uint64_t base_metadata __attribute__((aligned(8)));
+ int unaligned_width; // holds width client asked to allocate
+ int unaligned_height; // holds height client asked to allocate
#ifdef __cplusplus
static const int sNumFds = 2;
@@ -227,18 +229,40 @@ struct private_handle_t : public native_handle {
static const int sMagic = 'gmsm';
private_handle_t(int fd, unsigned int size, int flags, int bufferType,
- int format, int width, int height, int eFd = -1,
- unsigned int eOffset = 0, uint64_t eBase = 0) :
- fd(fd), fd_metadata(eFd), magic(sMagic),
+ int format, int width, int height) :
+ fd(fd), fd_metadata(-1), magic(sMagic),
flags(flags), size(size), offset(0), bufferType(bufferType),
- base(0), offset_metadata(eOffset), gpuaddr(0),
+ base(0), offset_metadata(0), gpuaddr(0),
format(format), width(width), height(height),
- base_metadata(eBase)
+ base_metadata(0), unaligned_width(width),
+ unaligned_height(height)
{
version = (int) sizeof(native_handle);
numInts = sNumInts();
numFds = sNumFds;
}
+
+ private_handle_t(int fd, unsigned int size, int flags, int bufferType,
+ int format, int width, int height,
+ int eFd, unsigned int eOffset, uint64_t eBase) :
+ private_handle_t(fd, size, flags, bufferType, format, width, height)
+ {
+ fd_metadata = eFd;
+ offset_metadata = eOffset;
+ base_metadata = eBase;
+ }
+
+ private_handle_t(int fd, unsigned int size, int flags, int bufferType,
+ int format, int width, int height,
+ int eFd, unsigned int eOffset, uint64_t eBase,
+ int unaligned_w, int unaligned_h) :
+ private_handle_t(fd, size, flags, bufferType, format, width, height,
+ eFd, eOffset, eBase)
+ {
+ unaligned_width = unaligned_w;
+ unaligned_height = unaligned_h;
+ }
+
~private_handle_t() {
magic = 0;
}
diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp
index bed0aebda..6f77e4a5a 100644
--- a/libgralloc/mapper.cpp
+++ b/libgralloc/mapper.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008 The Android Open Source Project
- * Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2016, 2018 The Linux Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -82,7 +82,7 @@ static int gralloc_map(gralloc_module_t const* module,
return -errno;
}
- hnd->base = uint64_t(mappedAddress) + hnd->offset;
+ hnd->base = uint64_t(mappedAddress);
}
//Allow mapping of metadata for all buffers including secure ones, but not
@@ -97,7 +97,7 @@ static int gralloc_map(gralloc_module_t const* module,
handle, hnd->fd_metadata, strerror(errno));
return -errno;
}
- hnd->base_metadata = uint64_t(mappedAddress) + hnd->offset_metadata;
+ hnd->base_metadata = uint64_t(mappedAddress);
}
return 0;
}
@@ -309,6 +309,7 @@ int gralloc_perform(struct gralloc_module_t const* module,
int width = va_arg(args, int);
int height = va_arg(args, int);
int format = va_arg(args, int);
+ int alignedw = 0, alignedh = 0;
native_handle_t** handle = va_arg(args, native_handle_t**);
private_handle_t* hnd = (private_handle_t*)native_handle_create(
@@ -321,8 +322,12 @@ int gralloc_perform(struct gralloc_module_t const* module,
hnd->offset = offset;
hnd->base = uint64_t(base) + offset;
hnd->gpuaddr = 0;
- hnd->width = width;
- hnd->height = height;
+ AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width,
+ height, format, 0, alignedw, alignedh);
+ hnd->width = alignedw;
+ hnd->height = alignedh;
+ hnd->unaligned_width = width;
+ hnd->unaligned_height = height;
hnd->format = format;
*handle = (native_handle_t *)hnd;
res = 0;