- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a CX3 device that runs a UVC-CDC that is supporting 4 resolutions.
The output format used is RGB24.
Currently it supports frame rate of 60 only. I need to update the code such that the resolutions needs to support 120fps, 30fps and 15fps.
I tried updating the class specific frame descriptors with constant height and width with different frame rates, but the Host side application listed just one resolution with a frame rate(Used AmCap to view the resolutions )
Desired output ex:
- 640 * 480 @ 120fps
- 640 * 480 @ 60fps
- 640 * 480 @ 30fps
- 640 * 480 @ 15fps
Could you please help me on this.
Regards
Ajay
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ajay,
To support different frame rate in same resolution. You need
1. Define mulitiple frame rate in frame descriptor. Here I define 1080P @30 fps and @15fps
0x22,
CX3_CS_INTRFC_DESCR, /* Descriptor type*/
0x05, /* Subtype: frame interface*/
0x01, /* Frame Descriptor Index: 1 */
0x00, /* No Still image capture method supported */
0x80,0x07, /* Width in pixel: 1920 */
0x38,0x04, /* Height in pixel: 1080 */
0x00,0x80,0x53,0x3b, /* Max bit rate (bits/s): 1920 x 1080 x 16 x 30 = 995328000 Hex: 0x3b538000*/
0x00,0x30,0xa9,0x1d, /* Min bit rate (bits/s): 1920 x 1080 x 16 x 15 = 497664000 Hex: 0x1DA9C000*/
0x00,0x48,0x3f,0x00, /* Maximum video or still frame size in bytes(Deprecated): 1920 x 1080 x 2 */
0x15,0x16,0x05,0x00, /* Default frame interval (in 100ns units): (1/30)x10^7 */
0x02, /* Frame interval type : No of discrete intervals */
0x15,0x16,0x05,0x00, /* 30 fps */
0x2a,0x2c,0x0a,0x00, /* 15 fps */
2. Update the length of Class-specific Video Streaming Input Header Descriptor and the total length of CyCx3USBSSConfigDscr.
3. Define the necessary probe structure as below.
/* UVC Probe Control Setting - 1080p*/
uint8_t const gl1080pProbeCtrl_30[CX3_UVC_MAX_PROBE_SETTING] = {
0x00, 0x01, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 1st Video frame index */
0x15,0x16,0x05,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,0x48,0x3f,0x00, /* Max video frame size in bytes = 1920 x 1080 x 2 */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x90, 0x00, 0x00 /* No. of bytes device can rx in single payload: 36KB */
#else
/* UVC 1.1 Probe Control has additional fields from UVC 1.0 */
0x00, 0x90, 0x00, 0x00, /* No. of bytes device can rx in single payload: 36KB */
0x00, 0x60, 0xE3, 0x16, /* Device Clock */
0x00, /* Framing Information - Ignored for uncompressed format*/
0x00, /* Preferred payload format version */
0x00, /* Minimum payload format version */
0x00 /* Maximum payload format version */
#endif
};
/* UVC Probe Control Setting - 1080p*/
uint8_t gl1080pProbeCtrl_15[CX3_UVC_MAX_PROBE_SETTING] = {
0x00, 0x01, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 1st Video frame index */
0x2a,0x2c,0x0a,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,0x48,0x3f,0x00, /* Max video frame size in bytes = 1920 x 1080 x 2 */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x90, 0x00, 0x00 /* No. of bytes device can rx in single payload: 36KB */
#else
/* UVC 1.1 Probe Control has additional fields from UVC 1.0 */
0x00, 0x90, 0x00, 0x00, /* No. of bytes device can rx in single payload: 36KB */
0x00, 0x60, 0xE3, 0x16, /* Device Clock */
0x00, /* Framing Information - Ignored for uncompressed format*/
0x00, /* Preferred payload format version */
0x00, /* Minimum payload format version */
0x00 /* Maximum payload format version */
#endif
};
4. Modify CyCx3UvcAppGetProbeControlData to return corresponding structure.
/*Returns the pointer to the Probe Control structure for the corresponding frame index.*/
uint8_t *
CyCx3UvcAppGetProbeControlData (
CyU3PUSBSpeed_t usbConType,
uint8_t frameIndex,
uint32_t glCurrentFrameInterval
)
{
uint32_t frame_fps = 10000000/glCurrentFrameInterval;
if (usbConType == CY_U3P_SUPER_SPEED)
{
if (frameIndex == 1)
{
if(frame_fps == 30)
{
/* 1920 x 1080 @30.0 fps */
return ((uint8_t *) gl1080pProbeCtrl_30);
}
else if (frame_fps == 15)
{
/* 1920 x 1080 @30.0 fps */
return ((uint8_t *) gl1080pProbeCtrl_15);
}
}
}
else if (usbConType == CY_U3P_HIGH_SPEED)
{
}
else
{
}
return NULL;
}
5. Modify the set probe control in set_cur call back function.
/* Set Probe Control */
if (wValue == CX3_UVC_VS_PROBE_CONTROL)
{
glCurrentFrameIndex = glCommitCtrl[3];
#ifdef Mulfps
glCurrentFrameInterval = ((uint32_t)glCommitCtrl[7] << 24) | ((uint32_t)glCommitCtrl[6] << 16) |
((uint32_t)glCommitCtrl[5] << 😎 | ((uint32_t)glCommitCtrl[4] << 0);
#endif
}
6. Modify the SetVideoResolution function.
static void
CyCx3UvcAppImageSensorSetVideoResolution(
uint8_t resolution_index, uint32_t frame_Interval
)
{
CyU3PReturnStatus_t status = CY_U3P_SUCCESS;
uint32_t frameRate= 10000000/frame_Interval;
switch (CyU3PUsbGetSpeed ())
{
case CY_U3P_SUPER_SPEED:
switch (resolution_index)
{
case 0x01:
{
if (frameRate == 30)
{
CyU3PDebugPrint(4,"\n Set 1080P 30 fps \n");
/* Write 1080pSettings */
#ifndef FX3_STREAMING
status = CyU3PMipicsiSetIntfParams (&ov1111_YUY2_1080p, CyFalse);
if (status != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "\n\rUSBStpCB:SetIntfParams SS1 Err = 0x%x", status);
}
#endif
CyCx3_ImageSensor_Set_1080p ();
}
else
{
CyU3PDebugPrint(4,"\n Set 1080P 15 fps \n");
/* Write 1080pSettings */
#ifndef FX3_STREAMING
status = CyU3PMipicsiSetIntfParams (&ov1111_YUY2_1080p, CyFalse);
if (status != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "\n\rUSBStpCB:SetIntfParams SS1 Err = 0x%x", status);
}
#endif
CyCx3_ImageSensor_Set_1080p ();
}
}
break;
}
break;
case CY_U3P_HIGH_SPEED:
switch (resolution_index)
{
}
break;
}
}
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ajay,
To support different frame rate in same resolution. You need
1. Define mulitiple frame rate in frame descriptor. Here I define 1080P @30 fps and @15fps
0x22,
CX3_CS_INTRFC_DESCR, /* Descriptor type*/
0x05, /* Subtype: frame interface*/
0x01, /* Frame Descriptor Index: 1 */
0x00, /* No Still image capture method supported */
0x80,0x07, /* Width in pixel: 1920 */
0x38,0x04, /* Height in pixel: 1080 */
0x00,0x80,0x53,0x3b, /* Max bit rate (bits/s): 1920 x 1080 x 16 x 30 = 995328000 Hex: 0x3b538000*/
0x00,0x30,0xa9,0x1d, /* Min bit rate (bits/s): 1920 x 1080 x 16 x 15 = 497664000 Hex: 0x1DA9C000*/
0x00,0x48,0x3f,0x00, /* Maximum video or still frame size in bytes(Deprecated): 1920 x 1080 x 2 */
0x15,0x16,0x05,0x00, /* Default frame interval (in 100ns units): (1/30)x10^7 */
0x02, /* Frame interval type : No of discrete intervals */
0x15,0x16,0x05,0x00, /* 30 fps */
0x2a,0x2c,0x0a,0x00, /* 15 fps */
2. Update the length of Class-specific Video Streaming Input Header Descriptor and the total length of CyCx3USBSSConfigDscr.
3. Define the necessary probe structure as below.
/* UVC Probe Control Setting - 1080p*/
uint8_t const gl1080pProbeCtrl_30[CX3_UVC_MAX_PROBE_SETTING] = {
0x00, 0x01, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 1st Video frame index */
0x15,0x16,0x05,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,0x48,0x3f,0x00, /* Max video frame size in bytes = 1920 x 1080 x 2 */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x90, 0x00, 0x00 /* No. of bytes device can rx in single payload: 36KB */
#else
/* UVC 1.1 Probe Control has additional fields from UVC 1.0 */
0x00, 0x90, 0x00, 0x00, /* No. of bytes device can rx in single payload: 36KB */
0x00, 0x60, 0xE3, 0x16, /* Device Clock */
0x00, /* Framing Information - Ignored for uncompressed format*/
0x00, /* Preferred payload format version */
0x00, /* Minimum payload format version */
0x00 /* Maximum payload format version */
#endif
};
/* UVC Probe Control Setting - 1080p*/
uint8_t gl1080pProbeCtrl_15[CX3_UVC_MAX_PROBE_SETTING] = {
0x00, 0x01, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 1st Video frame index */
0x2a,0x2c,0x0a,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,0x48,0x3f,0x00, /* Max video frame size in bytes = 1920 x 1080 x 2 */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x90, 0x00, 0x00 /* No. of bytes device can rx in single payload: 36KB */
#else
/* UVC 1.1 Probe Control has additional fields from UVC 1.0 */
0x00, 0x90, 0x00, 0x00, /* No. of bytes device can rx in single payload: 36KB */
0x00, 0x60, 0xE3, 0x16, /* Device Clock */
0x00, /* Framing Information - Ignored for uncompressed format*/
0x00, /* Preferred payload format version */
0x00, /* Minimum payload format version */
0x00 /* Maximum payload format version */
#endif
};
4. Modify CyCx3UvcAppGetProbeControlData to return corresponding structure.
/*Returns the pointer to the Probe Control structure for the corresponding frame index.*/
uint8_t *
CyCx3UvcAppGetProbeControlData (
CyU3PUSBSpeed_t usbConType,
uint8_t frameIndex,
uint32_t glCurrentFrameInterval
)
{
uint32_t frame_fps = 10000000/glCurrentFrameInterval;
if (usbConType == CY_U3P_SUPER_SPEED)
{
if (frameIndex == 1)
{
if(frame_fps == 30)
{
/* 1920 x 1080 @30.0 fps */
return ((uint8_t *) gl1080pProbeCtrl_30);
}
else if (frame_fps == 15)
{
/* 1920 x 1080 @30.0 fps */
return ((uint8_t *) gl1080pProbeCtrl_15);
}
}
}
else if (usbConType == CY_U3P_HIGH_SPEED)
{
}
else
{
}
return NULL;
}
5. Modify the set probe control in set_cur call back function.
/* Set Probe Control */
if (wValue == CX3_UVC_VS_PROBE_CONTROL)
{
glCurrentFrameIndex = glCommitCtrl[3];
#ifdef Mulfps
glCurrentFrameInterval = ((uint32_t)glCommitCtrl[7] << 24) | ((uint32_t)glCommitCtrl[6] << 16) |
((uint32_t)glCommitCtrl[5] << 😎 | ((uint32_t)glCommitCtrl[4] << 0);
#endif
}
6. Modify the SetVideoResolution function.
static void
CyCx3UvcAppImageSensorSetVideoResolution(
uint8_t resolution_index, uint32_t frame_Interval
)
{
CyU3PReturnStatus_t status = CY_U3P_SUCCESS;
uint32_t frameRate= 10000000/frame_Interval;
switch (CyU3PUsbGetSpeed ())
{
case CY_U3P_SUPER_SPEED:
switch (resolution_index)
{
case 0x01:
{
if (frameRate == 30)
{
CyU3PDebugPrint(4,"\n Set 1080P 30 fps \n");
/* Write 1080pSettings */
#ifndef FX3_STREAMING
status = CyU3PMipicsiSetIntfParams (&ov1111_YUY2_1080p, CyFalse);
if (status != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "\n\rUSBStpCB:SetIntfParams SS1 Err = 0x%x", status);
}
#endif
CyCx3_ImageSensor_Set_1080p ();
}
else
{
CyU3PDebugPrint(4,"\n Set 1080P 15 fps \n");
/* Write 1080pSettings */
#ifndef FX3_STREAMING
status = CyU3PMipicsiSetIntfParams (&ov1111_YUY2_1080p, CyFalse);
if (status != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "\n\rUSBStpCB:SetIntfParams SS1 Err = 0x%x", status);
}
#endif
CyCx3_ImageSensor_Set_1080p ();
}
}
break;
}
break;
case CY_U3P_HIGH_SPEED:
switch (resolution_index)
{
}
break;
}
}
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the quick solution.
I've tested the solution and is working perfectly.
Regards
Ajay