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

📄 prev270.c

📁 dm270 source code
💻 C
字号:
/*
    DM270 ARM Evaluation Software

    (c)Texas Instruments 2003
*/

/**
	\file prev270.c
	\brief Preview Engine Related APIs
*/
#include <prev270.h>

/**
    \brief Preview Engine Enable

    \param enable	TRUE: enable, FASLE: disable

    \return if success, \c E_PASS, else error code
*/
STATUS PREV_enable( BOOL enable ) {
	PREV_RSET( PVEN, enable == TRUE ? 1 : 0);
	return E_PASS;
}

/**
    \brief Check if Preview Engine is Enabled

    \return TRUE: enabled, FASLE: disabled
*/

BOOL PREV_isEnabled() {
	return (BOOL)PREV_RGET( PVEN );
}

/**
    \brief Set Preview Engine configuration parameters

    \param prevConfig	Configuration data

    \return if success, \c E_PASS, else error code

	\see PREV_ConfigData
*/
STATUS PREV_setConfig( PREV_ConfigData *prevConfig ){
	Uint16 prev_hsize, prev_vsize;
	Uint16 prev_hrsz, prev_vrsz;

	PREV_FSET( PVSET1, 8BITS,  prevConfig->ccdcInputWidth8bits == TRUE ? 1 : 0 );
	PREV_FSET( PVSET1, ALAW,   prevConfig->alawEnable == TRUE ? 1 : 0 );
	PREV_FSET( PVSET1, PVOS,   prevConfig->oneShotEnable == TRUE ? 1 : 0 );
	PREV_FSET( PVSET1, RSONLY, prevConfig->resizeOnlyEnable == TRUE ? 1 : 0 );
	PREV_FSET( PVSET1, INMODE,  prevConfig->sdramInputEnable == TRUE ? 1 : 0 );
	PREV_FSET( PVSET1, BSTAL,  prevConfig->burstAlignModeEnable == TRUE ? 1 : 0);
	PREV_FSET( PVSET1, WEN,    prevConfig->writeEnableValid == TRUE ? 1 : 0 );
	
	PREV_setReadAddr( prevConfig->readAddress );
	PREV_setWriteAddr( prevConfig->writeAddress );

	PREV_RSET( HSTART, prevConfig->hstart );
	PREV_RSET( VSTART, prevConfig->vstart );

	prev_hsize = prevConfig->inputPixelsH;
	prev_vsize = prevConfig->inputLinesV;
	
	prev_hrsz  = ( prev_hsize * 16 ) / prevConfig->outputPixelsH;
	prev_hsize = ( prev_hrsz * prevConfig->outputPixelsH) / 16;		
	
	// since for horizontal upscaling Hout = (HSIZE-1)*16/HRSZ
	if( prevConfig->outputPixelsH > prevConfig->inputPixelsH )
		prev_hsize++;
	
	prev_vrsz  = ( prev_vsize* 16 ) / prevConfig->outputLinesV;

	prev_vsize = ( prev_vrsz * prevConfig->outputLinesV) / 16;

	PREV_RSET( HSIZE, prev_hsize );
	PREV_RSET( HRSZ,  prev_hrsz  );
	PREV_RSET( VSIZE, prev_vsize );
	PREV_RSET( VRSZ,  prev_vrsz  );

	return E_PASS;
}

/**
    \brief	Set Preview Engine read address

    \param  address		absolute SDRAM address, must be 32byte aligned

    \return if success, \c E_PASS, else error code
*/
STATUS PREV_setReadAddr( char *address ) {
	STATUS status=E_PASS;
	Uint32 addr;

	if(address==NULL)
		return E_INVALID_INPUT;

	addr = (Uint32)address - SDRAM_MEMORY_BASE;
	if(addr%32!=0)
		status=E_INVALID_INPUT;

	addr /= 32;

	PREV_RSET( RADRL, addr );
	PREV_RSET( RADRH, addr >> 16 );

	return status;
}

/**
    \brief	Set Preview Engine write address

    \param  address		absolute SDRAM address, must be 32byte aligned

    \return if success, \c E_PASS, else error code
*/
STATUS PREV_setWriteAddr( char *address ) {
	STATUS status=E_PASS;
	Uint32 addr;

	if(address==NULL)
		return E_INVALID_INPUT;

	addr = (Uint32)address - SDRAM_MEMORY_BASE;
	if(addr%32!=0)
		status=E_INVALID_INPUT;

	addr /= 32;

	PREV_RSET( WADRL, addr );
	PREV_RSET( WADRH, addr >> 16 );

	return status;
}

