//setting srceen window(x,y,width,height) __s32 BSP_disp_sprite_block_set_screen_win(__u32 sel, __s32 hid, __disp_rect_t * scn_win) { __s32 id = 0; list_head_t * node = NULL; __disp_rect_t cur_scn; __u32 cpu_sr; id = Sprite_Hid_To_Id(sel, hid); if(gsprite[sel].block_status[id] & SPRITE_BLOCK_USED) { if((scn_win->width != 8) && (scn_win->width != 16) && (scn_win->width != 32) && (scn_win->width != 64) && (scn_win->width != 128) && (scn_win->width != 256) && (scn_win->width != 512)) { DE_WRN("BSP_disp_sprite_block_set_screen_win,scn_win width invalid:%d\n",scn_win->width); return DIS_PARA_FAILED; } if((scn_win->height != 8) && (scn_win->height != 16) && (scn_win->height != 32) && (scn_win->height != 64) && (scn_win->height != 128) && (scn_win->height != 256) && (scn_win->height != 512) && (scn_win->height != 1024)) { DE_WRN("BSP_disp_sprite_block_set_screen_win,scn_win height invalid:%d\n",scn_win->height); return DIS_PARA_FAILED; } node = List_Find_Sprite_Block(sel, id); if(node == NULL) { return DIS_PARA_FAILED; } cur_scn.x = scn_win->x; cur_scn.y = scn_win->y; cur_scn.width = scn_win->width; cur_scn.height = scn_win->height; if(node->data->enable == FALSE) { cur_scn.y = -2000; } DE_BE_Sprite_Block_Set_Pos(sel, id,cur_scn.x,cur_scn.y); DE_BE_Sprite_Block_Set_Size(sel, id,cur_scn.width,cur_scn.height); OSAL_IrqLock(&cpu_sr); node->data->scn_win.x = scn_win->x; node->data->scn_win.y = scn_win->y; node->data->scn_win.width = scn_win->width; node->data->scn_win.height = scn_win->height; OSAL_IrqUnLock(cpu_sr); return DIS_SUCCESS; } else { return DIS_OBJ_NOT_INITED; } }
__s32 NAND_SetFrequencePar(__u32 FrequencePar) { __u32 cpu_sr = 0; OSAL_IrqLock(&cpu_sr); NandStorageInfo.FrequencePar = (__u8)FrequencePar; OSAL_IrqUnLock(cpu_sr); return 0; }
__s32 NAND_SetValidBlkRatio(__u32 ValidBlkRatio) { __u32 cpu_sr = 0; OSAL_IrqLock(&cpu_sr); NandStorageInfo.ValidBlkRatio = (__u16)ValidBlkRatio; OSAL_IrqUnLock(cpu_sr); return 0; }
//the para including fb address,fb width,fb height,source x/y offset,screen window __s32 BSP_disp_sprite_block_request(__u32 sel, __disp_sprite_block_para_t *para) { __s32 id = 0; __disp_sprite_block_para_t cur_para; list_head_t * node = NULL; __u32 cpu_sr; if((para->scn_win.width != 8) && (para->scn_win.width != 16) && (para->scn_win.width != 32) && (para->scn_win.width != 64) && (para->scn_win.width != 128) && (para->scn_win.width != 256) && (para->scn_win.width != 512)) { DE_WRN("BSP_disp_sprite_block_request,scn_win width invalid:%d\n",para->scn_win.width); return DIS_NULL; } if((para->scn_win.height != 8) && (para->scn_win.height != 16) && (para->scn_win.height != 32) && (para->scn_win.height != 64) && (para->scn_win.height != 128) && (para->scn_win.height != 256) && (para->scn_win.height != 512) && (para->scn_win.height != 1024)) { DE_WRN("BSP_disp_sprite_block_request,scn_win height invalid:%d\n",para->scn_win.height); return DIS_NULL; } node = List_Add_Sprite_Block(sel, para); if(node == NULL) { return (__s32)NULL; } id = node->data->id; node->data->address = (__u32)para->fb.addr[0]; node->data->size.width = para->fb.size.width; node->data->src_win.x = para->src_win.x; node->data->src_win.y = para->src_win.y; node->data->scn_win.x = para->scn_win.x; node->data->scn_win.y = para->scn_win.y; node->data->scn_win.width = para->scn_win.width; node->data->scn_win.height = para->scn_win.height; memcpy(&cur_para,para,sizeof(__disp_sprite_block_para_t)); cur_para.scn_win.y = -2000; DE_BE_Sprite_Block_Set_Next_Id(sel, node->prev->data->id, id); sprite_set_sprite_block_para(sel, id, 0, para); OSAL_IrqLock(&cpu_sr); gsprite[sel].block_status[id] |= SPRITE_BLOCK_USED; gsprite[sel].block_num ++; OSAL_IrqUnLock(cpu_sr); return Sprite_Id_To_Hid(sel, id); }
__s32 BSP_disp_sprite_close(__u32 sel) { __u32 cpu_sr; if(gsprite[sel].status & SPRITE_OPENED) { DE_BE_Sprite_Enable(sel, FALSE); OSAL_IrqLock(&cpu_sr); gsprite[sel].enable = FALSE; gsprite[sel].status &=SPRITE_OPENED_MASK; OSAL_IrqUnLock(cpu_sr); } return DIS_SUCCESS; }
__s32 BSP_disp_sprite_open(__u32 sel) { __u32 cpu_sr; if(!gsprite[sel].status & SPRITE_OPENED) { DE_BE_Sprite_Enable(sel, TRUE); OSAL_IrqLock(&cpu_sr); gsprite[sel].enable = TRUE; gsprite[sel].status|= SPRITE_OPENED; OSAL_IrqUnLock(cpu_sr); } return DIS_SUCCESS; }
//setting source x/y offset __s32 BSP_disp_sprite_block_set_src_win(__u32 sel, __s32 hid, __disp_rect_t * src_win) { __s32 id = 0; list_head_t * node = NULL; __u32 cpu_sr; __u32 bpp, addr; id = Sprite_Hid_To_Id(sel, hid); if(gsprite[sel].block_status[id] & SPRITE_BLOCK_USED) { node = List_Find_Sprite_Block(sel, id); bpp = de_format_to_bpp(gsprite[sel].format); addr = DE_BE_Offset_To_Addr(node->data->address, node->data->size.width, src_win->x, src_win->y, bpp); DE_BE_Sprite_Block_Set_fb(sel, id,(__u32)OSAL_VAtoPA((void*)addr),node->data->size.width*(bpp>>3)); OSAL_IrqLock(&cpu_sr); node->data->src_win.x = src_win->x; node->data->src_win.y = src_win->y; OSAL_IrqUnLock(cpu_sr); return DIS_SUCCESS; }
__s32 BSP_disp_sprite_block_release(__u32 sel, __s32 hid) { __s32 id = 0,pre_id = 0,next_id = 0; list_head_t * node = NULL, *next_node=NULL, *pre_node=NULL; __s32 release_id = 0; __u32 cpu_sr; id = Sprite_Hid_To_Id(sel, hid); if(gsprite[sel].block_status[id] & SPRITE_BLOCK_USED) { node = List_Find_Sprite_Block(sel, id); pre_node = node->prev; next_node = node->next; pre_id = node->prev->data->id; next_id = node->next->data->id; release_id = List_Delete_Free_Sprite_Block(sel, node); if(id == pre_id)//release the only block { __disp_sprite_block_para_t para; para.fb.addr[0] = 0; para.fb.size.width = 8; para.fb.format = DISP_FORMAT_ARGB8888; para.src_win.x = 0; para.src_win.y = 0; para.scn_win.x = 0; para.scn_win.y = -2000; para.scn_win.width = 8; para.scn_win.height = 8; sprite_set_sprite_block_para(sel, id,0,¶); } else if(id == 0)//release the first block { __disp_sprite_block_para_t para; para.fb.addr[0] = next_node->data->address; para.fb.size.width = next_node->data->size.width; para.src_win.x = next_node->data->src_win.x; para.src_win.y = next_node->data->src_win.y; para.scn_win.x = next_node->data->scn_win.x; if(next_node->data->enable == FALSE) { para.scn_win.y = -2000; } else { para.scn_win.y = next_node->data->scn_win.y; } para.scn_win.width = next_node->data->scn_win.width; para.scn_win.height = next_node->data->scn_win.height; sprite_set_sprite_block_para(sel, 0,next_node->next->data->id,¶); para.fb.addr[0] = 0; para.fb.size.width= 8; para.src_win.x = 0; para.src_win.y = 0; para.scn_win.x = 0; para.scn_win.y = -2000; para.scn_win.width = 8; para.scn_win.height = 8; sprite_set_sprite_block_para(sel, next_id,0,¶); } else { __disp_sprite_block_para_t para; para.fb.addr[0] = pre_node->data->address; para.fb.size.width= pre_node->data->size.width; para.src_win.x = pre_node->data->src_win.x; para.src_win.y = pre_node->data->src_win.y; para.scn_win.x = pre_node->data->scn_win.x; if(node->data->enable == FALSE) { para.scn_win.y = -2000; } else { para.scn_win.y = pre_node->data->scn_win.y; } para.scn_win.width = pre_node->data->scn_win.width; para.scn_win.height = pre_node->data->scn_win.height; sprite_set_sprite_block_para(sel, pre_id,next_id,¶); para.fb.addr[0] = 0; para.fb.size.width = 8; para.src_win.x = 0; para.src_win.y = 0; para.scn_win.x = 0; para.scn_win.y = -2000; para.scn_win.width = 8; para.scn_win.height = 8; sprite_set_sprite_block_para(sel, id,0,¶); } OSAL_IrqLock(&cpu_sr); gsprite[sel].block_status[release_id] &= SPRITE_BLOCK_USED_MASK; gsprite[sel].block_num --; OSAL_IrqUnLock(cpu_sr); return DIS_SUCCESS; } else { return DIS_OBJ_NOT_INITED; } }
__s32 Scaler_Set_Framebuffer(__u32 sel, __disp_fb_t *pfb)//keep the source window { __scal_buf_addr_t scal_addr; __scal_src_size_t in_size; __scal_out_size_t out_size; __scal_src_type_t in_type; __scal_out_type_t out_type; __scal_scan_mod_t in_scan; __scal_scan_mod_t out_scan; __disp_scaler_t * scaler; __u32 screen_index; __u32 cpu_sr; scaler = &(gdisp.scaler[sel]); screen_index = gdisp.scaler[sel].screen_index; OSAL_IrqLock(&cpu_sr); memcpy(&scaler->in_fb, pfb, sizeof(__disp_fb_t)); OSAL_IrqUnLock(cpu_sr); in_type.fmt= Scaler_sw_para_to_reg(0,scaler->in_fb.format); in_type.mod= Scaler_sw_para_to_reg(1,scaler->in_fb.mode); in_type.ps= Scaler_sw_para_to_reg(2,(__u8)scaler->in_fb.seq); in_type.byte_seq = 0; in_type.sample_method = 0; scal_addr.ch0_addr= (__u32)OSAL_VAtoPA((void*)(scaler->in_fb.addr[0])); scal_addr.ch1_addr= (__u32)OSAL_VAtoPA((void*)(scaler->in_fb.addr[1])); scal_addr.ch2_addr= (__u32)OSAL_VAtoPA((void*)(scaler->in_fb.addr[2])); in_size.src_width = scaler->in_fb.size.width; in_size.src_height = scaler->in_fb.size.height; in_size.x_off = scaler->src_win.x; in_size.y_off = scaler->src_win.y; in_size.scal_width = scaler->src_win.width; in_size.scal_height = scaler->src_win.height; out_type.byte_seq = scaler->out_fb.seq; out_type.fmt = scaler->out_fb.format; out_size.width = scaler->out_size.width; out_size.height = scaler->out_size.height; in_scan.field = FALSE; in_scan.bottom = FALSE; out_scan.field = (gdisp.screen[screen_index].de_flicker_status & DE_FLICKER_USED)?FALSE: gdisp.screen[screen_index].b_out_interlace; if(scaler->in_fb.cs_mode > DISP_VXYCC) { scaler->in_fb.cs_mode = DISP_BT601; } if(scaler->in_fb.b_trd_src) { __scal_3d_inmode_t inmode; __scal_3d_outmode_t outmode = 0; __scal_buf_addr_t scal_addr_right; inmode = Scaler_3d_sw_para_to_reg(0, scaler->in_fb.trd_mode, 0); outmode = Scaler_3d_sw_para_to_reg(1, scaler->out_trd_mode, gdisp.screen[screen_index].b_out_interlace); DE_SCAL_Get_3D_In_Single_Size(inmode, &in_size, &in_size); if(scaler->b_trd_out) { DE_SCAL_Get_3D_Out_Single_Size(outmode, &out_size, &out_size); } scal_addr_right.ch0_addr= (__u32)OSAL_VAtoPA((void*)(scaler->in_fb.trd_right_addr[0])); scal_addr_right.ch1_addr= (__u32)OSAL_VAtoPA((void*)(scaler->in_fb.trd_right_addr[1])); scal_addr_right.ch2_addr= (__u32)OSAL_VAtoPA((void*)(scaler->in_fb.trd_right_addr[2])); DE_SCAL_Set_3D_Ctrl(sel, scaler->b_trd_out, inmode, outmode); DE_SCAL_Config_3D_Src(sel, &scal_addr, &in_size, &in_type, inmode, &scal_addr_right); } else { DE_SCAL_Config_Src(sel,&scal_addr,&in_size,&in_type,FALSE,FALSE); } DE_SCAL_Set_Scaling_Factor(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type); if(scaler->enhance_en == TRUE) { Scaler_Set_Enhance(sel, scaler->bright, scaler->contrast, scaler->saturation, scaler->hue); } else { DE_SCAL_Set_CSC_Coef(sel, scaler->in_fb.cs_mode, DISP_BT601, get_fb_type(scaler->in_fb.format), DISP_FB_TYPE_RGB, scaler->in_fb.br_swap, 0); } DE_SCAL_Set_Scaling_Coef(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, scaler->smooth_mode); return DIS_SUCCESS; }
__s32 Scaler_Set_Framebuffer(__u32 sel, __disp_fb_t *pfb)//keep the source window { __scal_buf_addr_t scal_addr; __scal_src_size_t in_size; __scal_out_size_t out_size; __scal_src_type_t in_type; __scal_out_type_t out_type; __scal_scan_mod_t in_scan; __scal_scan_mod_t out_scan; __disp_scaler_t * scaler; __u32 cpu_sr; scaler = &(gdisp.scaler[sel]); OSAL_IrqLock(&cpu_sr); memcpy(&scaler->in_fb, pfb, sizeof(__disp_fb_t)); OSAL_IrqUnLock(cpu_sr); in_type.fmt= Scaler_sw_para_to_reg(0,scaler->in_fb.format); in_type.mod= Scaler_sw_para_to_reg(1,scaler->in_fb.mode); in_type.ps= Scaler_sw_para_to_reg(2,(__u8)scaler->in_fb.seq); in_type.byte_seq = 0; scal_addr.ch0_addr= (__u32)OSAL_VAtoPA((void*)(scaler->in_fb.addr[0])); scal_addr.ch1_addr= (__u32)OSAL_VAtoPA((void*)(scaler->in_fb.addr[1])); scal_addr.ch2_addr= (__u32)OSAL_VAtoPA((void*)(scaler->in_fb.addr[2])); in_size.src_width = scaler->in_fb.size.width; in_size.x_off = scaler->src_win.x; in_size.y_off = scaler->src_win.y; in_size.scal_width = scaler->src_win.width; in_size.scal_height = scaler->src_win.height; out_type.byte_seq = scaler->out_fb.seq; out_type.fmt = scaler->out_fb.format; out_size.width = scaler->out_size.width; out_size.height = scaler->out_size.height; in_scan.field = FALSE; in_scan.bottom = FALSE; out_scan.field = scaler->out_scan_mode; if(scaler->in_fb.cs_mode > DISP_VXYCC) { scaler->in_fb.cs_mode = DISP_BT601; } DE_SCAL_Config_Src(sel,&scal_addr,&in_size,&in_type,FALSE,FALSE); DE_SCAL_Set_Scaling_Factor(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type); if(scaler->enhance_en == TRUE) { Scaler_Set_Enhance(sel, scaler->bright, scaler->contrast, scaler->saturation, scaler->hue); } else { DE_SCAL_Set_CSC_Coef(sel, scaler->in_fb.cs_mode, DISP_BT601, get_fb_type(scaler->in_fb.format), DISP_FB_TYPE_RGB); } DE_SCAL_Set_Scaling_Coef(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, scaler->smooth_mode); return DIS_SUCCESS; }