diff --git a/common/omv_csi.h b/common/omv_csi.h index e78a9ec71..666f97c0a 100644 --- a/common/omv_csi.h +++ b/common/omv_csi.h @@ -287,6 +287,9 @@ typedef struct _omv_csi_callback_t { void *arg; } omv_csi_cb_t; +typedef int (*omv_csi_snapshot_t) + (omv_csi_t *csi, image_t *image, uint32_t flags); + typedef struct _omv_csi { uint32_t chip_id; // Sensor ID 32 bits. uint8_t slv_addr; // Sensor I2C slave address. diff --git a/drivers/sensors/boson.c b/drivers/sensors/boson.c index a44559368..bae2f8874 100644 --- a/drivers/sensors/boson.c +++ b/drivers/sensors/boson.c @@ -139,7 +139,7 @@ static int set_colorbar(omv_csi_t *csi, int enable) { } static int snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) { - int ret = omv_csi_snapshot(csi, image, flags); + int ret = ((omv_csi_snapshot_t) csi->priv)(csi, image, flags); if (ret < 0) { return ret; @@ -165,6 +165,7 @@ int boson_init(omv_csi_t *csi) { csi->set_pixformat = set_pixformat; csi->set_framesize = set_framesize; csi->set_colorbar = set_colorbar; + csi->priv = csi->snapshot; csi->snapshot = snapshot; // Set csi flags diff --git a/drivers/sensors/genx320.c b/drivers/sensors/genx320.c index 6318c36c9..f9b633328 100644 --- a/drivers/sensors/genx320.c +++ b/drivers/sensors/genx320.c @@ -406,7 +406,7 @@ static int snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) { // Collect events to calibrate hot pixels. for (uint32_t i = 0; i < EVENT_THRESHOLD_TO_CALIBRATE; ) { - int ret = omv_csi_snapshot(csi, image, flags); + int ret = ((omv_csi_snapshot_t) csi->priv)(csi, image, flags); if (ret < 0) { return ret; @@ -451,7 +451,7 @@ static int snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) { } #endif // (OMV_GENX320_CAL_ENABLE == 1) - int ret = omv_csi_snapshot(csi, image, flags); + int ret = ((omv_csi_snapshot_t) csi->priv)(csi, image, flags); if (ret < 0) { return ret; @@ -604,6 +604,7 @@ int genx320_init(omv_csi_t *csi) { csi->set_colorbar = set_colorbar; csi->set_hmirror = set_hmirror; csi->set_vflip = set_vflip; + csi->priv = csi->snapshot; csi->snapshot = snapshot; csi->ioctl = ioctl; diff --git a/drivers/sensors/paj6100.c b/drivers/sensors/paj6100.c index f135d4075..aa06c85f8 100644 --- a/drivers/sensors/paj6100.c +++ b/drivers/sensors/paj6100.c @@ -661,8 +661,9 @@ static int reset(omv_csi_t *csi) { } static int paj6100_snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) { - int res = omv_csi_snapshot(csi, image, flags); - if (res == 0) { + int ret = ((omv_csi_snapshot_t) csi->priv)(csi, image, flags); + + if (ret == 0) { l_total = 0; int iml = image->h * image->w; for (int i = 0; i < iml; ++i) { @@ -673,7 +674,7 @@ static int paj6100_snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) { auto_exposure(csi); } - return res; + return ret; } int paj6100_init(omv_csi_t *csi) { @@ -700,6 +701,7 @@ int paj6100_init(omv_csi_t *csi) { csi->set_special_effect = set_special_effect; csi->set_lens_correction = set_lens_correction; + csi->priv = csi->snapshot; csi->snapshot = paj6100_snapshot; // Set csi flags