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

📄 display.c

📁 Samsung S3C2443 Test program source code
💻 C
📖 第 1 页 / 共 2 页
字号:
/*********************************************************************
;* 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 <stdio.h>

#include "Def.h"
#include "Option.h"
#include "System.h"
#include "Console.h"
#include "Exception.h"
#include "MMUCache.h"
#include "2443addr.h"

#include "Display.h"
#include "DisplaySample.h"
#include "DisplaySample_240_320.h"
#include "DisplaySample_320_240.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_frame_rate=0;
uint8 lcd_burst_mode=WINCONx_4WORD_BURST;
uint16 screen_width, screen_height;
uint32 *lcd_framebuffer=0;


void *lcd_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 *)Test_Interrupt,				"Interrupt Test",
	(void *)Test_DisplayFramebufferCpuIf_QVGA, 	"Cpu If Test",


	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;
	
	printf("\n!! RGB I/F Display Controller Test !!\n");

	rMISCCR |= (1<<28);  // select LCD controller for TFT lcd controller

	SetLcdPort();	
	Init_LDI();


	
	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;
		
}
//
//==========================================


//==========================================
// 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");
	
}

//------------------------------------------
// Basic Display Test sub function 1
//
void Test_DisplayFramebufferRgbIf_QVGA1(void)
{
	int8 image,window,buffer;
	uint32 i,j,k;

	printf("\nSelect the window # which you want to test\n");
	printf(" 0: Window 0   1: Window 1\n");

	window = GetIntNum();
	if( (window<0) || (window>1) )	return;

	if (window==0)
	{
		printf("\nSelect the buffer # which you want to test\n");
		printf(" 0: Buffer 0   1: Buffer 1\n");

		buffer = GetIntNum();
		if( (buffer<0) || (buffer>1) )	return;
	} else {
		buffer = 0;
	}

	printf("\nSelect the image which you want to display\n");
	printf(" 1: RGBW (24bpp)  2: Snail (16bpp)\n");


	image = GetIntNum();

 	if(image == 1)	//RGBW
 	{
		Basic_Display_Setting(window,buffer,WINCONx_24BPP_888,lcd_horizon_value,lcd_line_value);
		LCD_FilledRectangle(0, 0, screen_width-1, screen_height/4*1-1, 0xff0000);
		LCD_FilledRectangle(0, screen_height/4*1, screen_width-1, screen_height/4*2-1, 0x00ff00);
		LCD_FilledRectangle(0, screen_height/4*2, screen_width-1, screen_height/4*3-1, 0x0000ff);
		LCD_FilledRectangle(0, screen_height/4*3, screen_width-1, screen_height-1, 0xffffff);
		lprintf(130,80,0xffffff,"Hello~");
 	}
	else if(image == 2)	//Snail
	{
		Basic_Display_Setting(window,buffer,WINCONx_16BPP_565,lcd_horizon_value,lcd_line_value);			
		for(j=0;j<screen_height;j++)
			for(i=0;i<screen_width;i++)
				PutPixel(i,j,snail16bpp[k++]);
	}
	else
	{
		printf("You entered wrong number..\n");
		return;	
	}
	
	Display_Start(window);	

	printf("\n >>> display through window %d[%s] is going on...\n",window,lcd_bpp_mode[WINCONx_16BPP_565]);
	Display_End(window);
	
	return;	
}

//------------------------------------------
// Basic Display Test sub function 2
//
void Test_DisplayFramebufferRgbIf_QVGA2(void)
{
	int32 image,window,buffer;
	uint32 i,j,k;

	printf("\nSelect the window # which you want to test\n");
	printf(" 0: Window 0   1: Window 1\n");

	window = GetIntNum();
	if( (window<0) || (window>1) )	return;

	if (window==0)
	{
		printf("\nSelect the buffer # which you want to test\n");
		printf(" 0: Buffer 0   1: Buffer 1\n");

		buffer = GetIntNum();
		if( (buffer<0) || (buffer>1) )	return;
	} else {
		buffer = 0;
	}


	printf("\nSelect the image which you want to display\n");
	printf(" 1: RGBW (24bpp)  2: praying girl (16bpp)\n");

	image = GetIntNum();

 	if(image == 1)	//RGBW
 	{
		Basic_Display_Setting(window,buffer,WINCONx_24BPP_888,lcd_horizon_value,lcd_line_value);
		LCD_FilledRectangle(0, 0, screen_width-1, screen_height/4*1-1, 0xff0000);
		LCD_FilledRectangle(0, screen_height/4*1, screen_width-1, screen_height/4*2-1, 0x00ff00);
		LCD_FilledRectangle(0, screen_height/4*2, screen_width-1, screen_height/4*3-1, 0x0000ff);
		LCD_FilledRectangle(0, screen_height/4*3, screen_width-1, screen_height-1, 0xffffff);
		lprintf(130,80,0xffffff,"Hello~");
 	}
	else if(image == 2)	//praying girl
	{
		Basic_Display_Setting(window,buffer,WINCONx_16BPP_565,lcd_horizon_value,lcd_line_value);			
		for(j=0;j<screen_height;j++)
			for(i=0;i<screen_width;i++)
					PutPixel(i,j,prayer16bpp[k++]);
	}
	else
	{
		printf("You entered wrong number..\n");
		return;	
	}

	Display_Start(window);

	printf("\n >>> display through window %d[%s] is going on...\n",window,lcd_bpp_mode[WINCONx_24BPP_888]);

	Display_End(window);

	return;	
}
//
//==========================================

//==========================================
// Each Window and Each BPP Test function
//
void Test_EachWindow_EachBPP(void)
{
	int32 window,buffer,bpp;
	uint32 i=0;


	while(1)
	{
		printf("\nSelect the window # which you want to test\n");
		printf("(If you want to stop this test, press enter key)\n");
		printf(" 0: Window 0 (Buffer0)   1: Window 1\n");

		window = GetIntNum();
		if ((window<0)||(window>1)) break;

		while(1)
		{
			printf("\nSelect the bpp type which you want to test\n");
			printf("(If you want to exit, press enter key)\n");

			for(i=0;i<14;i++)
			{
				printf("   %2d:%s\n",i,lcd_bpp_mode[i]);
			}

			bpp = GetIntNum();
			if( (bpp<0)||(bpp>14) )	break;

			LcdWindowOnOff(LCD_WIN_ALL,LCD_OFF);
			LcdEnvidOnOff(LCD_OFF);
				
			Basic_Display_Setting(window,LCD_BUF_0,bpp,lcd_horizon_value,lcd_line_value);	
			LCD_ClearScr(0);

			Prepare_Image(window,bpp);

			Display_Start(window);
			Display_End(window);

		}

	}
	
}
//
//==========================================

//==========================================
// Blending(per-plane or per-pixel) Test
//
void PlaneBlendingTest(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(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(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");
			

	*WINCONx_Reg_Addr[1] &= ~((1<<6)|(1<<1));
	*WINCONx_Reg_Addr[1] |= (alpha_sel<<1);
	*VIDOSDxC_Reg_Addr[1] = (0<<20)|(0<<16)|(0<<12)|(0xf<<8)|(0xf<<4)|(0xf<<0);

	LcdWindowOnOff(LCD_WIN_ALL,LCD_ON);
	LcdEnvidOnOff(LCD_ON);

	printf("Press any key to start\n");
	getchar();

	for(i=0;i<16;i++)
	{
		*VIDOSDxC_Reg_Addr[1] = (i<<20)|(i<<16)|(i<<12)|((i^0xf)<<8)|((i^0xf)<<4)|((i^0xf)<<0);
		delayLoop(10000000);
	}

	/* Ending Test */
	Display_End(LCD_WIN_ALL);
	
}

