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

📄 hal_jpeg.c

📁 一款SmartPhone的驱动代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/************************************************************************
;  	HAL_JPEG.C
;
;	The routines in this file comprise the jpeg codec setting
;
;	The Function is basic operation of LCDC
;
; 	Copyright (c) 2002 Epson Research and Development, Inc.
;
;  	All Rights Reserved.
;	2002.11.12	D Eric 		Start.					
;														
;************************************************************************/

#include "sysLCDC.h"
//#include "Jencode.h"

 long g_LastError;


/*************************************************************************************
;	Jpeg_codec.c - JPEG Codec module set for JPEG Function
;**************************************************************************************/
/*************************************************************************************
; Function:	Jpeg Codec Operation Mode Set
; Input:		YUV Format
;			JPEG Operation	
;			Marker Insert
;
; Output:	n/a
; Format:	void JpegOpModeSetting(YUVFmtSel yuvFmtSel, JpegOpSel jpegOpSel,BOOL markerInsert)
;*************************************************************************************/
void JpegOpModeSetting(	JpegYUVFmtSel yuvFmtSel,	 JpegOpSel jpegOpSel,BOOL markerInsert)
{
	unsigned short opModeSet = (unsigned short)(yuvFmtSel | (jpegOpSel << 2) | (markerInsert << 3));
	halWriteReg16( REG1000_OP_MODE_SETTING, opModeSet );
}

/*************************************************************************************
; Function:	Jpeg Marker Insert Set for encode or disable
; Input:		enable	TRUE	means marker insertion enabled
;					FALSE 	means marker insertion disabled
; Output:	n/a
; Format:	void JpegMarkerInsertSet( BOOL enable )
;*************************************************************************************/
void JpegMarkerInsertSet( BOOL enable )
{
	unsigned short operationModeSetting = halReadReg16( REG1000_OP_MODE_SETTING );
	operationModeSetting &= (~0x0008);
	operationModeSetting |= (unsigned short)(enable << 3);
	halWriteReg16( REG1000_OP_MODE_SETTING, operationModeSetting );
}

/*************************************************************************************
; Function:	get Marker Insert enable status
; Input:	n/a
; Output:	TRUE : 	marker insertion enabled
;			FALSE:	means marker insertion disabled
; Format:	BOOL JpegMarkerInsertGet( void )
;*************************************************************************************/
BOOL JpegMarkerInsertGet( void )
{
	unsigned short operationModeSetting = halReadReg16( REG1000_OP_MODE_SETTING );
	BOOL enable = (BOOL)((operationModeSetting >> 3) & TRUE);
	return ( enable );
}

/*************************************************************************************
; Function:	enables / disables DNL marker insertion
; Input:	enable	TRUE:	DNL insertion enabled
					FALSE:	DNL insertion disabled
; Output:	n/a
; Format:	void JpegDNLInsertSet( BOOL enable )
;*************************************************************************************/
void JpegDNLInsertSet( BOOL enable )
{
	unsigned short operationModeSetting = halReadReg16( REG1000_OP_MODE_SETTING );
	operationModeSetting &= (~0x0010);
	operationModeSetting |= (unsigned short)(enable << 4);
	halWriteReg16( REG1000_OP_MODE_SETTING, operationModeSetting );
}

/*************************************************************************************
; Function:	retrieves status of DNL marker inserts
; Input:	n/a
; Output:	TRUE:	DNL insertion enabled
;			FALSE:	DNL insertion disabled
; Format:	BOOL JpegDNLInsertGet( void )
;*************************************************************************************/
BOOL JpegDNLInsertGet( void )
{
	unsigned short operationModeSetting = halReadReg16( REG1000_OP_MODE_SETTING );
	BOOL enable = (BOOL)((operationModeSetting >> 4) & TRUE);
	return ( enable );
}

/*************************************************************************************
; Function:	select JPEG Operation and input source for resize block
; Input:	JpegOpSel	Encode or decode
; Output:	n/a
; Format:	void JpegOpSelSet( JpegOpSel opSel )
;*************************************************************************************/
void JpegOpSelSet( JpegOpSel opSel )
{
	unsigned short operationModeSetting = halReadReg16( REG1000_OP_MODE_SETTING );
	operationModeSetting &= ~0x0004;
	operationModeSetting |= (unsigned short)(opSel << 2);
	halWriteReg16( REG1000_OP_MODE_SETTING, operationModeSetting );
}

/*************************************************************************************
; Function:	get JPEG Operation Select
; Input:	n/a
; Output:	JPEGOpSel	Enc or decode
; Format:	JpegOpSel JpegOpSelGet( void )
;*************************************************************************************/
JpegOpSel JpegOpSelGet( void )
{
	unsigned short operationModeSetting = halReadReg16( REG1000_OP_MODE_SETTING );
	JpegOpSel opSel = (JpegOpSel)((operationModeSetting >> 2) & TRUE);
	return ( opSel );
}

