⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r2d_task_i.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
  * Revision History:
  * 	1. Oct. 27, 2003 Jeffrey modified this for new TFT-LCD module 
  * 	2. Nov. 18, 2003 Jeffrey modified for Truly LCM Test
  */

#ifndef _WINDOWS
	#ifndef _INNOVATION_EMULATOR_
		#include "uwire.h"
	#endif	
#endif

#include  "R2D_customer_lcd_i.h"
#include  "..\..\r2d_config.h" 
#include "r2d_task_init_i.h"

#if(LCDC_DRV_CHIP == 1 )
#include "..\..\common\camera\include\chiplib.h"
#include "..\..\common\camera\src_hal\camera.h"
#endif


#ifndef _INNOVATION_EMULATOR_


#if R2D_COMPARE_REFRESH	

#pragma DATA_SECTION (OriginLCDData, ".DISP_BUF");
UINT32  OriginLCDData[R2D_MWWIDTH*R2D_HEIGHT]; //modified by ljq from 9760 to 2003/4/10
#endif

/* zhq, 2004/08/03, added for we use explicit OR to compare frame buffer. */
#ifdef _XOR_COMPARE_

#define XOR_SIZE 16
#define XOR_BLOCK	(XOR_SIZE*XOR_SIZE)
#define HOR_SIZE (R2D_WIDTH/XOR_SIZE)	/* 8 for 128. */
#define VER_SIZE (R2D_HEIGHT/XOR_SIZE)	/* 10 for 160. */

UINT16   Compare_subblock[VER_SIZE][HOR_SIZE];
UINT32   Compare_block[VER_SIZE][HOR_SIZE];
UINT32	 Compare_result[HOR_SIZE];

UINT16 Temp_Compare_subblock[HOR_SIZE];
UINT32 Temp_Compare_block[HOR_SIZE];

int ver_begin, ver_end, hor_begin, hor_end;

#endif //_XOR_COMPARE_


UINT16  g_needrefreshline = 0;



#if (R2D_BENCHMARKING == R2D_ON)
UINT32 r2d_g_tick=0;
#endif


//static unsigned char temp_frame[64*12];

void r2d_lcd_power_on(void)
{
}

void r2d_lcd_power_off(void)
{
}

UINT8 CompareLcdData(void)
{
	int  i, j;
	UINT32 Lcd_Temp,*pPmemory_Words_Pointer,*ptr1,*ptr2,originarr[160];
	//MmiTrace("zym:CompareLcdData");

	g_needrefreshline = 0;
	pPmemory_Words_Pointer=r2d_g_framebuffer->p_memory_words;

    #if R2D_COMPARE_REFRESH	/* Robert.Chen add, 2003-12-13 */
	for ( i = 0; i < 160 ; i++ )
	{
		//	originarr[i] = OriginLCDData[61*(i +1)-1];
		OriginLCDData[R2D_MWWIDTH*(i +1)-1] =  *(pPmemory_Words_Pointer +R2D_MWWIDTH*(i +1)-1);//modified by ljq from 61 to R2d_MWWIDTH 2003/4/10
	}

	for ( i = 0; i < 10 ; i ++ )
	{
		ptr1 = &OriginLCDData[0] +16*R2D_MWWIDTH*i ;//modified by ljq from 61 to R2d_MWWIDTH 2003/4/10
		ptr2 = pPmemory_Words_Pointer +16*R2D_MWWIDTH*i;//modified by ljq from 61 to R2d_MWWIDTH 2003/4/10
		if ( !memcmp( ptr1,ptr2 ,16*R2D_MWWIDTH*4) )
		{  //ptr1  equal to  ptr2 //modified by ljq from 61 to R2d_MWWIDTH 2003/4/10

			/*
				for(j =0 ; j <16 ;j ++){
					OriginLCDData[61*(16*i+j) ]= originarr[61*(16*i+j)];
				}
				*/
			;
		} else
		{
			//	MmiTrace("not equal ");
			g_needrefreshline |=(1<<i);
		}           
	}   

	memcpy( &OriginLCDData[0],pPmemory_Words_Pointer ,R2D_MWWIDTH*R2D_HEIGHT*4);//modified by ljq from 39040 to R2d_MWWIDTH*R2D_HEIGHT*4 2003/4/10
	#endif
}

