📄 play_capture_saa7119.c
字号:
struct capsam_update *pUpdate, RMuint32 reg){ return RM_OK;}static RMstatus Handle_HD_COPRO(struct capsam_SAA7119_instance *pSAA7119, struct capsam_update *pUpdate, RMuint32 reg){ return RM_OK;}static RMstatus Handle_HD_RDCAP(struct capsam_SAA7119_instance *pSAA7119, struct capsam_update *pUpdate, RMuint32 reg){ return RM_OK;}static RMstatus Handle_HD_HL(struct capsam_SAA7119_instance *pSAA7119, struct capsam_update *pUpdate, RMuint32 reg){ return RM_OK;}/********************************************************************************** Capture Chip API*********************************************************************************/RMstatus capsam_SAA7119_open( struct RUA *pRUA, struct capsam_SAA7119_instance **ppSAA7119, RMuint32 I2CModuleID, struct EMhwlibI2CDeviceParameter *pI2CDevice, RMuint32 XtalClock, RMuint32 SampleRate){ struct capsam_SAA7119_instance *pSAA7119; RMDBGLOG((FUNCNAME, "%s\n",__func__)); // Sanity checks if (ppSAA7119 == NULL) return RM_FATALINVALIDPOINTER; *ppSAA7119 = NULL; if (pRUA == NULL) return RM_FATALINVALIDPOINTER; if (pI2CDevice == NULL) return RM_FATALINVALIDPOINTER; // Allocate and clear local instance pSAA7119 = (struct capsam_SAA7119_instance *)RMMalloc(sizeof(struct capsam_SAA7119_instance)); if (pSAA7119 == NULL) { fprintf(stderr, "FATAL! Not enough memory for struct capsam_SAA7119_instance!\n"); return RM_FATALOUTOFMEMORY; } RMMemset(pSAA7119, 0, sizeof(struct capsam_SAA7119_instance)); *ppSAA7119 = pSAA7119; // Set default and startup values pSAA7119->pRUA = pRUA; pSAA7119->I2CModuleID = I2CModuleID; pSAA7119->I2CDevice = *pI2CDevice; pSAA7119->BaseDevice = pI2CDevice->DevAddr; // Set initial state pSAA7119->state = INIT; // board specific information pSAA7119->XtalClock = XtalClock; /* audio clock info */ /* default 59.94Hz */ pSAA7119->vfreq_n = 60000; pSAA7119->vfreq_m = 1001; pSAA7119->pixel_clk = 13500000; pSAA7119->h_total_size = 858; pSAA7119->SampleRate = SampleRate; pSAA7119->MclkFactor = 256; return RM_OK;}RMstatus capsam_SAA7119_close( struct capsam_SAA7119_instance *pSAA7119){ // Sanity checks if (pSAA7119 == NULL) return RM_FATALINVALIDPOINTER; // Free all ressources RMFree(pSAA7119); return RM_OK;}RMstatus capsam_SAA7119_tristate(struct capsam_SAA7119_instance *pSAA7119){ // Sanity checks if (pSAA7119 == NULL) return RM_FATALINVALIDPOINTER; capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x83, 0x10); // tri-state xport capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x87, 0x10); // tri-state iport capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x88, 0x0D); // reset and power down scaler, tri-state audio clocks return RM_OK;}RMstatus capsam_SAA7119_init_capture(struct capsam_SAA7119_instance *pSAA7119, const struct capsam_access *pInput){ RMuint32 reg; RMuint32 port = pInput->input; //////////////////////////////////////////////////////////////////////// // Philips SAA 7119 setup for power-up // (CVBS on AI11, auto PAL-BG/NTSC-M, 8 bit 656/601 on i-port, h- and v-sync on RTS0 and RTS1) //////////////////////////////////////////////////////////////////////// RMuint8 i2c_data[][2] = { {0x88, 0x20}, // take scaler out of reset {0x83, 0x11}, // xport enabled {0x01, 0x17}, {0x02, 0x00}, // input CVBS on AI11 {0x03, 0x40}, {0x04, 0xe0}, {0x05, 0xe0}, {0x06, 0xf4}, // (0xeb) Horizontal Sync Start @ 0 {0x07, 0xe2}, // (0xe0) Horizontal Sync is 4 Clk long {0x08, 0x90}, {0x09, 0x80}, // (0x40 for cvbs) {0x0a, 0x80}, {0x0b, 0x44}, {0x0c, 0x40}, {0x0d, 0x00}, {0x0e, 0x03}, // pref. 50/60 Hz auto detect: 00:PAL-BG/NTSC-M 40:PAL-BG/NTSC-Japan 50:SECAM/NTSC-M {0x0f, 0x37}, {0x10, 0x06}, // {0x11, 0x68}, // RTS0 and RTS1 pins are inverted {0x11, 0x20}, // RTS0 and RTS1 pins are not inverted // {0x12, 0xc8}, // RTS0 is HSync and RTS1 is VSync {0x12, 0xc9}, // RTS0 is HS and RTS1 is VSync {0x13, 0x80}, {0x14, 0xc0}, {0x15, 0x15}, {0x16, 0x20}, {0x17, 0xe8}, // tri-state LLC, LLC2, 5 field loop search {0x18, 0x40}, {0x19, 0x80}, {0x1a, 0x77}, {0x1b, 0x42}, {0x1c, 0xa9}, // 0xdd {0x1d, 0x01}, {0x21, 0x03}, {0x22, 0x96}, {0x23, 0x96}, {0x24, 0x6e}, {0x25, 0x07}, {0x26, 0xa0}, {0x27, 0x00}, {0x28, 0x10}, {0x29, 0x00}, {0x2a, 0x80}, {0x2b, 0x40}, {0x2c, 0x40}, {0x2d, 0x00}, // Disable Interrupts {0x2e, 0x00}, // Disable Interrupts {0x2f, 0x00}, // Disable Interrupts // Audio PLL setup (0x30 - 0x3f) is done in init_capture_SAA7119_amclk() {0x40, 0x40}, // VBI slicer {0x41, 0xff}, // lines 2 / 266/316 {0x42, 0xff}, // lines 3 / 267/317 {0x43, 0xff}, // lines 4 / 268/318 {0x44, 0xff}, // lines 5 / 269/319 {0x45, 0xff}, // lines 6 / 270/320 {0x46, 0xff}, // lines 7 / 271/321 {0x47, 0xff}, // lines 8 / 272/322 {0x48, 0xff}, // lines 9 / 273/323 {0x49, 0xff}, // lines 10 / 274/324 {0x4a, 0xff}, // lines 11 / 275/325 {0x4b, 0xff}, // lines 12 / 276/326 {0x4c, 0xff}, // lines 13 / 277/327 {0x4d, 0xff}, // lines 14 / 278/328 {0x4e, 0xff}, // lines 15 / 279/329 {0x4f, 0xff}, // lines 16 / 280/330 {0x50, 0xff}, // lines 17 / 281/331 {0x51, 0xff}, // lines 18 / 282/332 {0x52, 0xff}, // lines 19 / 283/333 {0x53, 0xff}, // lines 20 / 284/334 {0x54, 0xff}, // lines 21 / 285/335 {0x55, 0xff}, // lines 22 / 286/336 {0x56, 0xff}, // lines 23 / 287/337 {0x57, 0xff}, // lines 24 / 288/338 {0x58, 0x40}, {0x59, 0x47}, {0x5a, 0x06}, // 0x03 for PAL {0x5b, 0x83}, {0x5d, 0x66}, // 0C: SAV/EAV 00:no VBI data 62:ANC {0x5e, 0x00}, {0x5f, 0x00}, {0x80, 0x90}, {0x81, 0x00}, {0x84, 0x0a}, {0x85, 0x00}, {0x86, 0x40}, {0x87, 0x11}, // iport enabled {0x8e, 0x00}, {0x90, 0x00}, {0x91, 0x08}, {0x92, 0x00}, {0x93, 0xc0}, // 80:656 40:yuv-black at blanking ; 00=4:2:2 01=4:1:1 02=4:2:0 03=4:1:0 04=Y only {0x94, 0x04}, {0x95, 0x00}, {0x96, 0xd0}, {0x97, 0x02}, {0x98, 0x07}, {0x99, 0x01}, {0x9a, 0x06}, {0x9b, 0x01}, {0x9c, 0xd0}, {0x9d, 0x02}, {0x9e, 0x07}, {0x9f, 0x01}, {0xa0, 0x01}, {0xa1, 0x00}, {0xa2, 0x00}, {0xa4, 0x80}, // brightness {0xa5, 0x40}, // contrast {0xa6, 0x40}, // saturation {0xa8, 0x00}, {0xa9, 0x04}, {0xaa, 0x00}, {0xac, 0x00}, {0xad, 0x02}, {0xae, 0x00}, {0xb0, 0x00}, {0xb1, 0x04}, {0xb4, 0x41}, {0xb5, 0x15}, {0xb6, 0x33}, {0xb7, 0xe3}, {0xb8, 0x00}, {0xb9, 0x00}, {0xba, 0x00}, {0xbb, 0x00}, {0xc0, 0x03}, {0xc1, 0x08}, {0xc2, 0x00}, {0xc3, 0x80}, {0xc4, 0x03}, {0xc5, 0x00}, {0xc6, 0xd0}, {0xc7, 0x02}, {0xc8, 0x18}, {0xc9, 0x00}, {0xca, 0x18}, {0xcb, 0x01}, {0xcc, 0xce}, {0xcd, 0x02}, {0xce, 0x18}, {0xcf, 0x01}, {0xd0, 0x02}, {0xd1, 0x01}, {0xd2, 0x01}, {0xd4, 0x80}, {0xd5, 0x20}, {0xd6, 0x20}, {0xd8, 0x00}, {0xd9, 0x04}, {0xda, 0x00}, {0xdc, 0x00}, {0xdd, 0x02}, {0xde, 0x00}, {0xe0, 0xf8}, {0xe1, 0x07}, {0xe4, 0x41}, {0xe5, 0x05}, {0xe6, 0x00}, {0xe7, 0x00}, {0xe8, 0x07}, {0xe9, 0x07}, {0xea, 0x07}, {0xeb, 0x07}, {0x88, 0x00}, // set scaler reset bit {0x88, 0x30}, // take scaler out of reset, set DPROG signal (device has been programmed) {0x83, 0x10}, // xport disabled }; RMDBGLOG((FUNCNAME, "%s\n",__func__ )); /* printf(" %p \n", pSAA7119); printf(" %d \n", pSAA7119->BaseDevice); printf(" %p\n", pSAA7119->pRUA ); printf(" %ld\n", pSAA7119->I2CModuleID ); */ // Sanity checks if (pSAA7119 == NULL) return RM_FATALINVALIDPOINTER; //////////////////////////////////////////////////////////////////////// // Setup for power-up //////////////////////////////////////////////////////////////////////// capsam_i2c_init(pSAA7119, pSAA7119->BaseDevice, i2c_data); capsam_i2c_read_dev(pSAA7119, pSAA7119->BaseDevice, 0x8F, ®); if (! (reg & 0x08)) { fprintf(stderr, "Philips 7119 power-up or start-up failed!\n"); return RM_ERROR; } //////////////////////////////////////////////////////////////////////// // input port setting //////////////////////////////////////////////////////////////////////// switch (port) { case capsam_input_cvbs1: capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x02, 0x0E); break; case capsam_input_svideo1: capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x02, 0x0D); break; /* case capsam_ScartCVBS1: capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x02, 0x01); break; case capsam_ScartRGB1: capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x02, 0x33); break; case capsam_Component1: capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x02, 0x20); break; case capsam_Tuner1: capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x02, 0x04); break; */ default: return RM_ERROR; break; } //////////////////////////////////////////////////////////////////////// // filter settup for SAA7119 //////////////////////////////////////////////////////////////////////// switch (port) { case capsam_input_cvbs1: case capsam_input_cvbs2: /* case capsam_ScartCVBS1: case capsam_ScartCVBS2: case capsam_Tuner1: case capsam_Tuner2: */ // activate chrominance trap and comb filter for CVBS capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x09, 0x40); break; case capsam_Component1: case capsam_Component2: case capsam_ScartRGB1: case capsam_ScartRGB2: // activate overlay channel for component video capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x27, 0x01); break; default: return RM_ERROR; break; } return RM_OK;}RMstatus capsam_SAA7119_setup_vbi(struct capsam_SAA7119_instance *pSAA7119, struct capsam_update *pUpdate){ RMstatus err = RM_OK; RMuint32 reg; RMuint32 vbianc_enable = 0; RMuint8 i2c_data_tt[][2] = { // Enable PAL TeleText slicing {0x41, 0xff}, // lines 2 / 316 {0x42, 0xff}, // lines 3 / 317 {0x43, 0xff}, // lines 4 / 318 {0x44, 0xf1}, // lines 5 / 319 {0x45, 0x11}, // lines 6 / 320 {0x46, 0x11}, // lines 7 / 321 {0x47, 0x11}, // lines 8 / 322 {0x48, 0x11}, // lines 9 / 323 {0x49, 0x11}, // lines 10 / 324 {0x4a, 0x11}, // lines 11 / 325 {0x4b, 0x11}, // lines 12 / 326 {0x4c, 0x11}, // lines 13 / 327 {0x4d, 0x11}, // lines 14 / 328 {0x4e, 0x11}, // lines 15 / 329 {0x4f, 0x11}, // lines 16 / 330 {0x50, 0x11}, // lines 17 / 331 {0x51, 0x11}, // lines 18 / 332 {0x52, 0x11}, // lines 19 / 333 {0x53, 0x11}, // lines 20 / 334 {0x54, 0x11}, // lines 21 / 335 {0x55, 0x1f}, // lines 22 / 336 {0x56, 0xff}, // lines 23 / 337 {0x57, 0xff}, // lines 24 / 338 }; RMuint8 i2c_data_cc[][2] = { // Enable NTSC ClosedCaption/WSS525/CGMS slicing {0x41, 0xff}, // lines 2 / 266 {0x42, 0xff}, // lines 3 / 267 {0x43, 0xff}, // lines 4 / 268 {0x44, 0xff}, // lines 5 / 269 {0x45, 0xff}, // lines 6 / 270 {0x46, 0xff}, // lines 7 / 271 {0x47, 0xff}, // lines 8 / 272 {0x48, 0xff}, // lines 9 / 273 {0x49, 0xff}, // lines 10 / 274 {0x4a, 0xff}, // lines 11 / 275 {0x4b, 0xff}, // lines 12 / 276 {0x4c, 0xff}, // lines 13 / 277 {0x4d, 0xff}, // lines 14 / 278 {0x4e, 0xff}, // lines 15 / 279 {0x4f, 0xff}, // lines 16 / 280 {0x50, 0xff}, // lines 17 / 281 {0x51, 0xff}, // lines 18 / 282 {0x52, 0xf5}, // lines 19 / 283 {0x53, 0x54}, // lines 20 / 284 {0x54, 0x4f}, // lines 21 / 285 {0x55, 0xff}, // lines 22 / 286 {0x56, 0xff}, // lines 23 / 287 {0x57, 0xff}, // lines 24 / 288 }; //////////////////////////////////////////////////////////////////////// // select VBI data slicing //////////////////////////////////////////////////////////////////////// switch (pUpdate->TVStandard) { case EMhwlibTVStandard_ITU_Bt656_625: case EMhwlibTVStandard_ITU_Bt656_288p: case EMhwlibTVStandard_PAL_BG: case EMhwlibTVStandard_PAL_BG_702: case EMhwlibTVStandard_PAL_N: case EMhwlibTVStandard_PAL_N_702: if (vbianc_enable) { // TeleText data has to be handled by ANC capture fprintf(stderr, "Setting up PAL TeleText VBI slicing/\n"); capsam_i2c_init(pSAA7119, pSAA7119->BaseDevice, i2c_data_tt); } // enable WSS625 slicing capsam_i2c_read_dev(pSAA7119, pSAA7119->BaseDevice, 0x55, ®); reg = (reg & 0xF0) | 0x05; capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x55, reg); capsam_i2c_read_dev(pSAA7119, pSAA7119->BaseDevice, 0x56, ®); reg = (reg & 0x0F) | 0x50; capsam_i2c_write_dev(pSAA7119, pSAA7119->BaseDevice, 0x56, reg); break; case EMhwlibTVStandard_ITU_Bt656_525: case EMhwlibTVStandard_ITU_Bt656_240p: case EMhwlibTVStandard_NTSC_M_Japan: case EMhwlibTVStandard_NTSC_M_Japan_714: case EMhwlibTVStandard_NTSC_M: case EMhwlibTVStandard_NTSC_M_714: fprintf(stderr, "Setting up NTSC ClosedCaption VBI slicing/\n"); capsam_i2c_init(pSAA7119, pSAA7119->BaseDevice, i2c_data_cc); break; default: break; } //////////////////////////////////////////////////////////////////////// // vertical offset ////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -