Skip to content

Commit

Permalink
Merge remote-tracking branch 'caf/LA.BR.1.3.7_rb1.9' into lineage-15.…
Browse files Browse the repository at this point in the history
…1-caf-8952

Change-Id: I63dba27802b5dd21326f30e2dce26f2fc8a55b8b
  • Loading branch information
intervigilium committed Mar 4, 2018
2 parents 8648766 + 3f8274c commit 6e7faf6
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 17 deletions.
15 changes: 13 additions & 2 deletions libgralloc/alloc_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 13 additions & 3 deletions libgralloc/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions libgralloc/gr.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ class AdrenoMemInfo : public android::Singleton <AdrenoMemInfo>
void getGpuAlignedWidthHeight(int width, int height, int format,
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
*
Expand Down
38 changes: 31 additions & 7 deletions libgralloc/gralloc_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
15 changes: 10 additions & 5 deletions libgralloc/mapper.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand Down Expand Up @@ -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(
Expand All @@ -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;
Expand Down

0 comments on commit 6e7faf6

Please sign in to comment.