summaryrefslogtreecommitdiff
path: root/v4l2-apps/util/v4l2-ctl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'v4l2-apps/util/v4l2-ctl.cpp')
-rw-r--r--v4l2-apps/util/v4l2-ctl.cpp380
1 files changed, 254 insertions, 126 deletions
diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp
index 35d9f466b..cc6819971 100644
--- a/v4l2-apps/util/v4l2-ctl.cpp
+++ b/v4l2-apps/util/v4l2-ctl.cpp
@@ -99,14 +99,24 @@ enum Option {
OptGetSlicedVbiOutCap,
OptGetFBuf,
OptSetFBuf,
- OptGetVideoCrop,
- OptSetVideoCrop,
+ OptGetCrop,
+ OptSetCrop,
+ OptGetOutputCrop,
+ OptSetOutputCrop,
+ OptGetOverlayCrop,
+ OptSetOverlayCrop,
+ OptGetOutputOverlayCrop,
+ OptSetOutputOverlayCrop,
OptGetAudioInput,
OptSetAudioInput,
OptGetAudioOutput,
OptSetAudioOutput,
OptListAudioOutputs,
OptListAudioInputs,
+ OptGetCropCap,
+ OptGetOutputCropCap,
+ OptGetOverlayCropCap,
+ OptGetOutputOverlayCropCap,
OptLast = 256
};
@@ -143,12 +153,10 @@ static const flag_def service_def[] = {
};
/* fmts specified */
-#define FmtTop (1L<<0)
-#define FmtLeft (1L<<1)
-#define FmtWidth (1L<<2)
-#define FmtHeight (1L<<3)
-#define FmtChromaKey (1L<<4)
-#define FmtGlobalAlpha (1L<<5)
+#define FmtWidth (1L<<0)
+#define FmtHeight (1L<<1)
+#define FmtChromaKey (1L<<2)
+#define FmtGlobalAlpha (1L<<3)
/* crop specified */
#define CropWidth (1L<<0)
@@ -206,8 +214,18 @@ static struct option long_options[] = {
{"get-sliced-vbi-out-cap", no_argument, 0, OptGetSlicedVbiOutCap},
{"get-fbuf", no_argument, 0, OptGetFBuf},
{"set-fbuf", required_argument, 0, OptSetFBuf},
- {"get-crop-video", no_argument, 0, OptGetVideoCrop},
- {"set-crop-video", required_argument, 0, OptSetVideoCrop},
+ {"get-cropcap", no_argument, 0, OptGetCropCap},
+ {"get-crop", no_argument, 0, OptGetCrop},
+ {"set-crop", required_argument, 0, OptSetCrop},
+ {"get-cropcap-output", no_argument, 0, OptGetOutputCropCap},
+ {"get-crop-output", no_argument, 0, OptGetOutputCrop},
+ {"set-crop-output", required_argument, 0, OptSetOutputCrop},
+ {"get-cropcap-overlay", no_argument, 0, OptGetOverlayCropCap},
+ {"get-crop-overlay", no_argument, 0, OptGetOverlayCrop},
+ {"set-crop-overlay", required_argument, 0, OptSetOverlayCrop},
+ {"get-cropcap-output-overlay", no_argument, 0, OptGetOutputOverlayCropCap},
+ {"get-crop-output-overlay", no_argument, 0, OptGetOutputOverlayCrop},
+ {"set-crop-output-overlay", required_argument, 0, OptSetOutputOverlayCrop},
{0, 0, 0, 0}
};
@@ -275,7 +293,7 @@ static void usage(void)
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=left=<x>,top=<y>,width=<w>,height=<h>\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");
@@ -300,12 +318,29 @@ static void usage(void)
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(" --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>\n");
+ printf(" --set-fbuf=chromakey=<0/1>,global_alpha=<0/1>,local_alpha=<0/1>,\n");
+ printf(" global_inv_alpha=<0/1>,local_inv_alpha=<0/1>\n");
printf(" set the overlay framebuffer [VIDIOC_S_FBUF]\n");
- printf(" --get-crop-video\n");
- printf(" query the video capture crop window [VIDIOC_G_CROP]\n");
- printf(" --set-crop-video=top=<x>,left=<y>,width=<w>,height=<h>\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");
@@ -608,18 +643,22 @@ static std::string fbufcap2s(unsigned cap)
std::string s;
if (cap & V4L2_FBUF_CAP_EXTERNOVERLAY)
- s += "\t\tExtern Overlay\n";
+ s += "\t\t\tExtern Overlay\n";
if (cap & V4L2_FBUF_CAP_CHROMAKEY)
- s += "\t\tChromakey\n";
+ s += "\t\t\tChromakey\n";
if (cap & V4L2_FBUF_CAP_GLOBAL_ALPHA)
- s += "\t\tGlobal Alpha\n";
+ s += "\t\t\tGlobal Alpha\n";
if (cap & V4L2_FBUF_CAP_LOCAL_ALPHA)
- s += "\t\tLocal Alpha\n";
+ s += "\t\t\tLocal Alpha\n";
+ if (cap & V4L2_FBUF_CAP_GLOBAL_INV_ALPHA)
+ s += "\t\t\tGlobal Inverted Alpha\n";
+ if (cap & V4L2_FBUF_CAP_LOCAL_INV_ALPHA)
+ s += "\t\t\tLocal Inverted Alpha\n";
if (cap & V4L2_FBUF_CAP_LIST_CLIPPING)
- s += "\t\tClipping List\n";
+ s += "\t\t\tClipping List\n";
if (cap & V4L2_FBUF_CAP_BITMAP_CLIPPING)
- s += "\t\tClipping Bitmap\n";
- if (s.empty()) s += "\t\t\n";
+ s += "\t\t\tClipping Bitmap\n";
+ if (s.empty()) s += "\t\t\t\n";
return s;
}
@@ -628,16 +667,20 @@ static std::string fbufflags2s(unsigned fl)
std::string s;
if (fl & V4L2_FBUF_FLAG_PRIMARY)
- s += "\t\tPrimary Graphics Surface\n";
+ s += "\t\t\tPrimary Graphics Surface\n";
if (fl & V4L2_FBUF_FLAG_OVERLAY)
- s += "\t\tOverlay Matches Capture/Output Size\n";
+ s += "\t\t\tOverlay Matches Capture/Output Size\n";
if (fl & V4L2_FBUF_FLAG_CHROMAKEY)
- s += "\t\tChromakey\n";
+ s += "\t\t\tChromakey\n";
if (fl & V4L2_FBUF_FLAG_GLOBAL_ALPHA)
- s += "\t\tGlobal Alpha\n";
+ s += "\t\t\tGlobal Alpha\n";
if (fl & V4L2_FBUF_FLAG_LOCAL_ALPHA)
- s += "\t\tLocal Alpha\n";
- if (s.empty()) s += "\t\t\n";
+ s += "\t\t\tLocal Alpha\n";
+ if (fl & V4L2_FBUF_FLAG_GLOBAL_INV_ALPHA)
+ s += "\t\t\tGlobal Inverted Alpha\n";
+ if (fl & V4L2_FBUF_FLAG_LOCAL_INV_ALPHA)
+ s += "\t\t\tLocal Inverted Alpha\n";
+ if (s.empty()) s += "\t\t\t\n";
return s;
}
@@ -645,19 +688,20 @@ static void printfbuf(const struct v4l2_framebuffer &fb)
{
int is_ext = fb.capability & V4L2_FBUF_CAP_EXTERNOVERLAY;
- printf("Capability : %s", fbufcap2s(fb.capability).c_str() + 2);
- printf("Flags : %s", fbufflags2s(fb.flags).c_str() + 2);
+ printf("Framebuffer Format:\n");
+ printf("\tCapability : %s", fbufcap2s(fb.capability).c_str() + 3);
+ printf("\tFlags : %s", fbufflags2s(fb.flags).c_str() + 3);
if (fb.base)
- printf("Base : 0x%p\n", fb.base);
- printf("Width : %d\n", fb.fmt.width);
- printf("Height : %d\n", fb.fmt.height);
- printf("Pixel Format : %s\n", fcc2s(fb.fmt.pixelformat).c_str());
+ 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());
if (!is_ext) {
- printf("Bytes per Line: %d\n", fb.fmt.bytesperline);
- printf("Size image : %d\n", fb.fmt.sizeimage);
- printf("Colorspace : %s\n", colorspace2s(fb.fmt.colorspace).c_str());
+ printf("\tBytes per Line: %d\n", fb.fmt.bytesperline);
+ printf("\tSize image : %d\n", fb.fmt.sizeimage);
+ printf("\tColorspace : %s\n", colorspace2s(fb.fmt.colorspace).c_str());
if (fb.fmt.priv)
- printf("Custom Info : %08x\n", fb.fmt.priv);
+ printf("\tCustom Info : %08x\n", fb.fmt.priv);
}
}
@@ -667,6 +711,16 @@ static void printcrop(const struct v4l2_crop &crop)
crop.c.left, crop.c.top, crop.c.width, crop.c.height);
}
+static void printcropcap(const struct v4l2_cropcap &cropcap)
+{
+ printf("Crop Capability %s:\n", buftype2s(cropcap.type).c_str());
+ printf("\tBounds : Left %d, Top %d, Width %d, Height %d\n",
+ cropcap.bounds.left, cropcap.bounds.top, cropcap.bounds.width, cropcap.bounds.height);
+ printf("\tDefault : Left %d, Top %d, Width %d, Height %d\n",
+ cropcap.defrect.left, cropcap.defrect.top, cropcap.defrect.width, cropcap.defrect.height);
+ printf("\tPixel Aspect: %u/%u\n", cropcap.pixelaspect.numerator, cropcap.pixelaspect.denominator);
+}
+
static int printfmt(struct v4l2_format vfmt)
{
const flag_def vbi_def[] = {
@@ -674,32 +728,22 @@ static int printfmt(struct v4l2_format vfmt)
{ V4L2_VBI_INTERLACED, "interlaced" },
{ 0, NULL }
};
- printf("Format:\n");
+ printf("Format %s:\n", buftype2s(vfmt.type).c_str());
switch (vfmt.type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
- printf("\tType : %s\n", buftype2s(vfmt.type).c_str());
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("\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);
printf("\tColorspace : %s\n", colorspace2s(vfmt.fmt.pix.colorspace).c_str());
-#if 0
- /* Comment out until ABI breakage is resolved */
- if (vfmt.type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
- (capabilities & V4L2_CAP_VIDEO_OUTPUT_POS)) {
- printf("\tLeft/Top : %d/%d\n",
- vfmt.fmt.pix.left, vfmt.fmt.pix.top);
- }
-#endif
if (vfmt.fmt.pix.priv)
printf("\tCustom Info : %08x\n", vfmt.fmt.pix.priv);
break;
case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
- printf("\tType : %s\n", buftype2s(vfmt.type).c_str());
printf("\tLeft/Top : %d/%d\n",
vfmt.fmt.win.w.left, vfmt.fmt.win.w.top);
printf("\tWidth/Height: %d/%d\n",
@@ -712,7 +756,6 @@ static int printfmt(struct v4l2_format vfmt)
break;
case V4L2_BUF_TYPE_VBI_CAPTURE:
case V4L2_BUF_TYPE_VBI_OUTPUT:
- printf("\tType : %s\n", buftype2s(vfmt.type).c_str());
printf("\tSampling Rate : %u Hz\n", vfmt.fmt.vbi.sampling_rate);
printf("\tOffset : %u samples (%g secs after leading edge)\n",
vfmt.fmt.vbi.offset,
@@ -728,7 +771,6 @@ static int printfmt(struct v4l2_format vfmt)
break;
case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
- printf("\tType : %s\n", buftype2s(vfmt.type).c_str());
printf("\tService Set : %s\n",
flags2s(vfmt.fmt.sliced.service_set, service_def).c_str());
for (int i = 0; i < 24; i++) {
@@ -739,10 +781,8 @@ static int printfmt(struct v4l2_format vfmt)
printf("\tI/O Size : %u\n", vfmt.fmt.sliced.io_size);
break;
case V4L2_BUF_TYPE_PRIVATE:
- printf("\tType: %s\n", buftype2s(vfmt.type).c_str());
break;
default:
- printf("\tType: %s\n", buftype2s(vfmt.type).c_str());
return -1;
}
return 0;
@@ -860,8 +900,6 @@ 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_VIDEO_OUTPUT_POS)
- s += "\t\tVideo Output Position\n";
if (cap & V4L2_CAP_TUNER)
s += "\t\tTuner\n";
if (cap & V4L2_CAP_AUDIO)
@@ -1031,6 +1069,62 @@ static void print_std(const char *prefix, const char *stds[], unsigned long long
printf("\n");
}
+static void do_crop(int fd, unsigned int set_crop, struct v4l2_rect &vcrop, v4l2_buf_type type)
+{
+ 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 (set_crop & CropWidth)
+ in_crop.c.width = vcrop.width;
+ if (set_crop & CropHeight)
+ in_crop.c.height = vcrop.height;
+ if (set_crop & CropLeft)
+ 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");
+ }
+}
+
+static void parse_crop(char *optarg, unsigned int &set_crop, v4l2_rect &vcrop)
+{
+ char *value;
+ char *subs = optarg;
+
+ while (*subs != '\0') {
+ static char *const subopts[] = {
+ "left",
+ "top",
+ "width",
+ "height",
+ NULL
+ };
+
+ switch (parse_subopt(&subs, subopts, &value)) {
+ case 0:
+ vcrop.left = strtol(value, 0L, 0);
+ set_crop |= CropLeft;
+ break;
+ case 1:
+ vcrop.top = strtol(value, 0L, 0);
+ set_crop |= CropTop;
+ break;
+ case 2:
+ vcrop.width = strtol(value, 0L, 0);
+ set_crop |= CropWidth;
+ break;
+ case 3:
+ vcrop.height = strtol(value, 0L, 0);
+ set_crop |= CropHeight;
+ break;
+ }
+ }
+}
+
int main(int argc, char **argv)
{
char *value, *subs;
@@ -1042,6 +1136,9 @@ int main(int argc, char **argv)
unsigned int set_fmts = 0;
unsigned int set_fmts_out = 0;
unsigned int set_crop = 0;
+ unsigned int set_crop_out = 0;
+ unsigned int set_crop_overlay = 0;
+ unsigned int set_crop_out_overlay = 0;
unsigned int set_fbuf = 0;
unsigned int set_overlay_fmt_out = 0;
@@ -1064,6 +1161,9 @@ int main(int argc, char **argv)
struct v4l2_audio vaudio; /* list audio inputs */
struct v4l2_audioout vaudout; /* audio outputs */
struct v4l2_rect vcrop; /* crop rect */
+ struct v4l2_rect vcrop_out; /* crop rect */
+ struct v4l2_rect vcrop_overlay; /* crop rect */
+ struct v4l2_rect vcrop_out_overlay; /* crop rect */
struct v4l2_framebuffer fbuf; /* fbuf */
int input; /* set_input/get_input */
int output; /* set_output/get_output */
@@ -1088,6 +1188,9 @@ int main(int argc, char **argv)
memset(&vaudio, 0, sizeof(vaudio));
memset(&vaudout, 0, sizeof(vaudout));
memset(&vcrop, 0, sizeof(vcrop));
+ memset(&vcrop_out, 0, sizeof(vcrop_out));
+ memset(&vcrop_overlay, 0, sizeof(vcrop_overlay));
+ memset(&vcrop_out_overlay, 0, sizeof(vcrop_out_overlay));
memset(&vf, 0, sizeof(vf));
memset(&vs, 0, sizeof(vs));
memset(&fbuf, 0, sizeof(fbuf));
@@ -1150,30 +1253,17 @@ int main(int argc, char **argv)
subs = optarg;
while (*subs != '\0') {
static char *const subopts[] = {
- "top",
- "left",
"width",
"height",
NULL
};
switch (parse_subopt(&subs, subopts, &value)) {
-#if 0
- /* Comment out until ABI breakage is resolved */
case 0:
- vfmt_out.fmt.pix.top = strtol(value, 0L, 0);
- set_fmts_out |= FmtTop;
- break;
- case 1:
- vfmt_out.fmt.pix.left = strtol(value, 0L, 0);
- set_fmts_out |= FmtLeft;
- break;
-#endif
- case 2:
vfmt_out.fmt.pix.width = strtol(value, 0L, 0);
set_fmts_out |= FmtWidth;
break;
- case 3:
+ case 1:
vfmt_out.fmt.pix.height = strtol(value, 0L, 0);
set_fmts_out |= FmtHeight;
break;
@@ -1208,6 +1298,8 @@ int main(int argc, char **argv)
"chromakey",
"global_alpha",
"local_alpha",
+ "global_inv_alpha",
+ "local_inv_alpha",
NULL
};
@@ -1224,40 +1316,29 @@ int main(int argc, char **argv)
fbuf.flags |= strtol(value, 0L, 0) ? V4L2_FBUF_FLAG_LOCAL_ALPHA : 0;
set_fbuf |= V4L2_FBUF_FLAG_LOCAL_ALPHA;
break;
- }
- }
- break;
- case OptSetVideoCrop:
- subs = optarg;
- while (*subs != '\0') {
- static char *const subopts[] = {
- "left",
- "top",
- "width",
- "height",
- NULL
- };
-
- switch (parse_subopt(&subs, subopts, &value)) {
- case 0:
- vcrop.left = strtol(value, 0L, 0);
- set_crop |= CropLeft;
- break;
- case 1:
- vcrop.top = strtol(value, 0L, 0);
- set_crop |= CropTop;
- break;
- case 2:
- vcrop.width = strtol(value, 0L, 0);
- set_crop |= CropWidth;
- break;
case 3:
- vcrop.height = strtol(value, 0L, 0);
- set_crop |= CropHeight;
+ fbuf.flags |= strtol(value, 0L, 0) ? V4L2_FBUF_FLAG_GLOBAL_INV_ALPHA : 0;
+ set_fbuf |= V4L2_FBUF_FLAG_GLOBAL_INV_ALPHA;
+ break;
+ case 4:
+ fbuf.flags |= strtol(value, 0L, 0) ? V4L2_FBUF_FLAG_LOCAL_INV_ALPHA : 0;
+ set_fbuf |= V4L2_FBUF_FLAG_LOCAL_INV_ALPHA;
break;
}
}
break;
+ case OptSetCrop:
+ parse_crop(optarg, set_crop, vcrop);
+ break;
+ case OptSetOutputCrop:
+ parse_crop(optarg, set_crop_out, vcrop_out);
+ break;
+ case OptSetOverlayCrop:
+ parse_crop(optarg, set_crop_overlay, vcrop_overlay);
+ break;
+ case OptSetOutputOverlayCrop:
+ parse_crop(optarg, set_crop_out_overlay, vcrop_out_overlay);
+ break;
case OptSetInput:
input = strtol(optarg, 0L, 0);
break;
@@ -1434,7 +1515,7 @@ int main(int argc, char **argv)
if (options[OptAll]) {
options[OptGetVideoFormat] = 1;
- options[OptGetVideoCrop] = 1;
+ options[OptGetCrop] = 1;
options[OptGetVideoOutFormat] = 1;
options[OptGetDriverInfo] = 1;
options[OptGetInput] = 1;
@@ -1451,12 +1532,14 @@ int main(int argc, char **argv)
options[OptGetSlicedVbiFormat] = 1;
options[OptGetSlicedVbiOutFormat] = 1;
options[OptGetFBuf] = 1;
+ options[OptGetCropCap] = 1;
+ options[OptGetOutputCropCap] = 1;
}
/* Information Opts */
if (options[OptGetDriverInfo]) {
- printf("Driver info:\n");
+ printf("Driver Info:\n");
printf("\tDriver name : %s\n", vcap.driver);
printf("\tCard type : %s\n", vcap.card);
printf("\tBus info : %s\n", vcap.bus_info);
@@ -1558,13 +1641,6 @@ int main(int argc, char **argv)
if (ioctl(fd, VIDIOC_G_FMT, &in_vfmt) < 0)
fprintf(stderr, "ioctl: VIDIOC_G_FMT failed\n");
else {
-#if 0
- /* Comment out until ABI breakage is resolved */
- if (set_fmts_out & FmtTop)
- in_vfmt.fmt.pix.top = vfmt_out.fmt.pix.top;
- if (set_fmts_out & FmtLeft)
- in_vfmt.fmt.pix.left = vfmt_out.fmt.pix.left;
-#endif
if (set_fmts_out & FmtWidth)
in_vfmt.fmt.pix.width = vfmt_out.fmt.pix.width;
if (set_fmts_out & FmtHeight)
@@ -1626,24 +1702,20 @@ int main(int argc, char **argv)
}
}
- if (options[OptSetVideoCrop]) {
- struct v4l2_crop in_crop;
+ if (options[OptSetCrop]) {
+ do_crop(fd, set_crop, vcrop, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+ }
- in_crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(fd, VIDIOC_G_CROP, &in_crop) < 0)
- fprintf(stderr, "ioctl: VIDIOC_G_CROP failed\n");
- else {
- if (set_crop & CropWidth)
- in_crop.c.width = vcrop.width;
- if (set_crop & CropHeight)
- in_crop.c.height = vcrop.height;
- if (set_crop & CropLeft)
- 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");
- }
+ if (options[OptSetOutputCrop]) {
+ do_crop(fd, set_crop_out, vcrop_out, V4L2_BUF_TYPE_VIDEO_OUTPUT);
+ }
+
+ if (options[OptSetOverlayCrop]) {
+ do_crop(fd, set_crop_overlay, vcrop_overlay, V4L2_BUF_TYPE_VIDEO_OVERLAY);
+ }
+
+ if (options[OptSetOutputOverlayCrop]) {
+ do_crop(fd, set_crop_out_overlay, vcrop_out_overlay, V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY);
}
if (options[OptSetCtrl] && !set_ctrls.empty()) {
@@ -1765,7 +1837,39 @@ int main(int argc, char **argv)
printfbuf(fb);
}
- if (options[OptGetVideoCrop]) {
+ if (options[OptGetCropCap]) {
+ struct v4l2_cropcap cropcap;
+
+ cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0)
+ printcropcap(cropcap);
+ }
+
+ if (options[OptGetOutputCropCap]) {
+ struct v4l2_cropcap cropcap;
+
+ cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0)
+ printcropcap(cropcap);
+ }
+
+ if (options[OptGetOverlayCropCap]) {
+ struct v4l2_cropcap cropcap;
+
+ cropcap.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
+ if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0)
+ printcropcap(cropcap);
+ }
+
+ if (options[OptGetOutputOverlayCropCap]) {
+ struct v4l2_cropcap cropcap;
+
+ cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY;
+ if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0)
+ printcropcap(cropcap);
+ }
+
+ if (options[OptGetCrop]) {
struct v4l2_crop crop;
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -1773,6 +1877,30 @@ int main(int argc, char **argv)
printcrop(crop);
}
+ if (options[OptGetOutputCrop]) {
+ struct v4l2_crop crop;
+
+ crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ if (doioctl(fd, VIDIOC_G_CROP, &crop, "VIDIOC_G_CROP") == 0)
+ printcrop(crop);
+ }
+
+ if (options[OptGetOverlayCrop]) {
+ struct v4l2_crop crop;
+
+ crop.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
+ if (doioctl(fd, VIDIOC_G_CROP, &crop, "VIDIOC_G_CROP") == 0)
+ printcrop(crop);
+ }
+
+ if (options[OptGetOutputOverlayCrop]) {
+ struct v4l2_crop crop;
+
+ crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY;
+ if (doioctl(fd, VIDIOC_G_CROP, &crop, "VIDIOC_G_CROP") == 0)
+ printcrop(crop);
+ }
+
if (options[OptGetInput]) {
if (doioctl(fd, VIDIOC_G_INPUT, &input, "VIDIOC_G_INPUT") == 0) {
printf("Video input : %d", input);
@@ -1836,7 +1964,7 @@ int main(int argc, char **argv)
NULL
};
- printf("Video standard = 0x%08llx\n", (unsigned long long)std);
+ printf("Video Standard = 0x%08llx\n", (unsigned long long)std);
if (std & 0xfff) {
print_std("PAL", pal, std);
}