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

📄 camera_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 : camera_test.c
*  
*	File Description : Camera Test Function 
*
*	Author : 
*	Dept. : AP Development Team
*	Created Date : 
*	Version : 0.1 
* 
*	History
*	- Created
*  
**************************************************************************************/

#include <string.h>
#include <stdio.h>

#include "system.h"
#include "lcd.h"
#include "camera.h"
#include "glib.h"
#include "intc.h"
#include "option.h"
#include "library.h"
#include "sfr6400.h"
#include "sysc.h"
#include "gpio.h"
#include "Smile.h"

static CSPACE eSrcDataFmt; // For source data format of direct path
static CSPACE eDstDataFmt; // For destinaion data format of codec path
static CSPACE eLcdBpp;

static IMAGE_EFFECT   	eImgEffect;
static FLIP_DIR 	    eFlipDir;
static ROT_DEG 	     	eRotDeg;
static CAMIF_INOUT		eInputPath;
static PROCESS_PATH     eProcessPath;
static CAMIF_INOUT		eOutputPath;

static u32 uSrcCroppedHsz, uSrcCroppedVsz;
static u32 uSrcWidth, uSrcHeight;
static u32 uArbitraryCbValue, uArbitraryCrValue;

static u32 uLcdFbAddr;

static volatile u32 uFbAddr1 = 0x52000000;
static volatile u32 uFbAddr2 = 0x53000000;
static volatile u32 uFbAddr3 = 0x54000000;
static volatile u32 uFbAddr4 = 0x55000000;

static volatile bool bPreviewDone;
static volatile bool bCodecDone;


static volatile u32 uFramec;

// for Last IRQ Test
volatile u32 uCamPreviewStatus, uCamPreviewDataValid, uCamPreviewCptCount;
volatile u32 uCamCodecStatus, uCamCodecDataValid, uCamCodecCptCount;
#define CAPTURE_STOPPED			(0)
#define CAPTURING					(1)
#define CAPTURE_STOP_ISSUED		(2)
#define CAPTURE_LASTIRQ_ISSUED	(3)
#define CAPTURE_LAST_IRQ			(4)

//////////
// Function Name : isr_previewdone
// Function Description : Preview Path ISR 
// Input : NONE
// Output : NONE
// Version : v0.1
void __irq Isr_PreviewDone(void)
{
	LCD_Trigger();
	bPreviewDone = true;
	printf("P");
	CAMERA_SetClearPreviewInt();
	INTC_ClearVectAddr();		
}


//////////
// Function Name : isr_4previewdone
// Function Description : Preview Path ISR 
// Input : NONE
// Output : NONE
// Version : v0.1
void __irq Isr_4PreviewDone(void)
{
	u32 uFrameNumber;
	LCD_Trigger();
	bPreviewDone = true;
	printf("P");
	CAMERA_GetFrameNum(P_PATH, &uFrameNumber);

	switch ( (uFrameNumber-2) )
	{
		case 0:
			LCD_InitWin(eLcdBpp, 320, 240, 0, 0, 320, 240, 0, 0, uFbAddr1, WIN0, false);
			break;
		case 1:
			LCD_InitWin(eLcdBpp, 320, 240, 0, 0, 320, 240, 0, 0, uFbAddr2, WIN0, false);
			break;
		case 2:
			LCD_InitWin(eLcdBpp, 320, 240, 0, 0, 320, 240, 0, 0, uFbAddr3, WIN0, false);
			break;
		case 3:
			LCD_InitWin(eLcdBpp, 320, 240, 0, 0, 320, 240, 0, 0, uFbAddr4, WIN0, false);
			break;
		default :
			break;
	}

	CAMERA_SetClearPreviewInt();
	INTC_ClearVectAddr();		
}






//////////
// Function Name : isr_Codecdone
// Function Description : Codec Path ISR 
// Input : NONE
// Output : NONE
// Version : v0.1
void __irq Isr_CodecDone(void)
{
	LCD_Trigger();
	printf("C");
	bCodecDone = true;
	CAMERA_SetClearCodecInt();
	INTC_ClearVectAddr();
}


//////////
// Function Name : isr_previewdone
// Function Description : Preview Path ISR 
// Input : NONE
// Output : NONE
// Version : v0.1
void __irq Isr_MSDMAPreviewDone(void)
{
	LCD_Trigger();
	bPreviewDone = true;
	printf("PMS");
	CAMERA_StartMSDmaPreviewPath();
	CAMERA_SetClearPreviewInt();
	INTC_ClearVectAddr();		
}


//////////
// Function Name : isr_previewdone
// Function Description : Preview Path ISR 
// Input : NONE
// Output : NONE
// Version : v0.1
void __irq Isr_MSDMACodecDone(void)
{
	LCD_Trigger();
	bCodecDone = true;
	printf("CMS");
	CAMERA_StartMSDmaCodecPath();
	CAMERA_SetClearCodecInt();
	INTC_ClearVectAddr();		
}


//////////
// Function Name : isr_LastIRQDone
// Function Description : Preview Path Last IRQ Test
// Input : NONE
// Output : NONE
// Version : v0.1
void __irq Isr_LastIRQDone(void)
{
	printf("L");

	switch(uCamPreviewStatus) {

	case CAPTURE_STOPPED	:					//	It will never happen.
			break;
			
	case CAPTURING	:
			break;

	case CAPTURE_STOP_ISSUED	:
			CAMERA_EnablePreviewLastIRQ();
			uCamPreviewStatus	=	CAPTURE_LASTIRQ_ISSUED;
			break;

	case CAPTURE_LASTIRQ_ISSUED	:
			CAMERA_DisableImageCapture();
			CAMERA_DisableImageCapturePreview();
			CAMERA_DisablePreviewScaler();
			uCamPreviewStatus	=	CAPTURE_LAST_IRQ;
			break;			

	case CAPTURE_LAST_IRQ	:
			uCamPreviewStatus	=	CAPTURE_STOPPED;
			break;
	}

	if (uCamPreviewCptCount>0)
		uCamPreviewDataValid	=	1;
				
	uCamPreviewCptCount++;	
	CAMERA_SetClearPreviewInt();
	INTC_ClearVectAddr();		
	
}

