summaryrefslogtreecommitdiff
path: root/v4l2-apps/util/v4l2-ctl.cpp
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-08-06 20:32:01 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-08-06 20:32:01 -0300
commit11a870a6ffe158aa929d11a5adac7cfc3d7a0f4e (patch)
tree05f0feae680138fd1f400b6727a45ef91c05aa96 /v4l2-apps/util/v4l2-ctl.cpp
parent18c7475db040fb0ed62df174b6831aea290f2479 (diff)
downloadmediapointer-dvb-s2-11a870a6ffe158aa929d11a5adac7cfc3d7a0f4e.tar.gz
mediapointer-dvb-s2-11a870a6ffe158aa929d11a5adac7cfc3d7a0f4e.tar.bz2
v4l2-ctl: Add support for VIDIOC_[G|S]_PARM
From: Mauro Carvalho Chehab <mchehab@redhat.com> Those ioctls are used to control streaming frame rate. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'v4l2-apps/util/v4l2-ctl.cpp')
-rw-r--r--v4l2-apps/util/v4l2-ctl.cpp46
1 files changed, 46 insertions, 0 deletions
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=<mode>\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 };