From 0f244c1179f86853703f68e41073118f58dd47e9 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 20 Jun 2009 14:52:22 +0200 Subject: v4l2-ctl: support new RDS and modulator caps. From: Hans Verkuil Priority: normal Signed-off-by: Hans Verkuil --- v4l2-apps/util/v4l2-ctl.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'v4l2-apps/util') diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp index 6f6b5e2f8..3355f28e6 100644 --- a/v4l2-apps/util/v4l2-ctl.cpp +++ b/v4l2-apps/util/v4l2-ctl.cpp @@ -1019,8 +1019,12 @@ static std::string cap2s(unsigned cap) s += "\t\tSliced VBI Output\n"; if (cap & V4L2_CAP_RDS_CAPTURE) s += "\t\tRDS Capture\n"; + if (cap & V4L2_CAP_RDS_OUTPUT) + s += "\t\tRDS Output\n"; if (cap & V4L2_CAP_TUNER) s += "\t\tTuner\n"; + if (cap & V4L2_CAP_MODULATOR) + s += "\t\tModulator\n"; if (cap & V4L2_CAP_AUDIO) s += "\t\tAudio\n"; if (cap & V4L2_CAP_RADIO) -- cgit v1.2.3 From 952c49f54e270f24e84923c228b98348e052317c Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 20 Jul 2009 16:20:36 +0200 Subject: v4l2-ctl: fix broken camera control support. From: Hans Verkuil v4l2-ctl didn't properly support the camera controls. Priority: normal Signed-off-by: Hans Verkuil --- v4l2-apps/util/v4l2-ctl.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'v4l2-apps/util') diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp index 6f6b5e2f8..5410e5d03 100644 --- a/v4l2-apps/util/v4l2-ctl.cpp +++ b/v4l2-apps/util/v4l2-ctl.cpp @@ -147,6 +147,7 @@ static unsigned capabilities; typedef std::vector ctrl_list; static ctrl_list user_ctrls; static ctrl_list mpeg_ctrls; +static ctrl_list camera_ctrls; typedef std::map ctrl_strmap; static ctrl_strmap ctrl_str2id; @@ -2187,6 +2188,8 @@ set_vid_fmt_error: ctrl.value = strtol(iter->second.c_str(), NULL, 0); if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_MPEG) mpeg_ctrls.push_back(ctrl); + else if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_CAMERA) + camera_ctrls.push_back(ctrl); else user_ctrls.push_back(ctrl); } @@ -2217,6 +2220,22 @@ set_vid_fmt_error: } } } + if (camera_ctrls.size()) { + ctrls.ctrl_class = V4L2_CTRL_CLASS_CAMERA; + ctrls.count = camera_ctrls.size(); + ctrls.controls = &camera_ctrls[0]; + if (doioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls, "VIDIOC_S_EXT_CTRLS")) { + if (ctrls.error_idx >= ctrls.count) { + fprintf(stderr, "Error setting CAMERA controls: %s\n", + strerror(errno)); + } + else { + fprintf(stderr, "%s: %s\n", + ctrl_id2str[camera_ctrls[ctrls.error_idx].id].c_str(), + strerror(errno)); + } + } + } } /* Get options */ @@ -2432,6 +2451,7 @@ set_vid_fmt_error: struct v4l2_ext_controls ctrls = { 0 }; mpeg_ctrls.clear(); + camera_ctrls.clear(); user_ctrls.clear(); for (ctrl_get_list::iterator iter = get_ctrls.begin(); iter != get_ctrls.end(); ++iter) { @@ -2440,6 +2460,8 @@ set_vid_fmt_error: ctrl.id = ctrl_str2id[*iter]; if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_MPEG) mpeg_ctrls.push_back(ctrl); + else if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_CAMERA) + camera_ctrls.push_back(ctrl); else user_ctrls.push_back(ctrl); } @@ -2458,6 +2480,17 @@ set_vid_fmt_error: for (unsigned i = 0; i < mpeg_ctrls.size(); i++) { struct v4l2_ext_control ctrl = mpeg_ctrls[i]; + printf("%s: %d\n", ctrl_id2str[ctrl.id].c_str(), ctrl.value); + } + } + if (camera_ctrls.size()) { + ctrls.ctrl_class = V4L2_CTRL_CLASS_CAMERA; + ctrls.count = camera_ctrls.size(); + ctrls.controls = &camera_ctrls[0]; + doioctl(fd, VIDIOC_G_EXT_CTRLS, &ctrls, "VIDIOC_G_EXT_CTRLS"); + for (unsigned i = 0; i < camera_ctrls.size(); i++) { + struct v4l2_ext_control ctrl = camera_ctrls[i]; + printf("%s: %d\n", ctrl_id2str[ctrl.id].c_str(), ctrl.value); } } -- cgit v1.2.3 From c3f9323429d06d88d8986100746bebe48c6b7097 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 9 Aug 2009 19:58:14 -0300 Subject: v4l2-dbg: Add register maps for mt9v011 From: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-dbg-micron.h | 46 ++++++++++++++++++++++++++++++++++++++++ v4l2-apps/util/v4l2-dbg.cpp | 19 ++++++++++++----- 2 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 v4l2-apps/util/v4l2-dbg-micron.h (limited to 'v4l2-apps/util') diff --git a/v4l2-apps/util/v4l2-dbg-micron.h b/v4l2-apps/util/v4l2-dbg-micron.h new file mode 100644 index 000000000..8466322bf --- /dev/null +++ b/v4l2-apps/util/v4l2-dbg-micron.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2009 Mauro Carvalho Chehab + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "v4l2-dbg.h" + +#define MT9V011_IDENT "mt9v011" + +/* Register name prefix */ +#define MT9V011_PREFIX "MT9V011_" + +static struct board_regs mt9v011_regs[] = { + {0x00, MT9V011_PREFIX "CHIP_VERSION"}, + {0x01, MT9V011_PREFIX "ROWSTART"}, + {0x02, MT9V011_PREFIX "COLSTART"}, + {0x03, MT9V011_PREFIX "HEIGHT"}, + {0x04, MT9V011_PREFIX "WIDTH"}, + {0x05, MT9V011_PREFIX "HBLANK"}, + {0x06, MT9V011_PREFIX "VBLANK"}, + {0x07, MT9V011_PREFIX "OUT_CTRL"}, + {0x09, MT9V011_PREFIX "SHUTTER_WIDTH"}, + {0x0a, MT9V011_PREFIX "CLK_SPEED"}, + {0x0b, MT9V011_PREFIX "RESTART"}, + {0x0c, MT9V011_PREFIX "SHUTTER_DELAY"}, + {0x0d, MT9V011_PREFIX "RESET"}, + {0x1e, MT9V011_PREFIX "DIGITAL_ZOOM"}, + {0x20, MT9V011_PREFIX "READ_MODE"}, + {0x2b, MT9V011_PREFIX "GREEN_1_GAIN"}, + {0x2c, MT9V011_PREFIX "BLUE_GAIN"}, + {0x2d, MT9V011_PREFIX "RED_GAIN"}, + {0x2e, MT9V011_PREFIX "GREEN_2_GAIN"}, + {0x35, MT9V011_PREFIX "GLOBAL_GAIN"}, + {0xf1, MT9V011_PREFIX "CHIP_ENABLE"}, +}; diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index 424b0fffe..1a481c04c 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -47,6 +47,7 @@ #include "v4l2-dbg-em28xx.h" #include "v4l2-dbg-ac97.h" #include "v4l2-dbg-tvp5150.h" +#include "v4l2-dbg-micron.h" #define ARRAY_SIZE(arr) ((int)(sizeof(arr) / sizeof((arr)[0]))) @@ -61,7 +62,7 @@ struct board_list { static const struct board_list boards[] = { #define AC97_BOARD 0 - { /* From ac97-dbg.h */ + { /* From v4l2-dbg-ac97.h */ AC97_IDENT, sizeof(AC97_PREFIX) - 1, ac97_regs, @@ -69,7 +70,7 @@ static const struct board_list boards[] = { NULL, 0, }, - { /* From bttv-dbg.h */ + { /* From v4l2-dbg-bttv.h */ BTTV_IDENT, sizeof(BTTV_PREFIX) - 1, bt8xx_regs, @@ -77,7 +78,7 @@ static const struct board_list boards[] = { bt8xx_regs_other, ARRAY_SIZE(bt8xx_regs_other), }, - { /* From saa7134-dbg.h */ + { /* From v4l2-dbg-saa7134.h */ SAA7134_IDENT, sizeof(SAA7134_PREFIX) - 1, saa7134_regs, @@ -85,7 +86,7 @@ static const struct board_list boards[] = { NULL, 0, }, - { /* From em28xx-dbg.h */ + { /* From v4l2-dbg-em28xx.h */ EM28XX_IDENT, sizeof(EM28XX_PREFIX) - 1, em28xx_regs, @@ -93,7 +94,7 @@ static const struct board_list boards[] = { em28xx_alt_regs, ARRAY_SIZE(em28xx_alt_regs), }, - { /* From tvp5150-dbg.h */ + { /* From v4l2-dbg-tvp5150.h */ TVP5150_IDENT, sizeof(TVP5150_PREFIX) - 1, tvp5150_regs, @@ -101,6 +102,14 @@ static const struct board_list boards[] = { NULL, 0, }, + { /* From v4l2-dbg-micron.h */ + MT9V011_IDENT, + sizeof(MT9V011_PREFIX) - 1, + mt9v011_regs, + ARRAY_SIZE(mt9v011_regs), + NULL, + 0, + }, }; struct chipid { -- cgit v1.2.3 From 11a870a6ffe158aa929d11a5adac7cfc3d7a0f4e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 6 Aug 2009 20:32:01 -0300 Subject: v4l2-ctl: Add support for VIDIOC_[G|S]_PARM From: Mauro Carvalho Chehab Those ioctls are used to control streaming frame rate. Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-ctl.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'v4l2-apps/util') diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp index b2246c557..e872a2916 100644 --- a/v4l2-apps/util/v4l2-ctl.cpp +++ b/v4l2-apps/util/v4l2-ctl.cpp @@ -77,6 +77,8 @@ enum Option { OptSetTuner = 't', OptGetVideoFormat = 'V', OptSetVideoFormat = 'v', + OptGetParm = 'P', + OptSetParm = 'p', OptGetSlicedVbiOutFormat = 128, OptGetOverlayFormat, @@ -222,6 +224,8 @@ static struct option long_options[] = { {"list-formats", no_argument, 0, OptListFormats}, {"get-standard", no_argument, 0, OptGetStandard}, {"set-standard", required_argument, 0, OptSetStandard}, + {"get-parm", no_argument, 0, OptGetParm}, + {"set-parm", required_argument, 0, OptSetParm}, {"info", no_argument, 0, OptGetDriverInfo}, {"list-ctrls", no_argument, 0, OptListCtrls}, {"list-ctrls-menus", no_argument, 0, OptListCtrlsMenus}, @@ -306,6 +310,8 @@ static void usage(void) " ntsc-X (X = M/J/K) or just 'ntsc' (V4L2_STD_NTSC)\n" " secam-X (X = B/G/H/D/K/L/Lc) or just 'secam' (V4L2_STD_SECAM)\n" " --list-standards display supported video standards [VIDIOC_ENUMSTD]\n" + " -P, --get-parm display video parameters [VIDIOC_G_PARMS]\n" + " -p, --set-parm set video rate in fps [VIDIOC_G_PARMS]\n" " -T, --get-tuner query the tuner settings [VIDIOC_G_TUNER]\n" " -t, --set-tuner=\n" " set the audio mode of the tuner [VIDIOC_S_TUNER]\n" @@ -1419,11 +1425,13 @@ int main(int argc, char **argv) struct v4l2_rect vcrop_out_overlay; /* crop rect */ struct v4l2_framebuffer fbuf; /* fbuf */ struct v4l2_jpegcompression jpegcomp; /* jpeg compression */ + struct v4l2_streamparm parm; /* get/set parm */ int input; /* set_input/get_input */ int output; /* set_output/get_output */ int txsubchans; /* set_modulator */ v4l2_std_id std; /* get_std/set_std */ double freq = 0; /* get/set frequency */ + double fps = 0; /* set framerate speed, in fps */ struct v4l2_frequency vf; /* get_freq/set_freq */ struct v4l2_standard vs; /* list_std */ int overlay; /* overlay */ @@ -1690,6 +1698,9 @@ int main(int argc, char **argv) std = strtol(optarg, 0L, 0) | (1ULL << 63); } break; + case OptSetParm: + fps = strtod(optarg, NULL); + break; case OptGetCtrl: subs = optarg; while (*subs != '\0') { @@ -1915,6 +1926,7 @@ int main(int argc, char **argv) options[OptGetAudioInput] = 1; options[OptGetAudioOutput] = 1; options[OptGetStandard] = 1; + options[OptGetParm] = 1; options[OptGetFreq] = 1; options[OptGetTuner] = 1; options[OptGetModulator] = 1; @@ -1976,6 +1988,23 @@ int main(int argc, char **argv) printf("Standard set to %08llx\n", (unsigned long long)std); } + + if (options[OptSetParm]) { + memset (&parm, 0, sizeof(parm)); + parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + parm.parm.capture.timeperframe.numerator = 1000; + parm.parm.capture.timeperframe.denominator = (__u32)(fps * parm.parm.capture.timeperframe.numerator); + + if (doioctl(fd, VIDIOC_S_PARM, &parm, "VIDIOC_S_PARM") == 0) { + struct v4l2_fract *tf = &parm.parm.capture.timeperframe; + if (!tf->denominator || !tf->numerator) + printf ("Invalid frame rate\n"); + else + printf("Frame rate set to: %.3f fps\n", + 1.0*tf->denominator/tf->numerator); + } + } + if (options[OptSetInput]) { if (doioctl(fd, VIDIOC_S_INPUT, &input, "VIDIOC_S_INPUT") == 0) { printf("Video input set to %d", input); @@ -2451,6 +2480,23 @@ set_vid_fmt_error: } } + if (options[OptGetParm]) { + memset (&parm, 0, sizeof(parm)); + parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (doioctl(fd, VIDIOC_G_PARM, &parm, "VIDIOC_G_PARM") == 0) { + struct v4l2_fract *tf = &parm.parm.capture.timeperframe; + if (parm.parm.capture.capability & V4L2_MODE_HIGHQUALITY) + printf("Has High quality imaging mode\n"); + if (parm.parm.capture.capability && V4L2_CAP_TIMEPERFRAME) + printf("Has V4L2_CAP_TIMEPERFRAME\n"); + if (!tf->denominator || !tf->numerator) + printf ("Invalid frame rate\n"); + else + printf("Frame rate is %.3f fps\n", + (1.0 * tf->denominator) / tf->numerator); + } + } + if (options[OptGetCtrl] && !get_ctrls.empty()) { struct v4l2_ext_controls ctrls = { 0 }; -- cgit v1.2.3 From eb07db27a2dcfe8263e54069db82b60c4219e670 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 7 Aug 2009 16:48:52 +0200 Subject: v4l2-ctl: fix help message From: hermann pitton For -p (--set-parm) v4l2-ctl also prints G_PARMS too. -P, --get-parm display video parameters [VIDIOC_G_PARMS] -p, --set-parm set video rate in fps [VIDIOC_G_PARMS] Priority: normal Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-ctl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'v4l2-apps/util') diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp index e872a2916..898c88cb7 100644 --- a/v4l2-apps/util/v4l2-ctl.cpp +++ b/v4l2-apps/util/v4l2-ctl.cpp @@ -311,7 +311,7 @@ static void usage(void) " secam-X (X = B/G/H/D/K/L/Lc) or just 'secam' (V4L2_STD_SECAM)\n" " --list-standards display supported video standards [VIDIOC_ENUMSTD]\n" " -P, --get-parm display video parameters [VIDIOC_G_PARMS]\n" - " -p, --set-parm set video rate in fps [VIDIOC_G_PARMS]\n" + " -p, --set-parm set video rate in fps [VIDIOC_S_PARMS]\n" " -T, --get-tuner query the tuner settings [VIDIOC_G_TUNER]\n" " -t, --set-tuner=\n" " set the audio mode of the tuner [VIDIOC_S_TUNER]\n" -- cgit v1.2.3 From 9bd841d241b9c9c46b86a860a279d3c576b5ca90 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 7 Aug 2009 12:39:31 +0200 Subject: v4l2-ctl: fix get/set-parm bugs and add get/set-output-parm support From: Hans Verkuil Fixed several get/set-parm bugs, cleaned it up a bit and reformatted the output to conform to the output of the other get options. Implemented get/set-output-parm to complete the VIDIOC_G/S_PARM support. Priority: normal Signed-off-by: Hans Verkuil --- v4l2-apps/util/v4l2-ctl.cpp | 98 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 79 insertions(+), 19 deletions(-) (limited to 'v4l2-apps/util') diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp index 898c88cb7..60ebc5474 100644 --- a/v4l2-apps/util/v4l2-ctl.cpp +++ b/v4l2-apps/util/v4l2-ctl.cpp @@ -136,6 +136,8 @@ enum Option { OptGetModulator, OptSetModulator, OptListDevices, + OptGetOutputParm, + OptSetOutputParm, OptLast = 256 }; @@ -226,6 +228,8 @@ static struct option long_options[] = { {"set-standard", required_argument, 0, OptSetStandard}, {"get-parm", no_argument, 0, OptGetParm}, {"set-parm", required_argument, 0, OptSetParm}, + {"get-output-parm", no_argument, 0, OptGetOutputParm}, + {"set-output-parm", required_argument, 0, OptSetOutputParm}, {"info", no_argument, 0, OptGetDriverInfo}, {"list-ctrls", no_argument, 0, OptListCtrls}, {"list-ctrls-menus", no_argument, 0, OptListCtrlsMenus}, @@ -310,8 +314,9 @@ static void usage(void) " ntsc-X (X = M/J/K) or just 'ntsc' (V4L2_STD_NTSC)\n" " secam-X (X = B/G/H/D/K/L/Lc) or just 'secam' (V4L2_STD_SECAM)\n" " --list-standards display supported video standards [VIDIOC_ENUMSTD]\n" - " -P, --get-parm display video parameters [VIDIOC_G_PARMS]\n" - " -p, --set-parm set video rate in fps [VIDIOC_S_PARMS]\n" + " -P, --get-parm display video parameters [VIDIOC_G_PARM]\n" + " -p, --set-parm=\n" + " set video framerate in [VIDIOC_S_PARM]\n" " -T, --get-tuner query the tuner settings [VIDIOC_G_TUNER]\n" " -t, --set-tuner=\n" " set the audio mode of the tuner [VIDIOC_S_TUNER]\n" @@ -424,6 +429,9 @@ static void usage(void) " bilingual: Modulate as bilingual\n" " mono-sap: Modulate as mono with Second Audio Program\n" " stereo-sap: Modulate as stereo with Second Audio Program\n" + " --get-output-parm display output video parameters [VIDIOC_G_PARM]\n" + " --set-output-parm=\n" + " set output video framerate in [VIDIOC_S_PARM]\n" "\n"); printf("Expert options:\n" " --streamoff turn the stream off [VIDIOC_STREAMOFF]\n" @@ -830,7 +838,7 @@ static void printcropcap(const struct v4l2_cropcap &cropcap) printf("\tPixel Aspect: %u/%u\n", cropcap.pixelaspect.numerator, cropcap.pixelaspect.denominator); } -static void printfmt(struct v4l2_format vfmt) +static void printfmt(const struct v4l2_format &vfmt) { const flag_def vbi_def[] = { { V4L2_VBI_UNSYNC, "unsynchronized" }, @@ -1431,7 +1439,8 @@ int main(int argc, char **argv) int txsubchans; /* set_modulator */ v4l2_std_id std; /* get_std/set_std */ double freq = 0; /* get/set frequency */ - double fps = 0; /* set framerate speed, in fps */ + double fps = 0; /* set framerate speed, in fps */ + double output_fps = 0; /* set framerate speed, in fps */ struct v4l2_frequency vf; /* get_freq/set_freq */ struct v4l2_standard vs; /* list_std */ int overlay; /* overlay */ @@ -1701,6 +1710,9 @@ int main(int argc, char **argv) case OptSetParm: fps = strtod(optarg, NULL); break; + case OptSetOutputParm: + output_fps = strtod(optarg, NULL); + break; case OptGetCtrl: subs = optarg; while (*subs != '\0') { @@ -1927,6 +1939,7 @@ int main(int argc, char **argv) options[OptGetAudioOutput] = 1; options[OptGetStandard] = 1; options[OptGetParm] = 1; + options[OptGetOutputParm] = 1; options[OptGetFreq] = 1; options[OptGetTuner] = 1; options[OptGetModulator] = 1; @@ -1990,18 +2003,38 @@ int main(int argc, char **argv) if (options[OptSetParm]) { - memset (&parm, 0, sizeof(parm)); + memset(&parm, 0, sizeof(parm)); parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; parm.parm.capture.timeperframe.numerator = 1000; - parm.parm.capture.timeperframe.denominator = (__u32)(fps * parm.parm.capture.timeperframe.numerator); + parm.parm.capture.timeperframe.denominator = + fps * parm.parm.capture.timeperframe.numerator; if (doioctl(fd, VIDIOC_S_PARM, &parm, "VIDIOC_S_PARM") == 0) { struct v4l2_fract *tf = &parm.parm.capture.timeperframe; + if (!tf->denominator || !tf->numerator) - printf ("Invalid frame rate\n"); + printf("Invalid frame rate\n"); else - printf("Frame rate set to: %.3f fps\n", - 1.0*tf->denominator/tf->numerator); + printf("Frame rate set to %.3f fps\n", + 1.0 * tf->denominator / tf->numerator); + } + } + + if (options[OptSetOutputParm]) { + memset(&parm, 0, sizeof(parm)); + parm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + parm.parm.output.timeperframe.numerator = 1000; + parm.parm.output.timeperframe.denominator = + fps * parm.parm.output.timeperframe.numerator; + + if (doioctl(fd, VIDIOC_S_PARM, &parm, "VIDIOC_S_PARM") == 0) { + struct v4l2_fract *tf = &parm.parm.output.timeperframe; + + if (!tf->denominator || !tf->numerator) + printf("Invalid frame rate\n"); + else + printf("Frame rate set to %.3f fps\n", + 1.0 * tf->denominator / tf->numerator); } } @@ -2481,19 +2514,46 @@ set_vid_fmt_error: } if (options[OptGetParm]) { - memset (&parm, 0, sizeof(parm)); + memset(&parm, 0, sizeof(parm)); parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (doioctl(fd, VIDIOC_G_PARM, &parm, "VIDIOC_G_PARM") == 0) { - struct v4l2_fract *tf = &parm.parm.capture.timeperframe; - if (parm.parm.capture.capability & V4L2_MODE_HIGHQUALITY) - printf("Has High quality imaging mode\n"); - if (parm.parm.capture.capability && V4L2_CAP_TIMEPERFRAME) - printf("Has V4L2_CAP_TIMEPERFRAME\n"); - if (!tf->denominator || !tf->numerator) - printf ("Invalid frame rate\n"); + const struct v4l2_fract &tf = parm.parm.capture.timeperframe; + + printf("Streaming Parameters %s:\n", buftype2s(parm.type).c_str()); + if (parm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) + printf("\tCapabilities : timeperframe\n"); + if (parm.parm.capture.capturemode & V4L2_MODE_HIGHQUALITY) + printf("\tCapture mode : high quality\n"); + if (!tf.denominator || !tf.numerator) + printf("\tFrames per second: invalid (%d/%d)\n", + tf.denominator, tf.numerator); + else + printf("\tFrames per second: %.3f (%d/%d)\n", + (1.0 * tf.denominator) / tf.numerator, + tf.denominator, tf.numerator); + printf("\tRead buffers : %d\n", parm.parm.output.writebuffers); + } + } + + if (options[OptGetOutputParm]) { + memset(&parm, 0, sizeof(parm)); + parm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + if (doioctl(fd, VIDIOC_G_PARM, &parm, "VIDIOC_G_PARM") == 0) { + const struct v4l2_fract &tf = parm.parm.output.timeperframe; + + printf("Streaming Parameters %s:\n", buftype2s(parm.type).c_str()); + if (parm.parm.output.capability & V4L2_CAP_TIMEPERFRAME) + printf("\tCapabilities : timeperframe\n"); + if (parm.parm.output.outputmode & V4L2_MODE_HIGHQUALITY) + printf("\tOutput mode : high quality\n"); + if (!tf.denominator || !tf.numerator) + printf("\tFrames per second: invalid (%d/%d)\n", + tf.denominator, tf.numerator); else - printf("Frame rate is %.3f fps\n", - (1.0 * tf->denominator) / tf->numerator); + printf("\tFrames per second: %.3f (%d/%d)\n", + (1.0 * tf.denominator) / tf.numerator, + tf.denominator, tf.numerator); + printf("\tWrite buffers : %d\n", parm.parm.output.writebuffers); } } -- cgit v1.2.3