//////////
// Function Name : CAMERAT_DisplayParam
// Function Description : Test condition display function
// Input : NONE
// Output : NONE
// Version : v0.1
static void CAMERAT_DisplayParam(void)
{
	const char* cpDstDataFmtStr;
	const char* cpMemSrcDataFmtStr;
	const char* cpImgEffectStr;
	const char* cpFlipDirStr;
	const char* cpRotStr;
	const char* cpLcdBppStr;
	u32 uSrcHSz, uSrcVSz;
	
	if (eOutputPath==FIFO)
		cpDstDataFmtStr = ((eDstDataFmt == RGB16)||(eDstDataFmt == RGB18)||(eDstDataFmt == RGB24)) ? "RGB 24Bpp" : "YUV444" ;
	else
		cpDstDataFmtStr =(eDstDataFmt == RGB16) ? "RGB 16Bpp" :
			(eDstDataFmt == RGB18) ? "RGB 18Bpp" :
			(eDstDataFmt == RGB24) ? "RGB 24Bpp" :
			(eDstDataFmt == YCBYCR) ? "YCbYCr422_Intlv" :
			(eDstDataFmt == YCRYCB) ? "YCrYCb422_intlv" :
			(eDstDataFmt == CBYCRY) ? "CbYCrY422_Intlv" :
			(eDstDataFmt == CRYCBY) ? "CrYCbY422_Intlv" :
			(eDstDataFmt == YC422) ? "YC422" :
			(eDstDataFmt == YC420) ? "YC420" :"error";
	if (cpDstDataFmtStr == "error")
		Assert(0);

	cpMemSrcDataFmtStr =(eSrcDataFmt == YCBYCR) ? "YCbYCr422_Intlv" :
		(eSrcDataFmt == YCRYCB) ? "YCrYCb422_intlv" :
		(eSrcDataFmt == CBYCRY) ? "CbYCrY422_Intlv" :
		(eSrcDataFmt == CRYCBY) ? "CrYCbY422_Intlv" :
		(eSrcDataFmt == YC422) ? "YC422" :
		(eSrcDataFmt == YC420) ? "YC420" :
		(eSrcDataFmt == RGB16) ? "RGB 16Bpp" :
		(eSrcDataFmt == RGB18) ? "RGB 18Bpp" :
		(eSrcDataFmt == RGB24) ? "RGB 24Bpp" :"error";
	if (cpMemSrcDataFmtStr == "error")
		Assert(0);

	cpImgEffectStr =(eImgEffect == BYPASS) ? "No Image Effect" :
		(eImgEffect == ARBITRARY_CBCR) ? "Arbitrary Cb/Cr" :
		(eImgEffect == NEGATIVE) ? "Negative" :
		(eImgEffect == ART_FREEZE) ? "Art Freeze" :
		(eImgEffect == EMBOSSING) ? "Embossing" :
		(eImgEffect == SILHOUETTE) ? "Silhouette" : "error";
	if (cpImgEffectStr == "error")
		Assert(0);

	cpFlipDirStr =(eFlipDir == FLIP_NO) ? "No Flip" :
		(eFlipDir == FLIP_X) ? "X-Axis Flip" :
		(eFlipDir == FLIP_Y) ? "Y-Axis Flip" :
		(eFlipDir == FLIP_XY) ? "XY-Axis Flip" : "error";
	if (cpFlipDirStr == "error")
		Assert(0);

	cpRotStr = (eRotDeg == ROT_0) ? "No rotation" :
		(eRotDeg == ROT_90) ? "Rotation 90" :
		(eRotDeg == ROT_180) ? "Rotation 180" :
		(eRotDeg == ROT_270) ? "Rotation 270" : "error";
	if (cpRotStr == "error")
		Assert(0);

	cpLcdBppStr = (eLcdBpp == RGB16) ? "RGB 16Bpp" :
		(eLcdBpp == RGB18) ? "RGB 18Bpp" :  "RGB 24Bpp";

	
	printf("\n\nBasic info:\n");
	printf("\t- Lcd input bpp: %s\n", cpLcdBppStr);
	printf("\t- Output data format: %s\n", cpDstDataFmtStr);
	if (eInputPath==FIFO)
	{
		CAMERA_GetSrcImgSz(&uSrcHSz, &uSrcVSz);
	}
	else
		uSrcHSz = uSrcWidth, uSrcVSz=uSrcHeight;
	printf("Features info:\n");
	printf(" \t- Flip : %s\n", cpFlipDirStr);
	printf(" \t- Rotation : %s\n", cpRotStr);
	if (eImgEffect == ARBITRARY_CBCR)
		printf("\t- Image effect=Arbitrary CbCr, Cb=%d, Cr=%d\n", uArbitraryCbValue, uArbitraryCrValue);
	else
		printf(" \t- Image effect: %s\n", cpImgEffectStr);

	printf("Source image info.\n");
	if (eInputPath==DMA)
		printf("\t- Memory Input Data Format: %s\n", cpMemSrcDataFmtStr);
	printf(" \t- Source width: %d\t - Source height: %d\n", uSrcHSz, uSrcVSz);
	printf(" \t- Cropped width: %d\t - Cropped height: %d\n", uSrcCroppedHsz, uSrcCroppedVsz);

}

