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

Commit 8c3c0852 authored by Jeyaprakash Soundrapandian's avatar Jeyaprakash Soundrapandian Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: reqmgr: Verify the req of two links" into dev/msm-4.14-camx

parents bdb70816 7065a2f8
Loading
Loading
Loading
Loading
+71 −5
Original line number Diff line number Diff line
@@ -910,7 +910,8 @@ static int __cam_req_mgr_check_sync_req_is_ready(
	struct cam_req_mgr_slot *slot)
{
	struct cam_req_mgr_core_link *sync_link = NULL;
	int64_t req_id = 0;
	struct cam_req_mgr_slot *sync_rd_slot = NULL;
	int64_t req_id = 0, sync_req_id = 0;
	int sync_slot_idx = 0, sync_rd_idx = 0, rc = 0;
	int32_t sync_num_slots = 0;
	uint64_t sync_frame_duration = 0;
@@ -924,6 +925,9 @@ static int __cam_req_mgr_check_sync_req_is_ready(
	sync_link = link->sync_link;
	req_id = slot->req_id;
	sync_num_slots = sync_link->req.in_q->num_slots;
	sync_rd_idx = sync_link->req.in_q->rd_idx;
	sync_rd_slot = &sync_link->req.in_q->slot[sync_rd_idx];
	sync_req_id = sync_rd_slot->req_id;

	CAM_DBG(CAM_REQ,
		"link_hdl %x req %lld frame_skip_flag %d ",
@@ -945,7 +949,7 @@ static int __cam_req_mgr_check_sync_req_is_ready(
		sync_frame_duration = DEFAULT_FRAME_DURATION;

	CAM_DBG(CAM_CRM,
		"sync link %x last frame_duration is %d ns",
		"sync link %x last frame duration is %d ns",
		sync_link->link_hdl, sync_frame_duration);

	if (link->initial_skip) {
@@ -1005,12 +1009,11 @@ static int __cam_req_mgr_check_sync_req_is_ready(
		sync_ready = false;
	}

	sync_rd_idx = sync_link->req.in_q->rd_idx;
	if ((sync_link->req.in_q->slot[sync_slot_idx].status !=
		CRM_SLOT_STATUS_REQ_APPLIED) &&
		(((sync_slot_idx - sync_rd_idx + sync_num_slots) %
		sync_num_slots) >= 1) &&
		(sync_link->req.in_q->slot[sync_rd_idx].status !=
		(sync_rd_slot->status !=
		CRM_SLOT_STATUS_REQ_APPLIED)) {
		CAM_DBG(CAM_CRM,
			"Req: %lld [other link] not next req to be applied on link: %x",
@@ -1043,7 +1046,15 @@ static int __cam_req_mgr_check_sync_req_is_ready(
		CAM_DBG(CAM_CRM,
			"Req: %lld ready %d sync_ready %d, ignore sync link next SOF",
			req_id, ready, sync_ready);

		/*
		 * Only skip the frames if current frame sync with
		 * next frame of sync link.
		 */
		if (link->sof_timestamp - sync_link->sof_timestamp >
			sync_frame_duration / 2)
			link->sync_link_sof_skip = true;

		return -EINVAL;
	} else if (ready == false) {
		CAM_DBG(CAM_CRM,
@@ -1052,6 +1063,61 @@ static int __cam_req_mgr_check_sync_req_is_ready(
		return -EINVAL;
	}

	/*
	 * Do the self-correction when the frames are sync,
	 * we consider that the frames are synced if the
	 * difference of two SOF timestamp less than
	 * (sync_frame_duration / 5).
	 */
	if ((link->sof_timestamp > sync_link->sof_timestamp) &&
		(sync_link->sof_timestamp > 0) &&
		(link->sof_timestamp - sync_link->sof_timestamp <
		sync_frame_duration / 5) &&
		(sync_rd_slot->sync_mode == CAM_REQ_MGR_SYNC_MODE_SYNC)) {

		/*
		 * This means current frame should sync with next
		 * frame of sync link, then the request id of in
		 * rd slot of two links should be same.
		 */
		CAM_DBG(CAM_CRM,
			"link %x req_id %lld, sync_link %x req_id %lld",
			link->link_hdl, req_id,
			sync_link->link_hdl, sync_req_id);

		if (req_id > sync_req_id) {
			CAM_DBG(CAM_CRM,
				"link %x too quickly, skip this frame",
				link->link_hdl);
			return -EAGAIN;
		} else if (req_id < sync_req_id) {
			CAM_DBG(CAM_CRM,
				"sync link %x too quickly, skip next frame of sync link",
				sync_link->link_hdl);
			link->sync_link_sof_skip = true;
		}
	} else if ((sync_link->sof_timestamp > 0) &&
		(link->sof_timestamp < sync_link->sof_timestamp) &&
		(sync_link->sof_timestamp - link->sof_timestamp <
		sync_frame_duration / 5) &&
		(sync_rd_slot->sync_mode == CAM_REQ_MGR_SYNC_MODE_SYNC)) {

		/*
		 * There is a timing issue once enter this condition,
		 * it means link receives the SOF event earlier than
		 * sync link in IFE CSID side, but the process in CRM
		 * is sync_link earlier than link, then previous SOF
		 * event of sync link is skipped, so we also need to
		 * skip this SOF event.
		 */
		if (req_id >= sync_req_id) {
			CAM_DBG(CAM_CRM,
				"Timing issue, the sof event of link %x is delayed",
				link->link_hdl);
			return -EAGAIN;
		}
	}

	CAM_DBG(CAM_REQ,
		"Req: %lld ready to apply on link: %x [validation successful]",
		req_id, link->link_hdl);