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

📄 g2d_test.c

📁 s3c6400 ADS下官方测试程序
💻 C
📖 第 1 页 / 共 5 页
字号:
/**************************************************************************************
* 
*	Project Name : S3C6400 Validation
*
*	Copyright 2006 by Samsung Electronics, Inc.
*	All rights reserved.
*
*	Project Description :
*		This software is only for validating functions of the S3C6400.
*		Anybody can use this software without our permission.
*  
*--------------------------------------------------------------------------------------
* 
*	File Name : g2d_test.c
*  
*	File Description : This file includes the test code for 2D.
*
*	Author : Sekwang Kim
*	Dept. : AP Development Team
*	Created Date : 2007/01/25
*	Version : 0.1a 
* 
*	History
*	- Created by JiHyun Jang , YunSoo Lee 
* 	- Modified by Sekwang Kim(2007/01/25)
*  
**************************************************************************************/


#include "system.h"

#include "lcd.h"
#include "glib.h"
#include "g2d.h"
#include "def.h"
#include "library.h"
#include "intc.h"
#include "timer.h"



#define C16_BLUE            (0x1f<<0)
#define C16_GREEN           (0x3f<<5)
#define C16_RED             (0x1f<<11)
#define C16_BLACK           (0x0)
#define C16_WHITE           (0xffff)
#define C16_LIGHT_GRAY      (0xc618)

#define RGB16_IMG_SIZE      240*120*2
#define PATTERN_MEM_ST      (CODEC_MEM_ST+0x80000)


u16 pat8x8[]={
	C16_WHITE,C16_WHITE,C16_WHITE,C16_RED  ,C16_BLUE ,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_WHITE,C16_WHITE,C16_RED  ,C16_RED  ,C16_BLUE ,C16_BLUE ,C16_WHITE,C16_WHITE,
	C16_WHITE,C16_RED  ,C16_RED  ,C16_RED  ,C16_BLUE ,C16_BLUE ,C16_BLUE ,C16_WHITE,
	C16_RED  ,C16_RED  ,C16_RED  ,C16_RED  ,C16_BLUE ,C16_BLUE ,C16_BLUE ,C16_BLUE ,
	C16_GREEN,C16_GREEN,C16_GREEN,C16_GREEN,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,
	C16_WHITE,C16_GREEN,C16_GREEN,C16_GREEN,C16_BLACK,C16_BLACK,C16_BLACK,C16_WHITE,
	C16_WHITE,C16_WHITE,C16_GREEN,C16_GREEN,C16_BLACK,C16_BLACK,C16_WHITE,C16_WHITE,
	C16_WHITE,C16_WHITE,C16_WHITE,C16_GREEN,C16_BLACK,C16_WHITE,C16_WHITE,C16_WHITE};


u16 pat8x8_rectangle[]={
	C16_RED,C16_RED,C16_RED,C16_RED  ,C16_RED ,C16_RED,C16_RED,C16_RED,
	C16_RED,C16_RED,C16_RED,C16_RED  ,C16_RED ,C16_RED,C16_RED,C16_RED,
	C16_RED,C16_RED,C16_GREEN,C16_GREEN,C16_GREEN,C16_GREEN,C16_RED,C16_RED,
	C16_RED,C16_RED,C16_GREEN,C16_GREEN,C16_GREEN,C16_GREEN,C16_RED,C16_RED,
	C16_RED,C16_RED,C16_GREEN,C16_GREEN,C16_GREEN,C16_GREEN,C16_RED,C16_RED,
	C16_RED,C16_RED,C16_GREEN,C16_GREEN,C16_GREEN,C16_GREEN,C16_RED,C16_RED,
	C16_RED,C16_RED,C16_RED,C16_RED  ,C16_RED ,C16_RED,C16_RED,C16_RED,
	C16_RED,C16_RED,C16_RED,C16_RED  ,C16_RED ,C16_RED,C16_RED,C16_RED};

u16 pat8x8_outline[]={
	C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE  ,C16_WHITE ,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_WHITE,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_WHITE,
	C16_WHITE,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_WHITE,
	C16_WHITE,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_WHITE,
	C16_WHITE,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_WHITE,
	C16_WHITE,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_WHITE,
	C16_WHITE,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_WHITE,
	C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE  ,C16_WHITE ,C16_WHITE,C16_WHITE,C16_WHITE};
	
u16 pat8x8_white[]={
	C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE  ,C16_WHITE ,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE  ,C16_WHITE ,C16_WHITE,C16_WHITE,C16_WHITE};

