UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
586 Views
Registered: ‎01-21-2019

VPSS API Basics

Jump to solution

All,

I have been trying to get the VPSS up and running. It seems like I am very close but it's still not working correctly. Interlaced doesn't work at all and the progressive images look like every-other pixel is darker giving the appearance of vertical lines, one pixel wide for the entire frame. Not at all what one might expect. I get no errors and the log files says everything is awesome; init, config, starting, etc. all good.

In very basic terms, here is how I am applying the API calls:  (assume that I have already setup the VTG properly - the VTG has been rock-solid!)

// Video Subsystem Initialization
XVprocSs_SetFrameBufBaseaddr(&VprocInst0, USR_FRAME_BUF_BASEADDR0);
VprocSsConfigPtr0 = XVprocSs_LookupConfig(XPAR_XVPROCSS_0_DEVICE_ID);
if(VprocSsConfigPtr0 == NULL) {
xil_printf("ERR:: VprocSs device not found\r\n");
return (XST_DEVICE_NOT_FOUND);
}

Status = XVprocSs_CfgInitialize(&VprocInst0,
VprocSsConfigPtr0,
VprocSsConfigPtr0->BaseAddress);
if(Status != XST_SUCCESS) {
xil_printf("ERR:: Video Processing Subsystem Init. error\n\r");
return(XST_FAILURE);
}

// The deinterlizer chooses the best method if set to zero.
// XV_deinterlacer_Set_algo(VprocInst0.DeintPtr,ALGO_VERT_TEMP_LINEAR);
XV_deinterlacer_Set_algo(VprocInst0.DeintPtr,0);

// Configure Output Stream Settings
CurVideoMode = XVIDC_VM_1920x1080_60_P;
TimingPtr = XVidC_GetTimingInfo(CurVideoMode);
XVidC_SetVideoStream(&vidStrmOut, CurVideoMode, XVIDC_CSF_RGB, XVIDC_BPC_10, XVIDC_PPC_2); // SetStreamResolution fills in the viStrmOut structure.
vidStrmOut.FrameRate = XVIDC_FR_60HZ;
vidStrmOut.IsInterlaced = FALSE;
vidStrmOut.AspectRatio = XVIDC_AR_16_9;
XVprocSs_SetVidStreamOut(&VprocInst0, &vidStrmOut); // SetVidStreamOut sets the actual video stream output of the VPSS

// Configure Input Stream Settings
CurVideoMode = XVIDC_VM_1920x1080_60_P;
TimingPtr = XVidC_GetTimingInfo(CurVideoMode);
XVidC_SetVideoStream(&vidStrmIn, CurVideoMode, XVIDC_CSF_RGB, XVIDC_BPC_10, XVIDC_PPC_2);
vidStrmIn.FrameRate = XVIDC_FR_60HZ;
vidStrmIn.IsInterlaced = FALSE;
XVprocSs_SetVidStreamIn(&VprocInst0, &vidStrmIn);

print("\n\r- Setting SubsystemConfig.");
Status = XVprocSs_SetSubsystemConfig(&VprocInst0);
if(Status != XST_SUCCESS) {
xil_printf("ERR:: Set Subsystem 0 Config error\n\r");
return(XST_FAILURE);
}

// Display Log Info at this point.
XVprocSs_LogDisplay(&VprocInst0);
XVprocSs_LogReset(&VprocInst0);

XVidC_ReportStreamInfo(&VprocInst0.VidOut);
XVidC_ReportTiming(TimingPtr, XVidC_IsInterlaced(CurVideoMode));

Then, we react when we notice a change in resolution reg[0,0] = HActive, reg[0,1] = VActive: (Note: We are keeping the output at 1080p for now.)

XVprocSs_LogReset(&VprocInst0);

print("\n\rNew Input Resolution Detected on RTL0.");
xil_printf("\n\r- Horizontal Active %d", reg[0][0]);
xil_printf("\n\r- Vertical Active %d", reg[0][1]);
i = (unsigned char)((XVtc_ReadReg((UINTPTR)XPAR_AXIS_AURORA2VMDA_0_BASEADDR, LINK_STATUS) & 0x00000010) >> 4);
xil_printf("\n\r- Interlaced: %c\n\r", i == 0? 'N' : 'Y' );

print("\n\r- Turning RTL Pipe Off.");
RTL_STOP( XPAR_AXIS_AURORA2VMDA_0_BASEADDR ); // Begin by stopping the pipe from Axi to VDMA so minimal data is lost.
msDelay(100); // Add delay before enabling VMDA and VTG

