Forráskód Böngészése

msm: camera: ife: Add support for RDI crop in dual IFE

This change adds support for RDI crop in dual IFE usecases. The
crop window for RDI is obtained by combining left and right IFE
crop windows and width is calculated based on the crop window.
If crop or drop is needed on RDI, decode format should not be
programmed as payload only in order to enable RPP subpath.

CRs-Fixed: 2513939
Change-Id: Iaaf64784372ef918802a684b33e16845fd7d2b3b
Signed-off-by: Venkat Chinta <[email protected]>
Venkat Chinta 5 éve
szülő
commit
184ed6286f

+ 3 - 4
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -2028,7 +2028,6 @@ static int cam_ife_hw_mgr_acquire_res_ife_csid_rdi(
 		csid_acquire.cid = cid_res->hw_res[0]->res_id;
 		csid_acquire.in_port = in_port;
 		csid_acquire.out_port = out_port;
-		csid_acquire.sync_mode = CAM_ISP_HW_SYNC_NONE;
 		csid_acquire.node_res = NULL;
 
 		/*
@@ -2036,12 +2035,12 @@ static int cam_ife_hw_mgr_acquire_res_ife_csid_rdi(
 		 * ver 480 HW to allow userspace to control pixel drop pattern.
 		 */
 		csid_acquire.drop_enable = true;
+		csid_acquire.crop_enable = true;
 
-		/* Enable RDI crop for single ife use case only */
 		if (in_port->usage_type)
-			csid_acquire.crop_enable = false;
+			csid_acquire.sync_mode = CAM_ISP_HW_SYNC_MASTER;
 		else
-			csid_acquire.crop_enable = true;
+			csid_acquire.sync_mode = CAM_ISP_HW_SYNC_NONE;
 
 		hw_intf = cid_res->hw_res[0]->hw_intf;
 		rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,

+ 1 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid175_200.h

@@ -331,6 +331,7 @@ static struct cam_ife_csid_common_reg_offset
 	.path_rst_stb_all                             = 0x7f,
 	.path_rst_done_shift_val                      = 1,
 	.path_en_shift_val                            = 31,
+	.packing_fmt_shift_val                        = 30,
 	.dt_id_shift_val                              = 27,
 	.vc_shift_val                                 = 22,
 	.dt_shift_val                                 = 16,

+ 1 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid480.h

@@ -349,6 +349,7 @@ static struct cam_ife_csid_common_reg_offset
 	.path_rst_stb_all                             = 0x7f,
 	.path_rst_done_shift_val                      = 1,
 	.path_en_shift_val                            = 31,
+	.packing_fmt_shift_val                        = 30,
 	.dt_id_shift_val                              = 27,
 	.vc_shift_val                                 = 22,
 	.dt_shift_val                                 = 16,

+ 76 - 32
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c

@@ -72,8 +72,8 @@ static int cam_ife_csid_is_ipp_ppp_format_supported(
 }
 
 static int cam_ife_csid_get_format_rdi(
-	uint32_t in_format, uint32_t out_format,
-	uint32_t *decode_fmt, uint32_t *plain_fmt)
+	uint32_t in_format, uint32_t out_format, uint32_t *decode_fmt,
+	uint32_t *plain_fmt, uint32_t *packing_fmt, bool rpp)
 {
 	int rc = 0;
 
@@ -82,6 +82,10 @@ static int cam_ife_csid_get_format_rdi(
 		switch (out_format) {
 		case CAM_FORMAT_MIPI_RAW_6:
 			*decode_fmt = 0xf;
+			if (rpp) {
+				*decode_fmt = 0x0;
+				*packing_fmt = 0x1;
+			}
 			break;
 		case CAM_FORMAT_PLAIN8:
 			*decode_fmt = 0x0;
@@ -97,6 +101,10 @@ static int cam_ife_csid_get_format_rdi(
 		case CAM_FORMAT_MIPI_RAW_8:
 		case CAM_FORMAT_PLAIN128:
 			*decode_fmt = 0xf;
+			if (rpp) {
+				*decode_fmt = 0x1;
+				*packing_fmt = 0x1;
+			}
 			break;
 		case CAM_FORMAT_PLAIN8:
 			*decode_fmt = 0x1;
@@ -112,6 +120,10 @@ static int cam_ife_csid_get_format_rdi(
 		case CAM_FORMAT_MIPI_RAW_10:
 		case CAM_FORMAT_PLAIN128:
 			*decode_fmt = 0xf;
+			if (rpp) {
+				*decode_fmt = 0x2;
+				*packing_fmt = 0x1;
+			}
 			break;
 		case CAM_FORMAT_PLAIN16_10:
 			*decode_fmt = 0x2;
@@ -126,6 +138,10 @@ static int cam_ife_csid_get_format_rdi(
 		switch (out_format) {
 		case CAM_FORMAT_MIPI_RAW_12:
 			*decode_fmt = 0xf;
+			if (rpp) {
+				*decode_fmt = 0x3;
+				*packing_fmt = 0x1;
+			}
 			break;
 		case CAM_FORMAT_PLAIN16_12:
 			*decode_fmt = 0x3;
@@ -140,6 +156,10 @@ static int cam_ife_csid_get_format_rdi(
 		switch (out_format) {
 		case CAM_FORMAT_MIPI_RAW_14:
 			*decode_fmt = 0xf;
+			if (rpp) {
+				*decode_fmt = 0x4;
+				*packing_fmt = 0x1;
+			}
 			break;
 		case CAM_FORMAT_PLAIN16_14:
 			*decode_fmt = 0x4;
@@ -154,6 +174,10 @@ static int cam_ife_csid_get_format_rdi(
 		switch (out_format) {
 		case CAM_FORMAT_MIPI_RAW_16:
 			*decode_fmt = 0xf;
+			if (rpp) {
+				*decode_fmt = 0x5;
+				*packing_fmt = 0x1;
+			}
 			break;
 		case CAM_FORMAT_PLAIN16_16:
 			*decode_fmt = 0x5;
@@ -168,6 +192,10 @@ static int cam_ife_csid_get_format_rdi(
 		switch (out_format) {
 		case CAM_FORMAT_MIPI_RAW_20:
 			*decode_fmt = 0xf;
+			if (rpp) {
+				*decode_fmt = 0x6;
+				*packing_fmt = 0x1;
+			}
 			break;
 		case CAM_FORMAT_PLAIN32_20:
 			*decode_fmt = 0x6;
@@ -947,6 +975,7 @@ int cam_ife_csid_path_reserve(struct cam_ife_csid_hw *csid_hw,
 	int rc = 0, i, id;
 	struct cam_ife_csid_path_cfg    *path_data;
 	struct cam_isp_resource_node    *res;
+	bool                             is_rdi = false;
 
 	/* CSID  CSI2 v2.0 supports 31 vc */
 	if (reserve->sync_mode >= CAM_ISP_HW_SYNC_MAX) {
@@ -1042,6 +1071,7 @@ int cam_ife_csid_path_reserve(struct cam_ife_csid_hw *csid_hw,
 				"CSID:%d RDI resource:%d acquire success",
 				csid_hw->hw_intf->hw_idx,
 				res->res_id);
+			is_rdi = true;
 		}
 
 		break;
@@ -1113,12 +1143,21 @@ int cam_ife_csid_path_reserve(struct cam_ife_csid_hw *csid_hw,
 		path_data->start_pixel = reserve->in_port->left_start;
 		path_data->end_pixel = reserve->in_port->left_stop;
 		path_data->width  = reserve->in_port->left_width;
-		CAM_DBG(CAM_ISP, "CSID:%d master:startpixel 0x%x endpixel:0x%x",
-			csid_hw->hw_intf->hw_idx, path_data->start_pixel,
-			path_data->end_pixel);
-		CAM_DBG(CAM_ISP, "CSID:%d master:line start:0x%x line end:0x%x",
-			csid_hw->hw_intf->hw_idx, path_data->start_line,
-			path_data->end_line);
+
+		if (is_rdi) {
+			path_data->end_pixel = reserve->in_port->right_stop;
+			path_data->width = path_data->end_pixel -
+				path_data->start_pixel + 1;
+		}
+
+		CAM_DBG(CAM_ISP,
+			"CSID:%d res:%d master:startpixel 0x%x endpixel:0x%x",
+			csid_hw->hw_intf->hw_idx, reserve->res_id,
+			path_data->start_pixel, path_data->end_pixel);
+		CAM_DBG(CAM_ISP,
+			"CSID:%d res:%d master:line start:0x%x line end:0x%x",
+			csid_hw->hw_intf->hw_idx, reserve->res_id,
+			path_data->start_line, path_data->end_line);
 	} else if (reserve->sync_mode == CAM_ISP_HW_SYNC_SLAVE) {
 		path_data->master_idx = reserve->master_idx;
 		CAM_DBG(CAM_ISP, "CSID:%d master_idx=%d",
@@ -1126,23 +1165,29 @@ int cam_ife_csid_path_reserve(struct cam_ife_csid_hw *csid_hw,
 		path_data->start_pixel = reserve->in_port->right_start;
 		path_data->end_pixel = reserve->in_port->right_stop;
 		path_data->width  = reserve->in_port->right_width;
-		CAM_DBG(CAM_ISP, "CSID:%d slave:start:0x%x end:0x%x width 0x%x",
-			csid_hw->hw_intf->hw_idx, path_data->start_pixel,
-			path_data->end_pixel, path_data->width);
-		CAM_DBG(CAM_ISP, "CSID:%d slave:line start:0x%x line end:0x%x",
-			csid_hw->hw_intf->hw_idx, path_data->start_line,
-			path_data->end_line);
+		CAM_DBG(CAM_ISP,
+			"CSID:%d res:%d slave:start:0x%x end:0x%x width 0x%x",
+			csid_hw->hw_intf->hw_idx, reserve->res_id,
+			path_data->start_pixel, path_data->end_pixel,
+			path_data->width);
+		CAM_DBG(CAM_ISP,
+			"CSID:%d res:%d slave:line start:0x%x line end:0x%x",
+			csid_hw->hw_intf->hw_idx, reserve->res_id,
+			path_data->start_line, path_data->end_line);
 	} else {
 		path_data->width  = reserve->in_port->left_width;
 		path_data->start_pixel = reserve->in_port->left_start;
 		path_data->end_pixel = reserve->in_port->left_stop;
-		CAM_DBG(CAM_ISP, "Res id: %d left width %d start: %d stop:%d",
-			reserve->res_id, reserve->in_port->left_width,
+		CAM_DBG(CAM_ISP,
+			"CSID:%d res:%d left width %d start: %d stop:%d",
+			csid_hw->hw_intf->hw_idx, reserve->res_id,
+			reserve->in_port->left_width,
 			reserve->in_port->left_start,
 			reserve->in_port->left_stop);
 	}
 
-	CAM_DBG(CAM_ISP, "Res %d width %d height %d", reserve->res_id,
+	CAM_DBG(CAM_ISP, "CSID:%d res:%d width %d height %d",
+		csid_hw->hw_intf->hw_idx, reserve->res_id,
 		path_data->width, path_data->height);
 	reserve->node_res = res;
 
@@ -2077,8 +2122,7 @@ static int cam_ife_csid_init_config_rdi_path(
 	const struct cam_ife_csid_reg_offset   *csid_reg;
 	struct cam_hw_soc_info                 *soc_info;
 	uint32_t path_format = 0, plain_fmt = 0, val = 0, id;
-	uint32_t format_measure_addr;
-	uint32_t camera_hw_version;
+	uint32_t format_measure_addr, camera_hw_version, packing_fmt = 0;
 
 	path_data = (struct cam_ife_csid_path_cfg   *) res->res_priv;
 	csid_reg = csid_hw->csid_info->csid_reg;
@@ -2092,14 +2136,11 @@ static int cam_ife_csid_init_config_rdi_path(
 	}
 
 	rc = cam_ife_csid_get_format_rdi(path_data->in_format,
-		path_data->out_format, &path_format, &plain_fmt);
+		path_data->out_format, &path_format, &plain_fmt, &packing_fmt,
+		path_data->crop_enable || path_data->drop_enable);
 	if (rc)
 		return rc;
 
-	/* if path decode format is payload only then RDI crop is not applied */
-	if (path_format == 0xF)
-		path_data->crop_enable = 0;
-
 	/*
 	 * RDI path config and enable the time stamp capture
 	 * Enable the measurement blocks
@@ -2122,11 +2163,15 @@ static int cam_ife_csid_init_config_rdi_path(
 	}
 	CAM_DBG(CAM_ISP, "HW version: %x", camera_hw_version);
 
-	if (camera_hw_version == CAM_CPAS_TITAN_480_V100)
+	if (camera_hw_version == CAM_CPAS_TITAN_480_V100 ||
+		camera_hw_version == CAM_CPAS_TITAN_175_V130) {
 		val |= (path_data->drop_enable <<
 			csid_reg->cmn_reg->drop_h_en_shift_val) |
 			(path_data->drop_enable <<
-			csid_reg->cmn_reg->drop_v_en_shift_val);
+			csid_reg->cmn_reg->drop_v_en_shift_val) |
+			(packing_fmt <<
+			csid_reg->cmn_reg->packing_fmt_shift_val);
+	}
 
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 			csid_reg->rdi_reg[id]->csid_rdi_cfg0_addr);
@@ -2268,7 +2313,7 @@ static int cam_ife_csid_init_config_udi_path(
 	const struct cam_ife_csid_reg_offset   *csid_reg;
 	struct cam_hw_soc_info                 *soc_info;
 	uint32_t path_format = 0, plain_fmt = 0, val = 0, val1, id;
-	uint32_t format_measure_addr;
+	uint32_t format_measure_addr, packing_fmt = 0;
 
 	path_data = (struct cam_ife_csid_path_cfg *)res->res_priv;
 	csid_reg = csid_hw->csid_info->csid_reg;
@@ -2282,7 +2327,8 @@ static int cam_ife_csid_init_config_udi_path(
 	}
 
 	rc = cam_ife_csid_get_format_rdi(path_data->in_format,
-		path_data->out_format, &path_format, &plain_fmt);
+		path_data->out_format, &path_format, &plain_fmt, &packing_fmt,
+		path_data->crop_enable || path_data->drop_enable);
 	if (rc) {
 		CAM_ERR(CAM_ISP,
 			"Failed to get format in_format: %u out_format: %u rc: %d",
@@ -2290,10 +2336,6 @@ static int cam_ife_csid_init_config_udi_path(
 		return rc;
 	}
 
-	/* if path decode format is payload only then UDI crop is not applied */
-	if (path_format == 0xF)
-		path_data->crop_enable = false;
-
 	/*
 	 * UDI path config and enable the time stamp capture
 	 * Enable the measurement blocks
@@ -2309,6 +2351,8 @@ static int cam_ife_csid_init_config_udi_path(
 		csid_reg->cmn_reg->crop_v_en_shift_val) |
 		(1 << 2) | 3;
 
+	val |= (packing_fmt << csid_reg->cmn_reg->packing_fmt_shift_val);
+
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 			csid_reg->udi_reg[id]->csid_udi_cfg0_addr);
 

+ 1 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h

@@ -352,6 +352,7 @@ struct cam_ife_csid_common_reg_offset {
 	uint32_t path_rst_stb_all;
 	uint32_t path_rst_done_shift_val;
 	uint32_t path_en_shift_val;
+	uint32_t packing_fmt_shift_val;
 	uint32_t dt_id_shift_val;
 	uint32_t vc_shift_val;
 	uint32_t dt_shift_val;