From 5801dedd2a30e7123a0f78e6140c409c7c35988c Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Fri, 5 Jun 2020 20:36:32 +0900 Subject: libcamera: CameraManager, PipelineHandler: Automatically map devnums to Camera MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The V4L2 compatibility layer uses devnum to match video device nodes to libcamera Cameras. Some pipeline handlers don't report a devnum for their camera, which prevents the V4L2 compatibility layer from matching video device nodes to these cameras. To fix this, we first allow the camera manager to map multiple devnums to a camera. Next, we walk the media device and entity list and tell the camera manager to map every one of these devnums that is a video capture node to the camera. Since we decided that all video capture nodes that belong to a camera can be opened via the V4L2 compatibility layer to map to that camera, it would cause confusion for users if some pipeline handlers decided that only specific device nodes would map to the camera. To prevent this confusion, remove the ability for pipeline handlers to declare their own devnum-to-camera mapping. The only pipeline handler that declares the devnum mapping is the UVC pipeline handler, so remove the devnum there. We considered walking the media entity list and taking the devnum from just the one with the default flag set, but we found that some drivers (eg. vimc) don't set this flag for any entity. Instead, we take all the video capture nodes (entities with the sink pad flag set). Signed-off-by: Paul Elder Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- include/libcamera/camera_manager.h | 3 ++- include/libcamera/internal/pipeline_handler.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index 079f848a..95dc6360 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -34,7 +34,8 @@ public: std::shared_ptr get(const std::string &name); std::shared_ptr get(dev_t devnum); - void addCamera(std::shared_ptr camera, dev_t devnum); + void addCamera(std::shared_ptr camera, + const std::vector &devnums); void removeCamera(Camera *camera); static const std::string &version() { return version_; } diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 56968d14..22e629a8 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -91,7 +91,7 @@ public: protected: void registerCamera(std::shared_ptr camera, - std::unique_ptr data, dev_t devnum = 0); + std::unique_ptr data); void hotplugMediaDevice(MediaDevice *media); virtual int queueRequestDevice(Camera *camera, Request *request) = 0; -- cgit v1.2.1