Browse Source

msm: camera: isp: Keep LSB aligned for Plain16_10/12/14 RDI buffers

Due to hw limitation, if the required RDI buffer output is
Plain16_10/12/14, BUS cannot conver CSID unpacked MSB data
into LSB aligned while writing the buffers. So keep CSID out
as unpacked LSB data if the final RDI output buffer format
is Plain16_10/12/14. This will have limitation in using RDI
data going into LCR/PDAF.

CRs-Fixed: 3118104
Change-Id: I9193530ec549b4658a058ae71eed4f31653bd88e
Signed-off-by: Pavan Kumar Chilamkurthi <[email protected]>
Pavan Kumar Chilamkurthi 3 năm trước cách đây
mục cha
commit
5561a5d0ef

+ 19 - 14
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver2.c

@@ -2212,9 +2212,6 @@ static bool cam_ife_csid_hw_ver2_need_unpack_mipi(
 	case CAM_FORMAT_MIPI_RAW_10:
 	case CAM_FORMAT_MIPI_RAW_12:
 	case CAM_FORMAT_MIPI_RAW_14:
-	case CAM_FORMAT_PLAIN16_10:
-	case CAM_FORMAT_PLAIN16_12:
-	case CAM_FORMAT_PLAIN16_14:
 	 /*
 	  * CAM_FORMAT_PLAIN16_16 : can be removed? double check why default_out_format has it.
 	  * default_out_format is used in xCFA usecases without real RDI0 out buffer.
@@ -2323,20 +2320,21 @@ static int cam_ife_csid_hw_ver2_config_path_data(
 	case CAM_IFE_PIX_PATH_RES_RDI_2:
 	case CAM_IFE_PIX_PATH_RES_RDI_3:
 	case CAM_IFE_PIX_PATH_RES_RDI_4:
+		path_cfg->csid_out_unpack_msb = cam_ife_csid_hw_ver2_need_unpack_mipi(csid_hw,
+			reserve, path_reg, path_cfg->out_format);
+
 		/*
-		 * if csid gives unpacked out, packing needs to be done at
+		 * if csid gives unpacked msb out, packing needs to be done at
 		 * WM side if needed, based on the format the decision is
 		 * taken at WM side
 		 */
-		reserve->use_wm_pack = cam_ife_csid_hw_ver2_need_unpack_mipi(csid_hw,
-			reserve, path_reg, path_cfg->out_format);
-		path_cfg->use_wm_pack = reserve->use_wm_pack;
+		reserve->use_wm_pack = path_cfg->csid_out_unpack_msb;
 
 		rc = cam_ife_csid_get_format_rdi(
 			path_cfg->in_format[CAM_IFE_CSID_MULTI_VC_DT_GRP_0],
 			path_cfg->out_format,
 			&path_cfg->path_format[CAM_IFE_CSID_MULTI_VC_DT_GRP_0],
-			path_reg->mipi_pack_supported, reserve->use_wm_pack);
+			path_reg->mipi_pack_supported, path_cfg->csid_out_unpack_msb);
 		if (rc)
 			goto end;
 
@@ -2347,7 +2345,7 @@ static int cam_ife_csid_hw_ver2_config_path_data(
 				path_cfg->in_format[CAM_IFE_CSID_MULTI_VC_DT_GRP_1],
 				path_cfg->out_format,
 				&path_cfg->path_format[CAM_IFE_CSID_MULTI_VC_DT_GRP_1],
-				path_reg->mipi_pack_supported, reserve->use_wm_pack);
+				path_reg->mipi_pack_supported, path_cfg->csid_out_unpack_msb);
 			if (rc)
 				goto end;
 		}
@@ -2919,7 +2917,7 @@ static int cam_ife_csid_ver2_init_config_rdi_path(
 			path_reg->plain_fmt_shift_val);
 
 	/* Keep the data in MSB, IFE/SFE  pipeline, BUS expects data in MSB */