/**
    \brief Set Preview Engine mode parameters

    \param prevMode		Mode data

    \return if success, \c E_PASS, else error code

	\see PREV_ModeData
*/
STATUS PREV_setMode( PREV_ModeData *prevMode ){

	PREV_FSET( PVSET2, HINT,   prevMode->hinterpollationMode );
	PREV_FSET( PVSET2, VINT,   prevMode->vinterpollationMode );
	PREV_FSET( NFILT,  NFEN,   prevMode->horizontalNoiseFilterEnable == TRUE ? 1 : 0 );

	PREV_FSET( NFILT,  NFRT,   prevMode->horizontalNoiseFilterLevel );
	PREV_FSET( PVSET2, VNFILT, prevMode->verticalNoiseFilterEnable == TRUE ? 1 : 0 );

	PREV_FSET( SMTH,   SMEN,   prevMode->smoothEnable );
	PREV_FSET( SMTH,   SMLVL,  prevMode->smoothLevel );

	PREV_FSET( PVSET2, CCDMOD, prevMode->ccdcMode );
	PREV_FSET( PVSET2, GBLND,  prevMode->greenBlendMode );

	PREV_FSET( PVSET2, EPEL,   prevMode->colorPatternEvenEven );
	PREV_FSET( PVSET2, EPOL,   prevMode->colorPatternEvenOdd );
	PREV_FSET( PVSET2, OPEL,   prevMode->colorPatternOddEven );
	PREV_FSET( PVSET2, OPOL,   prevMode->colorPatternOddOdd );

	return E_PASS;
}

/**
    \brief Set Preview Engine white balance parameters

    \param whiteBalance		White balance data

    \return if success, \c E_PASS, else error code

	\see PREV_WbData
*/
STATUS PREV_setWhiteBalance( PREV_WbData *whiteBalance ){

	PREV_RSET( DGAIN,         whiteBalance->dgain );	
	PREV_FSET( WBGAIN0, WG00, whiteBalance->gainGb );	
	PREV_FSET( WBGAIN0, WG01, whiteBalance->gainB );	
	PREV_FSET( WBGAIN1, WG02, whiteBalance->gainGr );	
	PREV_FSET( WBGAIN1, WG03, whiteBalance->gainR );	

	return E_PASS;
}

/**
    \brief	Set Preview Engine Black Compensation parameters

    \param	offsetR		Black compensation R offset, Format 2's complement
	\param	offsetG		Black compensation G offset, Format 2's complement
	\param	offsetB		Black compensation B offset, Format 2's complement

    \return if success, \c E_PASS, else error code
*/
STATUS PREV_setBlackCompensation( Int8 offsetR, Int8 offsetG, Int8 offsetB ){

	PREV_FSET( BLOFST0, BLR, offsetR );
	PREV_FSET( BLOFST0, BLG, offsetG );
	PREV_FSET( BLOFST1, BLB, offsetB ); 

	return E_PASS;
}

/**
    \brief Set Preview Engine RGB to RGB parameters

    \param rgb2rgbConfig	RGB to RGB configuration data

    \return if success, \c E_PASS, else error code

	\see PREV_Rgb2RgbData
*/
STATUS PREV_setRGB2RGB( PREV_Rgb2RgbData *rgb2rgbConfig ){

	PREV_FSET( MTXGAIN0, MTXRR, rgb2rgbConfig->matrix[0][0] );
	PREV_FSET( MTXGAIN0, MTXGR, rgb2rgbConfig->matrix[0][1] );
	PREV_FSET( MTXGAIN1, MTXBR, rgb2rgbConfig->matrix[0][2] );

	PREV_FSET( MTXGAIN1, MTXRG, rgb2rgbConfig->matrix[1][0] );
	PREV_FSET( MTXGAIN2, MTXGG, rgb2rgbConfig->matrix[1][1] );
	PREV_FSET( MTXGAIN2, MTXBG, rgb2rgbConfig->matrix[1][2] );

	PREV_FSET( MTXGAIN3, MTXRB, rgb2rgbConfig->matrix[2][0] );
	PREV_FSET( MTXGAIN3, MTXGB, rgb2rgbConfig->matrix[2][1] );
	PREV_FSET( MTXGAIN4, MTXBB, rgb2rgbConfig->matrix[2][2] );

	PREV_RSET( MTXOFST0, rgb2rgbConfig->offset[0] );
	PREV_RSET( MTXOFST1, rgb2rgbConfig->offset[1] );
	PREV_RSET( MTXOFST2, rgb2rgbConfig->offset[2] );

	return E_PASS;
}

