From b9113a86269281ec8cda96140be24e6227abe791 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Wed, 3 May 2023 21:45:35 +0100 Subject: 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 Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Signed-off-by: Kieran Bingham --- src/libcamera/pipeline_handler.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/libcamera/pipeline_handler.cpp') diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 49092ea8..9c74c6cf 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "libcamera/internal/camera.h" #include "libcamera/internal/camera_manager.h" @@ -612,7 +613,7 @@ void PipelineHandler::registerCamera(std::shared_ptr camera) * Walk the entity list and map the devnums of all capture video nodes * to the camera. */ - std::vector devnums; + std::vector devnums; for (const std::shared_ptr &media : mediaDevices_) { for (const MediaEntity *entity : media->entities()) { if (entity->pads().size() == 1 && @@ -624,7 +625,14 @@ void PipelineHandler::registerCamera(std::shared_ptr camera) } } - manager_->_d()->addCamera(std::move(camera), devnums); + /* + * Store the associated devices as a property of the camera to allow + * systems to identify which devices are managed by libcamera. + */ + Camera::Private *data = camera->_d(); + data->properties_.set(properties::SystemDevices, devnums); + + manager_->_d()->addCamera(std::move(camera)); } /** -- cgit v1.2.1