mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
fixed flickering on automatic exposure and added support for set_auto_exposure API
This commit is contained in:
parent
dac63a6f6a
commit
fb80409fe2
185
src/omv/hm01b0.c
185
src/omv/hm01b0.c
@ -19,93 +19,95 @@
|
||||
#include "omv_boardconfig.h"
|
||||
#define HIMAX_BOOT_RETRY (10)
|
||||
|
||||
#define HIMAX_LINE_LEN_PCK 0x172
|
||||
#define HIMAX_FRAME_LENGTH 0x232
|
||||
#if (OMV_ENABLE_HM01B0 == 1)
|
||||
static const uint16_t default_regs[][2] = {
|
||||
{BLC_TGT, 0x08}, // BLC target :8 at 8 bit mode
|
||||
{BLC2_TGT, 0x08}, // BLI target :8 at 8 bit mode
|
||||
{0x3044, 0x0A}, // Increase CDS time for settling
|
||||
{0x3045, 0x00}, // Make symetric for cds_tg and rst_tg
|
||||
{0x3047, 0x0A}, // Increase CDS time for settling
|
||||
{0x3050, 0xC0}, // Make negative offset up to 4x
|
||||
{0x3051, 0x42},
|
||||
{0x3052, 0x50},
|
||||
{0x3053, 0x00},
|
||||
{0x3054, 0x03}, // tuning sf sig clamping as lowest
|
||||
{0x3055, 0xF7}, // tuning dsun
|
||||
{0x3056, 0xF8}, // increase adc nonoverlap clk
|
||||
{0x3057, 0x29}, // increase adc pwr for missing code
|
||||
{0x3058, 0x1F}, // turn on dsun
|
||||
{0x3059, 0x1E},
|
||||
{0x3064, 0x00},
|
||||
{0x3065, 0x04}, // pad pull 0
|
||||
{BLC_TGT, 0x08}, // BLC target :8 at 8 bit mode
|
||||
{BLC2_TGT, 0x08}, // BLI target :8 at 8 bit mode
|
||||
{0x3044, 0x0A}, // Increase CDS time for settling
|
||||
{0x3045, 0x00}, // Make symetric for cds_tg and rst_tg
|
||||
{0x3047, 0x0A}, // Increase CDS time for settling
|
||||
{0x3050, 0xC0}, // Make negative offset up to 4x
|
||||
{0x3051, 0x42},
|
||||
{0x3052, 0x50},
|
||||
{0x3053, 0x00},
|
||||
{0x3054, 0x03}, // tuning sf sig clamping as lowest
|
||||
{0x3055, 0xF7}, // tuning dsun
|
||||
{0x3056, 0xF8}, // increase adc nonoverlap clk
|
||||
{0x3057, 0x29}, // increase adc pwr for missing code
|
||||
{0x3058, 0x1F}, // turn on dsun
|
||||
{0x3059, 0x1E},
|
||||
{0x3064, 0x00},
|
||||
{0x3065, 0x04}, // pad pull 0
|
||||
|
||||
{BLC_CFG, 0x43}, // BLC_on, IIR
|
||||
|
||||
{0x1001, 0x43}, // BLC dithering en
|
||||
{0x1002, 0x43}, // blc_darkpixel_thd
|
||||
{0x0350, 0x7F}, // Dgain Control
|
||||
{BLI_EN, 0x01}, // BLI enable
|
||||
{0x1003, 0x00}, // BLI Target [Def: 0x20]
|
||||
|
||||
{DPC_CTRL, 0x01}, // DPC option 0: DPC off 1 : mono 3 : bayer1 5 : bayer2
|
||||
{0x1009, 0xA0}, // cluster hot pixel th
|
||||
{0x100A, 0x60}, // cluster cold pixel th
|
||||
{SINGLE_THR_HOT, 0x90}, // single hot pixel th
|
||||
{SINGLE_THR_COLD, 0x40}, // single cold pixel th
|
||||
{0x1012, 0x00}, // Sync. shift disable
|
||||
{0x2000, 0x07},
|
||||
{0x2003, 0x00},
|
||||
{0x2004, 0x1C},
|
||||
{0x2007, 0x00},
|
||||
{0x2008, 0x58},
|
||||
{0x200B, 0x00},
|
||||
{0x200C, 0x7A},
|
||||
{0x200F, 0x00},
|
||||
{0x2010, 0xB8},
|
||||
{0x2013, 0x00},
|
||||
{0x2014, 0x58},
|
||||
{0x2017, 0x00},
|
||||
{0x2018, 0x9B},
|
||||
|
||||
{AE_CTRL, 0x01}, //Automatic Exposure
|
||||
{AE_TARGET_MEAN, 0x3C}, //AE target mean [Def: 0x3C]
|
||||
{AE_MIN_MEAN, 0x0A}, //AE min target mean [Def: 0x0A]
|
||||
{CONVERGE_IN_TH, 0x03}, //Converge in threshold [Def: 0x03]
|
||||
{CONVERGE_OUT_TH, 0x05}, //Converge out threshold [Def: 0x05]
|
||||
{MAX_INTG_H, 0x01}, //Maximum INTG High Byte [Def: 0x01]
|
||||
{MAX_INTG_L, 0x54}, //Maximum INTG Low Byte [Def: 0x54]
|
||||
{MAX_AGAIN_FULL, 0x03}, //Maximum Analog gain in full frame mode [Def: 0x03]
|
||||
{MAX_AGAIN_BIN2, 0x04}, //Maximum Analog gain in bin2 mode [Def: 0x04]
|
||||
{MAX_DGAIN, 0xC0},
|
||||
|
||||
{INTEGRATION_H, 0x01}, //Integration H [Def: 0x01]
|
||||
{INTEGRATION_L, 0x08}, //Integration L [Def: 0x08]
|
||||
{ANALOG_GAIN, 0x00}, //Analog Global Gain [Def: 0x00]
|
||||
{DAMPING_FACTOR, 0x20}, //Damping Factor [Def: 0x20]
|
||||
{DIGITAL_GAIN_H, 0x01}, //Digital Gain High [Def: 0x01]
|
||||
{DIGITAL_GAIN_L, 0x00}, //Digital Gain Low [Def: 0x00]
|
||||
|
||||
{FS_CTRL, 0x00}, //Flicker Control
|
||||
|
||||
{FS_60HZ_H, 0x00},
|
||||
{FS_60HZ_L, 0x3C},
|
||||
{FS_50HZ_H, 0x00},
|
||||
{FS_50HZ_L, 0x32},
|
||||
|
||||
{BLC_CFG, 0x43}, // BLC_on, IIR
|
||||
|
||||
{0x1001, 0x43}, // BLC dithering en
|
||||
{0x1002, 0x43}, // blc_darkpixel_thd
|
||||
{0x0350, 0x00}, // Dgain Control
|
||||
{BLI_EN, 0x01}, // BLI enable
|
||||
{0x1003, 0x00}, // BLI Target [Def: 0x20]
|
||||
|
||||
{DPC_CTRL, 0x01}, // DPC option 0: DPC off 1 : mono 3 : bayer1 5 : bayer2
|
||||
{0x1009, 0xA0}, // cluster hot pixel th
|
||||
{0x100A, 0x60}, // cluster cold pixel th
|
||||
{SINGLE_THR_HOT, 0x90}, // single hot pixel th
|
||||
{SINGLE_THR_COLD, 0x40}, // single cold pixel th
|
||||
{0x1012, 0x00}, // Sync. shift disable
|
||||
{0x2000, 0x07},
|
||||
{0x2003, 0x00},
|
||||
{0x2004, 0x1C},
|
||||
{0x2007, 0x00},
|
||||
{0x2008, 0x58},
|
||||
{0x200B, 0x00},
|
||||
{0x200C, 0x7A},
|
||||
{0x200F, 0x00},
|
||||
{0x2010, 0xB8},
|
||||
{0x2013, 0x00},
|
||||
{0x2014, 0x58},
|
||||
{0x2017, 0x00},
|
||||
{0x2018, 0x9B},
|
||||
|
||||
{AE_CTRL, 0x01}, //Automatic Exposure
|
||||
{AE_TARGET_MEAN, 0x3C}, //AE target mean [Def: 0x3C]
|
||||
{AE_MIN_MEAN, 0x0A}, //AE min target mean [Def: 0x0A]
|
||||
{CONVERGE_IN_TH, 0x03}, //Converge in threshold [Def: 0x03]
|
||||
{CONVERGE_OUT_TH, 0x05}, //Converge out threshold [Def: 0x05]
|
||||
{MAX_INTG_H, 0x01}, //Maximum INTG High Byte [Def: 0x01]
|
||||
{MAX_INTG_L, 0x54}, //Maximum INTG Low Byte [Def: 0x54]
|
||||
{MAX_AGAIN_FULL, 0x03}, //Maximum Analog gain in full frame mode [Def: 0x03]
|
||||
{MAX_AGAIN_BIN2, 0x04}, //Maximum Analog gain in bin2 mode [Def: 0x04]
|
||||
{MAX_DGAIN, 0xC0},
|
||||
|
||||
{INTEGRATION_H, 0x01}, //Integration H [Def: 0x01]
|
||||
{INTEGRATION_L, 0x08}, //Integration L [Def: 0x08]
|
||||
{ANALOG_GAIN, 0x00}, //Analog Global Gain [Def: 0x00]
|
||||
{DAMPING_FACTOR, 0x20}, //Damping Factor [Def: 0x20]
|
||||
{DIGITAL_GAIN_H, 0x01}, //Digital Gain High [Def: 0x01]
|
||||
{DIGITAL_GAIN_L, 0x00}, //Digital Gain Low [Def: 0x00]
|
||||
|
||||
{FS_CTRL, 0x00}, //Flicker Control
|
||||
|
||||
{FS_60HZ_H, 0x00},
|
||||
{FS_60HZ_L, 0x3C},
|
||||
{FS_50HZ_H, 0x00},
|
||||
{FS_50HZ_L, 0x32},
|
||||
|
||||
{MD_CTRL, 0x30},
|
||||
{0x0340, 0x02},
|
||||
{0x0341, 0x16},
|
||||
{0x0342, 0x01},
|
||||
{0x0343, 0x78},
|
||||
{0x3010, 0x00}, // no full frame
|
||||
{0x0383, 0x01},
|
||||
{0x0387, 0x01},
|
||||
{0x0390, 0x00},
|
||||
{0x3011, 0x70},
|
||||
{0x3059, 0x02},
|
||||
{0x3060, 0x0B},
|
||||
{IMG_ORIENTATION, 0x01}, // change the orientation
|
||||
{0x0104, 0x01},
|
||||
{MD_CTRL, 0x30},
|
||||
{FRAME_LEN_LINES_H, HIMAX_FRAME_LENGTH>>8},
|
||||
{FRAME_LEN_LINES_L, HIMAX_FRAME_LENGTH&0xFF},
|
||||
{LINE_LEN_PCK_H, HIMAX_LINE_LEN_PCK>>8},
|
||||
{LINE_LEN_PCK_L, HIMAX_LINE_LEN_PCK&0xFF},
|
||||
{0x3010, 0x00}, // no full frame
|
||||
{0x0383, 0x01},
|
||||
{0x0387, 0x01},
|
||||
{0x0390, 0x00},
|
||||
{0x3011, 0x70},
|
||||
{0x3059, 0x02},
|
||||
{0x3060, 0x0B},
|
||||
{IMG_ORIENTATION, 0x01}, // change the orientation
|
||||
{0x0104, 0x01},
|
||||
|
||||
//============= End of regs marker ==================
|
||||
{0x0000, 0x00},
|
||||
@ -260,7 +262,20 @@ static int get_gain_db(sensor_t *sensor, float *gain_db)
|
||||
|
||||
static int set_auto_exposure(sensor_t *sensor, int enable, int exposure_us)
|
||||
{
|
||||
return 0;
|
||||
int ret=0;
|
||||
|
||||
if (enable) {
|
||||
ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, AE_CTRL, 1);
|
||||
} else {
|
||||
int coarse_int = exposure_us*(OMV_XCLK_FREQUENCY/1000000)/LINE_LEN_PCK_H;
|
||||
if (coarse_int<2) coarse_int = 2;
|
||||
if (coarse_int>HIMAX_FRAME_LENGTH-2) coarse_int = HIMAX_FRAME_LENGTH-2;
|
||||
ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, AE_CTRL, 0);
|
||||
ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, INTEGRATION_H, coarse_int>>8);
|
||||
ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, INTEGRATION_L, coarse_int&0xff);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int get_exposure_us(sensor_t *sensor, int *exposure_us)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user