mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-26 10:05:08 +03:00
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>
This commit is contained in:
parent
91dcd719d7
commit
cfe4f9622e
3 changed files with 21 additions and 27 deletions
|
@ -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_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue