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

Commit 6bc220f0 authored by Camera Software Integration's avatar Camera Software Integration Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: isp: Add support for PHY TPG" into camera-kernel.lnx.4.0

parents 3f87eede 131b4115
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -85,6 +85,11 @@ camera-$(CONFIG_SPECTRA_ISP) += \
	cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_fe_ver1.o \
	cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_lite_ver3.o \
	cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe17x/cam_vfe.o \
	cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_dev.o \
	cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_soc.o \
	cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_core.o \
	cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_ver2.o \
	cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg.o \
	cam_isp/isp_hw_mgr/cam_isp_hw_mgr.o \
	cam_isp/isp_hw_mgr/cam_ife_hw_mgr.o \
	cam_isp/cam_isp_dev.o \
@@ -197,7 +202,9 @@ camera-$(CONFIG_SPECTRA_CAMERA) += \
	cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_dev.o \
	cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_soc.o \
	cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_core.o \
	cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_v1.o
	cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_ver1.o \
	cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg.o


camera-y += camera_main.o

+92 −0
Original line number Diff line number Diff line
@@ -424,6 +424,17 @@ static int cam_ife_hw_mgr_init_hw(
	struct cam_isp_hw_mgr_res *hw_mgr_res;
	int rc = 0, i;

	if (ctx->is_tpg) {
		CAM_DBG(CAM_ISP, "INIT TPG ... in ctx id:%d",
			ctx->ctx_index);
		rc = cam_ife_hw_mgr_init_hw_res(&ctx->res_list_tpg);
		if (rc) {
			CAM_ERR(CAM_ISP, "Can not INIT TFE TPG(id :%d)",
				ctx->res_list_tpg.hw_res[0]->hw_intf->hw_idx);
			goto deinit;
		}
	}

	CAM_DBG(CAM_ISP, "INIT IFE CID ... in ctx id:%d",
		ctx->ctx_index);
	/* INIT IFE CID */
@@ -840,6 +851,10 @@ static int cam_ife_hw_mgr_release_hw_for_ctx(
		cam_ife_hw_mgr_put_res(&ife_ctx->free_res_list, &hw_mgr_res);
	}

	/* ife phy tpg resource */
	if (ife_ctx->is_tpg)
		cam_ife_hw_mgr_free_hw_res(&ife_ctx->res_list_tpg);

	/* ife root node */
	if (ife_ctx->res_list_ife_in.res_type != CAM_ISP_RESOURCE_UNINT)
		cam_ife_hw_mgr_free_hw_res(&ife_ctx->res_list_ife_in);
@@ -1862,6 +1877,48 @@ static int cam_ife_mgr_acquire_cid_res(

}

static int cam_ife_hw_mgr_acquire_tpg(
	struct cam_ife_hw_mgr_ctx               *ife_ctx,
	struct cam_isp_in_port_generic_info     *in_port,
	uint32_t                                 num_inport)
{
	int rc = -EINVAL;
	uint32_t i;
	struct cam_ife_hw_mgr *ife_hw_mgr;
	struct cam_hw_intf *hw_intf;
	struct cam_top_tpg_ver2_reserve_args tpg_reserve;

	ife_hw_mgr = ife_ctx->hw_mgr;

	for (i = 0; i < CAM_TOP_TPG_HW_NUM_MAX; i++) {
		if (!ife_hw_mgr->tpg_devices[i])
			continue;

		hw_intf = ife_hw_mgr->tpg_devices[i];
		tpg_reserve.num_inport = num_inport;
		tpg_reserve.node_res = NULL;
		tpg_reserve.in_port = in_port;

		rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
			&tpg_reserve, sizeof(tpg_reserve));
		if (!rc)
			break;
	}

	if (i == CAM_TOP_TPG_HW_NUM_MAX || !tpg_reserve.node_res) {
		CAM_ERR(CAM_ISP, "Can not acquire IFE TPG");
		rc = -EINVAL;
		goto end;
	}

	ife_ctx->res_list_tpg.res_type = in_port->res_type;
	ife_ctx->res_list_tpg.hw_res[0] = tpg_reserve.node_res;
	ife_ctx->is_tpg = true;

end:
	return rc;
}