void r2d_new_refresh(void)
{
	int i,x1= -1,y1=-1 ,x2 = -1,y2 = -1;
	UINT32 pdata;

	if ( g_needrefreshline == 0x3ff )
	{
		r2d_refresh();
		return ;
	}

	for ( i = 0; i < 11; i++ )
	{
		if ( (g_needrefreshline >> i) & 0x01 )
		{
			x1 = 0;
			if ( y1 == -1 )
				y1 = i *16;
			x2 = R2D_WIDTH-1;		   //by ljq from 119 to R2D_WIDTH-1 2003/4/11
			y2 = (i+1)*16 - 1;
		} 
		else
		{
			if ( x1 != -1 )
				r2d_refresh_rect(x1,y1,x2,y2);
			x1= y1 = x2 =y2 = -1;           
		}
	}
	r2d_reinit_update_region();

}

void r2d_refresh_rect(int x1 ,int y1, int x2 ,int y2 )
{
	unsigned char i,j;
	UINT16  x , y, firstpoint ,Lcd_Byte_1,Lcd_Byte_2;
	UINT32 Lcd_Temp,*pPmemory_Words_Pointer;

	pPmemory_Words_Pointer = &Lcd_Temp; 
	pPmemory_Words_Pointer = r2d_g_framebuffer->p_memory_words + y1 * 61;

	x = x2 << 8 + x1;
	y = y2 << 8 + y1;
	firstpoint = y1 << 8 + x1;

	//X address set
	main_lcd_sendcommand( XADDRESS_AREA_SET );
	main_lcd_sendcommand( y1 );
	main_lcd_sendcommand( y2 );

	if ( (x1 == 0) && (x2 == (R2D_WIDTH - 1)) )
	{
		i=0;
		while ( i < (y2 - y1 + 1) )
		{
			j = 0;
			while ( j < (R2D_MWWIDTH -1) )
			{
				Lcd_Temp = *pPmemory_Words_Pointer++;
				Lcd_Byte_1 = Lcd_Temp & 0x0000ffff;
				Lcd_Byte_2 = (Lcd_Temp & 0xffff0000) >> 16;

				main_lcd_senddata(Lcd_Byte_1 | Lcd_Byte_2);

				j++; 
			}
			pPmemory_Words_Pointer++;   
			i++;
		} 
	}
}

/* zhq, 2004/08/03, added for we use explicit OR to compare frame buffer. */
#ifdef _XOR_COMPARE_

void init_XOR_Compare()
{
	int i,j;
	ver_begin = VER_SIZE;
	hor_begin = HOR_SIZE;
	ver_end = 0;
	hor_end = 0;
	for(j=0;j<VER_SIZE;j++)
	{
		for(i=0;i<HOR_SIZE;i++)
		{
			Compare_subblock[j][i] = 0;
			Compare_block[j][i] = 0;
			//Compare_result[i] = 0;

		}
	}
}

