Skip to content

Commit

Permalink
Update minui to support overlay graphics
Browse files Browse the repository at this point in the history
Fix path in minuitwrp for includes

Change-Id: I9e9e5f67e8574cdcbc6f8873ceeb56eab71143ed
  • Loading branch information
Dees-Troy committed May 2, 2014
1 parent 626009f commit 62b75ab
Show file tree
Hide file tree
Showing 10 changed files with 1,616 additions and 38 deletions.
77 changes: 76 additions & 1 deletion minui/Android.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := events.c resources.c
LOCAL_SRC_FILES := graphics_overlay.c events.c resources.c
ifneq ($(BOARD_CUSTOM_GRAPHICS),)
LOCAL_SRC_FILES += $(BOARD_CUSTOM_GRAPHICS)
else
Expand All @@ -11,6 +11,19 @@ endif
LOCAL_C_INCLUDES +=\
external/libpng\
external/zlib

ifeq ($(TW_TARGET_USES_QCOM_BSP), true)
LOCAL_CFLAGS += -DMSM_BSP
ifeq ($(TARGET_PREBUILT_KERNEL),)
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
else
LOCAL_C_INCLUDES += bootable/recovery/minui/include
endif
else
LOCAL_C_INCLUDES += bootable/recovery/minui/include
endif

LOCAL_STATIC_LIBRARY := libpng
LOCAL_MODULE := libminui

Expand Down Expand Up @@ -44,3 +57,65 @@ ifneq ($(TW_NO_SCREEN_BLANK),)
endif

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_SRC_FILES := graphics_overlay.c events.c resources.c
ifneq ($(BOARD_CUSTOM_GRAPHICS),)
LOCAL_SRC_FILES += $(BOARD_CUSTOM_GRAPHICS)
else
LOCAL_SRC_FILES += graphics.c
endif

ifeq ($(TW_TARGET_USES_QCOM_BSP), true)
LOCAL_CFLAGS += -DMSM_BSP
ifeq ($(TARGET_PREBUILT_KERNEL),)
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
else
LOCAL_C_INCLUDES += bootable/recovery/minui/include
endif
else
LOCAL_C_INCLUDES += bootable/recovery/minui/include
endif

LOCAL_C_INCLUDES +=\
external/libpng\
external/zlib

LOCAL_MODULE := libminui

LOCAL_ARM_MODE:= arm
LOCAL_SHARED_LIBRARIES := libpng libpixelflinger
# This used to compare against values in double-quotes (which are just
# ordinary characters in this context). Strip double-quotes from the
# value so that either will work.

ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),RGBX_8888)
LOCAL_CFLAGS += -DRECOVERY_RGBX
endif
ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),BGRA_8888)
LOCAL_CFLAGS += -DRECOVERY_BGRA
endif

ifneq ($(TARGET_RECOVERY_OVERSCAN_PERCENT),)
LOCAL_CFLAGS += -DOVERSCAN_PERCENT=$(TARGET_RECOVERY_OVERSCAN_PERCENT)
else
LOCAL_CFLAGS += -DOVERSCAN_PERCENT=0
endif

ifneq ($(TW_BRIGHTNESS_PATH),)
LOCAL_CFLAGS += -DTW_BRIGHTNESS_PATH=\"$(TW_BRIGHTNESS_PATH)\"
endif
ifneq ($(TW_MAX_BRIGHTNESS),)
LOCAL_CFLAGS += -DTW_MAX_BRIGHTNESS=$(TW_MAX_BRIGHTNESS)
else
LOCAL_CFLAGS += -DTW_MAX_BRIGHTNESS=255
endif
ifneq ($(TW_NO_SCREEN_BLANK),)
LOCAL_CFLAGS += -DTW_NO_SCREEN_BLANK
endif

LOCAL_CFLAGS += -DFASTMMI_FEATURE

include $(BUILD_SHARED_LIBRARY)
84 changes: 61 additions & 23 deletions minui/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <stdlib.h>
#include <unistd.h>

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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++;

Expand All @@ -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;
}
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand Down Expand Up @@ -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);
}
Loading

0 comments on commit 62b75ab

Please sign in to comment.