gralloc: Remove opaque types
Remove opaque types like size_t, uintptr_t, intptr_t to support 32bit and 64bit processes together. When a 64bit process creates a handle and a 32bit process validates the incoming ints against expected ints, opaque types lead to different and mismatching values. Always use unit64_t for base address for 32bit and 64bit SF. Use unsigned int for offset and size, since ION uses that. Change-Id: I7db5544556a8924f98010b965f837592e9f0b4ca
This commit is contained in:
@@ -51,7 +51,7 @@ gpu_context_t::gpu_context_t(const private_module_t* module,
|
||||
|
||||
}
|
||||
|
||||
int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage,
|
||||
int gpu_context_t::gralloc_alloc_buffer(unsigned int size, int usage,
|
||||
buffer_handle_t* pHandle, int bufferType,
|
||||
int format, int width, int height)
|
||||
{
|
||||
@@ -152,13 +152,13 @@ int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage,
|
||||
}
|
||||
|
||||
flags |= data.allocType;
|
||||
uintptr_t eBaseAddr = (uintptr_t)(eData.base) + eData.offset;
|
||||
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);
|
||||
|
||||
hnd->offset = data.offset;
|
||||
hnd->base = (uintptr_t)(data.base) + data.offset;
|
||||
hnd->base = (uint64_t)(data.base) + data.offset;
|
||||
hnd->gpuaddr = 0;
|
||||
setMetaData(hnd, UPDATE_COLOR_SPACE, (void*) &colorSpace);
|
||||
|
||||
@@ -199,9 +199,9 @@ int gpu_context_t::gralloc_alloc_framebuffer_locked(int usage,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
const size_t bufferMask = m->bufferMask;
|
||||
const unsigned int bufferMask = m->bufferMask;
|
||||
const uint32_t numBuffers = m->numBuffers;
|
||||
size_t bufferSize = m->finfo.line_length * m->info.yres;
|
||||
unsigned int bufferSize = m->finfo.line_length * m->info.yres;
|
||||
|
||||
//adreno needs FB size to be page aligned
|
||||
bufferSize = roundUpToPageSize(bufferSize);
|
||||
@@ -221,7 +221,7 @@ int gpu_context_t::gralloc_alloc_framebuffer_locked(int usage,
|
||||
}
|
||||
|
||||
// create a "fake" handle for it
|
||||
uintptr_t vaddr = uintptr_t(m->framebuffer->base);
|
||||
uint64_t vaddr = uint64_t(m->framebuffer->base);
|
||||
private_handle_t* hnd = new private_handle_t(
|
||||
dup(m->framebuffer->fd), bufferSize,
|
||||
private_handle_t::PRIV_FLAGS_USES_PMEM |
|
||||
@@ -238,7 +238,7 @@ int gpu_context_t::gralloc_alloc_framebuffer_locked(int usage,
|
||||
vaddr += bufferSize;
|
||||
}
|
||||
hnd->base = vaddr;
|
||||
hnd->offset = vaddr - uintptr_t(m->framebuffer->base);
|
||||
hnd->offset = (unsigned int)(vaddr - m->framebuffer->base);
|
||||
*pHandle = hnd;
|
||||
return 0;
|
||||
}
|
||||
@@ -256,11 +256,11 @@ int gpu_context_t::gralloc_alloc_framebuffer(int usage,
|
||||
|
||||
int gpu_context_t::alloc_impl(int w, int h, int format, int usage,
|
||||
buffer_handle_t* pHandle, int* pStride,
|
||||
size_t bufferSize) {
|
||||
unsigned int bufferSize) {
|
||||
if (!pHandle || !pStride)
|
||||
return -EINVAL;
|
||||
|
||||
size_t size;
|
||||
unsigned int size;
|
||||
int alignedw, alignedh;
|
||||
int grallocFormat = format;
|
||||
int bufferType;
|
||||
@@ -287,7 +287,7 @@ int gpu_context_t::alloc_impl(int w, int h, int format, int usage,
|
||||
size = getBufferSizeAndDimensions(w, h, grallocFormat, usage, alignedw,
|
||||
alignedh);
|
||||
|
||||
if ((ssize_t)size <= 0)
|
||||
if ((unsigned int)size <= 0)
|
||||
return -EINVAL;
|
||||
size = (bufferSize >= size)? bufferSize : size;
|
||||
|
||||
@@ -319,19 +319,20 @@ int gpu_context_t::alloc_impl(int w, int h, int format, int usage,
|
||||
int gpu_context_t::free_impl(private_handle_t const* hnd) {
|
||||
private_module_t* m = reinterpret_cast<private_module_t*>(common.module);
|
||||
if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) {
|
||||
const size_t bufferSize = m->finfo.line_length * m->info.yres;
|
||||
size_t index = (hnd->base - m->framebuffer->base) / bufferSize;
|
||||
const unsigned int bufferSize = m->finfo.line_length * m->info.yres;
|
||||
unsigned int index = (unsigned int) ((hnd->base - m->framebuffer->base)
|
||||
/ bufferSize);
|
||||
m->bufferMask &= ~(1LU<<index);
|
||||
} else {
|
||||
|
||||
terminateBuffer(&m->base, const_cast<private_handle_t*>(hnd));
|
||||
IMemAlloc* memalloc = mAllocCtrl->getAllocator(hnd->flags);
|
||||
int err = memalloc->free_buffer((void*)hnd->base, (size_t) hnd->size,
|
||||
int err = memalloc->free_buffer((void*)hnd->base, hnd->size,
|
||||
hnd->offset, hnd->fd);
|
||||
if(err)
|
||||
return err;
|
||||
// free the metadata space
|
||||
size_t size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
|
||||
unsigned int size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
|
||||
err = memalloc->free_buffer((void*)hnd->base_metadata,
|
||||
size, hnd->offset_metadata,
|
||||
hnd->fd_metadata);
|
||||
|
||||
Reference in New Issue
Block a user