BOOL XOR_Compare(UINT32* pPmemory_Words_Pointer)
{
	UINT16 Lcd_Short_1,Lcd_Short_2;
	UINT32 Lcd_Word;
	UINT16* Orin_frabuf;
	int i,j;
	BOOL all_match;

	MI_dbgPrintf("zhq: XOR compare entered");

	all_match = TRUE;
	Orin_frabuf = (UINT16*)pPmemory_Words_Pointer;
	for(i=0;i<R2D_HEIGHT;i++)
	{
		for(j=0;j<(R2D_WIDTH);j+=2)
		{
			Lcd_Word = *pPmemory_Words_Pointer++;
			
			Lcd_Short_1 = Lcd_Word & 0x0000ffff;
			Lcd_Short_2 = (Lcd_Word & 0xffff0000) >> 16;
			Temp_Compare_subblock[j/XOR_SIZE] ^= Lcd_Short_1;
			Temp_Compare_subblock[j/XOR_SIZE] ^= Lcd_Short_2;
			Temp_Compare_block[j/XOR_SIZE] += Lcd_Word;
		}
		if(((i+1)%XOR_SIZE) == 0)
			for(j=0;j<(R2D_WIDTH);j+=XOR_SIZE)
			if((Compare_subblock[i/XOR_SIZE][j/XOR_SIZE] == Temp_Compare_subblock[j/XOR_SIZE])&&(Compare_block[i/XOR_SIZE][j/XOR_SIZE] == Temp_Compare_block[j/XOR_SIZE]))
			{
				//MI_dbgPrintf("zhq: XOR compare match, i = %d", i);
				//Compare_result[i/XOR_SIZE]&= ~(1L<<(j/XOR_SIZE));
				Temp_Compare_subblock[j/XOR_SIZE] = 0;
				Temp_Compare_block[j/XOR_SIZE] = 0;
			}
			else
			{
				MI_dbgPrintf("zhq: XOR compare mismatch, i = %d, j = %d", i, j);
				//Draw_Block(i/XOR_SIZE,j/XOR_SIZE,Orin_frabuf);
				//Compare_result[i/XOR_SIZE] |= 1L<<(j/XOR_SIZE);
				all_match = FALSE;

				
				if(ver_begin > (i/XOR_SIZE )) ver_begin = (i/XOR_SIZE );
				if(hor_begin > (j/XOR_SIZE )) hor_begin = (j/XOR_SIZE );
				if(ver_end < (i/XOR_SIZE )) ver_end = (i/XOR_SIZE );
				if(hor_end < (j/XOR_SIZE )) hor_end = (j/XOR_SIZE );
				
				Compare_subblock[i/XOR_SIZE][j/XOR_SIZE] = Temp_Compare_subblock[j/XOR_SIZE];
				Compare_block[i/XOR_SIZE][j/XOR_SIZE] = Temp_Compare_block[j/XOR_SIZE];
				Temp_Compare_subblock[j/XOR_SIZE] = 0;
				Temp_Compare_block[j/XOR_SIZE] = 0;
			}
				
	}
	return all_match;
}

void Draw_Block(int ver_ind, int hor_ind,UINT16* Orin_frabuf)
{
	int i,j;
	UINT16* Loc_frabuf;
	UINT16 Lcd_Short;
	
	if((ver_ind> VER_SIZE) || (hor_ind> HOR_SIZE))
		return;
	main_lcd_sendcommand( XADDRESS_AREA_SET );
	main_lcd_sendcommand(ver_ind*XOR_SIZE);
	main_lcd_sendcommand(ver_ind*XOR_SIZE+XOR_SIZE-1);
					
	main_lcd_sendcommand( YADDRESS_AREA_SET );
	main_lcd_sendcommand( hor_ind*XOR_SIZE );
	main_lcd_sendcommand( hor_ind*XOR_SIZE+XOR_SIZE-1);  

	Orin_frabuf += ver_ind*XOR_SIZE*R2D_WIDTH + hor_ind*XOR_SIZE;
	Loc_frabuf = Orin_frabuf;
	for(i=0;i<XOR_SIZE;i++)
	{
		for(j=0;j<XOR_SIZE;j++)
		{
				
				
				Lcd_Short = *Loc_frabuf++;
				main_lcd_senddata(Lcd_Short);
		}
		Loc_frabuf = Orin_frabuf + (i+1)*R2D_WIDTH;
	}


}

void Draw_Bluk(int ver_ind_begin, int hor_ind_begin, int ver_ind_end, int hor_ind_end, UINT16* Orin_frabuf)
{
	int i,j;
	UINT16* Loc_frabuf;
	UINT16 Lcd_Short;
	
	if((ver_ind_begin> VER_SIZE) || (hor_ind_begin> HOR_SIZE) ||(ver_ind_end> VER_SIZE) || (hor_ind_end> HOR_SIZE))
		return;
	main_lcd_sendcommand( XADDRESS_AREA_SET );
	main_lcd_sendcommand(ver_ind_begin*XOR_SIZE);
	main_lcd_sendcommand((ver_ind_end - ver_ind_begin)*XOR_SIZE+XOR_SIZE-1);
					
	main_lcd_sendcommand( YADDRESS_AREA_SET );
	main_lcd_sendcommand( hor_ind_begin*XOR_SIZE );
	main_lcd_sendcommand( (hor_ind_end - hor_ind_begin)*XOR_SIZE+XOR_SIZE-1);  

	Orin_frabuf += ver_ind_begin*XOR_SIZE*R2D_WIDTH + hor_ind_begin*XOR_SIZE;
	Loc_frabuf = Orin_frabuf;
	for(i=0;i<(ver_ind_end - ver_ind_begin + 1)*XOR_SIZE;i++)
	{
		for(j=0;j<(hor_ind_end - hor_ind_begin + 1)*XOR_SIZE;j++)
		{
				
				
				Lcd_Short = *Loc_frabuf++;
				main_lcd_senddata(Lcd_Short);
		}
		Loc_frabuf = Orin_frabuf + (i+1)*R2D_WIDTH;
	}


}

