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

Commit 916a5f56 authored by Alok Pandey's avatar Alok Pandey
Browse files

msm: camera: ife: calculate boot timestamp at csid SOF



This change is to avoid passing zero as boot timestamp for second
SOF onwards. If boot timestamp is not consumed for first SOF, it
will be read as zero at ISP context layer.
With this change, the logic to calculate accurate boot timestamp
is moved at csid core.

Change-Id: Icafd2cd8b9061cc935c977062cce573eb27a2597
Signed-off-by: default avatarAlok Pandey <akumarpa@codeaurora.org>
parent 78333605
Loading
Loading
Loading
Loading
+8 −23
Original line number Original line Diff line number Diff line
@@ -740,23 +740,21 @@ static int __cam_isp_ctx_handle_buf_done_in_activated_state(


static void __cam_isp_ctx_send_sof_boot_timestamp(
static void __cam_isp_ctx_send_sof_boot_timestamp(
	struct cam_isp_context *ctx_isp, uint64_t request_id,
	struct cam_isp_context *ctx_isp, uint64_t request_id,
	uint32_t sof_event_status, uint64_t delta_ts)
	uint32_t sof_event_status)
{
{
	struct cam_req_mgr_message   req_msg;
	struct cam_req_mgr_message   req_msg;


	req_msg.session_hdl = ctx_isp->base->session_hdl;
	req_msg.session_hdl = ctx_isp->base->session_hdl;
	req_msg.u.frame_msg.frame_id = ctx_isp->frame_id;
	req_msg.u.frame_msg.frame_id = ctx_isp->frame_id;
	req_msg.u.frame_msg.request_id = request_id;
	req_msg.u.frame_msg.request_id = request_id;
	req_msg.u.frame_msg.timestamp = ctx_isp->boot_timestamp;
	req_msg.u.frame_msg.link_hdl = ctx_isp->base->link_hdl;
	req_msg.u.frame_msg.link_hdl = ctx_isp->base->link_hdl;
	req_msg.u.frame_msg.sof_status = sof_event_status;
	req_msg.u.frame_msg.sof_status = sof_event_status;


	req_msg.u.frame_msg.timestamp = ctx_isp->prev_boot_timestamp + delta_ts;

	CAM_DBG(CAM_ISP,
	CAM_DBG(CAM_ISP,
		"req id:%lld frame num:%lld bt_ts:0x%llx pre_bt_ts:0x%llx diff:0x%llx",
		"request id:%lld frame number:%lld boot time stamp:0x%llx",
		request_id, ctx_isp->frame_id,
		request_id, ctx_isp->frame_id,
		ctx_isp->boot_timestamp, ctx_isp->prev_boot_timestamp,
		ctx_isp->boot_timestamp);
		delta_ts);




	if (cam_req_mgr_notify_message(&req_msg,
	if (cam_req_mgr_notify_message(&req_msg,
@@ -766,7 +764,6 @@ static void __cam_isp_ctx_send_sof_boot_timestamp(
			"Error in notifying the boot time for req id:%lld",
			"Error in notifying the boot time for req id:%lld",
			request_id);
			request_id);


	ctx_isp->prev_boot_timestamp = req_msg.u.frame_msg.timestamp;
}
}




@@ -775,7 +772,6 @@ static void __cam_isp_ctx_send_sof_timestamp(
	uint32_t sof_event_status)
	uint32_t sof_event_status)
{
{
	struct cam_req_mgr_message   req_msg;
	struct cam_req_mgr_message   req_msg;
	uint64_t delta_ts;


	req_msg.session_hdl = ctx_isp->base->session_hdl;
	req_msg.session_hdl = ctx_isp->base->session_hdl;
	req_msg.u.frame_msg.frame_id = ctx_isp->frame_id;
	req_msg.u.frame_msg.frame_id = ctx_isp->frame_id;
@@ -785,9 +781,9 @@ static void __cam_isp_ctx_send_sof_timestamp(
	req_msg.u.frame_msg.sof_status = sof_event_status;
	req_msg.u.frame_msg.sof_status = sof_event_status;


	CAM_DBG(CAM_ISP,
	CAM_DBG(CAM_ISP,
		"request id:%lld frame number:%lld SOF time stamp:0x%llx, Prev SOF time:0x%llx",
		"request id:%lld frame number:%lld SOF time stamp:0x%llx",
		request_id, ctx_isp->frame_id,
		request_id, ctx_isp->frame_id,
		ctx_isp->sof_timestamp_val, ctx_isp->prev_sof_timestamp_val);
		ctx_isp->sof_timestamp_val);
	CAM_DBG(CAM_ISP, "sof status:%d", sof_event_status);
	CAM_DBG(CAM_ISP, "sof status:%d", sof_event_status);


	if (cam_req_mgr_notify_message(&req_msg,
	if (cam_req_mgr_notify_message(&req_msg,
@@ -795,18 +791,9 @@ static void __cam_isp_ctx_send_sof_timestamp(
		CAM_ERR(CAM_ISP,
		CAM_ERR(CAM_ISP,
			"Error in notifying the sof time for req id:%lld",
			"Error in notifying the sof time for req id:%lld",
			request_id);
			request_id);
	delta_ts = ctx_isp->sof_timestamp_val -
			ctx_isp->prev_sof_timestamp_val;


	__cam_isp_ctx_send_sof_boot_timestamp(ctx_isp,
	__cam_isp_ctx_send_sof_boot_timestamp(ctx_isp,
		request_id, sof_event_status,
		request_id, sof_event_status);
		(ctx_isp->prev_sof_timestamp_val == 0) ?
			ctx_isp->boot_timestamp :
			delta_ts);

	ctx_isp->prev_sof_timestamp_val =
			ctx_isp->sof_timestamp_val;

}
}


static int __cam_isp_ctx_reg_upd_in_epoch_state(
static int __cam_isp_ctx_reg_upd_in_epoch_state(
@@ -3914,8 +3901,6 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
	ctx_isp->req_info.last_applied_time_stamp = 0;
	ctx_isp->req_info.last_applied_time_stamp = 0;
	ctx_isp->req_info.last_bufdone_time_stamp = 0;
	ctx_isp->req_info.last_bufdone_time_stamp = 0;
	ctx_isp->req_info.last_reported_id_time_stamp = 0;
	ctx_isp->req_info.last_reported_id_time_stamp = 0;
	ctx_isp->prev_sof_timestamp_val = 0;
	ctx_isp->prev_boot_timestamp = 0;


	atomic_set(&ctx_isp->process_bubble, 0);
	atomic_set(&ctx_isp->process_bubble, 0);


+0 −4
Original line number Original line Diff line number Diff line
@@ -219,9 +219,7 @@ struct cam_isp_context_event_record {
 * @req_isp:                   ISP private request object storage
 * @req_isp:                   ISP private request object storage
 * @hw_ctx:                    HW object returned by the acquire device command
 * @hw_ctx:                    HW object returned by the acquire device command
 * @sof_timestamp_val:         Captured time stamp value at sof hw event
 * @sof_timestamp_val:         Captured time stamp value at sof hw event
 * @prev_sof_timestamp_val     Holds last notified sof time stamp
 * @boot_timestamp:            Boot time stamp for a given req_id
 * @boot_timestamp:            Boot time stamp for a given req_id
 * @prev_boot_timestamp        Holds last notified boot time stamp
 * @active_req_cnt:            Counter for the active request
 * @active_req_cnt:            Counter for the active request
 * @subscribe_event:           The irq event mask that CRM subscribes to, IFE
 * @subscribe_event:           The irq event mask that CRM subscribes to, IFE
 *                             will invoke CRM cb at those event.
 *                             will invoke CRM cb at those event.
@@ -255,9 +253,7 @@ struct cam_isp_context {


	void                            *hw_ctx;
	void                            *hw_ctx;
	uint64_t                         sof_timestamp_val;
	uint64_t                         sof_timestamp_val;
	uint64_t                         prev_sof_timestamp_val;
	uint64_t                         boot_timestamp;
	uint64_t                         boot_timestamp;
	uint64_t                         prev_boot_timestamp;
	int32_t                          active_req_cnt;
	int32_t                          active_req_cnt;
	uint32_t                         subscribe_event;
	uint32_t                         subscribe_event;
	atomic64_t                       state_monitor_head;
	atomic64_t                       state_monitor_head;
+23 −7
Original line number Original line Diff line number Diff line
@@ -477,7 +477,7 @@ static int cam_ife_csid_global_reset(struct cam_ife_csid_hw *csid_hw)
		CAM_ERR(CAM_ISP, "CSID:%d IRQ value after reset rc = %d",
		CAM_ERR(CAM_ISP, "CSID:%d IRQ value after reset rc = %d",
			csid_hw->hw_intf->hw_idx, val);
			csid_hw->hw_intf->hw_idx, val);
	csid_hw->error_irq_count = 0;
	csid_hw->error_irq_count = 0;
	csid_hw->first_sof_ts = 0;
	csid_hw->prev_boot_timestamp = 0;


	for (i = 0 ; i < CAM_IFE_PIX_PATH_RES_MAX; i++)
	for (i = 0 ; i < CAM_IFE_PIX_PATH_RES_MAX; i++)
		csid_hw->res_sof_cnt[i] = 0;
		csid_hw->res_sof_cnt[i] = 0;
@@ -1178,8 +1178,8 @@ static int cam_ife_csid_disable_hw(struct cam_ife_csid_hw *csid_hw)


	csid_hw->hw_info->hw_state = CAM_HW_STATE_POWER_DOWN;
	csid_hw->hw_info->hw_state = CAM_HW_STATE_POWER_DOWN;
	csid_hw->error_irq_count = 0;
	csid_hw->error_irq_count = 0;
	csid_hw->first_sof_ts = 0;
	csid_hw->fatal_err_detected = false;
	csid_hw->fatal_err_detected = false;
	csid_hw->prev_boot_timestamp = 0;


	return rc;
	return rc;
}
}
@@ -2510,6 +2510,7 @@ static int cam_ife_csid_get_time_stamp(
	const struct cam_ife_csid_rdi_reg_offset   *rdi_reg;
	const struct cam_ife_csid_rdi_reg_offset   *rdi_reg;
	struct timespec64 ts;
	struct timespec64 ts;
	uint32_t  time_32, id;
	uint32_t  time_32, id;
	uint64_t  time_delta;


	time_stamp = (struct cam_csid_get_time_stamp_args  *)cmd_args;
	time_stamp = (struct cam_csid_get_time_stamp_args  *)cmd_args;
	res = time_stamp->node_res;
	res = time_stamp->node_res;
@@ -2563,16 +2564,31 @@ static int cam_ife_csid_get_time_stamp(
		CAM_IFE_CSID_QTIMER_MUL_FACTOR,
		CAM_IFE_CSID_QTIMER_MUL_FACTOR,
		CAM_IFE_CSID_QTIMER_DIV_FACTOR);
		CAM_IFE_CSID_QTIMER_DIV_FACTOR);


	if (!csid_hw->first_sof_ts) {
	if (!csid_hw->prev_boot_timestamp) {
		get_monotonic_boottime64(&ts);
		get_monotonic_boottime64(&ts);
		time_stamp->boot_timestamp =
		time_stamp->boot_timestamp =
			(uint64_t)((ts.tv_sec * 1000000000) +
			(uint64_t)((ts.tv_sec * 1000000000) +
			ts.tv_nsec);
			ts.tv_nsec);
		csid_hw->prev_qtimer_ts = 0;
		CAM_DBG(CAM_ISP, "timestamp:%lld",
		CAM_DBG(CAM_ISP, "timestamp:%lld",
			time_stamp->boot_timestamp);
			time_stamp->boot_timestamp);
		csid_hw->first_sof_ts = 1;
	} else {
	} else
		time_delta = time_stamp->time_stamp_val -
		time_stamp->boot_timestamp = 0;
			csid_hw->prev_qtimer_ts;

		if (csid_hw->prev_boot_timestamp >
			U64_MAX - time_delta) {
			CAM_WARN(CAM_ISP, "boottimestamp reached maximum");
			return -EINVAL;
		}

		time_stamp->boot_timestamp =
			csid_hw->prev_boot_timestamp + time_delta;
	}

	csid_hw->prev_qtimer_ts = time_stamp->time_stamp_val;
	csid_hw->prev_boot_timestamp = time_stamp->boot_timestamp;



	return 0;
	return 0;
}
}
@@ -4187,7 +4203,7 @@ int cam_ife_csid_hw_probe_init(struct cam_hw_intf *csid_hw_intf,


	ife_csid_hw->csid_debug = 0;
	ife_csid_hw->csid_debug = 0;
	ife_csid_hw->error_irq_count = 0;
	ife_csid_hw->error_irq_count = 0;
	ife_csid_hw->first_sof_ts = 0;
	ife_csid_hw->prev_boot_timestamp = 0;
	ife_csid_hw->ipp_path_config.measure_enabled = 0;
	ife_csid_hw->ipp_path_config.measure_enabled = 0;
	ife_csid_hw->ppp_path_config.measure_enabled = 0;
	ife_csid_hw->ppp_path_config.measure_enabled = 0;
	for (i = 0; i <= CAM_IFE_PIX_PATH_RES_RDI_3; i++)
	for (i = 0; i <= CAM_IFE_PIX_PATH_RES_RDI_3; i++)
+4 −2
Original line number Original line Diff line number Diff line
@@ -518,7 +518,8 @@ struct cam_ife_csid_path_cfg {
 * @init_frame_drop           Initial frame drop number
 * @init_frame_drop           Initial frame drop number
 * @res_sof_cnt               path resource sof count value. it used for initial
 * @res_sof_cnt               path resource sof count value. it used for initial
 *                            frame drop
 *                            frame drop
 * @first_sof_ts              flag to mark the first sof has been registered
 * @prev_boot_timestamp       first bootime stamp at the start
 * @prev_qtimer_ts            stores csid timestamp
 * @ppi_hw_intf               interface to ppi hardware
 * @ppi_hw_intf               interface to ppi hardware
 * @ppi_enabled               flag to specify if the hardware has ppi bridge
 * @ppi_enabled               flag to specify if the hardware has ppi bridge
 *                            or not
 *                            or not
@@ -563,7 +564,8 @@ struct cam_ife_csid_hw {
	uint32_t                         dual_usage;
	uint32_t                         dual_usage;
	uint32_t                         init_frame_drop;
	uint32_t                         init_frame_drop;
	uint32_t                         res_sof_cnt[CAM_IFE_PIX_PATH_RES_MAX];
	uint32_t                         res_sof_cnt[CAM_IFE_PIX_PATH_RES_MAX];
	uint32_t                         first_sof_ts;
	uint64_t                         prev_boot_timestamp;
	uint64_t                         prev_qtimer_ts;
	struct cam_hw_intf              *ppi_hw_intf[CAM_CSID_PPI_HW_MAX];
	struct cam_hw_intf              *ppi_hw_intf[CAM_CSID_PPI_HW_MAX];
	bool                             ppi_enable;
	bool                             ppi_enable;
	bool                             fatal_err_detected;
	bool                             fatal_err_detected;