print("\n\r- Setting New Input Stream Data for the VPSS.");
// Configure Output Stream Settings
CurVideoMode = XVIDC_VM_1920x1080_60_P;
TimingPtr = XVidC_GetTimingInfo(CurVideoMode);
XVidC_SetVideoStream(&vidStrmOut, CurVideoMode, XVIDC_CSF_RGB, XVIDC_BPC_10, XVIDC_PPC_2);
vidStrmOut.FrameRate = XVidC_GetFrameRate(CurVideoMode);
vidStrmOut.IsInterlaced = FALSE;
vidStrmOut.AspectRatio = XVIDC_AR_16_9;  // For some reason, VPSS is calling 1080p a 4:3 ratio image.
XVprocSs_SetVidStreamOut(&VprocInst0, &vidStrmOut); // SetVidStreamOut sets the actual video stream output of the VPSS

// Configure Input Stream Settings
//                                  HActive,  VActive,   Assume 60Hz,   Interlaced Flag
CurVideoMode = XVidC_GetVideoModeId(reg[0][0],reg[0][1], XVIDC_FR_60HZ, i);
if (CurVideoMode == XVIDC_VM_NOT_SUPPORTED)
print("\n\n*** ERROR: Resolution Not Supported!");
else
{
TimingPtr = XVidC_GetTimingInfo(CurVideoMode);
XVidC_SetVideoStream(&vidStrmIn, CurVideoMode, XVIDC_CSF_RGB, XVIDC_BPC_10, XVIDC_PPC_2);
vidStrmIn.FrameRate = XVidC_GetFrameRate(CurVideoMode);
vidStrmIn.IsInterlaced = XVidC_IsInterlaced(CurVideoMode);
XVprocSs_SetVidStreamIn(&VprocInst0, &vidStrmIn);
}

print("\n\r- Setting SubsystemConfig.");
Status = XVprocSs_SetSubsystemConfig(&VprocInst0);
if(Status != XST_SUCCESS) {
xil_printf("ERR:: Set Subsystem 0 Config error\n\r");
return(XST_FAILURE);
}

print("\n\r- Generating Status Message/Report.");
// Display Log Info at this point.
XVprocSs_LogDisplay(&VprocInst0);
print("\n\r- Input Signal VidIn (from a table)");
XVidC_ReportStreamInfo(&VprocInst0.VidIn);

// Turn pipe on
print("\n\r- Turning RTL Pipe On.");
RTL_START( XPAR_AXIS_AURORA2VMDA_0_BASEADDR );

Do you have any suggestions for me to try?  I am at a loss as what to try next. I have been trying to utilize the samples but I have not had much success.

BTW, the full application is linked below, "memorytest.c".  I've tried to keep this file as clean as I can so it is easy to read and debug.

Thank you for your assistance!

Phil

 

0 Kudos
1 Solution

Accepted Solutions
35 Views
Registered: ‎01-21-2019

Re: VPSS API Basics

Jump to solution

We finally got the VPSS to work pretty good. Everything seems to work just fine except for the Deinterlacer.

You were correct, the VPSS requires the defining of the input and output streams. But, that isn't all.  One needs to run the SetSubSystemConfig after defining the input and output streams.

Here is how this turned out.

Initializing
-------------------------

print("\n\rInitializing Timing Generator");
// Initialize Video Timing Generator
Vtg_Config0 = XVtc_LookupConfig(XPAR_VTC_0_DEVICE_ID);
if (!Vtg_Config0) {
xil_printf("No VTC found for ID %d\r\n", XPAR_VTC_0_DEVICE_ID);

return XST_FAILURE;
}

Status = XVtc_CfgInitialize(&VtcInst0, Vtg_Config0, Vtg_Config0->BaseAddress);
if (Status != XST_SUCCESS) {
xil_printf("VTC Failed to Configure for ID %d\r\n", XPAR_VTC_0_DEVICE_ID);

return XST_FAILURE;
}


XVtc_WriteReg( VtcInst0.Config.BaseAddress, XVTC_IER_OFFSET, XVTC_IXR_LOCKALL_MASK); // Write VTC IRQ Enable Register
XVtc_SetCallBack( &VtcInst0, XVTC_HANDLER_FRAMESYNC, &psVTcFSHdlr0, (void *)&VtcInst0);
XVtc_SetCallBack( &VtcInst0, XVTC_HANDLER_LOCK, &psVTcLkHdlr0, (void *)&VtcInst0);
XVtc_SetCallBack( &VtcInst0, XVTC_HANDLER_GENERATOR, &psVTcGenHdlr0, (void *)&VtcInst0);
XVtc_SetCallBack( &VtcInst0, XVTC_HANDLER_ERROR, &psVTcErrHdlr0, (void *)&VtcInst0);

