Răsfoiți Sursa

msm: camera: isp: Update last applied scratch configuration for sfe

In case of sHDR dynamic switch, for a frame on which we are
configuring scratch buffer, use num of exposure from the
last applied valid request as opposed to global reference of
num of exposure held by global scratch configuration. The
global reference could have been updated by a future request,
it would be incorrect to use that when that request has not
even been applied.

CRs-Fixed: 3084946
Change-Id: I2a70d0de57e2dd780aa2eecc71a6398dc1800b6c
Signed-off-by: Depeng Shao <[email protected]>
Depeng Shao 3 ani în urmă
părinte
comite
271a07b9ce

+ 25 - 11
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -5941,8 +5941,10 @@ static int cam_ife_mgr_config_hw(void *hw_mgr_priv,
 					"config done Success for req_id=%llu ctx_index %d",
 					cfg->request_id, ctx->ctx_index);
 				/* Update last applied MUP */
-				if (hw_update_data->mup_en)
+				if (hw_update_data->mup_en) {
 					ctx->current_mup = hw_update_data->mup_val;
+					ctx->curr_num_exp = hw_update_data->num_exp;
+				}
 				hw_update_data->mup_en = false;
 			}
 		}
@@ -7639,7 +7641,7 @@ static int cam_isp_blob_sfe_update_fetch_core_cfg(
 		if ((ctx->ctx_config &
 			CAM_IFE_CTX_CFG_DYNAMIC_SWITCH_ON) &&
 			((res_id - CAM_ISP_SFE_IN_RD_0) >=
-			ctx->sfe_info.scratch_config->curr_num_exp))
+			ctx->sfe_info.scratch_config->updated_num_exp))
 			enable = false;
 		else
 			enable = true;
