This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:
Subject: (c)v4l-helpers: add v4l-subdev support Author: Hans Verkuil <hans.verk...@cisco.com> Date: Fri Feb 2 13:28:46 2018 +0100 Add a new subdev_open method to open v4l-subdevX devices. It avoids calling V4L2 ioctls on the opened filehandle. Signed-off-by: Hans Verkuil <hans.verk...@cisco.com> utils/common/cv4l-helpers.h | 2 ++ utils/common/v4l-helpers.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) --- http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=7d79bc98af40bf8331d890ac7f47045909f88797 diff --git a/utils/common/cv4l-helpers.h b/utils/common/cv4l-helpers.h index e4d11f07b462..ffe2fe7c9fed 100644 --- a/utils/common/cv4l-helpers.h +++ b/utils/common/cv4l-helpers.h @@ -53,6 +53,7 @@ public: *this = *fd; } + bool is_subdev() const { return v4l_fd_is_subdev(this); } __u32 g_type() const { return type; } void s_type(__u32 type) { v4l_s_type(this, type); } __u32 g_selection_type() const { return v4l_g_selection_type(this); } @@ -65,6 +66,7 @@ public: void s_trace(bool trace) { v4l_fd_s_trace(this, trace); } int open(const char *devname, bool non_blocking = false) { return v4l_open(this, devname, non_blocking); } + int subdev_open(const char *devname, bool non_blocking = false) { return v4l_subdev_open(this, devname, non_blocking); } int close() { return v4l_close(this); } int reopen(bool non_blocking = false) { return v4l_reopen(this, non_blocking); } ssize_t read(void *buffer, size_t n) { return v4l_read(this, buffer, n); } diff --git a/utils/common/v4l-helpers.h b/utils/common/v4l-helpers.h index bbaa3857a7cf..bdd55b02d24f 100644 --- a/utils/common/v4l-helpers.h +++ b/utils/common/v4l-helpers.h @@ -65,6 +65,7 @@ struct v4l_fd { bool have_ext_ctrls; bool have_next_ctrl; bool have_selection; + bool is_subdev; int (*open)(struct v4l_fd *f, const char *file, int oflag, ...); int (*close)(struct v4l_fd *f); @@ -190,6 +191,7 @@ static inline void v4l_fd_init(struct v4l_fd *f) { memset(f, 0, sizeof(*f)); f->fd = -1; + f->is_subdev = false; f->open = v4l_wrap_open; f->close = v4l_wrap_close; f->ioctl = v4l_wrap_ioctl; @@ -199,6 +201,11 @@ static inline void v4l_fd_init(struct v4l_fd *f) f->munmap = v4l_wrap_munmap; } +static inline bool v4l_fd_is_subdev(const struct v4l_fd *f) +{ + return f->is_subdev; +} + static inline bool v4l_fd_g_trace(const struct v4l_fd *f) { return f->trace; @@ -467,10 +474,12 @@ static inline int v4l_open(struct v4l_fd *f, const char *devname, bool non_block strncpy(f->devname, devname, sizeof(f->devname)); f->devname[sizeof(f->devname) - 1] = '\0'; } + memset(&f->cap, 0, sizeof(f->cap)); if (v4l_querycap(f, &f->cap)) { v4l_close(f); return -1; } + f->is_subdev = false; f->caps = v4l_capability_g_caps(&f->cap); f->type = v4l_determine_type(f); @@ -485,9 +494,32 @@ static inline int v4l_open(struct v4l_fd *f, const char *devname, bool non_block return f->fd; } +static inline int v4l_subdev_open(struct v4l_fd *f, const char *devname, bool non_blocking) +{ + f->fd = f->open(f, devname, O_RDWR | (non_blocking ? O_NONBLOCK : 0)); + + if (f->fd < 0) + return f->fd; + if (f->devname != devname) { + strncpy(f->devname, devname, sizeof(f->devname)); + f->devname[sizeof(f->devname) - 1] = '\0'; + } + memset(&f->cap, 0, sizeof(f->cap)); + f->is_subdev = true; + f->type = 0; + f->have_query_ext_ctrl = false; + f->have_ext_ctrls = false; + f->have_next_ctrl = false; + f->have_selection = false; + + return f->fd; +} + static inline int v4l_reopen(struct v4l_fd *f, bool non_blocking) { f->close(f); + if (f->is_subdev) + return v4l_subdev_open(f, f->devname, non_blocking); return v4l_open(f, f->devname, non_blocking); } _______________________________________________ linuxtv-commits mailing list linuxtv-commits@linuxtv.org https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits