FX3 - How to change the image resolution and pixels depth

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

cross mob
omco_594686
Level 3
Level 3
Welcome!

Hi,

I'm using CYUSB2KIT-003 with the aptina sensor for non-uvc application.

Everything works with 720p and 8bit pixel-depth.

Now I want to move on to our costume sensor.

I want to be able to change resolutions and the pixel-depth (from 8bit to 14, 16, up to 24) on runtime.

Is it possible?

If so;

1. How is it effect the GPIF bus

2. How should change the DMA configuration? (size? alignment?)

3. What else should I change to be able to do it?

( My reference code is from here - FX3 non-uvc camera streamer )

Omri.

0 Likes
1 Solution

Hello Omri,

Do I need to change the GPIF designer project and change the bus width to 24 bit? or just use CyU3PFX3GpifLoad with CY_U3P_GPIF_BUS_24 argument?

>> No, as CyU3PFX3GpifLoad  is used in the firmware there is no need to modify the .cyfx (GPIF designer file). The registers will be overwritten with the new values by CyU3PFX3GpifLoad API. The default state machine can be used for other GPIF bus widths

About the DMA - This size is 32KB.

Is the possible to increase it?

>> Yes the DMA buffer size can be increased.  For example, you can use 42KB buffer and DMA count 2. The DMA buffer space available in FX3 with 512 KB SRAM (CYUSB3013 and CYUSB3014) is 224 KB and tA single DMA buffer used on FX3 can have a maximum size of 65535 bytes

You can refer to this KBA DMA Buffer Count - KBA218339

Please let me know if any query on this

Regards,

Rashi

Regards,
Rashi

View solution in original post

0 Likes
6 Replies
lock attach
Attachments are accessible only for community members.
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello Omri,

For Non-UVC applications, the change of resolution can be initiated by the host application by passing a vendor command.

The handling of this vendor command needs to be done in the firmware.  This can be done as follows

- On getting the vendor command the previous streaming need to be stopped and then the sensor settings for the new video resolution should be sent to the sensor and the event for streaming should be set.

You can add below-mentioned vendor command in your firmware and follow the steps

...

    else if (bRequest == 0x89)

    {

    SensorScaling_VGA();

    apiRetStatus = CyU3PEventSet (&glFxUVCEvent, CY_FX_UVC_STREAM_EVENT, CYU3P_EVENT_OR);

                                  if (apiRetStatus != CY_U3P_SUCCESS)

                                  {

                                      CyU3PDebugPrint (4, "Set CY_FX_UVC_STREAM_EVENT failed %x\n", apiRetStatus);

                                  }

                                  uvcHandleReq = CyTrue;

                                  CyU3PUsbAckSetup ();

Steps:

- After programming FX3, pass 0x99 vendor command from the control center and check the streaming

- To change the resolution to 640*480, the current streaming need to be stopped using 0x88 or you can click on "STOP" on streamer Application and then pass 0x89 to set the new resolution

- To set the new resolution the sensor settings need to be passed (using SensorScaling_VGA) and then streaming will start again.

I want to be able to change resolutions and the pixel-depth (from 8bit to 14, 16, up to 24) on runtime.

Is it possible?

>> The resolution can be changed as mentioned above. Please let me know if you are referring to changing of GPIF bus width by saying changing pixel depth

. 1) How is it affect the GPIF bus

>> Please let me know what all parallel bus width can the new sensor support. So you want to use different parallel bus width? If the parallel interface between the sensor and FX3's GPIF is to be changed then the GPIF needs to be disabled and the state machine needs to be loaded again after making appropriate changes to GPIF registers using CyFxGpifRegValue API. If you are just changing the resolution there is no need to change the GPIF bus width. The GPIF bus width should only be changed if the sensor's data bus width is changed.

2) How should change the DMA configuration? (size? alignment?)

>> No changes are needed in the DMA buffer size for changing the resolution. Please let me know what are the different resolutions that you are planning to stream

3)What else should I change to be able to do it?

>> The major changes for changing the resolution and sensor - GPIF parallel bus width would require

- configuring the sensor with appropriate settings when vendor command is received by the device

- Stopping the previous stream (and disabling the GPIF), changing the GPIF bus width settings  and loading the GPIF state machine again

Regards,

Rashi

Regards,
Rashi
0 Likes

Hi RashiV_61

Thanks for your reply.

I implemented a way for different requests with vendor commands, as you show above.

1. Changing resolution

I want to stream 1324*1000 maximum (120 fps).

So, As you explained, There's no need to change the GPIF bus and the DMA configuration. Am I right?

2. Changing pixel-depth.

Now I'm using 8-bit per pixel and his is also the configuration in the GPIF designer project.

I want to be able to change it to 8, 10, 12 and 24 bpp maximum.

How can I stop->configure->start the GPIF bus in runtime?

The DMA configuration stays the same. Or do I need to change it?

Omri.

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

Hello Omri,

1)  I want to stream 1324*1000 maximum (120 fps).

So, As you explained, There's no need to change the GPIF bus and the DMA configuration. Am I right?

>> If GPIF bus width is kept the maximum i.e. 32 bits and PCLK is 100 MHz  The maximum bandwidth of GPIF interface is 3.2Gbps.

