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: v4l2-ctl: add --list-formats-out-ext
Author:  Hans Verkuil <hans.verk...@cisco.com>
Date:    Mon Jul 30 13:07:31 2018 +0200

Add the --list-formats-out-ext function since m2m (codec) devices
need this.

Also push cv4l_fd down into the various test sources.

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

 utils/v4l2-ctl/v4l2-ctl-common.cpp    |  21 ++--
 utils/v4l2-ctl/v4l2-ctl-edid.cpp      |   7 +-
 utils/v4l2-ctl/v4l2-ctl-io.cpp        |  12 ++-
 utils/v4l2-ctl/v4l2-ctl-meta.cpp      |  11 +-
 utils/v4l2-ctl/v4l2-ctl-misc.cpp      |   8 +-
 utils/v4l2-ctl/v4l2-ctl-overlay.cpp   |  12 ++-
 utils/v4l2-ctl/v4l2-ctl-sdr.cpp       |  15 +--
 utils/v4l2-ctl/v4l2-ctl-selection.cpp |   8 +-
 utils/v4l2-ctl/v4l2-ctl-stds.cpp      |  12 ++-
 utils/v4l2-ctl/v4l2-ctl-subdev.cpp    |  12 ++-
 utils/v4l2-ctl/v4l2-ctl-tuner.cpp     |   7 +-
 utils/v4l2-ctl/v4l2-ctl-vbi.cpp       |  13 ++-
 utils/v4l2-ctl/v4l2-ctl-vidcap.cpp    | 121 ++-------------------
 utils/v4l2-ctl/v4l2-ctl-vidout.cpp    |  21 ++--
 utils/v4l2-ctl/v4l2-ctl.cpp           | 194 ++++++++++++++++++++++++++--------
 utils/v4l2-ctl/v4l2-ctl.h             |  84 ++++++++-------
 16 files changed, 309 insertions(+), 249 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=5583f43ef1a4814c2bd3c43cb06461b7f532b141
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp 
b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index 7ab629444df1..46451f45d85a 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -531,10 +531,11 @@ static void list_controls(int fd, int show_menus)
        }
 }
 
-static void find_controls(int fd)
+static void find_controls(cv4l_fd &_fd)
 {
        const unsigned next_fl = V4L2_CTRL_FLAG_NEXT_CTRL | 
V4L2_CTRL_FLAG_NEXT_COMPOUND;
        struct v4l2_query_ext_ctrl qctrl;
+       int fd = _fd.g_fd();
        int id;
 
        memset(&qctrl, 0, sizeof(qctrl));
@@ -573,14 +574,14 @@ int common_find_ctrl_id(const char *name)
        return ctrl_str2q[name].id;
 }
 
-void common_process_controls(int fd)
+void common_process_controls(cv4l_fd &fd)
 {
        struct v4l2_query_ext_ctrl qc = {
                V4L2_CTRL_FLAG_NEXT_CTRL | V4L2_CTRL_FLAG_NEXT_COMPOUND
        };
        int rc;
 
-       rc = test_ioctl(fd, VIDIOC_QUERY_EXT_CTRL, &qc);
+       rc = test_ioctl(fd.g_fd(), VIDIOC_QUERY_EXT_CTRL, &qc);
        have_query_ext_ctrl = rc == 0;
 
        find_controls(fd);
@@ -787,8 +788,10 @@ static bool idx_in_subset(const struct v4l2_query_ext_ctrl 
&qc, const ctrl_subse
        return true;
 }
 
-void common_set(int fd)
+void common_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptSetPriority]) {
                if (doioctl(fd, VIDIOC_S_PRIORITY, &prio) >= 0) {
                        printf("Priority set: %d\n", prio);
@@ -974,8 +977,10 @@ static void print_array(const struct v4l2_query_ext_ctrl 
&qc, void *p)
        }
 }
 
-void common_get(int fd)
+void common_get(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptGetCtrl] && !get_ctrls.empty()) {
                struct v4l2_ext_controls ctrls;
                class2ctrls_map class2ctrls;
@@ -1083,13 +1088,13 @@ void common_get(int fd)
        }
 }
 
-void common_list(int fd)
+void common_list(cv4l_fd &fd)
 {
        if (options[OptListCtrlsMenus]) {
-               list_controls(fd, 1);
+               list_controls(fd.g_fd(), 1);
        }
 
        if (options[OptListCtrls]) {
-               list_controls(fd, 0);
+               list_controls(fd.g_fd(), 0);
        }
 }
diff --git a/utils/v4l2-ctl/v4l2-ctl-edid.cpp b/utils/v4l2-ctl/v4l2-ctl-edid.cpp
index 1600642fe1da..88a91cf8a4cb 100644
--- a/utils/v4l2-ctl/v4l2-ctl-edid.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-edid.cpp
@@ -1184,8 +1184,9 @@ void edid_cmd(int ch, char *optarg)
        }
 }
 
-void edid_set(int fd)
+void edid_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
        int loc;
 
        if (options[OptClearEdid]) {
@@ -1313,8 +1314,10 @@ void edid_set(int fd)
        }
 }
 
