Skip to content

Instantly share code, notes, and snippets.

@koush
Forked from psyke83/gist:1074017
Created July 9, 2011 22:42
Show Gist options
  • Save koush/1074018 to your computer and use it in GitHub Desktop.
Save koush/1074018 to your computer and use it in GitHub Desktop.
diff -urdN -x .git /extra/git/koush/android_bootable_recovery//minui/Android.mk bootable/recovery//minui/Android.mk
--- /extra/git/koush/android_bootable_recovery//minui/Android.mk 2011-07-09 23:39:10.549892000 +0100
+++ bootable/recovery//minui/Android.mk 2011-07-09 23:06:38.016647002 +0100
@@ -19,6 +19,10 @@
LOCAL_CFLAGS += -DBOARD_HAS_FLIPPED_SCREEN
endif
+ifeq ($(BOARD_USE_GR_FLIP_32), true)
+ LOCAL_CFLAGS += -DBOARD_USE_GR_FLIP_32
+endif
+
LOCAL_MODULE := libminui
include $(BUILD_STATIC_LIBRARY)
diff -urdN -x .git /extra/git/koush/android_bootable_recovery//minui/graphics.c bootable/recovery//minui/graphics.c
--- /extra/git/koush/android_bootable_recovery//minui/graphics.c 2011-07-09 23:39:10.549892000 +0100
+++ bootable/recovery//minui/graphics.c 2011-07-09 23:02:11.659892002 +0100
@@ -56,12 +56,20 @@
static int gr_vt_fd = -1;
static struct fb_var_screeninfo vi;
+#ifdef BOARD_USE_GR_FLIP_32
+static struct fb_fix_screeninfo fi;
+#endif
static int get_framebuffer(GGLSurface *fb)
-{
+{
+#ifdef BOARD_USE_GR_FLIP_32
+ int fd;
+ void *bits;
+#else
int fd;
struct fb_fix_screeninfo fi;
void *bits;
+#endif
fd = open("/dev/graphics/fb0", O_RDWR);
if (fd < 0) {
@@ -93,12 +101,15 @@
fb->height = vi.yres;
#ifdef BOARD_HAS_JANKY_BACKBUFFER
fb->stride = fi.line_length/2;
+#endif
+#ifdef BOARD_USE_GR_FLIP_32
+ fb->stride = fi.line_length / (vi.bits_per_pixel / 8);
#else
- fb->stride = vi.xres_virtual;
+ fb->stride = vi.xres;
#endif
fb->data = bits;
fb->format = GGL_PIXEL_FORMAT_RGB_565;
- memset(fb->data, 0, vi.yres * vi.xres_virtual * vi.bits_per_pixel / 8);
+ memset(fb->data, 0, vi.yres * vi.xres * 2);
fb++;
@@ -108,12 +119,16 @@
#ifdef BOARD_HAS_JANKY_BACKBUFFER
fb->stride = fi.line_length/2;
fb->data = (void*) (((unsigned) bits) + vi.yres * fi.line_length);
+#endif
+#ifdef BOARD_USE_GR_FLIP_32
+ fb->stride = fi.line_length / (vi.bits_per_pixel / 8);
+ fb->data = (void*) (((unsigned) bits) + (vi.yres * fi.line_length));
#else
- fb->stride = vi.xres_virtual;
- fb->data = (void*) (((unsigned) bits) + (vi.yres * vi.xres_virtual * vi.bits_per_pixel / 8));
+ fb->stride = vi.xres;
+ fb->data = (void*) (((unsigned) bits) + vi.yres * vi.xres * 2);
#endif
fb->format = GGL_PIXEL_FORMAT_RGB_565;
- memset(fb->data, 0, vi.yres * vi.xres_virtual * vi.bits_per_pixel / 8);
+ memset(fb->data, 0, vi.yres * vi.xres * 2);
return fd;
}
@@ -122,21 +137,27 @@
ms->version = sizeof(*ms);
ms->width = vi.xres;
ms->height = vi.yres;
- ms->stride = vi.xres_virtual;
- ms->data = malloc(vi.xres_virtual * vi.yres * vi.bits_per_pixel / 8);
+#ifdef BOARD_USE_GR_FLIP_32
+ ms->stride = fi.line_length / (vi.bits_per_pixel / 8);
+ ms->data = malloc(fi.line_length * vi.yres);
+#else
+ ms->stride = vi.xres;
+ ms->data = malloc(vi.xres * vi.yres * 2);
+#endif
ms->format = GGL_PIXEL_FORMAT_RGB_565;
}
static void set_active_framebuffer(unsigned n)
{
if (n > 1) return;
- vi.yres_virtual = vi.yres * 2;
+ vi.yres_virtual = vi.yres * 2;
vi.yoffset = n * vi.yres;
+// vi.bits_per_pixel = 24;
if (ioctl(gr_fb_fd, FBIOPUT_VSCREENINFO, &vi) < 0) {
perror("active fb swap failed");
}
}
-
+#ifdef BOARD_USE_GR_FLIP_32
void gr_flip_32(unsigned *bits, unsigned short *ptr, unsigned count)
{
unsigned i=0;
@@ -158,6 +179,7 @@
bits++;
}
}
+#endif
void gr_flip(void)
{
@@ -178,18 +200,23 @@
/* copy data from the in-memory surface to the buffer we're about
* to make active. */
- if( vi.bits_per_pixel == 16)
- {
- memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data,
- vi.xres_virtual * vi.yres *2);
+#ifdef BOARD_USE_GR_FLIP_32
+ if( vi.bits_per_pixel == 16)
+ {
+#endif
+ memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data,
+#ifdef BOARD_USE_GR_FLIP_32
+ fi.line_length * vi.yres);
}
else
{
gr_flip_32((unsigned *)gr_framebuffer[gr_active_fb].data, \
- (unsigned short *)gr_mem_surface.data,
- (vi.xres_virtual * vi.yres));
+ (unsigned short *)gr_mem_surface.data, \
+ ((fi.line_length / (vi.bits_per_pixel / 8)) * vi.yres));
}
-
+#else
+ vi.xres * vi.yres * 2);
+#endif
/* inform the display driver */
set_active_framebuffer(gr_active_fb);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment