OV5640 Auto Focus support on i.MX8M Mini

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OV5640 Auto Focus support on i.MX8M Mini

1,901 Views
riccardoierardi
Contributor I

Hi everyone,

I'm working on a project using an i.MX8M Mini Processor SOM that runs on Android 9 Pie and uses an OV5640 camera with Focus support connected over MIPI-CSI (LI-OV5640-MIPI-AF).

I’m working with this driver, into which I implemented a very basic always on autofocus function: https://source.codeaurora.org/external/imx/linux-imx/tree/drivers/media/platform/mxc/capture/ov5640_...
The driver puts the device into software power down mode everytime the configuration is updated and everytime it calls s_stream off. This makes the shutter to close and turns off the autofocus, so high resolutions photo are unusable (not in focus and almost black).

I've tried to remove the power down command, but it doesn't work, after acquisition is triggered the HAL cannot get the buffer for acquisition, giving this error back:

09-19 18:05:36.816  3270  4848 E Camera3-Stream: getBuffer: wait for output buffer return timed out after 3000ms (max_buffers 2)
09-19 18:05:36.816  3270  4848 E Camera3-Device: RequestThread: Can't get output buffer, skipping request: Connection timed out (-110)

Then the camera becomes unusable until reboot.

This happens only when the resolution is over 1280x720, because under it the driver is not triggered for capture.

I've seen a lot of OV5640 drivers with AF function and V4L2 support enabled, but the software power down is never triggered. I can't understand why, in this case, the software power down is needed. Is there a workaround to avoid it? How can I capture a photo without resetting the autofocus function?

Thank you for the support,

Kind Regards

0 Kudos
4 Replies

303 Views
mikebaird
Contributor I

I was able to port code from here to make it work:

https://github.com/0015/ESP32-OV5640-AF

0 Kudos

304 Views
mikebaird
Contributor I

I was able to port code from here to make it work:

https://github.com/0015/ESP32-OV5640-AF 

0 Kudos

348 Views
mikebaird
Contributor I

I'm trying to get the Autofocus to work on the MIMXRT1170 Eval Kit.
Using the example "evkmimxrt1170_csi_mipi_rgb_cm7", as far as I can tell, AF isn't enabled. 

Digging through the source there's a function "CAMERA_DEVICE_CONTROL".

It's not clear to me when this should be called (I've tried it in a few places) with little success. 
The result of the command is "0" so it seems to be being sent to the camera. 

Is there something I'm missing? Is there an application note somewhere on this?

 Thanks!

 status_t cam_result = CAMERA_DEVICE_Control(&cameraDevice, kCAMERA_DeviceAutoFocus, CAMERA_AUTO_FOCUS_ON );
PRINTF("Setting light mode: %i", cam_result);

/*! @brief Camera device control command. */
typedef enum _camera_device_cmd
{
kCAMERA_DeviceAutoFocus, /*!< Auto focus. */
#define CAMERA_AUTO_FOCUS_ON 1
#define CAMERA_AUTO_FOCUS_OFF 0



0 Kudos

1,591 Views
jimmychan
NXP TechSupport
NXP TechSupport

In the driver code, there is no support for AFC and shutter control. You may need to contact OmniVision for App. Note "Auto FocusCamera Module Application Notes". There is firmware and AF Sequence. You need to add the AFC function in the driver by yourself.

0 Kudos