diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-01-04 22:58:35 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-01-07 22:35:23 +0200 |
commit | 7088041a805d3be8a1d8b7d4c28cc1cecccf4396 (patch) | |
tree | c9ee42d0bd7af58b8a0eaa807062bdc1ab65846c /src/v4l2/v4l2_compat_manager.h | |
parent | b4415f1c9863a2fda42e1882ed4857de9d9366b1 (diff) |
v4l2: compat_manager: Move file operations to new struct FileOperations
Create a new FileOperations structure to hold all the dynamically-loaded
C library file operations. The file operations are now exposed publicly,
to prepare for usage of mmap in the V4L2CameraProxy.
A new template helper function is added to retrieve a symbol with
dlsym() with proper casting to simplify the V4L2CompatManager
constructor.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/v4l2/v4l2_compat_manager.h')
-rw-r--r-- | src/v4l2/v4l2_compat_manager.h | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h index dd9d3210..d51b5953 100644 --- a/src/v4l2/v4l2_compat_manager.h +++ b/src/v4l2/v4l2_compat_manager.h @@ -26,11 +26,30 @@ using namespace libcamera; class V4L2CompatManager : public Thread { public: + struct FileOperations { + using openat_func_t = int (*)(int dirfd, const char *path, + int oflag, ...); + using dup_func_t = int (*)(int oldfd); + using close_func_t = int (*)(int fd); + using ioctl_func_t = int (*)(int fd, unsigned long request, ...); + using mmap_func_t = void *(*)(void *addr, size_t length, int prot, + int flags, int fd, off_t offset); + using munmap_func_t = int (*)(void *addr, size_t length); + + openat_func_t openat; + dup_func_t dup; + close_func_t close; + ioctl_func_t ioctl; + mmap_func_t mmap; + munmap_func_t munmap; + }; + static V4L2CompatManager *instance(); int init(); V4L2CameraProxy *getProxy(int fd); + const FileOperations &fops() const { return fops_; } int openat(int dirfd, const char *path, int oflag, mode_t mode); @@ -48,20 +67,7 @@ private: void run() override; int getCameraIndex(int fd); - typedef int (*openat_func_t)(int dirfd, const char *path, int oflag, ...); - typedef int (*dup_func_t)(int oldfd); - typedef int (*close_func_t)(int fd); - typedef int (*ioctl_func_t)(int fd, unsigned long request, ...); - typedef void *(*mmap_func_t)(void *addr, size_t length, int prot, - int flags, int fd, off_t offset); - typedef int (*munmap_func_t)(void *addr, size_t length); - - openat_func_t openat_func_; - dup_func_t dup_func_; - close_func_t close_func_; - ioctl_func_t ioctl_func_; - mmap_func_t mmap_func_; - munmap_func_t munmap_func_; + FileOperations fops_; CameraManager *cm_; |