XilinxProcessorIPLib/drivers/mipicsiss/examples/xmipi_vck_example/mipi_cfg.c
static int ConfigFrmbuf(u32 StrideInBytes,
                        XVidC_ColorFormat Cfmt,
                        XVidC_VideoStream *StreamPtr
						)
{
  int Status;


  XVFrmbufWr_WaitForIdle(&frmbufwr);
  XVFrmbufRd_WaitForIdle(&frmbufrd);


  XVFRMBUFWR_BUFFER_BASEADDR = frame_array[wr_ptr];
  XVFRMBUFRD_BUFFER_BASEADDR = frame_array[rd_ptr];
    /* Configure Frame Buffers */


    Status = XVFrmbufWr_SetMemFormat(&frmbufwr, StrideInBytes, Cfmt, StreamPtr);
    if(Status != XST_SUCCESS) {
      xil_printf("ERROR:: Unable to configure Frame Buffer Write\r\n");
      return(XST_FAILURE);
    }

    Status = XVFrmbufWr_SetBufferAddr(&frmbufwr, XVFRMBUFWR_BUFFER_BASEADDR);
    if(Status != XST_SUCCESS) {
      xil_printf("ERROR:: Unable to configure Frame \
                                        Buffer Write buffer address\r\n");
      return(XST_FAILURE);
    }

    /* Set Chroma Buffer Address for semi-planar color formats */
    if ((Cfmt == XVIDC_CSF_MEM_Y_UV8) || (Cfmt == XVIDC_CSF_MEM_Y_UV8_420) ||
        (Cfmt == XVIDC_CSF_MEM_Y_UV10) || (Cfmt == XVIDC_CSF_MEM_Y_UV10_420)) {
      Status = XVFrmbufWr_SetChromaBufferAddr(&frmbufwr,
                               XVFRMBUFWR_BUFFER_BASEADDR+CHROMA_ADDR_OFFSET);
      if(Status != XST_SUCCESS) {
        xil_printf("ERROR::Unable to configure Frame Buffer \
                                           Write chroma buffer address\r\n");
        return(XST_FAILURE);
      }
    }

    /* Configure Frame Buffer Read*/
        Status = XVFrmbufRd_SetMemFormat(&frmbufrd, StrideInBytes,
                                                       Cfmt, StreamPtr);
        if(Status != XST_SUCCESS) {
          xil_printf("ERROR:: Unable to configure Frame Buffer Read\r\n");
          return(XST_FAILURE);
        }

        Status = XVFrmbufRd_SetBufferAddr(&frmbufrd,
                                      XVFRMBUFRD_BUFFER_BASEADDR);
        if(Status != XST_SUCCESS) {
          xil_printf("ERROR:: Unable to configure Frame \
                                         Buffer Read buffer address\r\n");
          return(XST_FAILURE);
        }


        /* Set Chroma Buffer Address for semi-planar color formats */
        if ((Cfmt == XVIDC_CSF_MEM_Y_UV8) ||
            (Cfmt == XVIDC_CSF_MEM_Y_UV8_420) ||
            (Cfmt == XVIDC_CSF_MEM_Y_UV10) ||
            (Cfmt == XVIDC_CSF_MEM_Y_UV10_420)) {
          Status = XVFrmbufRd_SetChromaBufferAddr(&frmbufrd,
                       XVFRMBUFRD_BUFFER_BASEADDR+CHROMA_ADDR_OFFSET);
          if(Status != XST_SUCCESS) {
            xil_printf("ERROR:: Unable to configure Frame \
                               Buffer Read chroma buffer address\r\n");
            return(XST_FAILURE);
          }
        }


  /* Enable Interrupt */
  XVFrmbufWr_InterruptEnable(&frmbufwr, XVFRMBUFWR_IRQ_DONE_MASK);
  XVFrmbufRd_InterruptEnable(&frmbufrd, XVFRMBUFRD_IRQ_DONE_MASK);
  xil_printf("INFO: FRMBUF configured\r\n");

  return(Status);
}
/*****************************************************************************/
/**
 * This function configures Frame Buffer for defined mode
 *
 * @return XST_SUCCESS if init is OK else XST_FAILURE
 *
 *****************************************************************************/
