Переглянути джерело

Merge "msm: camera: tfe: Multiple fixes for TFE Lite" into camera-kernel.lnx.7.0

Camera Software Integration 1 рік тому
батько
коміт
7d82a270a3

+ 129 - 37
drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c

@@ -179,64 +179,155 @@ static int cam_tfe_mgr_handle_reg_dump(struct cam_tfe_hw_mgr_ctx *ctx,
 	return rc;
 }
 
-static int cam_tfe_mgr_get_hw_caps(void *hw_mgr_priv, void *hw_caps_args)
+static int cam_tfe_mgr_get_hw_caps_internal(void *hw_mgr_priv,
+	struct cam_isp_tfe_query_cap_cmd_v2     *query_isp)
 {
-	int rc = 0;
-	int i;
+	int i, rc = 0;
 	uint32_t num_dev = 0;
 	struct cam_tfe_hw_mgr                  *hw_mgr = hw_mgr_priv;
+
+	query_isp->device_iommu.non_secure = hw_mgr->mgr_common.img_iommu_hdl;
+	query_isp->device_iommu.secure = hw_mgr->mgr_common.img_iommu_hdl_secure;
+	query_isp->cdm_iommu.non_secure = hw_mgr->mgr_common.cmd_iommu_hdl;
+	query_isp->cdm_iommu.secure = hw_mgr->mgr_common.cmd_iommu_hdl_secure;
+
+	for (i = 0; i < CAM_TFE_CSID_HW_NUM_MAX; i++) {
+		if (!hw_mgr->csid_devices[i])
+			break;
+		if (query_isp->num_dev < i)
+			return -EINVAL;
+
+		query_isp->dev_caps[i].hw_type = CAM_ISP_TFE_HW_TFE;
+		query_isp->dev_caps[i].hw_version.major = 7;
+		query_isp->dev_caps[i].hw_version.minor = 7;
+		query_isp->dev_caps[i].hw_version.incr = 0;
+
+		/*
+		 * device number is based on number of full tfe
+		 * if pix is not supported, set reserve to 1
+		 */
+		if (hw_mgr->tfe_csid_dev_caps[i].num_pix) {
+			query_isp->dev_caps[i].hw_version.reserved = 0;
+			num_dev++;
+		} else {
+			query_isp->dev_caps[i].hw_version.reserved = 1;
+		}
+	}
+
+	query_isp->num_dev = num_dev;
+	return rc;
+}
+
+static int cam_tfe_mgr_get_hw_caps(void *hw_mgr_priv,
+	void *hw_caps_args)
+{
+	int rc = 0;
+	int i, query_size;
+	uint32_t version = 0;
 	struct cam_query_cap_cmd               *query = hw_caps_args;
+	struct cam_tfe_hw_mgr                  *hw_mgr = hw_mgr_priv;
 	struct cam_isp_tfe_query_cap_cmd        query_isp;
+	struct cam_isp_tfe_query_cap_cmd_v2    *query_isp_v2;
 
-	CAM_DBG(CAM_ISP, "enter");
+	query_size = sizeof(struct cam_isp_tfe_query_cap_cmd_v2) +
+		((CAM_TFE_CSID_HW_NUM_MAX - 1) * sizeof(struct cam_isp_tfe_dev_cap_info));
 
-	if (sizeof(struct cam_isp_tfe_query_cap_cmd) != query->size) {
-		CAM_ERR(CAM_ISP,
-			"Input query cap size:%u does not match expected query cap size: %u",
-			query->size, sizeof(struct cam_isp_tfe_query_cap_cmd));
-		return -EFAULT;
+	query_isp_v2 = kzalloc(query_size, GFP_KERNEL);
+
+	if (!query_isp_v2) {
+		CAM_ERR(CAM_ISP, "Mem alloc failed");
+		return -ENOMEM;
 	}
 
-	if (copy_from_user(&query_isp,
-		u64_to_user_ptr(query->caps_handle),
-		sizeof(struct cam_isp_tfe_query_cap_cmd))) {
-		rc = -EFAULT;
+	query_isp_v2->num_dev = CAM_TFE_CSID_HW_NUM_MAX;
+	rc = cam_tfe_mgr_get_hw_caps_internal(hw_mgr_priv, query_isp_v2);
+	if (rc) {
+		CAM_ERR(CAM_ISP, "Invalid num devs");
+		kfree(query_isp_v2);
 		return rc;
 	}
 
-	query_isp.device_iommu.non_secure = hw_mgr->mgr_common.img_iommu_hdl;
-	query_isp.device_iommu.secure = hw_mgr->mgr_common.img_iommu_hdl_secure;
-	query_isp.cdm_iommu.non_secure = hw_mgr->mgr_common.cmd_iommu_hdl;
-	query_isp.cdm_iommu.secure = hw_mgr->mgr_common.cmd_iommu_hdl_secure;
+	query_isp.device_iommu.non_secure = query_isp_v2->device_iommu.non_secure;
+	query_isp.device_iommu.secure = query_isp_v2->device_iommu.secure;
+	query_isp.cdm_iommu.non_secure = query_isp_v2->cdm_iommu.non_secure;
+	query_isp.cdm_iommu.secure = query_isp_v2->cdm_iommu.secure;
 
-	for (i = 0; i < CAM_TFE_CSID_HW_NUM_MAX; i++) {
+	for (i = 0; i < CAM_ISP_TFE_HW_MAX; i++) {
 		if (!hw_mgr->csid_devices[i])
 			continue;
+		query_isp.dev_caps[i] = query_isp_v2->dev_caps[i];
+	}
 
-		query_isp.dev_caps[i].hw_type = CAM_ISP_TFE_HW_TFE;
-		query_isp.dev_caps[i].hw_version.major = 5;
-		query_isp.dev_caps[i].hw_version.minor = 3;
-		query_isp.dev_caps[i].hw_version.incr = 0;
+	query_isp.num_dev = query_isp_v2->num_dev;
 
-		/*
-		 * device number is based on number of full tfe
-		 * if pix is not supported, set reserve to 1
-		 */
-		if (hw_mgr->tfe_csid_dev_caps[i].num_pix) {
-			query_isp.dev_caps[i].hw_version.reserved = 0;
-			num_dev++;
-		} else
-			query_isp.dev_caps[i].hw_version.reserved = 1;
+	if (copy_to_user(u64_to_user_ptr(query->caps_handle),
+		&query_isp, sizeof(struct cam_isp_tfe_query_cap_cmd))) {
+		CAM_ERR(CAM_ISP, "copy to user failed, query cap version %d", version);
+		kfree(query_isp_v2);
+		return -EFAULT;
 	}
 
-	query_isp.num_dev = num_dev;
+	kfree(query_isp_v2);
+	return rc;
+}
 
-	if (copy_to_user(u64_to_user_ptr(query->caps_handle),
-		&query_isp, sizeof(struct cam_isp_tfe_query_cap_cmd)))
+static int cam_tfe_mgr_get_hw_caps_v2(void *hw_mgr_priv,
+	void *hw_caps_args)
+{
+	int query_size, rc = 0;
+	struct cam_query_cap_cmd                *query = hw_caps_args;
+	struct cam_isp_tfe_query_cap_cmd_v2      tmp_query_isp_v2;
+	struct cam_isp_tfe_query_cap_cmd_v2     *query_isp_v2;
+
+	if (copy_from_user(&tmp_query_isp_v2, u64_to_user_ptr(query->caps_handle),
+		sizeof(tmp_query_isp_v2))) {
 		rc = -EFAULT;
+		return rc;
+	}
 
-	CAM_DBG(CAM_ISP, "exit rc :%d", rc);
+	if (tmp_query_isp_v2.version != CAM_QUERY_CAP_V2) {
+		CAM_ERR(CAM_ISP, "Query cap Version %d invalid", tmp_query_isp_v2.version);
+		return -EINVAL;
+	}
+
+	if (!tmp_query_isp_v2.num_dev) {
+		CAM_ERR(CAM_ISP, "Invalid Num of dev is %d query cap version %d",
+			tmp_query_isp_v2.num_dev, tmp_query_isp_v2.version);
+		rc = -EINVAL;
+		return rc;
+	}
+
+	query_size = sizeof(struct cam_isp_tfe_query_cap_cmd_v2) +
+		((tmp_query_isp_v2.num_dev - 1) * sizeof(struct cam_isp_tfe_dev_cap_info));
+
+	query_isp_v2 = kzalloc(query_size, GFP_KERNEL);
+
+	if (!query_isp_v2) {
+		CAM_ERR(CAM_ISP, "Mem alloc failed");
+		return -ENOMEM;
+	}
+
+	query_isp_v2->version = tmp_query_isp_v2.version;
+	query_isp_v2->num_dev = tmp_query_isp_v2.num_dev;
+
+	rc = cam_tfe_mgr_get_hw_caps_internal(hw_mgr_priv, query_isp_v2);
+	if (rc) {
+		CAM_ERR(CAM_ISP, "Invalid Num of dev is %d query cap version %d",
+			tmp_query_isp_v2.num_dev, tmp_query_isp_v2.version);
+		kfree(query_isp_v2);
+		return -EINVAL;
+	}
+
+	if (copy_to_user(u64_to_user_ptr(query->caps_handle), &query_isp_v2,
+		(sizeof(struct cam_isp_tfe_query_cap_cmd_v2) + ((query_isp_v2->num_dev - 1)
+		* sizeof(struct cam_isp_tfe_dev_cap_info))))) {
+		CAM_ERR(CAM_ISP, "copy to user failed, query cap version %d",
+			tmp_query_isp_v2.version);
+		kfree(query_isp_v2);
+		return -EFAULT;
+	}
 
+	kfree(query_isp_v2);
 	return rc;
 }
 
@@ -1731,7 +1822,7 @@ static int cam_tfe_mgr_acquire_hw_for_ctx(
 	cam_tfe_hw_mgr_preprocess_port(tfe_ctx, in_port, &ipp_count,
 		&rdi_count, &ppp_count, pdaf_enable, &lcr_enable);
 
-	if ((!ipp_count && !rdi_count && !ppp_count) || (!ipp_count && ppp_count)) {
+	if (!ipp_count && !rdi_count && !ppp_count) {
 		CAM_ERR(CAM_ISP,
 			"Invalid path count : Ipp %d ppp %d rdi %d",
 			ipp_count, ppp_count, rdi_count);
@@ -6470,7 +6561,7 @@ static int cam_tfe_hw_mgr_debug_register(void)
 
 	rc = cam_debugfs_create_subdir("tfe", &dbgfileptr);
 	if (rc) {
-		CAM_ERR(CAM_ISP,"DebugFS could not create directory!");
+		CAM_ERR(CAM_ISP, "DebugFS could not create directory!");
 		rc = -ENOENT;
 		goto end;
 	}
@@ -6694,6 +6785,7 @@ int cam_tfe_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
 	/* fill return structure */
 	hw_mgr_intf->hw_mgr_priv = &g_tfe_hw_mgr;
 	hw_mgr_intf->hw_get_caps = cam_tfe_mgr_get_hw_caps;
+	hw_mgr_intf->hw_get_caps_v2 = cam_tfe_mgr_get_hw_caps_v2;
 	hw_mgr_intf->hw_acquire = cam_tfe_mgr_acquire;
 	hw_mgr_intf->hw_start = cam_tfe_mgr_start_hw;
 	hw_mgr_intf->hw_stop = cam_tfe_mgr_stop_hw;

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

@@ -24,7 +24,7 @@
 #define CAM_ISP_BW_CONFIG_V1             1
 #define CAM_ISP_BW_CONFIG_V2             2
 #define CAM_ISP_BW_CONFIG_V3             3
-#define CAM_TFE_HW_NUM_MAX               3
+#define CAM_TFE_HW_NUM_MAX               4
 #define CAM_TFE_RDI_NUM_MAX              3
 #define CAM_IFE_SCRATCH_NUM_MAX          2
 #define CAM_IFE_BUS_COMP_NUM_MAX         18

+ 1 - 1
drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_tfe_csid_hw_intf.h

@@ -12,7 +12,7 @@
 #include "cam_tfe.h"
 
 /* MAX TFE CSID instance */
-#define CAM_TFE_CSID_HW_NUM_MAX                        3
+#define CAM_TFE_CSID_HW_NUM_MAX                        4
 #define CAM_TFE_CSID_RDI_MAX                           3
 
 /**

+ 1 - 1
drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_tfe_hw_intf.h

@@ -10,7 +10,7 @@
 #include "cam_isp_hw.h"
 #include "cam_cpas_api.h"
 
-#define CAM_TFE_HW_NUM_MAX            3
+#define CAM_TFE_HW_NUM_MAX            4
 #define TFE_CORE_BASE_IDX             0
 
 

+ 4 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid.c

@@ -33,6 +33,10 @@ static const struct of_device_id cam_tfe_csid_dt_match[] = {
 		.compatible = "qcom,csid770",
 		.data = &cam_tfe_csid770_hw_info,
 	},
+	{
+		.compatible = "qcom,csid-lite770",
+		.data = &cam_tfe_csid770_hw_info,
+	},
 	{}
 };
 

+ 4 - 1
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_bus.c

@@ -1403,7 +1403,10 @@ static int cam_tfe_bus_init_comp_grp(uint32_t index,
 	INIT_LIST_HEAD(&comp_grp->list);
 
 	comp_grp->res_id = index;
-	rsrc_data->comp_grp_id   = index;
+	if (bus_priv->common_data.is_lite)
+		rsrc_data->comp_grp_id   = hw_info->bus_client_reg[index].comp_group;
+	else
+		rsrc_data->comp_grp_id   = index;
 	rsrc_data->common_data   = &bus_priv->common_data;
 	rsrc_data->max_wm_per_comp_grp =
 		bus_priv->max_wm_per_comp_grp;

+ 10 - 6
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_lite770.h

@@ -70,6 +70,8 @@ static struct cam_tfe_top_reg_offset_common  tfe_lite770_top_commong_reg  = {
 	.diag_neq_hbi_shift                     = 14,
 	.diag_sensor_hbi_mask                   = 0x3FFF,
 	.serializer_supported                   = true,
+	.height_shift                           = 16,
+	.epoch_shift_val                        = 16,
 };
 
 static struct cam_tfe_rdi_reg  tfe_lite770_rdi0_reg = {
@@ -400,7 +402,7 @@ static struct cam_tfe_bus_hw_info  tfe_lite770_bus_hw_info = {
 			.irq_subsample_pattern = 0x00003934,
 			.framedrop_period      = 0x00003938,
 			.framedrop_pattern     = 0x0000393C,
-			.system_cache_cfg     = 0x00003960,
+			.system_cache_cfg      = 0x00003960,
 			.addr_status_0         = 0x00003968,
 			.addr_status_1         = 0x0000396C,
 			.addr_status_2         = 0x00003970,
@@ -408,7 +410,7 @@ static struct cam_tfe_bus_hw_info  tfe_lite770_bus_hw_info = {
 			.debug_status_cfg      = 0x00003978,
 			.debug_status_0        = 0x0000397C,
 			.debug_status_1        = 0x00003980,
-			.comp_group            = CAM_TFE_BUS_COMP_GRP_0,
+			.comp_group            = CAM_TFE_BUS_COMP_GRP_5,
 			.client_name           = "RDI0",
 		},
 		/* BUS Client 8 RDI1 */
@@ -429,7 +431,7 @@ static struct cam_tfe_bus_hw_info  tfe_lite770_bus_hw_info = {
 			.irq_subsample_pattern = 0x00003A34,
 			.framedrop_period      = 0x00003A38,
 			.framedrop_pattern     = 0x00003A3C,
-			.system_cache_cfg     = 0x00003A60,
+			.system_cache_cfg      = 0x00003A60,
 			.addr_status_0         = 0x00003A68,
 			.addr_status_1         = 0x00003A6C,
 			.addr_status_2         = 0x00003A70,
@@ -437,7 +439,7 @@ static struct cam_tfe_bus_hw_info  tfe_lite770_bus_hw_info = {
 			.debug_status_cfg      = 0x00003A78,
 			.debug_status_0        = 0x00003A7C,
 			.debug_status_1        = 0x00003A80,
-			.comp_group            = CAM_TFE_BUS_COMP_GRP_1,
+			.comp_group            = CAM_TFE_BUS_COMP_GRP_6,
 			.client_name           = "RDI1",
 		},
 		/* BUS Client 9 RDI2 */
@@ -458,7 +460,7 @@ static struct cam_tfe_bus_hw_info  tfe_lite770_bus_hw_info = {
 			.irq_subsample_pattern = 0x00003B34,
 			.framedrop_period      = 0x00003B38,
 			.framedrop_pattern     = 0x00003B3C,
-			.system_cache_cfg     = 0x00003B60,
+			.system_cache_cfg      = 0x00003B60,
 			.addr_status_0         = 0x00003B68,
 			.addr_status_1         = 0x00003B6C,
 			.addr_status_2         = 0x00003B70,
@@ -466,7 +468,7 @@ static struct cam_tfe_bus_hw_info  tfe_lite770_bus_hw_info = {
 			.debug_status_cfg      = 0x00003B78,
 			.debug_status_0        = 0x00003B7C,
 			.debug_status_1        = 0x00003B80,
-			.comp_group            = CAM_TFE_BUS_COMP_GRP_2,
+			.comp_group            = CAM_TFE_BUS_COMP_GRP_7,
 			.client_name           = "RDI2",
 		},
 	},
@@ -510,6 +512,8 @@ static struct cam_tfe_bus_hw_info  tfe_lite770_bus_hw_info = {
 	.support_consumed_addr = true,
 	.pdaf_rdi2_mux_en = false,
 	.rdi_width = 128,
+	.mode_cfg_shift = 16,
+	.height_shift = 16,
 };
 
 struct cam_tfe_hw_info cam_tfe_lite770 = {

+ 19 - 0
include/uapi/camera/media/cam_tfe.h

@@ -131,6 +131,25 @@ struct cam_isp_tfe_query_cap_cmd {
 	struct cam_isp_tfe_dev_cap_info dev_caps[CAM_ISP_TFE_HW_MAX];
 };
 
+/**
+ * struct cam_isp_tfe_query_cap_cmd_v2 - ISP TFE query device
+ * capability payload
+ *
+ * @version                     returned query cap cmd api version
+ * @num_dev:                    returned number of device capabilities
+ * @device_iommu:               returned iommu handles for device
+ * @cdm_iommu:                  returned iommu handles for cdm
+ * @dev_caps:                   returned device capability array
+ *
+ */
+struct cam_isp_tfe_query_cap_cmd_v2 {
+	__u32                           version;
+	__s32                           num_dev;
+	struct cam_iommu_handle         device_iommu;
+	struct cam_iommu_handle         cdm_iommu;
+	struct cam_isp_tfe_dev_cap_info dev_caps[1];
+};
+
 /* Acquire Device */
 /**
  * struct cam_isp_tfe_out_port_info - An output port resource info