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

Commit 4a0a1113 authored by Jing Zhou's avatar Jing Zhou
Browse files

msm: camera: isp: Improve the CSID resource allocation logic



This change improves the CSID resource allocation logic during the CSID
hardware resource allocation. In addition to the existing criteria,
pixel resource requirement has been added as a new criterion.

Change-Id: I2283d675f42429427e8200e172a08c05e3c1e210
Signed-off-by: default avatarJing Zhou <jzhou70@codeaurora.org>
parent 4f1b8381
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -1137,7 +1137,8 @@ static int cam_ife_hw_mgr_preprocess_out_port(
static int cam_ife_mgr_acquire_cid_res(
	struct cam_ife_hw_mgr_ctx          *ife_ctx,
	struct cam_isp_in_port_info        *in_port,
	uint32_t                           *cid_res_id)
	uint32_t                           *cid_res_id,
	int                                 pixel_count)
{
	int rc = -1;
	int i, j;
@@ -1157,6 +1158,7 @@ static int cam_ife_mgr_acquire_cid_res(

	csid_acquire.res_type = CAM_ISP_RESOURCE_CID;
	csid_acquire.in_port = in_port;
	csid_acquire.pixel_count = pixel_count;

	for (i = 0; i < CAM_IFE_CSID_HW_NUM_MAX; i++) {
		if (!ife_hw_mgr->csid_devices[i])
@@ -1237,13 +1239,6 @@ static int cam_ife_mgr_acquire_hw_for_ctx(
		goto err;
	}

	/* get cid resource */
	rc = cam_ife_mgr_acquire_cid_res(ife_ctx, in_port, &cid_res_id);
	if (rc) {
		CAM_ERR(CAM_ISP, "Acquire IFE CID resource Failed");
		goto err;
	}

	cam_ife_hw_mgr_preprocess_out_port(ife_ctx, in_port,
		&pixel_count, &rdi_count);

@@ -1252,6 +1247,14 @@ static int cam_ife_mgr_acquire_hw_for_ctx(
		return -EINVAL;
	}

	/* get cid resource */
	rc = cam_ife_mgr_acquire_cid_res(ife_ctx, in_port, &cid_res_id,
		pixel_count);
	if (rc) {
		CAM_ERR(CAM_ISP, "Acquire IFE CID resource Failed");
		goto err;
	}

	if (pixel_count) {
		/* get ife csid IPP resrouce */
		rc = cam_ife_hw_mgr_acquire_res_ife_csid_ipp(ife_ctx, in_port,
+27 −5
Original line number Diff line number Diff line
@@ -287,7 +287,7 @@ static int cam_ife_csid_get_format_ipp(

static int cam_ife_csid_cid_get(struct cam_ife_csid_hw *csid_hw,
	struct cam_isp_resource_node **res, int32_t vc, uint32_t dt,
	uint32_t res_type)
	uint32_t res_type, int pixel_count)
{
	int  rc = 0;
	struct cam_ife_csid_cid_data    *cid_data;
@@ -305,7 +305,8 @@ static int cam_ife_csid_cid_get(struct cam_ife_csid_hw *csid_hw,
					break;
				}
			} else {
				if (cid_data->vc == vc && cid_data->dt == dt) {
				if (cid_data->vc == vc && cid_data->dt == dt &&
					cid_data->pixel_count == pixel_count) {
					cid_data->cnt++;
					*res = &csid_hw->cid_res[i];
					break;
@@ -329,6 +330,7 @@ static int cam_ife_csid_cid_get(struct cam_ife_csid_hw *csid_hw,
				cid_data->vc  = vc;
				cid_data->dt  = dt;
				cid_data->cnt = 1;
				cid_data->pixel_count = pixel_count;
				csid_hw->cid_res[j].res_state =
					CAM_ISP_RESOURCE_STATE_RESERVED;
				*res = &csid_hw->cid_res[j];
@@ -568,6 +570,7 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
	struct cam_csid_hw_reserve_resource_args  *cid_reserv)
{
	int rc = 0;
	uint32_t i;
	struct cam_ife_csid_cid_data       *cid_data;

	CAM_DBG(CAM_ISP,
@@ -725,6 +728,7 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
		cid_data->vc = cid_reserv->in_port->vc;
		cid_data->dt = cid_reserv->in_port->dt;
		cid_data->cnt = 1;
		cid_data->pixel_count = cid_reserv->pixel_count;
		cid_reserv->node_res = &csid_hw->cid_res[0];
		csid_hw->csi2_reserve_cnt++;

@@ -733,9 +737,27 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
			csid_hw->hw_intf->hw_idx,
			cid_reserv->node_res->res_id);
	} else {
		rc = cam_ife_csid_cid_get(csid_hw, &cid_reserv->node_res,
			cid_reserv->in_port->vc, cid_reserv->in_port->dt,
			cid_reserv->in_port->res_type);
		if (cid_reserv->pixel_count > 0) {
			for (i = 0; i < CAM_IFE_CSID_CID_RES_MAX; i++) {
				cid_data = (struct cam_ife_csid_cid_data *)
					csid_hw->cid_res[i].res_priv;
				if ((csid_hw->cid_res[i].res_state >=
					CAM_ISP_RESOURCE_STATE_RESERVED) &&
					cid_data->pixel_count > 0) {
					CAM_DBG(CAM_ISP,
						"CSID:%d IPP resource is full");
					rc = -EINVAL;
					goto end;
				}
			}
		}

		rc = cam_ife_csid_cid_get(csid_hw,
			&cid_reserv->node_res,
			cid_reserv->in_port->vc,
			cid_reserv->in_port->dt,
			cid_reserv->in_port->res_type,
			cid_reserv->pixel_count);
		/* if success then increment the reserve count */
		if (!rc) {
			if (csid_hw->csi2_reserve_cnt == UINT_MAX) {
+6 −4
Original line number Diff line number Diff line
@@ -356,10 +356,11 @@ struct cam_ife_csid_tpg_cfg {
/**
 * struct cam_ife_csid_cid_data- cid configuration private data
 *
 * @vc:      virtual channel
 * @vc:          Virtual channel
 * @dt:          Data type
 * @cnt:     cid resource reference count.
 * @tpg_set: tpg used for this cid resource
 * @cnt:         Cid resource reference count.
 * @tpg_set:     Tpg used for this cid resource
 * @pixel_count: Pixel resource connected
 *
 */
struct cam_ife_csid_cid_data {
@@ -367,6 +368,7 @@ struct cam_ife_csid_cid_data {
	uint32_t                     dt;
	uint32_t                     cnt;
	uint32_t                     tpg_set;
	int                          pixel_count;
};


+16 −14
Original line number Diff line number Diff line
@@ -61,20 +61,21 @@ struct cam_ife_csid_hw_caps {

/**
 * struct cam_csid_hw_reserve_resource- hw reserve
 * @res_type :  reource type CID or PATH
 * @res_type :    Reource type CID or PATH
 *                if type is CID, then res_id is not required,
 *                if type is path then res id need to be filled
 * @res_id  :  res id to be reserved
 * @in_port : input port resource info
 * @out_port: output port resource info, used for RDI path only
 * @res_id  :     Resource id to be reserved
 * @in_port :     Input port resource info
 * @out_port:     Output port resource info, used for RDI path only
 * @sync_mode:    Sync mode
 *                Sync mode could be master, slave or none
 * @master_idx: master device index to be configured in the slave path
 * @master_idx:   Master device index to be configured in the slave path
 *                for master path, this value is not required.
 *                only slave need to configure the master index value
 * @cid:          cid (DT_ID) value for path, this is applicable for CSID path
 *                reserve
 * @node_res :  reserved resource structure pointer
 * @node_res :    Reserved resource structure pointer
 * @pixel_count:  Number of pixel resources
 *
 */
struct cam_csid_hw_reserve_resource_args {
@@ -86,6 +87,7 @@ struct cam_csid_hw_reserve_resource_args {
	uint32_t                                  master_idx;
	uint32_t                                  cid;
	struct cam_isp_resource_node             *node_res;
	int                                       pixel_count;
};

/**