This function configures Frame Buffer for defined mode
@return XST_SUCCESS if init is OK else XST_FAILURE
This function configures Frame Buffer for defined mode @return XST_SUCCESS if init is OK else XST_FAILURE
static int ConfigFrmbuf(u32 StrideInBytes,
                        XVidC_ColorFormat Cfmt,
                        XVidC_VideoStream *StreamPtr
						)
{
  int Status;
  XVFrmbufWr_WaitForIdle(&frmbufwr);
  XVFrmbufRd_WaitForIdle(&frmbufrd);
  XVFRMBUFWR_BUFFER_BASEADDR = frame_array[wr_ptr];
  XVFRMBUFRD_BUFFER_BASEADDR = frame_array[rd_ptr];
    Status = XVFrmbufWr_SetMemFormat(&frmbufwr, StrideInBytes, Cfmt, StreamPtr);
    if(Status != XST_SUCCESS) {
      xil_printf("ERROR:: Unable to configure Frame Buffer Write\r\n");
      return(XST_FAILURE);
    }
    Status = XVFrmbufWr_SetBufferAddr(&frmbufwr, XVFRMBUFWR_BUFFER_BASEADDR);
    if(Status != XST_SUCCESS) {
      xil_printf("ERROR:: Unable to configure Frame \
                                        Buffer Write buffer address\r\n");
      return(XST_FAILURE);
    }
    if ((Cfmt == XVIDC_CSF_MEM_Y_UV8) || (Cfmt == XVIDC_CSF_MEM_Y_UV8_420) ||
        (Cfmt == XVIDC_CSF_MEM_Y_UV10) || (Cfmt == XVIDC_CSF_MEM_Y_UV10_420)) {
      Status = XVFrmbufWr_SetChromaBufferAddr(&frmbufwr,
                               XVFRMBUFWR_BUFFER_BASEADDR+CHROMA_ADDR_OFFSET);
      if(Status != XST_SUCCESS) {
        xil_printf("ERROR::Unable to configure Frame Buffer \
                                           Write chroma buffer address\r\n");
        return(XST_FAILURE);
      }
    }
        Status = XVFrmbufRd_SetMemFormat(&frmbufrd, StrideInBytes,
                                                       Cfmt, StreamPtr);
        if(Status != XST_SUCCESS) {
          xil_printf("ERROR:: Unable to configure Frame Buffer Read\r\n");
          return(XST_FAILURE);
        }
        Status = XVFrmbufRd_SetBufferAddr(&frmbufrd,
                                      XVFRMBUFRD_BUFFER_BASEADDR);
        if(Status != XST_SUCCESS) {
          xil_printf("ERROR:: Unable to configure Frame \
                                         Buffer Read buffer address\r\n");
          return(XST_FAILURE);
        }
        if ((Cfmt == XVIDC_CSF_MEM_Y_UV8) ||
            (Cfmt == XVIDC_CSF_MEM_Y_UV8_420) ||
            (Cfmt == XVIDC_CSF_MEM_Y_UV10) ||
            (Cfmt == XVIDC_CSF_MEM_Y_UV10_420)) {
          Status = XVFrmbufRd_SetChromaBufferAddr(&frmbufrd,
                       XVFRMBUFRD_BUFFER_BASEADDR+CHROMA_ADDR_OFFSET);
          if(Status != XST_SUCCESS) {
            xil_printf("ERROR:: Unable to configure Frame \
                               Buffer Read chroma buffer address\r\n");
            return(XST_FAILURE);
          }
        }
  XVFrmbufWr_InterruptEnable(&frmbufwr, XVFRMBUFWR_IRQ_DONE_MASK);
  XVFrmbufRd_InterruptEnable(&frmbufrd, XVFRMBUFRD_IRQ_DONE_MASK);
  xil_printf("INFO: FRMBUF configured\r\n");
  return(Status);
}
static int ConfigFrmbuf ( u32 StrideInBytes , XVidC_ColorFormat Cfmt , XVidC_VideoStream * StreamPtr ) { int Status ; XVFrmbufWr_WaitForIdle ( & frmbufwr ) ; XVFrmbufRd_WaitForIdle ( & frmbufrd ) ; XVFRMBUFWR_BUFFER_BASEADDR = frame_array [ wr_ptr ] ; XVFRMBUFRD_BUFFER_BASEADDR = frame_array [ rd_ptr ] ; Status = XVFrmbufWr_SetMemFormat ( & frmbufwr , StrideInBytes , Cfmt , StreamPtr ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " ) ; return ( XST_FAILURE ) ; } Status = XVFrmbufWr_SetBufferAddr ( & frmbufwr , XVFRMBUFWR_BUFFER_BASEADDR ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \
 \r \n " ) ; return ( XST_FAILURE ) ; } if ( ( Cfmt == XVIDC_CSF_MEM_Y_UV8 ) || ( Cfmt == XVIDC_CSF_MEM_Y_UV8_420 ) || ( Cfmt == XVIDC_CSF_MEM_Y_UV10 ) || ( Cfmt == XVIDC_CSF_MEM_Y_UV10_420 ) ) { Status = XVFrmbufWr_SetChromaBufferAddr ( & frmbufwr , XVFRMBUFWR_BUFFER_BASEADDR + CHROMA_ADDR_OFFSET ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \
 \r \n " ) ; return ( XST_FAILURE ) ; } } Status = XVFrmbufRd_SetMemFormat ( & frmbufrd , StrideInBytes , Cfmt , StreamPtr ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " ) ; return ( XST_FAILURE ) ; } Status = XVFrmbufRd_SetBufferAddr ( & frmbufrd , XVFRMBUFRD_BUFFER_BASEADDR ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \
 \r \n " ) ; return ( XST_FAILURE ) ; } if ( ( Cfmt == XVIDC_CSF_MEM_Y_UV8 ) || ( Cfmt == XVIDC_CSF_MEM_Y_UV8_420 ) || ( Cfmt == XVIDC_CSF_MEM_Y_UV10 ) || ( Cfmt == XVIDC_CSF_MEM_Y_UV10_420 ) ) { Status = XVFrmbufRd_SetChromaBufferAddr ( & frmbufrd , XVFRMBUFRD_BUFFER_BASEADDR + CHROMA_ADDR_OFFSET ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \
 \r \n " ) ; return ( XST_FAILURE ) ; } } XVFrmbufWr_InterruptEnable ( & frmbufwr , XVFRMBUFWR_IRQ_DONE_MASK ) ; XVFrmbufRd_InterruptEnable ( & frmbufrd , XVFRMBUFRD_IRQ_DONE_MASK ) ; xil_printf ( " \r \n " ) ; return ( Status ) ; }
This function configures Frame Buffer for defined mode
 @return XST_SUCCESS if init is OK else XST_FAILURE
This function configures Frame Buffer for defined mode @return XST_SUCCESS if init is OK else XST_FAILURE
/* Configure Frame Buffers */ /* Set Chroma Buffer Address for semi-planar color formats */ /* Configure Frame Buffer Read*/ /* Set Chroma Buffer Address for semi-planar color formats */ /* Enable Interrupt */