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

Commit 5d81243e authored by Sagar Gore's avatar Sagar Gore
Browse files

msm: camera: isp: Add Fetch engine support



Added FE_CFG ioctl to FETCH_ENG_START and resused INPUT_CFG.
ioctl similar to camif config to configure fetch engine.

Change-Id: Id86a3abce0fb37912c1d254c5c0e18a75c43dba6
Signed-off-by: default avatarSagar Gore <sgore@codeaurora.org>
parent c57e2816
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
@@ -322,6 +322,48 @@ static int msm_isp_buf_unprepare(struct msm_isp_buf_mgr *buf_mgr,
	return 0;
}

static int msm_isp_get_buf_by_index(struct msm_isp_buf_mgr *buf_mgr,
	uint32_t bufq_handle, uint32_t buf_index,
	struct msm_isp_buffer **buf_info)
{
	int rc = -EINVAL;
	unsigned long flags;
	struct msm_isp_bufq *bufq = NULL;
	struct msm_isp_buffer *temp_buf_info;
	uint32_t i = 0;

	bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
	if (!bufq) {
		pr_err("%s: Invalid bufq\n", __func__);
		return rc;
	}

	spin_lock_irqsave(&bufq->bufq_lock, flags);
	if (buf_index >= bufq->num_bufs) {
		pr_err("%s: Invalid buf index: %d max: %d\n", __func__,
			buf_index, bufq->num_bufs);
		spin_unlock_irqrestore(&bufq->bufq_lock, flags);
		return rc;
	}

	*buf_info = NULL;
	for (i = 0; bufq->num_bufs; i++) {
		temp_buf_info = &bufq->bufs[i];
		if (temp_buf_info && temp_buf_info->buf_idx == buf_index) {
			*buf_info = temp_buf_info;
			break;
		}
	}

	if (*buf_info) {
		pr_debug("Found buf in isp buf mgr");
		rc = 0;
	}
	spin_unlock_irqrestore(&bufq->bufq_lock, flags);
	return rc;
}


static int msm_isp_get_buf(struct msm_isp_buf_mgr *buf_mgr, uint32_t id,
	uint32_t bufq_handle, struct msm_isp_buffer **buf_info)
{
@@ -795,6 +837,8 @@ static int msm_isp_get_bufq_handle(struct msm_isp_buf_mgr *buf_mgr,
			return buf_mgr->bufq[i].bufq_handle;
		}
	}
	pr_err("%s: No match found 0x%x 0x%x\n", __func__,
			session_id, stream_id);
	return 0;
}

