From 62b75ab66a94ffef29d0568c4d54d63a02aff814 Mon Sep 17 00:00:00 2001 From: Dees Troy Date: Fri, 2 May 2014 13:20:33 +0000 Subject: Update minui to support overlay graphics Fix path in minuitwrp for includes Change-Id: I9e9e5f67e8574cdcbc6f8873ceeb56eab71143ed --- minui/graphics.c | 84 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 23 deletions(-) (limited to 'minui/graphics.c') diff --git a/minui/graphics.c b/minui/graphics.c index 00fbb1eef..8f951756d 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -69,6 +70,15 @@ static int gr_vt_fd = -1; static struct fb_var_screeninfo vi; static struct fb_fix_screeninfo fi; +static bool has_overlay = false; + +bool target_has_overlay(char *version); +int free_ion_mem(void); +int alloc_ion_mem(unsigned int size); +int allocate_overlay(int fd, GGLSurface gr_fb[]); +int free_overlay(int fd); +int overlay_display_frame(int fd, GGLubyte* data, size_t size); + static int get_framebuffer(GGLSurface *fb) { int fd; @@ -127,11 +137,15 @@ static int get_framebuffer(GGLSurface *fb) return -1; } - bits = mmap(0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (bits == MAP_FAILED) { - perror("failed to mmap framebuffer"); - close(fd); - return -1; + has_overlay = target_has_overlay(fi.id); + + if (!has_overlay) { + bits = mmap(0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (bits == MAP_FAILED) { + perror("failed to mmap framebuffer"); + close(fd); + return -1; + } } overscan_offset_x = vi.xres * overscan_percent / 100; @@ -141,9 +155,11 @@ static int get_framebuffer(GGLSurface *fb) fb->width = vi.xres; fb->height = vi.yres; fb->stride = fi.line_length/PIXEL_SIZE; - fb->data = bits; fb->format = PIXEL_FORMAT; - memset(fb->data, 0, vi.yres * fi.line_length); + if (!has_overlay) { + fb->data = bits; + memset(fb->data, 0, vi.yres * fi.line_length); + } fb++; @@ -157,9 +173,11 @@ static int get_framebuffer(GGLSurface *fb) fb->width = vi.xres; fb->height = vi.yres; fb->stride = fi.line_length/PIXEL_SIZE; - fb->data = (void*) (((unsigned) bits) + vi.yres * fi.line_length); fb->format = PIXEL_FORMAT; - memset(fb->data, 0, vi.yres * fi.line_length); + if (!has_overlay) { + fb->data = (void*) (((unsigned) bits) + vi.yres * fi.line_length); + memset(fb->data, 0, vi.yres * fi.line_length); + } return fd; } @@ -186,19 +204,22 @@ static void set_active_framebuffer(unsigned n) void gr_flip(void) { - GGLContext *gl = gr_context; + if (-EINVAL == overlay_display_frame(gr_fb_fd, gr_mem_surface.data, + (fi.line_length * vi.yres))) { + GGLContext *gl = gr_context; - /* swap front and back buffers */ - if (double_buffering) - gr_active_fb = (gr_active_fb + 1) & 1; + /* swap front and back buffers */ + if (double_buffering) + gr_active_fb = (gr_active_fb + 1) & 1; - /* copy data from the in-memory surface to the buffer we're about - * to make active. */ - memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data, - fi.line_length * vi.yres); + /* copy data from the in-memory surface to the buffer we're about + * to make active. */ + memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data, + fi.line_length * vi.yres); - /* inform the display driver */ - set_active_framebuffer(gr_active_fb); + /* inform the display driver */ + set_active_framebuffer(gr_active_fb); + } } void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a) @@ -390,12 +411,13 @@ int gr_init(void) get_memory_surface(&gr_mem_surface); - printf("framebuffer: fd %d (%d x %d)\n", - gr_fb_fd, gr_framebuffer[0].width, gr_framebuffer[0].height); + fprintf(stderr, "framebuffer: fd %d (%d x %d)\n", + gr_fb_fd, gr_framebuffer[0].width, gr_framebuffer[0].height); - /* start with 0 as front (displayed) and 1 as back (drawing) */ + /* start with 0 as front (displayed) and 1 as back (drawing) */ gr_active_fb = 0; - set_active_framebuffer(0); + if (!has_overlay) + set_active_framebuffer(0); gl->colorBuffer(gl, &gr_mem_surface); gl->activeTexture(gl, 0); @@ -405,11 +427,17 @@ 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); + return 0; } void gr_exit(void) { + free_overlay(gr_fb_fd); + free_ion_mem(); + close(gr_fb_fd); gr_fb_fd = -1; @@ -451,9 +479,19 @@ void gr_fb_blank(bool blank) close(fd); #else int ret; + if (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) + allocate_overlay(gr_fb_fd, gr_framebuffer); #endif } + +void gr_get_memory_surface(gr_surface surface) +{ + get_memory_surface( (GGLSurface*) surface); +} -- cgit v1.2.3