diff --git a/framebuffer.cpp b/framebuffer.cpp index 797982f..d9cc89e 100644 --- a/framebuffer.cpp +++ b/framebuffer.cpp @@ -59,7 +59,8 @@ struct fb_context_t { /*****************************************************************************/ static void -msm_copy_buffer(buffer_handle_t handle, int fd, int width, int height, +msm_copy_buffer(buffer_handle_t handle, int fd, + int width, int height, int format, int x, int y, int w, int h); static int fb_setSwapInterval(struct framebuffer_device_t* dev, @@ -120,9 +121,6 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer) m->currentBuffer = buffer; } else { - // If we can't do the page_flip, just copy the buffer to the front - // FIXME: use copybit HAL instead of memcpy - void* fb_vaddr; void* buffer_vaddr; @@ -138,8 +136,9 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer) //memcpy(fb_vaddr, buffer_vaddr, m->finfo.line_length * m->info.yres); - msm_copy_buffer(m->framebuffer, m->framebuffer->fd, - m->info.xres, m->info.yres, + msm_copy_buffer( + m->framebuffer, m->framebuffer->fd, + m->info.xres, m->info.yres, m->fbFormat, m->info.xoffset, m->info.yoffset, m->info.width, m->info.height); @@ -199,18 +198,26 @@ int mapFrameBufferLocked(struct private_module_t* module) info.yoffset = 0; info.activate = FB_ACTIVATE_NOW; + /* Interpretation of offset for color fields: All offsets are from the right, + * inside a "pixel" value, which is exactly 'bits_per_pixel' wide (means: you + * can use the offset as right argument to <<). A pixel afterwards is a bit + * stream and is written to video memory as that unmodified. This implies + * big-endian byte order if bits_per_pixel is greater than 8. + */ + /* - * Explicitly request 5/6/5 + * Explicitly request RGBA_8888 */ - info.bits_per_pixel = 16; - info.red.offset = 11; - info.red.length = 5; - info.green.offset = 5; - info.green.length = 6; - info.blue.offset = 0; - info.blue.length = 5; + info.bits_per_pixel = 32; + info.red.offset = 24; + info.red.length = 8; + info.green.offset = 16; + info.green.length = 8; + info.blue.offset = 8; + info.blue.length = 8; info.transp.offset = 0; info.transp.length = 0; + module->fbFormat = HAL_PIXEL_FORMAT_RGBX_8888; /* * Request NUM_BUFFERS screens (at lest 2 for page flipping) @@ -378,7 +385,7 @@ int fb_device_open(hw_module_t const* module, const char* name, const_cast(dev->device.width) = m->info.xres; const_cast(dev->device.height) = m->info.yres; const_cast(dev->device.stride) = stride; - const_cast(dev->device.format) = HAL_PIXEL_FORMAT_RGB_565; + const_cast(dev->device.format) = m->fbFormat; const_cast(dev->device.xdpi) = m->xdpi; const_cast(dev->device.ydpi) = m->ydpi; const_cast(dev->device.fps) = m->fps; @@ -400,7 +407,8 @@ int fb_device_open(hw_module_t const* module, const char* name, /* Copy a pmem buffer to the framebuffer */ static void -msm_copy_buffer(buffer_handle_t handle, int fd, int width, int height, +msm_copy_buffer(buffer_handle_t handle, int fd, + int width, int height, int format, int x, int y, int w, int h) { struct { @@ -425,7 +433,7 @@ msm_copy_buffer(buffer_handle_t handle, int fd, int width, int height, blit.req.dst.height = height; blit.req.dst.offset = 0; blit.req.dst.memory_id = fd; - blit.req.dst.format = MDP_RGB_565; + blit.req.dst.format = format; blit.req.src_rect.x = blit.req.dst_rect.x = x; blit.req.src_rect.y = blit.req.dst_rect.y = y; diff --git a/gralloc.cpp b/gralloc.cpp index 45746ef..32bd24a 100644 --- a/gralloc.cpp +++ b/gralloc.cpp @@ -104,6 +104,7 @@ struct private_module_t HAL_MODULE_INFO_SYM = { perform: gralloc_perform, }, framebuffer: 0, + fbFormat: 0, flags: 0, numBuffers: 0, bufferMask: 0, diff --git a/gralloc_priv.h b/gralloc_priv.h index 534b4c0..1432c25 100644 --- a/gralloc_priv.h +++ b/gralloc_priv.h @@ -38,6 +38,7 @@ struct private_module_t { gralloc_module_t base; struct private_handle_t* framebuffer; + uint32_t fbFormat; uint32_t flags; uint32_t numBuffers; uint32_t bufferMask;