// Setting VTG Generator properties
print("\n\r- Setting Video Timing Generator.");
// Set VTG for 1080p@60Hz
VtcVideoTiming0.HActiveVideo = 1920;
VtcVideoTiming0.VActiveVideo = 1080;
VtcVideoTiming0.Interlaced = 0;
vid_mode0 = XVtc_ConvTiming2VideoMode( &VtcInst0, &VtcVideoTiming0);
XVtc_SetGeneratorVideoMode(&VtcInst0, vid_mode0);

// Start VTG Generator
print("\n\r- Starting Video Timing Generator.");
XVtc_EnableGenerator(&VtcInst0);

// Initialize Video Subsystem
print("\n\rInitializing Video Processing SubSystem, Channel 0.");

// Video Subsystem Initialization
XVprocSs_SetFrameBufBaseaddr(&VprocInst0, USR_FRAME_BUF_BASEADDR0);
VprocSsConfigPtr0 = XVprocSs_LookupConfig(XPAR_XVPROCSS_0_DEVICE_ID);
if(VprocSsConfigPtr0 == NULL) {
xil_printf("ERR:: VprocSs device not found\r\n");
return (XST_DEVICE_NOT_FOUND);
}

Status = XVprocSs_CfgInitialize(&VprocInst0,
VprocSsConfigPtr0,
VprocSsConfigPtr0->BaseAddress);
if(Status != XST_SUCCESS) {
xil_printf("ERR:: Video Processing Subsystem Init. error\n\r");
return(XST_FAILURE);
}

Then Set Stream
-------------------------------

// Get Input Stream Settings and Validate
// HActive, VActive, Assume 60Hz, Interlaced Flag
VideoMode = XVidC_GetVideoModeId(Hactive,Vactive, XVIDC_FR_60HZ, IntFlag);
if (VideoMode == XVIDC_VM_NOT_SUPPORTED)
print("\n\nResolution Not Supported. Ignoring this resolution change request.");
else
{

// If video output resolution changes, here is where we put the VTG setup and restart VTG.
//
//

// Configure VPSS Input Stream Settings based upon the new requested video resolution (video id).
XVidC_SetVideoStream(&VideoStream, VideoMode, XVIDC_CSF_RGB, XVIDC_BPC_10, XVIDC_PPC_2);
VideoStream.FrameRate = XVidC_GetFrameRate(VideoMode);
VideoStream.IsInterlaced = XVidC_IsInterlaced(VideoMode);
XVprocSs_SetVidStreamIn(&VprocInst0, &VideoStream);

// Configure Output Stream Settings - We are defaulting to 1080p for now.
VideoMode = XVIDC_VM_1920x1080_60_P;
XVidC_SetVideoStream(&VideoStream, VideoMode, XVIDC_CSF_RGB, XVIDC_BPC_10, XVIDC_PPC_2);
VideoStream.FrameRate = XVidC_GetFrameRate(VideoMode);
VideoStream.IsInterlaced = FALSE;
VideoStream.AspectRatio = XVIDC_AR_16_9;
XVprocSs_SetVidStreamOut(&VprocInst0, &VideoStream); // SetVidStreamOut sets the actual video stream output of the VPSS

print("\n\r- Writing VPSS Subsystem Config Info.");
Status = XVprocSs_SetSubsystemConfig(&VprocInst0);
if(Status != XST_SUCCESS) {
xil_printf("ERR:: Set Subsystem 0 Config error\n\r");
return(XST_FAILURE);
}

// Display Log Info at this point.
XVprocSs_LogDisplay(&VprocInst0);
}

 

Thank you for all your help!

Phil

9 Replies
Moderator
Moderator
534 Views
Registered: ‎11-09-2015

Re: VPSS API Basics

Jump to solution

HI phil@pswitchers.com ,

  • Can you give some details on how the VPSS is configured in vivado?
  • What vivado version are you using (I assume 2018.3?)
  • What do you get in the UART when you display the log?

For recomendation on what to try, I would refer the example design with the TPG as input. Can you reproduce with the same configuration?


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
528 Views
Registered: ‎01-21-2019

Re: VPSS API Basics

Jump to solution

Florentw,

VPSS is configured in Full Fledge Mode, RGB&YUV444 mode, 2 pix/clk, 10 bit clr, 1920 max h, 1080 max v, intl enabled, int dma enabled, scaler polyphase, hor taps 6, ver taps 6, hor phase 64, ver phase 64, color matrix demo window disabled. 

