Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0e068b5 authored by Karthik Anantha Ram's avatar Karthik Anantha Ram Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: reqmgr: Update frame sync logic for dual camera



Currently kernel frame sync expects that SOF's from one sensor
will always lead with respect to the other. This change removes
this dependency, but at the same time it is tightly bound with
HW frame sync. Also if a packet from a node is not available at
a given SOF for a particular link we will skip that frame and as
well as the corresponding frame in the sync link to ensure we
output matching frames on both links.

Change-Id: I5aad699302c163d75878b139ab8f079f8370886e
Signed-off-by: default avatarKarthik Anantha Ram <kartanan@codeaurora.org>
parent 4097ccbb
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -659,7 +659,7 @@ static int __cam_req_mgr_validate_sof_cnt(
		link->link_hdl, link->sof_counter,
		sync_link->sof_counter, sync_diff, link->sync_self_ref);

	if (sync_diff != link->sync_self_ref) {
	if (sync_diff > SYNC_LINK_SOF_CNT_MAX_LMT) {
		link->sync_link->frame_skip_flag = true;
		CAM_WARN(CAM_CRM,
			"Detected anomaly, skip link_hdl %x self_counter=%lld other_counter=%lld sync_self_ref=%lld",
@@ -703,6 +703,14 @@ static int __cam_req_mgr_process_sync_req(
		link->link_hdl, req_id, link->sync_self_ref, link->sof_counter,
		link->frame_skip_flag, link->sync_link->sync_self_ref);

	if (sync_link->sync_link_sof_skip) {
		CAM_DBG(CAM_CRM,
			"No req applied on corresponding SOF on sync link: %x",
			sync_link->link_hdl);
		sync_link->sync_link_sof_skip = false;
		return -EINVAL;
	}

	if (link->sof_counter == -1) {
		__cam_req_mgr_sof_cnt_initialize(link);
	} else if ((link->frame_skip_flag) &&
@@ -720,6 +728,7 @@ static int __cam_req_mgr_process_sync_req(
		CAM_DBG(CAM_CRM,
			"Req: %lld [My link]not available link: %x, rc=%d",
			req_id, link->link_hdl, rc);
		link->sync_link_sof_skip = true;
		goto failure;
	}

@@ -768,6 +777,7 @@ static int __cam_req_mgr_process_sync_req(
			"Req: %lld [Other link] not ready to apply on link: %x",
			req_id, sync_link->link_hdl);
		rc = -EPERM;
		link->sync_link_sof_skip = true;
		goto failure;
	}

@@ -884,6 +894,9 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link,
		}
		spin_unlock_bh(&link->link_state_spin_lock);

		if (link->sync_link_sof_skip)
			link->sync_link_sof_skip = false;

		if (link->trigger_mask == link->subscribe_event) {
			slot->status = CRM_SLOT_STATUS_REQ_APPLIED;
			link->trigger_mask = 0;
@@ -2514,11 +2527,13 @@ int cam_req_mgr_sync_config(
	link1->sof_counter = -1;
	link1->sync_self_ref = -1;
	link1->frame_skip_flag = false;
	link1->sync_link_sof_skip = false;
	link1->sync_link = link2;

	link2->sof_counter = -1;
	link2->sync_self_ref = -1;
	link2->frame_skip_flag = false;
	link2->sync_link_sof_skip = false;
	link2->sync_link = link1;

	cam_session->sync_mode = sync_info->sync_mode;
+6 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@

#define MAX_SYNC_COUNT 65535

#define SYNC_LINK_SOF_CNT_MAX_LMT 1

/**
 * enum crm_workq_task_type
 * @codes: to identify which type of task is present
@@ -296,6 +298,9 @@ struct cam_req_mgr_connected_device {
 * @sync_self_ref        : reference sync count against which the difference
 *                         between sync_counts for a given link is checked
 * @frame_skip_flag      : flag that determines if a frame needs to be skipped
 * @sync_link_sof_skip   : flag determines if a pkt is not available for a given
 *                         frame in a particular link skip corresponding
 *                         frame in sync link as well.
 *
 */
struct cam_req_mgr_core_link {
@@ -318,6 +323,7 @@ struct cam_req_mgr_core_link {
	int64_t                              sof_counter;
	int64_t                              sync_self_ref;
	bool                                 frame_skip_flag;
	bool                                 sync_link_sof_skip;
};

/**