<html><body><p>
<pre>
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@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;
> +}
> +

</pre>
</p></body></html><!--type:text--><!--{--><pre>************* MEDIATEK Confidentiality Notice ********************
The information contained in this e-mail message (including any 
attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be 
conveyed only to the designated recipient(s). Any use, dissemination, 
distribution, printing, retaining or copying of this e-mail (including its 
attachments) by unintended recipient(s) is strictly prohibited and may 
be unlawful. If you are not an intended recipient of this e-mail, or believe 
that you have received this e-mail in error, please notify the sender 
immediately (by replying to this e-mail), delete any and all copies of 
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!
</pre><!--}-->