void gr_flip(void) { GGLContext *gl = gr_context; /* swap front and back buffers */ 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; 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. */ 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, (gr_framebuffer[gr_active_fb].stride * gr_framebuffer[gr_active_fb].height)); } /* inform the display driver */ set_active_framebuffer(gr_active_fb); }
void gr_flip(void) { 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; #ifdef BOARD_HAS_FLIPPED_SCREEN /* flip buffer 180 degrees for devices with physicaly inverted screens */ unsigned int i; unsigned int j; uint8_t tmp; 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, vi.xres_virtual * vi.yres * PIXEL_SIZE); /* inform the display driver */ set_active_framebuffer(gr_active_fb); } }
void gr_flip(void) { 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; 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, vi.xres_virtual * vi.yres * PIXEL_SIZE); /* inform the display driver */ set_active_framebuffer(gr_active_fb); }
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); } }
void gr_flip(void) { GGLContext *gl = gr_context; /* currently active buffer becomes the backbuffer */ gl->colorBuffer(gl, gr_framebuffer + gr_active_fb); /* swap front and back buffers */ gr_active_fb = (gr_active_fb + 1) & 1; /* inform the display driver */ set_active_framebuffer(gr_active_fb); }
int gr_init(void) { gglInit(&gr_context); GGLContext *gl = gr_context; gr_mem_surface.data = NULL; gr_init_font(); gr_vt_fd = open("/dev/tty0", O_RDWR | O_SYNC); if (gr_vt_fd < 0) { gr_vt_fd = open("/dev/tty", 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 { ioctl(gr_vt_fd, KDGETMODE, &gr_vt_mode); 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) { perror("unable to get framebuffer"); 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; 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); return 0; }
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. } 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) { perror("Unable to get framebuffer.\n"); 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); #ifdef TW_SCREEN_BLANK_ON_BOOT printf("TW_SCREEN_BLANK_ON_BOOT := true\n"); gr_fb_blank(true); gr_fb_blank(false); #endif if (!alloc_ion_mem(fi.line_length * vi.yres)) allocate_overlay(gr_fb_fd, gr_framebuffer); return 0; }
void gr_flip(void) { GGLContext *gl = gr_context; /* swap front and back buffers */ gr_active_fb = (gr_active_fb + 1) & 1; #ifdef SCREEN_PORTRAIT int x, y; /* rotate 90 for (x = 0; x < gr_mem_surface.width; x++) { for (y = 0; y < gr_mem_surface.height; y++) { *(gr_framebuffer[gr_active_fb].data + (gr_mem_surface.height * x + gr_mem_surface.height - y) * 2 - 2) = *(gr_mem_surface.data + (gr_mem_surface.width * y + x) * 2); *(gr_framebuffer[gr_active_fb].data + (gr_mem_surface.height * x + gr_mem_surface.height - y) * 2 - 1) = *(gr_mem_surface.data + (gr_mem_surface.width * y + x) * 2 + 1); } } */ /* rotate 270 */ /* for (x = 0; x < gr_mem_surface.width; x++) { for (y = 0; y < gr_mem_surface.height; y++) { *(gr_framebuffer[gr_active_fb].data + (gr_mem_surface.height * (gr_mem_surface.width - x) + y) * 2 - 2) = *(gr_mem_surface.data + (gr_mem_surface.width * y + x) * 2); *(gr_framebuffer[gr_active_fb].data + (gr_mem_surface.height * (gr_mem_surface.width - x) + y) * 2 - 1) = *(gr_mem_surface.data + (gr_mem_surface.width * y + x) * 2 + 1); } } */ for (x = 0; x < gr_mem_surface.width; x++) { for (y = 0; y < gr_mem_surface.height; y++) { *(gr_framebuffer[gr_active_fb].data + (gr_mem_surface.height * (gr_mem_surface.width - x - 1) + y) * 2) = *(gr_mem_surface.data + (gr_mem_surface.width * y + x) * 2); *(gr_framebuffer[gr_active_fb].data + (gr_mem_surface.height * (gr_mem_surface.width - x - 1) + y) * 2 + 1) = *(gr_mem_surface.data + (gr_mem_surface.width * y + x) * 2 + 1); } } #else /* 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); #endif /* inform the display driver */ set_active_framebuffer(gr_active_fb); }
void gr_flip(void) { GGLContext *gl = gr_context; /* swap front and back buffers */ 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 main(int argc, char *argv[]) { time_t start = time(NULL); printf("Starting recovery on %s", ctime(&start)); gr_fb_fd = get_framebuffer(gr_framebuffer); if (gr_fb_fd < 0) { return -1; } get_memory_surface(&gr_mem_surface); typedef unsigned short pixel; pixel* dst = gr_framebuffer[gr_active_fb].data; pixel* src = gr_mem_surface.data; int i,j; switch(ROTATE){ case ROTATE_90: for(i = 0;i < vi.yres;i++) { for(j = 0;j < vi.xres;j++) { dst[i * vi.xres + vi.xres - 1 - j] = src[i + j * vi.yres]; } } break; case ROTATE_270: for(i = 0;i < vi.yres;i++) { for(j = 0;j < vi.xres;j++) { dst[(vi.yres -1 - i) * vi.xres + j] = src[i + j * vi.yres]; } } break; default://0 memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data, vi.xres * vi.yres * 2); break; } set_active_framebuffer(0); ioctl(gr_fb_fd, FBIOPAN_DISPLAY, &vi); exit: munmap(gr_framebuffer[0].data, vi.yres * vi.xres * 2); munmap(gr_framebuffer[1].data, vi.yres * vi.xres * 2); munmap(recovery_ebc_buffer_base, recovery_ebc_buffer_len); close(gr_fb_fd); close(recovery_ebc_fd); return 0; }
void gr_flip(void) { GGLContext *gl = gr_context; /* swap front and back buffers */ gr_active_fb = (gr_active_fb + 1) & 1; /* copy data from the in-memory surface to the buffer we're about * to make active. */ if(vi.rotate == 180) { unsigned int i = 0, max = 0; max = vi.yres * vi.xres; if(PIXEL_SIZE == 2) { unsigned short *src, *dest; src = (unsigned short *)gr_mem_surface.data; dest = (unsigned short *)gr_framebuffer[gr_active_fb].data; for(max ; max > 0; max--, i++) { dest[max - 1] = src[i]; } } else { unsigned int *src, *dest; src = (unsigned int *)gr_mem_surface.data; dest = (unsigned int *)gr_framebuffer[gr_active_fb].data; for(max ; max > 0; max--, i++) { dest[max - 1] = src[i]; } } } else { 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); }
void gr_flip(void) { 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; /* 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_virtual * vi.yres * PIXEL_SIZE); /* inform the display driver */ set_active_framebuffer(gr_active_fb); } }
void gr_flip(void) { 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); #ifdef BOARD_HAS_FLIPPED_SCREEN rk_rotate_surface_180(&gr_framebuffer[gr_active_fb]); #endif /* inform the display driver */ set_active_framebuffer(gr_active_fb); }
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); } }
int gr_init(void) { GGLContext *gl; int fd; gglInit(&gr_context); gl = gr_context; gr_init_font(); fd = open("/dev/tty0", O_RDWR | O_SYNC); if(fd < 0) return -1; if(ioctl(fd, KDSETMODE, (void*) KD_GRAPHICS)) { close(fd); return -1; } gr_fb_fd = get_framebuffer(gr_framebuffer); if(gr_fb_fd < 0) { ioctl(fd, KDSETMODE, (void*) KD_TEXT); close(fd); return -1; } gr_vt_fd = fd; /* start with 0 as front (displayed) and 1 as back (drawing) */ gr_active_fb = 0; set_active_framebuffer(0); gl->colorBuffer(gl, gr_framebuffer + 1); gl->activeTexture(gl, 0); gl->enable(gl, GGL_BLEND); gl->blendFunc(gl, GGL_SRC_ALPHA, GGL_ONE_MINUS_SRC_ALPHA); return 0; }
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); } }
void gr_flip(void) { GGLContext *gl = gr_context; /* swap front and back buffers */ if (double_buffering) gr_active_fb = (gr_active_fb + 1) & 1; /* 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; }*/ /* 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); }
void gr_flip(void) { GGLContext *gl = gr_context; int j,k; unsigned fb_lineLength = vi.xres_virtual * 2; unsigned mem_surface_lineLength = vi.xres * 2; void *d = NULL; void *s = gr_mem_surface.data; unsigned int width = vi.xres_virtual; unsigned int height = vi.yres; /* swap front and back buffers */ gr_active_fb = (gr_active_fb + 1) & 1; d = gr_framebuffer[gr_active_fb].data; /* copy data from the in-memory surface to the buffer we're about * to make active. */ if(0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "270", 3)) { unsigned int l; unsigned short *s_temp; unsigned short *d_temp; s_temp = (unsigned short*)s; for (j=0; j<width; j++){ for (k=0, l=height-1; k<height; k++, l--) { d_temp = d + ((width * l + j) << 1); *d_temp = *s_temp++; } } } else if(0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "90", 2)) { unsigned int l; unsigned short *s_temp; unsigned short *d_temp; s_temp = (unsigned short*)s; for (j=width - 1; j>=0; j--){ for (k=0, l=0; k<height; k++, l++) { d_temp = d + ((width * l + j) << 1); *d_temp = *s_temp++; } } } else{ for (j = 0; j < vi.yres; ++ j) { memcpy(d, s, mem_surface_lineLength); d += fb_lineLength; s += mem_surface_lineLength; } } /* memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data, vi.xres * vi.yres * 2); */ /* inform the display driver */ set_active_framebuffer(gr_active_fb); }