We are using 2017.4 but we have also tried 2018.3 and the results are the same. 2017.4 seems more stable for our Vivado development so we are sticking with that for now.

We use the Log continually. There is no indications of errors at any stage.

Also, one of our engineers has another post showing some of our artifacts:  

https://forums.xilinx.com/t5/Video/VPSS-pipeline-and-Deinterlacer-causing-problems/td-p/960202

I have studied the same code quite a bit and I think we are doing everything correctly. It would be nice if we could boil the API down to a series of high-level calls done in a certain order to demonstrate the VPSS.  For example, initialization, setting the output stream, setting the input stream, and launching the VPSS. It seems to me it really should be this simple. The API takes care of the details.

0 Kudos
Moderator
Moderator
509 Views
Registered: ‎11-09-2015

Re: VPSS API Basics

Jump to solution

phil@pswitchers.com wrote:

Florentw,

VPSS is configured in Full Fledge Mode, RGB&YUV444 mode, 2 pix/clk, 10 bit clr, 1920 max h, 1080 max v, intl enabled, int dma enabled, scaler polyphase, hor taps 6, ver taps 6, hor phase 64, ver phase 64, color matrix demo window disabled. 

We are using 2017.4 but we have also tried 2018.3 and the results are the same. 2017.4 seems more stable for our Vivado development so we are sticking with that for now.

We use the Log continually. There is no indications of errors at any stage.

Also, one of our engineers has another post showing some of our artifacts:  

https://forums.xilinx.com/t5/Video/VPSS-pipeline-and-Deinterlacer-causing-problems/td-p/960202

I have studied the same code quite a bit and I think we are doing everything correctly. It would be nice if we could boil the API down to a series of high-level calls done in a certain order to demonstrate the VPSS.  For example, initialization, setting the output stream, setting the input stream, and launching the VPSS. It seems to me it really should be this simple. The API takes care of the details.

[Florent] - Did you ever look at the example application. It is doing a really high level. Usually you just have to set the parameters for input and output streams and you should be able to have the VPSS up and running


 


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
488 Views
Registered: ‎01-21-2019

Re: VPSS API Basics

Jump to solution

I have been studying two particular examples:

Xapp1285

Xapp1291

Neither offers a simple example like we have discussed. One has to do a lot of searching between files to get the full picture. I think I have done a good job of simplification but it is still not working so I am sure I am doing something wrong.

If you have another example you want me to look at, I am very open to new data.

Thank you.

Phil

0 Kudos
Moderator
Moderator
451 Views
Registered: ‎11-09-2015

Re: VPSS API Basics

Jump to solution

Hi phil@pswitchers.com 

For a simple example, follow PG231 chapter 5.

 


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
440 Views
Registered: ‎01-21-2019

Re: VPSS API Basics

Jump to solution

This is an example of the Vivado portion but doesn't demonstrate the SDK. I will look at the SDK wiki again but it only showed prototype calls and abbreviated function definitions as I remember.

0 Kudos
Moderator
Moderator
437 Views
Registered: ‎11-09-2015

Re: VPSS API Basics

Jump to solution

Hi phil@pswitchers.com ,

Look a bit further in the chapter. It describe how to generate the SDK application.

Regards,


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Moderator
Moderator
119 Views
Registered: ‎11-09-2015

Re: VPSS API Basics

Jump to solution

Hi phil@pswitchers.com ,

Do you have any updates on this? Were you able to generate the SDK example application? Did it help you?

Note that the flow to generate the application example as changed in 2018.3. I have documented it in my

Video Series 27: Getting started with the Video Processing Subsystem IP

 

Regards,


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
36 Views
Registered: ‎01-21-2019

Re: VPSS API Basics

Jump to solution

We finally got the VPSS to work pretty good. Everything seems to work just fine except for the Deinterlacer.

You were correct, the VPSS requires the defining of the input and output streams. But, that isn't all.  One needs to run the SetSubSystemConfig after defining the input and output streams.

Here is how this turned out.

Initializing
-------------------------

print("\n\rInitializing Timing Generator");
// Initialize Video Timing Generator
Vtg_Config0 = XVtc_LookupConfig(XPAR_VTC_0_DEVICE_ID);
if (!Vtg_Config0) {
xil_printf("No VTC found for ID %d\r\n", XPAR_VTC_0_DEVICE_ID);

return XST_FAILURE;
}

Status = XVtc_CfgInitialize(&VtcInst0, Vtg_Config0, Vtg_Config0->BaseAddress);
if (Status != XST_SUCCESS) {
xil_printf("VTC Failed to Configure for ID %d\r\n", XPAR_VTC_0_DEVICE_ID);

return XST_FAILURE;
}


XVtc_WriteReg( VtcInst0.Config.BaseAddress, XVTC_IER_OFFSET, XVTC_IXR_LOCKALL_MASK); // Write VTC IRQ Enable Register
XVtc_SetCallBack( &VtcInst0, XVTC_HANDLER_FRAMESYNC, &psVTcFSHdlr0, (void *)&VtcInst0);
XVtc_SetCallBack( &VtcInst0, XVTC_HANDLER_LOCK, &psVTcLkHdlr0, (void *)&VtcInst0);
XVtc_SetCallBack( &VtcInst0, XVTC_HANDLER_GENERATOR, &psVTcGenHdlr0, (void *)&VtcInst0);
XVtc_SetCallBack( &VtcInst0, XVTC_HANDLER_ERROR, &psVTcErrHdlr0, (void *)&VtcInst0);

// Setting VTG Generator properties
print("\n\r- Setting Video Timing Generator.");
// Set VTG for 1080p@60Hz
VtcVideoTiming0.HActiveVideo = 1920;
VtcVideoTiming0.VActiveVideo = 1080;
VtcVideoTiming0.Interlaced = 0;
vid_mode0 = XVtc_ConvTiming2VideoMode( &VtcInst0, &VtcVideoTiming0);
XVtc_SetGeneratorVideoMode(&VtcInst0, vid_mode0);

// Start VTG Generator
print("\n\r- Starting Video Timing Generator.");
XVtc_EnableGenerator(&VtcInst0);

// Initialize Video Subsystem
print("\n\rInitializing Video Processing SubSystem, Channel 0.");

// Video Subsystem Initialization
XVprocSs_SetFrameBufBaseaddr(&VprocInst0, USR_FRAME_BUF_BASEADDR0);
VprocSsConfigPtr0 = XVprocSs_LookupConfig(XPAR_XVPROCSS_0_DEVICE_ID);
if(VprocSsConfigPtr0 == NULL) {
xil_printf("ERR:: VprocSs device not found\r\n");
return (XST_DEVICE_NOT_FOUND);
}

Status = XVprocSs_CfgInitialize(&VprocInst0,
VprocSsConfigPtr0,
VprocSsConfigPtr0->BaseAddress);
if(Status != XST_SUCCESS) {
xil_printf("ERR:: Video Processing Subsystem Init. error\n\r");
return(XST_FAILURE);
}

Then Set Stream
-------------------------------

// Get Input Stream Settings and Validate
// HActive, VActive, Assume 60Hz, Interlaced Flag
VideoMode = XVidC_GetVideoModeId(Hactive,Vactive, XVIDC_FR_60HZ, IntFlag);
if (VideoMode == XVIDC_VM_NOT_SUPPORTED)
print("\n\nResolution Not Supported. Ignoring this resolution change request.");
else
{

// If video output resolution changes, here is where we put the VTG setup and restart VTG.
//
//

// Configure VPSS Input Stream Settings based upon the new requested video resolution (video id).
XVidC_SetVideoStream(&VideoStream, VideoMode, XVIDC_CSF_RGB, XVIDC_BPC_10, XVIDC_PPC_2);
VideoStream.FrameRate = XVidC_GetFrameRate(VideoMode);
VideoStream.IsInterlaced = XVidC_IsInterlaced(VideoMode);
XVprocSs_SetVidStreamIn(&VprocInst0, &VideoStream);

// Configure Output Stream Settings - We are defaulting to 1080p for now.
VideoMode = XVIDC_VM_1920x1080_60_P;
XVidC_SetVideoStream(&VideoStream, VideoMode, XVIDC_CSF_RGB, XVIDC_BPC_10, XVIDC_PPC_2);
VideoStream.FrameRate = XVidC_GetFrameRate(VideoMode);
VideoStream.IsInterlaced = FALSE;
VideoStream.AspectRatio = XVIDC_AR_16_9;
XVprocSs_SetVidStreamOut(&VprocInst0, &VideoStream); // SetVidStreamOut sets the actual video stream output of the VPSS

print("\n\r- Writing VPSS Subsystem Config Info.");
Status = XVprocSs_SetSubsystemConfig(&VprocInst0);
if(Status != XST_SUCCESS) {
xil_printf("ERR:: Set Subsystem 0 Config error\n\r");
return(XST_FAILURE);
}

// Display Log Info at this point.
XVprocSs_LogDisplay(&VprocInst0);
}

 

Thank you for all your help!

Phil