summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRamkumar Radhakrishnan <ramkumar@codeaurora.org>2016-08-25 15:04:21 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2016-08-30 21:27:28 -0700
commit5353ccce11eedce467ab622b6d06263defe6a64f (patch)
tree274439640f774fe212f361155d9340f43d992ce1
parent7b5fe87e3052fe6802e380c649d845b887eaa486 (diff)
downloadhardware_qcom_display-5353ccce11eedce467ab622b6d06263defe6a64f.tar.gz
hardware_qcom_display-5353ccce11eedce467ab622b6d06263defe6a64f.tar.bz2
hardware_qcom_display-5353ccce11eedce467ab622b6d06263defe6a64f.zip
hwc: Store real buffer resolution in private handle.
Add real_width and real_height in private_handle_t to store the actual buffer resolution without alignment that client asked to allocate. Change-Id: I28d757af4178f581e6a83dc06198106c85fc7262 CRs-Fixed: 1040942
-rw-r--r--libcopybit/copybit_c2d.cpp2
-rw-r--r--libgralloc/alloc_controller.cpp46
-rw-r--r--libgralloc/framebuffer.cpp5
-rw-r--r--libgralloc/gpu.cpp18
-rw-r--r--libgralloc/gr.h8
-rw-r--r--libgralloc/gralloc_priv.h13
-rw-r--r--libgralloc/mapper.cpp9
7 files changed, 78 insertions, 23 deletions
diff --git a/libcopybit/copybit_c2d.cpp b/libcopybit/copybit_c2d.cpp
index 240ba26c6..ffe5a0aca 100644
--- a/libcopybit/copybit_c2d.cpp
+++ b/libcopybit/copybit_c2d.cpp
@@ -1174,6 +1174,7 @@ static int stretch_copybit_internal(
bufferInfo dst_info;
populate_buffer_info(dst, dst_info);
private_handle_t* dst_hnd = new private_handle_t(-1, 0, 0, 0, dst_info.format,
+ dst_info.width, dst_info.height,
dst_info.width, dst_info.height);
if (dst_hnd == NULL) {
ALOGE("%s: dst_hnd is null", __FUNCTION__);
@@ -1254,6 +1255,7 @@ static int stretch_copybit_internal(
bufferInfo src_info;
populate_buffer_info(src, src_info);
private_handle_t* src_hnd = new private_handle_t(-1, 0, 0, 0, src_info.format,
+ src_info.width, src_info.height,
src_info.width, src_info.height);
if (NULL == src_hnd) {
ALOGE("%s: src_hnd is null", __FUNCTION__);
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 39acf6624..4ca4e2d55 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -173,6 +173,17 @@ void AdrenoMemInfo::getAlignedWidthAndHeight(const private_handle_t *hnd, int& a
}
+void AdrenoMemInfo::getRealWidthAndHeight(const private_handle_t *hnd, int& real_w, int& real_h) {
+ MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
+ if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
+ real_w = metadata->bufferDim.sliceWidth;
+ real_h = metadata->bufferDim.sliceHeight;
+ } else {
+ real_w = hnd->real_width;
+ real_h = hnd->real_height;
+ }
+}
+
bool isUncompressedRgbFormat(int format)
{
bool is_rgb_format = false;
@@ -693,6 +704,16 @@ unsigned int getBufferSizeAndDimensions(int width, int height, int format,
return size;
}
+void getAlignedWidthAndHeight(int width, int height, int format,
+ int usage, int& alignedw, int &alignedh)
+{
+ AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width,
+ height,
+ format,
+ usage,
+ alignedw,
+ alignedh);
+}
void getBufferAttributes(int width, int height, int format, int usage,
int& alignedw, int &alignedh, int& tiled, unsigned int& size)
@@ -714,6 +735,8 @@ int getYUVPlaneInfo(private_handle_t* hnd, struct android_ycbcr* ycbcr)
int width = hnd->width;
int height = hnd->height;
int format = hnd->format;
+ int real_width = hnd->real_width;
+ int real_height = hnd->real_height;
unsigned int ystride, cstride;
unsigned int alignment = 4096;
@@ -734,8 +757,11 @@ int getYUVPlaneInfo(private_handle_t* hnd, struct android_ycbcr* ycbcr)
usage = GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
}
- AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(metadata->bufferDim.sliceWidth,
- metadata->bufferDim.sliceHeight, format, usage, width, height);
+ real_width = metadata->bufferDim.sliceWidth;
+ real_height = metadata->bufferDim.sliceHeight;
+
+ AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(real_width, real_height,
+ format, usage, width, height);
}
// Get the chroma offsets from the handle width/height. We take advantage
@@ -762,16 +788,16 @@ int getYUVPlaneInfo(private_handle_t* hnd, struct android_ycbcr* ycbcr)
unsigned int y_stride, y_height, y_size;
unsigned int c_meta_stride, c_meta_height, c_meta_size;
- y_meta_stride = VENUS_Y_META_STRIDE(COLOR_FMT_NV12_UBWC, width);
- y_meta_height = VENUS_Y_META_SCANLINES(COLOR_FMT_NV12_UBWC, height);
+ y_meta_stride = VENUS_Y_META_STRIDE(COLOR_FMT_NV12_UBWC, real_width);
+ y_meta_height = VENUS_Y_META_SCANLINES(COLOR_FMT_NV12_UBWC, real_height);
y_meta_size = ALIGN((y_meta_stride * y_meta_height), alignment);
- y_stride = VENUS_Y_STRIDE(COLOR_FMT_NV12_UBWC, width);
- y_height = VENUS_Y_SCANLINES(COLOR_FMT_NV12_UBWC, height);
+ y_stride = VENUS_Y_STRIDE(COLOR_FMT_NV12_UBWC, real_width);
+ y_height = VENUS_Y_SCANLINES(COLOR_FMT_NV12_UBWC, real_height);
y_size = ALIGN((y_stride * y_height), alignment);
- c_meta_stride = VENUS_UV_META_STRIDE(COLOR_FMT_NV12_UBWC, width);
- c_meta_height = VENUS_UV_META_SCANLINES(COLOR_FMT_NV12_UBWC, height);
+ c_meta_stride = VENUS_UV_META_STRIDE(COLOR_FMT_NV12_UBWC, real_width);
+ c_meta_height = VENUS_UV_META_SCANLINES(COLOR_FMT_NV12_UBWC, real_height);
c_meta_size = ALIGN((c_meta_stride * c_meta_height), alignment);
ycbcr->y = (void*)(hnd->base + y_meta_size);
@@ -779,7 +805,7 @@ int getYUVPlaneInfo(private_handle_t* hnd, struct android_ycbcr* ycbcr)
ycbcr->cr = (void*)(hnd->base + y_meta_size + y_size +
c_meta_size + 1);
ycbcr->ystride = y_stride;
- ycbcr->cstride = VENUS_UV_STRIDE(COLOR_FMT_NV12_UBWC, width);
+ ycbcr->cstride = VENUS_UV_STRIDE(COLOR_FMT_NV12_UBWC, real_width);
ycbcr->chroma_step = 2;
break;
@@ -856,7 +882,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, w, h);
hnd->base = (uint64_t) data.base;
hnd->offset = data.offset;
hnd->gpuaddr = 0;
diff --git a/libgralloc/framebuffer.cpp b/libgralloc/framebuffer.cpp
index 5c297c1f8..94a72a757 100644
--- a/libgralloc/framebuffer.cpp
+++ b/libgralloc/framebuffer.cpp
@@ -352,8 +352,9 @@ int mapFrameBufferLocked(framebuffer_device_t *dev)
// Create framebuffer handle using the ION fd
module->framebuffer = new private_handle_t(fd, fbSize,
private_handle_t::PRIV_FLAGS_USES_ION,
- BUFFER_TYPE_UI,
- module->fbFormat, info.xres, info.yres);
+ BUFFER_TYPE_UI, module->fbFormat,
+ info.xres, info.yres,
+ info.xres, info.yres);
module->framebuffer->base = uint64_t(vaddr);
memset(vaddr, 0, fbSize);
//Enable vsync
diff --git a/libgralloc/gpu.cpp b/libgralloc/gpu.cpp
index 0eee65e53..4f29a7003 100644
--- a/libgralloc/gpu.cpp
+++ b/libgralloc/gpu.cpp
@@ -53,6 +53,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;
@@ -159,8 +169,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, width, height, eData.fd,
+ eData.offset, eBaseAddr);
hnd->offset = data.offset;
hnd->base = (uint64_t)(data.base) + data.offset;
@@ -228,7 +238,7 @@ int gpu_context_t::gralloc_alloc_framebuffer_locked(int usage,
private_handle_t::PRIV_FLAGS_USES_ION |
private_handle_t::PRIV_FLAGS_FRAMEBUFFER,
BUFFER_TYPE_UI, m->fbFormat, m->info.xres,
- m->info.yres);
+ m->info.yres, m->info.xres, m->info.yres);
// find a free slot
for (uint32_t i=0 ; i<numBuffers ; i++) {
@@ -328,7 +338,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 1b8d9b4a5..d05055bfa 100644
--- a/libgralloc/gr.h
+++ b/libgralloc/gr.h
@@ -140,6 +140,14 @@ class AdrenoMemInfo : public android::Singleton <AdrenoMemInfo>
int tileEnabled, int& alignedw, int &alignedh);
/*
+ * Function to compute real width and real height based on
+ * private handle
+ *
+ * @return real width, real height
+ */
+ void getRealWidthAndHeight(const private_handle_t *hnd, int& real_w, int& real_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 7a5fc845a..4aa47541b 100644
--- a/libgralloc/gralloc_priv.h
+++ b/libgralloc/gralloc_priv.h
@@ -222,8 +222,10 @@ 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; // specifies aligned width
+ int height; // specifies aligned height
+ int real_width;
+ int real_height;
uint64_t base_metadata __attribute__((aligned(8)));
#ifdef __cplusplus
@@ -235,13 +237,14 @@ 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,
+ int format, int aligned_width, int aligned_height,
+ int width, int height, int eFd = -1,
unsigned int eOffset = 0, uint64_t eBase = 0) :
fd(fd), fd_metadata(eFd), magic(sMagic),
flags(flags), size(size), offset(0), bufferType(bufferType),
base(0), offset_metadata(eOffset), gpuaddr(0),
- format(format), width(width), height(height),
- base_metadata(eBase)
+ format(format), width(aligned_width), height(aligned_height),
+ real_width(width), real_height(height), base_metadata(eBase)
{
version = (int) sizeof(native_handle);
numInts = sNumInts();
diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp
index 142586b83..549951bc3 100644
--- a/libgralloc/mapper.cpp
+++ b/libgralloc/mapper.cpp
@@ -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->real_width = width;
+ hnd->real_height = height;
hnd->format = format;
*handle = (native_handle_t *)hnd;
res = 0;