[RFC,v1,15/20] libcamera: pipeline_handler: Make match() optional
diff mbox series

Message ID 20260918080734.1228227-16-naush@raspberrypi.com
State New
Headers show
Series
  • libcamera: New enumeration API
Related show

Commit Message

Naushir Patuck Sept. 18, 2026, 7:59 a.m. UTC
The camera manager creates the cameras of pipeline handlers that support
surveying without ever calling their match(), which leaves the match()
implementations of those handlers unreachable. Give match() a default
implementation matching no device, so that pipeline handlers supporting
enumeration can implement survey() and createCamera() only.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 include/libcamera/internal/pipeline_handler.h | 2 +-
 src/libcamera/pipeline_handler.cpp            | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h
index 1f82ff998514..4baac2fa87fa 100644
--- a/include/libcamera/internal/pipeline_handler.h
+++ b/include/libcamera/internal/pipeline_handler.h
@@ -40,7 +40,7 @@  public:
 			unsigned int maxQueuedRequestsDevice = 32);
 	virtual ~PipelineHandler();
 
-	virtual bool match(DeviceEnumerator *enumerator) = 0;
+	virtual bool match(DeviceEnumerator *enumerator);
 	virtual int survey(const DeviceEnumerator *enumerator,
 			   std::vector<std::shared_ptr<CameraDescriptor>> *descriptors);
 	virtual int createCamera(const CameraDescriptor *descriptor);
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index 6023d028f40b..7bc778b053b6 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -109,11 +109,20 @@  PipelineHandler::~PipelineHandler()
  * If this function returns true, a new instance of the pipeline handler will
  * be created and its match() function called.
  *
+ * Pipeline handlers that report their cameras through survey() have them
+ * created by the camera manager without this function being called, and
+ * therefore do not need to implement it. The default implementation matches
+ * no device.
+ *
  * \context This function is called from the CameraManager thread.
  *
  * \return true if media devices have been acquired and camera instances
  * created, or false otherwise
  */
+bool PipelineHandler::match([[maybe_unused]] DeviceEnumerator *enumerator)
+{
+	return false;
+}
 
 /**
  * \brief Survey the media devices for cameras this pipeline handler supports