XilinxProcessorIPLib/drivers/v_hscaler/src/xv_hscaler_l2.c
int XV_HScalerSetup(XV_Hscaler_l2  *InstancePtr,
                     u32 HeightIn,
                     u32 WidthIn,
                     u32 WidthOut,
                     u32 ColorFormatIn,
                     u32 ColorFormatOut)
{
  u32 PixelRate;

  /*
   * Assert validates the input arguments
   */
  Xil_AssertNonvoid(InstancePtr != NULL);
  Xil_AssertNonvoid((HeightIn>0) && (HeightIn<=InstancePtr->Hsc.Config.MaxHeight));
  Xil_AssertNonvoid((WidthIn>0) && (WidthIn<=InstancePtr->Hsc.Config.MaxWidth));
  Xil_AssertNonvoid((WidthOut>0) && (WidthOut<=InstancePtr->Hsc.Config.MaxWidth));
  Xil_AssertNonvoid((InstancePtr->Hsc.Config.PixPerClk >= XVIDC_PPC_1) &&
		  (InstancePtr->Hsc.Config.PixPerClk <= XVIDC_PPC_8));

  if(!XV_HScalerValidateConfig(InstancePtr, ColorFormatIn, ColorFormatOut))
  {
    return XST_FAILURE;
  }

  PixelRate = (WidthIn * STEP_PRECISION)/WidthOut;

  if(InstancePtr->Hsc.Config.ScalerType == XV_HSCALER_POLYPHASE)
  {
    if(!InstancePtr->UseExtCoeff)  //No user defined coefficients
    {
      /* Determine coefficient table to use */
      XV_HScalerSelectCoeff(InstancePtr, WidthIn, WidthOut);
    }
    /* Program generated coefficients into the IP register bank */
    XV_HScalerSetCoeff(InstancePtr);
  }

  /* Compute Phase for 1 line */
  CalculatePhases(InstancePtr, WidthIn, WidthOut, PixelRate);

  /* Program computed Phase into the IP register bank */
  XV_HScalerSetPhase(InstancePtr);

  XV_hscaler_Set_HwReg_Height(&InstancePtr->Hsc,        HeightIn);
  XV_hscaler_Set_HwReg_WidthIn(&InstancePtr->Hsc,       WidthIn);
  XV_hscaler_Set_HwReg_WidthOut(&InstancePtr->Hsc,      WidthOut);
  XV_hscaler_Set_HwReg_ColorMode(&InstancePtr->Hsc,     ColorFormatIn);
  XV_hscaler_Set_HwReg_ColorModeOut(&InstancePtr->Hsc,  ColorFormatOut);
  XV_hscaler_Set_HwReg_PixelRate(&InstancePtr->Hsc,     PixelRate);

  return XST_SUCCESS;
}
/*****************************************************************************/
/**
* This function configures the scaler core registers with the specified
* configuration parameters of the axi stream
*
* @param  InstancePtr is a pointer to the core instance to be worked on.
* @param  HeightIn is the input stream height
* @param  WidthIn is the input stream width
* @param  WidthOut is the output stream width
* @param  ColorFormatIn is the input stream color format
* @param  ColorFormatOut is the output stream color format
*
* @return XST_SUCCESS if the requested setup parameters are valid
*         XST_FAILURE otherwise
*
******************************************************************************/
This function configures the scaler core registers with the specified
configuration parameters of the axi stream
This function configures the scaler core registers with the specified configuration parameters of the axi stream
int XV_HScalerSetup(XV_Hscaler_l2  *InstancePtr,
                     u32 HeightIn,
                     u32 WidthIn,
                     u32 WidthOut,
                     u32 ColorFormatIn,
                     u32 ColorFormatOut)
{
  u32 PixelRate;
  Xil_AssertNonvoid(InstancePtr != NULL);
  Xil_AssertNonvoid((HeightIn>0) && (HeightIn<=InstancePtr->Hsc.Config.MaxHeight));
  Xil_AssertNonvoid((WidthIn>0) && (WidthIn<=InstancePtr->Hsc.Config.MaxWidth));
  Xil_AssertNonvoid((WidthOut>0) && (WidthOut<=InstancePtr->Hsc.Config.MaxWidth));
  Xil_AssertNonvoid((InstancePtr->Hsc.Config.PixPerClk >= XVIDC_PPC_1) &&
		  (InstancePtr->Hsc.Config.PixPerClk <= XVIDC_PPC_8));
  if(!XV_HScalerValidateConfig(InstancePtr, ColorFormatIn, ColorFormatOut))
  {
    return XST_FAILURE;
  }
  PixelRate = (WidthIn * STEP_PRECISION)/WidthOut;
  if(InstancePtr->Hsc.Config.ScalerType == XV_HSCALER_POLYPHASE)
  {
    if(!InstancePtr->UseExtCoeff)  
    {
      XV_HScalerSelectCoeff(InstancePtr, WidthIn, WidthOut);
    }
    XV_HScalerSetCoeff(InstancePtr);
  }
  CalculatePhases(InstancePtr, WidthIn, WidthOut, PixelRate);
  XV_HScalerSetPhase(InstancePtr);
  XV_hscaler_Set_HwReg_Height(&InstancePtr->Hsc,        HeightIn);
  XV_hscaler_Set_HwReg_WidthIn(&InstancePtr->Hsc,       WidthIn);
  XV_hscaler_Set_HwReg_WidthOut(&InstancePtr->Hsc,      WidthOut);
  XV_hscaler_Set_HwReg_ColorMode(&InstancePtr->Hsc,     ColorFormatIn);
  XV_hscaler_Set_HwReg_ColorModeOut(&InstancePtr->Hsc,  ColorFormatOut);
  XV_hscaler_Set_HwReg_PixelRate(&InstancePtr->Hsc,     PixelRate);
  return XST_SUCCESS;
}
int XV_HScalerSetup ( XV_Hscaler_l2 * InstancePtr , u32 HeightIn , u32 WidthIn , u32 WidthOut , u32 ColorFormatIn , u32 ColorFormatOut ) { u32 PixelRate ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( ( HeightIn > 0 ) && ( HeightIn <= InstancePtr -> Hsc . Config . MaxHeight ) ) ; Xil_AssertNonvoid ( ( WidthIn > 0 ) && ( WidthIn <= InstancePtr -> Hsc . Config . MaxWidth ) ) ; Xil_AssertNonvoid ( ( WidthOut > 0 ) && ( WidthOut <= InstancePtr -> Hsc . Config . MaxWidth ) ) ; Xil_AssertNonvoid ( ( InstancePtr -> Hsc . Config . PixPerClk >= XVIDC_PPC_1 ) && ( InstancePtr -> Hsc . Config . PixPerClk <= XVIDC_PPC_8 ) ) ; if ( ! XV_HScalerValidateConfig ( InstancePtr , ColorFormatIn , ColorFormatOut ) ) { return XST_FAILURE ; } PixelRate = ( WidthIn * STEP_PRECISION ) / WidthOut ; if ( InstancePtr -> Hsc . Config . ScalerType == XV_HSCALER_POLYPHASE ) { if ( ! InstancePtr -> UseExtCoeff ) { XV_HScalerSelectCoeff ( InstancePtr , WidthIn , WidthOut ) ; } XV_HScalerSetCoeff ( InstancePtr ) ; } CalculatePhases ( InstancePtr , WidthIn , WidthOut , PixelRate ) ; XV_HScalerSetPhase ( InstancePtr ) ; XV_hscaler_Set_HwReg_Height ( & InstancePtr -> Hsc , HeightIn ) ; XV_hscaler_Set_HwReg_WidthIn ( & InstancePtr -> Hsc , WidthIn ) ; XV_hscaler_Set_HwReg_WidthOut ( & InstancePtr -> Hsc , WidthOut ) ; XV_hscaler_Set_HwReg_ColorMode ( & InstancePtr -> Hsc , ColorFormatIn ) ; XV_hscaler_Set_HwReg_ColorModeOut ( & InstancePtr -> Hsc , ColorFormatOut ) ; XV_hscaler_Set_HwReg_PixelRate ( & InstancePtr -> Hsc , PixelRate ) ; return XST_SUCCESS ; }
This function configures the scaler core registers with the specified
configuration parameters of the axi stream
This function configures the scaler core registers with the specified configuration parameters of the axi stream
/*
   * Assert validates the input arguments
   */ //No user defined coefficients /* Determine coefficient table to use */ /* Program generated coefficients into the IP register bank */ /* Compute Phase for 1 line */ /* Program computed Phase into the IP register bank */