فهرست منبع

Merge "msm: camera: isp: Allocate max map entries based on the stream type" into camera-kernel.lnx.5.0

Savita Patted 4 سال پیش
والد
کامیت
90fb1ebc6c

+ 17 - 1
drivers/cam_core/cam_hw_mgr_intf.h

@@ -103,6 +103,19 @@ struct cam_hw_done_event_data {
 	uint32_t           evt_param;
 };
 
+/**
+ * struct cam_hw_acquire_stream_caps - Any HW caps info from HW mgr to ctx
+ *                                     Params to be interpreted by the
+ *                                     respective drivers
+ * @num_valid_params : Number of valid params
+ * @param_list       : List of params interpreted by the driver
+ *
+ */
+struct cam_hw_acquire_stream_caps {
+	uint32_t          num_valid_params;
+	uint32_t          param_list[4];
+};
+
 /**
  * struct cam_hw_acquire_args - Payload for acquire command
  *
@@ -119,7 +132,8 @@ struct cam_hw_done_event_data {
  * @acquired_hw_path:      Acquired path mask for an input
  *                         if input splits into multiple paths,
  *                         its updated per hardware
- * valid_acquired_hw:      Valid num of acquired hardware
+ * @valid_acquired_hw:     Valid num of acquired hardware
+ * @op_params:             OP Params from hw_mgr to ctx
  *
  */
 struct cam_hw_acquire_args {
@@ -136,6 +150,8 @@ struct cam_hw_acquire_args {
 	uint32_t    acquired_hw_id[CAM_MAX_ACQ_RES];
 	uint32_t    acquired_hw_path[CAM_MAX_ACQ_RES][CAM_MAX_HW_SPLIT];
 	uint32_t    valid_acquired_hw;
+
+	struct cam_hw_acquire_stream_caps op_params;
 };
 
 /**

+ 37 - 18
drivers/cam_isp/cam_isp_context.c

@@ -4315,6 +4315,8 @@ static void __cam_isp_ctx_free_mem_hw_entries(struct cam_context *ctx)
 	ctx->out_map_entries = NULL;
 	ctx->in_map_entries = NULL;
 	ctx->hw_update_entry = NULL;
+	ctx->max_out_map_entries = 0;
+	ctx->max_in_map_entries = 0;
 }
 
 static int __cam_isp_ctx_release_hw_in_top_state(struct cam_context *ctx,
@@ -4653,14 +4655,31 @@ free_req:
 	return rc;
 }
 
-static int __cam_isp_ctx_allocate_mem_hw_entries(struct cam_context *ctx)
+static int __cam_isp_ctx_allocate_mem_hw_entries(
+	struct cam_context *ctx,
+	struct cam_hw_acquire_args *param)
 {
 	int rc = 0;
+	uint32_t max_res = 0;
 	struct cam_ctx_request          *req;
 	struct cam_ctx_request          *temp_req;
 	struct cam_isp_ctx_req          *req_isp;
 	size_t num_entries = 0;
 
+	if (!param->op_params.param_list[0])
+		max_res = CAM_ISP_CTX_RES_MAX;
+	else {
+		max_res = param->op_params.param_list[0];
+		if (param->op_flags & CAM_IFE_CTX_SFE_EN)
+			max_res += param->op_params.param_list[1];
+	}
+
+	ctx->max_in_map_entries = max_res;
+	ctx->max_out_map_entries = max_res;
+
+	CAM_DBG(CAM_ISP, "Allocate max: 0x%x is_sfe_en: %d",
+		max_res, (param->op_flags & CAM_IFE_CTX_SFE_EN));
+
 	num_entries = ctx->max_hw_update_entries * CAM_ISP_CTX_REQ_MAX;
 	ctx->hw_update_entry = kcalloc(num_entries,
 		sizeof(struct cam_hw_update_entry),
@@ -4772,12 +4791,13 @@ static int __cam_isp_ctx_acquire_dev_in_available(struct cam_context *ctx,
 		goto free_res;
 	}
 
+	memset(&param, 0, sizeof(param));
 	param.context_data = ctx;
 	param.event_cb = ctx->irq_cb_intf;
 	param.num_acq = cmd->num_resources;
 	param.acquire_info = (uintptr_t) isp_res;
 
-	rc = __cam_isp_ctx_allocate_mem_hw_entries(ctx);
+	rc = __cam_isp_ctx_allocate_mem_hw_entries(ctx, &param);
 	if (rc) {
 		CAM_ERR(CAM_ISP, "Ctx[%d] allocate hw entry fail",
 			ctx->ctx_id);
@@ -4895,13 +4915,13 @@ static int __cam_isp_ctx_acquire_hw_v1(struct cam_context *ctx,
 	int i;
 	struct cam_acquire_hw_cmd_v1 *cmd =
 		(struct cam_acquire_hw_cmd_v1 *)args;
-	struct cam_hw_acquire_args       param;
-	struct cam_hw_release_args       release;
-	struct cam_isp_context          *ctx_isp =
+	struct cam_hw_acquire_args        param;
+	struct cam_hw_release_args        release;
+	struct cam_isp_context           *ctx_isp =
 		(struct cam_isp_context *) ctx->ctx_priv;
-	struct cam_hw_cmd_args           hw_cmd_args;
-	struct cam_isp_hw_cmd_args       isp_hw_cmd_args;
-	struct cam_isp_acquire_hw_info  *acquire_hw_info = NULL;
+	struct cam_hw_cmd_args            hw_cmd_args;
+	struct cam_isp_hw_cmd_args        isp_hw_cmd_args;
+	struct cam_isp_acquire_hw_info   *acquire_hw_info = NULL;
 
 	if (!ctx->hw_mgr_intf) {
 		CAM_ERR(CAM_ISP, "HW interface is not ready");
@@ -4946,7 +4966,8 @@ static int __cam_isp_ctx_acquire_hw_v1(struct cam_context *ctx,
 	param.acquire_info_size = cmd->data_size;
 	param.acquire_info = (uint64_t) acquire_hw_info;
 
-	rc = __cam_isp_ctx_allocate_mem_hw_entries(ctx);
+	rc = __cam_isp_ctx_allocate_mem_hw_entries(ctx,
+		&param);
 	if (rc) {
 		CAM_ERR(CAM_ISP, "Ctx[%d] allocate hw entry fail",
 			ctx->ctx_id);
@@ -5096,13 +5117,6 @@ static int __cam_isp_ctx_acquire_hw_v2(struct cam_context *ctx,
 	param.acquire_info_size = cmd->data_size;
 	param.acquire_info = (uint64_t) acquire_hw_info;
 
-	rc = __cam_isp_ctx_allocate_mem_hw_entries(ctx);
-	if (rc) {
-		CAM_ERR(CAM_ISP, "Ctx[%d] allocate hw entry fail",
-			ctx->ctx_id);
-		goto free_res;
-	}
-
 	/* call HW manager to reserve the resource */
 	rc = ctx->hw_mgr_intf->hw_acquire(ctx->hw_mgr_intf->hw_mgr_priv,
 		&param);
@@ -5111,6 +5125,13 @@ static int __cam_isp_ctx_acquire_hw_v2(struct cam_context *ctx,
 		goto free_res;
 	}
 
+	rc = __cam_isp_ctx_allocate_mem_hw_entries(ctx, &param);
+	if (rc) {
+		CAM_ERR(CAM_ISP, "Ctx[%d] allocate hw entry fail",
+			ctx->ctx_id);
+		goto free_hw;
+	}
+
 	/*
 	 * Set feature flag if applicable
 	 * custom hw is supported only on v2
@@ -6183,8 +6204,6 @@ int cam_isp_context_init(struct cam_isp_context *ctx,
 	ctx_base->ctx_priv = ctx;
 
 	ctx_base->max_hw_update_entries = CAM_ISP_CTX_CFG_MAX;
-	ctx_base->max_in_map_entries = CAM_ISP_CTX_RES_MAX;
-	ctx_base->max_out_map_entries = CAM_ISP_CTX_RES_MAX;
 
 	/* initializing current state for error logging */
 	for (i = 0; i < CAM_ISP_CTX_STATE_MONITOR_MAX_ENTRIES; i++) {

+ 40 - 9
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -4674,7 +4674,7 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
 	atomic_set(&ife_ctx->cdm_done, 1);
 	ife_ctx->last_cdm_done_req = 0;
 
-	if (g_ife_hw_mgr.support_consumed_addr)
+	if (g_ife_hw_mgr.isp_bus_caps.support_consumed_addr)
 		acquire_args->op_flags |=
 			CAM_IFE_CTX_CONSUME_ADDR_EN;
 
@@ -4692,6 +4692,10 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
 		acquire_args->op_flags |=
 			CAM_IFE_CTX_FRAME_HEADER_EN;
 
+	if (ife_ctx->ctx_type == CAM_IFE_CTX_TYPE_SFE)
+		acquire_args->op_flags |=
+			CAM_IFE_CTX_SFE_EN;
+
 	ife_ctx->ctx_in_use = 1;
 	ife_ctx->num_reg_dump_buf = 0;
 	memset(&ife_ctx->scratch_config, 0,
@@ -4699,6 +4703,10 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
 
 	acquire_args->valid_acquired_hw =
 		acquire_hw_info->num_inputs;
+	acquire_args->op_params.num_valid_params = 2;
+	acquire_args->op_params.param_list[0] = max_ife_out_res;
+	acquire_args->op_params.param_list[1] =
+		ife_hw_mgr->isp_bus_caps.max_sfe_out_res_type;
 
 	ktime_get_real_ts64(&ife_ctx->ts);
 
@@ -6030,7 +6038,7 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args)
 	struct cam_hw_intf                  *hw_intf;
 
 	primary_rdi_src_res = CAM_ISP_HW_VFE_IN_MAX;
-	primary_rdi_out_res = g_ife_hw_mgr.max_vfe_out_res_type;
+	primary_rdi_out_res = g_ife_hw_mgr.isp_bus_caps.max_vfe_out_res_type;
 	primary_rdi_csid_res = CAM_IFE_PIX_PATH_RES_MAX;
 
 	if (!hw_mgr_priv || !start_isp) {
@@ -6209,7 +6217,7 @@ start_only:
 		}
 	}
 
-	if (primary_rdi_out_res < g_ife_hw_mgr.max_vfe_out_res_type) {
+	if (primary_rdi_out_res < g_ife_hw_mgr.isp_bus_caps.max_vfe_out_res_type) {
 		primary_rdi_src_res =
 			cam_convert_rdi_out_res_id_to_src(primary_rdi_out_res);
 		primary_rdi_csid_res =
@@ -7653,7 +7661,7 @@ static int cam_isp_packet_generic_blob_handler(void *user_data,
 
 		hfr_config = (struct cam_isp_resource_hfr_config *)blob_data;
 
-		if (hfr_config->num_ports > g_ife_hw_mgr.max_vfe_out_res_type ||
+		if (hfr_config->num_ports > g_ife_hw_mgr.isp_bus_caps.max_vfe_out_res_type ||
 			hfr_config->num_ports == 0) {
 			CAM_ERR(CAM_ISP, "Invalid num_ports %u in HFR config",
 				hfr_config->num_ports);
@@ -11044,7 +11052,7 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
 					&isp_bus_cap,
 					sizeof(struct cam_isp_hw_bus_cap));
 				CAM_DBG(CAM_ISP, "max VFE out resources: 0x%x",
-					isp_bus_cap.max_vfe_out_res_type);
+					isp_bus_cap.max_out_res_type);
 			}
 
 			j++;
@@ -11066,9 +11074,13 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
 		return -EINVAL;
 	}
 
-	g_ife_hw_mgr.support_consumed_addr = isp_bus_cap.support_consumed_addr;
-	g_ife_hw_mgr.max_vfe_out_res_type = isp_bus_cap.max_vfe_out_res_type;
-	max_ife_out_res = g_ife_hw_mgr.max_vfe_out_res_type & 0xFF;
+	g_ife_hw_mgr.isp_bus_caps.support_consumed_addr =
+		isp_bus_cap.support_consumed_addr;
+	g_ife_hw_mgr.isp_bus_caps.max_vfe_out_res_type =
+		isp_bus_cap.max_out_res_type;
+	max_ife_out_res =
+		g_ife_hw_mgr.isp_bus_caps.max_vfe_out_res_type & 0xFF;
+	memset(&isp_bus_cap, 0x0, sizeof(struct cam_isp_hw_bus_cap));
 
 	/* fill csid hw intf information */
 	for (i = 0, j = 0; i < CAM_IFE_CSID_HW_NUM_MAX; i++) {
@@ -11093,8 +11105,27 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
 	/* fill sfe hw intf info */
 	for (i = 0, j = 0; i < CAM_SFE_HW_NUM_MAX; i++) {
 		rc = cam_sfe_hw_init(&g_ife_hw_mgr.sfe_devices[i], i);
-		if (!rc)
+		if (!rc) {
+			if (j == 0) {
+				struct cam_hw_intf *sfe_device =
+					g_ife_hw_mgr.sfe_devices[i];
+				struct cam_hw_info *sfe_hw =
+					(struct cam_hw_info *)
+					sfe_device->hw_priv;
+
+				rc = sfe_device->hw_ops.process_cmd(
+					sfe_hw,
+					CAM_ISP_HW_CMD_QUERY_BUS_CAP,
+					&isp_bus_cap,
+					sizeof(struct cam_isp_hw_bus_cap));
+				CAM_DBG(CAM_ISP, "max SFE out resources: 0x%x",
+					isp_bus_cap.max_out_res_type);
+				if (!rc)
+					g_ife_hw_mgr.isp_bus_caps.max_sfe_out_res_type =
+						isp_bus_cap.max_out_res_type;
+			}
 			j++;
+		}
 	}
 	if (!j)
 		CAM_ERR(CAM_ISP, "no valid SFE HW devices");

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

@@ -229,6 +229,19 @@ struct cam_ife_hw_mgr_ctx {
 	struct cam_sfe_scratch_buf_cfg  scratch_config;
 };
 
+/**
+ * struct cam_isp_bus_hw_caps - BUS capabilities
+ *
+ * @max_vfe_out_res_type  :  max ife out res type value from hw
+ * @max_sfe_out_res_type  :  max sfe out res type value from hw
+ * @support_consumed_addr :  indicate whether hw supports last consumed address
+ */
+struct cam_isp_bus_hw_caps {
+	uint32_t     max_vfe_out_res_type;
+	uint32_t     max_sfe_out_res_type;
+	bool         support_consumed_addr;
+};
+
 /**
  * struct cam_ife_hw_mgr - IFE HW Manager
  *
@@ -247,11 +260,10 @@ struct cam_ife_hw_mgr_ctx {
  * @work q                 work queue for IFE hw manager
  * @debug_cfg              debug configuration
  * @ctx_lock               context lock
- * @support_consumed_addr  indicate whether hw supports last consumed address
  * @hw_pid_support         hw pid support for this target
- * @max_vfe_out_res_type   max ife out res type value from hw
  * @csid_rup_en            Reg update at CSID side
  * @csid_global_reset_en   CSID global reset enable
+ * @isp_bus_caps           Capability of underlying SFE/IFE bus HW
  */
 struct cam_ife_hw_mgr {
 	struct cam_isp_hw_mgr          mgr_common;
@@ -273,11 +285,10 @@ struct cam_ife_hw_mgr {
 	struct cam_req_mgr_core_workq *workq;
 	struct cam_ife_hw_mgr_debug    debug_cfg;
 	spinlock_t                     ctx_lock;
-	bool                           support_consumed_addr;
 	bool                           hw_pid_support;
-	uint32_t                       max_vfe_out_res_type;
 	bool                           csid_rup_en;
 	bool                           csid_global_reset_en;
+	struct cam_isp_bus_hw_caps     isp_bus_caps;
 };
 
 /**

+ 1 - 0
drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h

@@ -37,6 +37,7 @@
 #define CAM_IFE_CTX_FRAME_HEADER_EN    BIT(1)
 #define CAM_IFE_CTX_CONSUME_ADDR_EN    BIT(2)
 #define CAM_IFE_CTX_APPLY_DEFAULT_CFG  BIT(3)
+#define CAM_IFE_CTX_SFE_EN             BIT(4)
 
 /*
  * Maximum configuration entry size  - This is based on the

+ 3 - 3
drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h

@@ -400,13 +400,13 @@ struct cam_isp_hw_intf_data {
  *
  * @Brief:         ISP hw bus capabilities
  *
- * @support_consumed_addr:   Indicate whether HW has last consumed addr reg
- * @max_vfe_out_res_type:    Maximum value of out resource type supported by hw
+ * @support_consumed_addr:  Indicate whether HW has last consumed addr reg
+ * @max_out_res_type:       Maximum value of out resource type supported by hw
  *
  */
 struct cam_isp_hw_bus_cap {
 	bool                    support_consumed_addr;
-	uint32_t                max_vfe_out_res_type;
+	uint32_t                max_out_res_type;
 };
 
 #endif /* _CAM_ISP_HW_H_ */

+ 1 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/cam_sfe_core.c

@@ -332,6 +332,7 @@ int cam_sfe_process_cmd(void *hw_priv, uint32_t cmd_type,
 	case CAM_ISP_HW_CMD_STRIPE_UPDATE:
 	case CAM_ISP_HW_CMD_WM_CONFIG_UPDATE:
 	case CAM_ISP_HW_CMD_GET_SECURE_MODE:
+	case CAM_ISP_HW_CMD_QUERY_BUS_CAP:
 		rc = core_info->sfe_bus_wr->hw_ops.process_cmd(
 			core_info->sfe_bus_wr->bus_priv, cmd_type,
 			cmd_args, arg_size);

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

@@ -2520,6 +2520,15 @@ static int cam_sfe_bus_wr_process_cmd(
 	case CAM_ISP_HW_CMD_WM_CONFIG_UPDATE:
 		rc = cam_sfe_bus_wr_update_wm_config(cmd_args);
 		break;
+	case CAM_ISP_HW_CMD_QUERY_BUS_CAP: {
+		struct cam_isp_hw_bus_cap *sfe_bus_cap;
+
+		bus_priv = (struct cam_sfe_bus_wr_priv  *) priv;
+		sfe_bus_cap = (struct cam_isp_hw_bus_cap *) cmd_args;
+		sfe_bus_cap->max_out_res_type = bus_priv->num_out;
+		rc = 0;
+	}
+		break;
 	default:
 		CAM_ERR_RATE_LIMIT(CAM_SFE, "Invalid HW command type:%d",
 			cmd_type);

+ 1 - 1
drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.c

@@ -3749,7 +3749,7 @@ static int cam_vfe_bus_process_cmd(
 	case CAM_ISP_HW_CMD_QUERY_BUS_CAP:
 		bus_priv = (struct cam_vfe_bus_ver2_priv  *) priv;
 		vfe_bus_cap = (struct cam_isp_hw_bus_cap *) cmd_args;
-		vfe_bus_cap->max_vfe_out_res_type = bus_priv->max_out_res;
+		vfe_bus_cap->max_out_res_type = bus_priv->max_out_res;
 		vfe_bus_cap->support_consumed_addr =
 			bus_priv->common_data.support_consumed_addr;
 

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

@@ -3775,7 +3775,7 @@ static int cam_vfe_bus_ver3_process_cmd(
 	case CAM_ISP_HW_CMD_QUERY_BUS_CAP:
 		bus_priv = (struct cam_vfe_bus_ver3_priv  *) priv;
 		vfe_bus_cap = (struct cam_isp_hw_bus_cap *) cmd_args;
-		vfe_bus_cap->max_vfe_out_res_type = bus_priv->max_out_res;
+		vfe_bus_cap->max_out_res_type = bus_priv->max_out_res;
 		vfe_bus_cap->support_consumed_addr =
 			bus_priv->common_data.support_consumed_addr;
 		break;