summaryrefslogtreecommitdiff
path: root/snapshot.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-04-16 20:10:34 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-04-16 23:40:30 +0200
commit4dd4dcb4f594c872df222390031975d06adc7e71 (patch)
treef387d6db94988a3f1904cd1c03d3f21769ec9f27 /snapshot.c
parent6310474d2fdc91dc2aac87e25ef17fc682a3c94d (diff)
snapshot: Replace -y argument with -f to freely select the snapshot format
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'snapshot.c')
-rw-r--r--snapshot.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/snapshot.c b/snapshot.c
index 5728ae6..bc2b7da 100644
--- a/snapshot.c
+++ b/snapshot.c
@@ -222,19 +222,56 @@ static void viewfinder_process(struct omap3_isp_device *isp,
}
}
+/* -------------------------------------------------------------------------- */
+
+static const struct {
+ const char *name;
+ unsigned int fourcc;
+} pixel_formats[] = {
+ { "Y8", V4L2_MBUS_FMT_Y8_1X8 },
+ { "Y10", V4L2_MBUS_FMT_Y10_1X10 },
+ { "Y12", V4L2_MBUS_FMT_Y12_1X12 },
+ { "YUYV", V4L2_MBUS_FMT_YUYV8_2X8 },
+ { "UYVY", V4L2_MBUS_FMT_UYVY8_2X8 },
+ { "SBGGR8", V4L2_MBUS_FMT_SBGGR8_1X8 },
+ { "SGBRG8", V4L2_MBUS_FMT_SGBRG8_1X8 },
+ { "SGRBG8", V4L2_MBUS_FMT_SGRBG8_1X8 },
+ { "SRGGB8", V4L2_MBUS_FMT_SRGGB8_1X8 },
+ { "SBGGR10", V4L2_MBUS_FMT_SBGGR10_1X10 },
+ { "SGBRG10", V4L2_MBUS_FMT_SGBRG10_1X10 },
+ { "SGRBG10", V4L2_MBUS_FMT_SGRBG10_1X10 },
+ { "SRGGB10", V4L2_MBUS_FMT_SRGGB10_1X10 },
+ { "SBGGR12", V4L2_MBUS_FMT_SBGGR12_1X12 },
+ { "SGBRG12", V4L2_MBUS_FMT_SGBRG12_1X12 },
+ { "SGRBG12", V4L2_MBUS_FMT_SGRBG12_1X12 },
+ { "SRGGB12", V4L2_MBUS_FMT_SRGGB12_1X12 },
+};
+
+static unsigned int parse_format(const char *name)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(pixel_formats); ++i) {
+ if (strcasecmp(pixel_formats[i].name, name) == 0)
+ return pixel_formats[i].fourcc;
+ }
+
+ return 0;
+}
+
static void usage(const char *argv0)
{
printf("Usage: %s [options]\n", argv0);
printf("Supported options:\n");
+ printf("-f, --format fmt Snapshot format\n");
printf("-h, --help Show this help screen\n");
printf("-s, --snap n Capture a snapshot every n frames\n");
- printf("-y, --yuv YUV snapshots\n");
}
static struct option opts[] = {
{ "help", 0, 0, 'h' },
+ { "format", 1, 0, 'f' },
{ "snap", 0, 0, 's' },
- { "yuv", 0, 0, 'y' },
{ 0, 0, 0, 0 }
};
@@ -253,8 +290,15 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
int ret;
int c;
- while ((c = getopt_long(argc, argv, "hs:y", opts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "f:hs:", opts, NULL)) != -1) {
switch (c) {
+ case 'f':
+ snap_code = parse_format(optarg);
+ if (snap_code == 0) {
+ printf("invalid format %s.\n", optarg);
+ return 1;
+ }
+ break;
case 'h':
usage(argv[0]);
return 0;
@@ -265,9 +309,6 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
return 1;
}
break;
- case 'y':
- snap_code = V4L2_MBUS_FMT_YUYV8_1X16;
- break;
default:
printf("Invalid option -%c\n", c);
printf("Run %s -h for help.\n", argv[0]);