int demo_init( demo_t *pdemo ) { int status; pdemo->paxivdma0 = &(pdemo->axivdma0); pdemo->paxivdma1 = &(pdemo->axivdma1); pdemo->posd = &(pdemo->osd); pdemo->pcfa = &(pdemo->cfa); pdemo->pfmc_ipmi_iic = &(pdemo->fmc_ipmi_iic); pdemo->pfmc_hdmi_cam_iic = &(pdemo->fmc_hdmi_cam_iic); pdemo->pfmc_hdmi_cam = &(pdemo->fmc_hdmi_cam); pdemo->ppython_receiver = &(pdemo->python_receiver); pdemo->cam_alpha = 0xFF; pdemo->hdmi_alpha = 0x00; pdemo->bVerbose = 0; pdemo->ipmi_info_valid = 0; pdemo->fmc_hdmi_cam_board_info.serial = "n/a"; XAxiVdma_Config *paxivdma_config; XOSD_Config *posd_config; XCfa_Config *pcfa_config; paxivdma_config = XAxiVdma_LookupConfig(XPAR_AXIVDMA_0_DEVICE_ID); XAxiVdma_CfgInitialize(pdemo->paxivdma0, paxivdma_config, paxivdma_config->BaseAddress); paxivdma_config = XAxiVdma_LookupConfig(XPAR_AXIVDMA_1_DEVICE_ID); XAxiVdma_CfgInitialize(pdemo->paxivdma1, paxivdma_config, paxivdma_config->BaseAddress); posd_config = XOSD_LookupConfig(XPAR_OSD_0_DEVICE_ID); XOSD_CfgInitialize(pdemo->posd, posd_config, posd_config->BaseAddress); pcfa_config = XCfa_LookupConfig(XPAR_V_CFA_0_DEVICE_ID); XCfa_CfgInitialize(pdemo->pcfa, pcfa_config, pcfa_config->BaseAddress); if ( pdemo->bVerbose ) { xil_printf( "FMC-IPMI Initialization ...\n\r" ); } status = fmc_iic_xps_init(pdemo->pfmc_ipmi_iic,"FMC-IPMI I2C Controller", XPAR_FMC_IPMI_IIC_0_BASEADDR ); if ( !status ) { xil_printf( "ERROR : Failed to open FMC-IIC driver\n\r" ); exit(0); } // FMC Module Validation if ( pdemo->bVerbose ) { xil_printf( "FMC-HDMI-CAM Identification ...\n\r" ); } //if ( fmc_ipmi_detect( pdemo->pfmc_ipmi_iic, "FMC-HDMI-CAM", FMC_ID_SLOT1 ) ) { int ret; ret = fmc_ipmi_get_common_info( pdemo->pfmc_ipmi_iic, 0xA0, &(pdemo->fmc_hdmi_cam_common_info) ); if ( ret == FRU_SUCCESS ) { ret = fmc_ipmi_get_board_info(pdemo->pfmc_ipmi_iic, 0xA0, &(pdemo->fmc_hdmi_cam_board_info) ); if ( ret == FRU_SUCCESS ) { pdemo->ipmi_info_valid = 1; } } //fmc_ipmi_enable(pdemo->pfmc_ipmi_iic, FMC_ID_SLOT1 ); } if ( pdemo->ipmi_info_valid == 1 ) { xil_printf( "FMC-IPMI programmed as %s (Serial Number = %s)\n\r", pdemo->fmc_hdmi_cam_board_info.part, pdemo->fmc_hdmi_cam_board_info.serial ); } else { xil_printf( "FMC-IPMI not programmed yet ...\n\r" ); } if ( pdemo->bVerbose ) { xil_printf( "FMC-HDMI-CAM Initialization ...\n\r" ); } status = fmc_iic_xps_init(pdemo->pfmc_hdmi_cam_iic,"FMC-HDMI-CAM I2C Controller", XPAR_FMC_HDMI_CAM_IIC_0_BASEADDR ); if ( !status ) { xil_printf( "ERROR : Failed to open FMC-IIC driver\n\r" ); exit(0); } fmc_hdmi_cam_init(pdemo->pfmc_hdmi_cam, "FMC-HDMI-CAM", pdemo->pfmc_hdmi_cam_iic); pdemo->pfmc_hdmi_cam->bVerbose = pdemo->bVerbose; // Configure Video Clock Synthesizer if ( pdemo->bVerbose ) { xil_printf( "Video Clock Synthesizer Configuration ...\n\r" ); } fmc_hdmi_cam_vclk_init( pdemo->pfmc_hdmi_cam ); fmc_hdmi_cam_vclk_config( pdemo->pfmc_hdmi_cam, FMC_HDMI_CAM_VCLK_FREQ_148_500_000); sleep(1); // Set HDMI output to 1080P60 pdemo->hdmio_width = 1920; pdemo->hdmio_height = 1080; //pDemo->hdmio_timing.IsHDMI = 1; // HDMI Mode pdemo->hdmio_timing.IsHDMI = 0; // DVI Mode pdemo->hdmio_timing.IsEncrypted = 0; pdemo->hdmio_timing.IsInterlaced = 0; pdemo->hdmio_timing.ColorDepth = 8; pdemo->hdmio_timing.HActiveVideo = 1920; pdemo->hdmio_timing.HFrontPorch = 88; pdemo->hdmio_timing.HSyncWidth = 44; pdemo->hdmio_timing.HSyncPolarity = 1; pdemo->hdmio_timing.HBackPorch = 148; pdemo->hdmio_timing.VBackPorch = 36; pdemo->hdmio_timing.VActiveVideo = 1080; pdemo->hdmio_timing.VFrontPorch = 4; pdemo->hdmio_timing.VSyncWidth = 5; pdemo->hdmio_timing.VSyncPolarity = 1; if ( pdemo->bVerbose ) { xil_printf( "HDMI Output Initialization ...\n\r" ); } status = fmc_hdmi_cam_hdmio_init( pdemo->pfmc_hdmi_cam, 1, // hdmioEnable = 1 &(pdemo->hdmio_timing), // pTiming 0 // waitHPD = 0 ); if ( !status ) { xil_printf( "ERROR : Failed to init HDMI Output Interface\n\r" ); return 0; } // Default HDMI input resolution pdemo->hdmii_width = pdemo->hdmio_width; pdemo->hdmii_height = pdemo->hdmio_height; return 1; }
int fmc_imageon_hdmi_passthrough( void ) { int ret; Xuint32 timeout = 100; // HDMI Input Settings Xuint32 hdmii_locked; Xuint32 hdmii_width; Xuint32 hdmii_height; Xuint32 hdmii_resolution; fmc_imageon_video_timing_t hdmii_timing; // HDMI Output settings Xuint32 hdmio_width; Xuint32 hdmio_height; Xuint32 hdmio_resolution; fmc_imageon_video_timing_t hdmio_timing; xil_printf("\n\r"); xil_printf("------------------------------------------------------\n\r"); xil_printf("-- FMC-IMAGEON HDMI Pass-Through --\n\r"); xil_printf("------------------------------------------------------\n\r"); xil_printf("\n\r"); xil_printf( "FMC-IMAGEON Initialization ...\n\r" ); ret = fmc_iic_xps_init(&fmc_imageon_iic,"FMC-IMAGEON I2C Controller",XPAR_AXI_IIC_0_BASEADDR); if ( !ret ) { xil_printf( "ERROR : Failed to open FMC-IIC driver\n\r" ); exit(0); } fmc_imageon_init(&fmc_imageon, "FMC-IMAGEON", &fmc_imageon_iic); //fmc_imageon.bVerbose = 0; // without verbose fmc_imageon.bVerbose = 1; // with verbose xil_printf( "HDMI Input Initialization ...\n\r" ); ret = fmc_imageon_hdmii_init( &fmc_imageon, 1, // hdmiiEnable = 1 1, // editInit = 1 fmc_imageon_hdmii_edid_content ); if ( !ret ) { xil_printf( "ERROR : Failed to init HDMI Input Interface\n\r" ); exit(0); } xil_printf( "Waiting for ADV7611 to locked on incoming video ...\n\r" ); hdmii_locked = 0; while ( !hdmii_locked && timeout-- ) { millisleep(100); // wait 100msec ... hdmii_locked = fmc_imageon_hdmii_get_lock( &fmc_imageon ); } if ( !hdmii_locked ) { xil_printf( "\tERROR : ADV7611 has NOT locked on incoming video, aborting !\n\r" ); return -1; } xil_printf( "\tADV7611 Video Input LOCKED\n\r" ); millisleep(100); // wait 100msec for timing to stabilize // Get Video Input information fmc_imageon_hdmii_get_timing( &fmc_imageon, &hdmii_timing ); hdmii_width = hdmii_timing.HActiveVideo; hdmii_height = hdmii_timing.VActiveVideo; hdmii_resolution = vres_detect( hdmii_width, hdmii_height ); xil_printf( "ADV7611 Video Input Information\n\r" ); xil_printf( "\tVideo Input = %s", hdmii_timing.IsHDMI ? "HDMI" : "DVI" ); xil_printf( "%s", hdmii_timing.IsEncrypted ? ", HDCP Encrypted" : "" ); xil_printf( ", %s\n\r", hdmii_timing.IsInterlaced ? "Interlaced" : "Progressive" ); xil_printf( "\tColor Depth = %d bits per channel\n\r", hdmii_timing.ColorDepth ); xil_printf( "\tHSYNC Timing = hav=%04d, hfp=%02d, hsw=%02d(hsp=%d), hbp=%03d\n\r", hdmii_timing.HActiveVideo, hdmii_timing.HFrontPorch, hdmii_timing.HSyncWidth, hdmii_timing.HSyncPolarity, hdmii_timing.HBackPorch ); xil_printf( "\tVSYNC Timing = vav=%04d, vfp=%02d, vsw=%02d(vsp=%d), vbp=%03d\n\r", hdmii_timing.VActiveVideo, hdmii_timing.VFrontPorch, hdmii_timing.VSyncWidth, hdmii_timing.VSyncPolarity, hdmii_timing.VBackPorch ); xil_printf( "\tVideo Dimensions = %d x %d\n\r", hdmii_width, hdmii_height ); if ( (hdmii_resolution) == -1 ) { xil_printf( "\tERROR : Invalid resolution, aborting !\n\r" ); return -1; } // Set HDMI output to same resolution as HDMI input hdmio_width = hdmii_width; hdmio_height = hdmii_height; memcpy( &hdmio_timing, &hdmii_timing, sizeof(fmc_imageon_video_timing_t) ); //hdmio_timing.IsHDMI = 1; // If your monitor is HDMI hdmio_timing.IsHDMI = 0; // If your monitor is DVI xil_printf( "ADV7511 Video Output Information\n\r" ); xil_printf( "\tVideo Output = %s", hdmio_timing.IsHDMI ? "HDMI" : "DVI" ); xil_printf( "%s", hdmio_timing.IsEncrypted ? ", HDCP Encrypted" : "" ); xil_printf( ", %s\n\r", hdmio_timing.IsInterlaced ? "Interlaced" : "Progressive" ); xil_printf( "\tColor Depth = %d bits per channel\n\r", hdmio_timing.ColorDepth ); xil_printf( "\tHSYNC Timing = hav=%04d, hfp=%02d, hsw=%02d(hsp=%d), hbp=%03d\n\r", hdmio_timing.HActiveVideo, hdmio_timing.HFrontPorch, hdmio_timing.HSyncWidth, hdmio_timing.HSyncPolarity, hdmio_timing.HBackPorch ); xil_printf( "\tVSYNC Timing = vav=%04d, vfp=%02d, vsw=%02d(vsp=%d), vbp=%03d\n\r", hdmio_timing.VActiveVideo, hdmio_timing.VFrontPorch, hdmio_timing.VSyncWidth, hdmio_timing.VSyncPolarity, hdmio_timing.VBackPorch ); xil_printf( "\tVideo Dimensions = %d x %d\n\r", hdmio_width, hdmio_height ); xil_printf( "HDMI Output Initialization ...\n\r" ); ret = fmc_imageon_hdmio_init( &fmc_imageon, 1, // hdmioEnable = 1 &hdmio_timing, // pTiming 0 // waitHPD = 0 ); if ( !ret ) { xil_printf( "ERROR : Failed to init HDMI Output Interface\n\r" ); exit(0); } xil_printf("\n\r"); xil_printf( "Done\n\r" ); xil_printf("\n\r"); return 0; }
int fmc_imageon_vita_passthrough_init( fmc_imageon_vita_passthrough_t *pDemo ) { int ret; Xuint32 timeout = 100; Xuint32 iterations = 0; printf("\n\r"); printf("------------------------------------------------------\n\r"); printf("-- FMC-IMAGEON VITA Pass-Through --\n\r"); printf("------------------------------------------------------\n\r"); printf("\n\r"); printf( "FMC-IMAGEON Initialization ...\n\r" ); ret = fmc_iic_xps_init(&(pDemo->fmc_imageon_iic),"FMC-IMAGEON I2C Controller", pDemo->uBaseAddr_IIC_FmcImageon ); if ( !ret ) { printf( "ERROR : Failed to open FMC-IIC driver\n\r" ); exit(0); } fmc_imageon_init(&(pDemo->fmc_imageon), "FMC-IMAGEON", &(pDemo->fmc_imageon_iic)); pDemo->fmc_imageon.bVerbose = pDemo->bVerbose; // Configure Video Clock Synthesizer printf( "Video Clock Synthesizer Configuration ...\n\r" ); fmc_imageon_vclk_init( &(pDemo->fmc_imageon) ); fmc_imageon_vclk_config( &(pDemo->fmc_imageon), FMC_IMAGEON_VCLK_FREQ_148_500_000); sleep(1); // Set HDMI output to 1080P60 pDemo->hdmio_resolution = VIDEO_RESOLUTION_1080P; pDemo->hdmio_width = 1920; pDemo->hdmio_height = 1080; //pDemo->hdmio_timing.IsHDMI = 1; // HDMI Mode pDemo->hdmio_timing.IsHDMI = 0; // DVI Mode pDemo->hdmio_timing.IsEncrypted = 0; pDemo->hdmio_timing.IsInterlaced = 0; pDemo->hdmio_timing.ColorDepth = 8; pDemo->hdmio_timing.HActiveVideo = 1920; pDemo->hdmio_timing.HFrontPorch = 88; pDemo->hdmio_timing.HSyncWidth = 44; pDemo->hdmio_timing.HSyncPolarity = 1; pDemo->hdmio_timing.HBackPorch = 148; pDemo->hdmio_timing.VActiveVideo = 1080; pDemo->hdmio_timing.VFrontPorch = 4; pDemo->hdmio_timing.VSyncWidth = 5; pDemo->hdmio_timing.VSyncPolarity = 1; pDemo->hdmio_timing.VBackPorch = 36; printf( "ADV7511 Video Output Information\n\r" ); printf( "\tVideo Output = %s", pDemo->hdmio_timing.IsHDMI ? "HDMI" : "DVI" ); printf( "%s", pDemo->hdmio_timing.IsEncrypted ? ", HDCP Encrypted" : "" ); printf( ", %s\n\r", pDemo->hdmio_timing.IsInterlaced ? "Interlaced" : "Progressive" ); printf( "\tColor Depth = %d bits per channel\n\r", pDemo->hdmio_timing.ColorDepth ); printf( "\tHSYNC Timing = hav=%04d, hfp=%02d, hsw=%02d(hsp=%d), hbp=%03d\n\r", pDemo->hdmio_timing.HActiveVideo, pDemo->hdmio_timing.HFrontPorch, pDemo->hdmio_timing.HSyncWidth, pDemo->hdmio_timing.HSyncPolarity, pDemo->hdmio_timing.HBackPorch ); printf( "\tVSYNC Timing = vav=%04d, vfp=%02d, vsw=%02d(vsp=%d), vbp=%03d\n\r", pDemo->hdmio_timing.VActiveVideo, pDemo->hdmio_timing.VFrontPorch, pDemo->hdmio_timing.VSyncWidth, pDemo->hdmio_timing.VSyncPolarity, pDemo->hdmio_timing.VBackPorch ); printf( "\tVideo Dimensions = %d x %d\n\r", pDemo->hdmio_width, pDemo->hdmio_height ); printf( "HDMI Output Initialization ...\n\r" ); ret = fmc_imageon_hdmio_init( &(pDemo->fmc_imageon), 1, // hdmioEnable = 1 &(pDemo->hdmio_timing), // pTiming 0 // waitHPD = 0 ); if ( !ret ) { printf( "ERROR : Failed to init HDMI Output Interface\n\r" ); exit(0); } while (1) { if ( iterations > 0 ) { printf( "\n\rPress ENTER to re-start ...\n\r" ); getchar(); } iterations++; // FMC-IMAGEON VITA Receiver Initialization printf( "FMC-IMAGEON VITA Receiver Initialization ...\n\r" ); onsemi_vita_init( &(pDemo->vita_receiver), "VITA-2000", pDemo->uBaseAddr_VITA_SPI, pDemo->uBaseAddr_VITA_CAM ); pDemo->vita_receiver.uManualTap = 25; printf( "FMC-IMAGEON VITA SPI Config for 10MHz ...\n\r" ); // axi4lite_0_clk = 50MHz onsemi_vita_spi_config( &(pDemo->vita_receiver), (50000000/10000000) ); // VITA-2000 Initialization printf( "FMC-IMAGEON VITA Initialization ...\n\r" ); ret = onsemi_vita_sensor_initialize( &(pDemo->vita_receiver), SENSOR_INIT_ENABLE, 1 ); // Be verbose if ( ret == 0 ) { printf( "VITA sensor failed to initialize ...\n\r" ); //return -1; return XST_SUCCESS; } sleep(1); printf( "FMC-IMAGEON VITA Configuration for 1080P60 timing ...\n\r" ); ret = onsemi_vita_sensor_1080P60( &(pDemo->vita_receiver), pDemo->bVerbose ); if ( ret == 0 ) { printf( "VITA sensor failed to configure for 1080P60 timing ...\n\r" ); //return -1; return XST_SUCCESS; } sleep(1); onsemi_vita_get_status( &(pDemo->vita_receiver), &(pDemo->vita_status_t1), 0 ); sleep(1); onsemi_vita_get_status( &(pDemo->vita_receiver), &(pDemo->vita_status_t2), 0 ); // printf( "VITA Status = \n\r" ); printf("\tImage Width = %d\n\r", pDemo->vita_status_t1.cntImagePixels * 4 ); printf("\tImage Height = %d\n\r", pDemo->vita_status_t1.cntImageLines ); printf("\tFrame Rate = %d frames/sec\n\r", pDemo->vita_status_t2.cntFrames - pDemo->vita_status_t1.cntFrames ); printf("\tCRC Status = %X\n\r", pDemo->vita_status_t2.crcStatus ); if ( pDemo->bVerbose ) { onsemi_vita_get_status( &(pDemo->vita_receiver), &(pDemo->vita_status_t2), 1 ); } #if 0 // accept 1920x1080 resolution if ( (pDemo->vita_status_t1.cntImagePixels * 4)==1920 && (pDemo->vita_status_t1.cntImageLines)==1080 ) { // accept 60-64fps range if ( (pDemo->vita_status_t2.cntFrames - pDemo->vita_status_t1.cntFrames)>=60 && (pDemo->vita_status_t2.cntFrames - pDemo->vita_status_t1.cntFrames)<=64 ) { ; //break; } } #endif #if defined(XPAR_XVTC_NUM_INSTANCES) // Configure VTC on output data path printf( "Video Timing Controller (generator) Initialization ...\n\r" ); vgen_init( &(pDemo->vtc_hdmio_generator), pDemo->uDeviceId_VTC_HdmioGenerator ); vgen_config( &(pDemo->vtc_hdmio_generator), pDemo->hdmio_resolution, 1 ); #endif //#if defined(XPAR_CFA_NUM_INSTANCES) #if defined(XPAR_CFA_0_BASEADDR) printf( "Color Filter Array Interpolation (CFA) Initialization ...\n\r" ); pDemo->pCfa_config = XCfa_LookupConfig(pDemo->uDeviceId_CFA); XCfa_CfgInitialize(&(pDemo->cfa), pDemo->pCfa_config, pDemo->pCfa_config->BaseAddress); XCfa_Reset( &(pDemo->cfa) ); XCfa_SetBayerPhase( &(pDemo->cfa), XCFA_RGRG_COMBINATION ); XCfa_RegUpdateEnable( &(pDemo->cfa) ); XCfa_Enable( &(pDemo->cfa) ); printf("\tCFA done\r\n"); #endif printf("\n\r"); printf( "Done\n\r" ); printf("\n\r"); sleep(1); } return 0; }