瀏覽代碼

msm: camera: isp: Add support for TS combined VC index

This change enables the timestamp combined vc index,
we can get the VC index of the received frames during
mup mismatch, also print out the timestamp to get the
frame duration info.

CRs-Fixed: 3397057
Change-Id: I433765777043b50dd153efc54070156e812f6200
Signed-off-by: Depeng Shao <[email protected]>
Depeng Shao 2 年之前
父節點
當前提交
3ae6a2abc9

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

@@ -1200,6 +1200,7 @@ static struct cam_ife_csid_ver2_common_reg_info
 	.frame_id_decode_en_shift_val            = 1,
 	.multi_vcdt_vc1_shift_val                = 2,
 	.multi_vcdt_dt1_shift_val                = 7,
+	.multi_vcdt_ts_combo_en_shift_val        = 13,
 	.multi_vcdt_en_shift_val                 = 0,
 	.timestamp_stb_sel_shift_val             = 0,
 	.vfr_en_shift_val                        = 0,
@@ -1211,6 +1212,8 @@ static struct cam_ife_csid_ver2_common_reg_info
 	.early_eof_supported                     = 1,
 	.vfr_supported                           = 1,
 	.multi_vcdt_supported                    = 1,
+	.ts_comb_vcdt_en                         = true,
+	.ts_comb_vcdt_mask                       = 3,
 	.frame_id_dec_supported                  = 1,
 	.measure_en_hbi_vbi_cnt_mask             = 0x1c,
 	.measure_pixel_line_en_mask              = 0x3,

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

@@ -1286,6 +1286,7 @@ static struct cam_ife_csid_ver2_common_reg_info
 	.frame_id_decode_en_shift_val            = 1,
 	.multi_vcdt_vc1_shift_val                = 2,
 	.multi_vcdt_dt1_shift_val                = 7,
+	.multi_vcdt_ts_combo_en_shift_val        = 13,
 	.multi_vcdt_en_shift_val                 = 0,
 	.timestamp_stb_sel_shift_val             = 8,
 	.vfr_en_shift_val                        = 0,
@@ -1300,6 +1301,8 @@ static struct cam_ife_csid_ver2_common_reg_info
 	.early_eof_supported                     = 1,
 	.vfr_supported                           = 1,
 	.multi_vcdt_supported                    = 1,
+	.ts_comb_vcdt_en                         = true,
+	.ts_comb_vcdt_mask                       = 3,
 	.frame_id_dec_supported                  = 1,
 	.measure_en_hbi_vbi_cnt_mask             = 0xc,
 	.measure_pixel_line_en_mask              = 0x3,

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

@@ -1317,6 +1317,7 @@ static struct cam_ife_csid_ver2_common_reg_info
 	.frame_id_decode_en_shift_val            = 1,
 	.multi_vcdt_vc1_shift_val                = 2,
 	.multi_vcdt_dt1_shift_val                = 7,
+	.multi_vcdt_ts_combo_en_shift_val        = 13,
 	.multi_vcdt_en_shift_val                 = 0,
 	.timestamp_stb_sel_shift_val             = 8,
 	.vfr_en_shift_val                        = 0,
@@ -1331,6 +1332,8 @@ static struct cam_ife_csid_ver2_common_reg_info
 	.early_eof_supported                     = 1,
 	.vfr_supported                           = 1,
 	.multi_vcdt_supported                    = 1,
+	.ts_comb_vcdt_en                         = true,
+	.ts_comb_vcdt_mask                       = 3,
 	.frame_id_dec_supported                  = 1,
 	.measure_en_hbi_vbi_cnt_mask             = 0xc,
 	.measure_pixel_line_en_mask              = 0x3,

+ 68 - 16
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver2.c

@@ -1499,26 +1499,54 @@ void cam_ife_csid_hw_ver2_drv_err_handler(void *csid)
 void cam_ife_csid_hw_ver2_mup_mismatch_handler(
 	void *csid, void *resource)
 {
+	uint32_t                           idx = 0;
+	struct timespec64                  current_ts;
 	struct cam_ife_csid_ver2_hw       *csid_hw = csid;
-        struct cam_isp_resource_node      *res = resource;
+	struct cam_isp_resource_node      *res = resource;
 	struct cam_ife_csid_ver2_path_cfg *path_cfg =
 		(struct cam_ife_csid_ver2_path_cfg *)res->res_priv;
 	struct cam_ife_csid_cid_data      *cid_data = &csid_hw->cid_data[path_cfg->cid];
+	struct cam_hw_soc_info            *soc_info = &csid_hw->hw_info->soc_info;
+	struct cam_ife_csid_ver2_reg_info *csid_reg = NULL;
+	const struct cam_ife_csid_ver2_path_reg_info *path_reg = NULL;
 
 	CAM_INFO(CAM_ISP, "CSID:%u Last MUP value 0x%x programmed for res [id: %d name: %s]",
 		csid_hw->hw_intf->hw_idx, csid_hw->rx_cfg.mup, res->res_id, res->res_name);
 
+	csid_reg = (struct cam_ife_csid_ver2_reg_info *)
+			csid_hw->core_info->csid_reg;
+	path_reg = csid_reg->path_reg[res->res_id];
+
 	if (cid_data->vc_dt[CAM_IFE_CSID_MULTI_VC_DT_GRP_1].valid) {
 		CAM_INFO(CAM_ISP, "CSID:%u vc0 %d vc1 %d",
 			csid_hw->hw_intf->hw_idx,
 			cid_data->vc_dt[CAM_IFE_CSID_MULTI_VC_DT_GRP_0].vc,
 			cid_data->vc_dt[CAM_IFE_CSID_MULTI_VC_DT_GRP_1].vc);
+
+		if (path_cfg->ts_comb_vcdt_en) {
+			ktime_get_boottime_ts64(&current_ts);
+
+			idx = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+				path_reg->timestamp_curr0_sof_addr) &
+				csid_reg->cmn_reg->ts_comb_vcdt_mask;
+
+			if (idx < CAM_IFE_CSID_MULTI_VC_DT_GRP_MAX)
+				CAM_INFO(CAM_ISP,
+					"CSID:%d Received frame with vc:%d on [id: %d name: %s] timestamp: %lld.%09lld",
+					csid_hw->hw_intf->hw_idx, cid_data->vc_dt[idx].vc,
+					res->res_id, res->res_name, current_ts.tv_sec,
+					current_ts.tv_nsec);
+			else
+				CAM_ERR(CAM_ISP,
+					"CSID:%d Get invalid vc index: %d on [id: %d name: %s] timestamp: %lld.%09lld",
+					csid_hw->hw_intf->hw_idx, idx, res->res_id,
+					res->res_name, current_ts.tv_sec, current_ts.tv_nsec);
+		}
 	} else {
 		CAM_ERR(CAM_ISP, "CSID:%u Multi-VCDT is not enabled, vc0 %d",
 			csid_hw->hw_intf->hw_idx,
 			cid_data->vc_dt[CAM_IFE_CSID_MULTI_VC_DT_GRP_0].vc);
 	}
