int zed_ali3_controller_demo_init( zed_ali3_controller_demo_t *pDemo )
{
   int ret;

   xil_printf("\n\r");
   xil_printf("------------------------------------------------------\n\r");
   xil_printf("--             Zynq Mini-ITX Display Kit            --\n\r");
   xil_printf("--           ALI3 Controller Demonstration          --\n\r");
   xil_printf("--         DH TMG120 Diagnostics Application        --\n\r");
   xil_printf("------------------------------------------------------\n\r");
   xil_printf("\n\r");

   // Fill frame stores with color bars
   xil_printf( "Video Frame Buffer Initialization ...\n\r" );
   int32u frame, row, col;
   int32u pixel;
   volatile int32u *pStorageMem = (int32u *)pDemo->uBaseAddr_MEM_FrameBuffer;
   for ( frame = 0; frame < pDemo->uNumFrames_FrameBuffer; frame++ )
   {
      for ( row = 0; row < pDemo->ali3_height; row++ )
      {
         for ( col = 0; col < pDemo->ali3_width; col++ )
         {
             pixel = 0x00000000; // Black
             *pStorageMem++ = pixel;
          }
       }
    }

    // Wait for DMA to synchronize.
    Xil_DCacheFlush();

   // Initialize Output Side of AXI VDMA
   xil_printf( "Video DMA (Output Side) Initialization ...\n\r" );
   vfb_common_init(
      pDemo->uDeviceId_VDMA_FrameBuffer, // uDeviceId
      &(pDemo->vdma_ali3)                // pAxiVdma
      );
   vfb_tx_init(
      &(pDemo->vdma_ali3),               // pAxiVdma
      &(pDemo->vdmacfg_ali3_read),       // pReadCfg
      pDemo->ali3_resolution,            // uVideoResolution
      pDemo->ali3_resolution,            // uStorageResolution
      pDemo->uBaseAddr_MEM_FrameBuffer,  // uMemAddr
      pDemo->uNumFrames_FrameBuffer      // uNumFrames
      );

   // IIC Initialization for touch controller
   xil_printf( "I2C Touch Controller Initialization ...\n\r");
   ret = zed_iic_axi_init(&(pDemo->touch_iic),"ALI3 Touch I2C Controller", pDemo->uBaseAddr_IIC_Touch);
   if ( !ret )
   {
      xil_printf("ERROR : Failed to open ZED-IIC driver\n\r");
      return -1;
   }

   /* For Zynq Mini-ITX, the I2C mux must be set to Channel 4 in order to
    * communicate with the touch controller.
    */
   ret = zed_ali3_controller_demo_initialize_mux(pDemo, I2C_MUX_SLAVE_ADDRESS);

   pDemo->touch_irqs   = 0;
   pDemo->touch_events = 0;
   pDemo->touch_posx   = 0x0000;
   pDemo->touch_posy   = 0x0000;

   zed_ali3_controller_demo_SetupInterruptSystem( pDemo );

   tmg_120_initialize( pDemo );

   return 0;

}
int zed_ali3_controller_demo_init(zed_ali3_controller_demo_t *pDemo)
{
    int ret;
    interface_graphic_t graphic;

    xil_printf("\n\r");
    xil_printf("------------------------------------------------------\n\r");
    xil_printf("--                Zed Display Kit                   --\n\r");
    xil_printf("--           ALI3 Controller Demonstration          --\n\r");
    xil_printf("--             Standalone Application               --\n\r");
    xil_printf("------------------------------------------------------\n\r");
    xil_printf("\n\r");

	// Blank the screen,
	draw_blank_screen(pDemo, COLOR_BLACK);

	// Wait for DMA to synchronize.
	Xil_DCacheFlush();

    // Draw the system configuration graphic to the display.
    graphic.location_x = 400 - (avnet_control_system_config_width / 2);  // Centered on graphic
    graphic.location_y = 240 - (avnet_control_system_config_height / 2);  // Centered on graphic
    graphic.size_x = avnet_control_system_config_width;
    graphic.size_y = avnet_control_system_config_height;
    graphic.default_image_data = avnet_control_system_config;
    draw_image_data(pDemo, &graphic);

    // Wait for DMA to synchronize.
    Xil_DCacheFlush();

    // Initialize Output Side of AXI VDMA
    xil_printf("Video DMA (Output Side) Initialization ...\n\r");
    vfb_common_init(
        pDemo->uDeviceId_VDMA_FrameBuffer, // uDeviceId
        &(pDemo->vdma_ali3)                // pAxiVdma
        );
    vfb_tx_init(
        &(pDemo->vdma_ali3),               // pAxiVdma
        &(pDemo->vdmacfg_ali3_read),       // pReadCfg
        pDemo->ali3_resolution,            // uVideoResolution
        pDemo->ali3_resolution,            // uStorageResolution
        pDemo->uBaseAddr_MEM_FrameBuffer,  // uMemAddr
        pDemo->uNumFrames_FrameBuffer      // uNumFrames
        );

    /*
     * Initialize the QSPI flash and load any stored touch screen calibration
     * values.
     */
    if (qspi_flash_polled_init() != 0)
    {
        xil_printf("ERROR : Failed to open QSPI driver\n\r");
    }

    /*
     * Load the touch calibration data from flash memory.
     */
    if (qspi_flash_load_calibration_data(pDemo) != 0)
    {
        xil_printf("No Valid Calibration Data Found in Flash\n\r");

        /*
         * Cause touch calibration to occur after init() finishes.
         */
        pDemo->calibration_success = 0;
    }
    else
    {
    	pDemo->calibration_success = 1;
    }

    // IIC Initialization for touch controller
    xil_printf("I2C Touch Controller Initialization ...\n\r");
    ret = zed_iic_axi_init(&(pDemo->touch_iic),"ALI3 Touch I2C Controller", pDemo->uBaseAddr_IIC_Touch);

    if (!ret)
    {
        xil_printf("ERROR : Failed to open ZED-IIC driver\n\r");
        return -1;
    }

    // Initialize the touch controller and prepare the event handler.
    tmg120_initialize(pDemo);

    // Setup the interrupt handling for the touch controller.
    zed_ali3_controller_demo_SetupInterruptSystem(pDemo);

    // Enable the touch controller to begin detecting touch input.
    tmg120_enable_touch(pDemo);

    // Initialize the GPIO interfaces.
    pDemo->button0_state = 0;
    pDemo->button1_state = 0;

    pDemo->led0_state = 0;
    pDemo->led1_state = 0;
    pDemo->led2_state = 0;
    pDemo->led3_state = 0;


    zed_ali3_controller_demo_button(pDemo, 0, pDemo->button0_state);
    zed_ali3_controller_demo_button(pDemo, 1, pDemo->button1_state);

    zed_ali3_controller_demo_led(pDemo, 0, pDemo->led0_state);
    zed_ali3_controller_demo_led(pDemo, 1, pDemo->led1_state);
    zed_ali3_controller_demo_led(pDemo, 2, pDemo->led2_state);
    zed_ali3_controller_demo_led(pDemo, 3, pDemo->led3_state);

    // Set the mode to draw by default.
    pDemo->mode = draw;

    return 0;
}
Exemple #3
0
// Main FMC-IMAGEON initialization function. Add your code here.
int fmc_imageon_enable( camera_config_t *config )
{
   int ret;

   xil_printf("\n\r");
   xil_printf("------------------------------------------------\n\r");
   xil_printf("--    FMC-IMAGEON Camera Application (MP-2)   --\n\r");
   xil_printf("------------------------------------------------\n\r");
   xil_printf("\n\r");

   config->bVerbose = 1;
   config->vita_aec = 0;       // off
   config->vita_again = 0;     // 1.0
   config->vita_dgain = 128;   // 1.0
   config->vita_exposure = 90; // 90% of frame period


   xil_printf("FMC-IPMI Initialization ...\n\r");
   ret = fmc_iic_axi_init(&(config->fmc_ipmi_iic), "FMC-IPMI I2C Controller", config->uBaseAddr_IIC_FmcIpmi);
   if (!ret ) {
      xil_printf("ERROR: Failed to open FMC-IIC driver,\n\r");
      exit(1);
   }


   // FMC Module Validation
   if (fmc_ipmi_detect(&(config->fmc_ipmi_iic), "FMC-IMAGEON", FMC_ID_ALL)) {
      fmc_ipmi_enable( &(config->fmc_ipmi_iic), FMC_ID_SLOT1 );
   }
   else {
	   xil_printf("ERROR: Failed to validate FMC-IPMI I2C Controller.\n\r");
       exit(1);
   }


   xil_printf("FMC-IMAGEON I2C Initialization ...\n\r");
   ret = fmc_iic_axi_init(&(config->fmc_imageon_iic), "FMC-IMAGEON I2C Controller", config->uBaseAddr_IIC_FmcImageon);
   if (!ret) {
      xil_printf( "ERROR: Failed to open FMC-IIC driver\n\r");
      exit(1);
   }

   xil_printf("FMC-IMAGEON Video Clock Initialization ...\n\r");
   fmc_imageon_init(&(config->fmc_imageon), "FMC-IMAGEON", &(config->fmc_imageon_iic));
   fmc_imageon_vclk_init( &(config->fmc_imageon) );
   fmc_imageon_vclk_config( &(config->fmc_imageon), FMC_IMAGEON_VCLK_FREQ_148_500_000);

   xil_printf("Resetting clock generator ...\n\r");
   reset_dcms(config);

   // Initialize Video Output Timing
   xil_printf("Initializing Video Output for 1080P60 ...\n\r");

   config->hdmio_width  = 1920;
   config->hdmio_height = 1080;
   config->hdmio_timing.IsHDMI        = 0; // DVI Mode
   config->hdmio_timing.IsEncrypted   = 0;
   config->hdmio_timing.IsInterlaced  = 0;
   config->hdmio_timing.ColorDepth    = 8;
   config->hdmio_timing.HActiveVideo  = 1920;
   config->hdmio_timing.HFrontPorch   =   88;
   config->hdmio_timing.HSyncWidth    =   44;
   config->hdmio_timing.HSyncPolarity =    1;
   config->hdmio_timing.HBackPorch    =  148;
   config->hdmio_timing.VActiveVideo  = 1080;
   config->hdmio_timing.VFrontPorch   =    4;
   config->hdmio_timing.VSyncWidth    =    5;
   config->hdmio_timing.VSyncPolarity =    1;
   config->hdmio_timing.VBackPorch    =   36;

   if (config->bVerbose) {
  	   xil_printf("ADV7511 Video Output Information\n\r");
    	   xil_printf( "\tHSYNC Timing     = hav=%04d, hfp=%02d, hsw=%02d(hsp=%d), hbp=%03d\n\r",
      			   config->hdmio_timing.HActiveVideo,
      			   config->hdmio_timing.HFrontPorch,
      			   config->hdmio_timing.HSyncWidth, config->hdmio_timing.HSyncPolarity,
      			   config->hdmio_timing.HBackPorch);
    	   xil_printf( "\tVSYNC Timing     = vav=%04d, vfp=%02d, vsw=%02d(vsp=%d), vbp=%03d\n\r",
    			   config->hdmio_timing.VActiveVideo,
    			   config->hdmio_timing.VFrontPorch,
    			   config->hdmio_timing.VSyncWidth, config->hdmio_timing.VSyncPolarity,
    			   config->hdmio_timing.VBackPorch);
    	   xil_printf( "\tVideo Dimensions = %d x %d\n\r", config->hdmio_width, config->hdmio_height );

   }

   config->hdmio_resolution = vres_detect(config->hdmio_width, config->hdmio_height);
   xil_printf("\tVideo Resolution = %s\n\r", vres_get_name(config->hdmio_resolution));

   xil_printf( "Video Generator Configuration ...\n\r");
   vgen_init( &(config->vtc_tpg), config->uDeviceId_VTC_tpg);
   vgen_config( &(config->vtc_tpg ), config->hdmio_resolution, 1);


   // FMC-IMAGEON HDMI Output Initialization
   xil_printf( "FMC-IMAGEON HDMI Output Initialization ...\n\r" );
   ret = fmc_imageon_hdmio_init(&(config->fmc_imageon), 1, &(config->hdmio_timing), 0);
   if (!ret) {
      xil_printf("ERROR : Failed to init FMC-IMAGEON HDMI Output Interface\n\r");
      exit(0);
   }


   // FMC-IMAGEON VITA Receiver Initialization
   xil_printf( "FMC-IMAGEON VITA Receiver Initialization ...\n\r" );
   fmc_imageon_vita_receiver_init( &(config->vita_receiver), "VITA-2000", config->uBaseAddr_VITA_Receiver );
   config->vita_receiver.uManualTap = 25;
   fmc_imageon_vita_receiver_spi_config( &(config->vita_receiver), (50000000/10000000) );


   xil_printf("Video Detector Configuration ...\n\r");
   vdet_init(&(config->vtc_ipipe), config->uDeviceId_VTC_ipipe);
   vdet_config(&(config->vtc_ipipe), config->hdmio_resolution, 1);


   // Initialize the Video Sources
   //fmc_imageon_enable_tpg(config);
   int vita_enabled;
   int vita_enable_attempt=1;
   do {
	  xil_printf("\r\n\n\nFMC_IMAGEON_ENABLE_VITA, attempt %d\r\n\n\n", vita_enable_attempt++);
	  vita_enabled = fmc_imageon_enable_vita(config);
   } while(vita_enabled != 0);
   fmc_imageon_enable_ipipe(config);


   // Enable spread-spectrum clocking (SSC)
   enable_ssc(config);

   // Clear frame stores
   Xuint32 i;
   Xuint32 storage_size = config->uNumFrames_HdmiFrameBuffer * ((1920*1080)<<1);
   volatile Xuint32 *pStorageMem = (Xuint32 *)config->uBaseAddr_MEM_HdmiFrameBuffer;

   // Frame #1 - Red pixels
   for (i = 0; i < storage_size / config->uNumFrames_HdmiFrameBuffer; i += 4) {
	   *pStorageMem++ = 0xF0525A52;
   }
   // Frame #2 - Green pixels
   for (i = 0; i < storage_size / config->uNumFrames_HdmiFrameBuffer; i += 4) {
	   *pStorageMem++ = 0x36912291;
   }
   // Frame #3 - Blue pixels
   for (i = 0; i < storage_size / config->uNumFrames_HdmiFrameBuffer; i += 4) {
	   *pStorageMem++ = 0x6E29F029;
   }


   // Initialize Output Side of AXI VDMA
   xil_printf( "Video DMA (Output Side) Initialization ...\n\r" );
   vfb_common_init(
      config->uDeviceId_VDMA_HdmiFrameBuffer, // uDeviceId
      &(config->vdma_hdmi)                    // pAxiVdma
      );
   vfb_tx_init(
      &(config->vdma_hdmi),                   // pAxiVdma
      &(config->vdmacfg_hdmi_read),           // pReadCfg
      config->hdmio_resolution,               // uVideoResolution
      config->hdmio_resolution,               // uStorageResolution
      config->uBaseAddr_MEM_HdmiFrameBuffer,  // uMemAddr
      config->uNumFrames_HdmiFrameBuffer      // uNumFrames
      );

   // Initialize Input Side of AXI VDMA
   xil_printf( "Video DMA (Input Side) Initialization ...\n\r" );
   vfb_rx_init(
      &(config->vdma_hdmi),                   // pAxiVdma
      &(config->vdmacfg_hdmi_write),          // pWriteCfg
      config->hdmio_resolution,               // uVideoResolution
      config->hdmio_resolution,               // uStorageResolution
      config->uBaseAddr_MEM_HdmiFrameBuffer,  // uMemAddr
      config->uNumFrames_HdmiFrameBuffer      // uNumFrames
      );

   sleep(64); // Version of sleep() we are using is off by 64X.

   // Status of AXI VDMA
   vfb_dump_registers( &(config->vdma_hdmi) );
   if ( vfb_check_errors( &(config->vdma_hdmi), 1/*clear errors, if any*/ ) ) {
      vfb_dump_registers( &(config->vdma_hdmi) );
   }

   xil_printf("\n\r");
   xil_printf( "Done\n\r" );
   xil_printf("\n\r");

   return 0;
}