[cx3] How to send extra data to host via CyU3PDmaMultiChannelCommitBuffer

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

cross mob
bbfe_4086196
Level 2
Level 2
5 sign-ins Welcome!

Hi  RashiV_61,

Now, I have requirement about add extra data to last uvc frame, offer the sensor's timestamp, exposure time/ gain get from sensor to host.

the step :

1, CyU3PDmaMultiChannelGetBuffer got data from sensor in callback

2, check if it's the last frame "DmaBuffer.count < ES_UVC_DATA_BUF_SIZE"

3, if yes, then pad extra information to “DmaBuffer.buffer+DmaBuffer.count”

     status = CyU3PDmaMultiChannelCommitBuffer (chHandle, (DmaBuffer.count + 12 + 48), 0);

else

     status = CyU3PDmaMultiChannelCommitBuffer (chHandle, (DmaBuffer.count + 12), 0);

as you know, DmaBuffer.count from CyU3PDmaMultiChannelGetBuffer has not contain the extra 48 bytes.

this is not a correct process, might corrupt the memory .

sensor trigger cx3, cx3 padding header, sent out.

I want to know, if there is a api for this case, can insert data to the video flow.

0 Likes
1 Solution
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

According to my understanding, your requirement is to add an additional 48 bytes at the end of a partial DMA buffer (the last buffer of a frame). Please correct me if Iam wrong. If this is the requirement, then it can be done without data corruption by using the following way:

1.While creating the DMA channel, as per the current configuration, 12 bytes will be allocated for header and 4 bytes will be allocated for footer. This needs to be changed so that 12 bytes are still allocated for header but 52 bytes are allocated for footer.

2.Reduce the DMA buffer size (excluding header and footer) by 48 bytes.

3.Step 2 will reduce the size of full buffers. So, make sure that the video frame ends with a partial buffer. This can be done by calculating the video frame size in bytes and dividing this with the size of full buffer obtained in step 2. The video frame size in bytes should not be perfectly divisible by the size of full buffer. This is a requirement for the fixed state machine on CX3 to work properly.

4.The total size of DMA buffer (size of full buffer + size of header + size of footer) should be divisible by 16 bytes.

As the size of footer is greater than 48 (the amount of data that you want to send at the end of DMA buffer), there will not be a case for data corruption to occur. Please try this and let us know the results.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna

View solution in original post

0 Likes
5 Replies
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

According to my understanding, your requirement is to add an additional 48 bytes at the end of a partial DMA buffer (the last buffer of a frame). Please correct me if Iam wrong. If this is the requirement, then it can be done without data corruption by using the following way:

1.While creating the DMA channel, as per the current configuration, 12 bytes will be allocated for header and 4 bytes will be allocated for footer. This needs to be changed so that 12 bytes are still allocated for header but 52 bytes are allocated for footer.

2.Reduce the DMA buffer size (excluding header and footer) by 48 bytes.

3.Step 2 will reduce the size of full buffers. So, make sure that the video frame ends with a partial buffer. This can be done by calculating the video frame size in bytes and dividing this with the size of full buffer obtained in step 2. The video frame size in bytes should not be perfectly divisible by the size of full buffer. This is a requirement for the fixed state machine on CX3 to work properly.

4.The total size of DMA buffer (size of full buffer + size of header + size of footer) should be divisible by 16 bytes.

As the size of footer is greater than 48 (the amount of data that you want to send at the end of DMA buffer), there will not be a case for data corruption to occur. Please try this and let us know the results.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hi JayakrishnaT_76,

Thanks.

According to my understanding, your requirement is to add an additional 48 bytes at the end of a partial DMA buffer (the last buffer of a frame). Please correct me if Iam wrong. If this is the requirement, then it can be done without data corruption by using the following way:

Yes, this is exactly what I want.

1.While creating the DMA channel, as per the current configuration, 12 bytes will be allocated for header and 4 bytes will be allocated for footer. This needs to be changed so that 12 bytes are still allocated for header but 52 bytes are allocated for footer.

2.Reduce the DMA buffer size (excluding header and footer) by 48 bytes.

3.Step 2 will reduce the size of full buffers. So, make sure that the video frame ends with a partial buffer. This can be done by calculating the video frame size in bytes and dividing this with the size of full buffer obtained in step 2. The video frame size in bytes should not be perfectly divisible by the size of full buffer. This is a requirement for the fixed state machine on CX3 to work properly.

4.The total size of DMA buffer (size of full buffer + size of header + size of footer) should be divisible by 16 bytes.

My DMA buffer size is 0x27f0.

reduce to 0x27c0 (0x27f0 - 48),and increase footer to 52 bytes.

just change ES_UVC_HS_DATA_BUF_SIZE and ES_UVC_PROD_FOOTER

#define ES_UVC_HS_DATA_BUF_SIZE                                 (0x27c0)

#define ES_UVC_PROD_FOOTER                                         (52)

#define ES_UVC_PROD_HEADER                                         (12)

CyU3PDmaMultiChannelCommitBuffer (chHandle, (DmaBuffer.count + 12), 0);

But the total frame length got from host is still 614400 (640 × 480 ×2), not contain extra 48 bytes.

Is there anything I missed from your guide ?

thanks.

0 Likes

Hello,

Please let me know if the extra 48 bytes that is to be added at the end of last partial buffer was added in the firmware or not. Also, the API CyU3PDmaMultiChannelCommitBuffer() should be called as follows when a partial buffer is to be committed:

status = CyU3PDmaMultiChannelCommitBuffer (chHandle, (DmaBuffer.count + 12 + 48), 0);

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hi JayakrishnaT_76,

Yes, after add 48 to CyU3PDmaMultiChannelCommitBuffer , host got extra 48 bytes.

your point is to increase footer size to leave rom for extra data, right ?

thanks.

0 Likes

Hello,

Yes, your understanding is correct, my point was to increase footer size to leave room for extra data to prevent any possible data corruption.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes