CX3 ov5640 usb hi-speed 720p configuration

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

cross mob
skennyg123
Level 1
Level 1
First reply posted First question asked Welcome!

I am trying to configure my device to output higher resolutions speeds at USB2.0/high speed. Specifically 720p at 30 FPS. I believe there should be enough bandwidth to support that at high speed. However I can go lower if that is not the case.

The current code example I am using provides just one setting at 640x480.  I have been able to coax the USB side to recognize that I should be running at 720p however no frames show up.  I assume there is some combination of buffers and pll configurations that i am not understanding.  here are the important code snippets.

USB descriptor (seems to be working)

/* Class specific Uncompressed VS frame descriptor 2 - 720p@ 30fps*/
0x1E, /* Descriptor size */
ES_UVC_CS_INTRFC_DESCR, /* Descriptor type*/
0x05, /* Subtype: Uncompressed frame interface*/
0x01, /* Frame Descriptor Index: 1 */
0x00, /* No Still image capture method supported */
0x00, 0x05, /* Width in pixel: 720 */
0xD0, 0x02, /* Height in pixel: 1280 */
0x00, 0x00, 0x5E, 0x1A, //720 x 1280 x 2 x 30 x 8 = 442368000 */
0x00, 0x00, 0x5E, 0x1A, //720 x 1280 x 2 x 30 x 8 = 442368000 */
0x00, 0x20, 0x1C, 0x00, /* Maximum video frame size in bytes(Deprecated): 1280 x 720 x 2 */
0x15, 0x16, 0x05, 0x00, /* Desired frame interval in 100ns = (1/30)x10^7 = 333,333.33 */
0x01, /* Frame interval type : No of discrete intervals */
0x15, 0x16, 0x05, 0x00, /* Desired frame interval in 100ns = (1/30)x10^7 = 333,333.33 */

probe control (possible point of failure)

/* UVC Probe Control Setting - 720p@30fps(HighSpeed)*/
uint8_t const gl720p30FPSProbeCtrl[ES_UVC_MAX_PROBE_SETTING] = {
0x00, 0x00, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 2nd Video frame index */
0x15, 0x16, 0x05, 0x00, /* Desired frame interval in 100ns = (1/30)x10^7 = 333,333.33 */
0x00, 0x00, /* Key frame rate in key frame/video frame units */
0x00, 0x00, /* PFrame rate in PFrame / key frame units */
0x00, 0x00, /* Compression quality control */
0x00, 0x00, /* Window size for average bit rate */
0x00, 0x00, /* Internal video streaming i/f latency in ms */
0x00, 0x20, 0x1C, 0x00, /* Max video frame size in bytes: 720 x 1280 x 2*/
0x00, 0x30, 0x00, 0x00 /* No. of bytes device can rx in single payload */
};

mipi control (possible point of failure)

/* Configuration parameters for 720p @30FPS for the OV5640 sensor */
CyU3PMipicsiCfg_t cfgUvc720p30NoMclk = {
CY_U3P_CSI_DF_YUV422_8_2, /* dataFormat */
1, /* numDataLanes */
1, /* pllPrd */
62, /* pllFbd */
CY_U3P_CSI_PLL_FRS_250_500M, /* pllFrs */
CY_U3P_CSI_PLL_CLK_DIV_4, /* csiRxClkDiv */
CY_U3P_CSI_PLL_CLK_DIV_4, /* parClkDiv */
0x00, /* mclkCtl */
CY_U3P_CSI_PLL_CLK_DIV_8, /* mClkRefDiv */
1280, /* hResolution */
50 /* fifoDelay */
};

 

resulting code in application

buffer switch (likely where my problem)

