CX3 pack RAW8 into 24 bits

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

cross mob
user_2884081
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

I have been investigating and managed to make this configuration work:

Camera: RAW8, 1638x1232

MIPI Block: RGB565_2, 819 hResolution

GPIF: 16 bits

Probe Control: 1638x1234 B

UVC: 819x1234, 16bpp

The idea is for the GPIF to receive 2 bytes in every cycle, and then send the information to the PC with 2 bytes per "pixel", so we get a picture with half the columns.

The next step would be to make something similar, but with a 24b GPIF bus, so 3 bytes are sent to the GPIF block every cycle. The UVC and Probe Control don't need to be modified if I understand correctly. MIPI block should be set to RGB888 and 546 hResolution, and GPIF to 24b. The whole configuration is shown below:

Camera: RAW8, 1638x1232

MIPI Block: RGB888, 546 hResolution

GPIF: 24 bits

Probe Control: 1638x1234 B

UVC: 819x1234, 16bpp

But when I set the GPIF bus to 24b it doesn't work. I even changed the second parameter of CyU3PMipicsiGpifLoad to 0x5FD0 so it is multiple of 3, as specified in the CX3 TRM. I know it doesn't work because I output (via COM port) the number of bytes received through the DMA, and it shows 0 DMA callbacks with type CY_U3P_DMA_CB_PROD_EVENT.

The information input into the Cypress MIPI Configuration Tool is:

THS-Prepare: 60

THS-Zero: 250

Input video format: RAW8

Output video format: 24-bit

Data lanes: 4

CSI Clock: 480MHz

H-Active: 1638

H-Blanking: 1810

V-Active: 1232

V-Blanking: 50

Frame rate: 45

This tool confirms that the configuration of the MIPI block is correct:

CyU3PMipicsiCfg_t cfgUvcFullFOVx2Mipi4Raw8 =  {

CY_U3P_CSI_DF_RGB888,      /* dataFormat   */

4,                          /* numDataLanes */

1,                        /* pllPrd       */

82,                          /* pllFbd       */

CY_U3P_CSI_PLL_FRS_500_1000M, /* pllFrs       */

CY_U3P_CSI_PLL_CLK_DIV_8,    /* csiRxClkDiv  */

CY_U3P_CSI_PLL_CLK_DIV_8,    /* parClkDiv    */

0,                        /* mclkCtl      */

CY_U3P_CSI_PLL_CLK_DIV_2,    /* mClkRefDiv   */

546,                        /* hResolution  */

0                        /* fifoDelay    */

};

Is there something wrong or something I need to take into consideration?

How can I make it work with 24 bits?

0 Likes
8 Replies
KandlaguntaR_36
Moderator
Moderator
Moderator
25 solutions authored 10 solutions authored 5 solutions authored

Please try with either 16-bit or 24-bit at a time and ensure it works well for one of them. No need to try both.

It is good to go with 16-bit parallel interface, since the 24-bit interface has a constaint - line size should be 24-bit multiple constraint.

As per your Image Sensor settings, the MIPI Configuration for 16-bit parallel output would be as follows:

CSI Clock: 480 MHz

Data Lane: 4 lane

THS Prepare: 60ns

THS Zero: 250ns

fps: 45

H Active: 1640

H Blanking: 1808

V Active: 1232

V Blanking: 50

CyU3PMipicsiCfg_t null_RAW8_Resolution0 =

{

    CY_U3P_CSI_DF_YUV422_8_2,  /* CyU3PMipicsiDataFormat_t dataFormat */

    4,                          /* uint8_t numDataLanes */

    2, /* uint8_t pllPrd */

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

    1640,         /* uint16_t hResolution */

    0                         /* uint16_t fifoDelay */

};

Please probe HSYNC and VSYNC test pins and measure the Active and Blanking time.

0 Likes

I want to use 24-bits to use the maximum transfer rate possible. I just tried 16-bits to make the modifications little by little. The 24-bits is no problem since I reduced my resolution from 1640x1232 to 1638x1232, which is multiple of 24 bits.

As for the MIPI configuration you suggested, it is not working. But the only problem is the format CY_U3P_CSI_DF_YUV422_8_2. When I use your configuration with CY_U3P_CSI_DF_RGB565_2, it works just like it used to with my configuration.

This makes me think that my problem with using 24 bits is just that the RGB888 format is not working as I expected.

