Merge "gralloc: Configure framebuffer mode according to requested image format." am: 1e249a0769
am: ae5e519fd9
am: 30124221f4
Change-Id: I609e11a90b3bcb50d12b487a4d4b3cb43035d810
This commit is contained in:
commit
94f0d1a30f
3 changed files with 23 additions and 8 deletions
|
@ -117,7 +117,7 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
int mapFrameBufferLocked(struct private_module_t* module)
|
int mapFrameBufferLocked(struct private_module_t* module, int format)
|
||||||
{
|
{
|
||||||
// already initialized...
|
// already initialized...
|
||||||
if (module->framebuffer) {
|
if (module->framebuffer) {
|
||||||
|
@ -161,6 +161,20 @@ int mapFrameBufferLocked(struct private_module_t* module)
|
||||||
*/
|
*/
|
||||||
info.yres_virtual = info.yres * NUM_BUFFERS;
|
info.yres_virtual = info.yres * NUM_BUFFERS;
|
||||||
|
|
||||||
|
switch (format) {
|
||||||
|
case HAL_PIXEL_FORMAT_RGBA_8888:
|
||||||
|
info.bits_per_pixel = 32;
|
||||||
|
info.red.offset = 0;
|
||||||
|
info.red.length = 8;
|
||||||
|
info.green.offset = 8;
|
||||||
|
info.green.length = 8;
|
||||||
|
info.blue.offset = 16;
|
||||||
|
info.blue.length = 8;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ALOGW("unknown format: %d", format);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t flags = PAGE_FLIP;
|
uint32_t flags = PAGE_FLIP;
|
||||||
#if USE_PAN_DISPLAY
|
#if USE_PAN_DISPLAY
|
||||||
|
@ -280,7 +294,8 @@ int mapFrameBufferLocked(struct private_module_t* module)
|
||||||
static int mapFrameBuffer(struct private_module_t* module)
|
static int mapFrameBuffer(struct private_module_t* module)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&module->lock);
|
pthread_mutex_lock(&module->lock);
|
||||||
int err = mapFrameBufferLocked(module);
|
// Request RGBA8888 because the platform assumes support for RGBA8888.
|
||||||
|
int err = mapFrameBufferLocked(module, HAL_PIXEL_FORMAT_RGBA_8888);
|
||||||
pthread_mutex_unlock(&module->lock);
|
pthread_mutex_unlock(&module->lock);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ inline size_t roundUpToPageSize(size_t x) {
|
||||||
return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
|
return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mapFrameBufferLocked(struct private_module_t* module);
|
int mapFrameBufferLocked(struct private_module_t* module, int format);
|
||||||
int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd);
|
int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd);
|
||||||
int mapBuffer(gralloc_module_t const* module, private_handle_t* hnd);
|
int mapBuffer(gralloc_module_t const* module, private_handle_t* hnd);
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ struct private_module_t HAL_MODULE_INFO_SYM = {
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev,
|
static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev,
|
||||||
size_t size, int usage, buffer_handle_t* pHandle)
|
size_t size, int format, int usage, buffer_handle_t* pHandle)
|
||||||
{
|
{
|
||||||
private_module_t* m = reinterpret_cast<private_module_t*>(
|
private_module_t* m = reinterpret_cast<private_module_t*>(
|
||||||
dev->common.module);
|
dev->common.module);
|
||||||
|
@ -110,7 +110,7 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev,
|
||||||
if (m->framebuffer == NULL) {
|
if (m->framebuffer == NULL) {
|
||||||
// initialize the framebuffer, the framebuffer is mapped once
|
// initialize the framebuffer, the framebuffer is mapped once
|
||||||
// and forever.
|
// and forever.
|
||||||
int err = mapFrameBufferLocked(m);
|
int err = mapFrameBufferLocked(m, format);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -154,12 +154,12 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gralloc_alloc_framebuffer(alloc_device_t* dev,
|
static int gralloc_alloc_framebuffer(alloc_device_t* dev,
|
||||||
size_t size, int usage, buffer_handle_t* pHandle)
|
size_t size, int format, int usage, buffer_handle_t* pHandle)
|
||||||
{
|
{
|
||||||
private_module_t* m = reinterpret_cast<private_module_t*>(
|
private_module_t* m = reinterpret_cast<private_module_t*>(
|
||||||
dev->common.module);
|
dev->common.module);
|
||||||
pthread_mutex_lock(&m->lock);
|
pthread_mutex_lock(&m->lock);
|
||||||
int err = gralloc_alloc_framebuffer_locked(dev, size, usage, pHandle);
|
int err = gralloc_alloc_framebuffer_locked(dev, size, format, usage, pHandle);
|
||||||
pthread_mutex_unlock(&m->lock);
|
pthread_mutex_unlock(&m->lock);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ static int gralloc_alloc(alloc_device_t* dev,
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
if (usage & GRALLOC_USAGE_HW_FB) {
|
if (usage & GRALLOC_USAGE_HW_FB) {
|
||||||
err = gralloc_alloc_framebuffer(dev, size, usage, pHandle);
|
err = gralloc_alloc_framebuffer(dev, size, format, usage, pHandle);
|
||||||
} else {
|
} else {
|
||||||
err = gralloc_alloc_buffer(dev, size, usage, pHandle);
|
err = gralloc_alloc_buffer(dev, size, usage, pHandle);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue