Pārlūkot izejas kodu

Merge "msm: camera: tfe: No Camera and Limited Camera Support" into camera-kernel.lnx.7.0

Camera Software Integration 1 gadu atpakaļ
vecāks
revīzija
8ca826a179

+ 44 - 1
drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/slab.h>
@@ -16,6 +16,7 @@
 #include "cam_isp_hw.h"
 #include "cam_tfe_csid_hw_intf.h"
 #include "cam_tfe_hw_intf.h"
+#include "cam_tfe_soc.h"
 #include "cam_isp_packet_parser.h"
 #include "cam_tfe_hw_mgr.h"
 #include "cam_cdm_intf_api.h"
@@ -41,6 +42,8 @@
 #define SMMU_SE_TFE 0
 
 static struct cam_tfe_hw_mgr g_tfe_hw_mgr;
+static uint32_t g_num_tfe_available, g_num_tfe_functional;
+static uint32_t g_num_tfe_lite_available, g_num_tfe_lite_functional;
 
 static int cam_tfe_hw_mgr_event_handler(
 	void                                *priv,
@@ -546,6 +549,32 @@ static void cam_tfe_hw_mgr_deinit_hw(
 	ctx->init_done = false;
 }
 
+static inline void cam_tfe_mgr_count_functional_tfe(void)
+{
+	int i;
+	struct cam_hw_info *tfe_hw;
+	struct cam_tfe_soc_private *soc_private;
+
+	g_num_tfe_functional = 0;
+	g_num_tfe_lite_functional = 0;
+
+	for (i = 0; i < CAM_TFE_HW_NUM_MAX; i++) {
+		if (g_tfe_hw_mgr.tfe_devices[i]) {
+			tfe_hw = (struct cam_hw_info *)
+				g_tfe_hw_mgr.tfe_devices[i]->hw_intf->hw_priv;
+			soc_private = tfe_hw->soc_info.soc_private;
+
+			if (soc_private->is_tfe_lite)
+				g_num_tfe_lite_functional++;
+			else
+				g_num_tfe_functional++;
+		}
+	}
+
+	CAM_DBG(CAM_ISP, "counted functional %u TFEs and %u TFE-LITEs", g_num_tfe_functional,
+		g_num_tfe_lite_functional);
+}
+
 static int cam_tfe_hw_mgr_init_hw(
 	struct cam_tfe_hw_mgr_ctx *ctx)
 {
@@ -7246,6 +7275,20 @@ int cam_tfe_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
 		*iommu_hdl = g_tfe_hw_mgr.mgr_common.img_iommu_hdl;
 
 	cam_tfe_hw_mgr_debug_register();
+	cam_tfe_mgr_count_functional_tfe();
+
+	cam_tfe_get_num_tfe_hws(&g_num_tfe_available);
+	rc = cam_cpas_prepare_subpart_info(CAM_IFE_HW_IDX, g_num_tfe_available,
+		g_num_tfe_functional);
+	if (rc)
+		CAM_ERR(CAM_ISP, "Failed to populate num_ifes, rc: %d", rc);
+
+	cam_tfe_get_num_tfe_lite_hws(&g_num_tfe_lite_available);
+	rc = cam_cpas_prepare_subpart_info(CAM_IFE_LITE_HW_IDX, g_num_tfe_lite_available,
+		g_num_tfe_lite_functional);
+	if (rc)
+		CAM_ERR(CAM_ISP, "Failed to populate num_ife_lites, rc: %d", rc);
+
 	CAM_DBG(CAM_ISP, "Exit");
 
 	return 0;

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

@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef _CAM_TFE_HW_INTF_H_
@@ -248,6 +248,24 @@ struct cam_tfe_irq_evt_payload {
 	uint32_t                   last_consumed_addr;
 };
 
+/*
+ * cam_tfe_get_num_tfe_hws()
+ *
+ * @brief:         Gets number of TFEs
+ *
+ * @num_tfes:      Fills number of TFES in the address passed
+ */
+void cam_tfe_get_num_tfe_hws(uint32_t *num_tfes);
+
+/*
+ * cam_tfe_get_num_tfe_lite_hws()
+ *
+ * @brief:         Gets number of TFE-LITEs
+ *
+ * @num_tfe_lites: Fills number of TFE-LITEs in the address passed
+ */
+void cam_tfe_get_num_tfe_lite_hws(uint32_t *num_tfe_lites);
+
 /*
  * cam_tfe_hw_init()
  *

+ 10 - 5
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_dev.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/slab.h>
@@ -27,17 +27,22 @@ static int cam_tfe_csid_component_bind(struct device *dev,
 	struct cam_tfe_csid_hw         *csid_dev = NULL;
 	const struct of_device_id      *match_dev = NULL;
 	struct cam_tfe_csid_hw_info    *csid_hw_data = NULL;
-	uint32_t                        csid_dev_idx;
+	uint32_t                        csid_dev_idx = 0;
 	int                             rc = 0;
 	struct platform_device *pdev = to_platform_device(dev);
 
 	CAM_DBG(CAM_ISP, "probe called");
 
 	/* get tfe csid hw index */
-	of_property_read_u32(pdev->dev.of_node, "cell-index", &csid_dev_idx);
+	rc = of_property_read_u32(pdev->dev.of_node, "cell-index", &csid_dev_idx);
+	if (rc) {
+		CAM_ERR(CAM_ISP, "Failed to read cell-index of TFE CSID HW, rc: %d", rc);
+		goto err;
+	}
 
-	if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_LITE_FUSE, BIT(csid_dev_idx), NULL)) {
-		CAM_DBG(CAM_ISP, "CSID:%d is not supported", csid_dev_idx);
+	if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_FUSE, BIT(csid_dev_idx), NULL) ||
+		!cam_cpas_is_feature_supported(CAM_CPAS_ISP_LITE_FUSE, BIT(csid_dev_idx), NULL)) {
+		CAM_DBG(CAM_ISP, "CSID[%d] not supported based on fuse", csid_dev_idx);
 		goto err;
 	}
 

