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 media support.
Author:  Hans Verkuil <hans.verk...@cisco.com>
Date:    Fri Feb 2 15:51:08 2018 +0100

Add a new media_open method to open mediaX devices. It avoids calling
V4L2 ioctls on the opened filehandle.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>

 utils/common/cv4l-helpers.h |  3 +++
 utils/common/v4l-helpers.h  | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=5793d13d9a444e92d312ac5320dccb5a38a616df
diff --git a/utils/common/cv4l-helpers.h b/utils/common/cv4l-helpers.h
index ffe2fe7c9fed..8e6f1d946e9d 100644
--- a/utils/common/cv4l-helpers.h
+++ b/utils/common/cv4l-helpers.h
@@ -54,6 +54,8 @@ public:
        }
 
        bool is_subdev() const { return v4l_fd_is_subdev(this); }
+       bool is_media() const { return v4l_fd_is_media(this); }
+       bool is_v4l2() const { return v4l_fd_is_v4l2(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); }
@@ -67,6 +69,7 @@ public:
 
        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 media_open(const char *devname, bool non_blocking = false) { return 
v4l_media_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 bdd55b02d24f..1f24b7ac86a2 100644
--- a/utils/common/v4l-helpers.h
+++ b/utils/common/v4l-helpers.h
@@ -66,6 +66,7 @@ struct v4l_fd {
        bool have_next_ctrl;
        bool have_selection;
        bool is_subdev;
+       bool is_media;
 
        int (*open)(struct v4l_fd *f, const char *file, int oflag, ...);
        int (*close)(struct v4l_fd *f);
@@ -192,6 +193,7 @@ static inline void v4l_fd_init(struct v4l_fd *f)
        memset(f, 0, sizeof(*f));
        f->fd = -1;
        f->is_subdev = false;
+       f->is_media = false;
        f->open = v4l_wrap_open;
        f->close = v4l_wrap_close;
        f->ioctl = v4l_wrap_ioctl;
@@ -206,6 +208,16 @@ static inline bool v4l_fd_is_subdev(const struct v4l_fd *f)
        return f->is_subdev;
 }
 
+static inline bool v4l_fd_is_media(const struct v4l_fd *f)
+{
+       return f->is_media;
+}
+
+static inline bool v4l_fd_is_v4l2(const struct v4l_fd *f)
+{
+       return !f->is_subdev && !f->is_media;
+}
+
 static inline bool v4l_fd_g_trace(const struct v4l_fd *f)
 {
        return f->trace;
@@ -480,6 +492,7 @@ static inline int v4l_open(struct v4l_fd *f, const char 
*devname, bool non_block
                return -1;
        }
        f->is_subdev = false;
+       f->is_media = false;
        f->caps = v4l_capability_g_caps(&f->cap);
        f->type = v4l_determine_type(f);
 
@@ -506,6 +519,29 @@ static inline int v4l_subdev_open(struct v4l_fd *f, const 
char *devname, bool no
        }
        memset(&f->cap, 0, sizeof(f->cap));
        f->is_subdev = true;
+       f->is_media = false;
+       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_media_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 = false;
+       f->is_media = true;
        f->type = 0;
        f->have_query_ext_ctrl = false;
        f->have_ext_ctrls = false;
@@ -520,6 +556,8 @@ 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);
+       if (f->is_media)
+               return v4l_media_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

Reply via email to