u16 pat8x8_black[]={
	C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK  ,C16_BLACK ,C16_BLACK,C16_BLACK,C16_BLACK,
	C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,
	C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,
	C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,
	C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,
	C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,
	C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK,
	C16_BLACK,C16_BLACK,C16_BLACK,C16_BLACK  ,C16_BLACK ,C16_BLACK,C16_BLACK,C16_BLACK};	

u16 pat8x8_rgbw[]={
	C16_RED,C16_RED,C16_RED,C16_RED,C16_GREEN,C16_GREEN,C16_GREEN,C16_GREEN,
	C16_RED,C16_RED,C16_RED,C16_RED,C16_GREEN,C16_GREEN,C16_GREEN,C16_GREEN,
	C16_RED,C16_RED,C16_RED,C16_RED,C16_GREEN,C16_GREEN,C16_GREEN,C16_GREEN,
	C16_RED,C16_RED,C16_RED,C16_RED,C16_GREEN,C16_GREEN,C16_GREEN,C16_GREEN,
	C16_BLUE,C16_BLUE,C16_BLUE,C16_BLUE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_BLUE,C16_BLUE,C16_BLUE,C16_BLUE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_BLUE,C16_BLUE,C16_BLUE,C16_BLUE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE,
	C16_BLUE,C16_BLUE,C16_BLUE,C16_BLUE,C16_WHITE,C16_WHITE,C16_WHITE,C16_WHITE};


extern void TestSFR(void);


void TestPointDrawingSimple(void)
{
	u32 i,j;
	u32 uG2dFbAddr, uG2dWidth, uG2dHeight;
	CSPACE eBpp;


	INTC_SetVectAddr(NUM_2D, Isr_G2d);
	INTC_Enable(NUM_2D);
	G2D_InterruptEnable();

	G2D_GetFrmSz(&uG2dWidth, &uG2dHeight);
	G2D_GetFbAddr(&uG2dFbAddr);	
	G2D_GetBppMode(&eBpp);
		
	printf("Width=%d, Height=%d, Framebuffer:0x%x\n", uG2dWidth, uG2dHeight, uG2dFbAddr);
	
	G2D_ClearFrameEcolor(G2D_BLACK, 0, 0);
	printf("Simple Point Drawing, press any key to continue\n");

	for(j=0; j<uG2dHeight; j++)
		for(i=0; i<uG2dWidth; i++)
			if(i<(uG2dWidth/2) && j<(uG2dHeight/2)) G2D_PutPixelEcolor(i, j, G2D_RED);
			else if(i>=(uG2dWidth/2) && (j<uG2dHeight/2)) G2D_PutPixelEcolor(i, j, G2D_GREEN);
			else if(i<(uG2dWidth/2) && j>=(uG2dHeight/2)) G2D_PutPixelEcolor(i, j, G2D_BLUE);
			else	 G2D_PutPixelEcolor(i, j, G2D_WHITE);
	printf("Red, Green, Bule and White are displayed, press any key to exit\n");
	UART_Getc();
	
	G2D_InterruptDisable();
	INTC_Disable(NUM_2D);
	G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);	
}