//////////
// Function Name : CAMERAT_TestTestPattern
// Function Description : Function of Test Pattern Test
// Input : NONE
// Output : NONE
// Version : v0.1
static void CAMERAT_TestTestPattern(void)
{
	u32 uIndex;
	u32 uLcdHsz, uLcdVsz;
	TEST_PATTERN eTestPattern ;
	for (uIndex = 0 ; uIndex<3 ; uIndex++)
	{
		switch(uIndex)
		{
			case 0:
				eTestPattern = VERTICAL_INCR;
				break;
			case 1:
				eTestPattern = COLOR_BAR;	
				break;
			case 2:
				eTestPattern = HORIZONTAL_INCR;	
				break;
			default:
				break;
	 	}

		eProcessPath = C_PATH;
		// 1. Initialize interrupt
		//=======================================
		INTC_SetVectAddr(NUM_CAMIF_P, Isr_PreviewDone);
		INTC_SetVectAddr(NUM_CAMIF_C, Isr_CodecDone);	
		INTC_Enable(NUM_CAMIF_P);
		INTC_Enable(NUM_CAMIF_C);

		// 2. Initialize lcd
		//=======================================
		LCD_InitDISPC(eLcdBpp, uLcdFbAddr, WIN0, false);
		LCD_GetFrmSz(&uLcdHsz, &uLcdVsz, WIN0);	
		LCD_SetWinOnOff(1, WIN0);
		LCD_Start();

		// 3. Initialize camera. run the process of preview/codec path
		//=============================================
		CAMERA_InitSensor();
		if (eProcessPath==P_PATH)
		{
			CAMERA_InitPreviewPath(uLcdHsz, uLcdVsz, uLcdFbAddr, eLcdBpp, FLIP_NO, ROT_0);
			CAMERA_EnableTestMode(eTestPattern);
			CAMERA_StartPreviewPath();
			printf("\nHit Any Key to Stop the test!\n");
			UART_Getc(); 
			CAMERA_StopPreviewPath();
		}
		else
		{
			CAMERA_InitCodecPath(uLcdHsz, uLcdVsz, uLcdFbAddr, eLcdBpp, FLIP_NO, ROT_0);
			CAMERA_EnableTestMode(eTestPattern);
			CAMERA_StartCodecPath(0);
			printf("\nHit Any Key to Stop the test!\n");
			UART_Getc();
			CAMERA_StopCodecPath();
		}

		INTC_Disable(NUM_CAMIF_P);
		INTC_Disable(NUM_CAMIF_C);	
	}
	
}


//////////
// Function Name : CAMERAT_TestZoomInOut
// Function Description : Function of ZoomIn/Out Test(Preview Path)
// Input : NONE
// Output : NONE
// Version : v0.1
static void CAMERAT_TestZoomInOut_Preview(void)
{
	u32 uLcdHsz, uLcdVsz;
	u32 uSrcHSz, uSrcVSz;
	char cChar;
	u32 uCurHsz;
	u32 uCurVsz;
	u32 uSrcStX;
	u32 uSrcStY;
	u32 uHStep;
	u32 uVStep;
	int nX;
	
	// 1. Initialize interrupt 
	//=======================================
	INTC_SetVectAddr(NUM_CAMIF_P, Isr_PreviewDone);
	INTC_Enable(NUM_CAMIF_P);
	
	// 2. Initialize lcd
	//=======================================
	LCD_InitDISPC(eLcdBpp, uLcdFbAddr, WIN0, false);
	LCD_GetFrmSz(&uLcdHsz, &uLcdVsz, WIN0);	
	LCD_SetWinOnOff(1, WIN0);
	LCD_Start();

	// 3. Initialize camera and variables of the fimc, run the zoom in/out process
	//=======================================

	CAMERA_InitSensor();
	CAMERA_GetSrcImgSz(&uSrcHSz, &uSrcVSz);

	uCurHsz = uSrcHSz;
	uCurVsz = uSrcVSz;
	uSrcStX = 0;
	uSrcStY = 0;
	uHStep = 16;
	uVStep = 16*uSrcVSz/uSrcHSz;
	eFlipDir = FLIP_NO;
	eRotDeg = ROT_0;

	while (true)
	{
		CAMERA_InitPreviewPath2(uSrcStX, uSrcStY, uCurHsz, uCurVsz,
			uLcdHsz, uLcdVsz, uLcdFbAddr, eLcdBpp, eFlipDir, eRotDeg);
		CAMERA_StartPreviewPath();
		printf("\nHit Any Key to Stop preview!\n\n");
		UART_Getc();
		CAMERA_StopPreviewPath();

		printf("\n 0 : Exit\n");
		printf(" 1 : Zoom In\n");
		printf(" 2 : Zoom Out\n");

		printf("Hit Key: ");
		nX = GetIntNum();
		printf("%c\n", cChar);

		if (nX == 1)
		{
			uSrcStX += uHStep;
			uSrcStY += uVStep;

			if ((uCurHsz >= 16+2*uSrcStX)||(uCurVsz>= 8+2*uSrcStY))
			{
				uCurHsz -= 2*uSrcStX;
				uCurVsz -= 2*uSrcStY;
			}
			else
			{
				uSrcStX -= uHStep;
				uSrcStY -= uVStep;

⌨️ 快捷键说明

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