diff --git a/system/camerad/cameras/camera_common.cc b/system/camerad/cameras/camera_common.cc index bfd9e1c54b..97df4ea75f 100644 --- a/system/camerad/cameras/camera_common.cc +++ b/system/camerad/cameras/camera_common.cc @@ -114,6 +114,7 @@ bool CameraBuf::acquire(int expo_time) { cur_frame_data.processing_time = (millis_since_boot() - start_time) / 1000.0; } else { cur_yuv_buf = vipc_server->get_buffer(stream_type, cur_buf_idx); + cur_frame_data.processing_time = (double)(cur_frame_data.timestamp_end_of_isp - cur_frame_data.timestamp_eof)*1e-6; } VisionIpcBufExtra extra = { diff --git a/system/camerad/cameras/camera_common.h b/system/camerad/cameras/camera_common.h index a30730865c..e4cdb27e71 100644 --- a/system/camerad/cameras/camera_common.h +++ b/system/camerad/cameras/camera_common.h @@ -15,6 +15,7 @@ typedef struct FrameMetadata { uint32_t request_id; uint64_t timestamp_sof; uint64_t timestamp_eof; + uint64_t timestamp_end_of_isp; float processing_time; } FrameMetadata; diff --git a/system/camerad/cameras/spectra.cc b/system/camerad/cameras/spectra.cc index d6de08de46..b8827e66d8 100644 --- a/system/camerad/cameras/spectra.cc +++ b/system/camerad/cameras/spectra.cc @@ -671,8 +671,8 @@ void SpectraCamera::enqueue_buffer(int i, bool dp) { LOGE("failed to wait for sync: %d %d", ret, sync_wait.sync_obj); // TODO: handle frame drop cleanly } - - buf.frame_metadata[i].timestamp_eof = (uint64_t)nanos_since_boot(); // set true eof + buf.frame_metadata[i].timestamp_end_of_isp = (uint64_t)nanos_since_boot(); + buf.frame_metadata[i].timestamp_eof = buf.frame_metadata[i].timestamp_sof + sensor->readout_time_ns; if (dp) buf.queue(i); // destroy old output fence @@ -1083,7 +1083,7 @@ void SpectraCamera::handle_camera_event(const cam_req_mgr_message *event_data) { auto &meta_data = buf.frame_metadata[buf_idx]; meta_data.frame_id = main_id - idx_offset; meta_data.request_id = real_id; - meta_data.timestamp_sof = timestamp; + meta_data.timestamp_sof = timestamp; // this is timestamped in the kernel's SOF IRQ callback // dispatch enqueue_req_multi(real_id + FRAME_BUF_COUNT, 1, 1); diff --git a/system/camerad/sensors/ar0231.cc b/system/camerad/sensors/ar0231.cc index 5b2b7445b1..11e06de76a 100644 --- a/system/camerad/sensors/ar0231.cc +++ b/system/camerad/sensors/ar0231.cc @@ -98,6 +98,8 @@ AR0231::AR0231() { frame_data_type = 0x12; // Changing stats to 0x2C doesn't work, so change pixels to 0x12 instead mclk_frequency = 19200000; //Hz + readout_time_ns = 22850000; + dc_gain_factor = 2.5; dc_gain_min_weight = 0; dc_gain_max_weight = 1; diff --git a/system/camerad/sensors/ar0231_registers.h b/system/camerad/sensors/ar0231_registers.h index 6c4c251e8e..e0872a673a 100644 --- a/system/camerad/sensors/ar0231_registers.h +++ b/system/camerad/sensors/ar0231_registers.h @@ -6,6 +6,8 @@ const struct i2c_random_wr_payload stop_reg_array_ar0231[] = {{0x301A, 0x918}}; const struct i2c_random_wr_payload init_array_ar0231[] = { {0x301A, 0x0018}, // RESET_REGISTER + // **NOTE**: if this is changed, readout_time_ns must be updated in the Sensor config + // CLOCK Settings // input clock is 19.2 / 2 * 0x37 = 528 MHz // pixclk is 528 / 6 = 88 MHz diff --git a/system/camerad/sensors/ox03c10.cc b/system/camerad/sensors/ox03c10.cc index b39b496bfa..b2e90c4e1d 100644 --- a/system/camerad/sensors/ox03c10.cc +++ b/system/camerad/sensors/ox03c10.cc @@ -42,6 +42,8 @@ OX03C10::OX03C10() { frame_data_type = 0x2c; // one is 0x2a, two are 0x2b mclk_frequency = 24000000; //Hz + readout_time_ns = 14697000; + dc_gain_factor = 7.32; dc_gain_min_weight = 1; // always on is fine dc_gain_max_weight = 1; diff --git a/system/camerad/sensors/ox03c10_registers.h b/system/camerad/sensors/ox03c10_registers.h index 575a2cb934..ffa0b79574 100644 --- a/system/camerad/sensors/ox03c10_registers.h +++ b/system/camerad/sensors/ox03c10_registers.h @@ -31,6 +31,7 @@ const struct i2c_random_wr_payload init_array_ox03c10[] = { // delay launch group 2 {0x3208, 0xa2},*/ + // **NOTE**: if this is changed, readout_time_ns must be updated in the Sensor config // PLL setup {0x0301, 0xc8}, // pll1_divs, pll1_predivp, pll1_divpix {0x0303, 0x01}, // pll1_prediv diff --git a/system/camerad/sensors/sensor.h b/system/camerad/sensors/sensor.h index 5cb7b686d4..b4c4303b66 100644 --- a/system/camerad/sensors/sensor.h +++ b/system/camerad/sensors/sensor.h @@ -66,6 +66,8 @@ public: uint32_t mclk_frequency; uint32_t frame_data_type; + uint32_t readout_time_ns; // used to recover EOF from SOF + // ISP image processing params uint32_t black_level; std::vector color_correct_matrix; // 3x3