switch(CyU3PUsbGetSpeed())
{
case CY_U3P_HIGH_SPEED:
endPointConfig.pcktSize = 0x200;
endPointConfig.burstLen = 1;
ES_UVC_STREAM_BUF_SIZE = ES_UVC_HS_STREAM_BUF_SIZE;
ES_UVC_DATA_BUF_SIZE = ES_UVC_HS_DATA_BUF_SIZE;
ES_UVC_STREAM_BUF_COUNT = ES_UVC_HS_STREAM_BUF_COUNT;
break;

where

#define ES_UVC_HS_STREAM_BUF_SIZE (ES_UVC_HS_DATA_BUF_SIZE + ES_UVC_PROD_HEADER + ES_UVC_PROD_FOOTER)

#define ES_UVC_HS_DATA_BUF_SIZE (3056) /* DMA Buffer Data Size Used: 3056 Bytes*/

#define ES_UVC_HS_STREAM_BUF_COUNT (8)

#define ES_UVC_PROD_HEADER (12) /* UVC DMA Buffer Header Size */
#define ES_UVC_PROD_FOOTER (4) /* UVC DMA Buffer Footer Size */

mipi selection (likely second point of failure)

else if (CyU3PUsbGetSpeed () == CY_U3P_HIGH_SPEED)
{

   status = CyU3PMipicsiSetIntfParams (&cfgUvc720p30NoMclk, CyFalse);
if (status != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "\n\rUSBStpCB:SetIntfParams SS2 Err = 0x%x", status);
}
   esOV5640_720P_config

   //also tried esOV5640_720P_HS_config();

probe selection

else if (CyU3PUsbGetSpeed () == CY_U3P_HIGH_SPEED)
{

    CyU3PMemCopy(glProbeCtrl, (uint8_t *)gl720p30FPSProbeCtrl, ES_UVC_MAX_PROBE_SETTING);

0 Likes
1 Solution
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

Please note that the practical bandwidth of USB 2.0 (High speed) is ~40MBps (mega bytes per second).

The resolution 1280*720*2*30  = ~52MBps

To stream through USB 2.0, please try to reduce the video bandwidth <35 - 40 MBps

Also, can you please let me know why 3KB DMA buffers (ES_UVC_HS_STREAM_BUF_SIZE ) are used?

Regards,
Rashi

View solution in original post

0 Likes
6 Replies
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

Please note that the practical bandwidth of USB 2.0 (High speed) is ~40MBps (mega bytes per second).

The resolution 1280*720*2*30  = ~52MBps

To stream through USB 2.0, please try to reduce the video bandwidth <35 - 40 MBps

Also, can you please let me know why 3KB DMA buffers (ES_UVC_HS_STREAM_BUF_SIZE ) are used?

Regards,
Rashi
0 Likes

Yes, I later found the CX3 mipi configuration page where it provided templates for 720p at 20FPS. I tried those settings as well but the frames were still not coming through. Unfortunately I do not know why the buffer was set to 3000 I inherited this project from someone not currently working with us. Should I post my code with the newer settings I created with the configuration wizard?

0 Likes
lock attach
Attachments are accessible only for community members.

attached is the latest attempt at 720p at 20 fps.  I still think i have a buffer issue though.

notable changes

status = CyU3PMipicsiSetIntfParams (&ov5640_YUY2_Resolution0, CyFalse);

CyU3PMemCopy(glProbeCtrl, (uint8_t *)glResolution0ProbeCtrl_HS, ES_UVC_MAX_PROBE_SETTING);

 

/* ov5640_YUY2_Resolution0 : */
CyU3PMipicsiCfg_t ov5640_YUY2_Resolution0 =
{
CY_U3P_CSI_DF_YUV422_8_2, /* CyU3PMipicsiDataFormat_t dataFormat */
2, /* uint8_t numDataLanes */
2, /* uint8_t pllPrd */
89, /* uint16_t pllFbd */
CY_U3P_CSI_PLL_FRS_250_500M, /* CyU3PMipicsiPllClkFrs_t pllFrs */
CY_U3P_CSI_PLL_CLK_DIV_4, /* CyU3PMipicsiPllClkDiv_t csiRxClkDiv */
CY_U3P_CSI_PLL_CLK_DIV_4, /* CyU3PMipicsiPllClkDiv_t parClkDiv */
0, /* uint16_t mClkCtl */
CY_U3P_CSI_PLL_CLK_DIV_2, /* CyU3PMipicsiPllClkDiv_t mClkRefDiv */
1280, /* uint16_t hResolution */
50 /* uint16_t fifoDelay */
};

/* UVC Probe Control Setting - Resolution0*/
uint8_t const glResolution0ProbeCtrl_HS[ES_UVC_MAX_PROBE_SETTING] = {
0x00, 0x00, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 1st Video frame index */
0x20,0xa1,0x07,0x00, /* Desired frame interval in 100ns = (1/30)x10^7 */
0x00, 0x00, /* Key frame rate in key frame/video frame units */
0x00, 0x00, /* PFrame rate in PFrame / key frame units */
0x00, 0x00, /* Compression quality control */
0x00, 0x00, /* Window size for average bit rate */
0x00, 0x00, /* Internal video streaming i/f latency in ms */
0x00,0x20,0x1c,0x00, /* Max video frame size in bytes = 1920 x 1080 x 2 */
0x00, 0x90, 0x00, 0x00 /* No. of bytes device can rx in single payload: 36KB */
};

/* Class specific Uncompressed VS Frame Descriptor 1 - Resolution0 */
0x1E, /* Descriptor size */
ES_UVC_CS_INTRFC_DESCR, /* Descriptor type*/
0x05, /* Subtype: frame interface*/
0x01, /* Frame Descriptor Index: 1 */
0x00, /* No Still image capture method supported */
0x00,0x05, /* Width in pixel: 1280 */
0xd0,0x02, /* Height in pixel: 720 */
0x00,0x00,0x94,0x11, /* Min bit rate (bits/s): 1280 x 720 x No Of Bits per Pixel x FrameRate = 294912000 */
0x00,0x00,0x94,0x11, /* Max bit rate (bits/s): Fixed rate so same as Min */
0x00,0x20,0x1c,0x00, /* Maximum video or still frame size in bytes(Deprecated): 1280 x 720 x 2 */
0x20,0xa1,0x07,0x00, /* Default frame interval (in 100ns units): (1/30)x10^7 */
0x01, /* Frame interval type : No of discrete intervals */
0x20,0xa1,0x07,0x00, /* Frame interval 3: Same as Default frame interval */

0 Likes

Hello,

Please share the UART debug prints with CX3_DEBUG_ENABLED macro enabled. This will help us to debug the issue faster.

Regards,
Rashi
0 Likes

I will try that i need to move back to the denobulan board

0 Likes

Hello,

Please let me know if there are any updates 

Regards,
Rashi
0 Likes