void PixelBlendingTest( void)
{
	uint32 i;

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

	// Setting Window 0
	Basic_Display_Setting(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(LCD_WIN_1,LCD_BUF_0,WINCONx_16BPP_A555,lcd_horizon_value,lcd_line_value);	

	LCD_FilledRectangle(0, 0, screen_width/8*1-1, screen_height-1, 0x7c00);
	LCD_FilledRectangle(screen_width/8*1, 0, screen_width/8*2-1, screen_height-1, 0x3e0);
	LCD_FilledRectangle(screen_width/8*2, 0, screen_width/8*3-1, screen_height-1, 0x1f);
	LCD_FilledRectangle(screen_width/8*3, 0, screen_width/8*4-1, screen_height-1, 0x7fff);

	LCD_FilledRectangle(screen_width/8*4, 0, screen_width/8*5-1, screen_height-1, 0xfc00);
	LCD_FilledRectangle(screen_width/8*5, 0, screen_width/8*6-1, screen_height-1, 0x83e0);
	LCD_FilledRectangle(screen_width/8*6, 0, screen_width/8*7-1, screen_height-1, 0x801f);
	LCD_FilledRectangle(screen_width/8*7, 0, screen_width-1, screen_height-1, 0xffff);
	
	lprintf(0,100,0x7fff,"Window 1");
	lprintf(0,120,0x7fff,"non blending area");
	
	lprintf(screen_width/2,100,0xffff,"Window 1");
	lprintf(screen_width/2,120,0xffff,"blending area");


	*WINCONx_Reg_Addr[1] &= ~((1<<6)|(1<<1));
	*WINCONx_Reg_Addr[1] |= (1<<6);
	*VIDOSDxC_Reg_Addr[1] = (0<<20)|(0<<16)|(0<<12)|(0xf<<8)|(0xf<<4)|(0xf<<0);

	LcdWindowOnOff(LCD_WIN_ALL,LCD_ON);
	LcdEnvidOnOff(LCD_ON);

	printf("Press any key to start\n");
	getchar();

	for(i=0;i<16;i++)
	{
		*VIDOSDxC_Reg_Addr[1] = (i<<20)|(i<<16)|(i<<12)|((i^0xf)<<8)|((i^0xf)<<4)|((i^0xf)<<0);
		delayLoop(10000000);
	}

	/* Ending Test */
	Display_End(LCD_WIN_ALL);

}

void Test_Blending_Win01(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();
	else if (blending==1)
		PixelBlendingTest();
}

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

//==========================================
// ColorKey Test
//
void Test_ColorKey(void)
{

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


	// Setting Window 0
	Basic_Display_Setting(LCD_WIN_0,LCD_BUF_0,WINCONx_24BPP_888,lcd_horizon_value,lcd_line_value);	

	LCD_FilledRectangle(0, 0, screen_width-1, screen_height/4*1-1, 0xff0000);
	LCD_FilledRectangle(0, screen_height/4*1, screen_width-1, screen_height/4*2-1, 0x00ff00);
	LCD_FilledRectangle(0, screen_height/4*2, screen_width-1, screen_height/4*3-1, 0x0000ff);
	LCD_FilledRectangle(0, screen_height/4*3, screen_width-1, screen_height-1, 0xffffff);
	lprintf(50,20,0xffffff,"Window 0");			
			
		
	// Setting Window 1
	Basic_Display_Setting(LCD_WIN_1,LCD_BUF_0,WINCONx_24BPP_888,lcd_horizon_value,lcd_line_value);	

	LCD_FilledRectangle(0, 0, screen_width/4*1-1, screen_height-1, 0xff0000);
	LCD_FilledRectangle(screen_width/4*1, 0, screen_width/4*2-1, screen_height-1, 0x00ff00);
	LCD_FilledRectangle(screen_width/4*2, 0, screen_width/4*3-1, screen_height-1, 0x0000ff);
	LCD_FilledRectangle(screen_width/4*3, 0, screen_width-1, screen_height-1, 0xffffff);
	lprintf(50,100,0xffffff,"Window 1");
			
	*WxKEYCON0_Reg_Addr[1]	=	(0<<26)|(1<<25)|(0<<24)|(0x000000);
	*WxKEYCON1_Reg_Addr[1]	=	0x000000;
	
	LcdWindowOnOff(LCD_WIN_ALL,LCD_ON);
	LcdEnvidOnOff(LCD_ON);


	printf("Press any key to start\n");
	getchar();
	
	*WxKEYCON1_Reg_Addr[1]	=	0xff0000;
	delayLoop(30000000);
	*WxKEYCON1_Reg_Addr[1]	=	0x00ff00;
	delayLoop(30000000);
	*WxKEYCON1_Reg_Addr[1]	=	0x0000ff;
	delayLoop(30000000);
	*WxKEYCON1_Reg_Addr[1]	=	0xffffff;
	delayLoop(30000000);

	/* Ending Test */
	Display_End(LCD_WIN_ALL);

}


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

//==========================================
// ColorMap Test function
//
void Test_ColorMap(void)
{
	int8 window=-1;
	uint8 i=0;
	uint32 color_map=0;
	
	while(1)
	{
		printf("\nSelect the window # which you want to test\n");
		printf("(If you want to stop this test, press enter key)\n");
		printf(" 0: Window 0   1: Window 1 \n");

⌨️ 快捷键说明

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