diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/v4l2/meson.build | 1 | ||||
-rw-r--r-- | src/v4l2/v4l2_camera_file.cpp | 26 | ||||
-rw-r--r-- | src/v4l2/v4l2_camera_file.h | 37 |
3 files changed, 64 insertions, 0 deletions
diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build index f2e4aaf2..e3838f0b 100644 --- a/src/v4l2/meson.build +++ b/src/v4l2/meson.build @@ -2,6 +2,7 @@ v4l2_compat_sources = files([ 'v4l2_camera.cpp', + 'v4l2_camera_file.cpp', 'v4l2_camera_proxy.cpp', 'v4l2_compat.cpp', 'v4l2_compat_manager.cpp', diff --git a/src/v4l2/v4l2_camera_file.cpp b/src/v4l2/v4l2_camera_file.cpp new file mode 100644 index 00000000..d3232ab2 --- /dev/null +++ b/src/v4l2/v4l2_camera_file.cpp @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2020, Google Inc. + * + * v4l2_camera_file.h - V4L2 compatibility camera file information + */ + +#include "v4l2_camera_file.h" + +#include <linux/videodev2.h> + +#include "v4l2_camera_proxy.h" + +using namespace libcamera; + +V4L2CameraFile::V4L2CameraFile(int efd, bool nonBlocking, V4L2CameraProxy *proxy) + : proxy_(proxy), nonBlocking_(nonBlocking), efd_(efd), + priority_(V4L2_PRIORITY_DEFAULT) +{ + proxy_->open(nonBlocking); +} + +V4L2CameraFile::~V4L2CameraFile() +{ + proxy_->close(); +} diff --git a/src/v4l2/v4l2_camera_file.h b/src/v4l2/v4l2_camera_file.h new file mode 100644 index 00000000..8f4670a0 --- /dev/null +++ b/src/v4l2/v4l2_camera_file.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2020, Google Inc. + * + * v4l2_camera_file.h - V4L2 compatibility camera file information + */ + +#ifndef __V4L2_CAMERA_FILE_H__ +#define __V4L2_CAMERA_FILE_H__ + +#include <linux/videodev2.h> + +class V4L2CameraProxy; + +class V4L2CameraFile +{ +public: + V4L2CameraFile(int efd, bool nonBlocking, V4L2CameraProxy *proxy); + ~V4L2CameraFile(); + + V4L2CameraProxy *proxy() const { return proxy_; } + + bool nonBlocking() const { return nonBlocking_; } + int efd() const { return efd_; } + + enum v4l2_priority priority() const { return priority_; } + void setPriority(enum v4l2_priority priority) { priority_ = priority; } + +private: + V4L2CameraProxy *proxy_; + + bool nonBlocking_; + int efd_; + enum v4l2_priority priority_; +}; + +#endif /* __V4L2_CAMERA_FILE_H__ */ |