diff options
author | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2023-05-03 21:45:35 +0100 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2023-06-17 22:52:39 +0100 |
commit | b9113a86269281ec8cda96140be24e6227abe791 (patch) | |
tree | 1f04144c14de580e2d51c129e37a3285f885f4a0 /src/libcamera/camera_manager.cpp | |
parent | 1de9518f51a92ee931ccb5041049e147a46ff65b (diff) |
libcamera: pipeline: Register device numbers with camera
Register the identified device numbers with each camera as the
SystemDevices property.
This facilitates camera daemons or other systems to identify which
devices are being managed by libcamera, and can prevent duplication of
camera resources.
As the SystemDevices property now provides this list of devices, use it
directly from within the CameraManager when adding a Camera rather than
passing it through the internal API.
Tested-by: Ashok Sidipotu <ashok.sidipotu@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/libcamera/camera_manager.cpp')
-rw-r--r-- | src/libcamera/camera_manager.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index cafd7bce..7c65bb99 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -11,7 +11,9 @@ #include <libcamera/base/utils.h> #include <libcamera/camera.h> +#include <libcamera/property_ids.h> +#include "libcamera/internal/camera.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/pipeline_handler.h" @@ -151,19 +153,17 @@ void CameraManager::Private::cleanup() /** * \brief Add a camera to the camera manager * \param[in] camera The camera to be added - * \param[in] devnums The device numbers to associate with \a camera * * This function is called by pipeline handlers to register the cameras they * handle with the camera manager. Registered cameras are immediately made * available to the system. * - * \a devnums are used by the V4L2 compatibility layer to map V4L2 device nodes - * to Camera instances. + * Device numbers from the SystemDevices property are used by the V4L2 + * compatibility layer to map V4L2 device nodes to Camera instances. * * \context This function shall be called from the CameraManager thread. */ -void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera, - const std::vector<dev_t> &devnums) +void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera) { ASSERT(Thread::current() == this); @@ -178,6 +178,10 @@ void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera, } } + auto devnums = camera->properties() + .get(properties::SystemDevices) + .value_or(Span<int64_t>{}); + cameras_.push_back(std::move(camera)); unsigned int index = cameras_.size() - 1; |