@@ -514,6 +514,8 @@ int Camera::freeBuffers()
pipe_->freeBuffers(this, stream);
}
+ pipe_->postFreeBuffers(this);
+
state_ = CameraConfigured;
return 0;
@@ -64,6 +64,10 @@ public:
}
virtual int allocateBuffers(Camera *camera, Stream *stream) = 0;
virtual int freeBuffers(Camera *camera, Stream *stream) = 0;
+ virtual int postFreeBuffers(Camera *camera)
+ {
+ return 0;
+ }
virtual int start(Camera *camera) = 0;
virtual void stop(Camera *camera);
@@ -109,6 +109,7 @@ public:
const std::set<Stream *> &activeStreams) override;
int allocateBuffers(Camera *camera, Stream *stream) override;
int freeBuffers(Camera *camera, Stream *stream) override;
+ int postFreeBuffers(Camera *camera) override;
int start(Camera *camera) override;
void stop(Camera *camera) override;
@@ -543,26 +544,8 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)
IPU3CameraData *data = cameraData(camera);
V4L2Device *viewfinder = data->imgu->viewfinder;
V4L2Device *output = data->imgu->output;
- V4L2Device *input = data->imgu->input;
- V4L2Device *cio2 = data->cio2.output;
- V4L2Device *stat = data->imgu->stat;
int ret;
- if (data->cio2.pool.count()) {
- ret = input->releaseBuffers();
- if (ret)
- LOG(IPU3, Error) << "Failed to release ImgU input memory";
-
- ret = cio2->releaseBuffers();
- if (ret)
- LOG(IPU3, Error) << "Failed to release CIO2 memory";
-
- ret = stat->releaseBuffers();
- if (ret)
- LOG(IPU3, Error) << "Failed to release ImgU stat memory";
-
- }
-
if (isOutput(data, stream)) {
ret = output->releaseBuffers();
if (ret)
@@ -594,6 +577,35 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)
return 0;
}
+int PipelineHandlerIPU3::postFreeBuffers(Camera *camera)
+{
+ IPU3CameraData *data = cameraData(camera);
+ V4L2Device *input = data->imgu->input;
+ V4L2Device *cio2 = data->cio2.output;
+ V4L2Device *stat = data->imgu->stat;
+ int retval = 0;
+
+ int ret = input->releaseBuffers();
+ if (ret) {
+ retval |= ret;
+ LOG(IPU3, Error) << "Failed to release ImgU input memory";
+ }
+
+ ret = cio2->releaseBuffers();
+ if (ret) {
+ retval |= ret;
+ LOG(IPU3, Error) << "Failed to release CIO2 memory";
+ }
+
+ ret = stat->releaseBuffers();
+ if (ret) {
+ retval |= ret;
+ LOG(IPU3, Error) << "Failed to release ImgU stat memory";
+ }
+
+ return retval;
+}
+
int PipelineHandlerIPU3::start(Camera *camera)
{
IPU3CameraData *data = cameraData(camera);
@@ -231,7 +231,24 @@ PipelineHandler::~PipelineHandler()
* After a capture session has been stopped all buffers associated with the
* stream shall be freed.
*
- * The intended caller of this method is the Camera class.
+ * The intended caller of this method is the Camera class which calls it
+ * once per each active stream.
+ *
+ * \return 0 on success or a negative error code otherwise
+ */
+
+/**
+ * \fn PipelineHandler::postFreeBuffers()
+ * \brief Perform post-memory release operations. Optional for pipeline
+ * handlers to implement
+ * \param[in] camera The camera to release memory on
+ *
+ * If any clean up operation is required this virtual method provides an entry
+ * point for pipeline handlers to do so.
+ *
+ * The intended caller of this method is the Camera class, which call it once
+ * after performing per-stream memory release by calling
+ * PipelineHandler::freeBuffers() on each active stream.
*
* \return 0 on success or a negative error code otherwise
*/
Add a postFreeBuffers virtual method to the PipelineHandler base class and call if after performing per-stream memory release. Implement the method in the IPU3 pipeline handler to perform memory release on the CIO2 unit and ImgU input and stat video nodes. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> --- src/libcamera/camera.cpp | 2 + src/libcamera/include/pipeline_handler.h | 4 ++ src/libcamera/pipeline/ipu3/ipu3.cpp | 48 +++++++++++++++--------- src/libcamera/pipeline_handler.cpp | 19 +++++++++- 4 files changed, 54 insertions(+), 19 deletions(-)