فهرست منبع

msm: camera: isp: Consolidate common code into a single API

Consolidate checks for scratch buffer config for CDM & AHB
into one API.

CRs-Fixed: 2841729
Change-Id: Icd177a942c257c97a047fe9c0833e9c1cdce7bef
Signed-off-by: Karthik Anantha Ram <[email protected]>
Karthik Anantha Ram 4 سال پیش
والد
کامیت
1d59dbe0cb
1فایلهای تغییر یافته به همراه24 افزوده شده و 39 حذف شده
  1. 24 39
      drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

+ 24 - 39
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -9268,6 +9268,22 @@ static int cam_sfe_packet_generic_blob_handler(void *user_data,
 	return rc;
 	return rc;
 }
 }
 
 
+static inline bool cam_isp_sfe_validate_for_scratch_buf_config(
+	uint32_t res_idx, struct cam_ife_hw_mgr_ctx  *ctx)
+{
+	/* check for num exposures for static mode but using RDI1-2 without RD1-2 */
+	if (res_idx >= ctx->sfe_info.num_fetches)
+		return true;
+
+	/* check for num exposures for dynamic mode */
+	if ((ctx->ctx_config &
+		CAM_IFE_CTX_CFG_DYNAMIC_SWITCH_ON) &&
+		(res_idx >= ctx->sfe_info.scratch_config->curr_num_exp))
+		return true;
+
+	return false;
+}
+
 static int cam_isp_sfe_send_scratch_buf_upd(
 static int cam_isp_sfe_send_scratch_buf_upd(
 	uint32_t                         remaining_size,
 	uint32_t                         remaining_size,
 	enum cam_isp_hw_cmd_type         cmd_type,
 	enum cam_isp_hw_cmd_type         cmd_type,
@@ -9380,22 +9396,14 @@ static int cam_isp_sfe_add_scratch_buffer_cfg(
 
 
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 
 
-			/* check for num exposures for static mode but using RDI1-2 without RD1-2 */
-			if ((res_id - CAM_ISP_SFE_OUT_RES_RDI_0) >=
-				ctx->sfe_info.num_fetches)
+			if (cam_isp_sfe_validate_for_scratch_buf_config(
+				(res_id - CAM_ISP_SFE_OUT_RES_RDI_0), ctx))
 				continue;
 				continue;
 
 
 			/* check if buffer provided for this RDI is from userspace */
 			/* check if buffer provided for this RDI is from userspace */
 			if (sfe_rdi_cfg_mask & (1 << (res_id - CAM_ISP_SFE_OUT_RES_RDI_0)))
 			if (sfe_rdi_cfg_mask & (1 << (res_id - CAM_ISP_SFE_OUT_RES_RDI_0)))
 				continue;
 				continue;
 
 
-			/* check for num exposures for dynamic mode */
-			if ((ctx->ctx_config &
-				CAM_IFE_CTX_CFG_DYNAMIC_SWITCH_ON) &&
-				((res_id - CAM_ISP_SFE_OUT_RES_RDI_0) >=
-				ctx->sfe_info.scratch_config->curr_num_exp))
-				continue;
-
 			cpu_addr = kmd_buf_info->cpu_addr +
 			cpu_addr = kmd_buf_info->cpu_addr +
 				kmd_buf_info->used_bytes / 4 + io_cfg_used_bytes / 4;
 				kmd_buf_info->used_bytes / 4 + io_cfg_used_bytes / 4;
 			buf_info = &ctx->sfe_info.scratch_config->buf_info[
 			buf_info = &ctx->sfe_info.scratch_config->buf_info[
@@ -9442,21 +9450,14 @@ static int cam_isp_sfe_add_scratch_buffer_cfg(
 
 
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 
 
-			if ((res_id - CAM_ISP_HW_SFE_IN_RD0) >=
-				ctx->sfe_info.num_fetches)
+			if (cam_isp_sfe_validate_for_scratch_buf_config(
+				(res_id - CAM_ISP_HW_SFE_IN_RD0), ctx))
 				continue;
 				continue;
 
 
 			/* check if buffer provided for this RM is from userspace */
 			/* check if buffer provided for this RM is from userspace */
 			if (sfe_rdi_cfg_mask & (1 << (res_id - CAM_ISP_HW_SFE_IN_RD0)))
 			if (sfe_rdi_cfg_mask & (1 << (res_id - CAM_ISP_HW_SFE_IN_RD0)))
 				continue;
 				continue;
 
 
-			/* check for num exposures */
-			if ((ctx->ctx_config &
-				CAM_IFE_CTX_CFG_DYNAMIC_SWITCH_ON) &&
-				((res_id - CAM_ISP_HW_SFE_IN_RD0) >=
-				ctx->sfe_info.scratch_config->curr_num_exp))
-				continue;
-
 			cpu_addr = kmd_buf_info->cpu_addr +
 			cpu_addr = kmd_buf_info->cpu_addr +
 				kmd_buf_info->used_bytes  / 4 +
 				kmd_buf_info->used_bytes  / 4 +
 				io_cfg_used_bytes / 4;
 				io_cfg_used_bytes / 4;
@@ -10364,16 +10365,8 @@ static int cam_ife_mgr_prog_default_settings(
 
 
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 
 
-			/* check for num exposures for static mode but using RDI1-2 without RD1-2 */
-			if ((res_id - CAM_ISP_SFE_OUT_RES_RDI_0) >=
-				ctx->sfe_info.num_fetches)
-				continue;
-
-			/* check for num exposures */
-			if ((ctx->ctx_config &
-				CAM_IFE_CTX_CFG_DYNAMIC_SWITCH_ON) &&
-				((res_id - CAM_ISP_SFE_OUT_RES_RDI_0) >=
-				ctx->sfe_info.scratch_config->curr_num_exp))
+			if (cam_isp_sfe_validate_for_scratch_buf_config(
+				(res_id - CAM_ISP_SFE_OUT_RES_RDI_0), ctx))
 				continue;
 				continue;
 
 
 			buf_info = &ctx->sfe_info.scratch_config->buf_info[
 			buf_info = &ctx->sfe_info.scratch_config->buf_info[
@@ -10402,16 +10395,8 @@ static int cam_ife_mgr_prog_default_settings(
 
 
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 
 
-			/* check for num exposures for static mode but using RDI1-2 without RD1-2 */
-			if ((res_id - CAM_ISP_HW_SFE_IN_RD0) >=
-				ctx->sfe_info.num_fetches)
-				continue;
-
-			/* check for num exposures */
-			if ((ctx->ctx_config &
-				CAM_IFE_CTX_CFG_DYNAMIC_SWITCH_ON) &&
-				((res_id - CAM_ISP_HW_SFE_IN_RD0) >=
-				ctx->sfe_info.scratch_config->curr_num_exp))
+			if (cam_isp_sfe_validate_for_scratch_buf_config(
+				(res_id - CAM_ISP_HW_SFE_IN_RD0), ctx))
 				continue;
 				continue;
 
 
 			buf_info = &ctx->sfe_info.scratch_config->buf_info
 			buf_info = &ctx->sfe_info.scratch_config->buf_info