void gr_fb_blank(bool blank) { #ifdef RECOVERY_LCD_BACKLIGHT_PATH int fd; fd = open(RECOVERY_LCD_BACKLIGHT_PATH, O_RDWR); if (fd < 0) { perror("cannot open LCD backlight"); return; } write(fd, blank ? "000" : "250", 3); close(fd); #else int ret; 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 (has_overlay && !blank) { allocate_overlay(gr_fb_fd, gr_framebuffer); } #endif }
void gr_flip(void) { 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 */ 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); /* inform the display driver */ set_active_framebuffer(gr_active_fb); } }
int gr_init(void) { gglInit(&gr_context); GGLContext *gl = gr_context; gr_init_font(); gr_vt_fd = open("/dev/tty0", O_RDWR | O_SYNC); if (gr_vt_fd < 0) { // This is non-fatal; post-Cupcake kernels don't have tty0. perror("can't open /dev/tty0"); } else if (ioctl(gr_vt_fd, KDSETMODE, (void*) KD_GRAPHICS)) { // However, if we do open tty0, we expect the ioctl to work. perror("failed KDSETMODE to KD_GRAPHICS on tty0"); gr_exit(); return -1; } gr_fb_fd = get_framebuffer(gr_framebuffer); if (gr_fb_fd < 0) { gr_exit(); return -1; } get_memory_surface(&gr_mem_surface); 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) */ gr_active_fb = 0; if (!has_overlay) set_active_framebuffer(0); gl->colorBuffer(gl, &gr_mem_surface); gl->activeTexture(gl, 0); gl->enable(gl, GGL_BLEND); gl->blendFunc(gl, GGL_SRC_ALPHA, GGL_ONE_MINUS_SRC_ALPHA); gr_fb_blank(true); gr_fb_blank(false); if (has_overlay) { if (alloc_ion_mem(fi.line_length * vi.yres) || allocate_overlay(gr_fb_fd, gr_framebuffer)) { free_ion_mem(); } } return 0; }
int gr_fb_blank(int blank) { 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); return ret; }
void gr_flip(void) { 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 */ if (double_buffering) gr_active_fb = (gr_active_fb + 1) & 1; #ifdef BOARD_HAS_FLIPPED_SCREEN /* flip buffer 180 degrees for devices with physicaly inverted screens */ unsigned int i; unsigned int j; uint8_t tmp; vi.xres_virtual = fi.line_length / PIXEL_SIZE; for (i = 0; i < ((vi.xres_virtual * vi.yres)/2); i++) { for (j = 0; j < PIXEL_SIZE; j++) { tmp = gr_mem_surface.data[i * PIXEL_SIZE + j]; gr_mem_surface.data[i * PIXEL_SIZE + j] = gr_mem_surface.data[(vi.xres_virtual * vi.yres * PIXEL_SIZE) - ((i+1) * PIXEL_SIZE) + j]; gr_mem_surface.data[(vi.xres_virtual * vi.yres * PIXEL_SIZE) - ((i+1) * PIXEL_SIZE) + j] = tmp; } } #endif /* 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); } }
static int impl_open(struct framebuffer *fb) { struct fb_qcom_overlay_data *data = mzalloc(sizeof(struct fb_qcom_overlay_data)); data->overlay_id = MSMFB_NEW_REQUEST; if (alloc_ion_mem(data, fb->fi.line_length * fb->vi.yres) < 0) goto fail; if(allocate_overlay(data, fb->fd, fb->vi.xres, fb->vi.yres) < 0) { free_ion_mem(data); goto fail; } fb->impl_data = data; return 0; fail: free(data); return -1; }
void gr_flip(void) { 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 */ if (double_buffering) gr_active_fb = (gr_active_fb + 1) & 1; /*PERSONAL MOD FOR FLIPPED SCREN like Unite2 */ #ifdef BOARD_HAS_FLIPPED_SCREEN /* flip buffer 180 degrees for devices with physicaly inverted screens */ unsigned int i; for (i = 1; i < (vi.xres * vi.yres); i++) { unsigned short tmp = gr_mem_surface.data[i]; gr_mem_surface.data[i] = gr_mem_surface.data[(vi.xres * vi.yres * 2) - i]; gr_mem_surface.data[(vi.xres * vi.yres * 2) - i] = tmp; } #endif /* 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); } }