+ 43 - 5
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_dev.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/slab.h>
@@ -16,6 +16,7 @@
 #include "cam_cpas_api.h"
 
 static struct cam_isp_hw_intf_data  cam_tfe_hw_list[CAM_TFE_HW_NUM_MAX];
+static uint32_t g_num_tfe_hws, g_num_tfe_lite_hws;
 
 static int cam_tfe_component_bind(struct device *dev,
 	struct device *master_dev, void *data)
@@ -33,11 +34,15 @@ static int cam_tfe_component_bind(struct device *dev,
 
 	CAM_DBG(CAM_ISP, "probe called");
 
-	of_property_read_u32(pdev->dev.of_node,
-		"cell-index", &tfe_hw_idx);
+	rc = of_property_read_u32(pdev->dev.of_node, "cell-index", &tfe_hw_idx);
+	if (rc) {
+		CAM_ERR(CAM_ISP, "Failed to read cell-index of TFE HW, rc: %d", rc);
+		goto end;
+	}
 
-	if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_LITE_FUSE, BIT(tfe_hw_idx), NULL)) {
-		CAM_DBG(CAM_ISP, "TFE:%d is not supported", tfe_hw_idx);
+	if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_FUSE, BIT(tfe_hw_idx), NULL) ||
+		!cam_cpas_is_feature_supported(CAM_CPAS_ISP_LITE_FUSE, BIT(tfe_hw_idx), NULL)) {
+		CAM_DBG(CAM_ISP, "TFE[%d] not supported based on fuse", tfe_hw_idx);
 		goto end;
 	}
 
@@ -207,11 +212,44 @@ const static struct component_ops cam_tfe_component_ops = {
 	.unbind = cam_tfe_component_unbind,
 };
 
+void cam_tfe_get_num_tfe_hws(uint32_t *num_tfes)
+{
+	if (num_tfes)
+		*num_tfes = g_num_tfe_hws;
+	else
+		CAM_ERR(CAM_ISP, "Invalid argument, g_num_tfe_hws: %u", g_num_tfe_hws);
+}
+
+void cam_tfe_get_num_tfe_lite_hws(uint32_t *num_tfe_lites)
+{
+	if (num_tfe_lites)
+		*num_tfe_lites = g_num_tfe_lite_hws;
+	else
+		CAM_ERR(CAM_ISP, "Invalid argument, g_num_tfe_lite_hws: %u", g_num_tfe_lite_hws);
+}
+
 int cam_tfe_probe(struct platform_device *pdev)
 {
 	int rc = 0;
+	const char *compatible_name;
+	struct device_node *of_node = NULL;
 
 	CAM_DBG(CAM_ISP, "Adding TFE component");
+
+	of_node = pdev->dev.of_node;
+
+	rc = of_property_read_string_index(of_node, "compatible", 0,
+		(const char **)&compatible_name);
+	if (rc)
+		CAM_ERR(CAM_ISP, "No compatible string present for: %s, rc: %d", pdev->name, rc);
+
+	if (strnstr(compatible_name, "lite", strlen(compatible_name)) != NULL)
+		g_num_tfe_lite_hws++;
+	else if (strnstr(compatible_name, "tfe", strlen(compatible_name)) != NULL)
+		g_num_tfe_hws++;
+	else
+		CAM_ERR(CAM_ISP, "Failed to increement number of TFEs/TFE-LITEs");
+
 	rc = component_add(&pdev->dev, &cam_tfe_component_ops);
 	if (rc)
 		CAM_ERR(CAM_ISP, "failed to add component rc: %d", rc);