summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorHirokazu Honda <hiroh@chromium.org>2021-06-10 16:50:23 +0900
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-12-04 23:05:04 +0200
commitcfe4f9622ead96702d879835ca9dd2942d503399 (patch)
treec2d52be45b44f5fcd67e297a0da4fdd3ece44bed /include
parent91dcd719d7c4aba3cd9942a77d03068c3f05c0a5 (diff)
libcamera: v4l2_device: Use UniqueFD for a file descriptor
Manages a file descriptor owned by V4L2Device for a v4l2 device node by UniqueFD. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/internal/v4l2_device.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h
index 7816a290..8886b750 100644
--- a/include/libcamera/internal/v4l2_device.h
+++ b/include/libcamera/internal/v4l2_device.h
@@ -16,6 +16,7 @@
#include <libcamera/base/log.h>
#include <libcamera/base/signal.h>
#include <libcamera/base/span.h>
+#include <libcamera/base/unique_fd.h>
#include <libcamera/controls.h>
@@ -27,7 +28,7 @@ class V4L2Device : protected Loggable
{
public:
void close();
- bool isOpen() const { return fd_ != -1; }
+ bool isOpen() const { return fd_.isValid(); }
const ControlInfoMap &controls() const { return controls_; }
@@ -49,11 +50,11 @@ protected:
~V4L2Device();
int open(unsigned int flags);
- int setFd(int fd);
+ int setFd(UniqueFD fd);
int ioctl(unsigned long request, void *argp);
- int fd() const { return fd_; }
+ int fd() const { return fd_.get(); }
private:
static ControlType v4l2CtrlType(uint32_t ctrlType);
@@ -72,7 +73,7 @@ private:
ControlIdMap controlIdMap_;
ControlInfoMap controls_;
std::string deviceNode_;
- int fd_;
+ UniqueFD fd_;
EventNotifier *fdEventNotifier_;
bool frameStartEnabled_;