-
 }
 
 void cam_ife_csid_ver2_print_illegal_programming_irq_status(
@@ -3376,6 +3404,8 @@ static int cam_ife_csid_ver2_init_config_rdi_path(
 	CAM_DBG(CAM_ISP, "CSID[%u] %s cfg0_addr 0x%x",
 		csid_hw->hw_intf->hw_idx, res->res_name, cfg0);
 
+	path_cfg->ts_comb_vcdt_en = false;
+
 	/*Configure Multi VC DT combo */
 	if (cid_data->vc_dt[CAM_IFE_CSID_MULTI_VC_DT_GRP_1].valid) {
 		val = (cid_data->vc_dt[CAM_IFE_CSID_MULTI_VC_DT_GRP_1].vc <<
@@ -3384,9 +3414,14 @@ static int cam_ife_csid_ver2_init_config_rdi_path(
 				 cmn_reg->multi_vcdt_dt1_shift_val) |
 			(1 << cmn_reg->multi_vcdt_en_shift_val);
 
-		if (csid_reg->cmn_reg->decode_format1_supported)
+		if (cmn_reg->ts_comb_vcdt_en) {
+			val |= (1 << cmn_reg->multi_vcdt_ts_combo_en_shift_val);
+			path_cfg->ts_comb_vcdt_en = true;
+		}
+
+		if (cmn_reg->decode_format1_supported)
 			val |= (path_cfg->path_format[CAM_IFE_CSID_MULTI_VC_DT_GRP_1].decode_fmt <<
-				csid_reg->cmn_reg->decode_format1_shift_val);
+				cmn_reg->decode_format1_shift_val);
 
 		cam_io_w_mb(val, mem_base + path_reg->multi_vcdt_cfg0_addr);
 		CAM_DBG(CAM_ISP, "CSID:%u RDI:%u multi_vcdt_cfg0:0x%x",
@@ -3462,7 +3497,7 @@ static int cam_ife_csid_ver2_init_config_rdi_path(
 		CAM_IFE_CSID_DEBUG_ENABLE_HBI_VBI_INFO) {
 		val = cam_io_r_mb(mem_base +
 			path_reg->format_measure_cfg0_addr);
-		val |= csid_reg->cmn_reg->measure_en_hbi_vbi_cnt_mask;
+		val |= cmn_reg->measure_en_hbi_vbi_cnt_mask;
 		cam_io_w_mb(val, mem_base +
 			path_reg->format_measure_cfg0_addr);
 	}
@@ -3539,6 +3574,8 @@ static int cam_ife_csid_ver2_init_config_pxl_path(
 
 	cam_io_w_mb(cfg0, mem_base + path_reg->cfg0_addr);
 
+	path_cfg->ts_comb_vcdt_en = false;
+
 	/*Configure Multi VC DT combo */
 	if (cid_data->vc_dt[CAM_IFE_CSID_MULTI_VC_DT_GRP_1].valid) {
 		val = (cid_data->vc_dt[CAM_IFE_CSID_MULTI_VC_DT_GRP_1].vc <<
@@ -3547,9 +3584,14 @@ static int cam_ife_csid_ver2_init_config_pxl_path(
 				 cmn_reg->multi_vcdt_dt1_shift_val) |
 			(1 << cmn_reg->multi_vcdt_en_shift_val);
 
-		if(csid_reg->cmn_reg->decode_format1_supported)
+		if (cmn_reg->ts_comb_vcdt_en) {
+			val |= (1 << cmn_reg->multi_vcdt_ts_combo_en_shift_val);
+			path_cfg->ts_comb_vcdt_en = true;
+		}
+
+		if (cmn_reg->decode_format1_supported)
 			val |= (path_cfg->path_format[CAM_IFE_CSID_MULTI_VC_DT_GRP_1].decode_fmt <<
-				csid_reg->cmn_reg->decode_format1_shift_val);
+				cmn_reg->decode_format1_shift_val);
 
 		cam_io_w_mb(val, mem_base + path_reg->multi_vcdt_cfg0_addr);
 	}
@@ -5597,13 +5639,17 @@ static int cam_ife_csid_ver2_program_offline_go_cmd(
 	return 0;
 }
 
-static uint64_t __cam_ife_csid_ver2_get_time_stamp(void __iomem *mem_base, uint32_t timestamp0_addr,
-	uint32_t timestamp1_addr)
+static uint64_t __cam_ife_csid_ver2_get_time_stamp(void __iomem *mem_base,
+	uint32_t timestamp0_addr, uint32_t timestamp1_addr,
+	bool ts_comb_vcdt_en, uint32_t ts_comb_vcdt_mask)
 {
 	uint64_t timestamp_val, time_hi, time_lo;
 
 	time_hi = cam_io_r_mb(mem_base + timestamp1_addr);
 	time_lo = cam_io_r_mb(mem_base + timestamp0_addr);
+	if (ts_comb_vcdt_en)
+		time_lo &= ~ts_comb_vcdt_mask;
+
 	timestamp_val = (time_hi << 32) | time_lo;
 
 	return mul_u64_u32_div(timestamp_val,
@@ -5615,11 +5661,12 @@ static int cam_ife_csid_ver2_get_time_stamp(
 	struct cam_ife_csid_ver2_hw  *csid_hw, void *cmd_args)
 {
 	const struct cam_ife_csid_ver2_path_reg_info *path_reg;
-	struct cam_isp_resource_node         *res = NULL;
-	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;
-	struct timespec64 ts;
+	struct cam_isp_resource_node                 *res = NULL;
+	struct cam_ife_csid_ver2_path_cfg            *path_cfg = NULL;
+	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;
+	struct timespec64                             ts;
 
 	timestamp_args = (struct cam_csid_get_time_stamp_args *)cmd_args;
 	res = timestamp_args->node_res;
@@ -5642,6 +5689,7 @@ static int cam_ife_csid_ver2_get_time_stamp(
 		return -EINVAL;
 	}
 
+	path_cfg = (struct cam_ife_csid_ver2_path_cfg *)res->res_priv;
 	path_reg = csid_reg->path_reg[res->res_id];
 
 	if (!path_reg) {
@@ -5654,13 +5702,17 @@ static int cam_ife_csid_ver2_get_time_stamp(
 		timestamp_args->prev_time_stamp_val = __cam_ife_csid_ver2_get_time_stamp(
 			soc_info->reg_map[0].mem_base,
 			path_reg->timestamp_perv0_sof_addr,
-			path_reg->timestamp_perv1_sof_addr);
+			path_reg->timestamp_perv1_sof_addr,
+			path_cfg->ts_comb_vcdt_en,
+			csid_reg->cmn_reg->ts_comb_vcdt_mask);
 	}
 
 	timestamp_args->time_stamp_val = __cam_ife_csid_ver2_get_time_stamp(
 		soc_info->reg_map[0].mem_base,
 		path_reg->timestamp_curr0_sof_addr,
-		path_reg->timestamp_curr1_sof_addr);
+		path_reg->timestamp_curr1_sof_addr,
+		path_cfg->ts_comb_vcdt_en,
+		csid_reg->cmn_reg->ts_comb_vcdt_mask);
 
 	if (qtime_to_boottime == 0) {
 		ktime_get_boottime_ts64(&ts);

+ 6 - 2
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver2.h

@@ -179,6 +179,7 @@ struct cam_ife_csid_ver2_camif_data {
  *                          the corresponding paths
  * @sfe_shdr:               flag to indicate if sfe is inline shdr
  * @lcr_en:                 Flag to indicate if path is part can be input to LCR
+ * @ts_comb_vcdt_en:        Indicates if Timestamp combined vcdt flag is enabled
  *
  */
 struct cam_ife_csid_ver2_path_cfg {
@@ -224,6 +225,7 @@ struct cam_ife_csid_ver2_path_cfg {
 	bool                                 lcr_en;
 	bool                                 csid_out_unpack_msb;
 	bool                                 handle_camif_irq;
+	bool                                 ts_comb_vcdt_en;
 };
 
 struct cam_ife_csid_ver2_top_reg_info {
@@ -296,7 +298,7 @@ struct cam_ife_csid_ver2_path_reg_info {
 	uint32_t timestamp_curr1_eof_addr;
 	uint32_t timestamp_perv0_eof_addr;
 	uint32_t timestamp_perv1_eof_addr;
-        uint32_t lut_bank_cfg_addr;
+	uint32_t lut_bank_cfg_addr;
 	uint32_t batch_id_cfg0_addr;
 	uint32_t batch_id_cfg1_addr;
 	uint32_t batch_period_cfg_addr;
@@ -335,7 +337,7 @@ struct cam_ife_csid_ver2_path_reg_info {
 	uint32_t crop_h_en_shift_val;
 	uint32_t drop_v_en_shift_val;
 	uint32_t drop_h_en_shift_val;
-        uint32_t pix_store_en_shift_val;
+	uint32_t pix_store_en_shift_val;
 	uint32_t early_eof_en_shift_val;
 	uint32_t bin_h_en_shift_val;
 	uint32_t bin_v_en_shift_val;
@@ -497,10 +499,12 @@ struct cam_ife_csid_ver2_common_reg_info {
 	uint32_t phy_sel_base_idx;
 	bool     timestamp_enabled_in_cfg0;
 	bool     camif_irq_support;
+	bool     ts_comb_vcdt_en;
 	uint32_t drv_rup_en_val_map[CAM_IFE_PIX_PATH_RES_MAX];
 	uint32_t drv_path_idle_en_val_map[CAM_ISP_MAX_PATHS];
 
 	/* Masks */
+	uint32_t ts_comb_vcdt_mask;
 	uint32_t pxl_cnt_mask;
 	uint32_t line_cnt_mask;
 	uint32_t hblank_max_mask;

+ 4 - 1
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite680.h

@@ -1,7 +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.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef _CAM_IFE_CSID_LITE_680_H_
@@ -391,12 +391,15 @@ static struct cam_ife_csid_ver2_common_reg_info
 	.frame_id_decode_en_shift_val                 = 1,
 	.multi_vcdt_vc1_shift_val                     = 2,
 	.multi_vcdt_dt1_shift_val                     = 7,
+	.multi_vcdt_ts_combo_en_shift_val             = 13,
 	.multi_vcdt_en_shift_val                      = 0,
 	.timestamp_stb_sel_shift_val                  = 0,
 	.vfr_en_shift_val                             = 0,
 	.early_eof_supported                          = 1,
 	.vfr_supported                                = 1,
 	.multi_vcdt_supported                         = 1,
+	.ts_comb_vcdt_en                              = true,
+	.ts_comb_vcdt_mask                            = 3,
 	.frame_id_dec_supported                       = 1,
 	.measure_en_hbi_vbi_cnt_mask                  = 0xc,
 	.measure_pixel_line_en_mask                   = 0x3,

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

@@ -427,12 +427,15 @@ static struct cam_ife_csid_ver2_common_reg_info
 	.frame_id_decode_en_shift_val                 = 1,
 	.multi_vcdt_vc1_shift_val                     = 2,
 	.multi_vcdt_dt1_shift_val                     = 7,
+	.multi_vcdt_ts_combo_en_shift_val             = 13,
 	.multi_vcdt_en_shift_val                      = 0,
 	.timestamp_stb_sel_shift_val                  = 8,
 	.vfr_en_shift_val                             = 0,
 	.early_eof_supported                          = 1,
 	.vfr_supported                                = 1,
 	.multi_vcdt_supported                         = 1,
+	.ts_comb_vcdt_en                              = true,
+	.ts_comb_vcdt_mask                            = 3,
 	.frame_id_dec_supported                       = 1,
 	.measure_en_hbi_vbi_cnt_mask                  = 0xc,
 	.measure_pixel_line_en_mask                   = 0x3,

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

@@ -436,12 +436,15 @@ static struct cam_ife_csid_ver2_common_reg_info
 	.frame_id_decode_en_shift_val                 = 1,
 	.multi_vcdt_vc1_shift_val                     = 2,
 	.multi_vcdt_dt1_shift_val                     = 7,
+	.multi_vcdt_ts_combo_en_shift_val             = 13,
 	.multi_vcdt_en_shift_val                      = 0,
 	.timestamp_stb_sel_shift_val                  = 8,
 	.vfr_en_shift_val                             = 0,
 	.early_eof_supported                          = 1,
 	.vfr_supported                                = 1,
 	.multi_vcdt_supported                         = 1,
+	.ts_comb_vcdt_en                              = true,
+	.ts_comb_vcdt_mask                            = 3,
 	.frame_id_dec_supported                       = 1,
 	.measure_en_hbi_vbi_cnt_mask                  = 0xc,
 	.measure_pixel_line_en_mask                   = 0x3,