static int cam_ife_hw_mgr_acquire_res_ife_csid_pxl(
	struct cam_ife_hw_mgr_ctx           *ife_ctx,
	struct cam_isp_in_port_generic_info *in_port,
@@ -2755,6 +2812,16 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
			ife_ctx->use_frame_header_ts = true;
		}

		if ((in_port->res_type == CAM_ISP_IFE_IN_RES_CPHY_TPG_0) ||
			(in_port->res_type == CAM_ISP_IFE_IN_RES_CPHY_TPG_1))
			rc  = cam_ife_hw_mgr_acquire_tpg(ife_ctx, in_port,
				acquire_hw_info->num_inputs);

		if (rc) {
			CAM_ERR(CAM_ISP, "can not acquire TPG resource");
			goto free_mem;
		}

		rc = cam_ife_mgr_acquire_hw_for_ctx(ife_ctx, in_port,
			&num_pix_port_per_in, &num_rdi_port_per_in,
			&acquire_args->acquired_hw_id[i],
@@ -3752,6 +3819,9 @@ static int cam_ife_mgr_stop_hw(void *hw_mgr_priv, void *stop_hw_args)
	if (cam_cdm_stream_off(ctx->cdm_handle))
		CAM_ERR(CAM_ISP, "CDM stream off failed %d", ctx->cdm_handle);

	if (ctx->is_tpg)
		cam_ife_hw_mgr_stop_hw_res(&ctx->res_list_tpg);

	cam_ife_hw_mgr_deinit_hw(ctx);
	CAM_DBG(CAM_ISP,
		"Stop success for ctx id:%d rc :%d", ctx->ctx_index, rc);
@@ -4077,6 +4147,17 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args)
		}
	}

	if (ctx->is_tpg) {
		CAM_DBG(CAM_ISP, "START TPG HW ... in ctx id:%d",
			ctx->ctx_index);
		rc = cam_ife_hw_mgr_start_hw_res(&ctx->res_list_tpg, ctx);
		if (rc) {
			CAM_ERR(CAM_ISP, "Can not start IFE TPG (%d)",
				ctx->res_list_tpg.res_id);
			goto err;
		}
	}

	/* Start IFE root node: do nothing */
	CAM_DBG(CAM_ISP, "Start success for ctx id:%d", ctx->ctx_index);

@@ -7100,6 +7181,16 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
		return -EINVAL;
	}

	/* fill tpg hw intf information */
	for (i = 0, j = 0; i < CAM_TOP_TPG_HW_NUM_MAX; i++) {
		rc = cam_top_tpg_hw_init(&g_ife_hw_mgr.tpg_devices[i], i);
		if (!rc)
			j++;
	}
	if (!j)
		CAM_ERR(CAM_ISP, "no valid IFE TPG HW");


	cam_ife_hw_mgr_sort_dev_with_caps(&g_ife_hw_mgr);

	/* setup ife context list */
@@ -7146,6 +7237,7 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
			sizeof(g_ife_hw_mgr.ctx_pool[i]));
		INIT_LIST_HEAD(&g_ife_hw_mgr.ctx_pool[i].list);

		INIT_LIST_HEAD(&g_ife_hw_mgr.ctx_pool[i].res_list_tpg.list);
		INIT_LIST_HEAD(&g_ife_hw_mgr.ctx_pool[i].res_list_ife_in.list);
		INIT_LIST_HEAD(&g_ife_hw_mgr.ctx_pool[i].res_list_ife_cid);
		INIT_LIST_HEAD(&g_ife_hw_mgr.ctx_pool[i].res_list_ife_csid);
+6 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include "cam_isp_hw_mgr.h"
#include "cam_vfe_hw_intf.h"
#include "cam_ife_csid_hw_intf.h"
#include "cam_top_tpg_hw_intf.h"
#include "cam_tasklet_util.h"

