msm: camera: tfe: Multiple fixes for TFE Lite

Increase count of maximum number of TFE HW supported and
corrected WM composite group number.

CRs-Fixed: 3426117
Change-Id: I4cf91bb92772c5be5a56783228c694fedf6c5ec7
Signed-off-by: Ayush Kumar <quic_ayushkr@quicinc.com>
This commit is contained in:
Ayush Kumar
2023-04-06 10:47:44 +05:30
committed by Alok Chauhan
parent 3e0200a7c2
commit ed703b3236
8 changed files with 170 additions and 48 deletions

View File

@@ -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;
struct cam_query_cap_cmd *query = hw_caps_args;
struct cam_isp_tfe_query_cap_cmd query_isp;
CAM_DBG(CAM_ISP, "enter");
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;
}
if (copy_from_user(&query_isp,
u64_to_user_ptr(query->caps_handle),
sizeof(struct cam_isp_tfe_query_cap_cmd))) {
rc = -EFAULT;
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 = 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])
continue;
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 = 5;
query_isp.dev_caps[i].hw_version.minor = 3;
query_isp.dev_caps[i].hw_version.incr = 0;
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;
query_isp->dev_caps[i].hw_version.reserved = 0;
num_dev++;
} else
query_isp.dev_caps[i].hw_version.reserved = 1;
} else {
query_isp->dev_caps[i].hw_version.reserved = 1;
}
}
query_isp.num_dev = num_dev;
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;
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));
query_isp_v2 = kzalloc(query_size, GFP_KERNEL);
if (!query_isp_v2) {
CAM_ERR(CAM_ISP, "Mem alloc failed");
return -ENOMEM;
}
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 = 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_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.num_dev = query_isp_v2->num_dev;
if (copy_to_user(u64_to_user_ptr(query->caps_handle),
&query_isp, sizeof(struct cam_isp_tfe_query_cap_cmd)))
&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;
}
kfree(query_isp_v2);
return rc;
}
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);
@@ -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;

View File

@@ -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

View File

@@ -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
/**

View File

@@ -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

View File

@@ -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,
},
{}
};

View File

@@ -1403,6 +1403,9 @@ static int cam_tfe_bus_init_comp_grp(uint32_t index,
INIT_LIST_HEAD(&comp_grp->list);
comp_grp->res_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 =

View File

@@ -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 = {
@@ -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 */
@@ -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 */
@@ -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 = {

View File

@@ -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