[PATCH v1 08/10] media: platform: mediatek: add isp_7x state ctrl

CK Hu (胡俊光) ck.hu at mediatek.com
Tue Oct 15 18:35:02 PDT 2024


Hi, Shu-hsiang:

On Wed, 2024-10-09 at 19:15 +0800, Shu-hsiang Yang wrote:
> Introduces state management and debugging mechanisms for the MediaTek
> ISP7.x camsys platform. State management establishes control over ISP
> operations and events, defining distinct states for request handling,
> sensor control, and frame synchronization, ensuring event processing.
> The debugging mechanism ensures stable operation and timely data
> collection during anomalies.
> 
> Signed-off-by: Shu-hsiang Yang <Shu-hsiang.Yang at mediatek.com>
> ---

[snip]

> +static bool mtk_cam_req_frame_sync_start(struct mtk_cam_request *req)
> +{
> +	/* All ctx with sensor is in ready state */
> +	struct mtk_cam_device *cam =
> +		container_of(req->req.mdev, struct mtk_cam_device, media_dev);
> +	struct mtk_cam_ctx *ctx;
> +	struct mtk_cam_ctx *sync_ctx[MTKCAM_SUBDEV_MAX];
> +	int i;
> +	u32 ctx_cnt = 0, synced_cnt = 0;
> +	bool ret = false;
> +
> +	/* pick out the used ctxs */
> +	for (i = 0; i < cam->max_stream_num; i++) {
> +		if (!(1 << i & req->ctx_used))
> +			continue;
> +
> +		sync_ctx[ctx_cnt] = &cam->ctxs[i];
> +		ctx_cnt++;
> +	}
> +
> +	mutex_lock(&req->fs.op_lock);
> +	if (ctx_cnt > 1) {
> +		/* multi sensor case */

multi sensor is advanced function, so separate multi sensor related code to a multi sensor patch.

Regards,
CK

> +		req->fs.on_cnt++;
> +		/* not first time */
> +		if (req->fs.on_cnt != 1)
> +			goto EXIT;
> +
> +		for (i = 0; i < ctx_cnt; i++) {
> +			ctx = sync_ctx[i];
> +			spin_lock(&ctx->streaming_lock);
> +			if (!ctx->streaming) {
> +				spin_unlock(&ctx->streaming_lock);
> +				dev_info(cam->dev,
> +					 "%s: ctx(%d): is streamed off\n",
> +					 __func__, ctx->stream_id);
> +				continue;
> +			}
> +			spin_unlock(&ctx->streaming_lock);
> +
> +			/* update sensor frame sync */
> +			if (ctx->synced)
> +				synced_cnt++;
> +		}
> +
> +		/*
> +		 * the prepared sensor is no enough, skip
> +		 * frame sync set failed or stream off
> +		 */
> +		if (synced_cnt < 2) {
> +			mtk_cam_fs_reset(&req->fs);
> +			dev_info(cam->dev, "%s:%s: sensor is not ready\n",
> +				 __func__, req->req.debug_str);
> +			goto EXIT;
> +		}
> +
> +		dev_dbg(cam->dev, "%s:%s:fs_sync_frame(1): ctxs: 0x%x\n",
> +			__func__, req->req.debug_str, req->ctx_used);
> +
> +		ret = true;
> +		goto EXIT;
> +	}
> +	/* single sensor case: unsupported sensor hardware sync */
> +
> +EXIT:
> +	dev_dbg(cam->dev, "%s:%s:target/on/off(%d/%d/%d)\n", __func__,
> +		req->req.debug_str, req->fs.target, req->fs.on_cnt,
> +		req->fs.off_cnt);
> +	mutex_unlock(&req->fs.op_lock);
> +	return ret;
> +}
> +


More information about the Linux-mediatek mailing list