summaryrefslogtreecommitdiff
path: root/snapshot.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-02-28 15:40:19 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-04-16 23:50:06 +0200
commitdcefa4189bf3b012333771730c2a9b3bd7c1d576 (patch)
tree5f376c5b131738dbadf994ade7655d001fa1d003 /snapshot.c
parent8dfa847f666396f7fdfe3f9b6518ed3917003e7f (diff)
snapshot: Add -s/--size argument to specify snapshot size
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'snapshot.c')
-rw-r--r--snapshot.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/snapshot.c b/snapshot.c
index 1ca2169..05b9bd7 100644
--- a/snapshot.c
+++ b/snapshot.c
@@ -229,6 +229,22 @@ static int parse_crop(const char *p, struct v4l2_rect *crop)
return 0;
}
+static int parse_size(const char *p, struct v4l2_mbus_framefmt *format)
+{
+ char *end;
+
+ format->width = strtoul(p, &end, 10);
+ if (*end != 'x')
+ return -EINVAL;
+
+ p = end + 1;
+ format->height = strtoul(p, &end, 10);
+ if (*end != '\0')
+ return -EINVAL;
+
+ return 0;
+}
+
static void usage(const char *argv0)
{
printf("Usage: %s [options]\n", argv0);
@@ -238,6 +254,7 @@ static void usage(const char *argv0)
printf("-h, --help Show this help screen\n");
printf("-i, --interval n Capture a snapshot every n frames\n");
printf("-S, --save Save snapshots to disk\n");
+ printf("-s, --size wxh Set the snapshot capture size\n");
}
static struct option opts[] = {
@@ -246,12 +263,12 @@ static struct option opts[] = {
{ "help", 0, 0, 'h' },
{ "interval", 1, 0, 'i' },
{ "save", 0, 0, 'S' },
+ { "size", 1, 0, 's' },
{ 0, 0, 0, 0 }
};
int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__)))
{
- enum v4l2_mbus_pixelcode snap_code = V4L2_MBUS_FMT_SGRBG10_1X10;
struct v4l2_mbus_framefmt view_format;
struct v4l2_mbus_framefmt snap_format;
struct v4l2_rect snap_crop;
@@ -265,7 +282,12 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
int ret;
int c;
- while ((c = getopt_long(argc, argv, "c:f:hi:S", opts, NULL)) != -1) {
+ memset(&snap_format, 0, sizeof snap_format);
+ snap_format.code = V4L2_MBUS_FMT_SGRBG10_1X10;
+ snap_format.width = SNAPSHOT_WIDTH;
+ snap_format.height = SNAPSHOT_HEIGHT;
+
+ while ((c = getopt_long(argc, argv, "c:f:hi:Ss:", opts, NULL)) != -1) {
switch (c) {
case 'c':
if (parse_crop(optarg, &snap_crop)) {
@@ -275,8 +297,8 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
do_crop = true;
break;
case 'f':
- snap_code = parse_format(optarg);
- if (snap_code == 0) {
+ snap_format.code = parse_format(optarg);
+ if (snap_format.code == 0) {
printf("invalid format %s.\n", optarg);
return 1;
}
@@ -294,6 +316,12 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
case 'S':
snapshot_save = true;
break;
+ case 's':
+ if (parse_size(optarg, &snap_format)) {
+ printf("invalid size %s.\n", optarg);
+ return 1;
+ }
+ break;
default:
printf("Invalid option -%c\n", c);
printf("Run %s -h for help.\n", argv[0]);
@@ -336,11 +364,6 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
printf("viewfinder configured for %04x %ux%u\n",
view_format.code, view_format.width, view_format.height);
- memset(&snap_format, 0, sizeof snap_format);
- snap_format.code = snap_code;
- snap_format.width = SNAPSHOT_WIDTH;
- snap_format.height = SNAPSHOT_HEIGHT;
-
ret = omap3_isp_snapshot_setup(isp, do_crop ? &snap_crop : NULL, &snap_format);
if (ret < 0) {
printf("error: unable to setup pipeline\n");