[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240326031237.25331-5-changhuang.liang@starfivetech.com>
Date: Mon, 25 Mar 2024 20:12:37 -0700
From: Changhuang Liang <changhuang.liang@...rfivetech.com>
To: Mauro Carvalho Chehab <mchehab@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Hans Verkuil <hverkuil-cisco@...all.nl>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Jack Zhu <jack.zhu@...rfivetech.com>,
Changhuang Liang <changhuang.liang@...rfivetech.com>,
Dan Carpenter <dan.carpenter@...aro.org>,
Jayshri Pawar <jpawar@...ence.com>,
Jai Luthra <j-luthra@...com>,
linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-staging@...ts.linux.dev
Subject: [PATCH v1 4/4] staging: media: starfive: Add suspend and resume support
This patch implements suspend and resume operation for StarFive Camera
Subsystem. It supports hibernation during streaming and resume streaming
when the system wake-up stage.
Signed-off-by: Changhuang Liang <changhuang.liang@...rfivetech.com>
---
.../staging/media/starfive/camss/stf-camss.c | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/staging/media/starfive/camss/stf-camss.c b/drivers/staging/media/starfive/camss/stf-camss.c
index a587f860101a..9abd8ee405e2 100644
--- a/drivers/staging/media/starfive/camss/stf-camss.c
+++ b/drivers/staging/media/starfive/camss/stf-camss.c
@@ -412,10 +412,59 @@ static int __maybe_unused stfcamss_runtime_resume(struct device *dev)
return 0;
}
+static int __maybe_unused stfcamss_suspend(struct device *dev)
+{
+ struct stfcamss *stfcamss = dev_get_drvdata(dev);
+ struct stfcamss_video *video;
+ unsigned int i;
+
+ for (i = 0; i < STF_CAPTURE_NUM; ++i) {
+ video = &stfcamss->captures[i].video;
+ if (video->vb2_q.streaming) {
+ video->ops->stop_streaming(video);
+ video->ops->flush_buffers(video, VB2_BUF_STATE_ERROR);
+ }
+ }
+
+ return pm_runtime_force_suspend(dev);
+}
+
+static int __maybe_unused stfcamss_resume(struct device *dev)
+{
+ struct stfcamss *stfcamss = dev_get_drvdata(dev);
+ struct stf_isp_dev *isp_dev = &stfcamss->isp_dev;
+ struct v4l2_subdev_state *sd_state;
+ struct stfcamss_video *video;
+ unsigned int i;
+ int ret;
+
+ ret = pm_runtime_force_resume(dev);
+ if (ret < 0) {
+ dev_err(dev, "Failed to resume\n");
+ return ret;
+ }
+
+ sd_state = v4l2_subdev_lock_and_get_active_state(&isp_dev->subdev);
+
+ if (isp_dev->subdev.enabled_streams)
+ stf_isp_stream_on(isp_dev, sd_state);
+
+ v4l2_subdev_unlock_state(sd_state);
+
+ for (i = 0; i < STF_CAPTURE_NUM; ++i) {
+ video = &stfcamss->captures[i].video;
+ if (video->vb2_q.streaming)
+ video->ops->start_streaming(video);
+ }
+
+ return 0;
+}
+
static const struct dev_pm_ops stfcamss_pm_ops = {
SET_RUNTIME_PM_OPS(stfcamss_runtime_suspend,
stfcamss_runtime_resume,
NULL)
+ SET_SYSTEM_SLEEP_PM_OPS(stfcamss_suspend, stfcamss_resume)
};
static struct platform_driver stfcamss_driver = {
--
2.25.1
Powered by blists - more mailing lists