#endif // _XOR_COMPARE_


/* zhq, 2004/08/03, modified for we use update region to do refresh to save power and time. */
void Draw_Rectangle(int ver_ind_begin, int hor_ind_begin, int ver_ind_end, int hor_ind_end, UINT16* Orin_frabuf)
{
	int i,j;
	UINT16* Loc_frabuf;
	UINT16 Lcd_Short;
	
	if((ver_ind_begin> R2D_HEIGHT) || (hor_ind_begin> R2D_WIDTH) ||(ver_ind_end> R2D_HEIGHT) || (hor_ind_end> R2D_WIDTH))
		return;
	main_lcd_sendcommand( XADDRESS_AREA_SET );
	main_lcd_sendcommand(ver_ind_begin);
	main_lcd_sendcommand(ver_ind_end);
					
	main_lcd_sendcommand( YADDRESS_AREA_SET );
	main_lcd_sendcommand( hor_ind_begin);
	main_lcd_sendcommand( hor_ind_end);  

	Orin_frabuf += ver_ind_begin*R2D_WIDTH + hor_ind_begin;
	Loc_frabuf = Orin_frabuf;
	for(i=0;i<(ver_ind_end - ver_ind_begin + 1);i++)
	{
		for(j=0;j<(hor_ind_end - hor_ind_begin + 1);j++)
		{
				
				
				Lcd_Short = *Loc_frabuf++;
				main_lcd_senddata(Lcd_Short);
		}
		Loc_frabuf = Orin_frabuf + (i+1)*R2D_WIDTH;
	}


}


void r2d_update_region(INT16 ul_x,INT16 ul_y,INT16 br_x,INT16 br_y)
{

	if (ul_x < r2d_update_ul_x)
		r2d_update_ul_x=ul_x;
    if (ul_y < r2d_update_ul_y)
		r2d_update_ul_y=ul_y;
	if (br_x > r2d_update_br_x)
		r2d_update_br_x=br_x;
	if (br_y > r2d_update_br_y)
		r2d_update_br_y=br_y;

	if (r2d_update_ul_x<0)
       r2d_update_ul_x=0;
    if (r2d_update_ul_y<0)
       r2d_update_ul_y=0;
    if (r2d_update_br_x>=R2D_WIDTH)
       r2d_update_br_x=R2D_WIDTH-1;
    if (r2d_update_br_y>=R2D_HEIGHT)
       r2d_update_br_y=R2D_HEIGHT-1;
}


void r2d_refresh(void)
{
#if(LCDC_DRV_CHIP == 0 )	
	unsigned char i,j;
	UINT32 Lcd_Temp,*pPmemory_Words_Pointer;
	UINT16 Lcd_Byte_1,Lcd_Byte_2;
	UINT16 Lcd_Byte_temp;

	pPmemory_Words_Pointer=r2d_g_framebuffer->p_memory_words;

	MI_dbgPrintf("zhq: r2d_refresh r2d_update_ul_x = %d",r2d_update_ul_x);
	MI_dbgPrintf("zhq: r2d_refresh r2d_update_ul_y = %d",r2d_update_ul_y);
	MI_dbgPrintf("zhq: r2d_refresh r2d_update_br_x = %d",r2d_update_br_x);
	MI_dbgPrintf("zhq: r2d_refresh r2d_update_br_y = %d",r2d_update_br_y);



/* zhq, 2004/08/03, modified for we use update region to do refresh to save power and time. */
	Draw_Rectangle(r2d_update_ul_y, r2d_update_ul_x, r2d_update_br_y, r2d_update_br_x, (UINT16*)pPmemory_Words_Pointer);

/* zhq, 2004/08/03, added for we use explicit OR to compare frame buffer. */
#ifdef _XOR_COMPARE_
	if(!XOR_Compare(pPmemory_Words_Pointer)) Draw_Bluk(ver_begin, hor_begin, ver_end, hor_end, (UINT16*)pPmemory_Words_Pointer);
#endif // _XOR_COMPARE_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -