@@ -347,6 +347,7 @@ static int mxc_isi_pm_suspend(struct device *dev)
struct mxc_isi_pipe *pipe = &isi->pipes[i];
mxc_isi_video_suspend(pipe);
+ mxc_isi_m2m_suspend(pipe);
}
return pm_runtime_force_suspend(dev);
@@ -376,6 +377,13 @@ static int mxc_isi_pm_resume(struct device *dev)
*/
err = ret;
}
+
+ ret = mxc_isi_m2m_resume(pipe);
+ if (ret) {
+ dev_err(dev, "Failed to resume ISI%u (%d) for m2m\n", i,
+ ret);
+ err = ret;
+ }
}
return err;
@@ -343,6 +343,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_pipe *pipe);
+int mxc_isi_m2m_resume(struct mxc_isi_pipe *pipe);
#else
static inline int mxc_isi_m2m_register(struct mxc_isi_dev *isi,
struct v4l2_device *v4l2_dev)
@@ -353,6 +355,15 @@ static inline int mxc_isi_m2m_unregister(struct mxc_isi_dev *isi)
{
return 0;
}
+
+static inline void mxc_isi_m2m_suspend(struct mxc_isi_pipe *pipe)
+{
+}
+
+static inline int mxc_isi_m2m_resume(struct mxc_isi_pipe *pipe)
+{
+ return 0;
+}
#endif
int mxc_isi_channel_acquire(struct mxc_isi_pipe *pipe,
@@ -722,6 +722,54 @@ 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_pipe *pipe)
+{
+ struct mxc_isi_m2m *m2m = &pipe->isi->m2m;
+ struct mxc_isi_m2m_ctx *ctx = m2m->last_ctx;
+
+ /*
+ * Check pipe for ISI memory to memory since only
+ * channel 0 support this feature.
+ */
+ if (m2m->pipe != pipe || m2m->usage_count == 0)
+ return;
+
+ v4l2_m2m_suspend(m2m->m2m_dev);
+
+ if (ctx->chained)
+ mxc_isi_channel_unchain(pipe);
+
+ mxc_isi_channel_disable(pipe);
+ mxc_isi_channel_put(pipe);
+}
+
+int mxc_isi_m2m_resume(struct mxc_isi_pipe *pipe)
+{
+ struct mxc_isi_m2m *m2m = &pipe->isi->m2m;
+ struct mxc_isi_m2m_ctx *ctx = m2m->last_ctx;
+
+ /*
+ * Check pipe for ISI memory to memory since only
+ * channel 0 support this feature.
+ */
+ if (m2m->pipe != pipe || m2m->usage_count == 0)
+ return 0;
+
+ mxc_isi_channel_get(pipe);
+
+ if (ctx->chained)
+ mxc_isi_channel_chain(pipe, false);
+
+ m2m->last_ctx = NULL;
+ v4l2_m2m_resume(m2m->m2m_dev);
+
+ return 0;
+}
+
/* -----------------------------------------------------------------------------
* Registration
*/