1324*1000 maximum (120 fps) = 1324*!000*16(bits/pixel)*120 = 2.5 Gbps. In this case, to meet the bandwidth requirements GPIF bus width needs to be changed to 32 bits i.e. the sensor should be configured to send the data on the 32-bit parallel data bus to FX3.

Note: The data rate (Hactive *Vactive*fps*bits/pixel) at which the sensor outputs the data should match to the GPIF bandwidth ( GPIF bus (bits) width * freq of PCLK)

Similarly, the host should match the data rate of the sensor (i.e. the host should be fast enough to read the data coming from the sensor) If the host is slow then the DMA buffer size can be increased to 32 KB and DMA buffer count to 3 so that the mismatch reduces. This is already implemented in the firmware. So no changes are required in DMA buffer size and count.

2 Changing pixel-depth.

Now I'm using 8-bit per pixel and his is also the configuration in the GPIF designer project.

I want to be able to change it to 8, 10, 12 and 24 bpp maximum.

How can I stop->configure->start the GPIF bus in runtime?

>> If you mean that bits/pixel is equivalent to the sensor output bus width only then GPIF bus width needs to be changed. For example, If the sensor output is 16 bits (data bus width) then the GPIF bus width should be 16 bits.

To change the GPIF bus width at run time you need the following modifications to your firmware.

- Stop the previous streaming and pass a vendor command from the host application to change the bus width.

- On receiving the vendor command to pass the sensor settings to configure the sensor to output 16 bits data in one clock and configure the GPIF state machine for new settings

I have shared the firmware with modifications

- Added vendor command 0x90 for setting the GPIF bus width to 16 bits from 8 bits. As of now, i have kept the new GPIF bus width the same as the previous one (8 bits) as we have an Aptina sensor that supports 8 bits data bus width. You can modify the bus width here

  else if (bRequest == 0x89)

    {

    apiRetStatus =  CyU3PFX3GpifLoad (CY_U3P_GPIF_BUS_8,CY_FX_UVC_BUF_FULL_SIZE); ////bus width can be changed gere

    SensorScaling_VGA();  //sesnor settings need to be passed here to change sensor data bus width

    apiRetStatus = CyU3PEventSet (&glFxUVCEvent, CY_FX_UVC_STREAM_EVENT, CYU3P_EVENT_OR);

                                   if (apiRetStatus != CY_U3P_SUCCESS)

                                   {

                                       CyU3PDebugPrint (4, "Set CY_FX_UVC_STREAM_EVENT failed %x\n", apiRetStatus);

                                   }

                                   uvcHandleReq = CyTrue;

                                   CyU3PUsbAckSetup ();

    }

    else if (bRequest == 0x90)

    {

            apiRetStatus =  CyU3PFX3GpifLoad (CY_U3P_GPIF_BUS_8,CY_FX_UVC_BUF_FULL_SIZE); //bus width can be changed gere

        SensorScaling_VGA();  //sesnor settings need to be passed here o change sensor data bus width

        apiRetStatus = CyU3PEventSet (&glFxUVCEvent, CY_FX_UVC_STREAM_EVENT, CYU3P_EVENT_OR);   //start stream

                                       if (apiRetStatus != CY_U3P_SUCCESS)

                                       {

                                           CyU3PDebugPrint (4, "Set CY_FX_UVC_STREAM_EVENT failed %x\n", apiRetStatus);

                                       }

                                       uvcHandleReq = CyTrue;

                                       CyU3PUsbAckSetup ();

    }

- Steps:  0x99>stop streaming 0x88 > 0x90 (streaming with 16 bits GPIF bus width)

- Added CyU3PFX3GpifLoad API for configuring the state machine with new settings

Please let me know if any queries on this

Regards,

Rashi

Regards,
Rashi
0 Likes

Hi RashiV_61​,

Thanks for your reply.

I'm using CyU3PFX3GpifLoad from your reference code.

Do I need to change the GPIF designer project and change the bus width to 24 bit? or just use CyU3PFX3GpifLoad with CY_U3P_GPIF_BUS_24 argument?

About the DMA - This size is 32KB.

Is the possible to increase it?

Omri.

0 Likes

Hello Omri,

Do I need to change the GPIF designer project and change the bus width to 24 bit? or just use CyU3PFX3GpifLoad with CY_U3P_GPIF_BUS_24 argument?

>> No, as CyU3PFX3GpifLoad  is used in the firmware there is no need to modify the .cyfx (GPIF designer file). The registers will be overwritten with the new values by CyU3PFX3GpifLoad API. The default state machine can be used for other GPIF bus widths

About the DMA - This size is 32KB.

Is the possible to increase it?

>> Yes the DMA buffer size can be increased.  For example, you can use 42KB buffer and DMA count 2. The DMA buffer space available in FX3 with 512 KB SRAM (CYUSB3013 and CYUSB3014) is 224 KB and tA single DMA buffer used on FX3 can have a maximum size of 65535 bytes

You can refer to this KBA DMA Buffer Count - KBA218339

Please let me know if any query on this

Regards,

Rashi

Regards,
Rashi
0 Likes

Hi RashiV_61​,

Thanks for clarifying this.

Omri.

0 Likes