@@ -1138,6 +1182,7 @@ static struct msm_isp_buf_ops isp_buf_ops = {
	.get_bufq_handle = msm_isp_get_bufq_handle,
	.get_buf_src = msm_isp_get_buf_src,
	.get_buf = msm_isp_get_buf,
	.get_buf_by_index = msm_isp_get_buf_by_index,
	.put_buf = msm_isp_put_buf,
	.flush_buf = msm_isp_flush_buf,
	.buf_done = msm_isp_buf_done,
+4 −0
Original line number Diff line number Diff line
@@ -127,6 +127,10 @@ struct msm_isp_buf_ops {
	int (*get_buf) (struct msm_isp_buf_mgr *buf_mgr, uint32_t id,
		uint32_t bufq_handle, struct msm_isp_buffer **buf_info);

	int (*get_buf_by_index) (struct msm_isp_buf_mgr *buf_mgr,
		uint32_t bufq_handle, uint32_t buf_index,
		struct msm_isp_buffer **buf_info);

	int (*put_buf) (struct msm_isp_buf_mgr *buf_mgr,
		uint32_t bufq_handle, uint32_t buf_index);

+15 −3
Original line number Diff line number Diff line
@@ -166,8 +166,10 @@ struct msm_vfe_core_ops {
	int (*init_hw) (struct vfe_device *vfe_dev);
	void (*init_hw_reg) (struct vfe_device *vfe_dev);
	void (*release_hw) (struct vfe_device *vfe_dev);
	void (*cfg_camif) (struct vfe_device *vfe_dev,
	void (*cfg_input_mux) (struct vfe_device *vfe_dev,
		struct msm_vfe_pix_cfg *pix_cfg);
	int (*start_fetch_eng)(struct vfe_device *vfe_dev,
		void *arg);
	void (*update_camif_state) (struct vfe_device *vfe_dev,
		enum msm_isp_camif_update_state update_state);
	void (*cfg_rdi_reg) (struct vfe_device *vfe_dev,
@@ -322,6 +324,7 @@ struct msm_vfe_axi_stream {
	uint32_t runtime_num_burst_capture;
	uint8_t  runtime_framedrop_update;
	uint32_t runtime_output_format;
	enum msm_stream_memory_input_t  memory_input;
};

struct msm_vfe_axi_composite_info {
@@ -341,6 +344,14 @@ struct msm_vfe_src_info {
	uint32_t last_updt_frm_id;
};

struct msm_vfe_fetch_engine_info {
	uint32_t session_id;
	uint32_t stream_id;
	uint32_t bufq_handle;
	uint32_t buf_idx;
	uint8_t is_busy;
};

enum msm_wm_ub_cfg_type {
	MSM_WM_UB_CFG_DEFAULT,
	MSM_WM_UB_EQUAL_SLICING,
@@ -518,6 +529,7 @@ struct vfe_device {
	void __iomem *p_avtimer_lsw;
	uint8_t ignore_error;
	struct msm_isp_statistics *stats;
	struct msm_vfe_fetch_engine_info fetch_engine_info;
};

#endif
+32 −1
Original line number Diff line number Diff line
@@ -620,6 +620,19 @@ static int32_t msm_vfe32_cfg_io_format(struct vfe_device *vfe_dev,
	return 0;
}

static int msm_vfe32_start_fetch_engine(struct vfe_device *vfe_dev,
	void *arg)
{
	return 0;
}

static void msm_vfe32_cfg_fetch_engine(struct vfe_device *vfe_dev,
	struct msm_vfe_pix_cfg *pix_cfg)
{
	pr_err("%s: Fetch engine not supported\n", __func__);
	return;
}

static void msm_vfe32_cfg_camif(struct vfe_device *vfe_dev,
	struct msm_vfe_pix_cfg *pix_cfg)
{
@@ -651,6 +664,23 @@ static void msm_vfe32_cfg_camif(struct vfe_device *vfe_dev,
	msm_camera_io_w(val, vfe_dev->vfe_base + 0x6FC);
}

static void msm_vfe32_cfg_input_mux(struct vfe_device *vfe_dev,
	struct msm_vfe_pix_cfg *pix_cfg)
{
	switch (pix_cfg->input_mux) {
	case CAMIF:
		msm_vfe32_cfg_camif(vfe_dev, pix_cfg);
		break;
	case EXTERNAL_READ:
		msm_vfe32_cfg_fetch_engine(vfe_dev, pix_cfg);
		break;
	default:
		pr_err("%s: Unsupported input mux %d\n",
			__func__, pix_cfg->input_mux);
	}
	return;
}

static void msm_vfe32_update_camif_state(
	struct vfe_device *vfe_dev,
	enum msm_isp_camif_update_state update_state)
@@ -1231,8 +1261,9 @@ struct msm_vfe_hardware_info vfe32_hw_info = {
		},
		.core_ops = {
			.reg_update = msm_vfe32_reg_update,
			.cfg_camif = msm_vfe32_cfg_camif,
			.cfg_input_mux = msm_vfe32_cfg_input_mux,
			.update_camif_state = msm_vfe32_update_camif_state,
			.start_fetch_eng = msm_vfe32_start_fetch_engine,
			.cfg_rdi_reg = msm_vfe32_cfg_rdi_reg,
			.reset_hw = msm_vfe32_reset_hardware,
			.init_hw = msm_vfe32_init_hardware,
+40 −1
Original line number Diff line number Diff line
@@ -884,6 +884,13 @@ static int32_t msm_vfe40_cfg_io_format(struct vfe_device *vfe_dev,
	}

	io_format_reg = msm_camera_io_r(vfe_dev->vfe_base + 0x54);
	if ((stream_src < RDI_INTF_0) &&
	    (vfe_dev->axi_data.src_info[VFE_PIX_0].input_mux ==
	     EXTERNAL_READ)) {

		io_format_reg &= 0xFFC8FFFF;
		io_format_reg |= (bpp_reg << 20 | pack_fmt << 16);
	}
	switch (stream_src) {
	case PIX_ENCODER:
	case PIX_VIEWFINDER:
@@ -906,6 +913,19 @@ static int32_t msm_vfe40_cfg_io_format(struct vfe_device *vfe_dev,
	return 0;
}

static int msm_vfe40_start_fetch_engine(struct vfe_device *vfe_dev,
	void *arg)
{
	return 0;
}

static void msm_vfe40_cfg_fetch_engine(struct vfe_device *vfe_dev,
	struct msm_vfe_pix_cfg *pix_cfg)
{
	pr_err("%s: Fetch engine not supported\n", __func__);
	return;
}

static void msm_vfe40_cfg_camif(struct vfe_device *vfe_dev,
	struct msm_vfe_pix_cfg *pix_cfg)
{
@@ -946,6 +966,7 @@ static void msm_vfe40_cfg_camif(struct vfe_device *vfe_dev,
		msm_camera_io_w(val, vfe_dev->vfe_base + 0x93C);
		break;
	case EXTERNAL_READ:
		break;
	default:
		pr_err("%s: not supported input_mux %d\n",
			__func__, pix_cfg->input_mux);
@@ -953,6 +974,23 @@ static void msm_vfe40_cfg_camif(struct vfe_device *vfe_dev,
	}
}

static void msm_vfe40_cfg_input_mux(struct vfe_device *vfe_dev,
	struct msm_vfe_pix_cfg *pix_cfg)
{
	switch (pix_cfg->input_mux) {
	case CAMIF:
		msm_vfe40_cfg_camif(vfe_dev, pix_cfg);
		break;
	case EXTERNAL_READ:
		msm_vfe40_cfg_fetch_engine(vfe_dev, pix_cfg);
		break;
	default:
		pr_err("%s: Unsupported input mux %d\n",
			__func__, pix_cfg->input_mux);
	}
	return;
}

static void msm_vfe40_update_camif_state(struct vfe_device *vfe_dev,
	enum msm_isp_camif_update_state update_state)
{
@@ -1713,8 +1751,9 @@ struct msm_vfe_hardware_info vfe40_hw_info = {
		},
		.core_ops = {
			.reg_update = msm_vfe40_reg_update,
			.cfg_camif = msm_vfe40_cfg_camif,
			.cfg_input_mux = msm_vfe40_cfg_input_mux,
			.update_camif_state = msm_vfe40_update_camif_state,
			.start_fetch_eng = msm_vfe40_start_fetch_engine,
			.cfg_rdi_reg = msm_vfe40_cfg_rdi_reg,
			.reset_hw = msm_vfe40_reset_hardware,
			.init_hw = msm_vfe40_init_hardware,
Loading