@@ -54,6 +54,8 @@ static const char *TAG = "ov2710";
5454static portMUX_TYPE s_stats_mutex = portMUX_INITIALIZER_UNLOCKED ;
5555#endif
5656
57+ #define OV2710_GAIN_V (_v , _b ) ((uint32_t)(((_v) >> ((_b))) & 0x01) + 1)
58+
5759static const esp_cam_sensor_isp_info_t ov2710_isp_info [] = {
5860 /* For MIPI */
5961 {
@@ -62,6 +64,7 @@ static const esp_cam_sensor_isp_info_t ov2710_isp_info[] = {
6264 .pclk = 80000000 ,
6365 .vts = 1322 ,
6466 .hts = 2420 ,
67+ .tline_ns = 30222 ,
6568 .bayer_type = ESP_CAM_SENSOR_BAYER_BGGR ,
6669 }
6770 },
@@ -71,6 +74,7 @@ static const esp_cam_sensor_isp_info_t ov2710_isp_info[] = {
7174 .pclk = 80000000 ,
7275 .vts = 1322 ,
7376 .hts = 2420 ,
77+ .tline_ns = 26666 ,
7478 .bayer_type = ESP_CAM_SENSOR_BAYER_BGGR ,
7579 },
7680 },
@@ -161,7 +165,8 @@ static esp_err_t ov2710_set_reg_bits(esp_sccb_io_handle_t sccb_handle, uint16_t
161165#if CONFIG_CAMERA_OV2710_STATS_UPDATE_EN
162166static void wb_timer_callback (TimerHandle_t timer )
163167{
164- uint8_t read_v [5 ] = {0 };
168+ uint8_t read_v [8 ] = {0 };
169+ uint8_t read_v2 = 0 ;
165170 esp_cam_sensor_device_t * dev = (esp_cam_sensor_device_t * )pvTimerGetTimerID (timer );
166171 struct ov2710_cam * cam_ov2710 = (struct ov2710_cam * )dev -> priv ;
167172
@@ -170,14 +175,28 @@ static void wb_timer_callback(TimerHandle_t timer)
170175 ov2710_read (dev -> sccb_handle , OV2710_REG_BLUE_BEFORE_GAIN_AVERAGE , & read_v [2 ]);
171176 ov2710_read (dev -> sccb_handle , OV2710_REG_AEC_AGC_ADJ_MSB , & read_v [3 ]);
172177 ov2710_read (dev -> sccb_handle , OV2710_REG_AEC_AGC_ADJ_LSB , & read_v [4 ]);
178+ ov2710_read (dev -> sccb_handle , OV2710_REG_AEC_EXPO_H , & read_v [5 ]);
179+ ov2710_read (dev -> sccb_handle , OV2710_REG_AEC_EXPO_M , & read_v [6 ]);
180+ ov2710_read (dev -> sccb_handle , OV2710_REG_AEC_EXPO_L , & read_v [7 ]);
181+ // ov2710_read(dev->sccb_handle, 0x568A, &read_v2);
182+ ov2710_read (dev -> sccb_handle , 0x5690 , & read_v2 );
173183
174184 portENTER_CRITICAL (& s_stats_mutex );
175185 cam_ov2710 -> ov2710_para .stats .wb_avg .red_avg = read_v [0 ];
176186 cam_ov2710 -> ov2710_para .stats .wb_avg .green_avg = read_v [1 ];
177187 cam_ov2710 -> ov2710_para .stats .wb_avg .blue_avg = read_v [2 ];
178- cam_ov2710 -> ov2710_para .stats .agc_gain = ((read_v [3 ] & 0x01 ) + 1 ) * ((read_v [4 ] & 0x80 ) + 1 ) * ((read_v [4 ] & 0x40 ) + 1 ) * ((read_v [4 ] & 0x20 ) + 1 ) * ((read_v [4 ] & 0x10 ) + 1 ) * ((read_v [4 ] & 0x0f ) / 16 + 1 );
188+ cam_ov2710 -> ov2710_para .stats .agc_gain = ((float )(read_v [4 ] & 0xf ) / 16.0 + 1.0 ) * \
189+ OV2710_GAIN_V (read_v [3 ], 0 ) * \
190+ OV2710_GAIN_V (read_v [4 ], 7 ) * \
191+ OV2710_GAIN_V (read_v [4 ], 6 ) * \
192+ OV2710_GAIN_V (read_v [4 ], 5 ) * \
193+ OV2710_GAIN_V (read_v [4 ], 4 );
194+
195+ cam_ov2710 -> ov2710_para .stats .aec_exp = ((uint32_t )(read_v [5 ] & 0x0f ) << 16 ) | ((uint32_t )read_v [6 ] << 8 ) | ((uint32_t )read_v [7 ]);
179196 cam_ov2710 -> ov2710_para .stats .seq ++ ;
180197 portEXIT_CRITICAL (& s_stats_mutex );
198+ ESP_LOGD (TAG , "_gain=%f, avg=0x%" PRIx8 ", _exp=0x%" PRIx32 , cam_ov2710 -> ov2710_para .stats .agc_gain , read_v2 , cam_ov2710 -> ov2710_para .stats .aec_exp );
199+ ESP_LOGD (TAG , "_luma=%f" , (float )read_v2 * 1000 / cam_ov2710 -> ov2710_para .stats .agc_gain / cam_ov2710 -> ov2710_para .stats .aec_exp );
181200}
182201#endif
183202
@@ -626,7 +645,7 @@ esp_cam_sensor_device_t *ov2710_detect(esp_cam_sensor_config_t *config)
626645
627646#if CONFIG_CAMERA_OV2710_STATS_UPDATE_EN
628647 // Init cam privae pata
629- cam_ov2710 -> ov2710_para .stats .flags = ESP_CAM_SENSOR_STATS_FLAG_WB_GAIN | ESP_CAM_SENSOR_STATS_FLAG_AGC_GAIN ;
648+ cam_ov2710 -> ov2710_para .stats .flags = ESP_CAM_SENSOR_STATS_FLAG_WB_GAIN | ESP_CAM_SENSOR_STATS_FLAG_AGC_GAIN | ESP_CAM_SENSOR_STATS_FLAG_EXPOSURE ;
630649 cam_ov2710 -> wb_timer_handle = xTimerCreate ("wb_t" , CONFIG_CAMERA_OV2710_STATS_UPDATE_INTERVAL / portTICK_PERIOD_MS , pdTRUE ,
631650 (void * )dev , wb_timer_callback );
632651 if (!cam_ov2710 -> wb_timer_handle ) {
0 commit comments