media: nxp: imx8-isi: m2m: Delay power up until streamon

There's no need to power up the device when userspace opens it. Delay
the operation until streamon.

Link: https://lore.kernel.org/r/20250821135123.29462-2-laurent.pinchart@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Guoniu Zhou <guoniu.zhou@nxp.com>
Tested-by: Guoniu Zhou <guoniu.zhou@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
Laurent Pinchart 2025-08-21 16:51:23 +03:00 committed by Hans Verkuil
parent 178aa33602
commit aec0f43f14

View File

@ -250,6 +250,10 @@ static int mxc_isi_m2m_vb2_prepare_streaming(struct vb2_queue *q)
if (m2m->usage_count == INT_MAX)
return -EOVERFLOW;
ret = pm_runtime_resume_and_get(m2m->isi->dev);
if (ret)
return ret;
/*
* Acquire the pipe and initialize the channel with the first user of
* the M2M device.
@ -263,7 +267,7 @@ static int mxc_isi_m2m_vb2_prepare_streaming(struct vb2_queue *q)
&mxc_isi_m2m_frame_write_done,
bypass);
if (ret)
return ret;
goto err_pm;
mxc_isi_channel_get(m2m->pipe);
}
@ -290,7 +294,8 @@ static int mxc_isi_m2m_vb2_prepare_streaming(struct vb2_queue *q)
mxc_isi_channel_put(m2m->pipe);
mxc_isi_channel_release(m2m->pipe);
}
err_pm:
pm_runtime_put(m2m->isi->dev);
return ret;
}
@ -350,6 +355,8 @@ static void mxc_isi_m2m_vb2_unprepare_streaming(struct vb2_queue *q)
}
WARN_ON(m2m->usage_count < 0);
pm_runtime_put(m2m->isi->dev);
}
static const struct vb2_ops mxc_isi_m2m_vb2_qops = {
@ -643,16 +650,10 @@ static int mxc_isi_m2m_open(struct file *file)
if (ret)
goto err_ctx;
ret = pm_runtime_resume_and_get(m2m->isi->dev);
if (ret)
goto err_ctrls;
v4l2_fh_add(&ctx->fh, file);
return 0;
err_ctrls:
mxc_isi_m2m_ctx_ctrls_delete(ctx);
err_ctx:
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
err_fh:
@ -664,7 +665,6 @@ static int mxc_isi_m2m_open(struct file *file)
static int mxc_isi_m2m_release(struct file *file)
{
struct mxc_isi_m2m *m2m = video_drvdata(file);
struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
@ -676,8 +676,6 @@ static int mxc_isi_m2m_release(struct file *file)
mutex_destroy(&ctx->vb2_lock);
kfree(ctx);
pm_runtime_put(m2m->isi->dev);
return 0;
}