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 <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2018, Google Inc.
|
|
*
|
|
* camera_manager.h - Camera management
|
|
*/
|
|
#ifndef __LIBCAMERA_CAMERA_MANAGER_H__
|
|
#define __LIBCAMERA_CAMERA_MANAGER_H__
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <sys/types.h>
|
|
#include <vector>
|
|
|
|
#include <libcamera/object.h>
|
|
|
|
namespace libcamera {
|
|
|
|
class Camera;
|
|
class EventDispatcher;
|
|
|
|
class CameraManager : public Object
|
|
{
|
|
public:
|
|
CameraManager();
|
|
CameraManager(const CameraManager &) = delete;
|
|
CameraManager &operator=(const CameraManager &) = delete;
|
|
~CameraManager();
|
|
|
|
int start();
|
|
void stop();
|
|
|
|
std::vector<std::shared_ptr<Camera>> cameras() const;
|
|
std::shared_ptr<Camera> get(const std::string &name);
|
|
std::shared_ptr<Camera> get(dev_t devnum);
|
|
|
|
void addCamera(std::shared_ptr<Camera> camera,
|
|
const std::vector<dev_t> &devnums);
|
|
void removeCamera(Camera *camera);
|
|
|
|
static const std::string &version() { return version_; }
|
|
|
|
void setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher);
|
|
EventDispatcher *eventDispatcher();
|
|
|
|
private:
|
|
static const std::string version_;
|
|
static CameraManager *self_;
|
|
|
|
class Private;
|
|
std::unique_ptr<Private> p_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|
|
|
|
#endif /* __LIBCAMERA_CAMERA_MANAGER_H__ */
|