?? viporfunc.c
字號:
#ifdef _WINDVD#ifdef VP_API_CT909 #include "..\Hio.H"#endif#ifdef VP_API_CT909P #include "..\Hio.H"#endifextern void _printf(char *fmt, ...);#else #include "defs.H"#endif#ifdef VP_API_CT909//BYTE _REG[26];BYTE gbTrmBuf[17];#endif#ifdef VP_API_CT909P//BYTE _REG[26];BYTE gbTrmBuf[17];#endif#include "Viporregtable_CT675.h"#include "ViporVariable.h"#include "Vipor_API.h"#include "ViporFunc.h"#ifdef VP_API_CT908#include "Vipor_iic908.h"#endif#ifdef VP_API_CT909#include "Vipor_iic909.h"#endif#ifdef VP_API_CT909P#include "Vipor_iic909P.h"#endifBYTE u8VideoHue;BYTE u8VideoContrast;BYTE u8VideoSaturation;//#define sRGB_HDTV//#define sRGB_SDTV_Computer#ifdef SetPicture_ALLBYTE Temperature_Adjust[][3] =#elseBYTE code Temperature_Adjust[][3] =#endif{ { 0x80, 0x80, 0x80 }, //R G B Gain 0 ... 128 ... 255 { 0x80, 0x80, 0x80 } //R G B Offset 0 ... 128 ... 255}; //DWORD __dwVersionTFT;#define TFT_SW_VERSION (112L)#define TFT_PANEL_VERSION (0)#define TFT_PANEL_MINOR_VERSION (0)extern DWORD __dwVersionTFT; extern WORD ViporSin(BYTE bval); extern WORD ViporCos(BYTE bval);extern WORD VPAddSize(WORD para1,WORD para2);#ifdef VP_API_CT909BYTE gbTrmBuf[17];#endifWORD wval;BYTE Vipor_BATTERY_State (void){ Vipor_SC_Write_Byte(0x07,Vipor_SC_Read_Byte(0x07) & 0xF7); //Enable SAR Vipor_SC_Write_Byte(0x0E,Vipor_SC_Read_Byte(0x0E) & 0x08); //Disable SAR Trigger Enable select ADC0 Vipor_SC_Write_Byte(0x0E,Vipor_SC_Read_Byte(0x0E)|0x04); //Enable SAR Trigger if (Vipor_SC_Read_Byte(0x0E) && 0x08) //Check if Filish return Vipor_SC_Read_Byte(0x0F); else return 0; }//set CVBS(video format)'s videomode PALvoid Vipor_SetVideo_CVBS_PAL(void){ Vipor_WriteRegister(Vipor_CVBS_PAL_Register); SoftResetMvdSync();}//set CVBS(video format)'s videomode NTSCvoid Vipor_SetVideo_CVBS_NTSC(void){ printf("CVBS_NTSC"); Vipor_WriteRegister(Vipor_CVBS_NTSC_Register); SoftResetMvdSync();}//set SVIDEO(video format)'s videomode PALvoid Vipor_SetVideo_SVIDEO_PAL(void){ Vipor_WriteRegister(Vipor_SVIDEO_PAL_Register); SoftResetMvdSync();}//set SVIDEO(video format)'s videomode NTSCvoid Vipor_SetVideo_SVIDEO_NTSC(void){ Vipor_WriteRegister(Vipor_SVIDEO_NTSC_Register); //Jeff 20060313 modify SoftResetMvdSync();}//Set video aspect ratio 4:3void Vipor_SetAspect_4_3(void){ Vipor_WriteRegister(Vipor_4_3_Register);}//Set video aspect ratio 16:9 void Vipor_SetAspect_16_9(void){ Vipor_WriteRegister(Vipor_16_9_Register);}void Vipor_SetAspect_4_3_CVBS(void){ Vipor_WriteRegister(Vipor_CVBS_4_3_Register);}//Set video aspect ratio 16:9 void Vipor_SetAspect_16_9_CVBS(void){ Vipor_WriteRegister(Vipor_CVBS_16_9_Register);}//Set picture Brightness//bBriValue: brightness valueBYTE code Vipor_BrightnessXferTable[]=// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15{0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70 ,0x7F };// -8 -7 -6 -5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7#ifdef VP_API_CT908#pragma NOAREGS //may be called by ISR // KCHong, 20060717#endifvoid Vipor_SetPicture_Brightness(BYTE bBriValue){ //printf("Brightness = %hx\n",Vipor_BrightnessXferTable[bBriValue >> 4]); Vipor_SC_Write_Byte(0xE1, Vipor_BrightnessXferTable[bBriValue >> 4]);}//Set picture Contrast#ifdef VP_API_CT908#pragma NOAREGS //may be called by ISR // KCHong, 20060717#endif //may be called by ISR // KCHong, 20060717void Vipor_SetPicture_Contrast(BYTE bConValue){ u8VideoHue = 128; u8VideoContrast = bConValue; ViporBCAdjust();}#ifdef SetPicture_ALL#ifdef VP_API_CT908#pragma NOAREGS //may be called by ISR // KCHong, 20060717#endifvoid Vipor_SetPicture_ALL(void){ extern BYTE _bLEVEL_TABLE[]; Vipor_SC_Write_Byte(0xE1, _bLEVEL_TABLE[0]); u8VideoContrast = _bLEVEL_TABLE[1]; u8VideoHue = _bLEVEL_TABLE[2]; u8VideoSaturation = _bLEVEL_TABLE[3]; Temperature_Adjust[0][0] = _bLEVEL_TABLE[4]; Temperature_Adjust[0][1] = _bLEVEL_TABLE[5]; Temperature_Adjust[0][2] = _bLEVEL_TABLE[6]; Temperature_Adjust[1][0] = _bLEVEL_TABLE[7]; Temperature_Adjust[1][1] = _bLEVEL_TABLE[8]; Temperature_Adjust[1][2] = _bLEVEL_TABLE[9]; ViporBCAdjust();}#endif //SetPicture_ALL#ifdef VP_API_CT908#pragma NOAREGS //may be called by ISR // KCHong, 20060717#endif //may be called by ISR // KCHong, 20060717void Vipor_SetPicture_Saturation(BYTE bSatValue){ u8VideoHue = 128; u8VideoSaturation = bSatValue; ViporBCAdjust();}//judge NTSC(video mode) color if Burst\locked//output: TRUE\FALSEBOOL Vipor_NTSC_GetColorBurstLocked(void){#define fNoColorBurst __bViporTemp5// BOOL fNoColorBurst; fNoColorBurst = Vipor_VD_Read_Byte(0x3B) & 0x08; if((Vipor_VD_Read_Byte(0x3A) & 0x08) == 0x08) { return TRUE; // Video Color Locked } if(fNoColorBurst) { gbTrmBuf[0] = Vipor_VD_Read_Byte(0x00); Vipor_VD_Write_Byte(0x00, (gbTrmBuf[0] & 0x01)); Vipor_VD_Write_Byte(0x03, 0x00); Vipor_WriteRegister(rVideoReg18_60[0]); return TRUE; } return FALSE;#undef fNoColorBurst}//for NTSC(video mode) subsystem//bVideoSubSystem: NTSC_M, PAL_443, NTSC_443,void Vipor_NTSC_VideoSubSystem(BYTE bVideoSubSystem){ Vipor_VD_Write_Byte(0xB2, 0x40); Vipor_WriteRegister(rVideoReg18_60[bVideoSubSystem]); gbTrmBuf[0] = Vipor_VD_Read_Byte(0x00); switch( bVideoSubSystem ) { case 1: // PAL 4.43 - 60Hz Vipor_VD_Write_Byte(0x00, gbTrmBuf[0]|0x04); Vipor_VD_Write_Byte(0x03, 0x1E); break; case 2: // NTSC 4.43 - 60Hz Vipor_VD_Write_Byte(0x00,gbTrmBuf[0]&0x01); Vipor_VD_Write_Byte(0x03,0x86); break; case 0: // NTSC M default: Vipor_VD_Write_Byte(0x00,gbTrmBuf[0]&0x01); Vipor_VD_Write_Byte(0x03,0x00); break; }}//judge PAL(video mode) color if Burst\locked//output: TRUE\FALSEBOOL Vipor_PAL_GetColorBurstLocked(BYTE bVideoSubSystem){#define fNoColorBurst2 __bViporTemp6// BOOL fNoColorBurst; fNoColorBurst2 = Vipor_VD_Read_Byte(0x3B) & 0x08; gbTrmBuf[0] = Vipor_VD_Read_Byte(0x3C); if(bVideoSubSystem <= 1) // 0 for PAL-B,G,D,K,I,N 1 for PAL-CN { if((gbTrmBuf[0] & 0x05) == 0x05) return TRUE; } else // (bVideoSubSystem == 2) { if((gbTrmBuf[0] & 0x07) == 0x06) return TRUE; } if(fNoColorBurst2) { gbTrmBuf[0] = (Vipor_VD_Read_Byte(0x00) & 0x01) | 0x32; Vipor_VD_Write_Byte(0x00, gbTrmBuf[0]); gbTrmBuf[0] = (Vipor_VD_Read_Byte(0x01) & 0x40) | 0x88; Vipor_VD_Write_Byte(0x01, gbTrmBuf[0]); Vipor_VD_Write_Byte(0x2C, 0x32); Vipor_VD_Write_Byte(0x2D, 0x46); Vipor_VD_Write_Byte(0x2E,0x90); Vipor_WriteRegister(rVideoReg18_50[0]); return TRUE; } return FALSE;#undef fNoColorBurst2 }//for PAL(video mode) subsystem//bVideoSubSystem: PAL_BGDHI, PAL_N, SECAMvoid Vipor_PAL_VideoSubSystem(BYTE bVideoSubSystem){ Vipor_VD_Write_Byte(0xB2, 0x40); Vipor_WriteRegister(rVideoReg18_50[bVideoSubSystem]); gbTrmBuf[0] = Vipor_VD_Read_Byte(0x00); gbTrmBuf[1] = Vipor_VD_Read_Byte(0x01); switch( bVideoSubSystem ) { case 1: // PAL N Vipor_VD_Write_Byte(0x00, (gbTrmBuf[0] | 0x36)); Vipor_VD_Write_Byte(0x01, (gbTrmBuf[1] & 0xFE)); Vipor_VD_Write_Byte(0x2C, 0x32); Vipor_VD_Write_Byte(0x2D, 0x46); Vipor_VD_Write_Byte(0x2E, 0x90); Vipor_VD_Write_Byte(0xB5, 0x80); break; case 2: // SECAM Vipor_VD_Write_Byte(0x00, (gbTrmBuf[0] | 0x38)); Vipor_VD_Write_Byte(0x01, ((gbTrmBuf[1] & 0x40) | 0x03)); Vipor_VD_Write_Byte(0x2C, 0x32); Vipor_VD_Write_Byte(0x2D, 0x6E); Vipor_VD_Write_Byte(0x2E, 0x90); Vipor_VD_Write_Byte(0xB5, 0x03); break; case 0: // PAL BGDHI default: Vipor_VD_Write_Byte(0x00, (gbTrmBuf[0] | 0x32)); Vipor_VD_Write_Byte(0x01, ((gbTrmBuf[1] & 0x40) | 0x08)); Vipor_VD_Write_Byte(0x2C, 0x32); Vipor_VD_Write_Byte(0x2D, 0x46); Vipor_VD_Write_Byte(0x2E, 0x90); Vipor_VD_Write_Byte(0xB5, 0x80); break; }}//judge video if locked//output: TRUE/FALSEBYTE Vipor_GetVideoLocked(void){
gbTrmBuf[0] = Vipor_VD_Read_Byte(0x10); // 0x10 MVD_STATUS0
// 1xx0xxxx bit7=1-->Hsync Lock , bit4=0-->Signal Lock
if ((gbTrmBuf[0] & 0x90) == 0x80) return TRUE; // Locked
else return FALSE; // Unlock}//get video mode//output: EN_VID_MODE_PAL/EN_VID_MODE_NTSCBYTE Vipor_GetVideoMode(void){ gbTrmBuf[0] = Vipor_VD_Read_Byte(0x10); // 0x10 MVD_STATUS0
if ((gbTrmBuf[0] & 0x07) == 0x02) return EN_VID_MODE_PAL;
else return EN_VID_MODE_NTSC;}void Vipor_SetPowerDown(void){#define u8Value __bViporTemp6 printf("Vipor_SetPowerDown"); u8Value = Vipor_SC_Read_Byte(0x07) | 0x10; VP_IIC_Write(0xF4, 0x07, u8Value);// VP_IIC_Write(0xF4, 0x28, 0x04);// VP_IIC_Write(0xF4, 0x25, 0x04); #undef u8Value } void Vipor_SetPowerON(void){#define u8Value __bViporTemp6 printf("Vipor_SetPowerON"); u8Value = Vipor_SC_Read_Byte(0x07) & 0xEF; VP_IIC_Write(0xF4, 0x07, u8Value);// VP_IIC_Write(0xF4, 0x28, 0x04);// VP_IIC_Write(0xF4, 0x25, 0x04);#undef u8Value } #ifdef LED_BackLight#ifdef VP_API_CT908#pragma NOAREGS#endifvoid Vipor_SetBlackLight_ON(void){ printf("BackLight_ON\n"); Vipor_WriteRegister(Vipor_LED_BackLight_ON);}#ifdef VP_API_CT908#pragma NOAREGS#endifvoid Vipor_SetBlackLight_OFF(void){ printf("BackLight_OFF\n");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -