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

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

msm: camera: Send boot timestamp for SOF event



Currently the SOF timestamp being sent to user space is
derived from qtimer. This change provides provision to
send kernel boot timestamp as well for a given
request_id.

Change-Id: I0735b6bef2221ddad77cbe0b4be0de8a1feec60c
Signed-off-by: default avatarKarthik Anantha Ram <kartanan@codeaurora.org>
parent 0a8a5b89
Loading
Loading
Loading
Loading
+40 −1
Original line number Diff line number Diff line
@@ -447,6 +447,33 @@ static int __cam_isp_ctx_handle_buf_done_in_activated_state(
	return rc;
}

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

	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.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.sof_status = sof_event_status;

	CAM_DBG(CAM_ISP,
		"request id:%lld frame number:%lld boot time stamp:0x%llx",
		 request_id, ctx_isp->frame_id,
		 ctx_isp->boot_timestamp);

	if (cam_req_mgr_notify_message(&req_msg,
		V4L_EVENT_CAM_REQ_MGR_SOF_BOOT_TS,
		V4L_EVENT_CAM_REQ_MGR_EVENT))
		CAM_ERR(CAM_ISP,
			"Error in notifying the boot time for req id:%lld",
			request_id);
}


static void __cam_isp_ctx_send_sof_timestamp(
	struct cam_isp_context *ctx_isp, uint64_t request_id,
	uint32_t sof_event_status)
@@ -471,6 +498,10 @@ static void __cam_isp_ctx_send_sof_timestamp(
		CAM_ERR(CAM_ISP,
			"Error in notifying the sof time for req id:%lld",
			request_id);

	__cam_isp_ctx_send_sof_boot_timestamp(ctx_isp,
		request_id, sof_event_status);

}