/**
    \brief Set Preview Engine RGB to YUV parameters

    \param rgb2yuvConfig	RGB to YUV configuration data

    \return if success, \c E_PASS, else error code

	\see PREV_Rgb2YuvData
*/
STATUS PREV_setRGB2YUV( PREV_Rgb2YuvData *rgb2yuvConfig ){

	PREV_FSET( CSC0, CSCRY, rgb2yuvConfig->matrix[0][0] );
	PREV_FSET( CSC0, CSCGY, rgb2yuvConfig->matrix[0][1] );
	PREV_FSET( CSC1, CSCBY, rgb2yuvConfig->matrix[0][2] );

	PREV_FSET( CSC1, CSCRCB, rgb2yuvConfig->matrix[1][0] );
	PREV_FSET( CSC2, CSCGCB, rgb2yuvConfig->matrix[1][1] );
	PREV_FSET( CSC2, CSCBCB, rgb2yuvConfig->matrix[1][2] );

	PREV_FSET( CSC3, CSCRCR, rgb2yuvConfig->matrix[2][0] );
	PREV_FSET( CSC3, CSCGCR, rgb2yuvConfig->matrix[2][1] );
	PREV_FSET( CSC4, CSCBCR, rgb2yuvConfig->matrix[2][2] );

	PREV_RSET( YOFST,         rgb2yuvConfig->offset[0] );
	PREV_FSET( COFST, OFSTCB, rgb2yuvConfig->offset[1] );
	PREV_FSET( COFST, OFSTCR, rgb2yuvConfig->offset[2] );

	return E_PASS;
}


/**
    \brief	Set Preview Engine Gamma parameters

    \param	tableSelect		0:table 0, 1:table 1
	\param  enableR			Use selected table for R component, TRUE: use, FALSE: do not use, bypass gamma
	\param  enableG			Use selected table for G component, TRUE: use, FALSE: do not use, bypass gamma
	\param  enableB			Use selected table for B component, TRUE: use, FALSE: do not use, bypass gamma

    \return if success, \c E_PASS, else error code
*/
STATUS PREV_setGamma( Uint8 tableSelect, BOOL enableR, BOOL enableG, BOOL enableB ){

	PREV_FSET( GAMTSBYP, TBSEL, tableSelect );
	PREV_FSET( GAMTSBYP, BYPR,  enableR == TRUE ? 0 : 1 );
	PREV_FSET( GAMTSBYP, BYPG,  enableG == TRUE ? 0 : 1 );
	PREV_FSET( GAMTSBYP, BYPB,  enableB == TRUE ? 0 : 1 );

	return E_PASS;
}

/**
    \brief	Set Preview Engine Contrast

    \param	gainY		Contrast Adjustment. Y signal gain, Format U8Q4
	\param  offsetY		Brightness Adjustment. Y signal offset, 0..255

    \return if success, \c E_PASS, else error code

	\see \ref FIXED_POINT_NOTATION
*/
STATUS PREV_setContrast( Uint8 gainY, Uint8 offsetY){

	PREV_FSET( CNTBRT, CNT, gainY );
	PREV_FSET( CNTBRT, BRT, offsetY );
	
	return E_PASS;
}

/**
    \brief	Set Preview Engine Chroma supression parameters

    \param	enable		Chroma supression, TRUE: enable, FALSE: disable
	\param  threshold	Chroma supression threshold, 0..255
	\param  gain        Chroma supression gain, Format U8Q8

    \return if success, \c E_PASS, else error code

	\see \ref FIXED_POINT_NOTATION
*/
STATUS PREV_setColorSuppression( BOOL enable, Uint8 threshold, Uint8 gain){

	PREV_RSET( CSUP0, enable == TRUE ? 1 : 0 );
	PREV_FSET( CSUP1, CSUPTH, threshold );
	PREV_FSET( CSUP1, CSUPG,  gain );
	
	return E_PASS;
}

/**
    \brief	Set Preview Engine YCbCr output level

    \param	minY		Minimum Y level, 0..255
	\param	maxY		Minimum Y level, 0..255
	\param	minC		Minimum Cb, Cr level, 0..255
	\param	maxC		Minimum Cb, Cr level, 0..255

    \return if success, \c E_PASS, else error code
*/
STATUS PREV_setYCbCrLevel( Uint8 minY, Uint8 maxY, Uint8 minC, Uint8 maxC ){
	
	PREV_FSET( SETUPY, MAXY, maxY );
	PREV_FSET( SETUPY, MINY, minY );
	PREV_FSET( SETUPC, MAXC, maxC );
	PREV_FSET( SETUPC, MINC, minC );
	
	return E_PASS;
}

⌨️ 快捷键说明

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