summaryrefslogtreecommitdiff
path: root/v4l2-apps/util/v4l2-ctl.cpp
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-08-22 10:34:29 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-08-22 10:34:29 -0300
commit4d3f684d3b6ab28ec9e251fff156d0b0f53d0517 (patch)
treef82a2ae2dc042d6d1de61f62babeb8c5f28b22a1 /v4l2-apps/util/v4l2-ctl.cpp
parent87eb1f67e4981f3a09825012f16af0107a7adb45 (diff)
parentb5ff2cd5cc913156858a0b15a186144f146c89d7 (diff)
downloadmediapointer-dvb-s2-4d3f684d3b6ab28ec9e251fff156d0b0f53d0517.tar.gz
mediapointer-dvb-s2-4d3f684d3b6ab28ec9e251fff156d0b0f53d0517.tar.bz2
merge: http://linuxtv.org/hg/~mkrufky/sms1xxx
From: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'v4l2-apps/util/v4l2-ctl.cpp')
-rw-r--r--v4l2-apps/util/v4l2-ctl.cpp311
1 files changed, 172 insertions, 139 deletions
diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp
index 57d98fc13..ae9293414 100644
--- a/v4l2-apps/util/v4l2-ctl.cpp
+++ b/v4l2-apps/util/v4l2-ctl.cpp
@@ -160,6 +160,7 @@ static const flag_def service_def[] = {
#define FmtHeight (1L<<1)
#define FmtChromaKey (1L<<2)
#define FmtGlobalAlpha (1L<<3)
+#define FmtPixelFormat (1L<<4)
/* crop specified */
#define CropWidth (1L<<0)
@@ -236,126 +237,128 @@ static struct option long_options[] = {
static void usage(void)
{
printf("Usage:\n");
- printf("Common options:\n");
- printf(" --all display all information available\n");
- printf(" -B, --get-fmt-sliced-vbi\n");
- printf(" query the sliced VBI capture format [VIDIOC_G_FMT]\n");
- printf(" -b, --set-fmt-sliced-vbi=<mode>\n");
- printf(" set the sliced VBI capture format to <mode> [VIDIOC_S_FMT]\n");
- printf(" <mode> is a comma separated list of:\n");
- printf(" off: turn off sliced VBI (cannot be combined with other modes)\n");
- printf(" teletext: teletext (PAL/SECAM)\n");
- printf(" cc: closed caption (NTSC)\n");
- printf(" wss: widescreen signal (PAL/SECAM)\n");
- printf(" vps: VPS (PAL/SECAM)\n");
- printf(" -C, --get-ctrl=<ctrl>[,<ctrl>...]\n");
- printf(" get the value of the controls [VIDIOC_G_EXT_CTRLS]\n");
- printf(" -c, --set-ctrl=<ctrl>=<val>[,<ctrl>=<val>...]\n");
- printf(" set the controls to the values specified [VIDIOC_S_EXT_CTRLS]\n");
- printf(" -D, --info show driver info [VIDIOC_QUERYCAP]\n");
- printf(" -d, --device=<dev> use device <dev> instead of /dev/video0\n");
- printf(" if <dev> is a single digit, then /dev/video<dev> is used\n");
- printf(" -F, --get-freq query the frequency [VIDIOC_G_FREQUENCY]\n");
- printf(" -f, --set-freq=<freq>\n");
- printf(" set the frequency to <freq> MHz [VIDIOC_S_FREQUENCY]\n");
- printf(" -h, --help display this help message\n");
- printf(" -I, --get-input query the video input [VIDIOC_G_INPUT]\n");
- printf(" -i, --set-input=<num>\n");
- printf(" set the video input to <num> [VIDIOC_S_INPUT]\n");
- printf(" -l, --list-ctrls display all controls and their values [VIDIOC_QUERYCTRL]\n");
- printf(" -L, --list-ctrls-menus\n");
- printf(" display all controls, their values and the menus [VIDIOC_QUERYMENU]\n");
- printf(" -N, --list-outputs display video outputs [VIDIOC_ENUMOUTPUT]\n");
- printf(" -n, --list-inputs display video inputs [VIDIOC_ENUMINPUT]\n");
- printf(" -O, --get-output query the video output [VIDIOC_G_OUTPUT]\n");
- printf(" -o, --set-output=<num>\n");
- printf(" set the video output to <num> [VIDIOC_S_OUTPUT]\n");
- printf(" -S, --get-standard\n");
- printf(" query the video standard [VIDIOC_G_STD]\n");
- printf(" -s, --set-standard=<num>\n");
- printf(" set the video standard to <num> [VIDIOC_S_STD]\n");
- printf(" <num> can be a numerical v4l2_std value, or it can be one of:\n");
- printf(" pal-X (X = B/G/H/N/Nc/I/D/K/M/60) or just 'pal' (V4L2_STD_PAL)\n");
- printf(" ntsc-X (X = M/J/K) or just 'ntsc' (V4L2_STD_NTSC)\n");
- printf(" secam-X (X = B/G/H/D/K/L/Lc) or just 'secam' (V4L2_STD_SECAM)\n");
- printf(" --list-standards display supported video standards [VIDIOC_ENUMSTD]\n");
- printf(" -T, --get-tuner query the tuner settings [VIDIOC_G_TUNER]\n");
- printf(" -t, --set-tuner=<mode>\n");
- printf(" set the audio mode of the tuner [VIDIOC_S_TUNER]\n");
- printf(" Possible values: mono, stereo, lang2, lang1, bilingual\n");
- printf(" --list-formats display supported video formats [VIDIOC_ENUM_FMT]\n");
- printf(" -V, --get-fmt-video\n");
- printf(" query the video capture format [VIDIOC_G_FMT]\n");
- printf(" -v, --set-fmt-video=width=<w>,height=<h>\n");
- printf(" set the video capture format [VIDIOC_S_FMT]\n");
- printf(" --verbose turn on verbose ioctl error reporting.\n");
- printf("\n");
- printf("Uncommon options:\n");
- printf(" --get-fmt-video-out\n");
- printf(" query the video output format [VIDIOC_G_FMT]\n");
- printf(" --set-fmt-video-out=width=<w>,height=<h>\n");
- printf(" set the video output format [VIDIOC_S_FMT]\n");
- printf(" --get-fmt-overlay\n");
- printf(" query the video overlay format [VIDIOC_G_FMT]\n");
- printf(" --get-fmt-output-overlay\n");
- printf(" query the video output overlay format [VIDIOC_G_FMT]\n");
- printf(" --set-fmt-output-overlay=chromakey=<key>,global_alpha=<alpha>\n");
- printf(" set the video output overlay format [VIDIOC_S_FMT]\n");
- printf(" --get-sliced-vbi-cap\n");
- printf(" query the sliced VBI capture capabilities [VIDIOC_G_SLICED_VBI_CAP]\n");
- printf(" --get-sliced-vbi-out-cap\n");
- printf(" query the sliced VBI output capabilities [VIDIOC_G_SLICED_VBI_CAP]\n");
- printf(" --get-fmt-sliced-vbi-out\n");
- printf(" query the sliced VBI output format [VIDIOC_G_FMT]\n");
- printf(" --set-fmt-sliced-vbi-out=<mode>\n");
- printf(" set the sliced VBI output format to <mode> [VIDIOC_S_FMT]\n");
- printf(" <mode> is a comma separated list of:\n");
- printf(" off: turn off sliced VBI (cannot be combined with other modes)\n");
- printf(" teletext: teletext (PAL/SECAM)\n");
- printf(" cc: closed caption (NTSC)\n");
- printf(" wss: widescreen signal (PAL/SECAM)\n");
- printf(" vps: VPS (PAL/SECAM)\n");
- printf(" --get-fmt-vbi query the VBI capture format [VIDIOC_G_FMT]\n");
- printf(" --get-fmt-vbi-out query the VBI output format [VIDIOC_G_FMT]\n");
- printf(" --overlay=<on> turn overlay on (1) or off (0) (VIDIOC_OVERLAY)\n");
- printf(" --get-fbuf query the overlay framebuffer data [VIDIOC_G_FBUF]\n");
- printf(" --set-fbuf=chromakey=<0/1>,global_alpha=<0/1>,local_alpha=<0/1>,local_inv_alpha=<0/1>\n");
- printf(" set the overlay framebuffer [VIDIOC_S_FBUF]\n");
- printf(" --get-cropcap query the crop capabilities [VIDIOC_CROPCAP]\n");
- printf(" --get-crop query the video capture crop window [VIDIOC_G_CROP]\n");
- printf(" --set-crop=top=<x>,left=<y>,width=<w>,height=<h>\n");
- printf(" set the video capture crop window [VIDIOC_S_CROP]\n");
- printf(" --get-cropcap-output\n");
- printf(" query the crop capabilities for video output [VIDIOC_CROPCAP]\n");
- printf(" --get-crop-output query the video output crop window [VIDIOC_G_CROP]\n");
- printf(" --set-crop-output=top=<x>,left=<y>,width=<w>,height=<h>\n");
- printf(" set the video output crop window [VIDIOC_S_CROP]\n");
- printf(" --get-cropcap-overlay\n");
- printf(" query the crop capabilities for video overlay [VIDIOC_CROPCAP]\n");
- printf(" --get-crop-overlay query the video overlay crop window [VIDIOC_G_CROP]\n");
- printf(" --set-crop-overlay=top=<x>,left=<y>,width=<w>,height=<h>\n");
- printf(" set the video overlay crop window [VIDIOC_S_CROP]\n");
- printf(" --get-cropcap-output-overlay\n");
- printf(" query the crop capabilities for video output overlays [VIDIOC_CROPCAP]\n");
- printf(" --get-crop-output-overlay\n");
- printf(" query the video output overlay crop window [VIDIOC_G_CROP]\n");
- printf(" --set-crop-output-overlay=top=<x>,left=<y>,width=<w>,height=<h>\n");
- printf(" set the video output overlay crop window [VIDIOC_S_CROP]\n");
- printf(" --get-audio-input query the audio input [VIDIOC_G_AUDIO]\n");
- printf(" --set-audio-input=<num>\n");
- printf(" set the audio input to <num> [VIDIOC_S_AUDIO]\n");
- printf(" --get-audio-output query the audio output [VIDIOC_G_AUDOUT]\n");
- printf(" --set-audio-output=<num>\n");
- printf(" set the audio output to <num> [VIDIOC_S_AUDOUT]\n");
- printf(" --list-audio-outputs\n");
- printf(" display audio outputs [VIDIOC_ENUMAUDOUT]\n");
- printf(" --list-audio-inputs\n");
- printf(" display audio inputs [VIDIOC_ENUMAUDIO]\n");
- printf("\n");
- printf("Expert options:\n");
- printf(" --streamoff turn the stream off [VIDIOC_STREAMOFF]\n");
- printf(" --streamon turn the stream on [VIDIOC_STREAMOFF]\n");
- printf(" --log-status log the board status in the kernel log [VIDIOC_LOG_STATUS]\n");
+ printf("Common options:\n"
+ " --all display all information available\n"
+ " -B, --get-fmt-sliced-vbi\n"
+ " query the sliced VBI capture format [VIDIOC_G_FMT]\n"
+ " -b, --set-fmt-sliced-vbi=<mode>\n"
+ " set the sliced VBI capture format to <mode> [VIDIOC_S_FMT]\n"
+ " <mode> is a comma separated list of:\n"
+ " off: turn off sliced VBI (cannot be combined with other modes)\n"
+ " teletext: teletext (PAL/SECAM)\n"
+ " cc: closed caption (NTSC)\n"
+ " wss: widescreen signal (PAL/SECAM)\n"
+ " vps: VPS (PAL/SECAM)\n"
+ " -C, --get-ctrl=<ctrl>[,<ctrl>...]\n"
+ " get the value of the controls [VIDIOC_G_EXT_CTRLS]\n"
+ " -c, --set-ctrl=<ctrl>=<val>[,<ctrl>=<val>...]\n"
+ " set the controls to the values specified [VIDIOC_S_EXT_CTRLS]\n"
+ " -D, --info show driver info [VIDIOC_QUERYCAP]\n"
+ " -d, --device=<dev> use device <dev> instead of /dev/video0\n"
+ " if <dev> is a single digit, then /dev/video<dev> is used\n"
+ " -F, --get-freq query the frequency [VIDIOC_G_FREQUENCY]\n"
+ " -f, --set-freq=<freq>\n"
+ " set the frequency to <freq> MHz [VIDIOC_S_FREQUENCY]\n"
+ " -h, --help display this help message\n"
+ " -I, --get-input query the video input [VIDIOC_G_INPUT]\n"
+ " -i, --set-input=<num>\n"
+ " set the video input to <num> [VIDIOC_S_INPUT]\n"
+ " -l, --list-ctrls display all controls and their values [VIDIOC_QUERYCTRL]\n"
+ " -L, --list-ctrls-menus\n"
+ " display all controls, their values and the menus [VIDIOC_QUERYMENU]\n"
+ " -N, --list-outputs display video outputs [VIDIOC_ENUMOUTPUT]\n"
+ " -n, --list-inputs display video inputs [VIDIOC_ENUMINPUT]\n"
+ " -O, --get-output query the video output [VIDIOC_G_OUTPUT]\n"
+ " -o, --set-output=<num>\n"
+ " set the video output to <num> [VIDIOC_S_OUTPUT]\n"
+ " -S, --get-standard\n"
+ " query the video standard [VIDIOC_G_STD]\n"
+ " -s, --set-standard=<num>\n"
+ " set the video standard to <num> [VIDIOC_S_STD]\n"
+ " <num> can be a numerical v4l2_std value, or it can be one of:\n"
+ " pal-X (X = B/G/H/N/Nc/I/D/K/M/60) or just 'pal' (V4L2_STD_PAL)\n"
+ " 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"
+ " -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"
+ " Possible values: mono, stereo, lang2, lang1, bilingual\n"
+ " --list-formats display supported video formats [VIDIOC_ENUM_FMT]\n"
+ " -V, --get-fmt-video\n"
+ " query the video capture format [VIDIOC_G_FMT]\n"
+ " -v, --set-fmt-video=width=<w>,height=<h>,pixelformat=<f>\n"
+ " set the video capture format [VIDIOC_S_FMT]\n"
+ " pixelformat is either the format index as reported by\n"
+ " --list-formats, or the fourcc value as a string\n"
+ " --verbose turn on verbose ioctl error reporting.\n"
+ "\n");
+ printf("Uncommon options:\n"
+ " --get-fmt-video-out\n"
+ " query the video output format [VIDIOC_G_FMT]\n"
+ " --set-fmt-video-out=width=<w>,height=<h>\n"
+ " set the video output format [VIDIOC_S_FMT]\n"
+ " --get-fmt-overlay\n"
+ " query the video overlay format [VIDIOC_G_FMT]\n"
+ " --get-fmt-output-overlay\n"
+ " query the video output overlay format [VIDIOC_G_FMT]\n"
+ " --set-fmt-output-overlay=chromakey=<key>,global_alpha=<alpha>\n"
+ " set the video output overlay format [VIDIOC_S_FMT]\n"
+ " --get-sliced-vbi-cap\n"
+ " query the sliced VBI capture capabilities [VIDIOC_G_SLICED_VBI_CAP]\n"
+ " --get-sliced-vbi-out-cap\n"
+ " query the sliced VBI output capabilities [VIDIOC_G_SLICED_VBI_CAP]\n"
+ " --get-fmt-sliced-vbi-out\n"
+ " query the sliced VBI output format [VIDIOC_G_FMT]\n"
+ " --set-fmt-sliced-vbi-out=<mode>\n"
+ " set the sliced VBI output format to <mode> [VIDIOC_S_FMT]\n"
+ " <mode> is a comma separated list of:\n"
+ " off: turn off sliced VBI (cannot be combined with other modes)\n"
+ " teletext: teletext (PAL/SECAM)\n"
+ " cc: closed caption (NTSC)\n"
+ " wss: widescreen signal (PAL/SECAM)\n"
+ " vps: VPS (PAL/SECAM)\n"
+ " --get-fmt-vbi query the VBI capture format [VIDIOC_G_FMT]\n"
+ " --get-fmt-vbi-out query the VBI output format [VIDIOC_G_FMT]\n"
+ " --overlay=<on> turn overlay on (1) or off (0) (VIDIOC_OVERLAY)\n"
+ " --get-fbuf query the overlay framebuffer data [VIDIOC_G_FBUF]\n"
+ " --set-fbuf=chromakey=<0/1>,global_alpha=<0/1>,local_alpha=<0/1>,local_inv_alpha=<0/1>\n"
+ " set the overlay framebuffer [VIDIOC_S_FBUF]\n"
+ " --get-cropcap query the crop capabilities [VIDIOC_CROPCAP]\n"
+ " --get-crop query the video capture crop window [VIDIOC_G_CROP]\n"
+ " --set-crop=top=<x>,left=<y>,width=<w>,height=<h>\n"
+ " set the video capture crop window [VIDIOC_S_CROP]\n"
+ " --get-cropcap-output\n"
+ " query the crop capabilities for video output [VIDIOC_CROPCAP]\n"
+ " --get-crop-output query the video output crop window [VIDIOC_G_CROP]\n"
+ " --set-crop-output=top=<x>,left=<y>,width=<w>,height=<h>\n"
+ " set the video output crop window [VIDIOC_S_CROP]\n"
+ " --get-cropcap-overlay\n"
+ " query the crop capabilities for video overlay [VIDIOC_CROPCAP]\n"
+ " --get-crop-overlay query the video overlay crop window [VIDIOC_G_CROP]\n"
+ " --set-crop-overlay=top=<x>,left=<y>,width=<w>,height=<h>\n"
+ " set the video overlay crop window [VIDIOC_S_CROP]\n"
+ " --get-cropcap-output-overlay\n"
+ " query the crop capabilities for video output overlays [VIDIOC_CROPCAP]\n"
+ " --get-crop-output-overlay\n"
+ " query the video output overlay crop window [VIDIOC_G_CROP]\n"
+ " --set-crop-output-overlay=top=<x>,left=<y>,width=<w>,height=<h>\n"
+ " set the video output overlay crop window [VIDIOC_S_CROP]\n"
+ " --get-audio-input query the audio input [VIDIOC_G_AUDIO]\n"
+ " --set-audio-input=<num>\n"
+ " set the audio input to <num> [VIDIOC_S_AUDIO]\n"
+ " --get-audio-output query the audio output [VIDIOC_G_AUDOUT]\n"
+ " --set-audio-output=<num>\n"
+ " set the audio output to <num> [VIDIOC_S_AUDOUT]\n"
+ " --list-audio-outputs\n"
+ " display audio outputs [VIDIOC_ENUMAUDOUT]\n"
+ " --list-audio-inputs\n"
+ " display audio inputs [VIDIOC_ENUMAUDIO]\n"
+ "\n");
+ printf("Expert options:\n"
+ " --streamoff turn the stream off [VIDIOC_STREAMOFF]\n"
+ " --streamon turn the stream on [VIDIOC_STREAMOFF]\n"
+ " --log-status log the board status in the kernel log [VIDIOC_LOG_STATUS]\n");
exit(0);
}
@@ -634,13 +637,17 @@ static void find_controls(int fd)
for (id = V4L2_CID_USER_BASE; id < V4L2_CID_LASTP1; id++) {
qctrl.id = id;
if (ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0 &&
- !(qctrl.flags & V4L2_CTRL_FLAG_DISABLED))
+ !(qctrl.flags & V4L2_CTRL_FLAG_DISABLED)) {
ctrl_str2id[name2var(qctrl.name)] = qctrl.id;
+ ctrl_id2str[qctrl.id] = name2var(qctrl.name);
+ }
}
for (qctrl.id = V4L2_CID_PRIVATE_BASE;
ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0; qctrl.id++) {
- if (!(qctrl.flags & V4L2_CTRL_FLAG_DISABLED))
+ if (!(qctrl.flags & V4L2_CTRL_FLAG_DISABLED)) {
ctrl_str2id[name2var(qctrl.name)] = qctrl.id;
+ ctrl_id2str[qctrl.id] = name2var(qctrl.name);
+ }
}
}
@@ -697,7 +704,7 @@ static void printfbuf(const struct v4l2_framebuffer &fb)
printf("\tBase : 0x%p\n", fb.base);
printf("\tWidth : %d\n", fb.fmt.width);
printf("\tHeight : %d\n", fb.fmt.height);
- printf("\tPixel Format : %s\n", fcc2s(fb.fmt.pixelformat).c_str());
+ printf("\tPixel Format : '%s'\n", fcc2s(fb.fmt.pixelformat).c_str());
if (!is_ext) {
printf("\tBytes per Line: %d\n", fb.fmt.bytesperline);
printf("\tSize image : %d\n", fb.fmt.sizeimage);
@@ -736,7 +743,7 @@ static void printfmt(struct v4l2_format vfmt)
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
printf("\tWidth/Height : %u/%u\n", vfmt.fmt.pix.width, vfmt.fmt.pix.height);
- printf("\tPixel Format : %s\n", fcc2s(vfmt.fmt.pix.pixelformat).c_str());
+ printf("\tPixel Format : '%s'\n", fcc2s(vfmt.fmt.pix.pixelformat).c_str());
printf("\tField : %s\n", field2s(vfmt.fmt.pix.field).c_str());
printf("\tBytes per Line: %u\n", vfmt.fmt.pix.bytesperline);
printf("\tSize Image : %u\n", vfmt.fmt.pix.sizeimage);
@@ -794,8 +801,9 @@ static void print_video_formats(int fd, enum v4l2_buf_type type)
fmt.index = 0;
fmt.type = type;
while (ioctl(fd, VIDIOC_ENUM_FMT, &fmt) >= 0) {
+ printf("\tIndex : %d\n", fmt.index);
printf("\tType : %s\n", buftype2s(type).c_str());
- printf("\tPixelformat : %s", fcc2s(fmt.pixelformat).c_str());
+ printf("\tPixel Format: '%s'", fcc2s(fmt.pixelformat).c_str());
if (fmt.flags)
printf(" (compressed)");
printf("\n");
@@ -1019,9 +1027,9 @@ static int doioctl(int fd, int request, void *parm, const char *name)
return retVal;
}
-static int parse_subopt(char **subs, char * const *subopts, char **value)
+static int parse_subopt(char **subs, const char * const *subopts, char **value)
{
- int opt = getsubopt(subs, subopts, value);
+ int opt = getsubopt(subs, (char * const *)subopts, value);
if (opt == -1) {
fprintf(stderr, "Invalid suboptions specified\n");
@@ -1094,7 +1102,7 @@ static void parse_crop(char *optarg, unsigned int &set_crop, v4l2_rect &vcrop)
char *subs = optarg;
while (*subs != '\0') {
- static char *const subopts[] = {
+ static const char *const subopts[] = {
"left",
"top",
"width",
@@ -1144,7 +1152,7 @@ int main(int argc, char **argv)
/* command args */
int ch;
- char *device = strdup("/dev/video0"); /* -d device */
+ const char *device = "/dev/video0"; /* -d device */
struct v4l2_format vfmt; /* set_format/get_format for video */
struct v4l2_format vfmt_out; /* set_format/get_format video output */
struct v4l2_format vbi_fmt; /* set_format/get_format for sliced VBI */
@@ -1220,19 +1228,22 @@ int main(int argc, char **argv)
usage();
return 0;
case OptSetDevice:
- device = strdup(optarg);
+ device = optarg;
if (device[0] >= '0' && device[0] <= '9' && device[1] == 0) {
+ static char newdev[20];
char dev = device[0];
- sprintf(device, "/dev/video%c", dev);
+ sprintf(newdev, "/dev/video%c", dev);
+ device = newdev;
}
break;
case OptSetVideoFormat:
subs = optarg;
while (*subs != '\0') {
- static char *const subopts[] = {
+ static const char *const subopts[] = {
"width",
"height",
+ "pixelformat",
NULL
};
@@ -1245,13 +1256,22 @@ int main(int argc, char **argv)
vfmt.fmt.pix.height = strtol(value, 0L, 0);
set_fmts |= FmtHeight;
break;
+ case 2:
+ if (strlen(value) == 4)
+ vfmt.fmt.pix.pixelformat =
+ v4l2_fourcc(value[0], value[1],
+ value[2], value[3]);
+ else
+ vfmt.fmt.pix.pixelformat = strtol(value, 0L, 0);
+ set_fmts |= FmtPixelFormat;
+ break;
}
}
break;
case OptSetVideoOutFormat:
subs = optarg;
while (*subs != '\0') {
- static char *const subopts[] = {
+ static const char *const subopts[] = {
"width",
"height",
NULL
@@ -1272,7 +1292,7 @@ int main(int argc, char **argv)
case OptSetOutputOverlayFormat:
subs = optarg;
while (*subs != '\0') {
- static char *const subopts[] = {
+ static const char *const subopts[] = {
"chromakey",
"global_alpha",
NULL
@@ -1293,7 +1313,7 @@ int main(int argc, char **argv)
case OptSetFBuf:
subs = optarg;
while (*subs != '\0') {
- static char *const subopts[] = {
+ static const char *const subopts[] = {
"chromakey",
"global_alpha",
"local_alpha",
@@ -1428,7 +1448,7 @@ int main(int argc, char **argv)
fmt->fmt.sliced.service_set = 0;
subs = optarg;
while (*subs != '\0') {
- static char *const subopts[] = {
+ static const char *const subopts[] = {
"off",
"teletext",
"cc",
@@ -1492,7 +1512,6 @@ int main(int argc, char **argv)
strerror(errno));
exit(1);
}
- free(device);
doioctl(fd, VIDIOC_QUERYCAP, &vcap, "VIDIOC_QUERYCAP");
capabilities = vcap.capabilities;
@@ -1622,9 +1641,22 @@ int main(int argc, char **argv)
in_vfmt.fmt.pix.width = vfmt.fmt.pix.width;
if (set_fmts & FmtHeight)
in_vfmt.fmt.pix.height = vfmt.fmt.pix.height;
+ if (set_fmts & FmtPixelFormat) {
+ in_vfmt.fmt.pix.pixelformat = vfmt.fmt.pix.pixelformat;
+ if (in_vfmt.fmt.pix.pixelformat < 256) {
+ struct v4l2_fmtdesc fmt;
+
+ fmt.index = in_vfmt.fmt.pix.pixelformat;
+ fmt.type = in_vfmt.type;
+ if (doioctl(fd, VIDIOC_ENUM_FMT, &fmt, "VIDIOC_ENUM_FMT"))
+ goto set_vid_fmt_error;
+ in_vfmt.fmt.pix.pixelformat = fmt.pixelformat;
+ }
+ }
doioctl(fd, VIDIOC_S_FMT, &in_vfmt, "VIDIOC_S_FMT");
}
}
+set_vid_fmt_error:
if (options[OptSetVideoOutFormat]) {
struct v4l2_format in_vfmt;
@@ -1992,6 +2024,7 @@ int main(int argc, char **argv)
memset(&vt, 0, sizeof(struct v4l2_tuner));
if (doioctl(fd, VIDIOC_G_TUNER, &vt, "VIDIOC_G_TUNER") == 0) {
printf("Tuner:\n");
+ printf("\tName : %s\n", vt.name);
printf("\tCapabilities : %s\n", tcap2s(vt.capability).c_str());
if (vt.capability & V4L2_TUNER_CAP_LOW)
printf("\tFrequency range : %.1f MHz - %.1f MHz\n",
@@ -1999,7 +2032,7 @@ int main(int argc, char **argv)
else
printf("\tFrequency range : %.1f MHz - %.1f MHz\n",
vt.rangelow / 16.0, vt.rangehigh / 16.0);
- printf("\tSignal strength : %d%%\n", (int)(vt.signal / 655.35));
+ printf("\tSignal strength/AFC : %d%%/%d\n", (int)(vt.signal / 655.35), vt.afc);
printf("\tCurrent audio mode : %s\n", audmode2s(vt.audmode));
printf("\tAvailable subchannels: %s\n",
rxsubchans2s(vt.rxsubchans).c_str());
@@ -2113,7 +2146,7 @@ int main(int argc, char **argv)
while (ioctl(fd, VIDIOC_ENUMSTD, &vs) >= 0) {
if (vs.index)
printf("\n");
- printf("\tindex : %d\n", vs.index);
+ printf("\tIndex : %d\n", vs.index);
printf("\tID : 0x%016llX\n", (unsigned long long)vs.id);
printf("\tName : %s\n", vs.name);
printf("\tFrame period: %d/%d\n",