How to dynamically change resolution of image sensor - AN75779

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

cross mob
bojankoce
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

Hello guys,

We were able to successfully benefit from the application note AN75779 and use FX3 to transfer video streams from our image sensors (IMX250, IMX253, IMX420) to the PC. VLC player has been used to play the streams. Thanks for your support in that sense (thread 1, thread 2)! It is really appreciated.

We are now in the process of replacing VLC player by our custom software using UVC class drivers. In that sense, we would like to be able to dynamically change video resolution during system runtime. Here are some use-cases where this dynamic resolution change would be necessary:

1) During system start-up, we will read the type of the image sensor we have connected with FX3 and set video resolution accordingly.

2) There will be a need to change video mode or simply video resolution during runtime of the system by sending appropriate command message from PC.

In this thread you explained us how to include different resolutions into USB descriptor chain and we did it successfully. We also noticed that the last Class specific Uncompressed VS frame descriptor in the list represents the default video resolution.

Our FX3 firmware is based on AN75779 example. What are the steps/commands to take in order to change video resolution of the stream dynamically, during runtime? We can change a resolution of the image sensor successfully, we only need to inform PC about that.

As always, thank you very much for your time and efforts!

Sincerely,

Bojan.

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

Hello Bojan,

I will explain the whole procedure of changing video resolution dynamically with VLC media player

When AN75779 firmware is modified to add multiple resolution, on opening the host application (VLC) the options of the video resolutions supported by FX3 (as per modifications in the firmware) will be visible. Among the multiple resolutions one resolution will be set by default

1) To change the video resolution dynamically, one among the multiple resolutions shown in host application (VLC) need to be chosen.

2) On changing the video resolution, UVC class request will be sent by the host to FX3. Please refer to figure 6 of AN75779 and section 2.3.2.2 for the flow of the requests and response between host and device.

3) The UVC requests (sent by host) need to be handled in the firmware. Changing video resolution is for Streaming interface. Streaming interface can handle two requests CY_FX_UVC_PROBE_CTRL and CY_FX_UVC_COMMIT_CTRL requests.

- Please confirm that you are sending the probe control structures for all the video resolutions when this CY_FX_USB_UVC_GET_DEF_REQ request is sent by the host

- Under  CY_FX_UVC_COMMIT_CTRL, when CY_FX_USB_UVC_SET_CUR_REQ  occurs then appropriate sensor settings need to be change (according to the video resolution set) by the host

// UVC class request

        if (wValue == FX3_UVC_VS_COMMIT_CONTROL)

        {

        

switch(bRequest)

case FX3_USB_UVC_SET_CUR_REQ:

            switch (CY_U3P_GET_LSB(wIndex))

            {

            case FX3_UVC_STREAM_INTERFACE_1:

            {

                CyU3PThreadSleep(900);

                CyFx3UvcAppSetVideoResolution(glCommitCtrl[2], glCommitCtrl[3], frameInterval, 0);

           }

            break;

            }

        }

void

CyFx3UvcAppSetVideoResolution(

uint8_t format_index,

uint8_t resolution_index,

uint32_t frame_interval,

)

{

glFrameSizeExpected = 0;

if (CyU3PUsbGetSpeed() == CY_U3P_SUPER_SPEED)

{

if(format_index == UYVY_FORMAT_INDEX)

{

switch (resolution_index)

{

case SS_YUY2_1920x1080_INDEX:

sensor_settings_1920*1080();                             //setting the sensor to stream 1920*1080

break;

case SS_YUY2_1280x720_INDEX:

sensor_settings_1280*720();                                 //setting the sensor to stream 1280*1720

break;

case SS_YUY2_640x640_INDEX:

sensor_settings_640x640();

break;

The fields like format_index, resolution_index etc needs to be parsed from glCommitCtrl  when bRequest is CY_FX_USB_UVC_SET_CUR_REQ and wValue is CY_FX_UVC_PROBE_CTRL

Please share the modified firmware if you have more queries

Regards,

Rashi

Regards,
Rashi

View solution in original post

7 Replies