void TestPointDrawingWithRop(void)
{
	u32 i,j,k;
	u32 uG2dFbAddr, uG2dWidth, uG2dHeight;
	CSPACE eBpp;


	INTC_SetVectAddr(NUM_2D, Isr_G2d);
	INTC_Enable(NUM_2D);
	G2D_InterruptEnable();

	G2D_GetFrmSz(&uG2dWidth, &uG2dHeight);
	G2D_GetFbAddr(&uG2dFbAddr);
	G2D_GetBppMode(&eBpp);
	printf("Width=%d, Height=%d, Framebuffer:0x%x\n", uG2dWidth, uG2dHeight, uG2dFbAddr);

	G2D_ClearFrameEcolor(G2D_YELLOW, 0, 0);
	G2D_RegisterPattern(pat8x8_rgbw);

	

	printf("Point Drawing with Raster Operation(pattern), press any key to continue\n");
	G2D_Set3rdOperand(G2D_OPERAND3_PAT);
	UART_Getc();	

	for(k=0; k<=8; k++) {
		G2D_SetRopEtype((G2D_ROP_TYPE)(k));
		switch((G2D_ROP_TYPE)k){
			case ROP_DST_ONLY: 
				printf("Destination Only, press any key to continue\n");
				break;
			case ROP_SRC_ONLY: 
				printf("Source Only, press any key to continue\n");
				break;
			case ROP_3RD_OPRND_ONLY: 
				printf("Third Operand Only, press any key to continue\n");
				break;
			case ROP_SRC_AND_DST: 
				printf("Source AND Destination, press any key to continue\n");
				break;
			case ROP_SRC_AND_3RD_OPRND: 
				printf("Source AND Third Operand, press any key to continue\n");
				break;
			case ROP_SRC_OR_DST: 
				printf("Source OR Destination, press any key to continue\n");
				break;
			case ROP_SRC_OR_3RD_OPRND: 
				printf("Source OR Third Operand, press any key to continue\n");
				break;				
			case ROP_DST_OR_3RD:
				printf("Destination OR Third Operand, press any key to continue\n");
				break;
			case ROP_SRC_XOR_3RD_OPRND: 
				printf("Source XOR Third Operand, press any key to continue\n");
				break;
			default:
				break;
		} 

		for(j=0; j<uG2dHeight; j++)
			for(i=0; i<uG2dWidth; i++)
				if(i<(uG2dWidth/2) && j<(uG2dHeight/2)) G2D_PutPixelEcolor(i, j, G2D_RED);
				else if(i>=(uG2dWidth/2) && (j<uG2dHeight/2)) G2D_PutPixelEcolor(i, j, G2D_GREEN);
				else if(i<(uG2dWidth/2) && j>=(uG2dHeight/2)) G2D_PutPixelEcolor(i, j, G2D_BLUE);
				else	 G2D_PutPixelEcolor(i, j, G2D_WHITE);
		UART_Getc();
	}

#if 0 // Open this block when you want to test ROP that get the third operand via foreground color 
	printf("Point Drawing with Raster Operation(foreground), press any key to continue\n");
	G2D_ClearFrameEcolor(G2D_YELLOW, 0, 0);
	G2D_SetFgColor(G2D_MAGENTA);
	G2D_Set3rdOperand(G2D_OPERAND3_FG);
	G2D_SetRopEtype(ROP_DST_OR_3RD);
	UART_Getc();	

	for(j=0; j<uG2dHeight; j++)
		for(i=0; i<uG2dWidth; i++)
			G2D_PutPixelEcolor(i, j, G2D_MAGENTA);
#endif

	G2D_InterruptDisable();
	INTC_Disable(NUM_2D);
	G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);

}

