Skip to content

Commit

Permalink
Merge "recovery: Fix overlay APIs in recovery mode"
Browse files Browse the repository at this point in the history
  • Loading branch information
Linux Build Service Account authored and Gerrit - the friendly Code Review server committed Oct 26, 2013
2 parents fd5f5ff + 8ac2dc8 commit dff8fc7
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 42 deletions.
32 changes: 24 additions & 8 deletions minui/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,16 @@ static void set_active_framebuffer(unsigned n)

void gr_flip(void)
{
if (-EINVAL == overlay_display_frame(gr_fb_fd, gr_mem_surface.data,
(fi.line_length * vi.yres))) {
if (has_overlay) {
// Allocate overly. It'll exit early if overlay already
// allocated and allocate it if not already allocated.
allocate_overlay(gr_fb_fd, gr_framebuffer);
if (overlay_display_frame(gr_fb_fd,gr_mem_surface.data,
(fi.line_length * vi.yres)) < 0) {
// Free overlay in failure case
free_overlay(gr_fb_fd);
}
} else {
GGLContext *gl = gr_context;

/* swap front and back buffers */
Expand Down Expand Up @@ -422,16 +430,22 @@ int gr_init(void)
gr_fb_blank(true);
gr_fb_blank(false);

if (!alloc_ion_mem(fi.line_length * vi.yres))
allocate_overlay(gr_fb_fd, gr_framebuffer);
if (has_overlay) {
if (alloc_ion_mem(fi.line_length * vi.yres) ||
allocate_overlay(gr_fb_fd, gr_framebuffer)) {
free_ion_mem();
}
}

return 0;
}

void gr_exit(void)
{
free_overlay(gr_fb_fd);
free_ion_mem();
if (has_overlay) {
free_overlay(gr_fb_fd);
free_ion_mem();
}

close(gr_fb_fd);
gr_fb_fd = -1;
Expand Down Expand Up @@ -461,15 +475,17 @@ gr_pixel *gr_fb_data(void)
void gr_fb_blank(bool blank)
{
int ret;
if (blank)
if (has_overlay && blank) {
free_overlay(gr_fb_fd);
}

ret = ioctl(gr_fb_fd, FBIOBLANK, blank ? FB_BLANK_POWERDOWN : FB_BLANK_UNBLANK);
if (ret < 0)
perror("ioctl(): blank");

if (!blank)
if (has_overlay && !blank) {
allocate_overlay(gr_fb_fd, gr_framebuffer);
}
}

void gr_get_memory_surface(gr_surface surface)
Expand Down
69 changes: 35 additions & 34 deletions minui/graphics_overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,30 +185,33 @@ int allocate_overlay(int fd, GGLSurface gr_fb[])
if (!overlay_supported)
return -EINVAL;

struct mdp_overlay overlay;
int ret = 0;
// Check if overlay is already allocated
if (MSMFB_NEW_REQUEST == overlay_id) {
struct mdp_overlay overlay;
int ret = 0;

memset(&overlay, 0 , sizeof (struct mdp_overlay));

/* Fill Overlay Data */

overlay.src.width = ALIGN(gr_fb[0].width, 32);
overlay.src.height = gr_fb[0].height;
overlay.src.format = map_mdp_pixel_format();
overlay.src_rect.w = gr_fb[0].width;
overlay.src_rect.h = gr_fb[0].height;
overlay.dst_rect.w = gr_fb[0].width;
overlay.dst_rect.h = gr_fb[0].height;
overlay.alpha = 0xFF;
overlay.transp_mask = MDP_TRANSP_NOP;
overlay.id = MSMFB_NEW_REQUEST;
ret = ioctl(fd, MSMFB_OVERLAY_SET, &overlay);
if (ret < 0) {
perror("Overlay Set Failed");
return ret;
}

memset(&overlay, 0 , sizeof (struct mdp_overlay));

/* Fill Overlay Data */

overlay.src.width = ALIGN(gr_fb[0].width, 32);
overlay.src.height = gr_fb[0].height;
overlay.src.format = map_mdp_pixel_format();
overlay.src_rect.w = gr_fb[0].width;
overlay.src_rect.h = gr_fb[0].height;
overlay.dst_rect.w = gr_fb[0].width;
overlay.dst_rect.h = gr_fb[0].height;
overlay.alpha = 0xFF;
overlay.transp_mask = MDP_TRANSP_NOP;
overlay.id = MSMFB_NEW_REQUEST;
ret = ioctl(fd, MSMFB_OVERLAY_SET, &overlay);
if (ret < 0) {
perror("Overlay Set Failed");
return ret;
overlay_id = overlay.id;
}

overlay_id = overlay.id;
return 0;
}

Expand Down Expand Up @@ -253,7 +256,7 @@ int overlay_display_frame(int fd, GGLubyte* data, size_t size)

if (overlay_id == MSMFB_NEW_REQUEST) {
perror("display_frame failed, no overlay\n");
return 0;
return -EINVAL;
}

memcpy(mem_info.mem_buf, data, size);
Expand All @@ -267,19 +270,17 @@ int overlay_display_frame(int fd, GGLubyte* data, size_t size)
ret = ioctl(fd, MSMFB_OVERLAY_PLAY, &ovdata);
if (ret < 0) {
perror("overlay_display_frame failed, overlay play Failed\n");
return 0;
}

memset(&ext_commit, 0, sizeof(struct mdp_display_commit));
ext_commit.flags = MDP_DISPLAY_COMMIT_OVERLAY;
ext_commit.wait_for_finish = 1;
ret = ioctl(fd, MSMFB_DISPLAY_COMMIT, &ext_commit);
if (ret < 0) {
perror("overlay_display_frame failed, overlay commit Failed\n!");
return 0;
} else {
memset(&ext_commit, 0, sizeof(struct mdp_display_commit));
ext_commit.flags = MDP_DISPLAY_COMMIT_OVERLAY;
ext_commit.wait_for_finish = 1;
ret = ioctl(fd, MSMFB_DISPLAY_COMMIT, &ext_commit);
if (ret < 0) {
perror("overlay_display_frame failed, overlay commit Failed\n!");
}
}

return 0;
return ret;
}

#else
Expand Down

0 comments on commit dff8fc7

Please sign in to comment.