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

📄 display.c

📁 三星2443芯片
💻 C
📖 第 1 页 / 共 5 页
字号:
/*********************************************************************
;* Project Name : s3c2443x
;*
;* Copyright 2006 by Samsung Electronics, Inc.
;* All rights reserved.
;*
;* Project Description :
;* This software is only for verifying functions of the s3c2443x
;* Anybody can use this code without our permission.
;**********************************************************************/


#include "System.h"
#include "Display.h"
#include "DisplaySample.h"
#include "DisplaySample_240_320.h"
#include "DisplaySample_320_240.h"
#include "sjy_320_240.h"
#include "adcts.h"


int8 lcd_type=-1;
uint32 lcd_bpp;
uint16 lcd_horizon_value=0,lcd_line_value=0;
uint8 lcd_vbpd=0,lcd_vfpd=0,lcd_vspw=0,lcd_hbpd=0,lcd_hfpd=0,lcd_hspw=0;
uint8 lcd_cs_setup=0,lcd_wr_setup=0,lcd_wr_act=0,lcd_wr_hold=0;
uint8 lcd_frame_rate=0;
uint8 lcd_burst_mode=WINCONx_4WORD_BURST;
uint16 screen_width, screen_height;
uint32 *lcd_framebuffer=0;

#define	__IS_MAIN_LCD			0


void *lcd_function[][2] =
{  //  									"123456789012345678901"
	(void *)Display_CpuIf,		"CPU I/F Test        ",
	(void *)Display_RgbIf,		"RGB I/F Test        ",
	(void *)Display_StnIf,			"STN I/F Test        ",
	0,0
};

void *lcd_cpuif_function[][2] =
{  //  									"123456789012345678901"
	(void *)Basic_Display_CPUIF,				"Basic Display Test & Halfword swap",
	(void *)Test_DisplayFramebufferCpuIf_QVGA_GOM, 	"Cpu If Test normal GOM",
	(void *)Test_ColorKey_CPUIF,				"ColorKey Test                  ",
	(void *)Test_Blending_Win01_CPUIF,		"Blending(per-plane or per-pixel) Test",
	(void *)Test_ColorMap_CPUIF,				"ColorMap Test                                 ",
	(void *)Test_EachWindow_EachBPP_CPUIF, "Each Window and Each BPP Test",
	(void *)Test_DisplayFramebufferCpuIf_OUTPUT_FORMAT, "Output format Test       ",
	(void *)Test_DisplayFramebufferCpuIf_Bufferchange,	"Buffer Auto change Test       ",
	(void *)Test_Interrupt,				"Interrupt Test",
/*
	(void *)Test_EachWindow_EachBPP,	"Each Window and Each BPP Test",
	(void *)Test_Blending_Win01,		"Blending(per-plane or per-pixel) Test",
	(void *)Test_ColorKey,				"ColorKey Test(One Windows)",
	(void *)Test_ColorMap,				"ColorMap Test",
	(void *)Test_Virtual_Screen,		"Virtual Screen Test",
	(void *)Test_DisplayFramebufferCpuIf_QVGA, 	"Cpu If Test",
*/
	0,0
};


void *lcd_rgbif_function[][2] =
{  //  									"123456789012345678901"
	(void *)Basic_Display,				"Basic Display Test",
	(void *)Test_EachWindow_EachBPP,	"Each Window and Each BPP Test",
	(void *)Test_Blending_Win01,		"Blending(per-plane or per-pixel) Test",
	(void *)Test_ColorKey,				"ColorKey Test(One Windows)",
	(void *)Test_ColorMap,				"ColorMap Test",
	(void *)Test_Virtual_Screen,		"Virtual Screen Test",

//////////////////////////////////////////////////////////////////////////////////	
	(void *)Basic_Display_Serial,				"Serial I/F Basic Display Serial Interface Test",
	(void *)Test_ColorKey_Serial,				"Serial I/F ColorKey Test                  ",
	(void *)Test_Blending_Win01_Serial,		"Serial I/F Blending(per-plane or per-pixel) Test",
	(void *)Test_EachWindow_EachBPP_Serial, "Serial I/F Each Window and Each BPP Test",
	(void *)Test_DisplayFramebufferSerial_Bufferchange,	"Serial I/F Buffer Auto change Test       ",
	(void *)Test_ColorMap_Serial,				"Serial I/F ColorMap Test                                 ",
	(void *)Test_Virtual_Screen,		"Serial I/F Virtual Screen Test",
	(void *)Test_Interrupt,				"Interrupt Test",
//	(void *)Test_DisplayFramebufferCpuIf_QVGA, 	"Cpu If Test",
	0,0
};

