From f9c48bc48b28e21b905ac3860326e820b38092ae Mon Sep 17 00:00:00 2001 From: Li Sha Lim Date: Thu, 10 Nov 2022 17:57:32 -0800 Subject: [PATCH] msm: camera: isp: Add new v4l2 tfe subdev This change registers tfe on v980 as an mc_tfe device for userspace to enumerate. CRs-Fixed: 3321317 Change-Id: Ic7810dc198aece0d1d0fa50e547f69c72218d49a Signed-off-by: Li Sha Lim --- drivers/cam_isp/cam_isp_context.c | 1 + drivers/cam_isp/cam_isp_dev.c | 8 +++++++- drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c | 9 +++++++-- drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h | 8 +++++++- drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c | 8 +++++--- drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h | 3 ++- 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/cam_isp/cam_isp_context.c b/drivers/cam_isp/cam_isp_context.c index 68d75da81d..8c58e644c3 100644 --- a/drivers/cam_isp/cam_isp_context.c +++ b/drivers/cam_isp/cam_isp_context.c @@ -1183,6 +1183,7 @@ static const char *__cam_isp_resource_handle_id_to_type( { switch (device_type) { case CAM_IFE_DEVICE_TYPE: + case CAM_TFE_MC_DEVICE_TYPE: return __cam_isp_ife_sfe_resource_handle_id_to_type(resource_handle); case CAM_TFE_DEVICE_TYPE: return __cam_isp_tfe_resource_handle_id_to_type(resource_handle); diff --git a/drivers/cam_isp/cam_isp_dev.c b/drivers/cam_isp/cam_isp_dev.c index 079f4ae242..50fc0a96aa 100644 --- a/drivers/cam_isp/cam_isp_dev.c +++ b/drivers/cam_isp/cam_isp_dev.c @@ -162,6 +162,11 @@ static int cam_isp_dev_component_bind(struct device *dev, CAM_IFE_DEVICE_TYPE); g_isp_dev.isp_device_type = CAM_IFE_DEVICE_TYPE; g_isp_dev.max_context = CAM_IFE_CTX_MAX; + } else if (strnstr(compat_str, "mc_tfe", strlen(compat_str))) { + rc = cam_subdev_probe(&g_isp_dev.sd, pdev, CAM_ISP_DEV_NAME, + CAM_TFE_MC_DEVICE_TYPE); + g_isp_dev.isp_device_type = CAM_TFE_MC_DEVICE_TYPE; + g_isp_dev.max_context = CAM_IFE_CTX_MAX; } else if (strnstr(compat_str, "tfe", strlen(compat_str))) { rc = cam_subdev_probe(&g_isp_dev.sd, pdev, CAM_ISP_DEV_NAME, CAM_TFE_DEVICE_TYPE); @@ -200,7 +205,8 @@ static int cam_isp_dev_component_bind(struct device *dev, goto unregister; } - rc = cam_isp_hw_mgr_init(compat_str, &hw_mgr_intf, &iommu_hdl); + rc = cam_isp_hw_mgr_init(compat_str, &hw_mgr_intf, &iommu_hdl, + g_isp_dev.isp_device_type); if (rc != 0) { CAM_ERR(CAM_ISP, "Can not initialized ISP HW manager!"); goto kfree; diff --git a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c index 2f83ae32ff..7ad9366c17 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c +++ b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c @@ -609,7 +609,9 @@ static int cam_ife_mgr_get_hw_caps(void *hw_mgr_priv, void *hw_caps_args) &query_isp.dev_caps[query_isp.num_dev]; query_isp.num_dev++; - ife_full_hw_info->hw_type = CAM_ISP_HW_IFE; + ife_full_hw_info->hw_type = (hw_mgr->isp_device_type + == CAM_TFE_MC_DEVICE_TYPE) ? + CAM_ISP_HW_MC_TFE : CAM_ISP_HW_IFE; ife_full_hw_info->hw_version.major = hw_mgr->ife_dev_caps[i].major; ife_full_hw_info->hw_version.minor = @@ -15373,7 +15375,8 @@ static int cam_ife_mgr_populate_sys_cache_id(void) } -int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl) +int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl, + uint32_t isp_device_type) { int rc = -EFAULT; int i, j; @@ -15458,6 +15461,8 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl) } g_ife_hw_mgr.path_port_map.num_entries = path_port_map.num_entries; + g_ife_hw_mgr.isp_device_type = isp_device_type; + /* fill csid hw intf information */ for (i = 0, j = 0; i < CAM_IFE_CSID_HW_NUM_MAX; i++) { rc = cam_ife_csid_hw_init(&g_ife_hw_mgr.csid_devices[i], i); diff --git a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h index 74d75f07a4..23235635ad 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h +++ b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h @@ -473,6 +473,8 @@ struct cam_isp_sfe_cache_info { * @num_caches_found Number of caches supported * @sys_cache_info Sys cache info * @sfe_cache_info SFE Cache Info + * @isp_device_type: If device supports single-context(ife) or multi- + * context(mc_tfe) */ struct cam_ife_hw_mgr { struct cam_isp_hw_mgr mgr_common; @@ -505,6 +507,7 @@ struct cam_ife_hw_mgr { uint32_t num_caches_found; struct cam_isp_sys_cache_info sys_cache_info[CAM_LLCC_MAX]; struct cam_isp_sfe_cache_info sfe_cache_info[CAM_SFE_HW_NUM_MAX]; + uint32_t isp_device_type; }; /** @@ -590,9 +593,12 @@ struct cam_ife_hw_mini_dump_data { * * @hw_mgr_intf: IFE hardware manager object returned * @iommu_hdl: Iommu handle to be returned + * @isp_device_type: If device supports single-context(ife) or multi- + * context(mc_tfe) * */ -int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl); +int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl, + uint32_t isp_device_type); void cam_ife_hw_mgr_deinit(void); #endif /* _CAM_IFE_HW_MGR_H_ */ diff --git a/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c b/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c index e68fd557a3..2fada4c84f 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c +++ b/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include "cam_isp_hw_mgr_intf.h" @@ -10,12 +11,13 @@ int cam_isp_hw_mgr_init(const char *device_name_str, - struct cam_hw_mgr_intf *hw_mgr, int *iommu_hdl) + struct cam_hw_mgr_intf *hw_mgr, int *iommu_hdl, uint32_t isp_device_type) { int rc = 0; - if (strnstr(device_name_str, "ife", strlen(device_name_str))) - rc = cam_ife_hw_mgr_init(hw_mgr, iommu_hdl); + if (strnstr(device_name_str, "ife", strlen(device_name_str)) || + strnstr(device_name_str, "mc_tfe", strlen(device_name_str))) + rc = cam_ife_hw_mgr_init(hw_mgr, iommu_hdl, isp_device_type); else if (strnstr(device_name_str, "tfe", strlen(device_name_str))) rc = cam_tfe_hw_mgr_init(hw_mgr, iommu_hdl); else { diff --git a/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h b/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h index 092fb28a44..0a86f600f0 100644 --- a/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h +++ b/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h @@ -453,9 +453,10 @@ struct cam_isp_lcr_rdi_cfg_args { * @hw_mgr: Input/output structure for the ISP hardware manager * initialization * @iommu_hdl: Iommu handle to be returned + * @isp_device_type: ISP device type */ int cam_isp_hw_mgr_init(const char *device_name_str, - struct cam_hw_mgr_intf *hw_mgr, int *iommu_hdl); + struct cam_hw_mgr_intf *hw_mgr, int *iommu_hdl, uint32_t isp_device_type); void cam_isp_hw_mgr_deinit(const char *device_name_str);