camerad: set EOF based on readout time (#33859)

* camerad: set EOF based on readout time

* set ar

* debug

* set processing time

* set ox

---------

Co-authored-by: Comma Device <device@comma.ai>
pull/33865/head
Adeeb Shihadeh 6 months ago committed by GitHub
parent 0b20007242
commit 0466d111d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      system/camerad/cameras/camera_common.cc
  2. 1
      system/camerad/cameras/camera_common.h
  3. 6
      system/camerad/cameras/spectra.cc
  4. 2
      system/camerad/sensors/ar0231.cc
  5. 2
      system/camerad/sensors/ar0231_registers.h
  6. 2
      system/camerad/sensors/ox03c10.cc
  7. 1
      system/camerad/sensors/ox03c10_registers.h
  8. 2
      system/camerad/sensors/sensor.h

@ -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 = {

@ -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;

@ -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);

@ -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;

@ -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

@ -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;

@ -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

@ -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<uint32_t> color_correct_matrix; // 3x3

Loading…
Cancel
Save