MODIFICATION HISTORY:
Ver Who Date Changes ----- ---- -------- ------------------------------------------------------- 1.00a xd 02/10/09 First release 2.00a xd 12/14/09 Updated Doxygen document tags 4.01a cw 06/27/12 Updated tcl file with new parameter names (num_x_taps) Updated mdd file with updated supported_peripherals field. 4.02a mpv 03/11/13 Updated the Driver to select the correct coeff bin. Changed RegValue variable to a volatile type Removed 10.x patch in the Tcl file 4.03a mpv 05/28/13 Fixed version limit in MDD file Updated the Driver input, output and aperture size mask 5.00a mpv 12/13/13 Updated to dynamic coeff generation to reduce driver size 7.0 adk 08/22/14 Modified prototype of XScaler_GetVersion API. and functionality of StubCallBack. Modified assert conditions in functions XScaler_CfgInitialize, XScaler_SetPhaseNum, XScaler_LoadCoeffBank. Removed error callback from XScaler_CfgInitialize function. Uncommented XScaler_Reset in XScaler_CfgInitialize function. Removed ErrorMask parameter in StubCallBack as there was only one interrupt.
#include "xscaler.h"
#include "xenv.h"
#include "xil_io.h"
#include "xil_assert.h"
Utility Macros | |
#define | round(x) ((x) >= 0 ? (s32)((x) + 0.5) : (s32)((x) - 0.5)) |
Functions | |
s16 * | XScaler_GenCoefTable (u32 Tap, u32 Phase) |
int | XScaler_CfgInitialize (XScaler *InstancePtr, XScaler_Config *CfgPtr, u32 EffectiveAddr) |
int | XScaler_SetAperture (XScaler *InstancePtr, XScalerAperture *AperturePtr) |
void | XScaler_GetAperture (XScaler *InstancePtr, XScalerAperture *AperturePtr) |
void | XScaler_SetPhaseNum (XScaler *InstancePtr, u16 VertPhaseNum, u16 HoriPhaseNum) |
void | XScaler_GetPhaseNum (XScaler *InstancePtr, u16 *VertPhaseNumPtr, u16 *HoriPhaseNumPtr) |
void | XScaler_SetStartFraction (XScaler *InstancePtr, XScalerStartFraction *StartFractionPtr) |
void | XScaler_GetStartFraction (XScaler *InstancePtr, XScalerStartFraction *StartFractionPtr) |
void | XScaler_GetCoeffBankSharingInfo (XScaler *InstancePtr, u8 *ChromaFormat, u8 *ChromaLumaShareCoeff, u8 *HoriVertShareCoeff) |
s16 * | XScaler_CoefValueLookup (u32 InSize, u32 OutSize, u32 Tap, u32 Phase) |
void | XScaler_LoadCoeffBank (XScaler *InstancePtr, XScalerCoeffBank *CoeffBankPtr) |
void | XScaler_SetActiveCoeffSet (XScaler *InstancePtr, u8 VertSetIndex, u8 HoriSetIndex) |
void | XScaler_GetActiveCoeffSet (XScaler *InstancePtr, u8 *VertSetIndexPtr, u8 *HoriSetIndexPtr) |
u32 | XScaler_GetVersion (XScaler *InstancePtr) |
Variables | |
u16 | XScaler_CoefficientBinScalingFactors [XSCL_NUM_COEF_BINS] |
#define round | ( | x | ) | ((x) >= 0 ? (s32)((x) + 0.5) : (s32)((x) - 0.5)) |
This macro calculates the integral value nearest to x rounding half-way cases away from zero, regardless of the current rounding direction.
x | has a float type value |
int XScaler_CfgInitialize | ( | XScaler * | InstancePtr, | |
XScaler_Config * | CfgPtr, | |||
u32 | EffectiveAddr | |||
) |
This function initializes a Scaler device. This function must be called prior to using a Scaler device. Initialization of a Scaler includes setting up the instance data, and ensuring the hardware is in a quiescent state.
InstancePtr | is a pointer to the Scaler device instance to be worked on. | |
CfgPtr | points to the configuration structure associated with the Scaler device. | |
EffectiveAddr | is the base address of the device. If address translation is being used, then this parameter must reflect the virtual base address. Otherwise, the physical address should be used. |
s16* XScaler_CoefValueLookup | ( | u32 | InSize, | |
u32 | OutSize, | |||
u32 | Tap, | |||
u32 | Phase | |||
) |
This function returns the pointer to the coefficients for a scaling operation given input/output sizes and the Tap and Phase numbers.
InSize | indicates the size (width or height) of the input video. | |
OutSize | indicates the size (width or height) of the output video. | |
Tap | indicates the Tap number. | |
Phase | indicates the Phase number. |
s16* XScaler_GenCoefTable | ( | u32 | Tap, | |
u32 | Phase | |||
) |
This function generates a table that contains the coefficient values for scaling operations
Tap | indicates the number of taps configured to the Scaler device. | |
Phase | indicates the number of phase configured to the Scaler device. |
void XScaler_GetActiveCoeffSet | ( | XScaler * | InstancePtr, | |
u8 * | VertSetIndexPtr, | |||
u8 * | HoriSetIndexPtr | |||
) |
This function fetches the indexes of active vertical and horizontal coefficient sets being used by a Scaler device.
Each coefficient set contains 4 banks: Horizontal Luma, Horizontal Chroma, Vertical Luma and Vertical Chroma. The horizontal part is independent from the vertical part and the Scaler device supports using the horizontal part of one coefficient set w/ the vertical part of a different coefficient set.
InstancePtr | is a pointer to the Scaler device instance to be worked on. | |
VertSetIndexPtr | points to the index of the active coefficient set in which the vertical part is being used by the Scaler device after this function returns. | |
HoriSetIndexPtr | points to the index of the active coefficient set in which the horizontal part is being used by the Scaler device after this function returns. |
void XScaler_GetAperture | ( | XScaler * | InstancePtr, | |
XScalerAperture * | AperturePtr | |||
) |
This function gets aperture of a Scaler device. The aperture setting consists of input video aperture and output video size.
InstancePtr | is a pointer to the Scaler device instance to be worked on. | |
AperturePtr | points to the aperture structure to store the current Scaler device setting after this function returns. |
void XScaler_GetCoeffBankSharingInfo | ( | XScaler * | InstancePtr, | |
u8 * | ChromaFormat, | |||
u8 * | ChromaLumaShareCoeff, | |||
u8 * | HoriVertShareCoeff | |||
) |
This function fetches the color space format and coefficient bank sharing decisions made on a Scaler device at build-time.
InstancePtr | is a pointer to the Scaler device instance to be worked on. | |
ChromaFormat | points to an 8-bit variable that will be assigned with the Chroma format chosen for the Scaler device at the build time after this function returns. Please use XSCL_CHROMA_FORMAT_* defined in xscaler_hw.h to interpret the variable value. | |
ChromaLumaShareCoeff | points to an 8-bit variable that will be assigned by this function with the decision value on coefficient bank sharing between Chroma and Luma filter operations. The decision is made for the Scaler device at build time and can NOT be changed at run-time. Value 0 indicates that each of Chroma and Luma filter operations has its own coefficient bank. Value 1 indicates that Chroma and Luma filter operations share one common coefficient bank. | |
HoriVertShareCoeff | points to an 8-bit variable that will be assigned by this function with the decision value on coefficient bank sharing between Horizontal and Vertical filter operations. The decision is made for the Scaler device at build time and can NOT be changed at run-time. Value 0 indicates that each of Horizontal and Vertical filter operations has its own coefficient bank. Value 1 indicates that Horizontal and Vertical filter operations share one common coefficient bank. |
The application of this function is responsible for loading the correct number of coefficient banks in the proper sequence order. The number of coefficient banks to load and the proper loading sequence totally depends on the values of the output parameters of this function. Please use the table below as reference.
ChromaFormat ChromaLumaShareCoeff HoriVertShareCoeff # of sequence coeff of banks loading to load coeff banks ------------ -------------------- ------------------ -------- ------------- YUV420 1 1 1 1.Single bank ------------ -------------------- ------------------ -------- ------------- YUV420 1 0 2 1.Hori bank 2.Vert bank ------------ -------------------- ------------------ -------- ------------- YUV420 0 1 2 1.Luma bank 2.Chroma bank ------------ -------------------- ------------------ -------- ------------- YUV420 0 0 4 1.Hori Luma 2.Hori Chroma 3.Vert Luma 4.Vert Chroma ------------ -------------------- ------------------ -------- ------------- YUV422 1 1 1 1.Single bank ------------ -------------------- ------------------ -------- ------------- YUV422 1 0 2 1.Hori bank 2.Vert bank ------------ -------------------- ------------------ -------- ------------- YUV422 0 1 2 1.Luma bank 2.Chroma bank ------------ -------------------- ------------------ -------- ------------- YUV422 0 0 4 1.Hori Luma 2.Hori Chroma 3.Vert Luma 4.Vert Chroma ------------ -------------------- ------------------ -------- ------------- YUV444 Always 1 1 1 1.Single bank ------------ -------------------- ------------------ -------- ------------- YUV444 Always 1 0 2 1.Hori bank 2.Vert bank ------------ -------------------- ------------------ -------- -------------
void XScaler_GetPhaseNum | ( | XScaler * | InstancePtr, | |
u16 * | VertPhaseNumPtr, | |||
u16 * | HoriPhaseNumPtr | |||
) |
This function gets the numbers of vertical and horizontal phases currently used by a Scaler device.
InstancePtr | is a pointer to the Scaler device instance to be worked on. | |
VertPhaseNumPtr | will point to the number of vertical phases used after this function returns. | |
HoriPhaseNumPtr | will point to the number of horizontal phases used after this function returns. |
void XScaler_GetStartFraction | ( | XScaler * | InstancePtr, | |
XScalerStartFraction * | StartFractionPtr | |||
) |
This function gets Luma and Chroma start fractional values currently used by a Scaler device.
InstancePtr | is a pointer to the Scaler device instance to be worked on. | |
StartFractionPtr | is a pointer to a start fractional value structure to be populated with the fractional values after this function returns. |
u32 XScaler_GetVersion | ( | XScaler * | InstancePtr | ) |
This function returns the contents of version register of the Scaler core.
InstancePtr | is a pointer to the Scaler core instance to be worked on. |
void XScaler_LoadCoeffBank | ( | XScaler * | InstancePtr, | |
XScalerCoeffBank * | CoeffBankPtr | |||
) |
This function loads a coefficient bank to the Scaler core. A complete coefficient set contains 4 banks (if Luma, Chroma, Horizontal and Vertical filter operations do not share common banks. For more details see XScaler_GetCoeffBankSharingInfo()): Horizontal Luma, Horizontal Chroma, Vertical Luma and Vertical Chroma. all 4 banks must be loaded back to back in the order listed here. The caller is responsible for ensuring the sequence and this function does not check it.
An example sequence to load an whole coefficient set is like:
XScaler_LoadCoeffBank(&Scaler, &HoriLumaCoeffBank); XScaler_LoadCoeffBank(&Scaler, &HoriChromaCoeffBank); XScaler_LoadCoeffBank(&Scaler, &VertLumaCoeffBank); XScaler_LoadCoeffBank(&Scaler, &VertChromaCoeffBank);
InstancePtr | is a pointer to the Scaler device instance to be worked on. | |
CoeffBankPtr | is a pointer to a coefficient bank that is to be loaded. |
void XScaler_SetActiveCoeffSet | ( | XScaler * | InstancePtr, | |
u8 | VertSetIndex, | |||
u8 | HoriSetIndex | |||
) |
This function chooses the active vertical and horizontal coefficient sets to be used by a Scaler device.
Each coefficient set contains 4 banks: Horizontal Luma, Horizontal Chroma, Vertical Luma and Vertical Chroma. The horizontal part is independent from the vertical part and the Scaler device supports using the horizontal part of one coefficient set w/ the vertical part of a different coefficient set.
InstancePtr | is a pointer to the Scaler device instance to be worked on. | |
VertSetIndex | indicates the index of the coefficient set in which the vertical part will be used by the Scaler device. Valid value is from 0 to (the number of the coefficient sets implemented by the Scaler device - 1). | |
HoriSetIndex | indicates the index of the coefficient set in which the horizontal part will be used by the Scaler device. Valid value is from 0 to (the number of the coefficient sets implemented by the Scaler device - 1). |
int XScaler_SetAperture | ( | XScaler * | InstancePtr, | |
XScalerAperture * | AperturePtr | |||
) |
This function sets up aperture of a Scaler device. The aperture setting consists of input video aperture and output video size. This function calculates the scale factor accordingly based on the aperture setting and sets up the Scaler appropriately.
InstancePtr | is a pointer to the Scaler device instance to be worked on. | |
AperturePtr | points to the aperture setting structure to set up the Scaler device. |
void XScaler_SetPhaseNum | ( | XScaler * | InstancePtr, | |
u16 | VertPhaseNum, | |||
u16 | HoriPhaseNum | |||
) |
This function sets the numbers of vertical and horizontal phases to be used by a Scaler device.
InstancePtr | is a pointer to the Scaler device instance to be worked on. | |
VertPhaseNum | is the number of vertical phase to set to | |
HoriPhaseNum | is the number of horizontal phase to set to |
void XScaler_SetStartFraction | ( | XScaler * | InstancePtr, | |
XScalerStartFraction * | StartFractionPtr | |||
) |
This function sets up Luma and Chroma start fractional values used by a Scaler device.
InstancePtr | is a pointer to the Scaler device instance to be worked on. | |
StartFractionPtr | is a pointer to a start fractional value set to be used. |
u16 XScaler_CoefficientBinScalingFactors[XSCL_NUM_COEF_BINS] |
XScaler_CoefficientsBinScalingFactors contains scaling factors calculated using (Output_Size * 10000 / Input_Size). This table could help find the index of coefficient Bin given an input size and a output size.
Copyright @ 1995-2014 Xilinx, Inc. All rights reserved.