media: nxp: imx8-isi: Add suspend/resume support for ISI mem2mem

Add suspend/resume support for ISI when work at memory to memory mode.

Link: https://lore.kernel.org/r/20250815-isi_m2m-v2-1-32e3720880cc@nxp.com
Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
Guoniu Zhou 2025-08-15 17:28:51 +08:00 committed by Hans Verkuil
parent 9a21ffeade
commit 45854b1e59
3 changed files with 51 additions and 0 deletions

View File

@ -374,6 +374,8 @@ static int mxc_isi_pm_suspend(struct device *dev)
mxc_isi_video_suspend(pipe);
}
mxc_isi_m2m_suspend(&isi->m2m);
return pm_runtime_force_suspend(dev);
}
@ -403,6 +405,12 @@ static int mxc_isi_pm_resume(struct device *dev)
}
}
ret = mxc_isi_m2m_resume(&isi->m2m);
if (ret) {
dev_err(dev, "Failed to resume ISI (%d) for m2m\n", ret);
err = ret;
}
return err;
}

View File

@ -342,6 +342,8 @@ int mxc_isi_video_buffer_prepare(struct mxc_isi_dev *isi, struct vb2_buffer *vb2
#ifdef CONFIG_VIDEO_IMX8_ISI_M2M
int mxc_isi_m2m_register(struct mxc_isi_dev *isi, struct v4l2_device *v4l2_dev);
int mxc_isi_m2m_unregister(struct mxc_isi_dev *isi);
void mxc_isi_m2m_suspend(struct mxc_isi_m2m *m2m);
int mxc_isi_m2m_resume(struct mxc_isi_m2m *m2m);
#else
static inline int mxc_isi_m2m_register(struct mxc_isi_dev *isi,
struct v4l2_device *v4l2_dev)
@ -352,6 +354,13 @@ static inline int mxc_isi_m2m_unregister(struct mxc_isi_dev *isi)
{
return 0;
}
static inline void mxc_isi_m2m_suspend(struct mxc_isi_m2m *m2m)
{
}
static inline int mxc_isi_m2m_resume(struct mxc_isi_m2m *m2m)
{
return 0;
}
#endif
int mxc_isi_channel_acquire(struct mxc_isi_pipe *pipe,

View File

@ -730,6 +730,40 @@ static const struct v4l2_file_operations mxc_isi_m2m_fops = {
.mmap = v4l2_m2m_fop_mmap,
};
/* -----------------------------------------------------------------------------
* Suspend & resume
*/
void mxc_isi_m2m_suspend(struct mxc_isi_m2m *m2m)
{
if (m2m->usage_count == 0)
return;
v4l2_m2m_suspend(m2m->m2m_dev);
if (m2m->chained_count > 0)
mxc_isi_channel_unchain(m2m->pipe);
mxc_isi_channel_disable(m2m->pipe);
mxc_isi_channel_put(m2m->pipe);
}
int mxc_isi_m2m_resume(struct mxc_isi_m2m *m2m)
{
if (m2m->usage_count == 0)
return 0;
mxc_isi_channel_get(m2m->pipe);
if (m2m->chained_count > 0)
mxc_isi_channel_chain(m2m->pipe);
m2m->last_ctx = NULL;
v4l2_m2m_resume(m2m->m2m_dev);
return 0;
}
/* -----------------------------------------------------------------------------
* Registration
*/