camerad: properly clean up sync objects after request flush (#34418)

destroy sync objects after re-align
pull/34453/head
Dean Lee 3 months ago committed by GitHub
parent feb9b1cd8d
commit f98c6a7f8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 32
      system/camerad/cameras/spectra.cc
  2. 1
      system/camerad/cameras/spectra.h

@ -258,6 +258,10 @@ int SpectraCamera::clear_req_queue() {
req_mgr_flush_request.flush_type = CAM_REQ_MGR_FLUSH_TYPE_ALL; req_mgr_flush_request.flush_type = CAM_REQ_MGR_FLUSH_TYPE_ALL;
int ret = do_cam_control(m->video0_fd, CAM_REQ_MGR_FLUSH_REQ, &req_mgr_flush_request, sizeof(req_mgr_flush_request)); int ret = do_cam_control(m->video0_fd, CAM_REQ_MGR_FLUSH_REQ, &req_mgr_flush_request, sizeof(req_mgr_flush_request));
// LOGD("flushed all req: %d", ret); // LOGD("flushed all req: %d", ret);
for (int i = 0; i < MAX_IFE_BUFS; ++i) {
destroySyncObjectAt(i);
}
return ret; return ret;
} }
@ -689,16 +693,7 @@ void SpectraCamera::enqueue_buffer(int i, bool dp) {
buf.queue(i); buf.queue(i);
} }
// destroy old output fence destroySyncObjectAt(i);
for (auto so : {sync_objs, sync_objs_bps_out}) {
if (so[i] == 0) continue;
struct cam_sync_info sync_destroy = {0};
sync_destroy.sync_obj = so[i];
ret = do_sync_control(m->cam_sync_fd, CAM_SYNC_DESTROY, &sync_destroy, sizeof(sync_destroy));
if (ret != 0) {
LOGE("failed to destroy sync object: %d %d", ret, sync_destroy.sync_obj);
}
}
} }
// create output fences // create output fences
@ -736,6 +731,23 @@ void SpectraCamera::enqueue_buffer(int i, bool dp) {
config_bps(i, request_id); config_bps(i, request_id);
} }
void SpectraCamera::destroySyncObjectAt(int index) {
auto destroy_sync_obj = [](int cam_sync_fd, int32_t &sync_obj) {
if (sync_obj == 0) return;
struct cam_sync_info sync_destroy = {.sync_obj = sync_obj};
int ret = do_sync_control(cam_sync_fd, CAM_SYNC_DESTROY, &sync_destroy, sizeof(sync_destroy));
if (ret != 0) {
LOGE("Failed to destroy sync object: %d, sync_obj: %d", ret, sync_destroy.sync_obj);
}
sync_obj = 0; // Reset the sync object to 0
};
destroy_sync_obj(m->cam_sync_fd, sync_objs[index]);
destroy_sync_obj(m->cam_sync_fd, sync_objs_bps_out[index]);
}
void SpectraCamera::camera_map_bufs() { void SpectraCamera::camera_map_bufs() {
int ret; int ret;
for (int i = 0; i < ife_buf_depth; i++) { for (int i = 0; i < ife_buf_depth; i++) {

@ -127,6 +127,7 @@ public:
void configICP(); void configICP();
void configCSIPHY(); void configCSIPHY();
void linkDevices(); void linkDevices();
void destroySyncObjectAt(int index);
// *** state *** // *** state ***

Loading…
Cancel
Save