📄 video_test.c
字号:
#include "davincievm_i2c.h"
#include "davincievm.h"
#define TVP5150_I2C_ADDR 0x5C
Uint16 temp;
Uint32 temp1,temp2[5];
Uint16 tmp;
Uint8 read_data;
/* ------------------------------------------------------------------------ *
* *
* tvp5146_rset *
* *
* Set codec register regnum to value regval *
* *
* ------------------------------------------------------------------------ */
void tvp5150_rset( Uint8 regnum, Uint8 regval)
{
Uint8 cmd[2];
cmd[0] = regnum; // 8-bit Register Address
cmd[1] = regval; // 8-bit Register Data
temp=DAVINCIEVM_I2C_write( TVP5150_I2C_ADDR, cmd, 2);
}
/* ------------------------------------------------------------------------ *
* *
* tvp5146_rget *
* *
* Return value of codec register regnum *
* *
* ------------------------------------------------------------------------ */
Uint8 tvp5150_rget( Uint8 regnum )
{
Uint8 cmd[2];
cmd[0] = regnum; // 8-bit Register Address
cmd[1] = 0; // 8-bit Register Data
DAVINCIEVM_I2C_write ( TVP5150_I2C_ADDR, cmd, 1 );
DAVINCIEVM_I2C_read ( TVP5150_I2C_ADDR, cmd, 1 );
return cmd[0];
}
/* ------------------------------------------------------------------------ *
* *
* tvp5146_init( ) *
* *
* Initialize the TVP5146 *
* mode=1 *
* ------------------------------------------------------------------------ */
void tvp5150_init()
{
DAVINCIEVM_waitusec( 1000 );
tvp5150_rset( 0x00, 0x02 ); // Input Video: CVBS From AIP1B pin
tvp5150_rset( 0x03, 0x6d ); //Miscellaneous Control Register
tvp5150_rset( 0x09, 0x8B ); //Brightness Control
tvp5150_rset( 0x0a, 0x80 ); //color saturation control,default 80h
tvp5150_rset( 0x0b, 0x00 ); //Hue Control Register ,default 00h
tvp5150_rset( 0x0D, 0x07 ); //?? Enabling clock & Y/CB/CR input format
tvp5150_rset( 0x0F, 0x02 ); //??Configuration Shared Pins Register,defualt 08h
tvp5150_rset( 0x15, 0x04 ); //??Genlock and RTC Register,default 01h
tvp5150_rset( 0x19, 0x01 ); //??Vertical Blanking Stop Register,default 00h
tvp5150_rset( 0x1B, 0x14 ); //Chrominance Control#2 Register ,default 14h
DAVINCIEVM_waitusec( 1000 ); // wait 1 msec
//zodisa add, read back for test
read_data=tvp5150_rget( 0x09);
if(read_data==0x8B)
{
printf("tvp5150 reg is ok!\n");
}
else
{
printf("tvp5150 reg is wrong!\n");
}
}
//#define NTSC 1 //zodisa delete Input NTSC format
#define PAL 1
#if NTSC
#define BASEP_X 0x7A // 122
#define BASEP_Y 0x12 // 18
#elif PAL
#define BASEP_X 0x84 // 132
#define BASEP_Y 0x16 // 22
#endif
/* ------------------------------------------------------------------------ *
* *
* vpfe_init( ) *
* *
* PAL: *
* Width: 720 *
* Height: 576 *
* NTSC: *
* Width: 720 *
* Height: 480 *
* *
* *
* ------------------------------------------------------------------------ */
void vpfe_init( Uint32 buffer, Uint32 width, Uint32 height )
{
VPFE_SYN_MODE = 0x00032F84; // interlaced, with VD pority as negative
VPFE_HD_VD_WID = 0;
VPFE_PIX_LINES = 0x02CF020D;
/*
* sph = 1, nph = 1440, according to page 32-33 of the CCDC spec
* for BT.656 mode, this setting captures only the 720x480 of the
* active NTSV video window
*/
VPFE_HORZ_INFO = width << 1; // Horizontal lines
VPFE_HSIZE_OFF = width << 1; // Horizontal line offset
VPFE_VERT_START = 0; // Vertical start line
VPFE_VERT_LINES = height >> 1; // Vertical lines
VPFE_CULLING = 0xFFFF00FF; // Disable cullng
/*
* Interleave the two fields
*/
VPFE_SDOFST = 0x00000249;
VPFE_SDR_ADDR = buffer;
VPFE_CLAMP = 0;
VPFE_DCSUB = 0;
VPFE_COLPTN = 0xEE44EE44;
VPFE_BLKCMP = 0;
VPFE_FPC_ADDR = 0x86800000;
VPFE_FPC = 0;
VPFE_VDINT = 0;
VPFE_ALAW = 0;
VPFE_REC656IF = 0x00000003;
/*
* Input format is Cb:Y:Cr:Y, w/ Y in odd-pixel position
*/
VPFE_CCDCFG = 0x00000800;
VPFE_FMTCFG = 0;
VPFE_FMT_HORZ = 0x000002D0;
VPFE_FMT_VERT = 0x00000272;//PAL format
//VPFE_FMT_VERT = 0x0000020E; //NTSC format
VPFE_FMT_ADDR0 = 0;
VPFE_FMT_ADDR1 = 0;
VPFE_FMT_ADDR2 = 0;
VPFE_FMT_ADDR3 = 0;
VPFE_FMT_ADDR4 = 0;
VPFE_FMT_ADDR5 = 0;
VPFE_FMT_ADDR6 = 0;
VPFE_FMT_ADDR7 = 0;
VPFE_PRGEVEN_0 = 0;
VPFE_PRGEVEN_1 = 0;
VPFE_PRGODD_0 = 0;
VPFE_PRGODD_1 = 0;
VPFE_VP_OUT = 0x04E22D00;//PAL format
//VPFE_VP_OUT = 0x041A2D00;//NTSC format
VPFE_PCR = 0x00000001; // Enable CCDC
}
/* ------------------------------------------------------------------------ *
* *
* vpbe_init( ) *
* *
* PAL: *
* Width: 720 *
* Height: 576 *
* NTSC: *
* Width: 720 *
* Height: 480 *
* cb_enable=1, Color Bar output *
* *
* ------------------------------------------------------------------------ */
void vpbe_init( Uint32 buffer, Uint32 width, Uint32 height, Uint32 cb_enable )
{
// Setup VPBE
VPSS_CLK_CTRL = 0x00000018; // Enable DAC and VENC clock, both at 27 MHz
VPBE_PCR = 0; // No clock div, clock enable
// Setup OSD
OSD_MODE = 0x000000fc; // Blackground color blue using clut in ROM0
OSD_OSDWIN0MD = 0; // Disable both osd windows and cursor window
OSD_OSDWIN1MD = 0;
OSD_RECTCUR = 0;
OSD_VIDWIN0OFST = width >> 4;
OSD_VIDWIN0ADR = buffer;
OSD_BASEPX = BASEP_X;
OSD_BASEPY = BASEP_Y;
OSD_VIDWIN0XP = 0;
OSD_VIDWIN0YP = 0;
OSD_VIDWIN0XL = width;
OSD_VIDWIN0YL = height >> 1;
OSD_MISCCTL = 0;
OSD_VIDWINMD = 0x00000003; // Disable vwindow 1 and enable vwindow 0
// Frame mode with no up-scaling
// Setup VENC
VENC_VMOD = 0x00000043; // Standard PAL interlaced output
//VENC_VMOD = 0x00000003; // Standard NTSC interlaced output
VENC_VDPRO = cb_enable << 8;
#ifdef Svideo
VENC_DACSEL = 0x00004210;
#else
VENC_CMPNT = 0x00008700;
VENC_DACSEL = 0x00005430;
#endif
VENC_DACTST = 0;
}
/* ------------------------------------------------------------------------ *
* *
* vpbe_cbtest( ) *
* cb_enable = 1 , Color Bar Test *
* mode = 1 , NTSC mode *
* mode = 2 , PAL mode *
* zodisa add *
* ------------------------------------------------------------------------ */
void vpbe_cbtest( Uint32 cb_enable,Uint8 mode)
{
//Setup VPBE
VPSS_CLK_CTRL = 0x00000018; // Enable DAC and VENC clock, both at 27 MHz
VPBE_PCR = 0; // No clock div, clock enable
// Setup VENC
switch(mode)
{
case 1://NTSC
{
VENC_VMOD = 0x00002003;
break;
}
case 2://PAL
{
VENC_VMOD = 0x00002043;
break;
}
default:
{
VENC_VMOD = 0x00002003;
break;
}
}
VENC_VDPRO = 0x00000870|(cb_enable << 8);
VENC_DACTST = 0x00000000;
VENC_DACSEL = 0x00000000;
}
/* ------------------------------------------------------------------------ *
* *
* video_loopback_test( ) *
* *
* *
* *
* ------------------------------------------------------------------------ */
Int16 video_loopback_test( )
{
tvp5150_init( );
vpfe_init( 0x81000000, 720, 576 ); // Setup Front-End PAL format
vpbe_init( 0x81000000, 720, 576, 0 ); // Setup Back-End PAL format
//vpfe_init( 0x81000000, 720, 480 ); // Setup Front-End NTSC format
//vpbe_init( 0x81000000, 720, 480, 0 ); // Setup Back-End NTSC format
// vpbe_cbtest(1,2);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -