[libcamera-devel] [RFC 1/7] libcamera: pipelines: implement start and stop of a camera

Niklas Söderlund niklas.soderlund at ragnatech.se
Tue Feb 5 01:06:56 CET 2019


The camera need methods to start and stop capturing once it have been
configured. Extend the pipeline API to provide this and implement stubs
in all pipeline handlers.

Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
---
 src/libcamera/include/pipeline_handler.h |  3 +++
 src/libcamera/pipeline/ipu3/ipu3.cpp     | 14 ++++++++++++
 src/libcamera/pipeline/uvcvideo.cpp      | 14 ++++++++++++
 src/libcamera/pipeline/vimc.cpp          | 14 ++++++++++++
 src/libcamera/pipeline_handler.cpp       | 27 ++++++++++++++++++++++++
 5 files changed, 72 insertions(+)

diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h
index b4321f0fa0f765be..4bfe45aaf78e34ab 100644
--- a/src/libcamera/include/pipeline_handler.h
+++ b/src/libcamera/include/pipeline_handler.h
@@ -45,6 +45,9 @@ public:
 	virtual int configureStreams(Camera *camera,
 				     std::map<Stream *, StreamConfiguration> &config) = 0;
 
+	virtual int start(const Camera *camera) = 0;
+	virtual void stop(const Camera *camera) = 0;
+
 	virtual bool match(DeviceEnumerator *enumerator) = 0;
 
 protected:
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 7823bbb55d9bde16..3bf196051f2ebdbc 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -34,6 +34,9 @@ public:
 	int configureStreams(Camera *camera,
 			     std::map<Stream *, StreamConfiguration> &config) override;
 
+	int start(const Camera *camera) override;
+	void stop(const Camera *camera) override;
+
 	bool match(DeviceEnumerator *enumerator);
 
 private:
@@ -104,6 +107,17 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,
 	return 0;
 }
 
+int PipelineHandlerIPU3::start(const Camera *camera)
+{
+	LOG(IPU3, Error) << "TODO: start camera";
+	return 0;
+}
+
+void PipelineHandlerIPU3::stop(const Camera *camera)
+{
+	LOG(IPU3, Error) << "TODO: stop camera";
+}
+
 bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)
 {
 	DeviceMatch cio2_dm("ipu3-cio2");
diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
index ad4d45d0698519b6..e6a15c58a63cf76b 100644
--- a/src/libcamera/pipeline/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo.cpp
@@ -30,6 +30,9 @@ public:
 	int configureStreams(Camera *camera,
 			     std::map<Stream *, StreamConfiguration> &config) override;
 
+	int start(const Camera *camera) override;
+	void stop(const Camera *camera) override;
+
 	bool match(DeviceEnumerator *enumerator);
 
 private:
@@ -82,6 +85,17 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,
 	return 0;
 }
 
+int PipelineHandlerUVC::start(const Camera *camera)
+{
+	LOG(UVC, Error) << "TODO: start camera";
+	return 0;
+}
+
+void PipelineHandlerUVC::stop(const Camera *camera)
+{
+	LOG(UVC, Error) << "TODO: stop camera";
+}
+
 bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)
 {
 	DeviceMatch dm("uvcvideo");
diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp
index 900477e257232b70..11eca0cd4d9a6e0c 100644
--- a/src/libcamera/pipeline/vimc.cpp
+++ b/src/libcamera/pipeline/vimc.cpp
@@ -30,6 +30,9 @@ public:
 	int configureStreams(Camera *camera,
 			     std::map<Stream *, StreamConfiguration> &config) override;
 
+	int start(const Camera *camera) override;
+	void stop(const Camera *camera) override;
+
 	bool match(DeviceEnumerator *enumerator);
 
 private:
@@ -77,6 +80,17 @@ int PipeHandlerVimc::configureStreams(Camera *camera,
 	return 0;
 }
 
+int PipeHandlerVimc::start(const Camera *camera)
+{
+	LOG(VIMC, Error) << "TODO: start camera";
+	return 0;
+}
+
+void PipeHandlerVimc::stop(const Camera *camera)
+{
+	LOG(VIMC, Error) << "TODO: stop camera";
+}
+
 bool PipeHandlerVimc::match(DeviceEnumerator *enumerator)
 {
 	DeviceMatch dm("vimc");
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index 3a560e10c442717f..fa5f780cea34fc8f 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -109,6 +109,33 @@ PipelineHandler::~PipelineHandler()
  * \return 0 on success or a negative error code on error.
  */
 
+/**
+ * \fn PipelineHandler::start()
+ * \brief Start capturing from a group of streams
+ * \param[in] camera The camera to start
+ *
+ * Start the group of streams that have been configured for capture by
+ * \a configureStreams(). The intended caller of this interface is
+ * the Camera class which will in turn will receive the call from the
+ * application to indicate that it's done configuring the streams
+ * and are ready to capture.
+ *
+ * \return 0 on success or a negative error code on error.
+ */
+
+/**
+ * \fn PipelineHandler::stop()
+ * \brief Stop capturing from all running streams
+ * \param[in] camera The camera to stop
+ *
+ * Stop processing requests, finish processing all already queued requests
+ * and once all buffers on all streams have been dequeued stop capturing
+ * from all running streams. Finish processing of queued requests do not
+ * necessarily involve processing them by the capture hardware but notifying
+ * the application that a queued request was not processed due to the fact
+ * that the camera was stopped before they could be processed.
+ */
+
 /**
  * \fn PipelineHandler::match(DeviceEnumerator *enumerator)
  * \brief Match media devices and create camera instances
-- 
2.20.1



More information about the libcamera-devel mailing list