-void edid_get(int fd)
+void edid_get(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptGetEdid]) {
                FILE *fout = stdout;
 
diff --git a/utils/v4l2-ctl/v4l2-ctl-io.cpp b/utils/v4l2-ctl/v4l2-ctl-io.cpp
index 29be8c958e26..dc2756c86bc4 100644
--- a/utils/v4l2-ctl/v4l2-ctl-io.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-io.cpp
@@ -93,8 +93,10 @@ void io_cmd(int ch, char *optarg)
        }
 }
 
-void io_set(int fd)
+void io_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptSetInput]) {
                if (doioctl(fd, VIDIOC_S_INPUT, &input) == 0) {
                        struct v4l2_input vin;
@@ -125,8 +127,10 @@ void io_set(int fd)
        }
 }
 
-void io_get(int fd)
+void io_get(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptGetInput]) {
                if (doioctl(fd, VIDIOC_G_INPUT, &input) == 0) {
                        struct v4l2_input vin;
@@ -163,8 +167,10 @@ void io_get(int fd)
        }
 }
 
-void io_list(int fd)
+void io_list(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptListInputs]) {
                struct v4l2_input vin;
 
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index 3cfc115309c2..98182fd016fa 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -61,8 +61,9 @@ void meta_cmd(int ch, char *optarg)
        }
 }
 
-void meta_set(int fd)
+void meta_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
        int ret;
 
        if (options[OptSetMetaFormat] || options[OptTryMetaFormat]) {
@@ -92,16 +93,16 @@ void meta_set(int fd)
        }
 }
 
-void meta_get(int fd)
+void meta_get(cv4l_fd &fd)
 {
        if (options[OptGetMetaFormat]) {
                vfmt.type = V4L2_BUF_TYPE_META_CAPTURE;
-               if (doioctl(fd, VIDIOC_G_FMT, &vfmt) == 0)
-                       printfmt(fd, vfmt);
+               if (doioctl(fd.g_fd(), VIDIOC_G_FMT, &vfmt) == 0)
+                       printfmt(fd.g_fd(), vfmt);
        }
 }
 
-void meta_list(int fd)
+void meta_list(cv4l_fd &fd)
 {
        if (options[OptListMetaFormats]) {
                printf("ioctl: VIDIOC_ENUM_FMT\n");
diff --git a/utils/v4l2-ctl/v4l2-ctl-misc.cpp b/utils/v4l2-ctl/v4l2-ctl-misc.cpp
index 57ab3d20c8aa..1a325d584a88 100644
--- a/utils/v4l2-ctl/v4l2-ctl-misc.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-misc.cpp
@@ -308,8 +308,10 @@ void misc_cmd(int ch, char *optarg)
        }
 }
 
-void misc_set(int fd)
+void misc_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptSetParm]) {
                memset(&parm, 0, sizeof(parm));
                parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -362,8 +364,10 @@ void misc_set(int fd)
                        print_deccmd(dec_cmd);
 }
 
-void misc_get(int fd)
+void misc_get(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptGetJpegComp]) {
                struct v4l2_jpegcompression jc;
                if (doioctl(fd, VIDIOC_G_JPEGCOMP, &jc) == 0)
diff --git a/utils/v4l2-ctl/v4l2-ctl-overlay.cpp 
b/utils/v4l2-ctl/v4l2-ctl-overlay.cpp
index 385da2b854e5..4eca772bdcf7 100644
--- a/utils/v4l2-ctl/v4l2-ctl-overlay.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-overlay.cpp
@@ -465,8 +465,10 @@ free:
                free(cliplist);
 }
 
-void overlay_set(int fd)
+void overlay_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if ((options[OptSetOverlayFormat] || options[OptTryOverlayFormat]) &&
                        (set_overlay_fmt || options[OptClearClips] || 
options[OptClearBitmap] ||
                         bitmap_rects.size() || clips.size())) {
@@ -498,8 +500,10 @@ void overlay_set(int fd)
        }
 }
 
-void overlay_get(int fd)
+void overlay_get(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptGetOverlayFormat]) {
                struct v4l2_format fmt;
                unsigned char *bitmap = NULL;
@@ -533,12 +537,12 @@ void overlay_get(int fd)
        }
 }
 
-void overlay_list(int fd)
+void overlay_list(cv4l_fd &fd)
 {
        if (options[OptListOverlayFormats]) {
                printf("ioctl: VIDIOC_ENUM_FMT\n");
                print_video_formats(fd, V4L2_BUF_TYPE_VIDEO_OVERLAY);
        }
        if (options[OptFindFb])
-               find_fb(fd);
+               find_fb(fd.g_fd());
 }
diff --git a/utils/v4l2-ctl/v4l2-ctl-sdr.cpp b/utils/v4l2-ctl/v4l2-ctl-sdr.cpp
index 5006f3008f5a..d13f5c76f5e6 100644
--- a/utils/v4l2-ctl/v4l2-ctl-sdr.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-sdr.cpp
@@ -63,8 +63,9 @@ void sdr_cmd(int ch, char *optarg)
        }
 }
 
-void sdr_set(int fd)
+void sdr_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
        int ret;
 
        if (options[OptSetSdrFormat] || options[OptTrySdrFormat]) {
@@ -119,21 +120,21 @@ void sdr_set(int fd)
        }
 }
 
-void sdr_get(int fd)
+void sdr_get(cv4l_fd &fd)
 {
        if (options[OptGetSdrFormat]) {
                vfmt.type = V4L2_BUF_TYPE_SDR_CAPTURE;
-               if (doioctl(fd, VIDIOC_G_FMT, &vfmt) == 0)
-                       printfmt(fd, vfmt);
+               if (doioctl(fd.g_fd(), VIDIOC_G_FMT, &vfmt) == 0)
+                       printfmt(fd.g_fd(), vfmt);
        }
        if (options[OptGetSdrOutFormat]) {
                vfmt.type = V4L2_BUF_TYPE_SDR_OUTPUT;
-               if (doioctl(fd, VIDIOC_G_FMT, &vfmt) == 0)
-                       printfmt(fd, vfmt);
+               if (doioctl(fd.g_fd(), VIDIOC_G_FMT, &vfmt) == 0)
+                       printfmt(fd.g_fd(), vfmt);
        }
 }
 
-void sdr_list(int fd)
+void sdr_list(cv4l_fd &fd)
 {
        if (options[OptListSdrFormats]) {
                printf("ioctl: VIDIOC_ENUM_FMT\n");
diff --git a/utils/v4l2-ctl/v4l2-ctl-selection.cpp 
b/utils/v4l2-ctl/v4l2-ctl-selection.cpp
index f4625100afcc..c35d053677c8 100644
--- a/utils/v4l2-ctl/v4l2-ctl-selection.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-selection.cpp
@@ -270,8 +270,10 @@ void selection_cmd(int ch, char *optarg)
        }
 }
 
-void selection_set(int fd)
+void selection_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptSetCrop]) {
                do_crop(fd, set_crop, vcrop, V4L2_BUF_TYPE_VIDEO_CAPTURE);
        }
@@ -297,8 +299,10 @@ void selection_set(int fd)
        }
 }
 
-void selection_get(int fd)
+void selection_get(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptGetCropCap]) {
                struct v4l2_cropcap cropcap;
 
diff --git a/utils/v4l2-ctl/v4l2-ctl-stds.cpp b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
index a94f674f3754..d2cbae74b003 100644
--- a/utils/v4l2-ctl/v4l2-ctl-stds.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
@@ -481,8 +481,10 @@ void stds_cmd(int ch, char *optarg)
        }
 }
 
-void stds_set(int fd)
+void stds_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptSetStandard]) {
                if (standard & (1ULL << 63)) {
                        struct v4l2_standard vs;
@@ -577,8 +579,10 @@ void stds_set(int fd)
        }
 }
 
-void stds_get(int fd)
+void stds_get(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptGetStandard]) {
                if (doioctl(fd, VIDIOC_G_STD, &standard) == 0) {
                        printf("Video Standard = 0x%08llx\n", (unsigned long 
long)standard);
@@ -631,8 +635,10 @@ void stds_get(int fd)
         }
 }
 
-void stds_list(int fd)
+void stds_list(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptListStandards]) {
                struct v4l2_standard vs;
 
diff --git a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp 
b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp
index c1d3e5ad46f7..3ce59aa7124d 100644
--- a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp
@@ -394,8 +394,10 @@ static void print_subdev_selection(const struct 
v4l2_subdev_selection &sel)
                        selflags2s(sel.flags).c_str());
 }
 
-void subdev_set(int fd)
+void subdev_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptSetSubDevFormat] || options[OptTrySubDevFormat]) {
                struct v4l2_subdev_format fmt;
 
@@ -494,8 +496,10 @@ void subdev_set(int fd)
        }
 }
 
-void subdev_get(int fd)
+void subdev_get(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptGetSubDevFormat]) {
                struct v4l2_subdev_format fmt;
 
@@ -610,8 +614,10 @@ static void print_frmival(const struct 
v4l2_subdev_frame_interval_enum &frmival)
               fract2fps(frmival.interval).c_str());
 }
 
-void subdev_list(int fd)
+void subdev_list(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptListSubDevMBusCodes]) {
                printf("ioctl: VIDIOC_SUBDEV_ENUM_MBUS_CODE (pad=%u)\n",
                       list_mbus_codes_pad);
diff --git a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp 
b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp
index fd85f83965ab..b8a082553bfa 100644
--- a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp
@@ -257,8 +257,9 @@ void tuner_cmd(int ch, char *optarg)
        }
 }
 
-void tuner_set(int fd)
+void tuner_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
        __u32 type = (capabilities & V4L2_CAP_RADIO) ?
                V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
        double fac = 16;
@@ -361,8 +362,10 @@ void tuner_set(int fd)
        }
 }
 
-void tuner_get(int fd)
+void tuner_get(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptGetFreq]) {
                double fac = 16;
 
diff --git a/utils/v4l2-ctl/v4l2-ctl-vbi.cpp b/utils/v4l2-ctl/v4l2-ctl-vbi.cpp
index 77d1309485b2..1db7c81e8eac 100644
--- a/utils/v4l2-ctl/v4l2-ctl-vbi.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-vbi.cpp
@@ -196,8 +196,9 @@ static void fill_raw_vbi(v4l2_vbi_format &dst, const 
v4l2_vbi_format &src)
                dst.count[1] = src.count[1];
 }
 
-void vbi_set(int fd)
+void vbi_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
        int ret;
 
        if (options[OptSetSlicedVbiFormat] || options[OptTrySlicedVbiFormat]) {
@@ -249,8 +250,10 @@ void vbi_set(int fd)
        }
 }
 
