Inserting Buffer into existing DMA Channel

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
jnagy
Level 5
Level 5
5 solutions authored 100 replies posted 100 sign-ins

I am implementing a UVC application using a manual, 2 socket, many-to-one DMA. We are encountering output buffer overruns so I would like to send error packets to the sink to notify of this issue. Reading the UVC spec, it seems I can send UVC packets containing just the UVC header and error bit set for the duration of the overruns.

The example USBVideoClassBulk manually inserts buffers into a DMA channel with no buffers however I would be inserting into a DMA with 2 buffers per socket.

Is this understanding correct? If so, how can I insert an empty buffer into the existing DMA channel? If I am incorrect, how should I handle the output buffer overruns?

0 Likes
1 Solution
Ajeethkumar_P
Moderator
Moderator
Moderator
50 likes received 500 replies posted 100 solutions authored

Hi Jason,

The Host Applications might not follow the complete UVC Specification like this Error Handling. You can check with appropriate Host applications to see how those applications handle once the error packet is received. Else, try to re-enumerate or restart the UVC transfer once all the buffers in the FX3 are filled as FPGA FULL and WATERMARK flags can assert only when all the DMA buffers are full. This is because the Host is not fast enough to poll the data.

Regards,
Ajeeth

View solution in original post

0 Likes
7 Replies
Ajeethkumar_P
Moderator
Moderator
Moderator
50 likes received 500 replies posted 100 solutions authored

Hi,

Write overrun can occur when you try to write beyond the available buffer size. DMA Buffer size(Should be multiple of 16) and the count would be configured while creating the DMA Channel using CyU3PDmaChannelCreate or CyU3PDmaMultiChannelCreate API.

USBVideoClassBulk copies the data to the DMA buffer up to the DMA buffer size minus the UVC Header and Footer size. This is done using CyU3PDmaChannelGetBuffer API to get the buffer, copy the data into this buffer obtained and commit the data using CyU3PDmaChannelCommitBuffer. For Multichannel-DMA, CyU3PDmaMultiChannelGetBuffer and CyU3PDmaMultiChannelCommitBuffer APIs can be used.

The size of the data to be committed can be controlled using the count parameter in CyU3PDmaChannelCommitBuffer. The count can be zero(ZLP will be sent), or UVC header size(UVC header of 12 bytes alone will be committed to USB).

Regards,
Ajeeth

0 Likes

These are not FX3 buffer overruns. We are receiving no PIB overrun errors. We are encountering an issue where the FPGA FULL and WATERMARK flags are suddenly asserting so I want to notify the UVC sink of the issue. How would this be done?

0 Likes
Ajeethkumar_P
Moderator
Moderator
Moderator
50 likes received 500 replies posted 100 solutions authored

Hi,

You can set the Error bit in the UVC Header and send it. For this case, you would also need to handle the VS_STREAM_ERROR_CODE_CONTROL control request. For more details, you can refer to the UVC specification.

Regards,
Ajeeth

0 Likes

Are the VS_STREAM_ERROR_CODE_CONTROL requests caught by tools like Wireshark? I have implemented the error bit asserting when the last usable buffer is sent (thus an overrun will occur) and the corresponding VS_STREAM_ERROR_CODE_CONTROL  handler for the UVC VS interface but I am not seeing any replies once that error bit is set on any camera applications (I have tried the Windows Camera App, e-CAMView, Teams, and Discord).

0 Likes
Ajeethkumar_P
Moderator
Moderator
Moderator
50 likes received 500 replies posted 100 solutions authored

Hi,

With Wireshark, you can see all the USB packets sent between the host and the device. You can check with appropriate Host applications to see how those applications handle once the error packet is received.

Regards,
Ajeeth

0 Likes

Looking at the UVC spec, it states I need to set bit 6 in the UVC uncompressed bit header field but none of my camera applications are responding to this bit being sent. I also tried stalling the endpoint during a transfer because UVC spec section 4.3.1.7 states "A bulk video endpoint returns a STALL packet to the host in the data or handshake stage of the transaction" to still no success.

0 Likes
Ajeethkumar_P
Moderator
Moderator
Moderator
50 likes received 500 replies posted 100 solutions authored

Hi Jason,

The Host Applications might not follow the complete UVC Specification like this Error Handling. You can check with appropriate Host applications to see how those applications handle once the error packet is received. Else, try to re-enumerate or restart the UVC transfer once all the buffers in the FX3 are filled as FPGA FULL and WATERMARK flags can assert only when all the DMA buffers are full. This is because the Host is not fast enough to poll the data.

Regards,
Ajeeth

0 Likes