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); } }
void free_timecode(timecode_data* tc_data) { int c; for (c = 0; c < 11; c++) free_overlay(&tc_data->tc_ovly[c]); }
static void impl_close(struct framebuffer *fb) { struct fb_qcom_overlay_data *data = fb->impl_data; free_overlay(data, fb->fd); free_ion_mem(data); free(data); fb->impl_data = NULL; }
YUV_error ml_text_to_ovly_player(p_info_rec* info, overlay* ovly, char* text, int max_width, char* font, const int size, int margin, const int aspect_ratio_num, const int aspect_ratio_den) { #define MAX_LINES 100 overlay line_ovly[MAX_LINES]; char* sub_str; int count; int length; int no_lines; BYTE* src; BYTE* dst; int j, n; // render each line of text to an overlay sub_str = text; length = strlen(text); no_lines = 0; while (length > 0 && no_lines < MAX_LINES) { count = text_to_overlay_player(info, &line_ovly[no_lines], sub_str, max_width, 0, 0, 0, 0, 0, 0, font, size, aspect_ratio_num, aspect_ratio_den); if (count < 0) return count; sub_str += count; length -= count; no_lines += 1; } // create overlay to accomodate every rendered line ovly->h = no_lines * size; ovly->w = 0; for (n = 0; n < no_lines; n++) ovly->w = max(ovly->w, line_ovly[n].w); ovly->h += margin * 2; ovly->w += margin * 2; ovly->ssx = -1; ovly->ssy = -1; ovly->buff = malloc(ovly->w * ovly->h * 2); if (ovly->buff == NULL) return YUV_no_memory; memset(ovly->buff, 0, ovly->w * ovly->h * 2); ovly->Cbuff = NULL; // copy rendered text for (n = 0; n < no_lines; n++) { src = line_ovly[n].buff; dst = ovly->buff + (ovly->w * n * size) + margin * ovly->w + margin; for (j = 0; j < line_ovly[n].h; j++) { memcpy(dst, src, line_ovly[n].w); src += line_ovly[n].w; dst += ovly->w; } free_overlay(&line_ovly[n]); } return YUV_OK; }
void free_char_set(char_set_data* cs_data) { int c; if (cs_data == NULL) return; for (c = 0; c < cs_data->numChars; c++) free_overlay(&cs_data->cs_ovly[c]); }
void gr_exit(void) { free_overlay(gr_fb_fd); free_ion_mem(); close(gr_fb_fd); gr_fb_fd = -1; free(gr_mem_surface.data); ioctl(gr_vt_fd, KDSETMODE, (void*) KD_TEXT); close(gr_vt_fd); gr_vt_fd = -1; }
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); } }
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); } }
int text_to_4box(p_info_rec* info, overlay* ovly, char* txt_0, char* txt_1, char* txt_2, char* txt_3, int max_width, char* font, const int size, const int aspect_ratio_num, const int aspect_ratio_den) { int n, w, h, j, x, y; BYTE* ptr; BYTE* src; BYTE* dst; overlay txt_ovly[4]; char* title[] = {txt_0, txt_1, txt_2, txt_3}; int result; // render the four text strings for (n = 0; n < 4; n++) { result = text_to_overlay(info, &txt_ovly[n], title[n], (max_width / 2) - 3, font, size, aspect_ratio_num, aspect_ratio_den); if (result < 0) return result; } // get dimensions of biggest string w = 0; h = 0; for (n = 0; n < 4; n++) { if (w < txt_ovly[n].w) w = txt_ovly[n].w; if (h < txt_ovly[n].h) h = txt_ovly[n].h; } // expand box a little w += 0; h += 8; // init result ovly ovly->h = (h * 2) + 2; ovly->w = (w * 2) + 2; ovly->ssx = -1; ovly->ssy = -1; ovly->buff = malloc(ovly->w * ovly->h * 2); if (ovly->buff == NULL) return YUV_no_memory; memset(ovly->buff, 0, ovly->w * ovly->h * 2); ovly->Cbuff = NULL; // copy rendered text for (n = 0; n < 4; n++) { x = (w + 2 - txt_ovly[n].w) / 2; y = 7; x += (n % 2) * w; y += (n / 2) * h; src = txt_ovly[n].buff; dst = ovly->buff + (ovly->w * y) + x; for (j = 0; j < txt_ovly[n].h; j++) { memcpy(dst, src, txt_ovly[n].w); src += txt_ovly[n].w; dst += ovly->w; } free_overlay(&txt_ovly[n]); } // draw horizontal grid lines for (y = 0; y < ovly->h; y += h) { ptr = ovly->buff + (ovly->w * y); for (x = 0; x < ovly->w; x++) *ptr++ = 160; ptr = ovly->buff + (ovly->w * (y + 1)); for (x = 0; x < ovly->w; x++) *ptr++ = 160; } // draw vertical grid lines for (x = 0; x < ovly->w; x += w) { ptr = ovly->buff + x; for (y = 0; y < ovly->h; y++) { *ptr = 160; ptr += ovly->w; } ptr = ovly->buff + x + 1; for (y = 0; y < ovly->h; y++) { *ptr = 160; ptr += ovly->w; } } return YUV_OK; }