-void vbi_get(int fd)
+void vbi_get(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
+
        if (options[OptGetSlicedVbiFormat]) {
                vbi_fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
                if (doioctl(fd, VIDIOC_G_FMT, &vbi_fmt) == 0)
@@ -276,13 +279,13 @@ void vbi_get(int fd)
        }
 }
 
-void vbi_list(int fd)
+void vbi_list(cv4l_fd &fd)
 {
        if (options[OptGetSlicedVbiCap]) {
                struct v4l2_sliced_vbi_cap cap;
 
                cap.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
-               if (doioctl(fd, VIDIOC_G_SLICED_VBI_CAP, &cap) == 0) {
+               if (doioctl(fd.g_fd(), VIDIOC_G_SLICED_VBI_CAP, &cap) == 0) {
                        print_sliced_vbi_cap(cap);
                }
        }
@@ -291,7 +294,7 @@ void vbi_list(int fd)
                struct v4l2_sliced_vbi_cap cap;
 
                cap.type = V4L2_BUF_TYPE_SLICED_VBI_OUTPUT;
-               if (doioctl(fd, VIDIOC_G_SLICED_VBI_CAP, &cap) == 0) {
+               if (doioctl(fd.g_fd(), VIDIOC_G_SLICED_VBI_CAP, &cap) == 0) {
                        print_sliced_vbi_cap(cap);
                }
        }
diff --git a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp 
b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
index 25fc26596b14..27ef25199625 100644
--- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
@@ -62,110 +62,6 @@ void vidcap_usage(void)
               );
 }
 
-static std::string frmtype2s(unsigned type)
-{
-       static const char *types[] = {
-               "Unknown",
-               "Discrete",
-               "Continuous",
-               "Stepwise"
-       };
-
-       if (type > 3)
-               type = 0;
-       return types[type];
-}
-
-static std::string fract2sec(const struct v4l2_fract &f)
-{
-       char buf[100];
-
-       sprintf(buf, "%.3f", (1.0 * f.numerator) / f.denominator);
-       return buf;
-}
-
-static std::string fract2fps(const struct v4l2_fract &f)
-{
-       char buf[100];
-
-       sprintf(buf, "%.3f", (1.0 * f.denominator) / f.numerator);
-       return buf;
-}
-
-static void print_frmsize(const struct v4l2_frmsizeenum &frmsize, const char 
*prefix)
-{
-       printf("%s\tSize: %s ", prefix, frmtype2s(frmsize.type).c_str());
-       if (frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
-               printf("%dx%d", frmsize.discrete.width, 
frmsize.discrete.height);
-       } else if (frmsize.type == V4L2_FRMSIZE_TYPE_STEPWISE) {
-               printf("%dx%d - %dx%d with step %d/%d",
-                               frmsize.stepwise.min_width,
-                               frmsize.stepwise.min_height,
-                               frmsize.stepwise.max_width,
-                               frmsize.stepwise.max_height,
-                               frmsize.stepwise.step_width,
-                               frmsize.stepwise.step_height);
-       }
-       printf("\n");
-}
-
-static void print_frmival(const struct v4l2_frmivalenum &frmival, const char 
*prefix)
-{
-       printf("%s\tInterval: %s ", prefix, frmtype2s(frmival.type).c_str());
-       if (frmival.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
-               printf("%ss (%s fps)\n", fract2sec(frmival.discrete).c_str(),
-                               fract2fps(frmival.discrete).c_str());
-       } else if (frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) {
-               printf("%ss - %ss (%s-%s fps)\n",
-                               fract2sec(frmival.stepwise.min).c_str(),
-                               fract2sec(frmival.stepwise.max).c_str(),
-                               fract2fps(frmival.stepwise.max).c_str(),
-                               fract2fps(frmival.stepwise.min).c_str());
-       } else if (frmival.type == V4L2_FRMIVAL_TYPE_STEPWISE) {
-               printf("%ss - %ss with step %ss (%s-%s fps)\n",
-                               fract2sec(frmival.stepwise.min).c_str(),
-                               fract2sec(frmival.stepwise.max).c_str(),
-                               fract2sec(frmival.stepwise.step).c_str(),
-                               fract2fps(frmival.stepwise.max).c_str(),
-                               fract2fps(frmival.stepwise.min).c_str());
-       }
-}
-
-static void print_video_formats_ext(int fd, __u32 type)
-{
-       struct v4l2_fmtdesc fmt;
-       struct v4l2_frmsizeenum frmsize;
-       struct v4l2_frmivalenum frmival;
-
-       fmt.index = 0;
-       fmt.type = type;
-       printf("\tType: %s\n\n", buftype2s(type).c_str());
-       while (test_ioctl(fd, VIDIOC_ENUM_FMT, &fmt) >= 0) {
-               printf("\t[%d]: '%s' (%s", fmt.index, 
fcc2s(fmt.pixelformat).c_str(),
-                      fmt.description);
-               if (fmt.flags)
-                       printf(", %s", fmtdesc2s(fmt.flags).c_str());
-               printf(")\n");
-               frmsize.pixel_format = fmt.pixelformat;
-               frmsize.index = 0;
-               while (test_ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &frmsize) >= 0) {
-                       print_frmsize(frmsize, "\t");
-                       if (frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
-                               frmival.index = 0;
-                               frmival.pixel_format = fmt.pixelformat;
-                               frmival.width = frmsize.discrete.width;
-                               frmival.height = frmsize.discrete.height;
-                               while (test_ioctl(fd, 
VIDIOC_ENUM_FRAMEINTERVALS, &frmival) >= 0) {
-                                       print_frmival(frmival, "\t\t");
-                                       frmival.index++;
-                               }
-                       }
-                       frmsize.index++;
-               }
-               fmt.index++;
-       }
-}
-
 static void print_video_fields(int fd)
 {
        struct v4l2_format fmt;
@@ -254,8 +150,9 @@ void vidcap_cmd(int ch, char *optarg)
        }
 }
 
