common/csi: Add support for non-blocking flag.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
iabdalkader 2025-06-24 09:58:15 +02:00
parent 72410dfc8c
commit 3270272e11
2 changed files with 8 additions and 7 deletions

View File

@ -1621,16 +1621,14 @@ __weak int omv_csi_copy_line(omv_csi_t *csi, void *dma, uint8_t *src, uint8_t *d
} }
__weak int omv_csi_snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) { __weak int omv_csi_snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) {
int ret = OMV_CSI_ERROR_CTL_UNSUPPORTED;
// Call the sensor specific function. // Call the sensor specific function.
if (csi->snapshot == NULL) { if (csi->snapshot) {
return OMV_CSI_ERROR_CTL_UNSUPPORTED; ret = csi->snapshot(csi, image, flags);
} }
if (csi->snapshot(csi, image, flags) != 0) { return ret;
return OMV_CSI_ERROR_CTL_FAILED;
}
return 0;
} }
const char *omv_csi_strerror(int error) { const char *omv_csi_strerror(int error) {
@ -1656,6 +1654,7 @@ const char *omv_csi_strerror(int error) {
"Frame buffer error.", "Frame buffer error.",
"Frame buffer overflow, try reducing the frame size.", "Frame buffer overflow, try reducing the frame size.",
"JPEG frame buffer overflow.", "JPEG frame buffer overflow.",
"The requested operation would block.",
}; };
// Sensor errors are negative. // Sensor errors are negative.

View File

@ -195,6 +195,7 @@ typedef enum {
typedef enum { typedef enum {
OMV_CSI_CAPTURE_FLAGS_UPDATE = (1 << 0), OMV_CSI_CAPTURE_FLAGS_UPDATE = (1 << 0),
OMV_CSI_CAPTURE_FLAGS_NBLOCK = (1 << 1),
} omv_csi_capture_flags_t; } omv_csi_capture_flags_t;
typedef enum { typedef enum {
@ -258,6 +259,7 @@ typedef enum {
OMV_CSI_ERROR_FRAMEBUFFER_ERROR = -18, OMV_CSI_ERROR_FRAMEBUFFER_ERROR = -18,
OMV_CSI_ERROR_FRAMEBUFFER_OVERFLOW = -19, OMV_CSI_ERROR_FRAMEBUFFER_OVERFLOW = -19,
OMV_CSI_ERROR_JPEG_OVERFLOW = -20, OMV_CSI_ERROR_JPEG_OVERFLOW = -20,
OMV_CSI_ERROR_WOULD_BLOCK = -21,
} omv_csi_error_t; } omv_csi_error_t;
#if (OMV_GENX320_ENABLE == 1) #if (OMV_GENX320_ENABLE == 1)