From 78f44e8bdf626c283c7447977f95f8666ebc9ab2 Mon Sep 17 00:00:00 2001 From: Subbaraman Narayanamurthy Date: Thu, 7 Jul 2011 02:02:51 -0400 Subject: [PATCH 1/2] [PATCH] [recovery]: Fix recovery mode display for RGB8888 display. Change-Id: If9cf141d89ef3b537d1228148cb324af7dcc11db --- minui/graphics.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/minui/graphics.c b/minui/graphics.c index 8192d3f..1a4a8f3 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -28,6 +28,7 @@ #include #include +#include #ifndef BOARD_LDPI_RECOVERY #include "font_10x18.h" @@ -109,7 +110,7 @@ static int get_framebuffer(GGLSurface *fb) fb->data = (void*) (((unsigned) bits) + vi.yres * fi.line_length); #else fb->stride = vi.xres; - fb->data = (void*) (((unsigned) bits) + vi.yres * vi.xres * 2); + fb->data = (void*) (((unsigned) bits) + (vi.yres * vi.xres * vi.bits_per_pixel / 8)); #endif fb->format = GGL_PIXEL_FORMAT_RGB_565; memset(fb->data, 0, vi.yres * vi.xres * 2); @@ -131,12 +132,33 @@ static void set_active_framebuffer(unsigned n) if (n > 1) return; vi.yres_virtual = vi.yres * 2; vi.yoffset = n * vi.yres; - vi.bits_per_pixel = 16; if (ioctl(gr_fb_fd, FBIOPUT_VSCREENINFO, &vi) < 0) { perror("active fb swap failed"); } } +void gr_flip_32(unsigned *bits, unsigned short *ptr, unsigned count) +{ + unsigned i=0; + while (i> 11) & 0x1F); + red = (rgb32 << 3) | (rgb32 >> 2); + rgb32 = ((ptr[i] >> 5) & 0x3F); + green = (rgb32 << 2) | (rgb32 >> 4); + rgb32 = ((ptr[i]) & 0x1F); + blue = (rgb32 << 3) | (rgb32 >> 2); + alpha = 0xff; + rgb32 = (alpha << 24) | (blue << 16) + | (green << 8) | (red); + android_memset32((uint32_t *)bits, rgb32, 4); + i++; + bits++; + } +} + void gr_flip(void) { GGLContext *gl = gr_context; @@ -156,8 +178,17 @@ void gr_flip(void) /* 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, - vi.xres * vi.yres * 2); + if( vi.bits_per_pixel == 16) + { + memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data, + vi.xres * vi.yres * 2); + } + else + { + gr_flip_32((unsigned *)gr_framebuffer[gr_active_fb].data, + (unsigned short *)gr_mem_surface.data, + (vi.xres * vi.yres)); + } /* inform the display driver */ set_active_framebuffer(gr_active_fb); From 1c2238b3afa4bcc45ff286a1a752a434c012c5ee Mon Sep 17 00:00:00 2001 From: Joe Hansche Date: Sat, 9 Jul 2011 12:32:05 -0400 Subject: [PATCH 2/2] minui: graphics: finish updates for 32-bit framebuffer in recovery work around slight issue on Sensation device and Shooter, by using xres_virtual instead of xres to get the 4 extra bits needed. based of original changes from toastcfh and modified to not be hard coded 32 bit and work with 16 bit as well. Change-Id: I15850a0969050598ffc14279b8b50c6fcb4682f7 --- minui/graphics.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/minui/graphics.c b/minui/graphics.c index 1a4a8f3..c11e498 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -94,11 +94,11 @@ static int get_framebuffer(GGLSurface *fb) #ifdef BOARD_HAS_JANKY_BACKBUFFER fb->stride = fi.line_length/2; #else - fb->stride = vi.xres; + fb->stride = vi.xres_virtual; #endif fb->data = bits; fb->format = GGL_PIXEL_FORMAT_RGB_565; - memset(fb->data, 0, vi.yres * vi.xres * 2); + memset(fb->data, 0, vi.yres * vi.xres_virtual * vi.bits_per_pixel / 8); fb++; @@ -109,11 +109,11 @@ static int get_framebuffer(GGLSurface *fb) fb->stride = fi.line_length/2; fb->data = (void*) (((unsigned) bits) + vi.yres * fi.line_length); #else - fb->stride = vi.xres; - fb->data = (void*) (((unsigned) bits) + (vi.yres * vi.xres * vi.bits_per_pixel / 8)); + fb->stride = vi.xres_virtual; + fb->data = (void*) (((unsigned) bits) + (vi.yres * vi.xres_virtual * vi.bits_per_pixel / 8)); #endif fb->format = GGL_PIXEL_FORMAT_RGB_565; - memset(fb->data, 0, vi.yres * vi.xres * 2); + memset(fb->data, 0, vi.yres * vi.xres_virtual * vi.bits_per_pixel / 8); return fd; } @@ -122,8 +122,8 @@ static void get_memory_surface(GGLSurface* ms) { ms->version = sizeof(*ms); ms->width = vi.xres; ms->height = vi.yres; - ms->stride = vi.xres; - ms->data = malloc(vi.xres * vi.yres * 2); + ms->stride = vi.xres_virtual; + ms->data = malloc(vi.xres_virtual * vi.yres * vi.bits_per_pixel / 8); ms->format = GGL_PIXEL_FORMAT_RGB_565; } @@ -181,13 +181,13 @@ void gr_flip(void) if( vi.bits_per_pixel == 16) { memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data, - vi.xres * vi.yres * 2); + vi.xres_virtual * vi.yres *2); } else { - gr_flip_32((unsigned *)gr_framebuffer[gr_active_fb].data, + gr_flip_32((unsigned *)gr_framebuffer[gr_active_fb].data, \ (unsigned short *)gr_mem_surface.data, - (vi.xres * vi.yres)); + (vi.xres_virtual * vi.yres)); } /* inform the display driver */