From patchwork Thu Sep 10 12:19:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 7153691 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9F216BEEC1 for ; Thu, 10 Sep 2015 12:21:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA3AD206BD for ; Thu, 10 Sep 2015 12:21:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE81E20686 for ; Thu, 10 Sep 2015 12:21:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751263AbbIJMVa (ORCPT ); Thu, 10 Sep 2015 08:21:30 -0400 Received: from mga09.intel.com ([134.134.136.24]:11092 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751174AbbIJMV3 (ORCPT ); Thu, 10 Sep 2015 08:21:29 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 10 Sep 2015 05:21:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,504,1437462000"; d="scan'208";a="766218652" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga001.jf.intel.com with ESMTP; 10 Sep 2015 05:21:28 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id 24F5720149; Thu, 10 Sep 2015 15:20:57 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id B7B61201EC; Thu, 10 Sep 2015 15:19:20 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com Subject: [yavta PATCH 1/1] List supported formats with -f help Date: Thu, 10 Sep 2015 15:19:20 +0300 Message-Id: <1441887560-21768-1-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.1.0.231.g7484e3b Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Passing format "help" to the -f option will list the supported formats and exit. Signed-off-by: Sakari Ailus --- yavta.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/yavta.c b/yavta.c index 7d8ac8e..b627725 100644 --- a/yavta.c +++ b/yavta.c @@ -215,6 +215,20 @@ static struct v4l2_format_info { { "MPEG", V4L2_PIX_FMT_MPEG, 1 }, }; +static void list_formats(void) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) + printf("%s (\"%c%c%c%c\", %u planes)\n", + pixel_formats[i].name, + pixel_formats[i].fourcc & 0xff, + (pixel_formats[i].fourcc >> 8) & 0xff, + (pixel_formats[i].fourcc >> 16) & 0xff, + (pixel_formats[i].fourcc >> 24) & 0xff, + pixel_formats[i].n_planes); +} + static const struct v4l2_format_info *v4l2_format_by_fourcc(unsigned int fourcc) { unsigned int i; @@ -1734,6 +1748,7 @@ static void usage(const char *argv0) printf("-C, --check-overrun Verify dequeued frames for buffer overrun\n"); printf("-d, --delay Delay (in ms) before requeuing buffers\n"); printf("-f, --format format Set the video format\n"); + printf(" use -f help to list the supported formats\n"); printf("-F, --file[=name] Read/write frames from/to disk\n"); printf("\tFor video capture devices, the first '#' character in the file name is\n"); printf("\texpanded to the frame sequence number. The default file name is\n"); @@ -1899,6 +1914,10 @@ int main(int argc, char *argv[]) delay = atoi(optarg); break; case 'f': + if (!strcmp("help", optarg)) { + list_formats(); + return 0; + } do_set_format = 1; info = v4l2_format_by_name(optarg); if (info == NULL) {