Is there a difference between RGB565_2 and YUV422_8_2 formats when it comes to configuring the MIPI block? What else should I take into consideration?

By the way, I'm using CyU3PMipicsiSetPhyTimeDelay (1, 18);

0 Likes

16-bit bus:

There is no difference when it comes to RGB565_2 and YUV422_8_2. Please let me know what are the changes you have done w.r.t 16-bit. Did you use the same configuration that I have shared? and changed the MIPI out format from YUY422_8_2 to RGB565_2?

24-bit:

As per 24-bit parallel bus, with 1638x1232 RAW 8 resolution, the MIPI configuration would be as follows:

/* null_RAW8_Resolution0 :  */

CyU3PMipicsiCfg_t null_RAW8_Resolution0 = 

{

    CY_U3P_CSI_DF_RGB888,  /* CyU3PMipicsiDataFormat_t dataFormat */

    4,                          /* uint8_t numDataLanes */

    2, /* uint8_t pllPrd */

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

    1638,         /* uint16_t hResolution */

    0                         /* uint16_t fifoDelay */

};

Please check whether there are any MIPI errors in YUY2_422_2 case and RGB888 case. Also probe the HSYNC and VSYNC lanes and share the active and blanking periods.

0 Likes

16-bit bus:

The only thing I change for it to work is the output format. I tried both your and my MIPI configuration, and they both work only with RGB565_2. When I use YUV422_8_2 it stops working. I have to use the MATLAB "imaqtool" GUI to see the camera, e-CAMView doesn't work with this resolution neither with YUV nor RGB.

The CyU3PMipicsiGetErrors() API doesn't show any error.

24-bit bus:

If I set GPIF bus to 16b and MIPI to RGB888 (I know this configuration makes no sense), the DMA is getting some bytes (incorrect amount). But when I set GPIF to 24b as it should be, I stop receiving any bytes. Again, there are no errors in the MIPI block.

I tried changing the CyU3PMipicsiGpifLoad() size argument from 0x5FF0 to 0x5FD0 so it is multiple of 24b and 16b.

I also tried setting "io_cfg.lppMode   = CY_U3P_IO_MATRIX_LPP_DEFAULT" , and "io_cfg.isDQ32Bit = CyTrue" in the "CyU3PDeviceConfigureIOMatrix()" API.

These changes work with 16b but not with 24b. As soon as I set GPIF to 24b, it stops receiving bytes.

Is there anything wrong with these modifications? Do I need to modify something else?

0 Likes

Let us focus on 24-bit since it is your priority.

Have you probed the HSYNC and VSYNC test lanes and measure the active and blanking timings?

If yes, please share the values.

>> I tried changing the CyU3PMipicsiGpifLoad() size argument from 0x5FF0 to 0x5FD0 so it is multiple of 24b and 16b

After this, have you updated the probe control structure. If not, please do.

No need to set io_cfg.isDQ32Bit = CyTrue.

Please enable the debug prints and see whether there is any DMA activity. Do not put debug prints in Call back functions.

0 Likes

Thanks for your answer.

I can't probe HSYNC and VSYNC since I have a custom board and those pins don't have a testpoint.

The only parameter I update in the probe control structure is the "Max video frame size in bytes":

0xAC, 0xD7, 0x1E, 0x00,             /* Max video frame size in bytes = 1638 x 1234 */

It is the same as with 16b GPIF bus because the frame size in bytes is the same, isn't it? Do I have to modify something else?

I don't have the debug UART connected either, but I have configured a UART interface through the USB, so I can output some debugging information. The DMA linked to the GPIF output (CY_U3P_UIB_SOCKET_CONS_3) has a callback. When a "CY_U3P_DMA_CB_PROD_EVENT" event arrives, I update a counter with the number of bytes in the DMA buffer (glByteCount += DmaBuffer.count;), and a counter with the number of times this callback is used. Neither of those counters update, so that callback is never being used, at least with a producer event.

As a note, this debugging works correctly with 16b, the number of bytes I get in the counter is similar to the number of bytes per frame.

0 Likes

24-bit GPIF II data bus:

Please confirm whether the GPIF II is configured properly with 24-bit interface.

Similarly, MIPI and Sensor are configured correctly.

Please check whethere there are any MIPI errors after the configuration (during MIPI Run time) using CyU3PMipicsiGetErrors API.

0 Likes

There are no MIPI errors.

Everything is configured correctly as explained before.

0 Likes