static int __cam_isp_ctx_reg_upd_in_activated_state(
@@ -617,6 +648,7 @@ static int __cam_isp_ctx_sof_in_activated_state(

	ctx_isp->frame_id++;
	ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
	ctx_isp->boot_timestamp = sof_event_data->boot_time;
	__cam_isp_ctx_update_state_monitor_array(ctx_isp,
		CAM_ISP_STATE_CHANGE_TRIGGER_SOF, req->request_id);
	CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
@@ -773,6 +805,7 @@ static int __cam_isp_ctx_sof_in_epoch(struct cam_isp_context *ctx_isp,

	ctx_isp->frame_id++;
	ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
	ctx_isp->boot_timestamp = sof_event_data->boot_time;

	if (list_empty(&ctx->active_req_list))
		ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_SOF;
@@ -1045,6 +1078,7 @@ static int __cam_isp_ctx_sof_in_flush(
	}
	ctx_isp->frame_id++;
	ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
	ctx_isp->boot_timestamp = sof_event_data->boot_time;
	CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
		ctx_isp->frame_id, ctx_isp->sof_timestamp_val);

@@ -1470,6 +1504,8 @@ static int __cam_isp_ctx_rdi_only_sof_in_top_state(

	ctx_isp->frame_id++;
	ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
	ctx_isp->boot_timestamp = sof_event_data->boot_time;

	CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
		ctx_isp->frame_id, ctx_isp->sof_timestamp_val);

@@ -1523,6 +1559,7 @@ static int __cam_isp_ctx_rdi_only_sof_in_applied_state(

	ctx_isp->frame_id++;
	ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
	ctx_isp->boot_timestamp = sof_event_data->boot_time;
	CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
		ctx_isp->frame_id, ctx_isp->sof_timestamp_val);

@@ -1554,6 +1591,7 @@ static int __cam_isp_ctx_rdi_only_sof_in_bubble_applied(

	ctx_isp->frame_id++;
	ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
	ctx_isp->boot_timestamp = sof_event_data->boot_time;
	CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
		ctx_isp->frame_id, ctx_isp->sof_timestamp_val);

@@ -1639,6 +1677,7 @@ static int __cam_isp_ctx_rdi_only_sof_in_bubble_state(

	ctx_isp->frame_id++;
	ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
	ctx_isp->boot_timestamp = sof_event_data->boot_time;
	CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
		ctx_isp->frame_id, ctx_isp->sof_timestamp_val);
	/*
+2 −0
Original line number Diff line number Diff line
@@ -149,6 +149,7 @@ struct cam_isp_context_state_monitor {
 * @req_isp:                   ISP private request object storage
 * @hw_ctx:                    HW object returned by the acquire device command
 * @sof_timestamp_val:         Captured time stamp value at sof hw event
 * @boot_timestamp:            Boot time stamp for a given req_id
 * @active_req_cnt:            Counter for the active request
 * @reported_req_id:           Last reported request id
 * @subscribe_event:           The irq event mask that CRM subscribes to, IFE
@@ -174,6 +175,7 @@ struct cam_isp_context {

	void                            *hw_ctx;
	uint64_t                         sof_timestamp_val;
	uint64_t                         boot_timestamp;
	int32_t                          active_req_cnt;
	int64_t                          reported_req_id;
	uint32_t                         subscribe_event;
+10 −4
Original line number Diff line number Diff line
@@ -2675,7 +2675,8 @@ static int cam_ife_mgr_cmd(void *hw_mgr_priv, void *cmd_args)

static int cam_ife_mgr_cmd_get_sof_timestamp(
	struct cam_ife_hw_mgr_ctx      *ife_ctx,
	uint64_t                       *time_stamp)
	uint64_t                       *time_stamp,
	uint64_t                       *boot_time_stamp)
{
	int rc = -EINVAL;
	uint32_t i;
@@ -2704,9 +2705,12 @@ static int cam_ife_mgr_cmd_get_sof_timestamp(
					&csid_get_time,
					sizeof(
					struct cam_csid_get_time_stamp_args));
				if (!rc)
				if (!rc) {
					*time_stamp =
						csid_get_time.time_stamp_val;
					*boot_time_stamp =
						csid_get_time.boot_timestamp;
				}
			/*
			 * Single VFE case, Get the time stamp from available
			 * one csid hw in the context
@@ -3537,7 +3541,8 @@ static int cam_ife_hw_mgr_handle_sof(
				if (!sof_status && !sof_sent) {
					cam_ife_mgr_cmd_get_sof_timestamp(
						ife_hw_mgr_ctx,
						&sof_done_event_data.timestamp);
						&sof_done_event_data.timestamp,
						&sof_done_event_data.boot_time);

					ife_hw_irq_sof_cb(
						ife_hw_mgr_ctx->common.cb_priv,
@@ -3558,7 +3563,8 @@ static int cam_ife_hw_mgr_handle_sof(
			if (!sof_status && !sof_sent) {
				cam_ife_mgr_cmd_get_sof_timestamp(
					ife_hw_mgr_ctx,
					&sof_done_event_data.timestamp);
					&sof_done_event_data.timestamp,
					&sof_done_event_data.boot_time);

				ife_hw_irq_sof_cb(
					ife_hw_mgr_ctx->common.cb_priv,
+3 −1
Original line number Diff line number Diff line
@@ -109,10 +109,12 @@ struct cam_isp_prepare_hw_update_data {
 * struct cam_isp_hw_sof_event_data - Event payload for CAM_HW_EVENT_SOF
 *
 * @timestamp:   Time stamp for the sof event
 * @boot_time:   Boot time stamp for the sof event
 *
 */
struct cam_isp_hw_sof_event_data {
	uint64_t       timestamp;
	uint64_t       boot_time;
};

/**
+5 −0
Original line number Diff line number Diff line
@@ -1904,6 +1904,7 @@ static int cam_ife_csid_get_time_stamp(
	struct cam_ife_csid_reg_offset       *csid_reg;
	struct cam_hw_soc_info               *soc_info;
	struct cam_ife_csid_rdi_reg_offset   *rdi_reg;
	struct timespec64 ts;
	uint32_t  time_32, id;

	time_stamp = (struct cam_csid_get_time_stamp_args  *)cmd_args;
@@ -1952,6 +1953,10 @@ static int cam_ife_csid_get_time_stamp(
		CAM_IFE_CSID_QTIMER_MUL_FACTOR,
		CAM_IFE_CSID_QTIMER_DIV_FACTOR);

	get_monotonic_boottime64(&ts);
	time_stamp->boot_timestamp = (uint64_t)((ts.tv_sec * 1000000000) +
		ts.tv_nsec);

	return 0;
}

Loading