__s32 Display_Fb_Request(__u32 fb_id, __disp_fb_create_para_t * fb_para) { struct fb_info *info = NULL; __s32 hdl = 0; __disp_layer_info_t layer_para; __u32 sel; __u32 xres, yres; __inf("Display_Fb_Request,fb_id:%d\n", fb_id); info = g_fbi.fbinfo[fb_id]; xres = fb_para->width; yres = fb_para->height; info->var.xoffset = 0; info->var.yoffset = 0; info->var.xres = xres; info->var.yres = yres; info->var.xres_virtual = xres; info->var.yres_virtual = yres * fb_para->buffer_num; info->fix.line_length = (fb_para->width * info->var.bits_per_pixel) >> 3; info->fix.smem_len = info->fix.line_length * fb_para->height * fb_para->buffer_num; Fb_map_video_memory(info); for (sel = 0; sel < 2; sel++) { if (((sel == 0) && (fb_para->fb_mode != FB_MODE_SCREEN1)) || ((sel == 1) && (fb_para->fb_mode != FB_MODE_SCREEN0))) { __u32 y_offset = 0, src_width = xres, src_height = yres; if (((sel == 0) && (fb_para->fb_mode == FB_MODE_SCREEN0 || fb_para->fb_mode == FB_MODE_DUAL_SAME_SCREEN_TB)) || ((sel == 1) && (fb_para->fb_mode == FB_MODE_SCREEN1)) || ((sel == fb_para->primary_screen_id) && (fb_para->fb_mode == FB_MODE_DUAL_DIFF_SCREEN_SAME_CONTENTS))) { __disp_tcon_timing_t tt; if (BSP_disp_get_timing(sel, &tt) >= 0) { info->var.pixclock = 1000000000 / tt.pixel_clk; info->var.left_margin = tt.hor_back_porch; info->var.right_margin = tt.hor_front_porch; info->var.upper_margin = tt.ver_back_porch; info->var.lower_margin = tt.ver_front_porch; info->var.hsync_len = tt.hor_sync_time; info->var.vsync_len = tt.ver_sync_time; } } if (fb_para->fb_mode == FB_MODE_DUAL_SAME_SCREEN_TB) { src_height = yres / 2; if (sel == 0) y_offset = yres / 2; } memset(&layer_para, 0, sizeof(__disp_layer_info_t)); layer_para.mode = fb_para->mode; layer_para.scn_win.width = src_width; layer_para.scn_win.height = src_height; if (fb_para->fb_mode == FB_MODE_DUAL_DIFF_SCREEN_SAME_CONTENTS) { if (sel != fb_para->primary_screen_id) { layer_para.mode = DISP_LAYER_WORK_MODE_SCALER; layer_para.scn_win.width = fb_para->aux_output_width; layer_para.scn_win.height = fb_para->aux_output_height; } else if (fb_para->mode == DISP_LAYER_WORK_MODE_SCALER) { layer_para.scn_win.width = fb_para->output_width; layer_para.scn_win.height = fb_para->output_height; } } else if (fb_para->mode == DISP_LAYER_WORK_MODE_SCALER) { layer_para.scn_win.width = fb_para->output_width; layer_para.scn_win.height = fb_para->output_height; } hdl = BSP_disp_layer_request(sel, layer_para.mode); layer_para.pipe = 0; layer_para.alpha_en = 1; layer_para.alpha_val = 0xff; layer_para.ck_enable = 0; layer_para.src_win.x = 0; layer_para.src_win.y = y_offset; layer_para.src_win.width = src_width; layer_para.src_win.height = src_height; layer_para.scn_win.x = 0; layer_para.scn_win.y = 0; var_to_disp_fb(&(layer_para.fb), &(info->var), &(info->fix)); layer_para.fb.addr[0] = (__u32) info->fix.smem_start; layer_para.fb.addr[1] = 0; layer_para.fb.addr[2] = 0; layer_para.fb.size.width = fb_para->width; layer_para.fb.size.height = fb_para->height; layer_para.fb.cs_mode = DISP_BT601; layer_para.b_from_screen = 0; BSP_disp_layer_set_para(sel, hdl, &layer_para); BSP_disp_layer_open(sel, hdl); g_fbi.layer_hdl[fb_id][sel] = hdl; } } g_fbi.fb_enable[fb_id] = 1; g_fbi.fb_mode[fb_id] = fb_para->fb_mode; memcpy(&g_fbi.fb_para[fb_id], fb_para, sizeof(__disp_fb_create_para_t)); return DIS_SUCCESS; }
__s32 Display_Fb_Request(__u32 fb_id, __disp_fb_create_para_t *fb_para) { struct fb_info *info = NULL; __s32 hdl = 0; __disp_layer_info_t layer_para; __u32 sel; __u32 xres, yres; unsigned long ulLCM; __u32 num_screens; num_screens = bsp_disp_feat_get_num_screens(); __inf("Display_Fb_Request,fb_id:%d\n", fb_id); if(g_fbi.fb_enable[fb_id]) { __wrn("Display_Fb_Request, fb%d is already requested!\n", fb_id); return DIS_NO_RES; } info = g_fbi.fbinfo[fb_id]; xres = fb_para->width; yres = fb_para->height; if((0 == xres) || (0 == yres)) { __wrn("invalid paras xres(%d, yres(%d) in Display_Fb_Request\n", xres, yres); return DIS_FAIL; } info->var.xoffset = 0; info->var.yoffset = 0; info->var.xres = xres; info->var.yres = yres; info->var.xres_virtual = xres; info->fix.line_length = (fb_para->width * info->var.bits_per_pixel) >> 3; ulLCM = LCM(info->fix.line_length, PAGE_SIZE); info->fix.smem_len = RoundUpToMultiple(info->fix.line_length * fb_para->height, ulLCM) * fb_para->buffer_num; info->var.yres_virtual = info->fix.smem_len / info->fix.line_length; Fb_map_video_memory(info); for(sel = 0; sel < num_screens; sel++) { if(((sel==0) && (fb_para->fb_mode != FB_MODE_SCREEN1)) || ((sel==1) && (fb_para->fb_mode != FB_MODE_SCREEN0))) { __u32 y_offset = 0, src_width = xres, src_height = yres; if(((sel==0) && (fb_para->fb_mode == FB_MODE_SCREEN0 || fb_para->fb_mode == FB_MODE_DUAL_SAME_SCREEN_TB)) || ((sel==1) && (fb_para->fb_mode == FB_MODE_SCREEN1)) || ((sel == fb_para->primary_screen_id) && (fb_para->fb_mode == FB_MODE_DUAL_DIFF_SCREEN_SAME_CONTENTS))) { __disp_tcon_timing_t tt; if(bsp_disp_get_timming(sel, &tt) >= 0) { info->var.pixclock = 1000000000 / tt.pixel_clk; info->var.left_margin = tt.hor_back_porch; info->var.right_margin = tt.hor_front_porch; info->var.upper_margin = tt.ver_back_porch; info->var.lower_margin = tt.ver_front_porch; info->var.hsync_len = tt.hor_sync_time; info->var.vsync_len = tt.ver_sync_time; } info->var.width = bsp_disp_get_screen_physical_width(sel); info->var.height = bsp_disp_get_screen_physical_height(sel); } if(fb_para->fb_mode == FB_MODE_DUAL_SAME_SCREEN_TB) { src_height = yres/ 2; if(sel == 0) { y_offset = yres / 2; } } memset(&layer_para, 0, sizeof(__disp_layer_info_t)); layer_para.mode = fb_para->mode; layer_para.scn_win.width = src_width; layer_para.scn_win.height = src_height; if(fb_para->fb_mode == FB_MODE_DUAL_DIFF_SCREEN_SAME_CONTENTS) { if(sel != fb_para->primary_screen_id) { layer_para.mode = DISP_LAYER_WORK_MODE_SCALER; layer_para.scn_win.width = fb_para->aux_output_width; layer_para.scn_win.height = fb_para->aux_output_height; } else if(fb_para->mode == DISP_LAYER_WORK_MODE_SCALER) { layer_para.scn_win.width = fb_para->output_width; layer_para.scn_win.height = fb_para->output_height; } } else if(fb_para->mode == DISP_LAYER_WORK_MODE_SCALER) { layer_para.scn_win.width = fb_para->output_width; layer_para.scn_win.height = fb_para->output_height; } hdl = bsp_disp_layer_request(sel, layer_para.mode); if(hdl == 0) { __wrn("Display_Fb_Request, ch%d no layer resource\n", sel); Fb_unmap_video_memory(info); return DIS_NO_RES; } layer_para.pipe = 0; layer_para.alpha_en = 1; layer_para.alpha_val = 0xff; layer_para.ck_enable = 0; layer_para.src_win.x = 0; layer_para.src_win.y = y_offset; layer_para.src_win.width = src_width; layer_para.src_win.height = src_height; layer_para.scn_win.x = 0; layer_para.scn_win.y = 0; var_to_disp_fb(&(layer_para.fb), &(info->var), &(info->fix)); layer_para.fb.addr[0] = (__u32)info->fix.smem_start; layer_para.fb.addr[1] = 0; layer_para.fb.addr[2] = 0; layer_para.fb.size.width = fb_para->width; layer_para.fb.size.height = fb_para->height; layer_para.fb.cs_mode = DISP_BT601; layer_para.b_from_screen = 0; bsp_disp_layer_set_para(sel, hdl, &layer_para); bsp_disp_layer_open(sel, hdl); g_fbi.layer_hdl[fb_id][sel] = hdl; } } g_fbi.fb_enable[fb_id] = 1; g_fbi.fb_mode[fb_id] = fb_para->fb_mode; memcpy(&g_fbi.fb_para[fb_id], fb_para, sizeof(__disp_fb_create_para_t)); return DIS_SUCCESS; }
__s32 Display_Fb_Request(__u32 sel, __disp_fb_create_para_t *fb_para) { struct fb_info *fbinfo = NULL; fb_info_t * fbi = &g_fbi; __s32 hdl = 0; __disp_layer_info_t layer_para; int ret; __msg("Display_Fb_Request, sel=%d\n", sel); fbinfo = framebuffer_alloc(0, fbi->dev); fbinfo->fbops = &dispfb_ops; fbinfo->flags = 0; fbinfo->device = fbi->dev; fbinfo->par = fbi; fbinfo->var.xoffset = 0; fbinfo->var.yoffset = 0; fbinfo->var.xres = 1; fbinfo->var.yres = 1; fbinfo->var.xres_virtual = 1; fbinfo->var.yres_virtual = 1; fbinfo->fix.type = FB_TYPE_PACKED_PIXELS; fbinfo->fix.type_aux = 0; fbinfo->fix.visual = FB_VISUAL_TRUECOLOR; fbinfo->fix.xpanstep = 1; fbinfo->fix.ypanstep = 1; fbinfo->fix.ywrapstep = 0; fbinfo->fix.accel = FB_ACCEL_NONE; fbinfo->fix.line_length = 0; fbinfo->fix.smem_len = fb_para->smem_len; ret = Fb_map_video_memory(fbinfo); if (ret) { __wrn("Failed to allocate video RAM: %d\n", ret); return DIS_FAIL; } hdl = BSP_disp_layer_request(sel, fb_para->mode); layer_para.mode = fb_para->mode; layer_para.pipe = 0; layer_para.alpha_en = 0; layer_para.alpha_val = 0xff; layer_para.ck_enable = 0; layer_para.src_win.x = 0; layer_para.src_win.y = 0; layer_para.src_win.width = 1; layer_para.src_win.height = 1; layer_para.scn_win.x = 0; layer_para.scn_win.y = 0; layer_para.scn_win.width = 1; layer_para.scn_win.height = 1; layer_para.fb.addr[0] = (__u32)fbinfo->fix.smem_start; layer_para.fb.addr[1] = (__u32)fbinfo->fix.smem_start+fb_para->ch1_offset; layer_para.fb.addr[2] = (__u32)fbinfo->fix.smem_start+fb_para->ch2_offset; layer_para.fb.size.width = 1; layer_para.fb.size.height = 1; layer_para.fb.format = DISP_FORMAT_ARGB8888; layer_para.fb.seq = DISP_SEQ_ARGB; layer_para.fb.mode = DISP_MOD_INTERLEAVED; layer_para.fb.br_swap = 0; layer_para.fb.cs_mode = DISP_BT601; BSP_disp_layer_set_para(sel, hdl, &layer_para); BSP_disp_layer_open(sel, hdl); register_framebuffer(fbinfo); fbi->fb_screen_id[fbinfo->node] = sel; fbi->layer_hdl[fbinfo->node] = hdl; fbi->fbinfo[fbinfo->node] = fbinfo; fbi->fb_num++; return hdl; }