Permalink
Browse files

mali: support sunxi hardware overlay also with r5g6b5 format

Now zero copy and tear free buffer swapping is also supported
for 16bpp desktop.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  • Loading branch information...
ssvb committed Sep 7, 2013
1 parent 64a0d64 commit 37d5e05d1cdc58f980c4197783449dcc66486cd3
Showing with 33 additions and 20 deletions.
  1. +19 −9 src/sunxi_disp.c
  2. +6 −5 src/sunxi_disp.h
  3. +3 −3 src/sunxi_mali_ump_dri2.c
  4. +5 −3 test/sunxi_disp_vsync_demo.c
View
@@ -357,11 +357,12 @@ int sunxi_layer_release(sunxi_disp_t *ctx)
return 0;
}
int sunxi_layer_set_x8r8g8b8_input_buffer(sunxi_disp_t *ctx,
uint32_t offset_in_framebuffer,
int width,
int height,
int stride)
int sunxi_layer_set_rgb_input_buffer(sunxi_disp_t *ctx,
int bpp,
uint32_t offset_in_framebuffer,
int width,
int height,
int stride)
{
__disp_fb_t fb;
__disp_rect_t rect = { 0, 0, width, height };
@@ -379,11 +380,20 @@ int sunxi_layer_set_x8r8g8b8_input_buffer(sunxi_disp_t *ctx,
}
fb.addr[0] = ctx->framebuffer_paddr + offset_in_framebuffer;
fb.size.width = stride;
fb.size.height = height;
fb.format = DISP_FORMAT_ARGB8888;
fb.seq = DISP_SEQ_ARGB;
fb.mode = DISP_MOD_INTERLEAVED;
if (bpp == 32) {
fb.format = DISP_FORMAT_ARGB8888;
fb.seq = DISP_SEQ_ARGB;
fb.mode = DISP_MOD_INTERLEAVED;
fb.size.width = stride;
} else if (bpp == 16) {
fb.format = DISP_FORMAT_RGB565;
fb.seq = DISP_SEQ_P10;
fb.mode = DISP_MOD_INTERLEAVED;
fb.size.width = stride * 2;
} else {
return -1;
}
tmp[0] = ctx->fb_id;
tmp[1] = ctx->layer_id;
View
@@ -89,11 +89,12 @@ int sunxi_hw_cursor_hide(sunxi_disp_t *ctx);
int sunxi_layer_reserve(sunxi_disp_t *ctx);
int sunxi_layer_release(sunxi_disp_t *ctx);
int sunxi_layer_set_x8r8g8b8_input_buffer(sunxi_disp_t *ctx,
uint32_t offset_in_framebuffer,
int width,
int height,
int stride);
int sunxi_layer_set_rgb_input_buffer(sunxi_disp_t *ctx,
int bpp,
uint32_t offset_in_framebuffer,
int width,
int height,
int stride);
int sunxi_layer_set_yuv420_input_buffer(sunxi_disp_t *ctx,
uint32_t y_offset_in_framebuffer,
@@ -344,7 +344,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
can_use_overlay = FALSE;
/* TODO: try to support other color depths later */
if (pDraw->bitsPerPixel != 32)
if (pDraw->bitsPerPixel != 32 && pDraw->bitsPerPixel != 16)
can_use_overlay = FALSE;
if (disp && disp->framebuffer_size - disp->gfx_layer_size < privates->size * 2) {
@@ -688,8 +688,8 @@ static void MaliDRI2CopyRegion(DrawablePtr pDraw,
/* Activate the overlay */
sunxi_layer_set_output_window(disp, pDraw->x, pDraw->y, pDraw->width, pDraw->height);
sunxi_layer_set_x8r8g8b8_input_buffer(disp, umpbuf->offs, umpbuf->width,
umpbuf->height, umpbuf->pitch / 4);
sunxi_layer_set_rgb_input_buffer(disp, umpbuf->cpp * 8, umpbuf->offs,
umpbuf->width, umpbuf->height, umpbuf->pitch / 4);
sunxi_layer_show(disp);
if (mali->bSwapbuffersWait) {
@@ -121,7 +121,8 @@ int main(int argc, char *argv[])
/* setup layer window to cover the whole screen */
sunxi_layer_set_output_window(disp, 0, 0, disp->xres, disp->yres);
/* setup the layer scanout buffer to the first page in the framebuffer */
sunxi_layer_set_x8r8g8b8_input_buffer(disp, 0, disp->xres, disp->yres, disp->xres);
sunxi_layer_set_rgb_input_buffer(disp, disp->bits_per_pixel,
0, disp->xres, disp->yres, disp->xres);
/* make the layer visible */
sunxi_layer_show(disp);
@@ -148,8 +149,9 @@ int main(int argc, char *argv[])
color);
/* schedule the change of layer scanout buffer on next vsync */
sunxi_layer_set_x8r8g8b8_input_buffer(disp, yoffs * disp->xres * 4,
disp->xres, disp->yres, disp->xres);
sunxi_layer_set_rgb_input_buffer(disp, disp->bits_per_pixel,
yoffs * disp->xres * 4,
disp->xres, disp->yres, disp->xres);
/* wait for the vsync itself */
sunxi_wait_for_vsync(disp);

0 comments on commit 37d5e05

Please sign in to comment.