To better understand the driver usage, consider the following test case scenario. Suppose the core in the design was configured with few memory layers and each layer has certain optional features, like alpha blending and/or scaling enabled, and that the logo layer is enabled with the optional color key feature. Because memory layers are being used, there are sources in the design that generates frame data for each of the Video Mixer memory layers. The application should allocate required frame buffer space per layer in memory. These addresses should be updated during the interrupt.
To integrate and use the Video Mixer driver in the application, the following steps should be followed:
1. Include the driver header file xv_mix_l2.h that contains the mixer instance object definition.
2. Declare an instance of the Video Mixer type: XV_Mix_l2 Mixer ;
3. Initialize the Video Mixer instance at power on:
int XVMix_Initialize(XV_Mix_l2 *InstancePtr, u16 DeviceId);
This function accesses the hardware configuration and initializes the core to the power on default state.
° Set Master layer to 1080p.
° Set Background color to blue.
° Enable the master layer.
° Set the operating mode to Auto Restart .
4. If the core is operating in interrupt mode, the application needs to perform the tasks mentioned, that is, register the ISR with the system interrupt controller and set the application callback function. This function is called by the Video Mixer driver when the frame done IRQ is triggered.
5. If applicable, write the application level callback function. An example action to be performed here would be to update layer buffer addresses from where to read the next frame data for each layer. This allows the application to render the frame updates in memory, on screen.
6. Write a function to configure the core. The following is a sample event sequence that might be performed here:
a. Set the master layer video stream properties:
void XVMix_SetVidStream(XV_Mix_l2 *InstancePtr,
const XVidC_VideoStream *StrmIn);
b. For each memory layer, set the frame buffer base address:
int XVMix_SetLayerBufferAddr(XV_Mix_l2 *InstancePtr,
c. For semi-planar formats, set the buffer base address for the second plane:
int XVMix_SetLayerChromaBufferAddr(XV_Mix_l2 *InstancePtr,
d. If logo layer is enabled, load the logo data:
int XVMix_LoadLogo(XV_Mix_l2 *InstancePtr,
e. If logo color key feature is enabled, set the default color key data:
int XVMix_SetLogoColorKey(XV_Mix_l2 *InstancePtr,
f. For each layer, set the window properties:
int XVMix_SetLayerWindow(XV_Mix_l2 *InstancePtr,
g. Enable the interrupts (if operating in interrupt mode):
void XVMix_InterruptEnable(XV_Mix_l2 *InstancePtr);
h. Enable the master layer (and additional memory layers if needed). (Enable streaming layers only when they start to receive video input on that layer.):
int XVMix_LayerEnable(XV_Mix_l2 *InstancePtr, XVMix_LayerId LayerId);
i. Finally, start the core:
void XVMix_Start(XV_Mix_l2 *InstancePtr);
7. If optional features like alpha blending, enable CSC coefficient registers or scaling are enabled for a given layer, then these can be updated using the provided APIs.
int XVMix_SetLayerAlpha(XV_Mix_l2 *InstancePtr,
int XVMix_SetLayerScaleFactor(XV_Mix_l2 *InstancePtr,
int XVMix_SetLayerScaleFactor(XV_Mix_l2 *InstancePtr,
u32 XVMix_SetCscCoeffs(XV_Mix_l2 *InstancePtr,XVidC_ColorStd colorStandard,
XVidC_ColorRange colorRange, u8 colorDepth);
You are encouraged to experiment with other APIs that allow the layer window to be resized or moved on the screen or change logo color key information, if applicable. Each API provides a return value indicating if the desired action was successful or not.
Also, to help debug the Video Mixer , two Debug APIs are available that provide the state of the core:
void XVMix_DbgReportStatus(XV_Mix_l2 *InstancePtr);
void XVMix_DbgLayerInfo(XV_Mix_l2 *InstancePtr, XVMix_LayerId LayerId);
a. Resolution changes are not possible on the fly. If either the master input stream resolution changes during operation or the output resolution needs to be changed, then the application must reset the Video Mixer , that is, toggle ap_rst_n , and reconfigure the core for the new resolution. After reset, all registers are cleared to 0.
b. Certain actions cannot be performed when the core is in middle of processing a frame. For example, if a window has to be resized or the scaling factor has to be changed for a layer, then this layer should be disabled first. Next, apply the new settings and lastly re-enable the layer. Alternatively, in interrupt mode these operations can be done in the user callback function registered with the mixer interrupt service routine.
c. When resizing, moving, or scaling a layer window, the driver checks to ensure that the window properties provided does not cause the new window to go out of frame boundary. If any of these actions cause such a condition, then the action cannot applied and the API returns with an error code. The application code should check the return status of all APIs to make sure the required action was completed successfully and if not take corrective action.
d. Do not enable any layer until you start receiving video input on that layer. If a layer is enabled before receiving the stream, the IP can freeze and then you must apply a hard reset on the IP. A hard reset is the only way to recover after the IP is in this frozen state.