15 #include <linux/videodev2.h> 19 #include <libcamera/base/span.h> 42 const struct v4l2_query_ext_ctrl *
controlInfo(uint32_t
id)
const;
44 const std::string &
deviceNode()
const {
return deviceNode_; }
56 int open(
unsigned int flags);
59 int ioctl(
unsigned long request,
void *argp);
61 int fd()
const {
return fd_.
get(); }
64 static std::optional<ColorSpace>
toColorSpace(
const T &v4l2Format,
68 static int fromColorSpace(
const std::optional<ColorSpace> &colorSpace, T &v4l2Format);
72 static std::unique_ptr<ControlId> v4l2ControlId(
const v4l2_query_ext_ctrl &ctrl);
73 std::optional<ControlInfo> v4l2ControlInfo(
const v4l2_query_ext_ctrl &ctrl);
74 std::optional<ControlInfo> v4l2MenuControlInfo(
const v4l2_query_ext_ctrl &ctrl);
78 Span<const v4l2_ext_control> v4l2Ctrls);
80 void eventAvailable();
82 std::map<unsigned int, struct v4l2_query_ext_ctrl> controlInfo_;
83 std::vector<std::unique_ptr<ControlId>> controlIds_;
86 std::string deviceNode_;
90 bool frameStartEnabled_;
int fd() const
Retrieve the V4L2 device file descriptor.
Definition: v4l2_device.h:61
int open(unsigned int flags)
Open a V4L2 device node.
Definition: v4l2_device.cpp:82
Base class for V4L2VideoDevice and V4L2Subdevice.
Definition: v4l2_device.h:31
static int fromColorSpace(const std::optional< ColorSpace > &colorSpace, T &v4l2Format)
Fill in the color space fields of a V4L2 format from a ColorSpace.
Definition: v4l2_device.cpp:927
Class and enums to represent color spaces.
File descriptor wrapper that owns a file descriptor.
int get() const
Retrieve the managed file descriptor.
Definition: unique_fd.h:60
Base class to support log message extensions.
Definition: log.h:91
Top-level libcamera namespace.
Definition: backtrace.h:17
void close()
Close the device node.
Definition: v4l2_device.cpp:141
std::string devicePath() const
Retrieve the device path in sysfs.
Definition: v4l2_device.cpp:398
bool isOpen() const
Check if the V4L2 device node is open.
Definition: v4l2_device.h:35
static std::optional< ColorSpace > toColorSpace(const T &v4l2Format, PixelFormatInfo::ColourEncoding colourEncoding)
Convert the color space fields in a V4L2 format to a ColorSpace.
Definition: v4l2_device.cpp:848
Signal< uint32_t > frameStart
A Signal emitted when capture of a frame has started.
Definition: v4l2_device.h:48
const std::string & deviceNode() const
Retrieve the device node path.
Definition: v4l2_device.h:44
A map of ControlId to ControlInfo.
Definition: controls.h:305
~V4L2Device()
Destroy a V4L2Device.
Definition: v4l2_device.cpp:69
Signal & slot implementation.
ControlType
Define the data type of a Control.
Definition: controls.h:27
unique_ptr-like wrapper for a file descriptor
Definition: unique_fd.h:17
void updateControlInfo()
Update the information for all device controls.
Definition: v4l2_device.cpp:674
const struct v4l2_query_ext_ctrl * controlInfo(uint32_t id) const
Retrieve the v4l2_query_ext_ctrl information for the given control.
Definition: v4l2_device.cpp:378
int setControls(ControlList *ctrls)
Write controls to the device.
Definition: v4l2_device.cpp:282
int setFd(UniqueFD fd)
Set the file descriptor of a V4L2 device.
Definition: v4l2_device.cpp:120
Notify of activity on a file descriptor.
Definition: event_notifier.h:19
int ioctl(unsigned long request, void *argp)
Perform an IOCTL system call on the device node.
Definition: v4l2_device.cpp:455
const ControlInfoMap & controls() const
Retrieve the supported V4L2 controls and their information.
Definition: v4l2_device.h:37
V4L2Device(const std::string &deviceNode)
Construct a V4L2Device.
Definition: v4l2_device.cpp:60
ControlList getControls(const std::vector< uint32_t > &ids)
Read controls from the device.
Definition: v4l2_device.cpp:178
Associate a list of ControlId with their values for an object.
Definition: controls.h:349
Framework to manage controls related to an object.
bool isValid() const
Check if the UniqueFD owns a valid file descriptor.
Definition: unique_fd.h:61
std::unordered_map< unsigned int, const ControlId * > ControlIdMap
A map of numerical control ID to ControlId.
Definition: controls.h:303
int setFrameStartEnabled(bool enable)
Enable or disable frame start event notification.
Definition: v4l2_device.cpp:424