-	if (path_cfg->use_wm_pack &&
+	if (path_cfg->csid_out_unpack_msb &&
 		path_cfg->path_format[CAM_IFE_CSID_MULTI_VC_DT_GRP_0].plain_fmt)
 		cfg1 |= (1 << path_reg->plain_alignment_shift_val);
 
@@ -5240,14 +5238,21 @@ static int cam_ife_csid_ver2_rdi_lcr_cfg(
 
 	/*
 	 * LCR should not be on for a resource if CSID is giving packed data
-	 * this case would come for formats which are not supported
-	 * */
+	 * this case would come for formats which are not supported.
+	 */
 	if (path_cfg->path_format[CAM_IFE_CSID_MULTI_VC_DT_GRP_0].packing_fmt) {
-		CAM_ERR(CAM_ISP, "LCR enabled for %s, csid out packed not supported",
-			res->res_name);
+		CAM_ERR(CAM_ISP, "[%s] LCR not supported in_format %d out_format %d",
+			res->res_name, path_cfg->in_format[CAM_IFE_CSID_MULTI_VC_DT_GRP_0],
+			path_cfg->out_format);
 		return -EINVAL;
 	}
 
+	/* if CSID unpacked data is not in MSB, we loose few bits going into PDAF, warn for now */
+	if (!path_cfg->csid_out_unpack_msb)
+		CAM_WARN(CAM_ISP, "[%s] Input data to LCR is in LSB, in_format %d out_format %d",
+			res->res_name, path_cfg->in_format[CAM_IFE_CSID_MULTI_VC_DT_GRP_0],
+			path_cfg->out_format);
+
 	if (csid_hw->flags.sfe_en)
 		csid_hw->top_cfg.rdi_lcr |= BIT(res->res_id) <<
 			csid_reg->top_reg->rdi_lcr_shift_val;

+ 1 - 1
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver2.h

@@ -209,7 +209,7 @@ struct cam_ife_csid_ver2_path_cfg {
 	bool                                 skip_discard_frame_cfg;
 	bool                                 sfe_shdr;
 	bool                                 lcr_en;
-	bool                                 use_wm_pack;
+	bool                                 csid_out_unpack_msb;
 };
 
 struct cam_ife_csid_ver2_top_reg_info {

+ 0 - 27
drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/sfe_bus/cam_sfe_bus_wr.c

@@ -657,33 +657,6 @@ static int cam_sfe_bus_config_rdi_wm(
 			CAM_WARN(CAM_SFE, "No index mode support for SFE WM: %u",
 				rsrc_data->index);
 		}
-
-		if (rsrc_data->use_wm_pack) {
-			switch (rsrc_data->format) {
-			case CAM_FORMAT_PLAIN16_10:
-				rsrc_data->pack_fmt = PACKER_FMT_PLAIN_16_10BPP;
-				break;
-			case CAM_FORMAT_PLAIN16_12:
-				rsrc_data->pack_fmt = PACKER_FMT_PLAIN_16_12BPP;
-				break;
-			case CAM_FORMAT_PLAIN16_14:
-				rsrc_data->pack_fmt = PACKER_FMT_PLAIN_16_14BPP;
-				break;
-			case CAM_FORMAT_PLAIN16_16:
-				rsrc_data->pack_fmt = PACKER_FMT_PLAIN_16_16BPP;
-				break;
-			default:
-				CAM_ERR(CAM_SFE, "Not possible");
-				break;
-			}
-
-			/* LSB aligned */
-			rsrc_data->pack_fmt |=
-				(1 << rsrc_data->common_data->pack_align_shift);
-
-			if (rsrc_data->wm_mode == CAM_SFE_WM_LINE_BASED_MODE)
-				rsrc_data->width = ALIGNUP((rsrc_data->acquired_width), 16);
-		}
 		break;
 	case CAM_FORMAT_PLAIN64:
 		if (rsrc_data->wm_mode == CAM_SFE_WM_LINE_BASED_MODE) {

+ 0 - 26
drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c

@@ -995,32 +995,6 @@ static int cam_vfe_bus_ver3_config_rdi_wm(
 		rsrc_data->width =
 			ALIGNUP(rsrc_data->width * 2, 16) / 16;
 		rsrc_data->en_cfg = 0x1;
-
-		if (rsrc_data->use_wm_pack) {
-			switch (rsrc_data->format) {
-			case CAM_FORMAT_PLAIN16_10:
-				rsrc_data->pack_fmt = PACKER_FMT_VER3_PLAIN_16_10BPP;
-				break;
-			case CAM_FORMAT_PLAIN16_12:
-				rsrc_data->pack_fmt = PACKER_FMT_VER3_PLAIN_16_12BPP;
-				break;
-			case CAM_FORMAT_PLAIN16_14:
-				rsrc_data->pack_fmt = PACKER_FMT_VER3_PLAIN_16_14BPP;
-				break;
-			case CAM_FORMAT_PLAIN16_16:
-				rsrc_data->pack_fmt = PACKER_FMT_VER3_PLAIN_16_16BPP;
-				break;
-			default:
-				CAM_ERR(CAM_SFE, "Not possible");
-				break;
-			}
-
-			/* LSB aligned */
-			rsrc_data->pack_fmt |= (1 << rsrc_data->common_data->pack_align_shift);
-
-			if (rsrc_data->default_line_based)
-				rsrc_data->width = ALIGNUP((rsrc_data->acquired_width), 16);
-		}
 		break;
 	case CAM_FORMAT_PLAIN64:
 		rsrc_data->width =