@@ -7652,7 +7654,7 @@ static int cam_isp_blob_sfe_update_fetch_core_cfg(
 			"SFE:%u RM: %u res_id: 0x%x enable: %u num_exp: %u",
 			blob_info->base_info->idx,
 			(res_id - CAM_ISP_SFE_IN_RD_0), res_id, enable,
-			ctx->sfe_info.scratch_config->curr_num_exp);
+			ctx->sfe_info.scratch_config->updated_num_exp);
 
 		rc = cam_isp_add_cmd_buf_update(
 			hw_mgr_res, blob_type,
@@ -9874,7 +9876,8 @@ static int cam_sfe_packet_generic_blob_handler(void *user_data,
 	}
 		break;
 	case CAM_ISP_GENERIC_BLOB_TYPE_DYNAMIC_MODE_SWITCH: {
-		struct cam_isp_mode_switch_info    *mup_config;
+		struct cam_isp_mode_switch_info       *mup_config;
+		struct cam_isp_prepare_hw_update_data *prepare_hw_data;
 
 		if (blob_size < sizeof(struct cam_isp_mode_switch_info)) {
 			CAM_ERR(CAM_ISP, "Invalid blob size %u expected %lu",
@@ -9883,10 +9886,13 @@ static int cam_sfe_packet_generic_blob_handler(void *user_data,
 			return -EINVAL;
 		}
 
+		prepare_hw_data = (struct cam_isp_prepare_hw_update_data  *)
+			prepare->priv;
 		mup_config = (struct cam_isp_mode_switch_info *)blob_data;
 		if (ife_mgr_ctx->flags.is_sfe_shdr) {
-			ife_mgr_ctx->sfe_info.scratch_config->curr_num_exp =
+			ife_mgr_ctx->sfe_info.scratch_config->updated_num_exp =
 				mup_config->num_expoures;
+			prepare_hw_data->num_exp = mup_config->num_expoures;
 
 			rc = cam_isp_blob_sfe_update_fetch_core_cfg(
 				blob_type, blob_info, prepare);
@@ -10011,16 +10017,24 @@ static int cam_sfe_packet_generic_blob_handler(void *user_data,
 }
 
 static inline bool cam_isp_sfe_validate_for_scratch_buf_config(
-	uint32_t res_idx, struct cam_ife_hw_mgr_ctx  *ctx)
+	uint32_t res_idx, struct cam_ife_hw_mgr_ctx  *ctx,
+	bool default_settings)
 {
+	uint32_t curr_num_exp;
+
 	/* check for num exposures for static mode but using RDI1-2 without RD1-2 */
 	if (res_idx >= ctx->sfe_info.num_fetches)
 		return true;
 
+	if (default_settings)
+		curr_num_exp = ctx->curr_num_exp;
+	else
+		curr_num_exp = ctx->sfe_info.scratch_config->updated_num_exp;
+
 	/* 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))
+		(res_idx >= curr_num_exp))
 		return true;
 
 	return false;
@@ -10139,7 +10153,7 @@ static int cam_isp_sfe_add_scratch_buffer_cfg(
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 
 			if (cam_isp_sfe_validate_for_scratch_buf_config(
-				(res_id - CAM_ISP_SFE_OUT_RES_RDI_0), ctx))
+				(res_id - CAM_ISP_SFE_OUT_RES_RDI_0), ctx, false))
 				continue;
 
 			/* check if buffer provided for this RDI is from userspace */
@@ -10201,7 +10215,7 @@ static int cam_isp_sfe_add_scratch_buffer_cfg(
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 
 			if (cam_isp_sfe_validate_for_scratch_buf_config(
-				(res_id - CAM_ISP_SFE_IN_RD_0), ctx))
+				(res_id - CAM_ISP_SFE_IN_RD_0), ctx, false))
 				continue;
 
 			/* check if buffer provided for this RM is from userspace */
@@ -11263,7 +11277,7 @@ static int cam_ife_mgr_prog_default_settings(
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 
 			if (cam_isp_sfe_validate_for_scratch_buf_config(
-				(res_id - CAM_ISP_SFE_OUT_RES_RDI_0), ctx))
+				(res_id - CAM_ISP_SFE_OUT_RES_RDI_0), ctx, true))
 				continue;
 
 			buf_info = &ctx->sfe_info.scratch_config->buf_info[
@@ -11301,7 +11315,7 @@ static int cam_ife_mgr_prog_default_settings(
 			res_id = hw_mgr_res->hw_res[j]->res_id;
 
 			if (cam_isp_sfe_validate_for_scratch_buf_config(
-				(res_id - CAM_ISP_SFE_IN_RD_0), ctx))
+				(res_id - CAM_ISP_SFE_IN_RD_0), ctx, false))
 				continue;
 
 			buf_info = &ctx->sfe_info.scratch_config->buf_info

+ 6 - 4
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h

@@ -108,14 +108,14 @@ struct cam_ife_sfe_scratch_buf_info {
 /**
  * struct cam_sfe_scratch_buf_cfg - Scratch buf info
  *
- * @num_configs : Total Number of scratch buffers provided
- * @curr_num_exp: Current num of exposures
- * @buf_info    : Info on each of the buffers
+ * @num_configs     : Total Number of scratch buffers provided
+ * @updated_num_exp : Current num of exposures
+ * @buf_info        : Info on each of the buffers
  *
  */
 struct cam_sfe_scratch_buf_cfg {
 	uint32_t                            num_config;
-	uint32_t                            curr_num_exp;
+	uint32_t                            updated_num_exp;
 	struct cam_ife_sfe_scratch_buf_info buf_info[
 		CAM_SFE_FE_RDI_NUM_MAX];
 };
@@ -259,6 +259,7 @@ struct cam_ife_cdm_user_data {
  * @recovery_id:            Unique ID of the current valid scheduled recovery
  * @current_mup:            Current MUP val, scratch will then apply the same as previously
  *                          applied request
+ * @curr_num_exp:           Current num of exposures
  *
  */
 struct cam_ife_hw_mgr_ctx {
@@ -315,6 +316,7 @@ struct cam_ife_hw_mgr_ctx {
 	uint32_t                          bw_config_version;
 	atomic_t                          recovery_id;
 	uint32_t                          current_mup;
+	uint32_t                          curr_num_exp;
 };
 
 /**

+ 4 - 2
drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h

@@ -231,9 +231,10 @@ struct cam_isp_bw_clk_config_info {
  * @bw_clk_config:          BW and clock config info
  * @reg_dump_buf_desc:     cmd buffer descriptors for reg dump
  * @num_reg_dump_buf:      Count of descriptors in reg_dump_buf_desc
- * @packet                 CSL packet from user mode driver
+ * @packet:                CSL packet from user mode driver
  * @mup_val:               MUP value if configured
- * @mup_en                 Flag if dynamic sensor switch is enabled
+ * @num_exp:               Num of exposures
+ * @mup_en:                Flag if dynamic sensor switch is enabled
  *
  */
 struct cam_isp_prepare_hw_update_data {
@@ -248,6 +249,7 @@ struct cam_isp_prepare_hw_update_data {
 	uint32_t                              num_reg_dump_buf;
 	struct cam_packet                    *packet;
 	uint32_t                              mup_val;
+	uint32_t                              num_exp;
 	bool                                  mup_en;
 };