Przeglądaj źródła

Merge "msm: camera: isp: Remove CPAS version check from IFE HW manager" into camera-kernel.lnx.5.0

Camera Software Integration 4 lat temu
rodzic
commit
1ef64946ef

+ 37 - 78
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -52,7 +52,7 @@ static uint32_t blob_type_hw_cmd_map[CAM_ISP_GENERIC_BLOB_TYPE_MAX] = {
 };
 
 static struct cam_ife_hw_mgr g_ife_hw_mgr;
-
+static uint32_t g_num_ife, g_num_ife_lite;
 static uint32_t max_ife_out_res;
 
 static int cam_ife_hw_mgr_event_handler(
@@ -2064,87 +2064,44 @@ err:
 	return rc;
 }
 
-static int cam_convert_hw_idx_to_ife_hw_num(int hw_idx)
+static inline void cam_ife_mgr_count_ife(void)
 {
-	uint32_t hw_version, rc = 0;
-
-	rc = cam_cpas_get_cpas_hw_version(&hw_version);
-	if (!rc) {
-		switch (hw_version) {
-		case CAM_CPAS_TITAN_170_V100:
-		case CAM_CPAS_TITAN_170_V110:
-		case CAM_CPAS_TITAN_170_V120:
-		case CAM_CPAS_TITAN_175_V100:
-		case CAM_CPAS_TITAN_175_V101:
-		case CAM_CPAS_TITAN_175_V120:
-		case CAM_CPAS_TITAN_175_V130:
-		case CAM_CPAS_TITAN_480_V100:
-			if (hw_idx == 0)
-				return CAM_ISP_IFE0_HW;
-			else if (hw_idx == 1)
-				return CAM_ISP_IFE1_HW;
-			else if (hw_idx == 2)
-				return CAM_ISP_IFE0_LITE_HW;
-			else if (hw_idx == 3)
-				return CAM_ISP_IFE1_LITE_HW;
-			else if (hw_idx == 4)
-				return CAM_ISP_IFE2_LITE_HW;
-			else if (hw_idx == 5)
-				return CAM_ISP_IFE3_LITE_HW;
-			else if (hw_idx == 6)
-				return CAM_ISP_IFE4_LITE_HW;
-			break;
-		case CAM_CPAS_TITAN_680_V100:
-			if (hw_idx == 0)
-				return CAM_ISP_IFE0_HW;
-			else if (hw_idx == 1)
-				return CAM_ISP_IFE1_HW;
-			else if (hw_idx == 2)
-				return CAM_ISP_IFE2_HW;
-			else if (hw_idx == 3)
-				return CAM_ISP_IFE0_LITE_HW;
-			else if (hw_idx == 4)
-				return CAM_ISP_IFE1_LITE_HW;
-			else if (hw_idx == 5)
-				return CAM_ISP_IFE2_LITE_HW;
-			else if (hw_idx == 6)
-				return CAM_ISP_IFE3_LITE_HW;
-			else if (hw_idx == 7)
-				return CAM_ISP_IFE4_LITE_HW;
-			break;
-		case CAM_CPAS_TITAN_580_V100:
-		case CAM_CPAS_TITAN_570_V200:
-		case CAM_CPAS_TITAN_165_V100:
-			if (hw_idx == 0)
-				return CAM_ISP_IFE0_HW;
-			else if (hw_idx == 1)
-				return CAM_ISP_IFE1_HW;
-			else if (hw_idx == 2)
-				return CAM_ISP_IFE2_HW;
-			else if (hw_idx == 3)
-				return CAM_ISP_IFE0_LITE_HW;
-			else if (hw_idx == 4)
-				return CAM_ISP_IFE1_LITE_HW;
-			break;
-		case CAM_CPAS_TITAN_170_V200:
-			if (hw_idx == 0)
-				return CAM_ISP_IFE0_HW;
-			else if (hw_idx == 1)
-				return CAM_ISP_IFE1_HW;
-			else if (hw_idx == 2)
-				return CAM_ISP_IFE2_HW;
-			else if (hw_idx == 3)
-				return CAM_ISP_IFE0_LITE_HW;
-			break;
-		default:
-			CAM_ERR(CAM_ISP, "Invalid hw_version: 0x%X",
-				hw_version);
-			rc = -EINVAL;
-			break;
+	int i;
+
+	g_num_ife = 0;
+	g_num_ife_lite = 0;
+
+	for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) {
+		if (g_ife_hw_mgr.ife_devices[i]) {
+			if (g_ife_hw_mgr.ife_dev_caps[i].is_lite)
+				g_num_ife_lite++;
+			else
+				g_num_ife++;
 		}
 	}
+	CAM_DBG(CAM_ISP, "counted %d IFE and %d IFE lite", g_num_ife, g_num_ife_lite);
+}
 
-	return rc;
+static int cam_convert_hw_idx_to_ife_hw_num(int hw_idx)
+{
+	if (hw_idx < g_num_ife) {
+		switch (hw_idx) {
+		case 0: return CAM_ISP_IFE0_HW;
+		case 1: return CAM_ISP_IFE1_HW;
+		case 2: return CAM_ISP_IFE2_HW;
+		}
+	} else if (hw_idx < g_num_ife_lite) {
+		switch (hw_idx - g_num_ife) {
+		case 0: return CAM_ISP_IFE0_LITE_HW;
+		case 1: return CAM_ISP_IFE1_LITE_HW;
+		case 2: return CAM_ISP_IFE2_LITE_HW;
+		case 3: return CAM_ISP_IFE3_LITE_HW;
+		case 4: return CAM_ISP_IFE4_LITE_HW;
+		}
+	} else {
+		CAM_ERR(CAM_ISP, "hw idx %d out-of-bounds", hw_idx);
+	}
+	return 0;
 }
 
 static int cam_convert_rdi_out_res_id_to_src(int res_id)
@@ -11440,6 +11397,8 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
 		*iommu_hdl = g_ife_hw_mgr.mgr_common.img_iommu_hdl;
 
 	cam_ife_hw_mgr_debug_register();
+	cam_ife_mgr_count_ife();
+
 	CAM_DBG(CAM_ISP, "Exit");
 
 	return 0;

+ 28 - 3
drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver4.c

@@ -1128,10 +1128,33 @@ static int cam_vfe_top_ver4_get_data(
 	return -EINVAL;
 }
 
-int cam_vfe_top_ver4_get_hw_caps(void *device_priv,
-	void *get_hw_cap_args, uint32_t arg_size)
+int cam_vfe_top_ver4_get_hw_caps(void *device_priv, void *args, uint32_t arg_size)
 {
-	return -EPERM;
+	struct cam_vfe_hw_get_hw_cap *vfe_cap_info = NULL;
+	struct cam_vfe_top_ver4_priv *vfe_top_prv = NULL;
+	struct cam_vfe_soc_private *soc_priv = NULL;
+
+	if (!device_priv || !args) {
+		CAM_ERR(CAM_ISP, "Invalid arguments device_priv:%p, args:%p", device_priv, args);
+		return -EINVAL;
+	}
+
+	vfe_cap_info = args;
+	vfe_top_prv = device_priv;
+
+	if (!vfe_top_prv->common_data.soc_info) {
+		CAM_ERR(CAM_ISP, "soc info is null");
+		return -EFAULT;
+	}
+
+	soc_priv = (struct cam_vfe_soc_private *)vfe_top_prv->common_data.soc_info->soc_private;
+
+	vfe_cap_info->is_lite = soc_priv->is_ife_lite;
+	vfe_cap_info->incr    = (vfe_top_prv->top_common.hw_version) & 0x00ffff;
+	vfe_cap_info->minor   = ((vfe_top_prv->top_common.hw_version) >> 16) & 0x0fff;
+	vfe_cap_info->major   = (vfe_top_prv->top_common.hw_version) >> 28;
+
+	return 0;
 }
 
 int cam_vfe_top_ver4_init_hw(void *device_priv,
@@ -1160,6 +1183,8 @@ int cam_vfe_top_ver4_init_hw(void *device_priv,
 	cam_soc_util_w_mb(common_data.soc_info, VFE_CORE_BASE_IDX,
 		common_data.common_reg->noc_cgc_ovd, 0x0);
 
+	top_priv->top_common.hw_version = cam_io_r_mb(common_data.soc_info->reg_map[0].mem_base +
+		common_data.common_reg->hw_version);
 	return 0;
 }