Explorar el Código

Merge "msm: camera: isp: Add support to dump reserved TPGv3 VC DT" into camera-kernel.lnx.5.0

Haritha Chintalapati hace 4 años
padre
commit
1e788374af

+ 42 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_core.c

@@ -17,6 +17,8 @@
 #include "cam_top_tpg_ver2.h"
 #include "cam_top_tpg_ver3.h"
 
+struct cam_top_tpg_debugfs tpg_debug = {0};
+
 int cam_top_tpg_get_format(
 	uint32_t                                     in_format,
 	uint32_t                                    *tpg_encode_format)
@@ -50,6 +52,43 @@ int cam_top_tpg_get_format(
 	return rc;
 }
 
+int cam_top_tpg_debug_register(void)
+{
+	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
+
+	if (tpg_debug.root) {
+		CAM_DBG(CAM_ISP, "Debugfs root already created");
+		return 0;
+	}
+
+	dbgfileptr = debugfs_create_dir("camera_tpg", NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_ISP, "DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
+	}
+
+	tpg_debug.root = dbgfileptr;
+
+	dbgfileptr = debugfs_create_bool("enable_vcdt_dump", 0644,
+		tpg_debug.root, &tpg_debug.enable_vcdt_dump);
+
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_ISP, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
+	}
+end:
+	return rc;
+}
+
+const struct cam_top_tpg_debugfs* cam_top_tpg_get_debugfs(void)
+{
+	return &tpg_debug;
+}
+
 static int cam_top_tpg_init_hw(void *hw_priv,
 	void *init_args, uint32_t arg_size)
 {
@@ -333,5 +372,8 @@ int cam_top_tpg_deinit(struct cam_top_tpg_hw *top_tpg_hw)
 	kfree(top_tpg_hw->tpg_res.res_priv);
 	cam_top_tpg_deinit_soc_resources(&top_tpg_hw->hw_info->soc_info);
 
+	debugfs_remove_recursive(tpg_debug.root);
+	tpg_debug.root = NULL;
+
 	return 0;
 }

+ 15 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_core.h

@@ -164,6 +164,21 @@ struct cam_top_tpg_hw {
 	struct completion                tpg_complete;
 };
 
+/**
+ * struct cam_top_tpg_debugfs- debugfs structure for TPG
+ *
+ * @root:                  A pointer to a root directory for debugfs
+ * @enable_vcdt_dump:      A flag to indicate if the VCDT dump is enabled
+ *
+ */
+struct cam_top_tpg_debugfs {
+	struct dentry *root;
+	bool enable_vcdt_dump;
+};
+
+int cam_top_tpg_debug_register(void);
+const struct cam_top_tpg_debugfs* cam_top_tpg_get_debugfs(void);
+
 int cam_top_tpg_get_format(uint32_t    in_format, uint32_t *tpg_encode_format);
 
 int cam_top_tpg_probe_init(struct cam_hw_intf *tpg_hw_intf,

+ 36 - 1
drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_ver3.c

@@ -47,6 +47,34 @@ static int cam_top_tpg_ver3_get_hw_caps(
 	return rc;
 }
 
+static int cam_top_tpg_ver3_print_reserved_vcdt(
+	struct cam_top_tpg_hw                  *tpg_hw)
+{
+	struct cam_top_tpg_cfg_v2              *tpg_data;
+	int                                     i, j;
+
+	if (!tpg_hw)
+		return -EINVAL;
+
+	tpg_data = (struct cam_top_tpg_cfg_v2 *)tpg_hw->tpg_res.res_priv;
+	CAM_INFO(CAM_ISP, "tpg:%d Active_VCs: %d",
+		tpg_hw->hw_intf->hw_idx, tpg_data->num_active_vcs);
+
+	for (i = 0; i < tpg_data->num_active_vcs; i++)
+	{
+		CAM_INFO(CAM_ISP, "VC[%d]: 0x%x", i, tpg_data->vc_dt[i].vc_num);
+
+		for (j = 0; j < tpg_data->vc_dt[i].num_active_dts; j++)
+		{
+			CAM_INFO(CAM_ISP, "DT[%d]: 0x%x", j,
+				tpg_data->vc_dt[i].dt_cfg[j].data_type);
+		}
+	}
+
+	return 0;
+}
+
+
 static int cam_top_tpg_ver3_process_cmd(void *hw_priv,
 	uint32_t cmd_type, void *cmd_args, uint32_t arg_size)
 {
@@ -207,9 +235,10 @@ static int cam_top_tpg_ver3_reserve(
 	struct cam_hw_info                           *tpg_hw_info;
 	struct cam_top_tpg_reserve_args              *reserv;
 	struct cam_top_tpg_cfg_v2                    *tpg_data;
-	uint32_t                                      num_active_vcs = 0;
 	struct cam_top_tpg_vc_dt_info
 		in_port_vc_dt[CAM_TOP_TPG_MAX_SUPPORTED_VC];
+	const struct cam_top_tpg_debugfs             *tpg_debug = NULL;
+	uint32_t                                      num_active_vcs = 0;
 	int                                           i;
 
 	if (!hw_priv || !reserve_args || (arg_size !=
@@ -224,6 +253,8 @@ static int cam_top_tpg_ver3_reserve(
 
 	mutex_lock(&tpg_hw->hw_info->hw_mutex);
 
+	tpg_debug = cam_top_tpg_get_debugfs();
+
 	if ((reserv->in_port[0]->lane_num <= 0 ||
 		reserv->in_port[0]->lane_num > 4) ||
 		(reserv->in_port[0]->lane_type >= 2)) {
@@ -292,6 +323,8 @@ static int cam_top_tpg_ver3_reserve(
 	reserv->node_res = &tpg_hw->tpg_res;
 	tpg_hw->tpg_res.res_state = CAM_ISP_RESOURCE_STATE_RESERVED;
 error:
+	if ((tpg_debug != NULL) && tpg_debug->enable_vcdt_dump)
+		cam_top_tpg_ver3_print_reserved_vcdt(tpg_hw);
 	mutex_unlock(&tpg_hw->hw_info->hw_mutex);
 	CAM_DBG(CAM_ISP, "exit rc %u", rc);
 
@@ -536,5 +569,7 @@ int cam_top_tpg_ver3_init(
 	tpg_hw->hw_intf->hw_ops.start       = cam_top_tpg_ver3_start;
 	tpg_hw->hw_intf->hw_ops.stop        = cam_top_tpg_ver3_stop;
 	tpg_hw->hw_intf->hw_ops.process_cmd = cam_top_tpg_ver3_process_cmd;
+
+	cam_top_tpg_debug_register();
 	return 0;
 }