summaryrefslogtreecommitdiff
path: root/v4l2-apps
diff options
context:
space:
mode:
Diffstat (limited to 'v4l2-apps')
-rw-r--r--v4l2-apps/util/ivtv-ctl.c56
-rw-r--r--v4l2-apps/util/v4l2-ctl.cpp111
2 files changed, 94 insertions, 73 deletions
diff --git a/v4l2-apps/util/ivtv-ctl.c b/v4l2-apps/util/ivtv-ctl.c
index 9d9808890..9d3170785 100644
--- a/v4l2-apps/util/ivtv-ctl.c
+++ b/v4l2-apps/util/ivtv-ctl.c
@@ -39,6 +39,7 @@
#include <linux/videodev2.h>
#include <linux/dvb/video.h>
+#include <linux/dvb/audio.h>
/* copied from ivtv-driver.h */
#define IVTV_DBGFLG_WARN (1 << 0)
@@ -84,11 +85,16 @@ enum Option {
OptReset = 128,
OptSetYuvMode,
OptGetYuvMode,
+ OptSetAudioMute,
+ OptSetStereoMode,
+ OptSetBilingualMode,
OptLast = 256
};
static char options[OptLast];
+static int app_result;
+
static struct option long_options[] = {
/* Please keep in alphabetical order of the short option.
That makes it easier to see which options are still free. */
@@ -104,6 +110,9 @@ static struct option long_options[] = {
{"reset", required_argument, 0, OptReset},
{"get-yuv-mode", no_argument, 0, OptGetYuvMode},
{"set-yuv-mode", required_argument, 0, OptSetYuvMode},
+ {"set-audio-mute", required_argument, 0, OptSetAudioMute},
+ {"set-stereo-mode", required_argument, 0, OptSetStereoMode},
+ {"set-bilingual-mode", required_argument, 0, OptSetBilingualMode},
{0, 0, 0, 0}
};
@@ -121,6 +130,21 @@ static void usage(void)
printf(" mode 1: interlaced (bottom transmitted first)\n");
printf(" mode 2: progressive\n");
printf(" mode 3: auto\n");
+ printf(" --set-audio-mute <mute>\n");
+ printf(" 0=enable audio during 1.5x and 0.5x playback\n");
+ printf(" 1=mute audio during 1.5x and 0.5x playback\n");
+ printf(" --set-stereo-mode <mode>\n");
+ printf(" mode 0: playback stereo as stereo\n");
+ printf(" mode 1: playback left stereo channel as mono\n");
+ printf(" mode 2: playback right stereo channel as mono\n");
+ printf(" mode 3: playback stereo as mono\n");
+ printf(" mode 4: playback stereo as swapped stereo\n");
+ printf(" --set-bilingual-mode <mode>\n");
+ printf(" mode 0: playback bilingual as stereo\n");
+ printf(" mode 1: playback left bilingual channel as mono\n");
+ printf(" mode 2: playback right bilingual channel as mono\n");
+ printf(" mode 3: playback bilingual as mono\n");
+ printf(" mode 4: playback bilingual as swapped stereo\n");
printf(" --reset <mask> reset the infrared receiver (1) or digitizer (2) [VIDIOC_INT_RESET]\n");
printf("\n");
printf("Expert options:\n");
@@ -285,8 +309,10 @@ static int doioctl(int fd, int request, void *parm, const char *name)
printf("ioctl %s ", name);
retVal = ioctl(fd, request, parm);
- if (retVal < 0)
+ if (retVal < 0) {
+ app_result = -1;
printf("failed: %s\n", strerror(errno));
+ }
else
printf("ok\n");
@@ -325,6 +351,9 @@ int main(int argc, char **argv)
unsigned short gpio_dir = 0x0; /* GPIO direction bits */
int gpio_set_dir = 0;
int passthrough = 0;
+ int audio_mute = 0;
+ int stereo_mode = 0;
+ int bilingual_mode = 0;
int debug_level = 0;
__u32 reset = 0;
int new_debug_level, gdebug_level;
@@ -427,6 +456,15 @@ int main(int argc, char **argv)
case OptPassThrough:
passthrough = strtol(optarg, 0L, 0);
break;
+ case OptSetAudioMute:
+ audio_mute = strtol(optarg, 0L, 0);
+ break;
+ case OptSetStereoMode:
+ stereo_mode = strtol(optarg, 0L, 0);
+ break;
+ case OptSetBilingualMode:
+ bilingual_mode = strtol(optarg, 0L, 0);
+ break;
case OptSetGPIO:
subs = optarg;
while (*subs != '\0') {
@@ -588,6 +626,20 @@ int main(int argc, char **argv)
"IVTV_IOC_PASSTHROUGH");
}
+ if (options[OptSetAudioMute]) {
+ doioctl(fd, AUDIO_SET_MUTE, (void *)audio_mute, "AUDIO_SET_MUTE");
+ }
+
+ if (options[OptSetStereoMode]) {
+ doioctl(fd, AUDIO_CHANNEL_SELECT,
+ (void *)stereo_mode, "AUDIO_CHANNEL_SELECT");
+ }
+
+ if (options[OptSetBilingualMode]) {
+ doioctl(fd, AUDIO_BILINGUAL_CHANNEL_SELECT,
+ (void *)bilingual_mode, "AUDIO_BILINGUAL_CHANNEL_SELECT");
+ }
+
if (options[OptReset])
doioctl(fd, VIDIOC_INT_RESET, &reset, "VIDIOC_INT_RESET");
@@ -631,5 +683,5 @@ int main(int argc, char **argv)
}
close(fd);
- exit(0);
+ exit(app_result);
}
diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp
index 198118ac6..d637e34d7 100644
--- a/v4l2-apps/util/v4l2-ctl.cpp
+++ b/v4l2-apps/util/v4l2-ctl.cpp
@@ -123,6 +123,8 @@ enum Option {
static char options[OptLast];
+static int app_result;
+
static unsigned capabilities;
typedef std::vector<struct v4l2_ext_control> ctrl_list;
@@ -715,7 +717,7 @@ static void printcropcap(const struct v4l2_cropcap &cropcap)
printf("\tPixel Aspect: %u/%u\n", cropcap.pixelaspect.numerator, cropcap.pixelaspect.denominator);
}
-static int printfmt(struct v4l2_format vfmt)
+static void printfmt(struct v4l2_format vfmt)
{
const flag_def vbi_def[] = {
{ V4L2_VBI_UNSYNC, "unsynchronized" },
@@ -776,10 +778,7 @@ static int printfmt(struct v4l2_format vfmt)
break;
case V4L2_BUF_TYPE_PRIVATE:
break;
- default:
- return -1;
}
- return 0;
}
static void print_video_formats(int fd, enum v4l2_buf_type type)
@@ -999,10 +998,12 @@ static v4l2_std_id parse_ntsc(const char *ntsc)
static int doioctl(int fd, int request, void *parm, const char *name)
{
- int retVal;
+ int retVal = ioctl(fd, request, parm);
- if (!options[OptVerbose]) return ioctl(fd, request, parm);
- retVal = ioctl(fd, request, parm);
+ if (retVal < 0) {
+ app_result = -1;
+ }
+ if (!options[OptVerbose]) return retVal;
printf("%s: ", name);
if (retVal < 0)
printf("failed: %s\n", strerror(errno));
@@ -1068,9 +1069,7 @@ static void do_crop(int fd, unsigned int set_crop, struct v4l2_rect &vcrop, v4l2
struct v4l2_crop in_crop;
in_crop.type = type;
- if (ioctl(fd, VIDIOC_G_CROP, &in_crop) < 0)
- fprintf(stderr, "ioctl: VIDIOC_G_CROP failed\n");
- else {
+ if (doioctl(fd, VIDIOC_G_CROP, &in_crop, "VIDIOC_G_CROP") == 0) {
if (set_crop & CropWidth)
in_crop.c.width = vcrop.width;
if (set_crop & CropHeight)
@@ -1079,8 +1078,7 @@ static void do_crop(int fd, unsigned int set_crop, struct v4l2_rect &vcrop, v4l2
in_crop.c.left = vcrop.left;
if (set_crop & CropTop)
in_crop.c.top = vcrop.top;
- if (ioctl(fd, VIDIOC_S_CROP, &in_crop) < 0)
- fprintf(stderr, "ioctl: VIDIOC_S_CROP failed\n");
+ doioctl(fd, VIDIOC_S_CROP, &in_crop, "VIDIOC_S_CROP");
}
}
@@ -1603,43 +1601,35 @@ int main(int argc, char **argv)
struct v4l2_tuner vt;
memset(&vt, 0, sizeof(struct v4l2_tuner));
- if (ioctl(fd, VIDIOC_G_TUNER, &vt) < 0) {
- fprintf(stderr, "ioctl: VIDIOC_G_TUNER failed\n");
- exit(1);
+ if (doioctl(fd, VIDIOC_G_TUNER, &vt, "VIDIOC_G_TUNER") == 0) {
+ vt.audmode = mode;
+ doioctl(fd, VIDIOC_S_TUNER, &vt, "VIDIOC_S_TUNER");
}
- vt.audmode = mode;
- doioctl(fd, VIDIOC_S_TUNER, &vt, "VIDIOC_S_TUNER");
}
if (options[OptSetVideoFormat]) {
struct v4l2_format in_vfmt;
- printf("ioctl: VIDIOC_S_FMT\n");
+
in_vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(fd, VIDIOC_G_FMT, &in_vfmt) < 0)
- fprintf(stderr, "ioctl: VIDIOC_G_FMT failed\n");
- else {
+ if (doioctl(fd, VIDIOC_G_FMT, &in_vfmt, "VIDIOC_G_FMT") == 0) {
if (set_fmts & FmtWidth)
in_vfmt.fmt.pix.width = vfmt.fmt.pix.width;
if (set_fmts & FmtHeight)
in_vfmt.fmt.pix.height = vfmt.fmt.pix.height;
- if (ioctl(fd, VIDIOC_S_FMT, &in_vfmt) < 0)
- fprintf(stderr, "ioctl: VIDIOC_S_FMT failed\n");
+ doioctl(fd, VIDIOC_S_FMT, &in_vfmt, "VIDIOC_S_FMT");
}
}
if (options[OptSetVideoOutFormat]) {
struct v4l2_format in_vfmt;
- printf("ioctl: VIDIOC_S_FMT\n");
+
in_vfmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
- if (ioctl(fd, VIDIOC_G_FMT, &in_vfmt) < 0)
- fprintf(stderr, "ioctl: VIDIOC_G_FMT failed\n");
- else {
+ if (doioctl(fd, VIDIOC_G_FMT, &in_vfmt, "VIDIOC_G_FMT") == 0) {
if (set_fmts_out & FmtWidth)
in_vfmt.fmt.pix.width = vfmt_out.fmt.pix.width;
if (set_fmts_out & FmtHeight)
in_vfmt.fmt.pix.height = vfmt_out.fmt.pix.height;
- if (ioctl(fd, VIDIOC_S_FMT, &in_vfmt) < 0)
- fprintf(stderr, "ioctl: VIDIOC_S_FMT failed\n");
+ doioctl(fd, VIDIOC_S_FMT, &in_vfmt, "VIDIOC_S_FMT");
}
}
@@ -1669,29 +1659,24 @@ int main(int argc, char **argv)
if (options[OptSetOutputOverlayFormat]) {
struct v4l2_format fmt;
- memset(&fmt, 0, sizeof(fmt));
+
fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY;
- if (ioctl(fd, VIDIOC_G_FMT, &fmt, "VIDIOC_G_FMT") < 0)
- fprintf(stderr, "ioctl: VIDIOC_G_FMT failed\n");
- else {
+ if (doioctl(fd, VIDIOC_G_FMT, &fmt, "VIDIOC_G_FMT") == 0) {
if (set_overlay_fmt_out & FmtChromaKey)
fmt.fmt.win.chromakey = overlay_fmt_out.fmt.win.chromakey;
if (set_overlay_fmt_out & FmtGlobalAlpha)
fmt.fmt.win.global_alpha = overlay_fmt_out.fmt.win.global_alpha;
- if (ioctl(fd, VIDIOC_S_FMT, &fmt, "VIDIOC_S_FMT") < 0)
- fprintf(stderr, "ioctl: VIDIOC_S_FMT failed\n");
+ doioctl(fd, VIDIOC_S_FMT, &fmt, "VIDIOC_S_FMT");
}
}
if (options[OptSetFBuf]) {
struct v4l2_framebuffer fb;
- if (ioctl(fd, VIDIOC_G_FBUF, &fb, "VIDIOC_G_FBUF") < 0)
- fprintf(stderr, "ioctl: VIDIOC_G_FBUF failed\n");
- else {
+
+ if (doioctl(fd, VIDIOC_G_FBUF, &fb, "VIDIOC_G_FBUF") == 0) {
fb.flags &= ~set_fbuf;
fb.flags |= fbuf.flags;
- if (ioctl(fd, VIDIOC_S_FBUF, &fb) < 0)
- fprintf(stderr, "ioctl: VIDIOC_S_FBUF failed\n");
+ doioctl(fd, VIDIOC_S_FBUF, &fb, "VIDIOC_S_FBUF");
}
}
@@ -1763,69 +1748,53 @@ int main(int argc, char **argv)
if (options[OptGetVideoFormat]) {
vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (doioctl(fd, VIDIOC_G_FMT, &vfmt, "VIDIOC_G_FMT") == 0)
- if (printfmt(vfmt) != 0)
- fprintf(stderr, "error printing result\n");
+ printfmt(vfmt);
}
if (options[OptGetVideoOutFormat]) {
vfmt_out.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
if (doioctl(fd, VIDIOC_G_FMT, &vfmt_out, "VIDIOC_G_FMT") == 0)
- if (printfmt(vfmt_out) != 0)
- fprintf(stderr, "error printing result\n");
+ printfmt(vfmt_out);
}
if (options[OptGetOverlayFormat]) {
struct v4l2_format fmt;
- memset(&fmt, 0, sizeof(fmt));
+
fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
if (doioctl(fd, VIDIOC_G_FMT, &fmt, "VIDIOC_G_FMT") == 0)
- if (printfmt(fmt) != 0)
- fprintf(stderr, "error printing result\n");
+ printfmt(fmt);
}
if (options[OptGetOutputOverlayFormat]) {
struct v4l2_format fmt;
- memset(&fmt, 0, sizeof(fmt));
+
fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY;
if (doioctl(fd, VIDIOC_G_FMT, &fmt, "VIDIOC_G_FMT") == 0)
- if (printfmt(fmt) != 0)
- fprintf(stderr, "error printing result\n");
+ printfmt(fmt);
}
if (options[OptGetSlicedVbiFormat]) {
vbi_fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
- if (doioctl(fd, VIDIOC_G_FMT, &vbi_fmt,
- "VIDIOC_G_FMT") == 0)
- if (printfmt(vbi_fmt) != 0)
- fprintf(stderr,
- "error printing result\n");
+ if (doioctl(fd, VIDIOC_G_FMT, &vbi_fmt, "VIDIOC_G_FMT") == 0)
+ printfmt(vbi_fmt);
}
if (options[OptGetSlicedVbiOutFormat]) {
vbi_fmt_out.type = V4L2_BUF_TYPE_SLICED_VBI_OUTPUT;
- if (doioctl(fd, VIDIOC_G_FMT, &vbi_fmt_out,
- "VIDIOC_G_FMT") == 0)
- if (printfmt(vbi_fmt_out) != 0)
- fprintf(stderr,
- "error printing result\n");
+ if (doioctl(fd, VIDIOC_G_FMT, &vbi_fmt_out, "VIDIOC_G_FMT") == 0)
+ printfmt(vbi_fmt_out);
}
if (options[OptGetVbiFormat]) {
raw_fmt.type = V4L2_BUF_TYPE_VBI_CAPTURE;
- if (doioctl(fd, VIDIOC_G_FMT, &raw_fmt,
- "VIDIOC_G_FMT") == 0)
- if (printfmt(raw_fmt) != 0)
- fprintf(stderr,
- "error printing result\n");
+ if (doioctl(fd, VIDIOC_G_FMT, &raw_fmt, "VIDIOC_G_FMT") == 0)
+ printfmt(raw_fmt);
}
if (options[OptGetVbiOutFormat]) {
raw_fmt_out.type = V4L2_BUF_TYPE_VBI_OUTPUT;
- if (doioctl(fd, VIDIOC_G_FMT, &raw_fmt_out,
- "VIDIOC_G_FMT") == 0)
- if (printfmt(raw_fmt_out) != 0)
- fprintf(stderr,
- "error printing result\n");
+ if (doioctl(fd, VIDIOC_G_FMT, &raw_fmt_out, "VIDIOC_G_FMT") == 0)
+ printfmt(raw_fmt_out);
}
if (options[OptGetFBuf]) {
@@ -2188,5 +2157,5 @@ int main(int argc, char **argv)
}
close(fd);
- exit(0);
+ exit(app_result);
}