void *lcd_stnif_function[][2] =
{  //  									"123456789012345678901"
	(void *)Test_Lcd_Stn_1Bit,							"STN 1Bit       ",
	(void *)Test_Lcd_Stn_2Bit,							"STN 2Bit       ",
	(void *)Test_Lcd_Stn_4Bit,							"STN 4Bit       ", 	 
	(void *)Test_Lcd_Cstn_8Bit, 							"CSTN 8Bit      ",
	(void *)Test_Lcd_Cstn_8Bit_On,					"CSTN 8Bit On   ", 	 
	(void *)Test_Lcd_Cstn_12Bit,						"CSTN 12Bit     ",
	(void *)Test_Lcd_Cstn_16Bit,						"CSTN 16Bit     ",
	0,0
};

void *lcd_bpp_mode[]=
{
	"1bpp(palletized)",		//0000
	"2bpp(palletized)",		//0001
	"4bpp(palletized)",		//0010
	"8bpp(palletized)",		//0011
	"8bpp(A232)",			//0100
	"16bpp(565)",			//0101
	"16bpp(A555)",			//0110
	"16bpp(1555)",			//0111
	"18bpp(666)",			//1000
	"18bpp(A665)",			//1001
	"19bpp(A666)",			//1010
	"24bpp(888)",			//1011
	"24bpp(A887)",			//1100
	"25bpp(A888)"			//1101	
};


uint8 lcd_bit_order[]=
{
	1,2,4,8,8,16,16,16,32,32,32,32,32,32
};

uint8 lcd_burst_in_byte[]=
{
	64,32,16
};

uint32 lcd_frame_buffer[][2]=
{
	{LCD_WIN0_FRAME_BUFFER0, LCD_WIN0_FRAME_BUFFER1},
	{LCD_WIN1_FRAME_BUFFER, NULL}
};

volatile uint32 *WINCONx_Reg_Addr[]=
{
	&rWINCON0,	&rWINCON1 
};

volatile uint32 *VIDOSDxA_Reg_Addr[]=
{
	&rVIDOSD0A, &rVIDOSD1A
};

volatile uint32 *VIDOSDxB_Reg_Addr[]=
{
	&rVIDOSD0B, &rVIDOSD1B
};

volatile uint32 *VIDOSDxC_Reg_Addr[]=
{
	NULL, &rVIDOSD1C
};


volatile uint32 *VIDWxADD0_Reg_Addr[][2]=
{
	{&rVIDW00ADD0B0, &rVIDW00ADD0B1},
	{&rVIDW01ADD0, NULL}
};

volatile uint32 *VIDWxADD1_Reg_Addr[][2]=
{
	{&rVIDW00ADD1B0, &rVIDW00ADD1B1},
	{&rVIDW01ADD1, NULL}
};

volatile uint32 *VIDWxADD2_Reg_Addr[][2]=
{
	{&rVIDW00ADD2B0, &rVIDW00ADD2B1},
	{&rVIDW01ADD2, NULL}
};

volatile uint32 *WxKEYCON0_Reg_Addr[]=
{
	0, &rW1KEYCON0
};

volatile uint32 *WxKEYCON1_Reg_Addr[]=
{
	0, &rW1KEYCON1
};

volatile uint32 *WINxMAP_Reg_Addr[]=
{
	&rWIN0MAP, &rWIN1MAP
};


vuint32 *WINxPalletBase[]=
{
	(vuint32 *)WIN0_PALETTE_START, (vuint32 *)WIN1_PALETTE_START
};

//==========================================
// LCD Test main function
//
void Test_LCD(void)
{
	int i=0;
	
	while(1)
	{	
		i=0;
		
		printf("************************************************************\n");
		while(1) {
		    printf("%2d:%s",i,lcd_function[i][1]);
		    i++;
		    if((int)(lcd_function[i][0])==0) {
				printf("\n");
				break;
		    }
		    printf("\n");
		}
		
		printf("************************************************************\n");
		printf("\nSelect(Press Enter key to exit): ");
		i = GetIntNum();
		if( i==(-1) ) break;
				
		if( i>=0 && (i<(sizeof(lcd_function)/8-1) )) 
		   ( (void (*)(void)) (lcd_function[i][0]) )();	
		
		printf("\n");
	}		
	
	return;
		
}


