summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline_handler.cpp
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2019-12-22 02:31:56 -0600
committerPaul Elder <paul.elder@ideasonboard.com>2020-01-03 19:53:14 -0500
commiteffe4d6ced881486ef1d17448c7a53aa36ef41eb (patch)
tree8396311e1587ae93842f68baced2ecbe72ec6aec /src/libcamera/pipeline_handler.cpp
parent58a19b9d56e5002367794ef0d2e9cf8dcd8d0be5 (diff)
libcamera: camera_manager, pipeline_handler: allow retrieving cameras by device numbers
The V4L2 compatibility layer will need a way to map device numbers to libcamera Camera instances. Expose a method in the camera manager to retrieve Camera instances by devnum. The mapping from device numbers to Camera instances is optionally declared by pipeline handlers when they register cameras with the camera manager. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline_handler.cpp')
-rw-r--r--src/libcamera/pipeline_handler.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index 5badf31c..698dd525 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -7,6 +7,8 @@
#include "pipeline_handler.h"
+#include <sys/sysmacros.h>
+
#include <libcamera/buffer.h>
#include <libcamera/camera.h>
#include <libcamera/camera_manager.h>
@@ -438,19 +440,26 @@ void PipelineHandler::completeRequest(Camera *camera, Request *request)
* \brief Register a camera to the camera manager and pipeline handler
* \param[in] camera The camera to be added
* \param[in] data Pipeline-specific data for the camera
+ * \param[in] devnum Device number of the camera (optional)
*
* This method is called by pipeline handlers to register the cameras they
* handle with the camera manager. It associates the pipeline-specific \a data
* with the camera, for later retrieval with cameraData(). Ownership of \a data
* is transferred to the PipelineHandler.
+ *
+ * \a devnum is the device number (as returned by makedev) that the \a camera
+ * is to be associated with. This is for the V4L2 compatibility layer to map
+ * device nodes to Camera instances based on the device number
+ * registered by this method in \a devnum.
*/
void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera,
- std::unique_ptr<CameraData> data)
+ std::unique_ptr<CameraData> data,
+ dev_t devnum)
{
data->camera_ = camera.get();
cameraData_[camera.get()] = std::move(data);
cameras_.push_back(camera);
- manager_->addCamera(std::move(camera));
+ manager_->addCamera(std::move(camera), devnum);
}
/**