17 #include <linux/v4l2-subdev.h> 56 return capabilities & V4L2_SUBDEV_CAP_RO_SUBDEV;
60 return capabilities & V4L2_SUBDEV_CAP_STREAMS;
69 const std::string toString()
const;
77 using Formats = std::map<unsigned int, std::vector<SizeRange>>;
80 TryFormat = V4L2_SUBDEV_FORMAT_TRY,
81 ActiveFormat = V4L2_SUBDEV_FORMAT_ACTIVE,
90 Stream(
unsigned int p,
unsigned int s)
106 : sink(snk), source(src), flags(f)
124 int getSelection(
const Stream &stream,
unsigned int target,
128 return getSelection({ pad, 0 }, target, rect);
130 int setSelection(
const Stream &stream,
unsigned int target,
134 return setSelection({ pad, 0 }, target, rect);
140 return formats({ pad, 0 });
144 Whence whence = ActiveFormat);
146 Whence whence = ActiveFormat)
148 return getFormat({ pad, 0 }, format, whence);
151 Whence whence = ActiveFormat);
153 Whence whence = ActiveFormat)
155 return setFormat({ pad, 0 }, format, whence);
158 int getRouting(
Routing *routing,
Whence whence = ActiveFormat);
159 int setRouting(
Routing *routing,
Whence whence = ActiveFormat);
161 const std::string &model();
164 static std::unique_ptr<V4L2Subdevice>
165 fromEntityName(
const MediaDevice *media,
const std::string &entity);
168 std::string logPrefix()
const override;
173 std::optional<ColorSpace>
174 toColorSpace(
const v4l2_mbus_framefmt &format)
const;
176 std::vector<unsigned int> enumPadCodes(
const Stream &stream);
177 std::vector<SizeRange> enumPadSizes(
const Stream &stream,
193 return !(lhs == rhs);
Utilities to help constructing class interfaces.
Base class for V4L2VideoDevice and V4L2Subdevice.
Definition: v4l2_device.h:32
int getFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence=ActiveFormat)
Retrieve the image format set on one of the V4L2 subdevice pads.
Definition: v4l2_subdevice.h:145
unsigned int stream
The stream number.
Definition: v4l2_subdevice.h:96
Stream source
The source stream of the route.
Definition: v4l2_subdevice.h:111
Class and enums to represent color spaces.
Route()
Construct a Route with default streams.
Definition: v4l2_subdevice.h:100
Top-level libcamera namespace.
Definition: backtrace.h:17
Stream sink
The sink stream of the route.
Definition: v4l2_subdevice.h:110
const MediaEntity * entity() const
Retrieve the media entity associated with the subdevice.
Definition: v4l2_subdevice.h:122
int setSelection(unsigned int pad, unsigned int target, Rectangle *rect)
Set selection rectangle rect for target.
Definition: v4l2_subdevice.h:132
int setFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence=ActiveFormat)
Set an image format on one of the V4L2 subdevice pads.
Definition: v4l2_subdevice.h:152
bool operator==(const V4L2Subdevice::Stream &lhs, const V4L2Subdevice::Stream &rhs)
Compare streams for equality.
Definition: v4l2_subdevice.cpp:1014
Describe a two-dimensional size.
Definition: geometry.h:50
std::map< unsigned int, std::vector< SizeRange > > Formats
A map of supported media bus formats to frame sizes.
Definition: v4l2_subdevice.h:77
std::vector< Route > Routing
V4L2 subdevice routing table.
Definition: v4l2_subdevice.h:115
int getSelection(unsigned int pad, unsigned int target, Rectangle *rect)
Get selection rectangle rect for target.
Definition: v4l2_subdevice.h:126
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
Describe a rectangle's position and dimensions.
Definition: geometry.h:240
Common base for V4L2 devices and subdevices.
V4L2 subdevice stream.
Definition: v4l2_subdevice.h:84
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition: geometry.cpp:91
const V4L2SubdeviceCapability & caps() const
Retrieve the subdevice V4L2 capabilities.
Definition: v4l2_subdevice.h:162
bool hasStreams() const
Retrieve if a subdevice supports the V4L2 streams API.
Definition: v4l2_subdevice.h:58
Formats formats(unsigned int pad)
Enumerate all media bus codes and frame sizes on a pad.
Definition: v4l2_subdevice.h:138
bool isReadOnly() const
Retrieve if a subdevice is registered as read-only.
Definition: v4l2_subdevice.h:54
V4L2 subdevice routing table entry.
Definition: v4l2_subdevice.h:99
Stream(unsigned int p, unsigned int s)
Construct a Stream with a given pad and stream number.
Definition: v4l2_subdevice.h:90
Route(const Stream &snk, const Stream &src, uint32_t f)
Construct a Route from sink to source.
Definition: v4l2_subdevice.h:105
uint32_t flags
The route flags (V4L2_SUBDEV_ROUTE_FL_*)
Definition: v4l2_subdevice.h:112
unsigned int pad
The 0-indexed pad number.
Definition: v4l2_subdevice.h:95
Data structures related to geometric objects.
Whence
Specify the type of format for getFormat() and setFormat() operations.
Definition: v4l2_subdevice.h:79
Stream()
Construct a Stream with pad and stream set to 0.
Definition: v4l2_subdevice.h:85
A V4L2 subdevice as exposed by the Linux kernel.
Definition: v4l2_subdevice.h:74
struct v4l2_subdev_capability object wrapper and helpers
Definition: v4l2_subdevice.h:53