void TestPointDrawingWithRotation(void)
{
	u32 i,j;
	u32 uG2dFbAddr, uG2dWidth, uG2dHeight;
	CSPACE eBpp;


	INTC_SetVectAddr(NUM_2D, Isr_G2d);
	INTC_Enable(NUM_2D);
	G2D_InterruptEnable();

	G2D_GetFrmSz(&uG2dWidth, &uG2dHeight);
	G2D_GetFbAddr(&uG2dFbAddr);
	G2D_GetBppMode(&eBpp);
	printf("Width=%d, Height=%d, Framebuffer:0x%x\n", uG2dWidth, uG2dHeight, uG2dFbAddr);

	G2D_ClearFrameEcolor(G2D_BLACK, 0, 0);
	for(j=0; j<uG2dHeight; j++)
		for(i=0; i<uG2dWidth; i++) {
			if(i==(uG2dWidth/2-1)) G2D_PutPixelEcolor(i, j, G2D_WHITE);
			if(j==(uG2dHeight/2-1)) G2D_PutPixelEcolor(i, j, G2D_WHITE);
		}	

	G2D_SetRotationMode(G2D_ROTATION_0_DEG_BIT);
	for(j=0; j<uG2dHeight; j++)
		for(i=0; i<uG2dWidth; i++) {
			if(i>=((uG2dWidth/2-1)+10) && i<((uG2dWidth/2-1)+50) && j > ((uG2dHeight/2-1)-50) && j<=((uG2dHeight/2-1)-10)) G2D_PutPixelEcolor(i, j, G2D_BLUE);
		}
	printf("Destination Image is displayed, press any key to test rotation\n");
	UART_Getc();

	G2D_SetRotationMode(G2D_ROTATION_90_DEG_BIT);
	G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
	for(j=0; j<uG2dHeight; j++)
		for(i=0; i<uG2dWidth; i++) {
			if(i>=((uG2dWidth/2-1)+10) && i<((uG2dWidth/2-1)+50) && j > ((uG2dHeight/2-1)-50) && j<=((uG2dHeight/2-1)-10)) G2D_PutPixelEcolor(i, j, G2D_RED);
		}
	printf("90 degree rotation, press any key to test rotation\n");
	UART_Getc();

	G2D_SetRotationMode(G2D_ROTATION_180_DEG_BIT);
	G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
	for(j=0; j<uG2dHeight; j++)
		for(i=0; i<uG2dWidth; i++) {
			if(i>=((uG2dWidth/2-1)+10) && i<((uG2dWidth/2-1)+50) && j > ((uG2dHeight/2-1)-50) && j<=((uG2dHeight/2-1)-10)) G2D_PutPixelEcolor(i, j, G2D_GREEN);
		}
	printf("180 degree rotation, press any key to test rotation\n");
	UART_Getc();

	G2D_SetRotationMode(G2D_ROTATION_270_DEG_BIT);
	G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
	for(j=0; j<uG2dHeight; j++)
		for(i=0; i<uG2dWidth; i++) {
			if(i>=((uG2dWidth/2-1)+10) && i<((uG2dWidth/2-1)+50) && j > ((uG2dHeight/2-1)-50) && j<=((uG2dHeight/2-1)-10)) G2D_PutPixelEcolor(i, j, G2D_WHITE);
		}
	printf("270 degree rotation, press any key to test rotation\n");
	UART_Getc();

	G2D_SetRotationMode(G2D_ROTATION_0_DEG_BIT);
	for(j=0; j<uG2dHeight; j++)
		for(i=0; i<uG2dWidth; i++) {
			if(i>=((uG2dWidth/2-1)+50) && i<((uG2dWidth/2-1)+90) && j > ((uG2dHeight/2-1)-90) && j<=((uG2dHeight/2-1)-50)) G2D_PutPixelEcolor(i, j, G2D_BLUE);
		}
	printf("Destination Image is displayed, press any key to test rotation\n");
	UART_Getc();	

	G2D_SetRotationMode(G2D_X_FLIP);
	G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
	for(j=0; j<uG2dHeight; j++)
		for(i=0; i<uG2dWidth; i++) {
			if(i>=((uG2dWidth/2-1)+50) && i<((uG2dWidth/2-1)+90) && j > ((uG2dHeight/2-1)-90) && j<=((uG2dHeight/2-1)-50)) G2D_PutPixelEcolor(i, j, G2D_YELLOW);
		}
	printf("X-FLIP, press any key to test rotation\n");
	UART_Getc();

	G2D_SetRotationMode(G2D_Y_FLIP);
	G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
	for(j=0; j<uG2dHeight; j++)
		for(i=0; i<uG2dWidth; i++) {
			if(i>=((uG2dWidth/2-1)+50) && i<((uG2dWidth/2-1)+90) && j > ((uG2dHeight/2-1)-90) && j<=((uG2dHeight/2-1)-50)) G2D_PutPixelEcolor(i, j, G2D_CYAN);
		}
	printf("Y-FLIP, press any key to exit\n");
	UART_Getc();

	G2D_InterruptDisable();
	INTC_Disable(NUM_2D);
	G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);	
}


void TestPointDrawingWithBlending(void)
{
	u32 i,j;
	u32 uG2dFbAddr, uG2dWidth, uG2dHeight;
	s32  sAlphaVal;	
	CSPACE eBpp;

	INTC_SetVectAddr(NUM_2D, Isr_G2d);
	INTC_Enable(NUM_2D);
	G2D_InterruptEnable();

	G2D_GetFrmSz(&uG2dWidth, &uG2dHeight);
	G2D_GetFbAddr(&uG2dFbAddr);
	G2D_GetBppMode(&eBpp);
	printf("Width=%d, Height=%d, Framebuffer:0x%x\n", uG2dWidth, uG2dHeight, uG2dFbAddr);

	printf("press any key to test alpha blending.\n");
	G2D_ClearFrameEcolor(G2D_YELLOW, 0, 0);


	G2D_SetAlphaMode(G2D_ALPHA_MODE);
	G2D_SetAlphaValue(0xff);
	
	for(j=0; j<uG2dHeight; j++)
		for(i=0; i<uG2dWidth; i++)
			if(i<(uG2dWidth/2) && j<(uG2dHeight/2)) G2D_PutPixelEcolor(i, j, G2D_RED);
			else if(i>=(uG2dWidth/2) && (j<uG2dHeight/2)) G2D_PutPixelEcolor(i, j, G2D_GREEN);
			else if(i<(uG2dWidth/2) && j>=(uG2dHeight/2)) G2D_PutPixelEcolor(i, j, G2D_BLUE);
			else	 G2D_PutPixelEcolor(i, j, G2D_WHITE);
			
	UART_Getc();
			
	sAlphaVal=255;

	while(1) {

⌨️ 快捷键说明

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