Ejemplo n.º 1
0
__s32 Scaler_Set_Outitl(__u32 sel,  __bool enable)
{
	__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;

	scaler = &(gdisp.scaler[sel]);

	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,scaler->in_fb.seq);
	in_type.byte_seq = 0;
	in_type.sample_method = 0;

	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_height=  scaler->src_win.height;
	in_size.scal_width=  scaler->src_win.width;

	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 = enable;

	DE_SCAL_Set_Init_Phase(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, FALSE);
	DE_SCAL_Set_Scaling_Factor(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type);
	DE_SCAL_Set_Scaling_Coef(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type,  scaler->smooth_mode);
	DE_SCAL_Set_Out_Size(sel, &out_scan,&out_type, &out_size);

	return DIS_SUCCESS;
}
Ejemplo n.º 2
0
__s32 bsp_disp_capture_screen(__u32 screen_id, __disp_capture_screen_para_t * para)
{
	__scal_buf_addr_t in_addr;
	__scal_buf_addr_t out_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;
	__u32 size = 0;
	__s32 scaler_index = 0;
	__s32 ret = 0;

	if(para==NULL) {
		DE_WRN("input parameter can't be null!\n");
		return DIS_FAIL;
	}

	scaler_index =  Scaler_Request(0xff);
	if(scaler_index < 0) {
		DE_WRN("request scaler fail in bsp_disp_capture_screen\n");
		return DIS_FAIL;
	}

	in_type.fmt= Scaler_sw_para_to_reg(0,DISP_MOD_INTERLEAVED, DISP_FORMAT_ARGB8888, DISP_SEQ_ARGB);
	in_type.mod= Scaler_sw_para_to_reg(1,DISP_MOD_INTERLEAVED, DISP_FORMAT_ARGB8888, DISP_SEQ_ARGB);
	in_type.ps= Scaler_sw_para_to_reg(2,DISP_MOD_INTERLEAVED, DISP_FORMAT_ARGB8888, (__u8)DISP_SEQ_ARGB);
	in_type.byte_seq = 0;
	in_type.sample_method = 0;

	if(get_fb_type(para->output_fb.format) == DISP_FB_TYPE_YUV) {
		if(para->output_fb.mode == DISP_MOD_NON_MB_PLANAR) {
			out_type.fmt = Scaler_sw_para_to_reg(3, para->output_fb.mode, para->output_fb.format, para->output_fb.seq);
		} else {
			DE_WRN("output mode:%d invalid in Display_Scaler_Start\n",para->output_fb.mode);
			return DIS_FAIL;
		}
	} else {
		if(para->output_fb.mode == DISP_MOD_NON_MB_PLANAR && (para->output_fb.format == DISP_FORMAT_RGB888
		|| para->output_fb.format == DISP_FORMAT_ARGB8888)) {
			out_type.fmt = DE_SCAL_OUTPRGB888;
		} else if(para->output_fb.mode == DISP_MOD_INTERLEAVED && para->output_fb.format == DISP_FORMAT_ARGB8888) {
			out_type.fmt = DE_SCAL_OUTI0RGB888;
		} else {
			DE_WRN("output para invalid in Display_Scaler_Start,mode:%d,format:%d\n",para->output_fb.mode, para->output_fb.format);
			return DIS_FAIL;
		}
		para->output_fb.br_swap= FALSE;
	}
	out_type.byte_seq = Scaler_sw_para_to_reg(2,para->output_fb.mode, para->output_fb.format, para->output_fb.seq);
	out_type.alpha_en = 1;
	out_type.alpha_coef_type = 0;

	out_size.width     = para->output_fb.size.width;
	out_size.height = para->output_fb.size.height;

	if(bsp_disp_get_output_type(screen_id) != DISP_OUTPUT_TYPE_NONE) {
		in_size.src_width = bsp_disp_get_screen_width(screen_id);
		in_size.src_height = bsp_disp_get_screen_height(screen_id);
		in_size.x_off = 0;
		in_size.y_off = 0;
		in_size.scal_width= bsp_disp_get_screen_width(screen_id);
		in_size.scal_height= bsp_disp_get_screen_height(screen_id);
	} else {
		in_size.src_width = para->screen_size.width;
		in_size.src_height= para->screen_size.height;
		in_size.x_off = 0;
		in_size.y_off = 0;
		in_size.scal_width= para->screen_size.width;
		in_size.scal_height= para->screen_size.height;
	}

	in_scan.field = FALSE;
	in_scan.bottom = FALSE;

	out_scan.field = FALSE; //when use scaler as writeback, won't be outinterlaced for any display device
	out_scan.bottom = FALSE;

	in_addr.ch0_addr = 0;
	in_addr.ch1_addr = 0;
	in_addr.ch2_addr = 0;

	out_addr.ch0_addr = (__u32)OSAL_VAtoPA((void*)(para->output_fb.addr[0]));
	out_addr.ch1_addr = (__u32)OSAL_VAtoPA((void*)(para->output_fb.addr[1]));
	out_addr.ch2_addr = (__u32)OSAL_VAtoPA((void*)(para->output_fb.addr[2]));

	size = (para->output_fb.size.width * para->output_fb.size.height * de_format_to_bpp(para->output_fb.format) + 7)/8;
	OSAL_CacheRangeFlush((void *)para->output_fb.addr[0],size ,CACHE_FLUSH_D_CACHE_REGION);

	if(bsp_disp_get_output_type(screen_id) == DISP_OUTPUT_TYPE_NONE) {
		DE_SCAL_Input_Select(scaler_index, 6 + screen_id);
		DE_BE_set_display_size(screen_id, para->screen_size.width, para->screen_size.height);
		DE_BE_Output_Select(screen_id, 6 + scaler_index);
		image_clk_on(screen_id, 1);
		Image_open(screen_id);
		DE_BE_Cfg_Ready(screen_id);
	} else {
		DE_SCAL_Input_Select(scaler_index, 4 + screen_id);
		DE_BE_Output_Select(screen_id, 2 + (scaler_index * 2) + screen_id);
	}
	DE_SCAL_Config_Src(scaler_index,&in_addr,&in_size,&in_type,FALSE,FALSE);
	DE_SCAL_Set_Scaling_Factor(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type);
	DE_SCAL_Set_Init_Phase(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, FALSE);
	DE_SCAL_Set_CSC_Coef(scaler_index, DISP_BT601, para->output_fb.cs_mode, DISP_FB_TYPE_RGB, get_fb_type(para->output_fb.format), 0, 0);
	DE_SCAL_Set_Scaling_Coef(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, DISP_VIDEO_NATUAL);
	DE_SCAL_Set_Out_Format(scaler_index, &out_type);
	DE_SCAL_Set_Out_Size(scaler_index, &out_scan,&out_type, &out_size);
	DE_SCAL_Set_Writeback_Addr(scaler_index,&out_addr);
	DE_SCAL_Output_Select(scaler_index, 3);
	DE_SCAL_ClearINT(scaler_index,DE_WB_END_IE);
	DE_SCAL_EnableINT(scaler_index,DE_WB_END_IE);
	DE_SCAL_Set_Reg_Rdy(scaler_index);
	DE_SCAL_Writeback_Enable(scaler_index);
	DE_SCAL_Start(scaler_index);

	DE_INF("capture begin\n");
	#ifndef __LINUX_OSAL__
	while(!(DE_SCAL_QueryINT(scaler_index) & DE_WB_END_IE)) {

	}
	#else
	{
		long timeout = (100 * HZ)/1000;//100ms

		init_waitqueue_head(&(gdisp.scaler[scaler_index].scaler_queue));
		gdisp.scaler[scaler_index].b_scaler_finished = 1;
		DE_SCAL_Writeback_Enable(scaler_index);

		timeout = wait_event_interruptible_timeout(gdisp.scaler[scaler_index].scaler_queue, gdisp.scaler[scaler_index].b_scaler_finished == 2, timeout);
		gdisp.scaler[scaler_index].b_scaler_finished = 0;
		if(timeout == 0) {
			__wrn("wait scaler %d finished timeout\n", scaler_index);
			return -1;
		}
	}
	#endif
	DE_SCAL_Reset(scaler_index);
	Scaler_Release(scaler_index, FALSE);
	if(bsp_disp_get_output_type(screen_id) == DISP_OUTPUT_TYPE_NONE) {
		Image_close(screen_id);
		image_clk_off(screen_id, 1);
	}
	DE_BE_Output_Select(screen_id, screen_id);
	DE_SCAL_ClearINT(scaler_index,DE_WB_END_IE);
	DE_SCAL_DisableINT(scaler_index,DE_WB_END_IE);

	return ret;
}
Ejemplo n.º 3
0
static __inline __s32 Hal_Set_Frame(__u32 sel, __u32 tcon_index, __u32 id)
{	
    __u32 cur_line = 0, start_delay = 0;

    cur_line = LCDC_get_cur_line(sel, tcon_index);
    start_delay = LCDC_get_start_delay(sel, tcon_index);
	if(cur_line > start_delay-5)
	{
	    //DE_INF("cur_line(%d) >= start_delay(%d)-3 in Hal_Set_Frame\n", cur_line, start_delay);
		return DIS_FAIL;
	}

    if(g_video[sel][id].display_cnt == 0)
    {
	    g_video[sel][id].pre_frame_addr0 = g_video[sel][id].video_cur.addr[0];
        memcpy(&g_video[sel][id].video_cur, &g_video[sel][id].video_new, sizeof(__disp_video_fb_t));
    }

    if(gdisp.screen[sel].layer_manage[id].para.mode == DISP_LAYER_WORK_MODE_SCALER)
    {
        __u32 scaler_index;
    	__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 pre_frame_addr = 0;
        __u32 maf_flag_addr = 0;
        __u32 maf_linestride = 0;

        scaler_index = gdisp.screen[sel].layer_manage[id].scaler_index;
        
        scaler = &(gdisp.scaler[scaler_index]);

    	if(g_video[sel][id].video_cur.interlace == TRUE)
    	{
    		g_video[sel][id].dit_enable = TRUE;

            g_video[sel][id].fetch_field = FALSE;
        	if(g_video[sel][id].display_cnt == 0)
        	{
        	    g_video[sel][id].fetch_bot = (g_video[sel][id].video_cur.top_field_first)?0:1;
        	}
        	else
        	{
        		g_video[sel][id].fetch_bot = (g_video[sel][id].video_cur.top_field_first)?1:0;
        	}

    		if(g_video[sel][id].dit_enable == TRUE)
    		{
    			if(g_video[sel][id].video_cur.maf_valid == TRUE)
    			{
    				g_video[sel][id].dit_mode = DIT_MODE_MAF;
                	maf_flag_addr = (__u32)OSAL_VAtoPA((void*)g_video[sel][id].video_cur.flag_addr);
            		maf_linestride =  g_video[sel][id].video_cur.flag_stride;
    			}
    			else
    			{
    				g_video[sel][id].dit_mode = DIT_MODE_MAF_BOB;
    			}

    			if(g_video[sel][id].video_cur.pre_frame_valid == TRUE)
    			{
    				g_video[sel][id].tempdiff_en = TRUE;
    				pre_frame_addr = (__u32)OSAL_VAtoPA((void*)g_video[sel][id].pre_frame_addr0);
    			}
    			else
    			{
    				g_video[sel][id].tempdiff_en = FALSE;
    			}
    			g_video[sel][id].diagintp_en = TRUE;

                g_video[sel][id].fetch_field = FALSE;//todo
                g_video[sel][id].fetch_bot = 0;//todo
                g_video[sel][id].dit_mode = DIT_MODE_MAF_BOB;//todo
                g_video[sel][id].tempdiff_en = FALSE;//todo
                g_video[sel][id].diagintp_en = FALSE;//todo
    		}
    		else
    		{
        	    g_video[sel][id].dit_mode = DIT_MODE_WEAVE;
        	    g_video[sel][id].tempdiff_en = FALSE;
        	    g_video[sel][id].diagintp_en = FALSE;
    		}
    	}
    	else
    	{
    		g_video[sel][id].dit_enable = FALSE;
    	    g_video[sel][id].fetch_field = FALSE;
    	    g_video[sel][id].fetch_bot = FALSE;
    	    g_video[sel][id].dit_mode = DIT_MODE_WEAVE;
    	    g_video[sel][id].tempdiff_en = FALSE;
    	    g_video[sel][id].diagintp_en = FALSE;
    	}
        
    	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,scaler->in_fb.seq);
    	in_type.byte_seq = 0;
    	in_type.sample_method = 0;

    	scal_addr.ch0_addr= (__u32)OSAL_VAtoPA((void*)(g_video[sel][id].video_cur.addr[0]));
    	scal_addr.ch1_addr= (__u32)OSAL_VAtoPA((void*)(g_video[sel][id].video_cur.addr[1]));
    	scal_addr.ch2_addr= (__u32)OSAL_VAtoPA((void*)(g_video[sel][id].video_cur.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_height=  scaler->src_win.height;
    	in_size.scal_width=  scaler->src_win.width;

    	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 = g_video[sel][id].fetch_field;
    	in_scan.bottom = g_video[sel][id].fetch_bot;

    	out_scan.field = (gdisp.screen[sel].de_flicker_status == DE_FLICKER_USED)?0: gdisp.screen[sel].b_out_interlace;
        
    	if(scaler->out_fb.cs_mode > DISP_VXYCC)
    	{
    		scaler->out_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[sel].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*)(g_video[sel][id].video_cur.addr_right[0]));
        	scal_addr_right.ch1_addr= (__u32)OSAL_VAtoPA((void*)(g_video[sel][id].video_cur.addr_right[1]));
        	scal_addr_right.ch2_addr= (__u32)OSAL_VAtoPA((void*)(g_video[sel][id].video_cur.addr_right[2]));

            DE_SCAL_Set_3D_Ctrl(scaler_index, scaler->b_trd_out, inmode, outmode);
            DE_SCAL_Config_3D_Src(scaler_index, &scal_addr, &in_size, &in_type, inmode, &scal_addr_right);
        }
        else
        {
    	    DE_SCAL_Config_Src(scaler_index,&scal_addr,&in_size,&in_type,FALSE,FALSE);
    	}

        if(g_video[sel][id].dit_enable == TRUE && gdisp.screen[sel].de_flicker_status == DE_FLICKER_USED)
        {   
            Disp_de_flicker_enable(sel, FALSE);
        }
    	DE_SCAL_Set_Init_Phase(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, g_video[sel][id].dit_enable);
    	DE_SCAL_Set_Scaling_Factor(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type);
    	DE_SCAL_Set_Scaling_Coef(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type,  scaler->smooth_mode);
    	DE_SCAL_Set_Out_Size(scaler_index, &out_scan,&out_type, &out_size);
    	DE_SCAL_Set_Di_Ctrl(scaler_index,g_video[sel][id].dit_enable,g_video[sel][id].dit_mode,g_video[sel][id].diagintp_en,g_video[sel][id].tempdiff_en);
    	DE_SCAL_Set_Di_PreFrame_Addr(scaler_index, pre_frame_addr);
    	DE_SCAL_Set_Di_MafFlag_Src(scaler_index, maf_flag_addr, maf_linestride);

        DE_SCAL_Set_Reg_Rdy(scaler_index);
    }
    else
    {
        __layer_man_t * layer_man;
        __disp_fb_t fb;
        layer_src_t layer_fb;

        layer_man = &gdisp.screen[sel].layer_manage[id];

        BSP_disp_layer_get_framebuffer(sel, id, &fb);
        fb.addr[0] = (__u32)OSAL_VAtoPA((void*)(g_video[sel][id].video_cur.addr[0]));
        fb.addr[1] = (__u32)OSAL_VAtoPA((void*)(g_video[sel][id].video_cur.addr[1]));
        fb.addr[2] = (__u32)OSAL_VAtoPA((void*)(g_video[sel][id].video_cur.addr[2]));

    	if(get_fb_type(fb.format) == DISP_FB_TYPE_YUV)
    	{
        	Yuv_Channel_adjusting(sel , fb.mode, fb.format, &layer_man->para.src_win.x, &layer_man->para.scn_win.width);
    		Yuv_Channel_Set_framebuffer(sel, &fb, layer_man->para.src_win.x, layer_man->para.src_win.y);
    	}
    	else
    	{        	    
            layer_fb.fb_addr    = (__u32)OSAL_VAtoPA((void*)fb.addr[0]);
            layer_fb.pixseq     = img_sw_para_to_reg(3,0,fb.seq);
            layer_fb.br_swap    = fb.br_swap;
            layer_fb.fb_width   = fb.size.width;
            layer_fb.offset_x   = layer_man->para.src_win.x;
            layer_fb.offset_y   = layer_man->para.src_win.y;
            layer_fb.format = fb.format;
            DE_BE_Layer_Set_Framebuffer(sel, id,&layer_fb);
        }
    }

    g_video[sel][id].display_cnt++;
    gdisp.screen[sel].layer_manage[id].para.fb.addr[0] = g_video[sel][id].video_cur.addr[0];
    gdisp.screen[sel].layer_manage[id].para.fb.addr[1] = g_video[sel][id].video_cur.addr[1];
    gdisp.screen[sel].layer_manage[id].para.fb.addr[2] = g_video[sel][id].video_cur.addr[2];
    gdisp.screen[sel].layer_manage[id].para.fb.trd_right_addr[0] = g_video[sel][id].video_cur.addr_right[0];
    gdisp.screen[sel].layer_manage[id].para.fb.trd_right_addr[1] = g_video[sel][id].video_cur.addr_right[1];
    gdisp.screen[sel].layer_manage[id].para.fb.trd_right_addr[2] = g_video[sel][id].video_cur.addr_right[2];
	return DIS_SUCCESS;
}
Ejemplo n.º 4
0
__s32 BSP_disp_scaler_start(__u32 handle,__disp_scaler_para_t *para)
{
	__scal_buf_addr_t in_addr;
	__scal_buf_addr_t out_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;
	__u32 size = 0;
	__u32 sel = 0;
	__s32 ret = 0;
	__u32 i = 0;
	__u32 ch_num = 0;

	if(para==NULL)
	{
		DE_WRN("input parameter can't be null!\n");
		return DIS_FAIL;
	}

	sel = SCALER_HANDTOID(handle);
	
	in_type.mod= Scaler_sw_para_to_reg(1,para->input_fb.mode);
	in_type.fmt= Scaler_sw_para_to_reg(0,para->input_fb.format);
	in_type.ps= Scaler_sw_para_to_reg(2,(__u8)para->input_fb.seq);
	in_type.byte_seq = 0;
	in_type.sample_method = 0;

	if(get_fb_type(para->output_fb.format) == DISP_FB_TYPE_YUV)
	{      
		if(para->output_fb.mode == DISP_MOD_NON_MB_PLANAR)
		{
			out_type.fmt = Scaler_sw_para_to_reg(3, para->output_fb.format);
		}
		else
		{	
			DE_WRN("output mode:%d invalid in Display_Scaler_Start\n",para->output_fb.mode);
			return DIS_FAIL;
		}
	}
	else
	{
		if(para->output_fb.mode == DISP_MOD_NON_MB_PLANAR && (para->output_fb.format == DISP_FORMAT_RGB888 || para->output_fb.format == DISP_FORMAT_ARGB8888))
		{
			out_type.fmt = DE_SCAL_OUTPRGB888;
		}
		else if(para->output_fb.mode == DISP_MOD_INTERLEAVED && para->output_fb.format == DISP_FORMAT_ARGB8888)
		{
			out_type.fmt = DE_SCAL_OUTI0RGB888;
		}
		else
		{
			DE_WRN("output para invalid in Display_Scaler_Start,mode:%d,format:%d\n",para->output_fb.mode, para->output_fb.format);
			return DIS_FAIL;
		}
	}  
    out_type.byte_seq = Scaler_sw_para_to_reg(2,para->output_fb.seq);

    out_size.width     = para->output_fb.size.width;
    out_size.height = para->output_fb.size.height;

    in_addr.ch0_addr = (__u32)OSAL_VAtoPA((void*)(para->input_fb.addr[0]));
    in_addr.ch1_addr = (__u32)OSAL_VAtoPA((void*)(para->input_fb.addr[1]));
    in_addr.ch2_addr = (__u32)OSAL_VAtoPA((void*)(para->input_fb.addr[2]));

    in_size.src_width = para->input_fb.size.width;
    in_size.src_height = para->input_fb.size.height;
    in_size.x_off = para->source_regn.x;
    in_size.y_off = para->source_regn.y;
    in_size.scal_width= para->source_regn.width;
    in_size.scal_height= para->source_regn.height;

    in_scan.field = FALSE;
    in_scan.bottom = FALSE;

    out_scan.field = FALSE;	//when use scaler as writeback, won't be outinterlaced for any display device
    out_scan.bottom = FALSE;

    out_addr.ch0_addr = (__u32)OSAL_VAtoPA((void*)(para->output_fb.addr[0]));
    out_addr.ch1_addr = (__u32)OSAL_VAtoPA((void*)(para->output_fb.addr[1]));
    out_addr.ch2_addr = (__u32)OSAL_VAtoPA((void*)(para->output_fb.addr[2]));

    size = (para->input_fb.size.width * para->input_fb.size.height * de_format_to_bpp(para->input_fb.format) + 7)/8;
    OSAL_CacheRangeFlush((void *)para->input_fb.addr[0],size ,CACHE_CLEAN_FLUSH_D_CACHE_REGION);

    size = (para->output_fb.size.width * para->output_fb.size.height * de_format_to_bpp(para->output_fb.format) + 7)/8;
    OSAL_CacheRangeFlush((void *)para->output_fb.addr[0],size ,CACHE_FLUSH_D_CACHE_REGION);
    if(para->input_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, para->input_fb.trd_mode, FALSE);
        outmode = Scaler_3d_sw_para_to_reg(1, para->output_fb.trd_mode, FALSE);
        
        DE_SCAL_Get_3D_In_Single_Size(inmode, &in_size, &in_size);
        if(para->output_fb.b_trd_src)
        {
            DE_SCAL_Get_3D_Out_Single_Size(outmode, &out_size, &out_size);
        }
        
    	scal_addr_right.ch0_addr= (__u32)OSAL_VAtoPA((void*)(para->input_fb.trd_right_addr[0]));
    	scal_addr_right.ch1_addr= (__u32)OSAL_VAtoPA((void*)(para->input_fb.trd_right_addr[1]));
    	scal_addr_right.ch2_addr= (__u32)OSAL_VAtoPA((void*)(para->input_fb.trd_right_addr[2]));

        DE_SCAL_Set_3D_Ctrl(sel, para->output_fb.b_trd_src, inmode, outmode);
        DE_SCAL_Config_3D_Src(sel, &in_addr, &in_size, &in_type, inmode, &scal_addr_right);
    }
    else
    {
        DE_SCAL_Config_Src(sel,&in_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);
    DE_SCAL_Set_Init_Phase(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, FALSE);
    DE_SCAL_Set_CSC_Coef(sel, para->input_fb.cs_mode, para->output_fb.cs_mode, get_fb_type(para->input_fb.format), get_fb_type(para->output_fb.format),  para->input_fb.br_swap, para->output_fb.br_swap);
    DE_SCAL_Set_Scaling_Coef(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, DISP_VIDEO_NATUAL);
    DE_SCAL_Set_Out_Format(sel, &out_type);
    DE_SCAL_Set_Out_Size(sel, &out_scan,&out_type, &out_size);

    if(para->output_fb.mode == DISP_MOD_INTERLEAVED)
    {
        ch_num = 1;
    }
    else if(para->output_fb.mode == DISP_MOD_MB_UV_COMBINED || para->output_fb.mode == DISP_MOD_NON_MB_UV_COMBINED)
    {
        ch_num = 2;
    }
    else if(para->output_fb.mode == DISP_MOD_MB_PLANAR|| para->output_fb.mode == DISP_MOD_NON_MB_PLANAR)
    {
        ch_num = 3;
    }
    
	for(i=0; i<ch_num; i++)
	{
	    __scal_buf_addr_t addr;
	    ret = 0;
	    
	    addr.ch0_addr = out_addr.ch0_addr;
	    if(i == 1)
	    {
	        addr.ch0_addr = out_addr.ch1_addr;
	    }
	    else if(i == 2)
	    {
	        addr.ch0_addr = out_addr.ch2_addr;
	    }
        DE_SCAL_Enable(sel);

    	DE_SCAL_Set_Writeback_Addr(sel,&addr);
    	DE_SCAL_Set_Writeback_Chnl(sel, i);
        DE_SCAL_Output_Select(sel, 3);
    	DE_SCAL_EnableINT(sel,DE_WB_END_IE);
    	DE_SCAL_Start(sel);   
    	DE_SCAL_Set_Reg_Rdy(sel);

#ifndef __LINUX_OSAL__
        DE_SCAL_Writeback_Enable(sel);
        while(!(DE_SCAL_QueryINT(sel) & DE_WB_END_IE) )
        {
        }
#else
        {
            long timeout = (100 * HZ)/1000;//100ms

            init_waitqueue_head(&(gdisp.scaler[sel].scaler_queue));
            gdisp.scaler[sel].b_scaler_finished = 1;
            DE_SCAL_Writeback_Enable(sel);
            
            timeout = wait_event_interruptible_timeout(gdisp.scaler[sel].scaler_queue, gdisp.scaler[sel].b_scaler_finished == 2, timeout);
            gdisp.scaler[sel].b_scaler_finished = 0;
            if(timeout == 0)
            {
                __wrn("wait scaler %d finished timeout\n", sel);
                DE_SCAL_Writeback_Disable(sel);
                DE_SCAL_Reset(sel);
                DE_SCAL_Disable(sel);
                
                return -1;
            }
        }
#endif
        DE_SCAL_Writeback_Disable(sel);
        DE_SCAL_Reset(sel);
        DE_SCAL_Disable(sel);
	}

    return ret;
}
Ejemplo n.º 5
0
__s32 Scaler_Set_Para(__u32 sel, __disp_scaler_t *scl)
{
    __disp_scaler_t * scaler;
	__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;
    __u32 screen_index;

    
    scaler = &(gdisp.scaler[sel]);
    screen_index = gdisp.scaler[sel].screen_index;

	memcpy(&(scaler->in_fb), &(scl->in_fb), sizeof(__disp_fb_t)); 
	memcpy(&(scaler->src_win), &(scl->src_win), sizeof(__disp_rect_t)); 
	memcpy(&(scaler->out_size), &(scl->out_size), sizeof(__disp_rectsz_t)); 

	in_type.mod = Scaler_sw_para_to_reg(1,scaler->in_fb.mode);
	in_type.fmt = Scaler_sw_para_to_reg(0,scaler->in_fb.format);
	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_height= scaler->src_win.height;
	in_size.scal_width= scaler->src_win.width;

	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);
	DE_SCAL_Set_Init_Phase(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, FALSE);
	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);
	DE_SCAL_Set_Out_Format(sel, &out_type);
	DE_SCAL_Set_Out_Size(sel, &out_scan,&out_type, &out_size);
    
	return DIS_NULL;
}
Ejemplo n.º 6
0
__s32 Scaler_Set_Para(__u32 scaler_index, __disp_scaler_t *scl)
{
	__disp_scaler_t * scaler;
	__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;
	__u32 screen_index;


	scaler = &(gdisp.scaler[scaler_index]);
	screen_index = gdisp.scaler[scaler_index].screen_index;

	memcpy(&(scaler->in_fb), &(scl->in_fb), sizeof(__disp_fb_t));
	memcpy(&(scaler->src_win), &(scl->src_win), sizeof(__disp_rect_t));
	memcpy(&(scaler->out_size), &(scl->out_size), sizeof(__disp_rectsz_t));

	in_type.fmt= Scaler_sw_para_to_reg(0,scaler->in_fb.mode, scaler->in_fb.format, scaler->in_fb.seq);
	in_type.mod= Scaler_sw_para_to_reg(1,scaler->in_fb.mode, scaler->in_fb.format, scaler->in_fb.seq);
	in_type.ps= Scaler_sw_para_to_reg(2,scaler->in_fb.mode, scaler->in_fb.format, (__u8)scaler->in_fb.seq);
	if(((__s32)in_type.fmt == DIS_FAIL) || ((__s32)in_type.mod== DIS_FAIL)
	    || ((__s32)in_type.ps == DIS_FAIL))	{
		DE_WRN("not supported scaler input pixel format: mode=%d,fmt=%d,ps=%d\n", scaler->in_fb.mode, scaler->in_fb.format, 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_height= scaler->src_win.height;
	in_size.scal_width= scaler->src_win.width;

	//	out_type.byte_seq = Scaler_sw_para_to_reg(2,scaler->out_fb.seq);
	//	out_type.fmt = Scaler_sw_para_to_reg(3, scaler->out_fb.format);

	if(get_fb_type(scaler->out_fb.format) == DISP_FB_TYPE_YUV) {
		if(scaler->out_fb.mode == DISP_MOD_NON_MB_PLANAR)	{
			out_type.fmt = Scaler_sw_para_to_reg(3, scaler->out_fb.mode, scaler->out_fb.format, scaler->out_fb.seq);
		}	else {
			DE_WRN("output mode:%d invalid in Scaler_Set_Para\n",scaler->out_fb.mode);
			return DIS_FAIL;
		}
	} else {
		if(scaler->out_fb.mode == DISP_MOD_NON_MB_PLANAR
		    && (scaler->out_fb.format == DISP_FORMAT_RGB888 || scaler->out_fb.format == DISP_FORMAT_ARGB8888)) {
			out_type.fmt = DE_SCAL_OUTPRGB888;
		}	else if(scaler->out_fb.mode == DISP_MOD_INTERLEAVED
		    && scaler->out_fb.format == DISP_FORMAT_ARGB8888 && scaler->out_fb.seq == DISP_SEQ_ARGB) {
			out_type.fmt = DE_SCAL_OUTI1RGB888;
		}else if(scaler->out_fb.mode == DISP_MOD_INTERLEAVED && scaler->out_fb.format == DISP_FORMAT_ARGB8888
		    && scaler->out_fb.seq == DISP_SEQ_BGRA) {
			out_type.fmt = DE_SCAL_OUTI0RGB888;
		}	else {
			DE_WRN("output para invalid in Scaler_Set_Para,mode:%d,format:%d\n",scaler->out_fb.mode, scaler->out_fb.format);
			return DIS_FAIL;
		}
	}
	out_type.byte_seq = Scaler_sw_para_to_reg(2,scaler->out_fb.mode, scaler->out_fb.format, scaler->out_fb.seq);
	out_type.alpha_en = 1;
	out_type.alpha_coef_type = 0;

	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;

		if(bsp_disp_feat_get_layer_feats(scaler->screen_index, DISP_LAYER_WORK_MODE_SCALER, scaler_index) & DISP_LAYER_FEAT_3D) {
			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);

			if(((__s32)inmode == DIS_FAIL) || ((__s32)outmode == DIS_FAIL))	{
				DE_WRN("input 3d para invalid in Scaler_Set_Para,trd_mode:%d,out_trd_mode:%d\n", scaler->in_fb.trd_mode, scaler->out_trd_mode);
			}

			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(scaler_index, scaler->b_trd_out, inmode, outmode);
			DE_SCAL_Config_3D_Src(scaler_index, &scal_addr, &in_size, &in_type, inmode, &scal_addr_right);
		}	else {
			DE_WRN("This platform not support 3d output!\n");
			DE_SCAL_Config_Src(scaler_index,&scal_addr,&in_size,&in_type,FALSE,FALSE);
		}
	}	else {
		DE_SCAL_Config_Src(scaler_index,&scal_addr,&in_size,&in_type,FALSE,FALSE);
	}
	DE_SCAL_Set_Scaling_Factor(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type);
	DE_SCAL_Set_Init_Phase(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, FALSE);
	if(scaler->enhance_en == TRUE) {
		Scaler_Set_Enhance(scaler_index, scaler->bright, scaler->contrast, scaler->saturation, scaler->hue);
	}	else {
		DE_SCAL_Set_CSC_Coef(scaler_index, scaler->in_fb.cs_mode, DISP_BT601, get_fb_type(scaler->in_fb.format), get_fb_type(scaler->out_fb.format), scaler->in_fb.br_swap, 0);
	}
	DE_SCAL_Set_Scaling_Coef(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, scaler->smooth_mode);
	DE_SCAL_Set_Out_Format(scaler_index, &out_type);
	DE_SCAL_Set_Out_Size(scaler_index, &out_scan,&out_type, &out_size);

	return DIS_NULL;
}
Ejemplo n.º 7
0
static __inline __s32 Hal_Set_Frame(__u32 screen_id, __u32 tcon_index, __u32 id)
{
	__u32 cur_line = 0, start_delay = 0;
#ifdef __LINUX_OSAL__
	unsigned long flags;
#endif

	cur_line = tcon_get_cur_line(screen_id, tcon_index);
	start_delay = tcon_get_start_delay(screen_id, tcon_index);
	if(cur_line > start_delay-5) {
		//DE_INF("cur_line(%d) >= start_delay(%d)-3 in Hal_Set_Frame\n", cur_line, start_delay);
		return DIS_FAIL;
	}
#ifdef __LINUX_OSAL__
	spin_lock_irqsave(&g_video[screen_id][id].flag_lock, flags);
#endif
	if(g_video[screen_id][id].display_cnt == 0) {
		g_video[screen_id][id].pre_frame_addr_luma = g_video[screen_id][id].video_cur.addr[0];
		g_video[screen_id][id].pre_frame_addr_chroma= g_video[screen_id][id].video_cur.addr[1];
		memcpy(&g_video[screen_id][id].video_cur, &g_video[screen_id][id].video_new, sizeof(__disp_video_fb_t));
		g_video[screen_id][id].cur_maf_flag_addr ^=  g_video[screen_id][id].pre_maf_flag_addr;
		g_video[screen_id][id].pre_maf_flag_addr ^=  g_video[screen_id][id].cur_maf_flag_addr;
		g_video[screen_id][id].cur_maf_flag_addr ^=  g_video[screen_id][id].pre_maf_flag_addr;
		disp_video_checkin(screen_id, id);
	}
	g_video[screen_id][id].display_cnt++;
#ifdef __LINUX_OSAL__
	spin_unlock_irqrestore(&g_video[screen_id][id].flag_lock, flags);
#endif

	/* scaler layer */
	if(gdisp.screen[screen_id].layer_manage[id].para.mode == DISP_LAYER_WORK_MODE_SCALER) {
		__u32 scaler_index;
		__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 pre_frame_addr_luma = 0, pre_frame_addr_chroma = 0;
		__u32 maf_linestride = 0;
		__u32 size;

		scaler_index = gdisp.screen[screen_id].layer_manage[id].scaler_index;

		scaler = &(gdisp.scaler[scaler_index]);

		if(g_video[screen_id][id].video_cur.interlace == TRUE) {
			/* todo , full size of 3d mode < 1920 */
			if((!(gdisp.screen[screen_id].de_flicker_status & DE_FLICKER_USED)) &&
			    (scaler->in_fb.format == DISP_FORMAT_YUV420 && scaler->in_fb.mode == DISP_MOD_MB_UV_COMBINED)
			    && (dit_mode_default[scaler_index] != 0xff) && (scaler->in_fb.size.width < 1920)) {
				g_video[screen_id][id].dit_enable = TRUE;
				if(!(bsp_disp_feat_get_layer_feats(scaler->screen_index, DISP_LAYER_WORK_MODE_SCALER, scaler_index)
				    & DISP_LAYER_FEAT_DE_INTERLACE)) {
					g_video[screen_id][id].dit_enable = FALSE;
				}
			} else {
				g_video[screen_id][id].dit_enable = FALSE;
			}

			g_video[screen_id][id].fetch_field = FALSE;
			if(g_video[screen_id][id].display_cnt == 0) {
				g_video[screen_id][id].fetch_bot = (g_video[screen_id][id].video_cur.top_field_first)?0:1;
			}	else {
				g_video[screen_id][id].fetch_bot = (g_video[screen_id][id].video_cur.top_field_first)?1:0;
			}

			if(g_video[screen_id][id].dit_enable == TRUE) {
				g_video[screen_id][id].dit_mode = dit_mode_default[scaler_index];
				maf_linestride = (((scaler->src_win.width + 31) & 	0xffffffe0)*2/8 + 31) & 0xffffffe0;
				// //g_video[screen_id][id].video_cur.flag_stride;//todo? ( (ги720 + 31гй&0xffffffe0 ) * 2/8  + 31) & 0xffffffe0

				if(g_video[screen_id][id].video_cur.pre_frame_valid == TRUE) {
					g_video[screen_id][id].tempdiff_en = TRUE;
					pre_frame_addr_luma= (__u32)OSAL_VAtoPA((void*)g_video[screen_id][id].pre_frame_addr_luma);
					pre_frame_addr_chroma= (__u32)OSAL_VAtoPA((void*)g_video[screen_id][id].pre_frame_addr_chroma);
				}	else {
					g_video[screen_id][id].tempdiff_en = FALSE;
				}
				g_video[screen_id][id].diagintp_en = TRUE;
			}
			else
			{
				g_video[screen_id][id].dit_mode = DIT_MODE_WEAVE;
				g_video[screen_id][id].tempdiff_en = FALSE;
				g_video[screen_id][id].diagintp_en = FALSE;
			}
		}	else {
			g_video[screen_id][id].dit_enable = FALSE;
			g_video[screen_id][id].fetch_field = FALSE;
			g_video[screen_id][id].fetch_bot = FALSE;
			g_video[screen_id][id].dit_mode = DIT_MODE_WEAVE;
			g_video[screen_id][id].tempdiff_en = FALSE;
			g_video[screen_id][id].diagintp_en = FALSE;
		}

		in_type.fmt= Scaler_sw_para_to_reg(0,scaler->in_fb.mode, scaler->in_fb.format, scaler->in_fb.seq);
		in_type.mod= Scaler_sw_para_to_reg(1,scaler->in_fb.mode, scaler->in_fb.format, scaler->in_fb.seq);
		in_type.ps= Scaler_sw_para_to_reg(2,scaler->in_fb.mode, scaler->in_fb.format, (__u8)scaler->in_fb.seq);
		in_type.byte_seq = 0;
		in_type.sample_method = 0;

		scal_addr.ch0_addr= (__u32)OSAL_VAtoPA((void*)(g_video[screen_id][id].video_cur.addr[0]));
		scal_addr.ch1_addr= (__u32)OSAL_VAtoPA((void*)(g_video[screen_id][id].video_cur.addr[1]));
		scal_addr.ch2_addr= (__u32)OSAL_VAtoPA((void*)(g_video[screen_id][id].video_cur.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_height=  scaler->src_win.height;
		in_size.scal_width=  scaler->src_win.width;

		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 = g_video[screen_id][id].fetch_field;
		in_scan.bottom = g_video[screen_id][id].fetch_bot;

		out_scan.field = (gdisp.screen[screen_id].de_flicker_status & DE_FLICKER_USED)?0: gdisp.screen[screen_id].b_out_interlace;

		if(scaler->out_fb.cs_mode > DISP_VXYCC)	{
			scaler->out_fb.cs_mode = DISP_BT601;
		}

		/* 3d source */
		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;

			/* if supported 3d display */
			if(bsp_disp_feat_get_layer_feats(scaler->screen_index, DISP_LAYER_WORK_MODE_SCALER, scaler_index) & DISP_LAYER_FEAT_3D) {
				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_id].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*)(g_video[screen_id][id].video_cur.addr_right[0]));
				scal_addr_right.ch1_addr= (__u32)OSAL_VAtoPA((void*)(g_video[screen_id][id].video_cur.addr_right[1]));
				scal_addr_right.ch2_addr= (__u32)OSAL_VAtoPA((void*)(g_video[screen_id][id].video_cur.addr_right[2]));

				DE_SCAL_Set_3D_Ctrl(scaler_index, scaler->b_trd_out, inmode, outmode);
				DE_SCAL_Config_3D_Src(scaler_index, &scal_addr, &in_size, &in_type, inmode, &scal_addr_right);
				DE_SCAL_Agth_Config(scaler_index, &in_type, &in_size, &out_size, 0, scaler->b_trd_out, outmode);
			}	else {
				DE_WRN("This platform not support 3d output!\n");
				DE_SCAL_Config_Src(scaler_index,&scal_addr,&in_size,&in_type,FALSE,FALSE);
				DE_SCAL_Agth_Config(scaler_index, &in_type, &in_size, &out_size, 0, 0, 0);
			}
		}	else {
			/* 2d source */
			DE_SCAL_Config_Src(scaler_index,&scal_addr,&in_size,&in_type,FALSE,FALSE);
			DE_SCAL_Agth_Config(scaler_index, &in_type, &in_size, &out_size, 0, 0, 0);
		}

		DE_SCAL_Set_Init_Phase(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, g_video[screen_id][id].dit_enable);
		DE_SCAL_Set_Scaling_Factor(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type);
		//DE_SCAL_Set_Scaling_Coef_for_video(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, 0x00000101);
		DE_SCAL_Set_Scaling_Coef(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, scaler->smooth_mode);
		DE_SCAL_Set_Out_Size(scaler_index, &out_scan,&out_type, &out_size);
		DE_SCAL_Set_Di_Ctrl(scaler_index,g_video[screen_id][id].dit_enable,g_video[screen_id][id].dit_mode,g_video[screen_id][id].diagintp_en,g_video[screen_id][id].tempdiff_en);
		DE_SCAL_Set_Di_PreFrame_Addr(scaler_index, pre_frame_addr_luma, pre_frame_addr_chroma);
		DE_SCAL_Set_Di_MafFlag_Src(scaler_index, 
		    OSAL_VAtoPA((void*)g_video[screen_id][id].cur_maf_flag_addr),
		    OSAL_VAtoPA((void*)g_video[screen_id][id].pre_maf_flag_addr), maf_linestride);

		if(g_video[screen_id][id].display_cnt == 0) {
			size = (scaler->in_fb.size.width * scaler->src_win.height * de_format_to_bpp(scaler->in_fb.format) + 7)/8;
			//OSAL_CacheRangeFlush((void *)scal_addr.ch0_addr,size ,CACHE_CLEAN_FLUSH_D_CACHE_REGION);
		}

		DE_SCAL_Set_Reg_Rdy(scaler_index);
	}
	/* normal layer */
	else {
		__layer_man_t * layer_man;
		__disp_fb_t fb;
		layer_src_t layer_fb;

		memset(&layer_fb, 0, sizeof(layer_src_t));
		layer_man = &gdisp.screen[screen_id].layer_manage[id];

		bsp_disp_layer_get_framebuffer(screen_id, id, &fb);
		fb.addr[0] = (__u32)OSAL_VAtoPA((void*)(g_video[screen_id][id].video_cur.addr[0]));
		fb.addr[1] = (__u32)OSAL_VAtoPA((void*)(g_video[screen_id][id].video_cur.addr[1]));
		fb.addr[2] = (__u32)OSAL_VAtoPA((void*)(g_video[screen_id][id].video_cur.addr[2]));

		if(get_fb_type(fb.format) == DISP_FB_TYPE_YUV) {
			Yuv_Channel_adjusting(screen_id , fb.mode, fb.format, &layer_man->para.src_win.x, &layer_man->para.scn_win.width);
			Yuv_Channel_Set_framebuffer(screen_id, &fb, layer_man->para.src_win.x, layer_man->para.src_win.y);
		}	else {
			layer_fb.fb_addr    = (__u32)OSAL_VAtoPA((void*)fb.addr[0]);
			layer_fb.pixseq     = img_sw_para_to_reg(3,0,fb.seq);
			layer_fb.br_swap    = fb.br_swap;
			layer_fb.fb_width   = fb.size.width;
			layer_fb.offset_x   = layer_man->para.src_win.x;
			layer_fb.offset_y   = layer_man->para.src_win.y;
			layer_fb.format = fb.format;
			DE_BE_Layer_Set_Framebuffer(screen_id, id,&layer_fb);
		}
	}

	gdisp.screen[screen_id].layer_manage[id].para.fb.addr[0] = g_video[screen_id][id].video_cur.addr[0];
	gdisp.screen[screen_id].layer_manage[id].para.fb.addr[1] = g_video[screen_id][id].video_cur.addr[1];
	gdisp.screen[screen_id].layer_manage[id].para.fb.addr[2] = g_video[screen_id][id].video_cur.addr[2];
	gdisp.screen[screen_id].layer_manage[id].para.fb.trd_right_addr[0] = g_video[screen_id][id].video_cur.addr_right[0];
	gdisp.screen[screen_id].layer_manage[id].para.fb.trd_right_addr[1] = g_video[screen_id][id].video_cur.addr_right[1];
	gdisp.screen[screen_id].layer_manage[id].para.fb.trd_right_addr[2] = g_video[screen_id][id].video_cur.addr_right[2];

	return DIS_SUCCESS;
}
Ejemplo n.º 8
0
__s32 BSP_disp_scaler_start(__u32 handle,__disp_scaler_para_t *para)
{
	__scal_buf_addr_t in_addr;
	__scal_buf_addr_t out_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;
	__u32 size = 0;
	__u32 sel = 0;
	__s32 ret = 0;

	if(para==NULL)
	{
		DE_WRN("input parameter can't be null!\n");
		return DIS_FAIL;
	}

	sel = SCALER_HANDTOID(handle);

	in_type.mod= Scaler_sw_para_to_reg(1,para->input_fb.mode);
	in_type.fmt= Scaler_sw_para_to_reg(0,para->input_fb.format);
	in_type.ps= Scaler_sw_para_to_reg(2,(__u8)para->input_fb.seq);
	in_type.byte_seq = 0;

	if(get_fb_type(para->output_fb.format) == DISP_FB_TYPE_YUV)
	{
		if(para->output_fb.mode == DISP_MOD_NON_MB_PLANAR)
		{
			out_type.fmt = Scaler_sw_para_to_reg(3, para->output_fb.format);
		}
		else
		{
			DE_WRN("output mode:%d invalid in Display_Scaler_Start\n",para->output_fb.mode);
			return DIS_FAIL;
		}
	}
	else
	{
		if(para->output_fb.mode == DISP_MOD_NON_MB_PLANAR && para->output_fb.format == DISP_FORMAT_RGB888)
		{
			out_type.fmt = DE_SCAL_OUTPRGB888;
		}
		else if(para->output_fb.mode == DISP_MOD_INTERLEAVED && para->output_fb.format == DISP_FORMAT_ARGB8888)
		{
			out_type.fmt = DE_SCAL_OUTI0RGB888;
		}
		else
		{
			DE_WRN("output para invalid in Display_Scaler_Start,mode:%d,format:%d\n",para->output_fb.mode, para->output_fb.format);
			return DIS_FAIL;
		}
		para->output_fb.br_swap= FALSE;
	}
	out_type.byte_seq = Scaler_sw_para_to_reg(2,para->output_fb.seq);

	out_size.width     = para->output_fb.size.width;
	out_size.height = para->output_fb.size.height;

	in_addr.ch0_addr = (__u32)OSAL_VAtoPA((void*)(para->input_fb.addr[0]));
	in_addr.ch1_addr = (__u32)OSAL_VAtoPA((void*)(para->input_fb.addr[1]));
	in_addr.ch2_addr = (__u32)OSAL_VAtoPA((void*)(para->input_fb.addr[2]));

	in_size.src_width = para->input_fb.size.width;
	in_size.x_off = para->source_regn.x;
	in_size.y_off = para->source_regn.y;
	in_size.scal_width= para->source_regn.width;
	in_size.scal_height= para->source_regn.height;

	in_scan.field = FALSE;
	in_scan.bottom = FALSE;

	out_scan.field = FALSE;	//when use scaler as writeback, won't be outinterlaced for any display device
	out_scan.bottom = FALSE;

	out_addr.ch0_addr = (__u32)OSAL_VAtoPA((void*)(para->output_fb.addr[0]));
	out_addr.ch1_addr = (__u32)OSAL_VAtoPA((void*)(para->output_fb.addr[1]));
	out_addr.ch2_addr = (__u32)OSAL_VAtoPA((void*)(para->output_fb.addr[2]));

	size = (para->input_fb.size.width * para->input_fb.size.height * de_format_to_bpp(para->input_fb.format) + 7)/8;
    OSAL_CacheRangeFlush((void *)para->input_fb.addr[0],size ,CACHE_CLEAN_FLUSH_D_CACHE_REGION);

	size = (para->output_fb.size.width * para->output_fb.size.height * de_format_to_bpp(para->output_fb.format) + 7)/8;
    OSAL_CacheRangeFlush((void *)para->output_fb.addr[0],size ,CACHE_FLUSH_D_CACHE_REGION);

	DE_SCAL_Config_Src(sel,&in_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);
	DE_SCAL_Set_Init_Phase(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, FALSE);
	DE_SCAL_Set_CSC_Coef(sel, para->input_fb.cs_mode, para->output_fb.cs_mode, get_fb_type(para->input_fb.format), get_fb_type(para->output_fb.format));
	DE_SCAL_Set_Scaling_Coef(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, DISP_VIDEO_NATUAL);
	DE_SCAL_Set_Out_Format(sel, &out_type);
	DE_SCAL_Set_Out_Size(sel, &out_scan,&out_type, &out_size);
	DE_SCAL_Set_Writeback_Addr(sel,&out_addr);
    DE_SCAL_Output_Select(sel, 3);
	DE_SCAL_EnableINT(sel,DE_WB_END_IE);
	DE_SCAL_Start(sel);
	DE_SCAL_Set_Reg_Rdy(sel);
	DE_SCAL_Writeback_Enable(sel);

	ret = gdisp.init_para.scaler_begin(sel);


	DE_SCAL_Reset(sel);
	DE_SCAL_Writeback_Disable(sel);

	return ret;

}
Ejemplo n.º 9
0
__s32 Scaler_Set_Para(__u32 sel, __disp_scaler_t *scl)
{
    __disp_scaler_t * scaler;
	__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;

    scaler = &(gdisp.scaler[sel]);

	memcpy(&(scaler->in_fb), &(scl->in_fb), sizeof(__disp_fb_t));
	memcpy(&(scaler->src_win), &(scl->src_win), sizeof(__disp_rect_t));
	memcpy(&(scaler->out_size), &(scl->out_size), sizeof(__disp_rectsz_t));

	in_type.mod = Scaler_sw_para_to_reg(1,scaler->in_fb.mode);
	in_type.fmt = Scaler_sw_para_to_reg(0,scaler->in_fb.format);
	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_height= scaler->src_win.height;
	in_size.scal_width= scaler->src_win.width;

	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);
	DE_SCAL_Set_Init_Phase(sel, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, FALSE);
	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);
	DE_SCAL_Set_Out_Format(sel, &out_type);
	DE_SCAL_Set_Out_Size(sel, &out_scan,&out_type, &out_size);

	return 0;
}
Ejemplo n.º 10
0
__s32 Video_Operation_In_Vblanking(__u32 sel, __u32 tcon_index)
{	
    __u32 id=0;

#if 0
	for(id = 0; id<4; id++)
	{
		if((g_video[sel][id].enable == TRUE) && (g_video[sel][id].have_got_frame == TRUE))
		{
			Hal_Set_Frame(sel, tcon_index, id);
		}
	}
#else  //de-interlace
	for(id = 0; id < 2; id++)
	{
		if((g_interlace[id].enable) && (gdisp.scaler[id].status & SCALER_USED))
		{
			unsigned long flags;
			dit_mode_t dit_mod;
			__u32 maf_linestride = 0;
			__u32 pre_frame_addr_luma = 0;
			__u32 pre_frame_addr_chroma = 0;
			__scal_src_type_t in_type;
			__scal_out_type_t out_type;
			__scal_src_size_t in_size;
			__scal_out_size_t out_size;
			__scal_scan_mod_t in_scan;
			__scal_scan_mod_t out_scan;
			__disp_scaler_t *scaler = &(gdisp.scaler[id]);
			__scal_buf_addr_t scal_addr;
			__bool fetch_bot;
			__bool  tempdiff_en;
			__bool  diagintp_en;

#ifdef __LINUX_OSAL__
			spin_lock_irqsave(&g_video[sel][0].flag_lock, flags);
#endif
			fetch_bot = scaler->in_fb.b_top_field_first ^ g_interlace[id].first_field;
			g_interlace[id].first_field = false;
#ifdef __LINUX_OSAL__
			spin_unlock_irqrestore(&g_video[sel][0].flag_lock, flags);
#endif

			dit_mod = dit_mode_default[id];
			maf_linestride = (((scaler->src_win.width + 31) & 0xffffffe0)*2/8 + 31) & 0xffffffe0;

			if(!g_interlace[id].first_frame)
			{
				if(dit_mod == DIT_MODE_MAF)
				{
					pre_frame_addr_luma = g_interlace[id].pre_frame_addr_luma;
					pre_frame_addr_chroma = g_interlace[id].pre_frame_addr_chroma;
					tempdiff_en = true;
					diagintp_en = true;
				}
				else
				{
					tempdiff_en =  false;
					diagintp_en = false;
				}
			}
			else
			{
				tempdiff_en =  false;
				g_interlace[id].first_frame = false;
			}

			in_type.fmt = Scaler_sw_para_to_reg(0,scaler->in_fb.mode,scaler->in_fb.format,scaler->in_fb.seq);
			in_type.mod = Scaler_sw_para_to_reg(1,scaler->in_fb.mode,scaler->in_fb.format,scaler->in_fb.seq);
			in_type.ps = Scaler_sw_para_to_reg(2,scaler->in_fb.mode,scaler->in_fb.format,scaler->in_fb.seq);
			in_type.byte_seq = 0;
			in_type.sample_method = 0;

			in_scan.field = false;
			in_scan.bottom = fetch_bot;
			out_scan.field = (gdisp.screen[sel].de_flicker_status & DE_FLICKER_USED) ?
				0: gdisp.screen[sel].b_out_interlace;

			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_height=  scaler->src_win.height;
			in_size.scal_width=  scaler->src_win.width;

			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;

			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]));

			DE_SCAL_Config_Src(id,&scal_addr,&in_size,&in_type,FALSE,FALSE);
			DE_SCAL_Agth_Config(sel, &in_type, &in_size, &out_size, 0, 0, 0);

			DE_SCAL_Set_Init_Phase(id, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, 1);
			DE_SCAL_Set_Scaling_Factor(id, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type);
			//DE_SCAL_Set_Scaling_Coef_for_video(scaler_index, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, 0x00000101);
			DE_SCAL_Set_Scaling_Coef(id, &in_scan, &in_size, &in_type, &out_scan, &out_size, &out_type, scaler->smooth_mode);
			DE_SCAL_Set_Out_Size(id, &out_scan,&out_type, &out_size);
			DE_SCAL_Set_Di_Ctrl(id,1,dit_mod,diagintp_en,tempdiff_en);
			DE_SCAL_Set_Di_PreFrame_Addr(id,pre_frame_addr_luma,pre_frame_addr_chroma);
			DE_SCAL_Set_Di_MafFlag_Src(id,g_interlace[id].cur_maf_flag_addr,
				g_interlace[id].pre_maf_flag_addr,maf_linestride);
		}
		else
		{
			DE_SCAL_Set_Di_Ctrl(id,0,DIT_MODE_WEAVE,0,0);
		}
	}

#endif
	return DIS_SUCCESS;
}