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

Commit 0bc42fe4 authored by Harsh Shah's avatar Harsh Shah Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: isp: Cleanup the start/stop/release functions" into dev/msm-4.14-camx

parents 499b34a8 e4824de4
Loading
Loading
Loading
Loading
+39 −21
Original line number Diff line number Diff line
@@ -433,7 +433,7 @@ static int cam_ife_hw_mgr_free_hw_res(
				sizeof(struct cam_isp_resource_node));
			if (rc)
				CAM_ERR(CAM_ISP,
					"Release hw resrouce id %d failed",
					"Release hw resource id %d failed",
					isp_hw_res->res_id);
			isp_hw_res->hw_res[i] = NULL;
		} else
@@ -2232,10 +2232,6 @@ static int cam_ife_mgr_stop_hw(void *hw_mgr_priv, void *stop_hw_args)

	CAM_DBG(CAM_ISP, "Halting CSIDs");

	if (cam_cdm_stream_off(ctx->cdm_handle))
		CAM_ERR(CAM_ISP, "CDM stream off failed %d",
			ctx->cdm_handle);

	CAM_DBG(CAM_ISP, "Going to stop IFE Out");

	/* IFE out resources */
@@ -2302,12 +2298,13 @@ static int cam_ife_mgr_stop_hw(void *hw_mgr_priv, void *stop_hw_args)
	if (stop_isp->stop_only)
		goto end;

	if (cam_cdm_stream_off(ctx->cdm_handle))
		CAM_ERR(CAM_ISP, "CDM stream off failed %d", ctx->cdm_handle);

	cam_ife_hw_mgr_deinit_hw(ctx);
	CAM_DBG(CAM_ISP,
		"Stop success for ctx id:%d rc :%d", ctx->ctx_index, rc);

end:

	mutex_lock(&g_ife_hw_mgr.ctx_mutex);
	if (!atomic_dec_return(&g_ife_hw_mgr.active_ctx_cnt)) {
		rc = cam_ife_notify_safe_lut_scm(CAM_IFE_SAFE_DISABLE);
@@ -2319,6 +2316,7 @@ static int cam_ife_mgr_stop_hw(void *hw_mgr_priv, void *stop_hw_args)
	}
	mutex_unlock(&g_ife_hw_mgr.ctx_mutex);

end:
	return rc;
}

@@ -2439,6 +2437,12 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args)
		return -EPERM;
	}

	if ((!ctx->init_done) && start_isp->start_only) {
		CAM_ERR(CAM_ISP, "Invalid args init_done %d start_only %d",
			ctx->init_done, start_isp->start_only);
		return -EINVAL;
	}

	CAM_DBG(CAM_ISP, "Enter... ctx id:%d",
		ctx->ctx_index);

@@ -2480,10 +2484,10 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args)
	rc = cam_ife_hw_mgr_init_hw(ctx);
	if (rc) {
		CAM_ERR(CAM_ISP, "Init failed");
		goto err;
		goto tasklet_stop;
	}

start_only:
	ctx->init_done = true;

	mutex_lock(&g_ife_hw_mgr.ctx_mutex);
	if (!atomic_fetch_inc(&g_ife_hw_mgr.active_ctx_cnt)) {
@@ -2491,7 +2495,8 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args)
		if (rc) {
			CAM_ERR(CAM_ISP,
				"SAFE SCM call failed:Check TZ/HYP dependency");
			rc = -1;
			rc = -EFAULT;
			goto deinit_hw;
		}
	}
	mutex_unlock(&g_ife_hw_mgr.ctx_mutex);
@@ -2501,20 +2506,19 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args)
	if (rc) {
		CAM_ERR(CAM_ISP, "Can not start cdm (%d)",
			 ctx->cdm_handle);
		goto err;
		goto safe_disable;
	}

	if (!start_isp->start_only) {
	/* Apply initial configuration */
	CAM_DBG(CAM_ISP, "Config HW");
		rc = cam_ife_mgr_config_hw(hw_mgr_priv,
			&start_isp->hw_config);
	rc = cam_ife_mgr_config_hw(hw_mgr_priv, &start_isp->hw_config);
	if (rc) {
		CAM_ERR(CAM_ISP, "Config HW failed");
			goto err;
		}
		goto cdm_streamoff;
	}

start_only:

	CAM_DBG(CAM_ISP, "START IFE OUT ... in ctx id:%d",
		ctx->ctx_index);
	/* start the IFE out devices */
@@ -2564,7 +2568,6 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args)
		}
	}

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

@@ -2579,6 +2582,21 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args)
	cam_ife_mgr_stop_hw(hw_mgr_priv, &stop_args);
	CAM_DBG(CAM_ISP, "Exit...(rc=%d)", rc);
	return rc;

cdm_streamoff:
	cam_cdm_stream_off(ctx->cdm_handle);

safe_disable:
	cam_ife_notify_safe_lut_scm(CAM_IFE_SAFE_DISABLE);

deinit_hw:
	cam_ife_hw_mgr_deinit_hw(ctx);
	ctx->init_done = false;

tasklet_stop:
	cam_tasklet_stop(ctx->common.tasklet_info);

	return rc;
}

static int cam_ife_mgr_read(void *hw_mgr_priv, void *read_args)
+6 −14
Original line number Diff line number Diff line
@@ -2409,21 +2409,13 @@ static int cam_ife_csid_release(void *hw_priv,
		goto end;
	}

	if (res->res_state == CAM_ISP_RESOURCE_STATE_AVAILABLE) {
		CAM_DBG(CAM_ISP,
			"CSID:%d res type:%d Res %d  in released state",
			csid_hw->hw_intf->hw_idx,
			res->res_type, res->res_id);
		goto end;
	}

	if (res->res_type == CAM_ISP_RESOURCE_PIX_PATH &&
		res->res_state != CAM_ISP_RESOURCE_STATE_RESERVED) {
		CAM_DBG(CAM_ISP,
			"CSID:%d res type:%d Res id:%d invalid state:%d",
	if ((res->res_state <= CAM_ISP_RESOURCE_STATE_AVAILABLE) ||
		(res->res_state >= CAM_ISP_RESOURCE_STATE_STREAMING)) {
		CAM_WARN(CAM_ISP,
			"CSID:%d res type:%d Res %d in state %d",
			csid_hw->hw_intf->hw_idx,
			res->res_type, res->res_id, res->res_state);
		rc = -EINVAL;
			res->res_type, res->res_id,
			res->res_state);
		goto end;
	}