From: Hans Verkuil Date: Wed, 20 Mar 2013 18:24:30 +0000 (+0100) Subject: v4l2-ctl: add the --concise option. X-Git-Tag: v4l-utils-0.9.4~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1fcb55a2e4b5678100e60a862d297a99f3a45cf6;p=platform%2Fupstream%2Fv4l-utils.git v4l2-ctl: add the --concise option. With the concise option you can get a more concise overview of some of the lists. Implemented this for list-dv-timings and list-standards. Signed-off-by: Hans Verkuil --- diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp index 0db0bbe..2e30321 100644 --- a/utils/v4l2-ctl/v4l2-ctl-common.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp @@ -71,6 +71,7 @@ void common_usage(void) " --help-vbi VBI format options\n" " --help-vidcap video capture format options\n" " --help-vidout vidout output format options\n" + " -k, --concise be more concise if possible.\n" " -l, --list-ctrls display all controls and their values [VIDIOC_QUERYCTRL]\n" " -L, --list-ctrls-menus\n" " display all controls and their menus [VIDIOC_QUERYMENU]\n" diff --git a/utils/v4l2-ctl/v4l2-ctl-stds.cpp b/utils/v4l2-ctl/v4l2-ctl-stds.cpp index 9ee975f..55a3b8a 100644 --- a/utils/v4l2-ctl/v4l2-ctl-stds.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-stds.cpp @@ -241,11 +241,25 @@ static const flag_def dv_flags_def[] = { static void print_dv_timings(const struct v4l2_dv_timings *t) { const struct v4l2_bt_timings *bt; + double tot_width, tot_height; switch (t->type) { case V4L2_DV_BT_656_1120: bt = &t->bt; + tot_height = bt->height + + bt->vfrontporch + bt->vsync + bt->vbackporch + + bt->il_vfrontporch + bt->il_vsync + bt->il_vbackporch; + tot_width = bt->width + + bt->hfrontporch + bt->hsync + bt->hbackporch; + if (options[OptConcise]) { + printf("\t%dx%d%c%.2f %s\n", bt->width, bt->height, + bt->interlaced ? 'i' : 'p', + (double)bt->pixelclock / + (tot_width * (tot_height / (bt->interlaced ? 2 : 1))), + flags2s(bt->flags, dv_flags_def).c_str()); + break; + } printf("\tActive width: %d\n", bt->width); printf("\tActive height: %d\n", bt->height); printf("\tTotal width: %d\n",bt->width + @@ -260,12 +274,6 @@ static void print_dv_timings(const struct v4l2_dv_timings *t) (bt->polarities & V4L2_DV_HSYNC_POS_POL) ? '+' : '-'); printf("\tPixelclock: %lld Hz", bt->pixelclock); if (bt->width && bt->height) { - double tot_height = bt->height + - bt->vfrontporch + bt->vsync + bt->vbackporch + - bt->il_vfrontporch + bt->il_vsync + bt->il_vbackporch; - double tot_width = bt->width + - bt->hfrontporch + bt->hsync + bt->hbackporch; - if (bt->interlaced) printf(" (%.2f fields per second)", (double)bt->pixelclock / (tot_width * (tot_height / 2))); @@ -458,15 +466,20 @@ void stds_list(int fd) printf("ioctl: VIDIOC_ENUMSTD\n"); vs.index = 0; while (test_ioctl(fd, VIDIOC_ENUMSTD, &vs) >= 0) { - if (vs.index) - printf("\n"); - 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", - vs.frameperiod.numerator, - vs.frameperiod.denominator); - printf("\tFrame lines : %d\n", vs.framelines); + if (options[OptConcise]) { + printf("\t%2d: 0x%016llX %s\n", vs.index, + (unsigned long long)vs.id, vs.name); + } else { + if (vs.index) + printf("\n"); + 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", + vs.frameperiod.numerator, + vs.frameperiod.denominator); + printf("\tFrame lines : %d\n", vs.framelines); + } vs.index++; } } @@ -494,9 +507,13 @@ void stds_list(int fd) dv_enum_timings.index = 0; printf("ioctl: VIDIOC_ENUM_DV_TIMINGS\n"); while (test_ioctl(fd, VIDIOC_ENUM_DV_TIMINGS, &dv_enum_timings) >= 0) { - if (dv_enum_timings.index) - printf("\n"); - printf("\tIndex: %d\n", dv_enum_timings.index); + if (options[OptConcise]) { + printf("\t%d:", dv_enum_timings.index); + } else { + if (dv_enum_timings.index) + printf("\n"); + printf("\tIndex: %d\n", dv_enum_timings.index); + } print_dv_timings(&dv_enum_timings.timings); dv_enum_timings.index++; } diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index fbe3cca..14406ca 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -90,6 +90,7 @@ static struct option long_options[] = { {"help-streaming", no_argument, 0, OptHelpStreaming}, {"help-all", no_argument, 0, OptHelpAll}, {"wrapper", no_argument, 0, OptUseWrapper}, + {"concise", no_argument, 0, OptConcise}, {"get-output", no_argument, 0, OptGetOutput}, {"set-output", required_argument, 0, OptSetOutput}, {"list-outputs", no_argument, 0, OptListOutputs}, diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index 6a3c312..26ecea0 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -20,6 +20,7 @@ enum Option { OptHelp = 'h', OptGetInput = 'I', OptSetInput = 'i', + OptConcise = 'k', OptListCtrls = 'l', OptListCtrlsMenus = 'L', OptListOutputs = 'N',