summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2022-07-15 13:47:01 +0200
committerJacopo Mondi <jacopo@jmondi.org>2022-07-23 11:41:20 +0200
commit15a5ab99aea0f87c86a5e45401fc2641e813ff3e (patch)
treeba0884ba49aea3241f79a18e46e5a286790590c4 /include
parent0f1d5cc15b88bb9cbc759a77186c891c6481d7b2 (diff)
libcamera: v4l2_videodevice: Match formats supported by the device
Now that V4L2PixelFormat::fromPixelFormat() returns a list of formats to chose from by checking which ones are actually supported by the video device. The first format found to match one of the device supported ones is returned. As V4L2VideoDevice::toV4L2PixelFormat() is a const function which uses other functions of the class, those functions has to be made const as well. In particular: - enumPixelformats() and enumSizes() do not modify the class state and can safely be made const. - formats() uses the above functions and does not itself modify the class state and can be made const - add a const version of V4L2Device::ioctl() to be used by the now const functions Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/internal/v4l2_device.h1
-rw-r--r--include/libcamera/internal/v4l2_videodevice.h6
2 files changed, 4 insertions, 3 deletions
diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h
index a52a5f2c..f7ec3c70 100644
--- a/include/libcamera/internal/v4l2_device.h
+++ b/include/libcamera/internal/v4l2_device.h
@@ -55,6 +55,7 @@ protected:
int setFd(UniqueFD fd);
int ioctl(unsigned long request, void *argp);
+ int ioctl(unsigned long request, void *argp) const;
int fd() const { return fd_.get(); }
diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h
index 29fa0bba..6d8850c9 100644
--- a/include/libcamera/internal/v4l2_videodevice.h
+++ b/include/libcamera/internal/v4l2_videodevice.h
@@ -205,7 +205,7 @@ public:
int getFormat(V4L2DeviceFormat *format);
int tryFormat(V4L2DeviceFormat *format);
int setFormat(V4L2DeviceFormat *format);
- Formats formats(uint32_t code = 0);
+ Formats formats(uint32_t code = 0) const;
int setSelection(unsigned int target, Rectangle *rect);
@@ -251,8 +251,8 @@ private:
int getFormatSingleplane(V4L2DeviceFormat *format);
int trySetFormatSingleplane(V4L2DeviceFormat *format, bool set);
- std::vector<V4L2PixelFormat> enumPixelformats(uint32_t code);
- std::vector<SizeRange> enumSizes(V4L2PixelFormat pixelFormat);
+ std::vector<V4L2PixelFormat> enumPixelformats(uint32_t code) const;
+ std::vector<SizeRange> enumSizes(V4L2PixelFormat pixelFormat) const;
int requestBuffers(unsigned int count, enum v4l2_memory memoryType);
int createBuffers(unsigned int count,