/*************************************************************************************
; Function:	set YUV Format Select
; Input:	yuv format
; Output:	n/a
; Format:	void JpegYUVFmtSelSet( JpegYUVFmtSel yuvFmtSel )
;*************************************************************************************/
void JpegYUVFmtSelSet( JpegYUVFmtSel yuvFmtSel )
{
	unsigned short operationModeSetting = halReadReg16( REG1000_OP_MODE_SETTING );
	operationModeSetting &= (~0x0003);
	operationModeSetting |= (unsigned short)yuvFmtSel;
	halWriteReg16( REG1000_OP_MODE_SETTING, operationModeSetting );
}

/*************************************************************************************
; Function:	get YUV Format Select
; Input:	n/a
; Output:	yuvFmtSel
; Format:	JpegYUVFmtSel JpegYUVFmtSelGet( void )
;*************************************************************************************/
JpegYUVFmtSel JpegYUVFmtSelGet( void )
{
	unsigned short operationModeSetting = halReadReg16( REG1000_OP_MODE_SETTING );
	JpegYUVFmtSel yuvFmtSel = (JpegYUVFmtSel)(operationModeSetting & 0x0003);
	return ( yuvFmtSel );
}


/*************************************************************************************
; Function:	Jpeg Codec Command Set
; Input:	opEn	
;			swReset
; Output:	n/a
; Format:	void JpegCommandSetting( BOOL opEn, BOOL swReset, JENCODEINFO* pJEncodeInfo )
;*************************************************************************************/
void JpegCommandSetting( BOOL opEn, BOOL swReset, JENCODEINFO* pJEncodeInfo )
{
	unsigned short commandSetting = (unsigned short)(opEn | (swReset << 7));
	halWriteReg16( REG1002_COMMAND_SETTING, commandSetting );
	halDelayUS( pJEncodeInfo->Delay );
}

/*************************************************************************************
; Function:	set JPEG codec software reset status
; Input:	reset	TRUE means software reset will be done for JPEG codec
;					FALSE means softwware reset will NOT be done
; Output:	n/a
; Format:	void JpegCodecSWResetSet( BOOL reset )
;*************************************************************************************/
void JpegCodecSWResetSet( BOOL reset )
{
	unsigned short commandSetting = halReadReg16( REG1002_COMMAND_SETTING );
	commandSetting &= (~0x0080);
	commandSetting |= (unsigned short)(reset << 7);
	halWriteReg16( REG1002_COMMAND_SETTING, commandSetting );
}

/*************************************************************************************
; Function:	get JPEG codec software reset status
; Input:	n/a
; Out:		TRUE means software reset will be done for JPEG codec
;			FALSE means softwware reset will NOT be done
; Format:	BOOL JpegCodecSWResetGet( void )
;*************************************************************************************/
BOOL JpegCodecSWResetGet( void )
{
	unsigned short commandSetting = halReadReg16( REG1002_COMMAND_SETTING );
	BOOL reset = (BOOL)((commandSetting & 0x0080) >> 7);
	return ( reset );
}

/*************************************************************************************
; Function:	set JPEG Codec Operation Enable
; Input:	start
; Out:		n/a
; Format:	void JpegOpEnSet( BOOL start )
;*************************************************************************************/
void JpegOpEnSet( BOOL start )
{
	unsigned short commandSetting = halReadReg16( REG1002_COMMAND_SETTING );
	commandSetting &= (~TRUE);
	commandSetting |= (unsigned short)start;
	halWriteReg16( REG1002_COMMAND_SETTING, commandSetting );
}

/*************************************************************************************
; Function:	Get JPEG Operation Status
; Input:	n/a
; Output:	FALSE:	idle
;			TRUE:	work
; Format:	BOOL JpegOpStatusGet( void )
;*************************************************************************************/
BOOL JpegOpStatusGet( void )
{
	BOOL JPEGOpStatus = (BOOL)halReadReg16( REG1004_JPEG_OP_STATUS );
	return ( JPEGOpStatus );
}


/*************************************************************************************
; Function:	Set Jpeg Quantization Table Number register
; Input:	Color1 table / Color2 table / Color3 table
;				0 means use No.0 Table
;				1 means use No.1 Table
; Output:	n/a
; Format:	void JpegQuantTableNumSet( BOOL color1, BOOL color2, BOOL color3 )
;*************************************************************************************/
void JpegQuantTableNumSet( BOOL color1, BOOL color2, BOOL color3 )
{
	unsigned short quantTableNumber = color1 | (color2 << 1) | (color3 << 2);
	halWriteReg16( REG1006_QUANTIZATION_TABLE_NUM, quantTableNumber );
}

