Răsfoiți Sursa

msm: camera: ife: use universal qtime-to-boottime offset for all cams

Modify IFE timestamp calculation to use a single qtime-to-boottime offset
value for all cameras. This will allow more precise timestamp comparison
between cameras.

CRs-Fixed: 3050973
Change-Id: Ic16864f544ad88e0215ae4d05a077d874af78fe9
Signed-off-by: Li Sha Lim <[email protected]>
Li Sha Lim 3 ani în urmă
părinte
comite
d30d360635

+ 4 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_common.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/iopoll.h>
@@ -24,6 +25,9 @@
 #include "cam_ife_csid_hw_ver2.h"
 #include "cam_cdm_intf_api.h"
 
+/* factor to conver qtime to boottime */
+int64_t qtime_to_boottime;
+
 const uint8_t *cam_ife_csid_irq_reg_tag[CAM_IFE_CSID_IRQ_REG_MAX] = {
 	"TOP",
 	"RX",

+ 3 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_common.h

@@ -73,6 +73,9 @@
 
 #define CAM_IFE_CSID_WIDTH_FUSE_VAL_MAX			  4
 
+/* factor to conver qtime to boottime */
+extern int64_t qtime_to_boottime;
+
 /* enum for multiple mem base in some of the targets */
 enum cam_ife_csid_mem_base_id {
 	CAM_IFE_CSID_CLC_MEM_BASE_ID,

+ 5 - 10
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver1.c

@@ -3430,7 +3430,6 @@ static int cam_ife_csid_ver1_get_time_stamp(
 	struct cam_hw_soc_info              *soc_info;
 	struct cam_csid_get_time_stamp_args *timestamp_args;
 	struct cam_ife_csid_ver1_reg_info *csid_reg;
-	uint64_t  time_delta;
 	struct timespec64 ts;
 	uint32_t curr_0_sof_addr, curr_1_sof_addr;
 
@@ -3493,19 +3492,15 @@ static int cam_ife_csid_ver1_get_time_stamp(
 		CAM_IFE_CSID_QTIMER_MUL_FACTOR,
 		CAM_IFE_CSID_QTIMER_DIV_FACTOR);
 
-	time_delta = timestamp_args->time_stamp_val -
-		csid_hw->timestamp.prev_sof_ts;
-
-	if (!csid_hw->timestamp.prev_boot_ts) {
+	if (qtime_to_boottime == 0) {
 		ktime_get_boottime_ts64(&ts);
-		timestamp_args->boot_timestamp =
+		qtime_to_boottime =
 			(uint64_t)((ts.tv_sec * 1000000000) +
-			ts.tv_nsec);
-	} else {
-		timestamp_args->boot_timestamp =
-			csid_hw->timestamp.prev_boot_ts + time_delta;
+			ts.tv_nsec) - (int64_t)timestamp_args->time_stamp_val;
 	}
 
+	timestamp_args->boot_timestamp = timestamp_args->time_stamp_val +
+		qtime_to_boottime;
 	CAM_DBG(CAM_ISP, "timestamp:%lld",
 		timestamp_args->boot_timestamp);
 	csid_hw->timestamp.prev_sof_ts = timestamp_args->time_stamp_val;

+ 5 - 10
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver2.c

@@ -4837,7 +4837,6 @@ static int cam_ife_csid_ver2_get_time_stamp(
 	struct cam_hw_soc_info              *soc_info;
 	struct cam_csid_get_time_stamp_args *timestamp_args;
 	struct cam_ife_csid_ver2_reg_info *csid_reg;
-	uint64_t  time_delta;
 	struct timespec64 ts;
 
 	timestamp_args = (struct cam_csid_get_time_stamp_args *)cmd_args;
@@ -4881,19 +4880,15 @@ static int cam_ife_csid_ver2_get_time_stamp(
 		path_reg->timestamp_curr0_sof_addr,
 		path_reg->timestamp_curr1_sof_addr);
 
-	time_delta = timestamp_args->time_stamp_val -
-		csid_hw->timestamp.prev_sof_ts;
-
-	if (!csid_hw->timestamp.prev_boot_ts) {
+	if (qtime_to_boottime == 0) {
 		ktime_get_boottime_ts64(&ts);
-		timestamp_args->boot_timestamp =
+		qtime_to_boottime =
 			(uint64_t)((ts.tv_sec * 1000000000) +
-			ts.tv_nsec);
-	} else {
-		timestamp_args->boot_timestamp =
-			csid_hw->timestamp.prev_boot_ts + time_delta;
+			ts.tv_nsec) - (int64_t)timestamp_args->time_stamp_val;
 	}
 
+	timestamp_args->boot_timestamp = timestamp_args->time_stamp_val +
+		qtime_to_boottime;
 	CAM_DBG(CAM_ISP, "Resource[id:%d name:%s timestamp:%lld]",
 		res->res_id, res->res_name, timestamp_args->boot_timestamp);
 	csid_hw->timestamp.prev_sof_ts = timestamp_args->time_stamp_val;