summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2025-08-21 16:51:23 +0300
committerHans Verkuil <hverkuil+cisco@kernel.org>2025-08-31 12:10:07 +0300
commitaec0f43f1429641e8a94d54aaecd16527b589486 (patch)
tree640992b5401a15c0037d3f3c90f41dd6b8d39c1c
parent178aa3360220231dd91e7dbc2eb984525886c9c1 (diff)
downloadlinux-aec0f43f1429641e8a94d54aaecd16527b589486.tar.xz
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>
-rw-r--r--drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
index a8b10d944d69..00afcbfbdde4 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
@@ -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 @@ err_deinit:
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 @@ err_fh:
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;
}