display: Add display metadata in buffer handle
Allocate extra space for metadata in buffer handles Provide api to map this space in client process and set the metadata Change-Id: I8bca8448670d4aa88d439320faf402dae30458f8
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
parent
28b1743a9d
commit
47573e20d5
@@ -27,6 +27,7 @@
|
||||
#include "gpu.h"
|
||||
#include "memalloc.h"
|
||||
#include "alloc_controller.h"
|
||||
#include <qdMetaData.h>
|
||||
|
||||
using namespace gralloc;
|
||||
|
||||
@@ -137,37 +138,52 @@ int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage,
|
||||
data.pHandle = (unsigned int) pHandle;
|
||||
err = mAllocCtrl->allocate(data, usage);
|
||||
|
||||
if (usage & GRALLOC_USAGE_PRIVATE_UNSYNCHRONIZED) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_UNSYNCHRONIZED;
|
||||
}
|
||||
if (!err) {
|
||||
/* allocate memory for enhancement data */
|
||||
alloc_data eData;
|
||||
eData.fd = -1;
|
||||
eData.base = 0;
|
||||
eData.offset = 0;
|
||||
eData.size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
|
||||
eData.pHandle = data.pHandle;
|
||||
eData.align = getpagesize();
|
||||
int eDataUsage = GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP;
|
||||
int eDataErr = mAllocCtrl->allocate(eData, eDataUsage);
|
||||
ALOGE_IF(eDataErr, "gralloc failed for eDataErr=%s",
|
||||
strerror(-eDataErr));
|
||||
|
||||
if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_ONLY;
|
||||
//The EXTERNAL_BLOCK flag is always an add-on
|
||||
if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_BLOCK;
|
||||
}if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_CC) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_CC;
|
||||
if (usage & GRALLOC_USAGE_PRIVATE_UNSYNCHRONIZED) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_UNSYNCHRONIZED;
|
||||
}
|
||||
}
|
||||
|
||||
if (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER ) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_VIDEO_ENCODER;
|
||||
}
|
||||
if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_ONLY;
|
||||
//The EXTERNAL_BLOCK flag is always an add-on
|
||||
if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_BLOCK;
|
||||
}
|
||||
if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_CC) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_CC;
|
||||
}
|
||||
}
|
||||
|
||||
if (usage & GRALLOC_USAGE_HW_CAMERA_WRITE) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_CAMERA_WRITE;
|
||||
}
|
||||
if (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER ) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_VIDEO_ENCODER;
|
||||
}
|
||||
|
||||
if (usage & GRALLOC_USAGE_HW_CAMERA_READ) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_CAMERA_READ;
|
||||
}
|
||||
if (usage & GRALLOC_USAGE_HW_CAMERA_WRITE) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_CAMERA_WRITE;
|
||||
}
|
||||
|
||||
if (usage & GRALLOC_USAGE_HW_CAMERA_READ) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_CAMERA_READ;
|
||||
}
|
||||
|
||||
if (err == 0) {
|
||||
flags |= data.allocType;
|
||||
private_handle_t* hnd = new private_handle_t(data.fd, size, flags,
|
||||
bufferType, format, width,
|
||||
height);
|
||||
int eBaseAddr = int(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 = int(data.base) + data.offset;
|
||||
@@ -175,6 +191,7 @@ int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage,
|
||||
}
|
||||
|
||||
ALOGE_IF(err, "gralloc failed err=%s", strerror(-err));
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -261,6 +278,13 @@ int gpu_context_t::free_impl(private_handle_t const* hnd) {
|
||||
hnd->offset, hnd->fd);
|
||||
if(err)
|
||||
return err;
|
||||
// free the metadata space
|
||||
unsigned long size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
|
||||
err = memalloc->free_buffer((void*)hnd->base_metadata,
|
||||
(size_t) size, hnd->offset_metadata,
|
||||
hnd->fd_metadata);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
// Release the genlock
|
||||
|
||||
Reference in New Issue
Block a user