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

📄 osd.c

📁 TECHWELL 之tw2835 四画面合一之驱动代码,CCIR656输出,KEIL C51 平台编译,
💻 C
📖 第 1 页 / 共 3 页
字号:
#include	"hdr.h"
//#include	"osd.h"

#include	"tbl_osd.h"
#include	"tbl_str.h"

//==================================================================================
//						OSD function description
//==================================================================================
/*
//void WriteOSDBmpX(U8 _dvc, U8 _pos_x, U16 _pos_y, U8 _prp, U8 _indx, U8 code *_bmp_ptr)
//{
////	U8 _wdat_;
////	U8 _t1_;
//	U8 _wdth_, _num_h_, _num_v_;
//	U16 _hght_, _ofst_indx_, _ofst_v_;
//	
//#if	defined(__EN_ISR__)
////	EA = 0;
//#endif
//
////	_hght_ = ((_bmp_ptr[OSD_TBL_V_SZ_MSB]<<8)+_bmp_ptr[OSD_TBL_V_SZ_LSB])>>_bmp_ptr[OSD_TBL_RSLTN];
////... if(_bmp_ptr[OSD_TBL_RSLTN]==0)	field resolution, else	frame resolution
//	_hght_ = (_bmp_ptr[OSD_TBL_V_SZ_MSB]<<8)+_bmp_ptr[OSD_TBL_V_SZ_LSB];
////	_wdth_ = _bmp_ptr[OSD_TBL_H_SZ];
//	
//	_ofst_indx_ = (_bmp_ptr[OSD_TBL_H_SZ]*_hght_)*_bmp_ptr[OSD_TBL_CLMN];
//	_ofst_indx_ = _ofst_indx_*(_indx/_bmp_ptr[OSD_TBL_CLMN]);		//... data size of one index row (= (one bitmap icon size)*column)
//	_ofst_indx_ = _ofst_indx_+((_indx%_bmp_ptr[OSD_TBL_CLMN])*_bmp_ptr[OSD_TBL_H_SZ]);	//... add array_index to offset for 1 index column
//
////	_wdth_ = _bmp_ptr[OSD_TBL_H_SZ]>>2;							//... horizontal size / 4(pixels)
//
//	WriteAsicByteOSD(_dvc,0x06,0x00);
//	WriteAsicByteOSD(_dvc,0x08,0x00);
//
//	for(_num_v_=0;_num_v_<_hght_;_num_v_+=(1<<_bmp_ptr[OSD_TBL_RSLTN])){	//... if(_bmp_ptr[OSD_TBL_RSLTN]==0)	field resolution, else	frame resolution
//		
//		for(_num_h_=0;_num_h_<_bmp_ptr[OSD_TBL_H_SZ];_num_h_+=4){
//			_ofst_v_ = _num_v_*(_bmp_ptr[OSD_TBL_H_SZ]*_bmp_ptr[OSD_TBL_CLMN]);	// _num_v_ * 32;	// 
//
////			_wdat_ = _bmp_ptr[_ofst_indx_+_ofst_v_+_num_h_];
//
//			WriteAsicByteOSD(_dvc,0x00,_prp|_bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_]);						//... 1st pixel
//			WriteAsicByteOSD(_dvc,0x01,_prp|_bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_+1]);					//... 2nd pixel
//			WriteAsicByteOSD(_dvc,0x02,_prp|_bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_+2]);					//... 3rd pixel
//			WriteAsicByteOSD(_dvc,0x03,_prp|_bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_+3]);					//... 4th pixel
//			
//	//... acceleration 阑 荤侩且 版快 buffer write 苞沥 积帆啊瓷.
//			WriteAsicByteOSD(_dvc,0x04,0x80);					//... write to buffer
//			
//			WriteAsicByteOSD(_dvc,0x05,_pos_x+_num_h_);
////			WriteAsicByteOSD(_dvc,0x06,_pos_x+_num_h_);
//			
//			WriteAsicByteOSD(_dvc,0x07,(_pos_y+_num_v_)&0xff);
////			WriteAsicByteOSD(_dvc,0x08,(_pos_y+_num_v_)&0xff);
////			WriteAsicByteOSD(_dvc,0x09,(((_pos_y+_num_v_)>>8)<<2)+((_pos_y+_num_v_)>>8));
//			WriteAsicByteOSD(_dvc,0x09,((_pos_y+_num_v_)>>8)<<2);
//
////			WriteAsicByteOSD(_dvc,0x0a,0xc0);					//... x path
//			WriteAsicByteOSD(_dvc,0x0a,0x80);					//... x path
//			while(ReadAsicOSDMemWr(_dvc)&BIT7);								//... wait finishing write for odd field
//
//			if(_bmp_ptr[OSD_TBL_RSLTN]){
//				_ofst_v_ = (_num_v_+1)*(_bmp_ptr[OSD_TBL_H_SZ]*_bmp_ptr[OSD_TBL_CLMN]);	// _num_v_ * 32;	// 
//				
//				WriteAsicByteOSD(_dvc,0x00,_prp|_bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_]);	//... 1st pixel
//				WriteAsicByteOSD(_dvc,0x01,_prp|_bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_+1]);	//... 2nd pixel
//				WriteAsicByteOSD(_dvc,0x02,_prp|_bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_+2]);	//... 3rd pixel
//				WriteAsicByteOSD(_dvc,0x03,_prp|_bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_+3]);	//... 4th pixel
//			
//		//... acceleration 阑 荤侩且 版快 buffer write 苞沥 积帆啊瓷.
//				WriteAsicByteOSD(_dvc,0x04,0x80);					//... write to buffer
//				
//				WriteAsicByteOSD(_dvc,0x05,_pos_x+_num_h_);
//	//			WriteAsicByteOSD(_dvc,0x06,_pos_x+_num_h_);
//				
//				WriteAsicByteOSD(_dvc,0x07,(_pos_y+_num_v_)&0xff);
//	//			WriteAsicByteOSD(_dvc,0x08,(_pos_y+_num_v_)&0xff);
//	//			WriteAsicByteOSD(_dvc,0x09,0x0a|((((_pos_y+_num_v_)>>8)<<2)+((_pos_y+_num_v_)>>8)));
//				WriteAsicByteOSD(_dvc,0x09,0x0a|(((_pos_y+_num_v_)>>8)<<2));
//	
//	//			WriteAsicByteOSD(_dvc,0x0a,0xc0);					//... x path
//				WriteAsicByteOSD(_dvc,0x0a,0x80);					//... x path
//				while(ReadAsicOSDMemWr(_dvc)&BIT7);								//... wait finishing write for even field
//			}
//		}
//	}
//
//#if	defined(__EN_ISR__)
////	EA = 1;
//#endif
//}
//==================================================================================
void WriteOSDBmpX(U8 _dvc, U8 _pos_x, U16 _pos_y, U8 _prp, U8 _indx, U8 code *_bmp_ptr)	//... 180(4 pixel/_pos_x) x 240/288 domain
{
	U8 _wdat_;
	U8 _t1_;
	U8 _wdth_, _num_h_, _num_v_;
	U16 _hght_, _ofst_indx_, _ofst_v_;
	
#if	defined(__EN_ISR__)
//	EA = 0;
#endif

//	_hght_ = ((_bmp_ptr[OSD_TBL_V_SZ_MSB]<<8)+_bmp_ptr[OSD_TBL_V_SZ_LSB])>>_bmp_ptr[OSD_TBL_RSLTN];
//... if(_bmp_ptr[OSD_TBL_RSLTN]==0)	field resolution, else	frame resolution
//	_hght_ = ((_bmp_ptr[OSD_TBL_V_SZ_MSB]<<8)+_bmp_ptr[OSD_TBL_V_SZ_LSB])<<_bmp_ptr[OSD_TBL_RSLTN];
	_hght_ = (_bmp_ptr[OSD_TBL_V_SZ_MSB]<<8)+_bmp_ptr[OSD_TBL_V_SZ_LSB];
	_wdth_ = _bmp_ptr[OSD_TBL_H_SZ]>>2;							//... for old table which 1 byte has 4 pixel info.
	
	_ofst_indx_ = (_wdth_*_hght_)*_bmp_ptr[OSD_TBL_CLMN];
	_ofst_indx_ = _ofst_indx_*(_indx/_bmp_ptr[OSD_TBL_CLMN]);		//... data size of one index row (= (one bitmap icon size)*column)
	_ofst_indx_ = _ofst_indx_+((_indx%_bmp_ptr[OSD_TBL_CLMN])*_wdth_);	//... add array_index to offset for 1 index column

//	_wdth_ = _bmp_ptr[OSD_TBL_H_SZ]>>2;							//... horizontal size / 4(pixels)

	WriteAsicByteOSD(_dvc,0x06,0x00);
	WriteAsicByteOSD(_dvc,0x08,0x00);

	for(_num_v_=0;_num_v_<_hght_;_num_v_+=(1<<_bmp_ptr[OSD_TBL_RSLTN])){	//... if(_bmp_ptr[OSD_TBL_RSLTN]==0)	field resolution, else	frame resolution
		
		for(_num_h_=0;_num_h_<_wdth_;_num_h_++){
			_ofst_v_ = _num_v_*(_wdth_*_bmp_ptr[OSD_TBL_CLMN]);	// _num_v_ * 32;	// 

			_wdat_ = _bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_];

			_t1_ = (_wdat_&0xc0)>>6;
			if(!_t1_)	_t1_ = 0xff;
			WriteAsicByteOSD(_dvc,0x00,_prp|_t1_);					//... 1st pixel
			_t1_ = (_wdat_&0x30)>>4;
			if(!_t1_)	_t1_ = 0xff;
			WriteAsicByteOSD(_dvc,0x01,_prp|_t1_);					//... 2nd pixel
			_t1_ = (_wdat_&0xc)>>2;
			if(!_t1_)	_t1_ = 0xff;
			WriteAsicByteOSD(_dvc,0x02,_prp|_t1_);					//... 3rd pixel
			_t1_ = _wdat_&0x3;
			if(!_t1_)	_t1_ = 0xff;
			WriteAsicByteOSD(_dvc,0x03,_prp|_t1_);					//... 4th pixel
			
	//... acceleration 阑 荤侩且 版快 buffer write 苞沥 积帆啊瓷.
			WriteAsicByteOSD(_dvc,0x04,0x80);					//... write to buffer
			
			WriteAsicByteOSD(_dvc,0x05,_pos_x+_num_h_);
//			WriteAsicByteOSD(_dvc,0x06,_pos_x+_num_h_);
			
			WriteAsicByteOSD(_dvc,0x07,(_pos_y+(_num_v_>>1))&0xff);
//			WriteAsicByteOSD(_dvc,0x08,(_pos_y+_num_v_)&0xff);
//			WriteAsicByteOSD(_dvc,0x09,(((_pos_y+_num_v_)>>8)<<2)+((_pos_y+_num_v_)>>8));
			WriteAsicByteOSD(_dvc,0x09,((_pos_y+(_num_v_>>1))>>8)<<2);

//			WriteAsicByteOSD(_dvc,0x0a,0xc0);					//... x path
			WriteAsicByteOSD(_dvc,0x0a,0x80);					//... x path
			while(ReadAsicOSDMemWr(_dvc)&BIT7);								//... wait finishing write for odd field


			if(_bmp_ptr[OSD_TBL_RSLTN]){
				_ofst_v_ = (_num_v_+1)*(_wdth_*_bmp_ptr[OSD_TBL_CLMN]);	// _num_v_ * 32;	// 

				_wdat_ = _bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_];
	//			_wdat_ = tbl_osd_tmp_even[_ofst_indx_+_ofst_v_+_num_h_];
				
				_t1_ = (_wdat_&0xc0)>>6;
				if(!_t1_)	_t1_ = 0xff;
				WriteAsicByteOSD(_dvc,0x00,_prp|_t1_);					//... 1st pixel
				_t1_ = (_wdat_&0x30)>>4;
				if(!_t1_)	_t1_ = 0xff;
				WriteAsicByteOSD(_dvc,0x01,_prp|_t1_);					//... 2nd pixel
				_t1_ = (_wdat_&0xc)>>2;
				if(!_t1_)	_t1_ = 0xff;
				WriteAsicByteOSD(_dvc,0x02,_prp|_t1_);					//... 3rd pixel
				_t1_ = _wdat_&0x3;
				if(!_t1_)	_t1_ = 0xff;
				WriteAsicByteOSD(_dvc,0x03,_prp|_t1_);					//... 4th pixel
				
		//... acceleration 阑 荤侩且 版快 buffer write 苞沥 积帆啊瓷.
				WriteAsicByteOSD(_dvc,0x04,0x80);					//... write to buffer
				
				WriteAsicByteOSD(_dvc,0x05,_pos_x+_num_h_);
	//			WriteAsicByteOSD(_dvc,0x06,_pos_x+_num_h_);
				
				WriteAsicByteOSD(_dvc,0x07,(_pos_y+(_num_v_>>1))&0xff);
	//			WriteAsicByteOSD(_dvc,0x08,(_pos_y+_num_v_)&0xff);
	//			WriteAsicByteOSD(_dvc,0x09,0x0a|((((_pos_y+_num_v_)>>8)<<2)+((_pos_y+_num_v_)>>8)));
				WriteAsicByteOSD(_dvc,0x09,0x0a|(((_pos_y+(_num_v_>>1))>>8)<<2));
	
	//			WriteAsicByteOSD(_dvc,0x0a,0xc0);					//... x path
				WriteAsicByteOSD(_dvc,0x0a,0x80);					//... x path
				while(ReadAsicOSDMemWr(_dvc)&BIT7);								//... wait finishing write for even field
			}
		}
	}

#if	defined(__EN_ISR__)
//	EA = 1;
#endif
}
//	*/
//==================================================================================
void WriteOSDBmpY(U8 _dvc, U8 _pos_x, U16 _pos_y, U8 _prp, U8 _indx, U8 code *_bmp_ptr)	//... 90(8 pixel/_pos_x) x 240/288 domain
{
	U8 _wdat_;
	U8 _t1_;
	U8 _wdth_, _num_h_, _num_v_;
	U16 _hght_, _ofst_indx_, _ofst_v_;
	
#if	defined(__EN_ISR__)
//	EA = 0;
#endif

	_prp |= _prp>>4;

//	_hght_ = ((_bmp_ptr[OSD_TBL_V_SZ_MSB]<<8)+_bmp_ptr[OSD_TBL_V_SZ_LSB])>>_bmp_ptr[OSD_TBL_RSLTN];
//... if(_bmp_ptr[OSD_TBL_RSLTN]==0)	field resolution, else	frame resolution
//	_hght_ = ((_bmp_ptr[OSD_TBL_V_SZ_MSB]<<8)+_bmp_ptr[OSD_TBL_V_SZ_LSB])<<_bmp_ptr[OSD_TBL_RSLTN];
	_hght_ = (_bmp_ptr[OSD_TBL_V_SZ_MSB]<<8)+_bmp_ptr[OSD_TBL_V_SZ_LSB];
	_wdth_ = _bmp_ptr[OSD_TBL_H_SZ]>>2;							//... for old table which 1 byte has 4 pixel info.
	
	_ofst_indx_ = (_wdth_*_hght_)*_bmp_ptr[OSD_TBL_CLMN];
	_ofst_indx_ = _ofst_indx_*(_indx/_bmp_ptr[OSD_TBL_CLMN]);		//... data size of one index row (= (one bitmap icon size)*column)
	_ofst_indx_ = _ofst_indx_+((_indx%_bmp_ptr[OSD_TBL_CLMN])*_wdth_);	//... add array_index to offset for 1 index column

//	_wdth_ = _bmp_ptr[OSD_TBL_H_SZ]>>2;							//... horizontal size / 4(pixels)

	WriteAsicByteOSD(_dvc,0x06,0x00);
	WriteAsicByteOSD(_dvc,0x08,0x00);

	for(_num_v_=0;_num_v_<_hght_;_num_v_+=(1<<_bmp_ptr[OSD_TBL_RSLTN])){	//... if(_bmp_ptr[OSD_TBL_RSLTN]==0)	field resolution, else	frame resolution
		
		for(_num_h_=0;_num_h_<_wdth_;_num_h_+=2){
			_ofst_v_ = _num_v_*(_wdth_*_bmp_ptr[OSD_TBL_CLMN]);	// _num_v_ * 32;	// 

			_wdat_ = _bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_];

//			_t1_ = (_wdat_&0xc0)>>6;
//			if(!_t1_)	_t1_ = 0xff;
//			WriteAsicByteOSD(_dvc,0x00,_prp|_t1_);					//... 1st pixel
//			_t1_ = (_wdat_&0x30)>>4;
//			if(!_t1_)	_t1_ = 0xff;
//			WriteAsicByteOSD(_dvc,0x01,_prp|_t1_);					//... 2nd pixel
//			_t1_ = (_wdat_&0xc)>>2;
//			if(!_t1_)	_t1_ = 0xff;
//			WriteAsicByteOSD(_dvc,0x02,_prp|_t1_);					//... 3rd pixel
//			_t1_ = _wdat_&0x3;
//			if(!_t1_)	_t1_ = 0xff;
//			WriteAsicByteOSD(_dvc,0x03,_prp|_t1_);					//... 4th pixel
//
//			_wdat_ = tbl_osd_16x20_odd[_ofst_indx_+_ofst_v_+_num_h_];

			_t1_ = ((_wdat_&0xc0)>>2)+((_wdat_&0x30)>>4);
			if(!(_t1_&0x30))	_t1_ |= 0xf0;
			if(!(_t1_&0x03))	_t1_ |= 0x0f;
			WriteAsicByteOSD(_dvc,0x00,_prp|_t1_);					//... 1st, 2nd pixel
			_t1_ = ((_wdat_&0x0c)<<2)+(_wdat_&0x03);
			if(!(_t1_&0x30))	_t1_ |= 0xf0;
			if(!(_t1_&0x03))	_t1_ |= 0x0f;
			WriteAsicByteOSD(_dvc,0x01,_prp|_t1_);					//... 3rd, 4th pixel

//			_wdat_ = tbl_osd_16x20_odd[_ofst_indx_+_ofst_v_+_num_h_+1];
			_wdat_ = _bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_+1];

			_t1_ = ((_wdat_&0xc0)>>2)+((_wdat_&0x30)>>4);
			if(!(_t1_&0x30))	_t1_ |= 0xf0;
			if(!(_t1_&0x03))	_t1_ |= 0x0f;
			WriteAsicByteOSD(_dvc,0x02,_prp|_t1_);					//... 5th, 6th pixel
			_t1_ = ((_wdat_&0x0c)<<2)+(_wdat_&0x03);
			if(!(_t1_&0x30))	_t1_ |= 0xf0;
			if(!(_t1_&0x03))	_t1_ |= 0x0f;
			WriteAsicByteOSD(_dvc,0x03,_prp|_t1_);					//... 7th, 8th pixel
			
			
	//... acceleration 阑 荤侩且 版快 buffer write 苞沥 积帆啊瓷.
			WriteAsicByteOSD(_dvc,0x04,0x80);					//... write to buffer
			
			WriteAsicByteOSD(_dvc,0x05,_pos_x+(_num_h_>>1));
//			WriteAsicByteOSD(_dvc,0x06,_pos_x+_num_h_);
			
			WriteAsicByteOSD(_dvc,0x07,(_pos_y+(_num_v_>>1))&0xff);
//			WriteAsicByteOSD(_dvc,0x08,(_pos_y+_num_v_)&0xff);
//			WriteAsicByteOSD(_dvc,0x09,(((_pos_y+_num_v_)>>8)<<2)+((_pos_y+_num_v_)>>8));
			WriteAsicByteOSD(_dvc,0x09,((_pos_y+(_num_v_>>1))>>8)<<2);

//			WriteAsicByteOSD(_dvc,0x0a,0xe0);					//... y path
			WriteAsicByteOSD(_dvc,0x0a,0xa0);					//... y path
			while(ReadAsicOSDMemWr(_dvc)&BIT7);								//... wait finishing write for odd field


			if(_bmp_ptr[OSD_TBL_RSLTN]){
				_ofst_v_ = (_num_v_+1)*(_wdth_*_bmp_ptr[OSD_TBL_CLMN]);	// _num_v_ * 32;	// 

				_wdat_ = _bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_];
	//			_wdat_ = tbl_osd_tmp_even[_ofst_indx_+_ofst_v_+_num_h_];
				
//				_t1_ = (_wdat_&0xc0)>>6;
//				if(!_t1_)	_t1_ = 0xff;
//				WriteAsicByteOSD(_dvc,0x00,_prp|_t1_);					//... 1st pixel
//				_t1_ = (_wdat_&0x30)>>4;
//				if(!_t1_)	_t1_ = 0xff;
//				WriteAsicByteOSD(_dvc,0x01,_prp|_t1_);					//... 2nd pixel
//				_t1_ = (_wdat_&0xc)>>2;
//				if(!_t1_)	_t1_ = 0xff;
//				WriteAsicByteOSD(_dvc,0x02,_prp|_t1_);					//... 3rd pixel
//				_t1_ = _wdat_&0x3;
//				if(!_t1_)	_t1_ = 0xff;
//				WriteAsicByteOSD(_dvc,0x03,_prp|_t1_);					//... 4th pixel

			_t1_ = ((_wdat_&0xc0)>>2)+((_wdat_&0x30)>>4);
			if(!(_t1_&0x30))	_t1_ |= 0xf0;
			if(!(_t1_&0x03))	_t1_ |= 0x0f;
			WriteAsicByteOSD(_dvc,0x00,_prp|_t1_);					//... 1st, 2nd pixel
			_t1_ = ((_wdat_&0x0c)<<2)+(_wdat_&0x03);
			if(!(_t1_&0x30))	_t1_ |= 0xf0;
			if(!(_t1_&0x03))	_t1_ |= 0x0f;
			WriteAsicByteOSD(_dvc,0x01,_prp|_t1_);					//... 3rd, 4th pixel

//			_wdat_ = tbl_osd_16x20_odd[_ofst_indx_+_ofst_v_+_num_h_+1];
			_wdat_ = _bmp_ptr[5+_ofst_indx_+_ofst_v_+_num_h_+1];

			_t1_ = ((_wdat_&0xc0)>>2)+((_wdat_&0x30)>>4);
			if(!(_t1_&0x30))	_t1_ |= 0xf0;
			if(!(_t1_&0x03))	_t1_ |= 0x0f;
			WriteAsicByteOSD(_dvc,0x02,_prp|_t1_);					//... 5th, 6th pixel
			_t1_ = ((_wdat_&0x0c)<<2)+(_wdat_&0x03);
			if(!(_t1_&0x30))	_t1_ |= 0xf0;
			if(!(_t1_&0x03))	_t1_ |= 0x0f;
			WriteAsicByteOSD(_dvc,0x03,_prp|_t1_);					//... 7th, 8th pixel
			
		//... acceleration 阑 荤侩且 版快 buffer write 苞沥 积帆啊瓷.
				WriteAsicByteOSD(_dvc,0x04,0x80);					//... write to buffer
				

⌨️ 快捷键说明

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