/* IFE resource constants */
@@ -48,6 +49,7 @@ struct cam_ife_hw_mgr_debug {
 * @slave_hw_idx:           hw index for slave core
 * @hw_mgr:                 IFE hw mgr which owns this context
 * @ctx_in_use:             flag to tell whether context is active
 * @res_list_tpg:           TPG resource list
 * @res_list_ife_in:        Starting resource(TPG,PHY0, PHY1...) Can only be
 *                          one.
 * @res_list_csid:          CSID resource list
@@ -85,6 +87,7 @@ struct cam_ife_hw_mgr_debug {
 * @custom_enabled          update the flag if context is connected to custom HW
 * @use_frame_header_ts     obtain qtimer ts using frame header
 * @ts                      captured timestamp when the ctx is acquired
 * @is_tpg                  indicate whether context is using PHY TPG
 */
struct cam_ife_hw_mgr_ctx {
	struct list_head                list;
@@ -97,6 +100,7 @@ struct cam_ife_hw_mgr_ctx {
	uint32_t                        ctx_in_use;

	struct cam_isp_hw_mgr_res       res_list_ife_in;
	struct cam_isp_hw_mgr_res       res_list_tpg;
	struct list_head                res_list_ife_cid;
	struct list_head                res_list_ife_csid;
	struct list_head                res_list_ife_src;
@@ -134,6 +138,7 @@ struct cam_ife_hw_mgr_ctx {
	bool                            custom_enabled;
	bool                            use_frame_header_ts;
	struct timespec64               ts;
	bool                            is_tpg;
};

/**
@@ -155,6 +160,7 @@ struct cam_ife_hw_mgr_ctx {
 */
struct cam_ife_hw_mgr {
	struct cam_isp_hw_mgr          mgr_common;
	struct cam_hw_intf            *tpg_devices[CAM_TOP_TPG_HW_NUM_MAX];
	struct cam_hw_intf            *csid_devices[CAM_IFE_CSID_HW_NUM_MAX];
	struct cam_hw_intf            *ife_devices[CAM_IFE_HW_NUM_MAX];
	struct cam_soc_reg_map        *cdm_reg_map[CAM_IFE_HW_NUM_MAX];
+1 −1
Original line number Diff line number Diff line
@@ -1350,7 +1350,7 @@ static int cam_tfe_hw_mgr_acquire_tpg(
	uint32_t i, j = 0;
	struct cam_tfe_hw_mgr                        *tfe_hw_mgr;
	struct cam_hw_intf                           *hw_intf;
	struct cam_top_tpg_hw_reserve_resource_args   tpg_reserve;
	struct cam_top_tpg_ver1_reserve_args          tpg_reserve;

	tfe_hw_mgr = tfe_ctx->hw_mgr;

+15 −3
Original line number Diff line number Diff line
@@ -25,6 +25,10 @@
#define CAM_IFE_CSID_TPG_VC_VAL                        0xA
#define CAM_IFE_CSID_TPG_DT_VAL                        0x2B

/* CSIPHY TPG VC/DT values */
#define CAM_IFE_CSI_TPG_VC_VAL                         0x0
#define CAM_IFE_CSI_TPG_DT_VAL                         0x2B

/* Timeout values in usec */
#define CAM_IFE_CSID_TIMEOUT_SLEEP_US                  1000
#define CAM_IFE_CSID_TIMEOUT_ALL_US                    100000
@@ -957,6 +961,12 @@ int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
				csid_hw->tpg_cfg.height);

			cid_data->tpg_set = 1;
		} else if (cid_reserv->in_port->res_type ==
			CAM_ISP_IFE_IN_RES_CPHY_TPG_0) {
			csid_hw->csi2_rx_cfg.phy_sel = 0;
		} else if (cid_reserv->in_port->res_type ==
			CAM_ISP_IFE_IN_RES_CPHY_TPG_1) {
			csid_hw->csi2_rx_cfg.phy_sel = 1;
		} else {
			csid_hw->csi2_rx_cfg.phy_sel =
				(cid_reserv->in_port->res_type & 0xFF) - 1;
@@ -1129,9 +1139,10 @@ int cam_ife_csid_path_reserve(struct cam_ife_csid_hw *csid_hw,
		reserve->in_port->line_start, reserve->in_port->line_stop,
		path_data->crop_enable);

	if (reserve->in_port->res_type == CAM_ISP_IFE_IN_RES_TPG) {
		path_data->dt = CAM_IFE_CSID_TPG_DT_VAL;
		path_data->vc = CAM_IFE_CSID_TPG_VC_VAL;
	if ((reserve->in_port->res_type == CAM_ISP_IFE_IN_RES_CPHY_TPG_0) ||
		(reserve->in_port->res_type == CAM_ISP_IFE_IN_RES_CPHY_TPG_1)) {
		path_data->dt = CAM_IFE_CSI_TPG_DT_VAL;
		path_data->vc = CAM_IFE_CSI_TPG_VC_VAL;
	} else {
		path_data->dt = reserve->in_port->dt[0];
		path_data->vc = reserve->in_port->vc[0];
@@ -4459,6 +4470,7 @@ int cam_ife_csid_hw_probe_init(struct cam_hw_intf *csid_hw_intf,
	num_paths = ife_csid_hw->csid_info->csid_reg->cmn_reg->num_pix +
		ife_csid_hw->csid_info->csid_reg->cmn_reg->num_rdis +
		ife_csid_hw->csid_info->csid_reg->cmn_reg->num_udis;

	/* Initialize the CID resource */
	for (i = 0; i < num_paths; i++) {
		ife_csid_hw->cid_res[i].res_type = CAM_ISP_RESOURCE_CID;
Loading