Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d03757cd authored by Shubhraprakash Das's avatar Shubhraprakash Das Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: lrme: Fix the unpack config and add dump function



Fix unpack config in fetch engine and add dump function.
adb shell "echo 1 > /sys/kernel/debug/camera_lrme/dump_register"
to dump register when reg update irq is received.

Signed-off-by: default avatarShubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: default avatarJunzhe Zou <jnzhezou@codeaurora.org>
Change-Id: I9ff9843df6cb881a2a0080b852ae376d42a00ed0
parent 135c40c8
Loading
Loading
Loading
Loading
+8 −6
Original line number Original line Diff line number Diff line
@@ -25,7 +25,7 @@ static int __cam_lrme_ctx_acquire_dev_in_available(struct cam_context *ctx,
	uint64_t ctxt_to_hw_map = (uint64_t)ctx->ctxt_to_hw_map;
	uint64_t ctxt_to_hw_map = (uint64_t)ctx->ctxt_to_hw_map;
	struct cam_lrme_context *lrme_ctx = ctx->ctx_priv;
	struct cam_lrme_context *lrme_ctx = ctx->ctx_priv;


	CAM_DBG(CAM_LRME, "Enter");
	CAM_DBG(CAM_LRME, "Enter ctx %d", ctx->ctx_id);


	rc = cam_context_acquire_dev_to_hw(ctx, cmd);
	rc = cam_context_acquire_dev_to_hw(ctx, cmd);
	if (rc) {
	if (rc) {
@@ -46,7 +46,7 @@ static int __cam_lrme_ctx_release_dev_in_acquired(struct cam_context *ctx,
{
{
	int rc = 0;
	int rc = 0;


	CAM_DBG(CAM_LRME, "Enter");
	CAM_DBG(CAM_LRME, "Enter ctx %d", ctx->ctx_id);


	rc = cam_context_release_dev_to_hw(ctx, cmd);
	rc = cam_context_release_dev_to_hw(ctx, cmd);
	if (rc) {
	if (rc) {
@@ -64,7 +64,7 @@ static int __cam_lrme_ctx_start_dev_in_acquired(struct cam_context *ctx,
{
{
	int rc = 0;
	int rc = 0;


	CAM_DBG(CAM_LRME, "Enter");
	CAM_DBG(CAM_LRME, "Enter ctx %d", ctx->ctx_id);


	rc = cam_context_start_dev_to_hw(ctx, cmd);
	rc = cam_context_start_dev_to_hw(ctx, cmd);
	if (rc) {
	if (rc) {
@@ -82,7 +82,7 @@ static int __cam_lrme_ctx_config_dev_in_activated(struct cam_context *ctx,
{
{
	int rc;
	int rc;


	CAM_DBG(CAM_LRME, "Enter");
	CAM_DBG(CAM_LRME, "Enter ctx %d", ctx->ctx_id);


	rc = cam_context_prepare_dev_to_hw(ctx, cmd);
	rc = cam_context_prepare_dev_to_hw(ctx, cmd);
	if (rc) {
	if (rc) {
@@ -98,6 +98,8 @@ static int __cam_lrme_ctx_flush_dev_in_activated(struct cam_context *ctx,
{
{
	int rc;
	int rc;


	CAM_DBG(CAM_LRME, "Enter ctx %d", ctx->ctx_id);

	rc = cam_context_flush_dev_to_hw(ctx, cmd);
	rc = cam_context_flush_dev_to_hw(ctx, cmd);
	if (rc)
	if (rc)
		CAM_ERR(CAM_LRME, "Failed to flush device");
		CAM_ERR(CAM_LRME, "Failed to flush device");
@@ -109,7 +111,7 @@ static int __cam_lrme_ctx_stop_dev_in_activated(struct cam_context *ctx,
{
{
	int rc = 0;
	int rc = 0;


	CAM_DBG(CAM_LRME, "Enter");
	CAM_DBG(CAM_LRME, "Enter ctx %d", ctx->ctx_id);


	rc = cam_context_stop_dev_to_hw(ctx);
	rc = cam_context_stop_dev_to_hw(ctx);
	if (rc) {
	if (rc) {
@@ -127,7 +129,7 @@ static int __cam_lrme_ctx_release_dev_in_activated(struct cam_context *ctx,
{
{
	int rc = 0;
	int rc = 0;


	CAM_DBG(CAM_LRME, "Enter");
	CAM_DBG(CAM_LRME, "Enter ctx %d", ctx->ctx_id);


	rc = __cam_lrme_ctx_stop_dev_in_activated(ctx, NULL);
	rc = __cam_lrme_ctx_stop_dev_in_activated(ctx, NULL);
	if (rc) {
	if (rc) {
+37 −0
Original line number Original line Diff line number Diff line
@@ -765,6 +765,12 @@ static int cam_lrme_mgr_hw_start(void *hw_mgr_priv, void *hw_start_args)
		return -EINVAL;
		return -EINVAL;
	}
	}


	rc = hw_device->hw_intf.hw_ops.process_cmd(
			hw_device->hw_intf.hw_priv,
			CAM_LRME_HW_CMD_DUMP_REGISTER,
			&g_lrme_hw_mgr.debugfs_entry.dump_register,
			sizeof(bool));

	return rc;
	return rc;
}
}


@@ -963,6 +969,35 @@ static int cam_lrme_mgr_hw_config(void *hw_mgr_priv,
	return rc;
	return rc;
}
}


static int cam_lrme_mgr_create_debugfs_entry(void)
{
	int rc = 0;

	g_lrme_hw_mgr.debugfs_entry.dentry =
		debugfs_create_dir("camera_lrme", NULL);
	if (!g_lrme_hw_mgr.debugfs_entry.dentry) {
		CAM_ERR(CAM_LRME, "failed to create dentry");
		return -ENOMEM;
	}

	if (!debugfs_create_bool("dump_register",
		0644,
		g_lrme_hw_mgr.debugfs_entry.dentry,
		&g_lrme_hw_mgr.debugfs_entry.dump_register)) {
		CAM_ERR(CAM_LRME, "failed to create dump register entry");
		rc = -ENOMEM;
		goto err;
	}

	return rc;

err:
	debugfs_remove_recursive(g_lrme_hw_mgr.debugfs_entry.dentry);
	g_lrme_hw_mgr.debugfs_entry.dentry = NULL;
	return rc;
}


int cam_lrme_mgr_register_device(
int cam_lrme_mgr_register_device(
	struct cam_hw_intf *lrme_hw_intf,
	struct cam_hw_intf *lrme_hw_intf,
	struct cam_iommu_handle *device_iommu,
	struct cam_iommu_handle *device_iommu,
@@ -1113,6 +1148,8 @@ int cam_lrme_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf,


	g_lrme_hw_mgr.event_cb = cam_lrme_dev_buf_done_cb;
	g_lrme_hw_mgr.event_cb = cam_lrme_dev_buf_done_cb;


	cam_lrme_mgr_create_debugfs_entry();

	CAM_DBG(CAM_LRME, "Hw mgr init done");
	CAM_DBG(CAM_LRME, "Hw mgr init done");
	return rc;
	return rc;
}
}
+14 −1
Original line number Original line Diff line number Diff line
@@ -52,12 +52,23 @@ enum cam_lrme_hw_mgr_ctx_priority {
/**
/**
 * struct cam_lrme_mgr_work_data : HW Mgr work data
 * struct cam_lrme_mgr_work_data : HW Mgr work data
 *
 *
 * hw_device : Pointer to the hw device
 * @hw_device                    : Pointer to the hw device
 */
 */
struct cam_lrme_mgr_work_data {
struct cam_lrme_mgr_work_data {
	struct cam_lrme_device *hw_device;
	struct cam_lrme_device *hw_device;
};
};


/**
 * struct cam_lrme_debugfs_entry : debugfs entry struct
 *
 * @dentry                       : entry of debugfs
 * @dump_register                : flag to dump registers
 */
struct cam_lrme_debugfs_entry {
	struct dentry   *dentry;
	bool             dump_register;
};

/**
/**
 * struct cam_lrme_device     : LRME HW device
 * struct cam_lrme_device     : LRME HW device
 *
 *
@@ -98,6 +109,7 @@ struct cam_lrme_device {
 * @frame_req       : List of frame request to use
 * @frame_req       : List of frame request to use
 * @lrme_caps       : LRME capabilities
 * @lrme_caps       : LRME capabilities
 * @event_cb        : IRQ callback function
 * @event_cb        : IRQ callback function
 * @debugfs_entry   : debugfs entry to set debug prop
 */
 */
struct cam_lrme_hw_mgr {
struct cam_lrme_hw_mgr {
	uint32_t                      device_count;
	uint32_t                      device_count;
@@ -110,6 +122,7 @@ struct cam_lrme_hw_mgr {
	struct cam_lrme_frame_request frame_req[CAM_CTX_REQ_MAX * CAM_CTX_MAX];
	struct cam_lrme_frame_request frame_req[CAM_CTX_REQ_MAX * CAM_CTX_MAX];
	struct cam_lrme_query_cap_cmd lrme_caps;
	struct cam_lrme_query_cap_cmd lrme_caps;
	cam_hw_event_cb_func          event_cb;
	cam_hw_event_cb_func          event_cb;
	struct cam_lrme_debugfs_entry debugfs_entry;
};
};


int cam_lrme_mgr_register_device(struct cam_hw_intf *lrme_hw_intf,
int cam_lrme_mgr_register_device(struct cam_hw_intf *lrme_hw_intf,
+33 −4
Original line number Original line Diff line number Diff line
@@ -14,6 +14,20 @@
#include "cam_lrme_hw_soc.h"
#include "cam_lrme_hw_soc.h"
#include "cam_smmu_api.h"
#include "cam_smmu_api.h"


static void cam_lrme_dump_registers(void __iomem *base)
{
	/* dump the clc registers */
	cam_io_dump(base, 0x60, (0xc0 - 0x60) / 0x4);
	/* dump the fe and we registers */
	cam_io_dump(base, 0x200, (0x29c - 0x200) / 0x4);
	cam_io_dump(base, 0x2f0, (0x330 - 0x2f0) / 0x4);
	cam_io_dump(base, 0x500, (0x5b4 - 0x500) / 0x4);
	cam_io_dump(base, 0x700, (0x778 - 0x700) / 0x4);
	cam_io_dump(base, 0x800, (0x878 - 0x800) / 0x4);
	/* dump lrme sw registers, interrupts */
	cam_io_dump(base, 0x900, (0x928 - 0x900) / 0x4);
}

static void cam_lrme_cdm_write_reg_val_pair(uint32_t *buffer,
static void cam_lrme_cdm_write_reg_val_pair(uint32_t *buffer,
	uint32_t *index, uint32_t reg_offset, uint32_t reg_value)
	uint32_t *index, uint32_t reg_offset, uint32_t reg_value)
{
{
@@ -64,7 +78,8 @@ static void cam_lrme_hw_util_fill_fe_reg(struct cam_lrme_hw_io_buffer *io_buf,
		cam_lrme_cdm_write_reg_val_pair(reg_val_pair, num_cmd,
		cam_lrme_cdm_write_reg_val_pair(reg_val_pair, num_cmd,
			hw_info->bus_rd_reg.bus_client_reg[index].unpack_cfg_0,
			hw_info->bus_rd_reg.bus_client_reg[index].unpack_cfg_0,
			0x0);
			0x0);
	else if (io_buf->io_cfg->format == CAM_FORMAT_Y_ONLY)
	else if (io_buf->io_cfg->format == CAM_FORMAT_Y_ONLY ||
			io_buf->io_cfg->format == CAM_FORMAT_PLAIN8)
		cam_lrme_cdm_write_reg_val_pair(reg_val_pair, num_cmd,
		cam_lrme_cdm_write_reg_val_pair(reg_val_pair, num_cmd,
			hw_info->bus_rd_reg.bus_client_reg[index].unpack_cfg_0,
			hw_info->bus_rd_reg.bus_client_reg[index].unpack_cfg_0,
			0x1);
			0x1);
@@ -567,6 +582,8 @@ static int cam_lrme_hw_util_process_err(struct cam_hw_info *lrme_hw)
			lrme_core->state);
			lrme_core->state);
	}
	}


	cam_lrme_dump_registers(lrme_hw->soc_info.reg_map[0].mem_base);

	CAM_ERR_RATE_LIMIT(CAM_LRME, "Start recovery");
	CAM_ERR_RATE_LIMIT(CAM_LRME, "Start recovery");
	lrme_core->state = CAM_LRME_CORE_STATE_RECOVERY;
	lrme_core->state = CAM_LRME_CORE_STATE_RECOVERY;
	rc = cam_lrme_hw_util_reset(lrme_hw, CAM_LRME_HW_RESET_TYPE_HW_RESET);
	rc = cam_lrme_hw_util_reset(lrme_hw, CAM_LRME_HW_RESET_TYPE_HW_RESET);
@@ -610,6 +627,9 @@ static int cam_lrme_hw_util_process_reg_update(
	lrme_core->req_proc = lrme_core->req_submit;
	lrme_core->req_proc = lrme_core->req_submit;
	lrme_core->req_submit = NULL;
	lrme_core->req_submit = NULL;


	if (lrme_core->dump_flag)
		cam_lrme_dump_registers(lrme_hw->soc_info.reg_map[0].mem_base);

	return 0;
	return 0;
}
}


@@ -654,13 +674,13 @@ void cam_lrme_set_irq(struct cam_hw_info *lrme_hw,
		cam_io_w_mb(0xFFFF,
		cam_io_w_mb(0xFFFF,
			soc_info->reg_map[0].mem_base +
			soc_info->reg_map[0].mem_base +
			hw_info->titan_reg.top_irq_mask);
			hw_info->titan_reg.top_irq_mask);
		cam_io_w_mb(0xFFFF,
		cam_io_w_mb(0xFFFFF,
			soc_info->reg_map[0].mem_base +
			soc_info->reg_map[0].mem_base +
			hw_info->bus_wr_reg.common_reg.irq_mask_0);
			hw_info->bus_wr_reg.common_reg.irq_mask_0);
		cam_io_w_mb(0xFFFF,
		cam_io_w_mb(0xFFFFF,
			soc_info->reg_map[0].mem_base +
			soc_info->reg_map[0].mem_base +
			hw_info->bus_wr_reg.common_reg.irq_mask_1);
			hw_info->bus_wr_reg.common_reg.irq_mask_1);
		cam_io_w_mb(0xFFFF,
		cam_io_w_mb(0xFFFFF,
			soc_info->reg_map[0].mem_base +
			soc_info->reg_map[0].mem_base +
			hw_info->bus_rd_reg.common_reg.irq_mask);
			hw_info->bus_rd_reg.common_reg.irq_mask);
		break;
		break;
@@ -952,6 +972,7 @@ int cam_lrme_hw_submit_req(void *hw_priv, void *hw_submit_args,
	}
	}


	lrme_core->req_submit = frame_req;
	lrme_core->req_submit = frame_req;

	mutex_unlock(&lrme_hw->hw_mutex);
	mutex_unlock(&lrme_hw->hw_mutex);
	CAM_DBG(CAM_LRME, "Release lock, submit done for req %llu",
	CAM_DBG(CAM_LRME, "Release lock, submit done for req %llu",
		frame_req->req_id);
		frame_req->req_id);
@@ -1235,6 +1256,14 @@ int cam_lrme_hw_process_cmd(void *hw_priv, uint32_t cmd_type,
		break;
		break;
	}
	}


	case CAM_LRME_HW_CMD_DUMP_REGISTER: {
		struct cam_lrme_core *lrme_core =
			(struct cam_lrme_core *)lrme_hw->core_info;
		lrme_core->dump_flag = *(bool *)cmd_args;
		CAM_DBG(CAM_LRME, "dump_flag %d", lrme_core->dump_flag);
		break;
	}

	default:
	default:
		break;
		break;
	}
	}
+1 −0
Original line number Original line Diff line number Diff line
@@ -137,6 +137,7 @@ struct cam_lrme_core {
	struct cam_lrme_frame_request    *req_submit;
	struct cam_lrme_frame_request    *req_submit;
	struct cam_lrme_cdm_info         *hw_cdm_info;
	struct cam_lrme_cdm_info         *hw_cdm_info;
	uint32_t                          hw_idx;
	uint32_t                          hw_idx;
	bool                              dump_flag;
};
};


/**
/**
Loading