diff mbox series

[v12,08/29] media: platform: Improve the implementation of the system PM ops

Message ID 20200814071202.25067-10-xia.jiang@mediatek.com
State Superseded
Headers show
Series None | expand

Commit Message

Xia Jiang Aug. 14, 2020, 7:11 a.m. UTC
Add v4l2_m2m_suspend() function call in mtk_jpeg_suspend() to make sure
that the current frame is processed completely before suspend.
Add v4l2_m2m_resume() function call in mtk_jpeg_resume() to unblock the
driver from scheduling next frame.

Reviewed-by: Tomasz Figa <tfiga@chromium.org>

Signed-off-by: Xia Jiang <xia.jiang@mediatek.com>

---
v12: no changes
---
 .../media/platform/mtk-jpeg/mtk_jpeg_core.c    | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

-- 
2.18.0
diff mbox series

Patch

diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
index 7f74597262fc..ee4aaf618551 100644
--- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
@@ -1207,24 +1207,22 @@  static __maybe_unused int mtk_jpeg_pm_resume(struct device *dev)
 
 static __maybe_unused int mtk_jpeg_suspend(struct device *dev)
 {
-	int ret;
-
-	if (pm_runtime_suspended(dev))
-		return 0;
+	struct mtk_jpeg_dev *jpeg = dev_get_drvdata(dev);
 
-	ret = mtk_jpeg_pm_suspend(dev);
-	return ret;
+	v4l2_m2m_suspend(jpeg->m2m_dev);
+	return pm_runtime_force_suspend(dev);
 }
 
 static __maybe_unused int mtk_jpeg_resume(struct device *dev)
 {
+	struct mtk_jpeg_dev *jpeg = dev_get_drvdata(dev);
 	int ret;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	ret = mtk_jpeg_pm_resume(dev);
+	ret = pm_runtime_force_resume(dev);
+	if (ret < 0)
+		return ret;
 
+	v4l2_m2m_resume(jpeg->m2m_dev);
 	return ret;
 }