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

Commit 094c3cc9 authored by Om Parkash's avatar Om Parkash Committed by Gerrit - the friendly Code Review server
Browse files

msm:camera: Add Support for Multiple SOF sources



Sensor can stream frames uisng different VC/DT combination
and generating multiple SOFs. Currently in CRM multiple SOFs
are not supported so to handle this case we need to combine
these SOFs and send single SOF to work queue.

Change-Id: I8a831be8296fcf20784bd1d586398c290951390e
Signed-off-by: default avatarOm Parkash <oparkash@codeaurora.org>
parent 80d7a8cc
Loading
Loading
Loading
Loading
+53 −5
Original line number Diff line number Diff line
/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -51,6 +51,7 @@ void cam_req_mgr_core_link_reset(struct cam_req_mgr_core_link *link)
	link->initial_skip = true;
	link->sof_timestamp = 0;
	link->prev_sof_timestamp = 0;
	link->num_sof_src = 0;
}

void cam_req_mgr_handle_core_shutdown(void)
@@ -2491,6 +2492,9 @@ static int cam_req_mgr_cb_notify_trigger(
	struct  cam_req_mgr_core_link    *link = NULL;
	struct  cam_req_mgr_trigger_notify   *notify_trigger;
	struct  crm_task_payload         *task_data;
	bool    send_sof = true;
	int     i = 0;
	int64_t sof_time_diff = 0;

	if (!trigger_data) {
		CAM_ERR(CAM_CRM, "sof_data is NULL");
@@ -2506,6 +2510,44 @@ static int cam_req_mgr_cb_notify_trigger(
		goto end;
	}

	for (i = 0; i < link->num_sof_src; i++) {
		if (link->dev_sof_evt[i].dev_hdl == trigger_data->dev_hdl) {
			if (link->dev_sof_evt[i].sof_done == false) {
				link->dev_sof_evt[i].sof_done = true;
				link->dev_sof_evt[i].frame_id =
						trigger_data->frame_id;
				link->dev_sof_evt[i].timestamp =
					trigger_data->sof_timestamp_val;
			} else
				CAM_INFO(CAM_CRM, "Received Spurious SOF");
		} else if (link->dev_sof_evt[i].sof_done == false) {
			send_sof = false;
		}
	}

	if (!send_sof)
		return 0;
	if (link->num_sof_src > 1) {
		for (i = 0; i < (link->num_sof_src - 1); i++) {
			if (link->dev_sof_evt[i].timestamp >=
				link->dev_sof_evt[i+1].timestamp) {
				sof_time_diff = link->dev_sof_evt[i].timestamp -
					link->dev_sof_evt[i+1].timestamp;
			} else {
				sof_time_diff =
					link->dev_sof_evt[i+1].timestamp -
					link->dev_sof_evt[i].timestamp;
			}
			if ((link->dev_sof_evt[i].frame_id !=
				link->dev_sof_evt[i+1].frame_id) ||
				sof_time_diff > TIMESTAMP_DIFF_THRESHOLD)
				return 0;
		}
	}

	for (i = 0; i < link->num_sof_src; i++)
		link->dev_sof_evt[i].sof_done = false;

	spin_lock_bh(&link->link_state_spin_lock);
	if (link->state < CAM_CRM_LINK_STATE_READY) {
		CAM_WARN(CAM_CRM, "invalid link state:%d", link->state);
@@ -2654,6 +2696,12 @@ static int __cam_req_mgr_setup_link_info(struct cam_req_mgr_core_link *link,

			subscribe_event |= (uint32_t)dev->dev_info.trigger;
		}
		if (dev->dev_info.dev_id == CAM_REQ_MGR_DEVICE_IFE) {
			link->dev_sof_evt[link->num_sof_src].dev_hdl =
				dev->dev_hdl;
			link->dev_sof_evt[link->num_sof_src].sof_done = false;
			link->num_sof_src++;
		}
	}

	link->subscribe_event = subscribe_event;
+17 −1
Original line number Diff line number Diff line
/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -34,6 +34,7 @@

/* Default frame rate is 30 */
#define DEFAULT_FRAME_DURATION 33333333
#define TIMESTAMP_DIFF_THRESHOLD 10000000

#define SYNC_LINK_SOF_CNT_MAX_LMT 1

@@ -286,6 +287,19 @@ struct cam_req_mgr_connected_device {
	void                           *parent;
};

/* *
 * struct cam_req_mgr_ife_sof_evt
 * - Track SOF Events from IFE
 * @ dev_hdl  : device handle
 * @ sof_done : tracks sof for individual IFE
 */
struct cam_req_mgr_dev_sof_evt {
	uint64_t timestamp;
	int32_t  dev_hdl;
	int32_t  frame_id;
	bool     sof_done;
};

/**
 * struct cam_req_mgr_core_link
 * -  Link Properties
@@ -350,6 +364,8 @@ struct cam_req_mgr_core_link {
	bool                                 sync_link_sof_skip;
	int32_t                              open_req_cnt;
	uint32_t                             last_flush_id;
	int32_t                              num_sof_src;
	struct cam_req_mgr_dev_sof_evt       dev_sof_evt[3];
	atomic_t                             is_used;
	bool                                 is_master;
	bool                                 initial_skip;