1 2 Previous Next 20 Replies Latest reply on Nov 26, 2020 3:19 AM by JayakrishnaT_76

    About the THS-Prepare max value for CX3?

    kyli_4592306

      Hi,

      We are using CX3 to get data from ToF image sensor (Sony IMX528) over USB to host PC,

      we would like to get maximum possible frame rate, now, i can get the raw data from sensor via CX3,

      but i am hitting a issue when i am trying to compose the raw data into a frame with streamer app, there is few pixel data will random missing,

      ex, 640x480 resolution but only receive 640x479 or 640x478 ...

       

      Because the sensor IMX528 setting of THS prepare is 95 (0x5f), but CX3 THS prepare max value seems to be limited under 89 as below pic via EZ USB IDE ?

      how can i modify the THS prepare max value to over 89 ? Thanks ~

       

      IMX528 settings :

          Image format : RAW12

          Resolusion: 640x480 30fps

          MIPI 4 lanes

       

      擷取.JPG

        • 1. Re: About the THS-Prepare max value for CX3?
          JayakrishnaT_76

          Hello,

           

          According to your description, I understand that you are facing trouble while streaming 640x480 video using CX3. Please share the snapshot of the MIPI configuration utility for this setting so that I can understand the issue better.

           

          Also, please refer to Q13 of the following KBA which describes about the Max setting for CSI clock for different number of lanes used.

          CX3 Firmware: Frequently Asked Questions - KBA91297

           

          Please reduce the value of CSI clock based on the KBA mentioned above and let me know if you can configure the THS-Prepare for 95ns.

           

          Best Regards,

          Jayakrishna

          • 2. Re: About the THS-Prepare max value for CX3?
            kyli_4592306

            Hi Jayakrishna

             

            Please refer the following snapshot of the MIPI configuration utility,

            And sorry to allow me to correct the sensor setting as below, could you help to check if i have any wrong setting ?

             

            The sensor settings :

                Image format : RAW12

                Resolusion: 1280 (640x2) x 1920 (480x4) 30fps

                MIPI 2 lanes

                MCLK : 24MHz

             

             

            擷取.JPG

            /* null_RAW12_ModeAA :  */

            CyU3PMipicsiCfg_t null_RAW12_ModeAA = 

            {

                CY_U3P_CSI_DF_RAW12,  /* CyU3PMipicsiDataFormat_t dataFormat */

                2,                          /* uint8_t numDataLanes */

                1, /* uint8_t pllPrd */

                69, /* uint16_t pllFbd */

                CY_U3P_CSI_PLL_FRS_500_1000M, /* CyU3PMipicsiPllClkFrs_t pllFrs */ 

                CY_U3P_CSI_PLL_CLK_DIV_8, /* CyU3PMipicsiPllClkDiv_t csiRxClkDiv */

                CY_U3P_CSI_PLL_CLK_DIV_8, /* CyU3PMipicsiPllClkDiv_t parClkDiv */

                0x0203,                 /* uint16_t mClkCtl */

                CY_U3P_CSI_PLL_CLK_DIV_2, /* CyU3PMipicsiPllClkDiv_t mClkRefDiv */

                1280,         /* uint16_t hResolution */

                0                         /* uint16_t fifoDelay */

            };

             

             

            More over, I wonder how to config the correct fps, is it set by the API CyU3PMipicsiCfg_t  ?

            because, i try to change the "frame rate(fps)" in MIPI configuration utility from 30fps to 15fps, but the CyU3PMipicsiCfg_t  does not change ?

            • 3. Re: About the THS-Prepare max value for CX3?
              JayakrishnaT_76

              Hello,

               

              As mentioned in my previous response, the Q13 of following KBA describes the maximum value for the CSI clock setting that can be used for different number of lanes.

              CX3 Firmware: Frequently Asked Questions - KBA91297

               

              For 2 lanes, the maximum setting allowed is 500MHz only. Please refer to the KBA to understand the reason for this constraint.

               

              Regarding your question on FPS, the FPS is based on the input timings (h-active, v-active, h-total etc). Please refer to the following KBA to understand the CX3 timing parameters better:

              Analysis of CX3 Video Timing Parameters – KBA226779

               

              Note that the change in fps will not affect the MIPI configuration structure CyU3PMipicsiCfg_t. The configuration structure will remain unchanged until you make a change in the CX3 MIPI Interface Configuration settings in the MIPI configuration utility.

               

              Best Regards,

              Jayakrishna

              • 4. Re: About the THS-Prepare max value for CX3?
                kyli_4592306

                Hi Jayakrishna,

                 

                Thanks for your suggestions, allow me to explain more detail,

                 

                ------------------------------------------------------------------------------------------------------------------------------------

                My environment :

                I am using the way that base on "Non UVC" format as following link for reference,

                https://community.cypress.com/thread/16971

                 

                Sensor setting :

                1. 720Mbps data rate per lane

                2. MIPI lane count: 2 lanes

                3. sensor resolution (pixel) : 1280(640x2) x 483(480+3 embedded data line)

                4. fps: 30fps

                5. RAW12

                6. INCK = 24[MHz]

                 

                Description :

                The sensor resolution is 640 x 2(2 groups) x 483 x 4(4 packages within a frame)

                ------------------------------------------------------------------------------------------------------------------------------------

                Issue :

                The output data from CX3 is incomplete, basically a full frame data is H x V = 1280(H)x2(2bytes/per pixel) x 483x4, but the valid frame is only 2560 x 1520 currently i got.

                 

                Description :

                As my understand, i select the input Raw12 and output 16bit in CX3, so i should received the correct frame should be 2560(H) x 1932(V), but actually there is exist 2560 x 1520 (as attached "RAW_1.bmp")

                 

                ------------------------------------------------------------------------------------------------------------------------------------

                Attached files :

                1. RAW_1.bmp - Currenlty output data the valid data is only 2560 x 1520

                RAW_1.bmp

                2. V_less480.JPG - Same data as 1., i have marked a package address, however, the valid package vertical should be 483 (480 + 3 embedded data) , but it's less than 480, and there exist noise or garbage at the end of frame.

                V_less480.JPG

                3. HSYNC - because the frequency is not stable, so i record it as a video for reference.

                 

                4. VSYNC

                VSYNC.jpg

                5. PCLK - 96.15 MCLK

                PCLK.jpg

                 

                 

                Could you help to point out if there is any wrong setting or related suggestion for the missing data ? Thanks ~

                • 5. Re: About the THS-Prepare max value for CX3?
                  kyli_4592306

                  Sorry for missing my currently configuration :

                   

                  CX3_setting1.JPG

                  CX3_setting2.JPG

                  CyU3PMipicsiCfg_t IMX516_RAW12_MODE_AA =

                  {

                      CY_U3P_CSI_DF_RAW12,  /* CyU3PMipicsiDataFormat_t dataFormat */

                      2,                          /* uint8_t numDataLanes */

                      2, /* uint8_t pllPrd */

                      119, /* 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 */

                      0x0203,                 /* uint16_t mClkCtl */

                      CY_U3P_CSI_PLL_CLK_DIV_2, /* CyU3PMipicsiPllClkDiv_t mClkRefDiv */

                      1280,         /* uint16_t hResolution */

                      0                         /* uint16_t fifoDelay */

                  };

                  • 6. Re: About the THS-Prepare max value for CX3?
                    JayakrishnaT_76

                    Hello,

                     

                    I checked the configurations that you have shared in your previous response. It is correct.

                    Please find my questions and comments below:
                    1. According to your description the CX3 MIPI receiver receives 1280x1932x2Bytes data. Are you making use of an ISP or FPGA for sending the data from multiple image sensors to CX3? This is because you have mentioned 640x2 and 483x4 in your description. Also, in your description, you have mentioned that the valid vertical is 483. Please let us know more about your setup. Also, please confirm once again that the input to CX3 is 1280x1932x2Bytes.

                    2. Regarding embedded data, please let us know if you mean the embedded data type (0x12) as defined in MIPI CSI 2 spec.

                    3. Please try setting MCLK to 0. Please refer to the point 5 of the following KBA:
                    Analysis of CX3 Clocking Parameters – KBA226758

                    4. Please share the UART debug logs so that we can understand more on this issue.

                     

                    Also, can you please share the traces of Hsync and Vsync with the timings so that I can check if they are proper or not?

                     

                    Best Regards,

                    Jayakrishna

                    • 7. Re: About the THS-Prepare max value for CX3?
                      kyli_4592306

                      Hi Jayakrishna,

                       

                      Thanks for your confirmation, please find my reply mark as [Kyle].

                       

                      1. According to your description the CX3 MIPI receiver receives 1280x1932x2Bytes data. Are you making use of an ISP or FPGA for sending the data from multiple image sensors to CX3? This is because you have mentioned 640x2 and 483x4 in your description. Also, in your description, you have mentioned that the valid vertical is 483. Please let us know more about your setup. Also, please confirm once again that the input to CX3 is 1280x1932x2Bytes.

                      [Kyle] There is no FPGA or ISP, in my case, it's only one image sensor IMX528 direct connect to CX3,

                      For current sensor setting, a complete frame should be 1920(H) x 1932(V), that's confirmed, because i had tried to connected the IMX528 to other USB bridge EVK, which output a complete frame is 1920(H)x1932(V) as following pic, and i set the same sensor setting as CX3.

                       

                      2. Regarding embedded data, please let us know if you mean the embedded data type (0x12) as defined in MIPI CSI 2 spec.

                      [Kyle] Yes, the embedded data is 0x12.

                      MIPI_ID.JPG

                      [Kyle] moreover, a frame structure would be like the format, FS - frame start, FE - frame end,

                      4 packages within a frame, a package is 1280 x (480+3), 3 is the embedded data line

                      1frame.jpg

                       

                      3. Please try setting MCLK to 0. Please refer to the point 5 of the following KBA:

                      Analysis of CX3 Clocking Parameters – KBA226758

                      [Kyle] i have tried to set the MCLK to 0, but it's still not work.

                       

                       

                      4. Please share the UART debug logs so that we can understand more on this issue.

                      [Kyle] Because i am using Non-UVC way to process it as following, the log is not complete as UVC way does.

                      putty_log.JPG

                      • 8. Re: About the THS-Prepare max value for CX3?
                        JayakrishnaT_76

                        Hello,

                         

                        Looks like the Appstop() is called multiple times as per the UART logs. Please let me know the following:

                        1. Are you binding the device to cypress driver?

                        2. Are you issuing the vendor command to stop streaming in between the transfer? This is because I see Appstop in the UART debug logs. If not, then this should be due to failures in data transfer. Can you please check if the API CyU3PDmaMultiChannelCommitBuffer is failing or not?

                        3. Please check the size of the frame received by CX3 by modifying the firmware? This can be done by adding the size of the DMA buffers until the last partial buffer is received. Please note that the size of the frame should not be printed in the DMA callback. You can print it in the infinite for loop. Please share the UART debug logs after this modification.

                        4. Also, can you please provide the wireshark traces for us to check the USB data transfer?

                         

                        In addition to this, can you please try varying the Multiplier of unit clock setting from 100 to 105 and check if you see any improvements in the video stream? Also, please let me know if the size of the frame received by CX3 is increasing with this change or not.

                         

                        Best Regards,

                        Jayakrishna

                        • 9. Re: About the THS-Prepare max value for CX3?
                          kyli_4592306

                          Hi Jayakrishna,

                           

                          1. Are you binding the device to cypress driver?

                          [Kyle] Yes, but i use the Non-UVC type as following link for reference with "CX3_RAWData_Cypress Driver and Descriptors.zip".

                          https://community.cypress.com/thread/16971

                          Driver.JPG

                           

                           

                          2. Are you issuing the vendor command to stop streaming in between the transfer?

                          [Kyle] No.

                          This is because I see Appstop in the UART debug logs. If not, then this should be due to failures in data transfer. Can you please check if the API CyU3PDmaMultiChannelCommitBuffer is failing or not?

                          [Kyle] No. there is w/o error message w/ the following code via UART.

                          CyU3PDmaMultiChannelCommitBuffer.JPG

                           

                          3. Please check the size of the frame received by CX3 by modifying the firmware? This can be done by adding the size of the DMA buffers until the last partial buffer is received. Please note that the size of the frame should not be printed in the DMA callback. You can print it in the infinite for loop. Please share the UART debug logs after this modification

                          [Kyle] currently i set the CX3_UVC_DATA_BUF_SIZE=0x6000, CX3_UVC_STREAM_BUF_COUNT=4

                          could you suggest me the value of DMA buffer to try ?

                          .

                          4. Also, can you please provide the wireshark traces for us to check the USB data transfer?

                          [Kyle] update later.

                           

                          In addition to this, can you please try varying the Multiplier of unit clock setting from 100 to 105 and check if you see any improvements in the video stream? Also, please let me know if the size of the frame received by CX3 is increasing with this change or not.

                          [Kyle] could you help to guide me how to modify it as you mention "Multiplier of unit clock setting from 100 to 105 " ? thanks ~

                          • 10. Re: About the THS-Prepare max value for CX3?
                            JayakrishnaT_76

                            Hello,

                             

                            Please find my comments below:

                            1. [Kyle] No. there is w/o error message w/ the following code via UART.

                             

                            It is not recommended to add Debug Prints inside DMA callback function. Please try calling the Debug Prints at all points just before the function CyCx3UvcApplnStop() is called. This can be used to understand what triggered this call.

                             

                            2. [Kyle] currently i set the CX3_UVC_DATA_BUF_SIZE=0x6000, CX3_UVC_STREAM_BUF_COUNT=4

                            could you suggest me the value of DMA buffer to try ?

                             

                            As of now, you can use the same size for the DMA buffer. If required, we will change it later. But, I would like to know the size of video frame that is sent to the host. As you might be knowing, for your case, the size of frame that is sent to the host can be calculated as:

                            Frame size = 1280*1932*2 = 4945920 bytes.

                            To send the frame completely to host, more than one DMA buffer would be required. The number of DMA buffers required can be exactly calculated by dividing the frame size with the DMA buffer size (24576 bytes currently for your firmware). This will give the number of full buffers required for transmitting the frame. The last buffer will be a partial buffer.

                            We need to find the total frame size received by CX3 and sent to the host. For this, please add the following modification to the cycx3_uvc.c file.

                             

                            a. Declare two global variables (fsize and fcplt) as follows:

                             

                             

                            b. Add the following modifications to the code for calculating the frame size:

                             

                             

                            c. Print the frame size in the infinite for loop and reset the variables again as shown below:

                             

                             

                            d. Change the last parameter of the API CyU3PEventGet() inside the infinite for loop from CYU3P_WAIT_FOREVER to 1000.

                             

                            This can help us to understand the frame size received by CX3 and sent to the host.

                             

                            3. [Kyle] could you help to guide me how to modify it as you mention "Multiplier of unit clock setting from 100 to 105 " ?

                             

                            The multiplier of unit clock setting is a part of CX3 MIPI receiver configuration settings of the MIPI configuration utility. From your response 5, this parameter is set to 120 in your project. Please change this from 100 to 105 and let me know if you see any improvements.

                             

                            Best Regards,

                            Jayakrishna

                            • 11. Re: About the THS-Prepare max value for CX3?
                              kyli_4592306

                              Hi Jayakrishna,

                               

                              i found 2 issues after tracing the log msg you suggest in previous reply, i think the 2 issues root cause should be same, may need your favor to provide related suggestion how to fix or further debugging ? thanks ~

                               

                              1. The Appstop in the UART debug logs, it's called in CyCx3UvcAppThread_Entry with "eventFlag & CX3_DMA_RESET_EVENT" been setted as following pic, as you mention it should be due to failures in data transfer, then i try to check the  API CyU3PDmaMultiChannelCommitBuffer, it return the error code "CY_U3P_ERROR_INVALID_SEQUENCE".

                              201123C.JPG

                               

                              2. I tried to add your suggestion in previous reply to find the total frame size received by CX3 and sent to the host in cycx3_uvc.c file,

                              but there is no any msg output via UART, then i found the DmaBuffer.count is more than CX3_UVC_DATA_BUF_SIZE, i wonder the issue root cause should be same as previous issue 1.

                              201123D.JPG

                              Pic : msg output via UART

                              201123B.JPG

                              • 12. Re: About the THS-Prepare max value for CX3?
                                JayakrishnaT_76

                                Hello,

                                 

                                As per our previous discussions on this thread, I understand that you are binding the device to Cypress driver (cyusb3.sys). If this is the case, is your host application developed by modifying Streamer Application?

                                Also, the commit buffer failures with CY_U3P_ERROR_INVALID_SEQUENCE error comes up when the host is slow to issue the IN tokens to clear the DMA buffers filled by the GPIF II socket. As you doubt, there is a possibility than the last partial buffer associated with a frame could be missed due to the Appstop and Appstart sequence following a Commit Buffer failure. Please try the following and let us know the results:

                                1. Increase the DMA buffer size (CX3_UVC_DATA_BUF_SIZE) to 0x8FD0 (from 0x6000). You can reduce the buffer count to 3.

                                2. Please test using different hosts and let us know the results.

                                 

                                Best Regards,

                                Jayakrishna

                                • 13. Re: About the THS-Prepare max value for CX3?
                                  kyli_4592306

                                  Hi Jayakrishna,

                                   

                                  Yes, i am developing the Streamer Application as host application as following pic with Cypress driver (cyusb3.sys).

                                  control_1.JPG

                                  Here is my steps to start streaming

                                  control_2.jpg

                                   

                                   

                                  1. Increase the DMA buffer size (CX3_UVC_DATA_BUF_SIZE) to 0x8FD0 (from 0x6000). You can reduce the buffer count to 3.

                                  [Kyle] it is not work for the issue.

                                  2. Please test using different hosts and let us know the results.

                                  [Kyle] i have tried 2 hosts but all fail, one is laptop the other is desktop.

                                   

                                  However, i tried to adjust the resolution to test.

                                  The original frame size i need should be 1280(640*2)*1932(483*4)*2(byte) = 4,945,920 bytes.

                                  i tried to reduce the sensor resolution with sensor setting to VGA 640*480*2(byte) = 614,400 bytes,

                                  then, i found the frame size received by CX3 is constant and correct as below pic.

                                  201125A.JPG

                                   

                                  after that, i tried to increase the resolution with sensor setting to 1280(640*2)*480*2(byte) = 1,228,800 bytes,

                                  the frame size received by CX3 is constant but INCORRECT as below pic, it's only 965,520 bytes, and the frame size will be changed to  965344、965552 ... when i re-run again after reset the CX3.

                                   

                                  Moreover, i had tried to modify the DMA buffer size (CX3_UVC_DATA_BUF_SIZE) to 0x8000 and 0x8FD0 (from 0x6000) and reduce the buffer count to 3, but it's still fail.

                                   

                                  Could you help to provide the related suggestion ? Thanks ~

                                  201125B.JPG

                                  • 14. Re: About the THS-Prepare max value for CX3?
                                    JayakrishnaT_76

                                    Hello,

                                     

                                    While choosing the DMA buffer size, the following needs to be taken care of:

                                    1. The DMA buffer size (including size of footer and trailer) should be a multiple of 16 bytes.

                                    2. The frame should end with a partial buffer. This can be ensured by dividing the Frame size in bytes with the DMA buffer size in bytes (excluding size of footer and trailer). The frame size in bytes should not be perfectly divisible by DMA Buffer size.

                                     

                                    Please try to keep the DMA buffer size as large as possible without contradicting the requirements mentioned above. If possible, please keep it as 0x8FD0.

                                     

                                    We feel that the host is issuing IN packets slowly to clear the DMA buffers filled by the GPIF II socket. So, please try increasing Packets per xfer from 32 to 256 in steps and xfers to queue from 16 to 32. Please let me know if there are any improvements with the new settings. Also, please share snapshots of the Streamer application when you run it with the default settings and the modified settings. In addition to this, if you have modified the default streamer application that comes along with FX3 SDK, then please try these tests on both the default and the modified applications and share the result with us.

                                     

                                    Also, please let me know if you changed the code to print the Frame size? This is because I find that lower frame sizes are printed in the UART logs shared in the previous response.

                                     

                                    Best Regards,

                                    Jayakrishna

                                    1 2 Previous Next