nxp-mcuxpresso / mcux-sdk

MCUXpresso SDK
BSD 3-Clause "New" or "Revised" License
301 stars 136 forks source link

drivers: csi: Rework to fix framerate issue #188

Closed ngphibang closed 1 month ago

ngphibang commented 2 months ago

Prerequisites

Describe the pull request Currently, the camera framerate is divided by two. This is because the driver only puts the full buffer to the queue and calls the callback at half of the interrupt rate (when there are at least 2 active framebuffers).

On bare metal, this issue is not really visible when using more than 2 buffers and the application does not hold the full buffer for too long before submitting it again to the empty buffers queue. But if we use only 2 buffers, the framerate is clearly reduced (by a factor of two).

Especially, when CSI_TransferGetFullBuffer() get called inside the callback function (as in Zephyr RTOS), framerate is always reduced by a factor of two despite of the number of buffers used.

Rework the driver to fix these issues as well as to clean up the logics.

After the fix : On i.MX RT1170 EVK and i.MX RT1064 EVK, with the csi rgb bare metal example, framerate is not changed if we use more than 2 buffers. However, if we use only 2 buffers, the fix gives the full framerate while the framerate is reduced by a half with the original code.

On Zephyr RTOS, framerate is always improved by 2 on both i.MX RT1064 EVK and i.MX RT1170 EVK.

Fixes # (187) -->

Type of change

Tests

mmahadevan108 commented 2 months ago

cc @jasonNXP

ngphibang commented 2 months ago

@zejiang0jason Thanks for your comments ! I addressed all of your comments, though for some I added some arguments :)

ngphibang commented 2 months ago

@zejiang0jason Is it ok for you now ? Thanks !