void Display_CpuIf(void)
{

	int i;
	printf("CPU I/F Display Controller Test!\n");
	
	rMISCCR |= (1<<28);  // select LCD controller for TFT lcd controller

	#ifdef __EVT1
	#else
	rSIFCCON0 = rSIFCCON0 & ~(0x3ff) | (1<<7);
	#endif

	SetLcdPort();	
	Init_LDI_CPUIF();	

///////////////////// select menu ///////////////////////////
	while(1)
	{	
		i=0;
		
		printf("************************************************************\n");
		while(1) {
		    printf("%2d:%s",i,lcd_cpuif_function[i][1]);
		    i++;
		    if((int)(lcd_cpuif_function[i][0])==0) {
				printf("\n");
				break;
		    }
		    printf("\n");
		}
		
		printf("************************************************************\n");
		printf("\nSelect(Press Enter key to exit): ");
		i = GetIntNum();
		if( i==(-1) ) break;
				
		if( i>=0 && (i<(sizeof(lcd_cpuif_function)/8-1) )) 
		   ( (void (*)(void)) (lcd_cpuif_function[i][0]) )();	
		
		printf("\n");
	}	
}


void Display_RgbIf(void)
{

	int i;
	printf("RGB I/F Display Controller Test!\n");
	
	rMISCCR |= (1<<28);  // select LCD controller for TFT lcd controller

	SetLcdPort();	
	Init_LDI();

///////////////////// select menu ///////////////////////////
	while(1)
	{	
		i=0;
		
		printf("************************************************************\n");
		while(1) {
		    printf("%2d:%s",i,lcd_rgbif_function[i][1]);
		    i++;
		    if((int)(lcd_rgbif_function[i][0])==0) {
				printf("\n");
				break;
		    }
		    printf("\n");
		}
		
		printf("************************************************************\n");
		printf("\nSelect(Press Enter key to exit): ");
		i = GetIntNum();
		if( i==(-1) ) break;
				
		if( i>=0 && (i<(sizeof(lcd_rgbif_function)/8-1) )) 
		   ( (void (*)(void)) (lcd_rgbif_function[i][0]) )();	
		
		printf("\n");
	}	
}


void Display_StnIf(void)
{

	int i;
	printf("RGB I/F Display Controller Test!\n");
	
	rMISCCR &= ~(1<<28);  // select LCD controller for TFT lcd controller	

	SetLcdPort();	
	//Init_LDI();

///////////////////// select menu ///////////////////////////
	while(1)
	{	
		i=0;
		
		printf("************************************************************\n");
		while(1) {
		    printf("%2d:%s",i,lcd_stnif_function[i][1]);
		    i++;
		    if((int)(lcd_stnif_function[i][0])==0) {
				printf("\n");
				break;
		    }
		    printf("\n");
		}
		
		printf("************************************************************\n");
		printf("\nSelect(Press Enter key to exit): ");
		i = GetIntNum();
		if( i==(-1) ) break;
				
		if( i>=0 && (i<(sizeof(lcd_stnif_function)/8-1) )) 
		   ( (void (*)(void)) (lcd_stnif_function[i][0]) )();	
		
		printf("\n");
	}	
}

//
//==========================================


//==========================================
// Basic Display Test function
//
void Basic_Display(void)
{	
	LcdWindowOnOff(LCD_WIN_ALL,LCD_OFF);
	LcdEnvidOnOff(LCD_OFF);

	if(lcd_type==LCD_MODULE_LTS222)
	{
		Test_DisplayFramebufferRgbIf_QVGA1();
	}
	else if(lcd_type==LCD_MODULE_LTV350)
	{
		Test_DisplayFramebufferRgbIf_QVGA2();
	}
	else
		printf("Wrong LCD TYPE!!!\n");
}

void Basic_Display_Serial(void)
{	
	LcdWindowOnOff(LCD_WIN_ALL,LCD_OFF);
	LcdEnvidOnOff(LCD_OFF);

	Test_DisplayFramebufferRgbIf_QVGA1_Serial();
}

void Test_ColorKey_Serial(void)
{

	LcdWindowOnOff(LCD_WIN_ALL,LCD_OFF);
	LcdEnvidOnOff(LCD_OFF);


	// Setting Window 0
	Basic_Display_Setting_Serial(LCD_WIN_0,LCD_BUF_0,WINCONx_16BPP_565,lcd_horizon_value,lcd_line_value);	

	LCD_FilledRectangle(0, 0, screen_width-1, screen_height/4*1-1, 0xf800);
	LCD_FilledRectangle(0, screen_height/4*1, screen_width-1, screen_height/4*2-1, 0x07e0);
	LCD_FilledRectangle(0, screen_height/4*2, screen_width-1, screen_height/4*3-1, 0x001f);
	LCD_FilledRectangle(0, screen_height/4*3, screen_width-1, screen_height-1, 0xffff);
	lprintf(50,20,0xffff,"Window 0");			
	
	// Setting Window 1
	Basic_Display_Setting_Serial(LCD_WIN_1,LCD_BUF_0,WINCONx_16BPP_565,lcd_horizon_value,lcd_line_value);	

	LCD_FilledRectangle(0, 0, screen_width/4*1-1, screen_height-1, 0xf800);
	LCD_FilledRectangle(screen_width/4*1, 0, screen_width/4*2-1, screen_height-1, 0x07e0);
	LCD_FilledRectangle(screen_width/4*2, 0, screen_width/4*3-1, screen_height-1, 0x001f);
	LCD_FilledRectangle(screen_width/4*3, 0, screen_width-1, screen_height-1, 0xffff);
	lprintf(50,100,0xffff,"Window 1");
	
	*WxKEYCON0_Reg_Addr[1]	=	(0<<26)|(1<<25)|(0<<24)|(0x7<<16)|(0x3<<8)|(0x7);
	*WxKEYCON1_Reg_Addr[1]	=	0x0;
	
	LcdWindowOnOff(LCD_WIN_ALL,LCD_ON);
	LcdEnvidOnOff(LCD_ON);	

	printf("Press any key to start\n");
	getchar();
	
	*WxKEYCON1_Reg_Addr[1]	=	0xf80000;
	delayLoop(30000000);
	*WxKEYCON1_Reg_Addr[1]	=	0x00fc00;
	delayLoop(30000000);
	*WxKEYCON1_Reg_Addr[1]	=	0x0000f8;
	delayLoop(30000000);
	*WxKEYCON1_Reg_Addr[1]	=	0xf8fcf8;
	delayLoop(30000000);
	*WxKEYCON1_Reg_Addr[1]	=	0xf80000;
	delayLoop(30000000);
	/* Ending Test */
	Display_End(LCD_WIN_ALL);

}

void Test_Blending_Win01_Serial(void)
{
	int blending;
	
	printf("\nSelect the blending mode which you want to test\n");
	printf("(If you want to stop this test, press enter key)\n");
	printf(" 0: Per Plane Blending   1: Per Pixel Blending\n");
		
	blending = GetIntNum();
	if (blending==0)
		PlaneBlendingTest_Serial();
	else if (blending==1)
		PixelBlendingTest_Serial();
}

void PlaneBlendingTest_Serial(void)
{
	uint32 i;
	int32 alpha_sel;

	printf("\nSelect the alpha type which you want to test\n");
	printf(" 0: alpha 0   1: alpha 1\n");
	alpha_sel = GetIntNum();
	if ((alpha_sel<0)||(alpha_sel>1))
		alpha_sel=0;

	LcdWindowOnOff(LCD_WIN_ALL,LCD_OFF);
	LcdEnvidOnOff(LCD_OFF);
			

	// Setting Window 0
	Basic_Display_Setting_Serial(LCD_WIN_0,LCD_BUF_0,WINCONx_16BPP_565,lcd_horizon_value,lcd_line_value);	

	LCD_FilledRectangle(0, 0, screen_width-1, screen_height/4*1-1, 0xf800);

	LCD_FilledRectangle(0, screen_height/4*1, screen_width-1, screen_height/4*2-1, 0x7e0);
	LCD_FilledRectangle(0, screen_height/4*2, screen_width-1, screen_height/4*3-1, 0x1f);
	LCD_FilledRectangle(0, screen_height/4*3, screen_width-1, screen_height-1, 0xffff);
	lprintf(50,20,0xffff,"Window 0");			
			
		
	// Setting Window 1
	Basic_Display_Setting_Serial(LCD_WIN_1,LCD_BUF_0,WINCONx_16BPP_565,lcd_horizon_value,lcd_line_value);	

	LCD_FilledRectangle(0, 0, screen_width/4*1-1, screen_height-1, 0xf800);
	LCD_FilledRectangle(screen_width/4*1, 0, screen_width/4*2-1, screen_height-1, 0x7e0);
	LCD_FilledRectangle(screen_width/4*2, 0, screen_width/4*3-1, screen_height-1, 0x1f);
	LCD_FilledRectangle(screen_width/4*3, 0, screen_width-1, screen_height-1, 0xffff);
	lprintf(50,100,0xffff,"Window 1");

⌨️ 快捷键说明

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