-void vidcap_set(int fd)
+void vidcap_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
        int ret;
 
        if (options[OptSetVideoFormat] || options[OptTryVideoFormat]) {
@@ -331,7 +228,7 @@ void vidcap_set(int fd)
        }
 }
 
-void vidcap_get(int fd)
+void vidcap_get(cv4l_fd &fd)
 {
        if (options[OptGetVideoFormat]) {
                struct v4l2_format vfmt;
@@ -339,12 +236,12 @@ void vidcap_get(int fd)
                memset(&vfmt, 0, sizeof(vfmt));
                vfmt.fmt.pix.priv = priv_magic;
                vfmt.type = vidcap_buftype;
-               if (doioctl(fd, VIDIOC_G_FMT, &vfmt) == 0)
-                       printfmt(fd, vfmt);
+               if (doioctl(fd.g_fd(), VIDIOC_G_FMT, &vfmt) == 0)
+                       printfmt(fd.g_fd(), vfmt);
        }
 }
 
-void vidcap_list(int fd)
+void vidcap_list(cv4l_fd &fd)
 {
        if (options[OptListFormats]) {
                printf("ioctl: VIDIOC_ENUM_FMT\n");
@@ -357,13 +254,13 @@ void vidcap_list(int fd)
        }
 
        if (options[OptListFields]) {
-               print_video_fields(fd);
+               print_video_fields(fd.g_fd());
        }
 
        if (options[OptListFrameSizes]) {
                printf("ioctl: VIDIOC_ENUM_FRAMESIZES\n");
                frmsize.index = 0;
-               while (test_ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &frmsize) >= 0) {
+               while (test_ioctl(fd.g_fd(), VIDIOC_ENUM_FRAMESIZES, &frmsize) 
>= 0) {
                        print_frmsize(frmsize, "");
                        frmsize.index++;
                }
@@ -372,7 +269,7 @@ void vidcap_list(int fd)
        if (options[OptListFrameIntervals]) {
                printf("ioctl: VIDIOC_ENUM_FRAMEINTERVALS\n");
                frmival.index = 0;
-               while (test_ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &frmival) >= 
0) {
+               while (test_ioctl(fd.g_fd(), VIDIOC_ENUM_FRAMEINTERVALS, 
&frmival) >= 0) {
                        print_frmival(frmival, "");
                        frmival.index++;
                }
diff --git a/utils/v4l2-ctl/v4l2-ctl-vidout.cpp 
b/utils/v4l2-ctl/v4l2-ctl-vidout.cpp
index c98931d1a8fa..927afbb19952 100644
--- a/utils/v4l2-ctl/v4l2-ctl-vidout.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-vidout.cpp
@@ -24,6 +24,9 @@ void vidout_usage(void)
 {
        printf("\nVideo Output Formats options:\n"
               "  --list-formats-out display supported video output formats 
[VIDIOC_ENUM_FMT]\n"
+              "  --list-formats-out-ext\n"
+              "                     display supported video output formats 
including frame sizes\n"
+              "                     and intervals\n"
               "  --list-fields-out  list supported fields for the current 
output format\n"
               "  -X, --get-fmt-video-out\n"
               "                     query the video output format 
[VIDIOC_G_FMT]\n"
@@ -96,8 +99,9 @@ void vidout_cmd(int ch, char *optarg)
        }
 }
 
-void vidout_set(int fd)
+void vidout_set(cv4l_fd &_fd)
 {
+       int fd = _fd.g_fd();
        int ret;
 
        if (options[OptSetVideoOutFormat] || options[OptTryVideoOutFormat]) {
@@ -188,7 +192,7 @@ void vidout_set(int fd)
        }
 }
 
-void vidout_get(int fd)
+void vidout_get(cv4l_fd &fd)
 {
        if (options[OptGetVideoOutFormat]) {
                struct v4l2_format vfmt;
@@ -196,19 +200,24 @@ void vidout_get(int fd)
                memset(&vfmt, 0, sizeof(vfmt));
                vfmt.fmt.pix.priv = priv_magic;
                vfmt.type = vidout_buftype;
-               if (doioctl(fd, VIDIOC_G_FMT, &vfmt) == 0)
-                       printfmt(fd, vfmt);
+               if (doioctl(fd.g_fd(), VIDIOC_G_FMT, &vfmt) == 0)
+                       printfmt(fd.g_fd(), vfmt);
        }
 }
 
-void vidout_list(int fd)
+void vidout_list(cv4l_fd &fd)
 {
        if (options[OptListOutFormats]) {
                printf("ioctl: VIDIOC_ENUM_FMT\n");
                print_video_formats(fd, vidout_buftype);
        }
 
+       if (options[OptListOutFormatsExt]) {
+               printf("ioctl: VIDIOC_ENUM_FMT\n");
+               print_video_formats_ext(fd, vidout_buftype);
+       }
+
        if (options[OptListOutFields]) {
-               print_video_out_fields(fd);
+               print_video_out_fields(fd.g_fd());
        }
 }
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 2a87c48f1dbe..e0a81a5298ca 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -120,6 +120,7 @@ static struct option long_options[] = {
        {"list-formats-sdr", no_argument, 0, OptListSdrFormats},
        {"list-formats-sdr-out", no_argument, 0, OptListSdrOutFormats},
        {"list-formats-out", no_argument, 0, OptListOutFormats},
+       {"list-formats-out-ext", no_argument, 0, OptListOutFormatsExt},
        {"list-formats-meta", no_argument, 0, OptListMetaFormats},
        {"list-subdev-mbus-codes", optional_argument, 0, 
OptListSubDevMBusCodes},
        {"list-subdev-framesizes", required_argument, 0, 
OptListSubDevFrameSizes},
@@ -510,21 +511,124 @@ void printfmt(int fd, const struct v4l2_format &vfmt)
        }
 }
 
-void print_video_formats(int fd, __u32 type)
+static std::string frmtype2s(unsigned type)
 {
+       static const char *types[] = {
+               "Unknown",
+               "Discrete",
+               "Continuous",
+               "Stepwise"
+       };
+
+       if (type > 3)
+               type = 0;
+       return types[type];
+}
+
+static std::string fract2sec(const struct v4l2_fract &f)
+{
+       char buf[100];
+
+       sprintf(buf, "%.3f", (1.0 * f.numerator) / f.denominator);
+       return buf;
+}
+
+static std::string fract2fps(const struct v4l2_fract &f)
+{
+       char buf[100];
+
+       sprintf(buf, "%.3f", (1.0 * f.denominator) / f.numerator);
+       return buf;
+}
+
+void print_frmsize(const struct v4l2_frmsizeenum &frmsize, const char *prefix)
+{
+       printf("%s\tSize: %s ", prefix, frmtype2s(frmsize.type).c_str());
+       if (frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
+               printf("%dx%d", frmsize.discrete.width, 
frmsize.discrete.height);
+       } else if (frmsize.type == V4L2_FRMSIZE_TYPE_STEPWISE) {
+               printf("%dx%d - %dx%d with step %d/%d",
+                               frmsize.stepwise.min_width,
+                               frmsize.stepwise.min_height,
+                               frmsize.stepwise.max_width,
+                               frmsize.stepwise.max_height,
+                               frmsize.stepwise.step_width,
+                               frmsize.stepwise.step_height);
+       }
+       printf("\n");
+}
+
+void print_frmival(const struct v4l2_frmivalenum &frmival, const char *prefix)
+{
+       printf("%s\tInterval: %s ", prefix, frmtype2s(frmival.type).c_str());
+       if (frmival.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
+               printf("%ss (%s fps)\n", fract2sec(frmival.discrete).c_str(),
+                               fract2fps(frmival.discrete).c_str());
+       } else if (frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) {
+               printf("%ss - %ss (%s-%s fps)\n",
+                               fract2sec(frmival.stepwise.min).c_str(),
+                               fract2sec(frmival.stepwise.max).c_str(),
+                               fract2fps(frmival.stepwise.max).c_str(),
+                               fract2fps(frmival.stepwise.min).c_str());
+       } else if (frmival.type == V4L2_FRMIVAL_TYPE_STEPWISE) {
+               printf("%ss - %ss with step %ss (%s-%s fps)\n",
+                               fract2sec(frmival.stepwise.min).c_str(),
+                               fract2sec(frmival.stepwise.max).c_str(),
+                               fract2sec(frmival.stepwise.step).c_str(),
+                               fract2fps(frmival.stepwise.max).c_str(),
+                               fract2fps(frmival.stepwise.min).c_str());
+       }
+}
+
+void print_video_formats(cv4l_fd &fd, __u32 type)
+{
+       cv4l_disable_trace dt(fd);
        struct v4l2_fmtdesc fmt;
 
-       memset(&fmt, 0, sizeof(fmt));
-       fmt.type = type;
        printf("\tType: %s\n\n", buftype2s(type).c_str());
-       while (test_ioctl(fd, VIDIOC_ENUM_FMT, &fmt) >= 0) {
+       if (fd.enum_fmt(fmt, true, 0, type))
+               return;
+       do {
                printf("\t[%d]: '%s' (%s", fmt.index, 
fcc2s(fmt.pixelformat).c_str(),
                       fmt.description);
                if (fmt.flags)
                        printf(", %s", fmtdesc2s(fmt.flags).c_str());
                printf(")\n");
-               fmt.index++;
-       }
+       } while (!fd.enum_fmt(fmt));
+}
+
+void print_video_formats_ext(cv4l_fd &fd, __u32 type)
+{
+       cv4l_disable_trace dt(fd);
+       struct v4l2_fmtdesc fmt;
+       struct v4l2_frmsizeenum frmsize;
+       struct v4l2_frmivalenum frmival;
+
+       printf("\tType: %s\n\n", buftype2s(type).c_str());
+       if (fd.enum_fmt(fmt, true, 0, type))
+               return;
+       do {
+               printf("\t[%d]: '%s' (%s", fmt.index, 
fcc2s(fmt.pixelformat).c_str(),
+                      fmt.description);
+               if (fmt.flags)
+                       printf(", %s", fmtdesc2s(fmt.flags).c_str());
+               printf(")\n");
+               if (fd.enum_framesizes(frmsize, fmt.pixelformat))
+                       continue;
+               do {
+                       print_frmsize(frmsize, "\t");
+                       if (frmsize.type != V4L2_FRMSIZE_TYPE_DISCRETE)
+                               continue;
+
+                       if (fd.enum_frameintervals(frmival, fmt.pixelformat,
+                                                  frmsize.discrete.width,
+                                                  frmsize.discrete.height))
+                               continue;
+                       do {
+                               print_frmival(frmival, "\t\t");
+                       } while (!fd.enum_frameintervals(frmival));
+               } while (!fd.enum_framesizes(frmsize));
+       } while (!fd.enum_fmt(fmt));
 }
 
 int parse_subopt(char **subs, const char * const *subopts, char **value)
@@ -1091,7 +1195,7 @@ int main(int argc, char **argv)
                                V4L2_PIX_FMT_PRIV_MAGIC : 0;
        }
 
-       common_process_controls(fd);
+       common_process_controls(c_fd);
 
        if (wait_for_event == V4L2_EVENT_CTRL && wait_event_id)
                if (!common_find_ctrl_id(wait_event_id)) {
@@ -1151,50 +1255,50 @@ int main(int argc, char **argv)
 
        /* Set options */
 
-       common_set(fd);
-       tuner_set(fd);
-       io_set(fd);
-       stds_set(fd);
-       vidcap_set(fd);
-       vidout_set(fd);
-       overlay_set(fd);
-       vbi_set(fd);
-       sdr_set(fd);
-       meta_set(fd);
-       subdev_set(fd);
-       selection_set(fd);
-       misc_set(fd);
-       edid_set(fd);
+       common_set(c_fd);
+       tuner_set(c_fd);
+       io_set(c_fd);
+       stds_set(c_fd);
+       vidcap_set(c_fd);
+       vidout_set(c_fd);
+       overlay_set(c_fd);
+       vbi_set(c_fd);
+       sdr_set(c_fd);
+       meta_set(c_fd);
+       subdev_set(c_fd);
+       selection_set(c_fd);
+       misc_set(c_fd);
+       edid_set(c_fd);
 
        /* Get options */
 
-       common_get(fd);
-       tuner_get(fd);
-       io_get(fd);
-       stds_get(fd);
-       vidcap_get(fd);
-       vidout_get(fd);
-       overlay_get(fd);
-       vbi_get(fd);
-       sdr_get(fd);
-       meta_get(fd);
-       subdev_get(fd);
-       selection_get(fd);
-       misc_get(fd);
-       edid_get(fd);
+       common_get(c_fd);
+       tuner_get(c_fd);
+       io_get(c_fd);
+       stds_get(c_fd);
+       vidcap_get(c_fd);
+       vidout_get(c_fd);
+       overlay_get(c_fd);
+       vbi_get(c_fd);
+       sdr_get(c_fd);
+       meta_get(c_fd);
+       subdev_get(c_fd);
+       selection_get(c_fd);
+       misc_get(c_fd);
+       edid_get(c_fd);
 
        /* List options */
 
-       common_list(fd);
-       io_list(fd);
-       stds_list(fd);
-       vidcap_list(fd);
-       vidout_list(fd);
-       overlay_list(fd);
-       vbi_list(fd);
-       sdr_list(fd);
-       meta_list(fd);
-       subdev_list(fd);
+       common_list(c_fd);
+       io_list(c_fd);
+       stds_list(c_fd);
+       vidcap_list(c_fd);
+       vidout_list(c_fd);
+       overlay_list(c_fd);
+       vbi_list(c_fd);
+       sdr_list(c_fd);
+       meta_list(c_fd);
+       subdev_list(c_fd);
        streaming_list(c_fd, c_out_fd);
 
        /* Special case: handled last */
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index e510d778deb0..e4214e784576 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -120,6 +120,7 @@ enum Option {
        OptListSdrFormats,
        OptListSdrOutFormats,
        OptListOutFormats,
+       OptListOutFormatsExt,
        OptListMetaFormats,
        OptListSubDevMBusCodes,
        OptListSubDevFrameSizes,
@@ -301,103 +302,106 @@ int parse_selection_target(const char *s, unsigned int 
&target);
 int parse_selection_flags(const char *s);
 void print_selection(const struct v4l2_selection &sel);
 __u32 find_pixel_format(int fd, unsigned index, bool output, bool mplane);
+void print_frmsize(const struct v4l2_frmsizeenum &frmsize, const char *prefix);
+void print_frmival(const struct v4l2_frmivalenum &frmival, const char *prefix);
 void printfmt(int fd, const struct v4l2_format &vfmt);
-void print_video_formats(int fd, __u32 type);
+void print_video_formats(cv4l_fd &fd, __u32 type);
+void print_video_formats_ext(cv4l_fd &fd, __u32 type);
 
 #define doioctl(n, r, p) doioctl_name(n, r, p, #r)
 
 // v4l2-ctl-common.cpp
 void common_usage(void);
 void common_cmd(int ch, char *optarg);
-void common_set(int fd);
-void common_get(int fd);
-void common_list(int fd);
-void common_process_controls(int fd);
+void common_set(cv4l_fd &fd);
+void common_get(cv4l_fd &fd);
+void common_list(cv4l_fd &fd);
+void common_process_controls(cv4l_fd &fd);
 void common_control_event(const struct v4l2_event *ev);
 int common_find_ctrl_id(const char *name);
 
 // v4l2-ctl-tuner.cpp
 void tuner_usage(void);
 void tuner_cmd(int ch, char *optarg);
-void tuner_set(int fd);
-void tuner_get(int fd);
+void tuner_set(cv4l_fd &fd);
+void tuner_get(cv4l_fd &fd);
 
 // v4l2-ctl-io.cpp
 void io_usage(void);
 void io_cmd(int ch, char *optarg);
-void io_set(int fd);
-void io_get(int fd);
-void io_list(int fd);
+void io_set(cv4l_fd &fd);
+void io_get(cv4l_fd &fd);
+void io_list(cv4l_fd &fd);
 
 // v4l2-ctl-stds.cpp
 void stds_usage(void);
 void stds_cmd(int ch, char *optarg);
-void stds_set(int fd);
-void stds_get(int fd);
-void stds_list(int fd);
+void stds_set(cv4l_fd &fd);
+void stds_get(cv4l_fd &fd);
+void stds_list(cv4l_fd &fd);
 
 // v4l2-ctl-vidcap.cpp
 void vidcap_usage(void);
 void vidcap_cmd(int ch, char *optarg);
-void vidcap_set(int fd);
-void vidcap_get(int fd);
-void vidcap_list(int fd);
+void vidcap_set(cv4l_fd &fd);
+void vidcap_get(cv4l_fd &fd);
+void vidcap_list(cv4l_fd &fd);
 
 // v4l2-ctl-vidout.cpp
 void vidout_usage(void);
 void vidout_cmd(int ch, char *optarg);
-void vidout_set(int fd);
-void vidout_get(int fd);
-void vidout_list(int fd);
+void vidout_set(cv4l_fd &fd);
+void vidout_get(cv4l_fd &fd);
+void vidout_list(cv4l_fd &fd);
 
 // v4l2-ctl-overlay.cpp
 void overlay_usage(void);
 void overlay_cmd(int ch, char *optarg);
-void overlay_set(int fd);
-void overlay_get(int fd);
-void overlay_list(int fd);
+void overlay_set(cv4l_fd &fd);
+void overlay_get(cv4l_fd &fd);
+void overlay_list(cv4l_fd &fd);
 
 // v4l2-ctl-vbi.cpp
 void vbi_usage(void);
 void vbi_cmd(int ch, char *optarg);
-void vbi_set(int fd);
-void vbi_get(int fd);
-void vbi_list(int fd);
+void vbi_set(cv4l_fd &fd);
+void vbi_get(cv4l_fd &fd);
+void vbi_list(cv4l_fd &fd);
 
 // v4l2-ctl-sdr.cpp
 void sdr_usage(void);
 void sdr_cmd(int ch, char *optarg);
-void sdr_set(int fd);
-void sdr_get(int fd);
-void sdr_list(int fd);
+void sdr_set(cv4l_fd &fd);
+void sdr_get(cv4l_fd &fd);
+void sdr_list(cv4l_fd &fd);
 
 // v4l2-ctl-meta.cpp
 void meta_usage(void);
 void meta_cmd(int ch, char *optarg);
-void meta_set(int fd);
-void meta_get(int fd);
-void meta_list(int fd);
+void meta_set(cv4l_fd &fd);
+void meta_get(cv4l_fd &fd);
+void meta_list(cv4l_fd &fd);
 
 // v4l2-ctl-subdev.cpp
 void subdev_usage(void);
 void subdev_cmd(int ch, char *optarg);
-void subdev_set(int fd);
-void subdev_get(int fd);
-void subdev_list(int fd);
+void subdev_set(cv4l_fd &fd);
+void subdev_get(cv4l_fd &fd);
+void subdev_list(cv4l_fd &fd);
 
 // v4l2-ctl-selection.cpp
 void selection_usage(void);
 void selection_cmd(int ch, char *optarg);
-void selection_set(int fd);
-void selection_get(int fd);
+void selection_set(cv4l_fd &fd);
+void selection_get(cv4l_fd &fd);
 
 // v4l2-ctl-misc.cpp
 // This one is also used by the streaming code.
 extern struct v4l2_decoder_cmd dec_cmd;
 void misc_usage(void);
 void misc_cmd(int ch, char *optarg);
-void misc_set(int fd);
-void misc_get(int fd);
+void misc_set(cv4l_fd &fd);
+void misc_get(cv4l_fd &fd);
 
 // v4l2-ctl-streaming.cpp
 void streaming_usage(void);
@@ -408,8 +412,8 @@ void streaming_list(cv4l_fd &fd, cv4l_fd &out_fd);
 // v4l2-ctl-edid.cpp
 void edid_usage(void);
 void edid_cmd(int ch, char *optarg);
-void edid_set(int fd);
-void edid_get(int fd);
+void edid_set(cv4l_fd &fd);
+void edid_get(cv4l_fd &fd);
 
 /* v4l2-ctl-modes.cpp */
 bool calc_cvt_modeline(int image_width, int image_height,

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to