@@ -1396,31 +1396,7 @@ bool SpectraCamera::handle_camera_event(const cam_req_mgr_message *event_data) {
1396
1396
1397
1397
int buf_idx = (request_id - 1 ) % ife_buf_depth;
1398
1398
uint64_t timestamp = event_data->u .frame_msg .timestamp ; // this is timestamped in the kernel's SOF IRQ callback
1399
- if (syncFirstFrame (cc.camera_num , request_id, frame_id_raw, timestamp)) {
1400
- // wait for this frame's EOF, then queue up the next one
1401
- if (enqueue_buffer (buf_idx, request_id + ife_buf_depth)) {
1402
- // Frame is ready
1403
-
1404
- // in IFE_PROCESSED mode, we can't know the true EOF, so recover it with sensor readout time
1405
- uint64_t timestamp_eof = timestamp + sensor->readout_time_ns ;
1406
-
1407
- // Update buffer and frame data
1408
- buf.cur_buf_idx = buf_idx;
1409
- buf.cur_frame_data = {
1410
- .frame_id = (uint32_t )(frame_id_raw - camera_sync_data[cc.camera_num ].frame_id_offset ),
1411
- .request_id = (uint32_t )request_id,
1412
- .timestamp_sof = timestamp,
1413
- .timestamp_eof = timestamp_eof,
1414
- .processing_time = float ((nanos_since_boot () - timestamp_eof) * 1e-9 )
1415
- };
1416
- return true ;
1417
- }
1418
- // LOGW("camerad %d synced req %d fid %d, publishing ts %.2f cereal_frame_id %d", cc.camera_num, (int)request_id, (int)frame_id_raw, (double)(timestamp)*1e-6, meta_data.frame_id);
1419
- } else {
1420
- // Frames not yet synced
1421
- enqueue_req_multi (request_id + ife_buf_depth, 1 );
1422
- // LOGW("camerad %d not synced req %d fid %d", cc.camera_num, (int)request_id, (int)frame_id_raw);
1423
- }
1399
+ return processFrame (request_id, buf_idx, frame_id_raw, timestamp);
1424
1400
} else { // not ready
1425
1401
if (frame_id_raw > frame_id_raw_last + 10 ) {
1426
1402
LOGE (" camera %d reset after half second of no response" , cc.camera_num );
@@ -1434,6 +1410,31 @@ bool SpectraCamera::handle_camera_event(const cam_req_mgr_message *event_data) {
1434
1410
return false ;
1435
1411
}
1436
1412
1413
+ bool SpectraCamera::processFrame (uint64_t request_id, int buf_idx, uint64_t frame_id_raw, uint64_t timestamp) {
1414
+ // wait for this frame's EOF, then queue up the next one
1415
+ if (!enqueue_buffer (buf_idx, request_id + ife_buf_depth)) {
1416
+ return false ;
1417
+ }
1418
+
1419
+ if (!syncFirstFrame (cc.camera_num , request_id, frame_id_raw, timestamp)) {
1420
+ return false ;
1421
+ }
1422
+
1423
+ // in IFE_PROCESSED mode, we can't know the true EOF, so recover it with sensor readout time
1424
+ uint64_t timestamp_eof = timestamp + sensor->readout_time_ns ;
1425
+
1426
+ // Update buffer and frame data
1427
+ buf.cur_buf_idx = buf_idx;
1428
+ buf.cur_frame_data = {
1429
+ .frame_id = (uint32_t )(frame_id_raw - camera_sync_data[cc.camera_num ].frame_id_offset ),
1430
+ .request_id = (uint32_t )request_id,
1431
+ .timestamp_sof = timestamp,
1432
+ .timestamp_eof = timestamp_eof,
1433
+ .processing_time = float ((nanos_since_boot () - timestamp_eof) * 1e-9 )};
1434
+
1435
+ return true ;
1436
+ }
1437
+
1437
1438
bool SpectraCamera::syncFirstFrame (int camera_id, uint64_t request_id, uint64_t raw_id, uint64_t timestamp) {
1438
1439
if (first_frame_synced) return true ;
1439
1440
0 commit comments