/*************************************************************************************
; Function:	Get Jpeg Quantization Table Number 
; Input:	color	color value
; Output:	0 means use No.0 Table
;			1 means use No.1 Table
; Format:	unsigned char JpegQuantTableNumGet( unsigned char color )
;*************************************************************************************/
unsigned char JpegQuantTableNumGet( unsigned char color )
{
	unsigned short quantTableNum = halReadReg16( REG1006_QUANTIZATION_TABLE_NUM );
	unsigned char table = (unsigned char)(quantTableNum >> (color - 1));
	table &= 0x01;
	++table;
	return ( table );
}

/*************************************************************************************
; Function:	Set the Jpeg Huffman Table Number register
; Input:	dcColor1 / acColor1 / dcColor2 / acColor2 / dcColor3 / acColor3
;				0 means use No.0 Table
;				1 means use No.1 Table
; Output:	n/a
; Format:	void JpegHuffmanTableNumSet( BOOL dcColor1,BOOL acColor1,BOOL dcColor2,BOOL acColor2,BOOL dcColor3,BOOL acColor3 )
;*************************************************************************************/
void JpegHuffmanTableNumSet( 	BOOL dcColor1,BOOL acColor1,
									BOOL dcColor2,BOOL acColor2,
									BOOL dcColor3,BOOL acColor3 )
{
	unsigned short huffmanTableNum = (unsigned short)(dcColor1 | (acColor1 << 1) | (dcColor2 << 2) | (acColor2 << 3) | (dcColor3 << 4) | (acColor3 << 5));
	halWriteReg16( REG1008_HUFFMAN_TABLE_NUM, huffmanTableNum );
}

/*************************************************************************************
; Function:	Get the Jpeg Huffman Table Number
; Input:	color	color value
;			ac		TRUE means AC table
;					FALSE means DC table
; Output:	0 means use No.0 Table
;			1 means use No.1 Table
; Format: 	unsigned char JpegHuffmanTableNumGet( unsigned char color, BOOL ac )
;*************************************************************************************/
unsigned char JpegHuffmanTableNumGet( unsigned char color, BOOL ac )
{
	unsigned short huffmanTableNum = halReadReg16( REG1008_HUFFMAN_TABLE_NUM );
	unsigned char table = (unsigned char)(huffmanTableNum >> ((color - 1) + ac));
	table &= 0x01;
	++table;
	return ( table );
}

/*************************************************************************************
; Function:	Set DRI setting
; Input:	minimumCodedUnit
; Output:	n/a
; Format:	void JpegDRISettingSet( unsigned short minimumCodedUnit )
;*************************************************************************************/
void JpegDRISettingSet( unsigned short minimumCodedUnit )
{
	unsigned char lsb = (unsigned char )(minimumCodedUnit & 0x00FF);
	unsigned char msb = (unsigned char)((minimumCodedUnit & 0xFF00) >> 8);
	halWriteReg16( REG100A_DRI_SETTING0, (unsigned short)msb );
	halWriteReg16( REG100C_DRI_SETTING1, (unsigned short)lsb );
}

/*************************************************************************************
; Function:	Get DRI setting
; Input:	n/a
; Output:	minimumCodedUnit
; Format:	unsigned short JpegDRISettingGet( void )
;*************************************************************************************/
unsigned short JpegDRISettingGet( void )
{
	unsigned char msb = (unsigned char)halReadReg16( REG100A_DRI_SETTING0 );
	unsigned char lsb = (unsigned char)halReadReg16( REG100C_DRI_SETTING1 );
	unsigned short minimumCodedUnit = (unsigned short)((msb << 8) | lsb);
	return ( minimumCodedUnit );
}

/*************************************************************************************
; Function:	set vertical pixel size (encode only)
; Input:	verticalPixelSize
; Output:	n/a
; Format:	void JpegVertPixelSizeSet( unsigned short verticalPixelSize )
;*************************************************************************************/
void JpegVertPixelSizeSet( unsigned short verticalPixelSize )
{
	unsigned char lsb = (unsigned char)(verticalPixelSize & 0x00FF);
	unsigned char msb = (unsigned char)((verticalPixelSize & 0xFF00) >> 8);
	halWriteReg16( REG100E_VERTICAL_PIXEL_SIZE0, (unsigned short)msb );
	halWriteReg16( REG1010_VERTICAL_PIXEL_SIZE1, (unsigned short)lsb );
}

/*************************************************************************************
; Function:	get vertical pixel size
; Input:	n/a
; Output:	vertical pixel size
; Format:	unsigned short JpegVertPixelSizeGet( void )
;*************************************************************************************/
unsigned short JpegVertPixelSizeGet( void )

⌨️ 快捷键说明

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