From patchwork Mon Aug 26 17:20:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 103692 Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sidOA-0005CK-1E for patchwork@linuxtv.org; Mon, 26 Aug 2024 17:20:23 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8C8B51F22F03 for ; Mon, 26 Aug 2024 17:20:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 334D7198A11; Mon, 26 Aug 2024 17:20:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="iUre3MLV"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="ZsLp5ZV/" X-Original-To: linux-media@vger.kernel.org Received: from a7-40.smtp-out.eu-west-1.amazonses.com (a7-40.smtp-out.eu-west-1.amazonses.com [54.240.7.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94A151917DF for ; Mon, 26 Aug 2024 17:20:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.240.7.40 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724692815; cv=none; b=p5FVnjW9iimVGQdBZT2eD7Y/paFhMQiAsXW7x59Vg47IsGDpmIrVtygimIFQwiHXSm2LP4k0xHdke/I97zqdSjGOeUvaveyO3T+xNfwTMFYPAqQlXCP07cD2H3nqzRw11iIX9ygrBytOFiwQRafb1jMWRs1sEK5gMLrVyW7L2wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724692815; c=relaxed/simple; bh=8JeMApPWlaQv0tbX+hlRbBQjpN7mc/W+zuvS/3thdHc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qu/qymJfmD0mnuLg+hilgFmynRqJSYrPiVSvLt/uuNHPtdxoa2Cne/2OeUS517xpMz2PSBdauC/8TxQMn90optrjunABIOAnoyylb2bD5qKMe9aLAYL+KNlVxvAqrxBu5CUe6q0jlosp1O1sKTszQshsT45nUJ3dNRGY/Np8ohY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=amazonses.collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=iUre3MLV; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b=ZsLp5ZV/; arc=none smtp.client-ip=54.240.7.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazonses.collabora.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=4232tfv5ebdrjdwkr5zzm7kytdkokgug; d=collabora.com; t=1724692812; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=8JeMApPWlaQv0tbX+hlRbBQjpN7mc/W+zuvS/3thdHc=; b=iUre3MLVwq6qEYIrtxFlqW7nqmO3Qe6fXODsJPwRmkowmH801K8X6Pk+8Vb5ohQi 4VOjFjDRMTTgUsZrwS8Arjrx79nX7H0OezgLeCR+q1zJ0NMs1JPP079+dyKzq73bk/N szrbNVMlxX0vfO+T1zhPZzScyOA23bn9i8Cx12nXGpaNJPxpnbO2lOGutLrvdKAEBVD BMgzsh9PaY6+BRi1Tyux/j/w747U6Eqq/Ca45djIhxao+iL6oU950cWEhZZpdH/8JlC 9JPLb0+Yjty8l6FM3rrxXU51+mb5/FGVRyMHYDfCIPKaRavZaYTttmVkUhXtWKYcVaI kim+9V9paA== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=uku4taia5b5tsbglxyj6zym32efj7xqv; d=amazonses.com; t=1724692812; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Feedback-ID; bh=8JeMApPWlaQv0tbX+hlRbBQjpN7mc/W+zuvS/3thdHc=; b=ZsLp5ZV/mvz3bs3d7phv5KcrsOhWLUJv6hmeSWywem/S7373vdmA63dn3rY8wf2w Ko1CCu89xfOVCmduhsbNkzByuyJ1pkV2xNapMki8I505Hq182Tnb99GECji6BhVYGQa a8yE0IhTVd1XgtXKuV04/5tS2p35ar+QFz5dF7QU= From: Benjamin Gaignard To: hverkuil-cisco@xs4all.nl Cc: linux-media@vger.kernel.org, Benjamin Gaignard Subject: [PATCH v4 1/2] v4l2-compliance: Add test for V4L2_FMTDESC_FLAG_ENUM_ALL flag Date: Mon, 26 Aug 2024 17:20:11 +0000 Message-ID: <010201918fb3d081-a676cc64-a19a-4c45-8083-7413a389f048-000000@eu-west-1.amazonses.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240826172009.140022-1-benjamin.gaignard@collabora.com> References: <20240826172009.140022-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Feedback-ID: ::1.eu-west-1.YpP9ZbxnARFfy3Cb5pfsLd/pdsXBCNK0KEM7HforL4k=:AmazonSES X-SES-Outgoing: 2024.08.26-54.240.7.40 X-LSpam-Score: -6.3 (------) X-LSpam-Report: No, score=-6.3 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no If V4L2_FMTDESC_FLAG_ENUM_ALL flag is supported, test if all pixel formats list with VIDIOC_ENUM_FMT without the flag been set is a subset of the list created with the flag. Also Test that the flag is cleared of calling VIDIOC_ENUM_FMT. Signed-off-by: Benjamin Gaignard --- include/linux/videodev2.h | 3 ++ utils/v4l2-compliance/v4l2-test-formats.cpp | 35 +++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index f18a40d4..c166bb35 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -864,6 +864,9 @@ struct v4l2_fmtdesc { #define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100 #define V4L2_FMT_FLAG_META_LINE_BASED 0x0200 +/* Format description flag, to be ORed with the index */ +#define V4L2_FMTDESC_FLAG_ENUM_ALL 0x80000000 + /* Frame Size and frame rate enumeration */ /* * F R A M E S I Z E E N U M E R A T I O N diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp index fc16ad39..bac28cba 100644 --- a/utils/v4l2-compliance/v4l2-test-formats.cpp +++ b/utils/v4l2-compliance/v4l2-test-formats.cpp @@ -224,6 +224,7 @@ static int testEnumFrameSizes(struct node *node, __u32 pixfmt) static int testEnumFormatsType(struct node *node, unsigned type) { pixfmt_map &map = node->buftype_pixfmts[type]; + pixfmt_map enum_all; struct v4l2_fmtdesc fmtdesc; unsigned f = 0; int ret; @@ -318,6 +319,40 @@ static int testEnumFormatsType(struct node *node, unsigned type) map[fmtdesc.pixelformat] = fmtdesc.flags; } info("found %d formats for buftype %d\n", f, type); + + /* Test V4L2_FMTDESC_FLAG_ENUM_ALL if supported */ + f = 0; + for (;;) { + memset(&fmtdesc, 0xff, sizeof(fmtdesc)); + fmtdesc.type = type; + fmtdesc.index = f | V4L2_FMTDESC_FLAG_ENUM_ALL; + fmtdesc.mbus_code = 0; + + ret = doioctl(node, VIDIOC_ENUM_FMT, &fmtdesc); + if (f == 0 && ret == EINVAL) + return 0; + if (ret == EINVAL) + break; + if (ret) + return fail("expected EINVAL, but got %d when enumerating buftype %d\n", ret, type); + if (fmtdesc.index != f) + return fail("V4L2_FMTDESC_FLAG_ENUM_ALL hasn't been cleared from fmtdesc.index 0x%x f 0x%x\n", fmtdesc.index, f); + f++; + if (type == V4L2_BUF_TYPE_PRIVATE) + continue; + assert(type <= V4L2_BUF_TYPE_LAST); + if (enum_all.find(fmtdesc.pixelformat) != enum_all.end()) + return fail("duplicate format %08x (%s)\n", + fmtdesc.pixelformat, fcc2s(fmtdesc.pixelformat).c_str()); + enum_all[fmtdesc.pixelformat] = fmtdesc.flags; + } + info("found %d formats for buftype %d (with V4L2_FMTDESC_FLAG_ENUM_ALL)\n", f, type); + + /* if V4L2_FMTDESC_FLAG_ENUM_ALL is supported, verify that the list is a subset of VIDIOC_ENUM_FMT list */ + for (auto it = map.begin(); it != map.end(); it++) + if (enum_all.find(it->first) == enum_all.end()) + return fail("V4L2_FMTDESC_FLAG_ENUM_ALL failed to enumerate format %08x (%s)\n", it->first, fcc2s(it->first).c_str()); + return 0; } From patchwork Mon Aug 26 17:20:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 103693 Received: from ny.mirrors.kernel.org ([147.75.199.223]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sidOC-0005Cd-0f for patchwork@linuxtv.org; Mon, 26 Aug 2024 17:20:25 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 216BA1C2193D for ; Mon, 26 Aug 2024 17:20:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D3C51917DF; Mon, 26 Aug 2024 17:20:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="YmXZODqX"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="bKxa6gUX" X-Original-To: linux-media@vger.kernel.org Received: from a7-44.smtp-out.eu-west-1.amazonses.com (a7-44.smtp-out.eu-west-1.amazonses.com [54.240.7.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A40D192D64 for ; Mon, 26 Aug 2024 17:20:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.240.7.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724692816; cv=none; b=Gj5eX2JGaxcH6OcP5hlH7yNdSuGTP1ez+fW9aWBcN50kXdlmjkmzQ9Wv4yRRiY32dpnTFIhBi/VopwfNIJt/eTveW1QHo/QKXfW9zcDRShJBQCHZsz25xOts3x4WKQq5s+6zgOtlT610T0fxWsXO9VnDlvKiXrV/2rM5WgAhthI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724692816; c=relaxed/simple; bh=QVo/tzc7xDWTCe9EfvawQcoLFUU5LFSnfElDUCx/Pz0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=inljDgnxt5DKtDjQ7RJ1DQezEiRUVPeU7uDAAoszd8iHPUJ0JDwBdEi24u+px/Aj7InkuMqfvdl896bDMvi0/+uOur7xJ5Xjo8dECKfmwUWIhvNFAT5W1LgcE1a5LGtyL/0AyvgLO/FztON8as7oJFLlcoKKsPxRhDUIp0pwjyw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=amazonses.collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=YmXZODqX; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b=bKxa6gUX; arc=none smtp.client-ip=54.240.7.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazonses.collabora.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=4232tfv5ebdrjdwkr5zzm7kytdkokgug; d=collabora.com; t=1724692812; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=QVo/tzc7xDWTCe9EfvawQcoLFUU5LFSnfElDUCx/Pz0=; b=YmXZODqXHFygzcMoiQpZkJDZl9hDlCFjnA462lomxDsxyUHkN24sJ2K+0MA4imkt Z4XeIyUZoYgr6JXcsmEE6+TgeTZsroJOC0BFfEuORPscKeqJtiXgmHNB1ByBvyx6H0f WBKulxqZXlpIFjtTa9BcXCyIS4PNACq4vDlyQL+AYQ1MdXL7fFziv21oi5cijyczhSW U3w4lU5IMDnwenIYFXhediMswnLSdfyeAHk7vgGG1g3/6kAMA4rZRe/6PKQemblBeSe gwXG0Xc0GeV6FbkHOYejC/DXsmrFb9IOrTLrDVPkp7bq/Z2NKRAJnu90/1GK7DmMHn/ Z9FNZJRTyg== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=uku4taia5b5tsbglxyj6zym32efj7xqv; d=amazonses.com; t=1724692812; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Feedback-ID; bh=QVo/tzc7xDWTCe9EfvawQcoLFUU5LFSnfElDUCx/Pz0=; b=bKxa6gUX6PwU9TGIT75cnSavRm3VsXRp3P4UHqxXCXMsSvXRm77j9IhwE0MoqzWW 5+muEec95a+4+1xUNgjSDAUQWDHSWb+bkQ32qLdSsJF2K5BCW8WKdvWwzjPDwR/se40 S5oKRKggntS6jnqG6QxIp9EQ3iVCzVEWyOlX2PTU= From: Benjamin Gaignard To: hverkuil-cisco@xs4all.nl Cc: linux-media@vger.kernel.org, Benjamin Gaignard Subject: [PATCH v4 2/2] v4l2-ctl-vidcap: Add options to enumerate all pixel formats Date: Mon, 26 Aug 2024 17:20:12 +0000 Message-ID: <010201918fb3d1ab-e36adb13-c37e-43b5-841d-3cf7e4685412-000000@eu-west-1.amazonses.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240826172009.140022-1-benjamin.gaignard@collabora.com> References: <20240826172009.140022-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Feedback-ID: ::1.eu-west-1.YpP9ZbxnARFfy3Cb5pfsLd/pdsXBCNK0KEM7HforL4k=:AmazonSES X-SES-Outgoing: 2024.08.26-54.240.7.44 X-LSpam-Score: -6.3 (------) X-LSpam-Report: No, score=-6.3 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Add 'all' option to the following test tools to use V4L2_FMTDESC_FLAG_ENUM_ALL if supported by the driver: - vidcap --list-formats(-ext) options - meta --list-formats-meta option - vidout -list-formats-out(-ext) options Update functions prototype to provide an additional parameter. Signed-off-by: Benjamin Gaignard --- changes in v4: - Add 'all' option in vidcap, meta and vidout. - Make 'all' and 'mbus_code' exclusive. - Simplify 'all' vs 'mbus_code' parsing. utils/common/cv4l-helpers.h | 5 ++++- utils/v4l2-ctl/v4l2-ctl-meta.cpp | 34 +++++++++++++++++++++-------- utils/v4l2-ctl/v4l2-ctl-overlay.cpp | 2 +- utils/v4l2-ctl/v4l2-ctl-sdr.cpp | 4 ++-- utils/v4l2-ctl/v4l2-ctl-vidcap.cpp | 26 +++++++++++++++------- utils/v4l2-ctl/v4l2-ctl-vidout.cpp | 27 ++++++++++++++++------- utils/v4l2-ctl/v4l2-ctl.cpp | 16 +++++++++----- utils/v4l2-ctl/v4l2-ctl.h | 4 ++-- 8 files changed, 81 insertions(+), 37 deletions(-) diff --git a/utils/common/cv4l-helpers.h b/utils/common/cv4l-helpers.h index ec33da78..ab9c64b3 100644 --- a/utils/common/cv4l-helpers.h +++ b/utils/common/cv4l-helpers.h @@ -488,7 +488,7 @@ public: return cv4l_ioctl(VIDIOC_ENUM_DV_TIMINGS, &timings); } - int enum_fmt(v4l2_fmtdesc &fmt, bool init = false, int index = 0, unsigned type = 0, __u32 mbus_code = 0) + int enum_fmt(v4l2_fmtdesc &fmt, bool init = false, int index = 0, unsigned type = 0, __u32 mbus_code = 0, bool enum_all = false) { if (init) { memset(&fmt, 0, sizeof(fmt)); @@ -498,6 +498,9 @@ public: } else { fmt.index++; } + if (enum_all) + fmt.index |= V4L2_FMTDESC_FLAG_ENUM_ALL; + return cv4l_ioctl(VIDIOC_ENUM_FMT, &fmt); } diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp index 6ad56845..b24cb176 100644 --- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp @@ -5,14 +5,19 @@ static struct v4l2_format vfmt; /* set_format/get_format */ static unsigned mbus_code; static unsigned mbus_code_out; +static bool enum_all; +static bool enum_all_out; void meta_usage() { printf("\nMetadata Formats options:\n" - " --list-formats-meta [] display supported metadata capture formats.\n" + " --list-formats-meta [|all] display supported metadata capture formats.\n" " is an optional media bus code, if the device has\n" " capability V4L2_CAP_IO_MC then only formats that support this\n" - " media bus code are listed [VIDIOC_ENUM_FMT]\n" + " media bus code are listed.\n" + " When 'all' is specify it enumerates all pixel formats if\n" + " V4L2_FMTDESC_FLAG_ENUM_ALL flag is supported by the driver.\n" + " [VIDIOC_ENUM_FMT]\n" " --get-fmt-meta query the metadata capture format [VIDIOC_G_FMT]\n" " --set-fmt-meta set the metadata capture format [VIDIOC_S_FMT]\n" " parameter is either the format index as reported by\n" @@ -23,7 +28,10 @@ void meta_usage() " --list-formats-meta-out [] display supported metadata output formats.\n" " is an optional media bus code, if the device has\n" " capability V4L2_CAP_IO_MC then only formats that support this\n" - " media bus code are listed [VIDIOC_ENUM_FMT]\n" + " media bus code are listed.\n" + " When 'all' is specify it enumerates all pixel formats if\n" + " V4L2_FMTDESC_FLAG_ENUM_ALL flag is supported by the driver.\n" + " [VIDIOC_ENUM_FMT]\n" " --get-fmt-meta-out query the metadata output format [VIDIOC_G_FMT]\n" " --set-fmt-meta-out set the metadata output format [VIDIOC_S_FMT]\n" " parameter is either the format index as reported by\n" @@ -52,12 +60,20 @@ void meta_cmd(int ch, char *optarg) } break; case OptListMetaFormats: - if (optarg) - mbus_code = strtoul(optarg, nullptr, 0); + if (optarg) { + if (strstr(optarg , "all")) + enum_all = true; + else + mbus_code = strtoul(optarg, nullptr, 0); + } break; case OptListMetaOutFormats: - if (optarg) - mbus_code_out = strtoul(optarg, nullptr, 0); + if (optarg) { + if (strstr(optarg , "all")) + enum_all_out = true; + else + mbus_code_out = strtoul(optarg, nullptr, 0); + } break; } } @@ -121,12 +137,12 @@ void meta_list(cv4l_fd &fd) { if (options[OptListMetaFormats]) { printf("ioctl: VIDIOC_ENUM_FMT\n"); - print_video_formats(fd, V4L2_BUF_TYPE_META_CAPTURE, mbus_code); + print_video_formats(fd, V4L2_BUF_TYPE_META_CAPTURE, mbus_code, enum_all); } if (options[OptListMetaOutFormats]) { printf("ioctl: VIDIOC_ENUM_FMT\n"); - print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT, mbus_code_out); + print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT, mbus_code_out, enum_all_out); } } diff --git a/utils/v4l2-ctl/v4l2-ctl-overlay.cpp b/utils/v4l2-ctl/v4l2-ctl-overlay.cpp index 5493222d..797b3f34 100644 --- a/utils/v4l2-ctl/v4l2-ctl-overlay.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-overlay.cpp @@ -522,7 +522,7 @@ void overlay_list(cv4l_fd &fd) { if (options[OptListOverlayFormats]) { printf("ioctl: VIDIOC_ENUM_FMT\n"); - print_video_formats(fd, V4L2_BUF_TYPE_VIDEO_OVERLAY, 0); + print_video_formats(fd, V4L2_BUF_TYPE_VIDEO_OVERLAY, 0, false); } if (options[OptFindFb]) find_fb(fd.g_fd()); diff --git a/utils/v4l2-ctl/v4l2-ctl-sdr.cpp b/utils/v4l2-ctl/v4l2-ctl-sdr.cpp index 4168eeb1..6f4a012a 100644 --- a/utils/v4l2-ctl/v4l2-ctl-sdr.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-sdr.cpp @@ -122,10 +122,10 @@ void sdr_list(cv4l_fd &fd) { if (options[OptListSdrFormats]) { printf("ioctl: VIDIOC_ENUM_FMT\n"); - print_video_formats(fd, V4L2_BUF_TYPE_SDR_CAPTURE, 0); + print_video_formats(fd, V4L2_BUF_TYPE_SDR_CAPTURE, 0, false); } if (options[OptListSdrOutFormats]) { printf("ioctl: VIDIOC_ENUM_FMT\n"); - print_video_formats(fd, V4L2_BUF_TYPE_SDR_OUTPUT, 0); + print_video_formats(fd, V4L2_BUF_TYPE_SDR_OUTPUT, 0, false); } } diff --git a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp index d593b3b4..250511a1 100644 --- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp @@ -12,20 +12,26 @@ static __u32 ycbcr, quantization, xfer_func, colorspace; static __u32 bytesperline[VIDEO_MAX_PLANES]; static __u32 sizeimage[VIDEO_MAX_PLANES]; static unsigned mbus_code; +static bool enum_all; void vidcap_usage() { printf("\nVideo Capture Formats options:\n" - " --list-formats []\n" + " --list-formats [|all]\n" " display supported video formats. is an optional\n" " media bus code, if the device has capability V4L2_CAP_IO_MC\n" - " then only formats that support this media bus code are listed\n" + " then only formats that support this media bus code are listed.\n" + " When 'all' is specify it enumerates all pixel formats if\n" + " V4L2_FMTDESC_FLAG_ENUM_ALL flag is supported by the driver.\n" " [VIDIOC_ENUM_FMT]\n" - " --list-formats-ext []\n" + " --list-formats-ext [|all]\n" " display supported video formats including frame sizes and intervals\n" " is an optional media bus code, if the device has\n" " capability V4L2_CAP_IO_MC then only formats that support this\n" - " media bus code are listed [VIDIOC_ENUM_FMT]\n" + " media bus code are listed.\n" + " When 'all' is specify it enumerates all pixel formats if\n" + " V4L2_FMTDESC_FLAG_ENUM_ALL flag is supported by the driver.\n" + " [VIDIOC_ENUM_FMT]\n" " --list-framesizes \n" " list supported framesizes for pixelformat \n" " [VIDIOC_ENUM_FRAMESIZES]\n" @@ -113,8 +119,12 @@ void vidcap_cmd(int ch, char *optarg) break; case OptListFormats: case OptListFormatsExt: - if (optarg) - mbus_code = strtoul(optarg, nullptr, 0); + if (optarg) { + if (strstr(optarg , "all")) + enum_all = true; + else + mbus_code = strtoul(optarg, nullptr, 0); + } break; case OptListFrameSizes: be_pixfmt = strlen(optarg) == 7 && !memcmp(optarg + 4, "-BE", 3); @@ -331,12 +341,12 @@ void vidcap_list(cv4l_fd &fd) { if (options[OptListFormats]) { printf("ioctl: VIDIOC_ENUM_FMT\n"); - print_video_formats(fd, vidcap_buftype, mbus_code); + print_video_formats(fd, vidcap_buftype, mbus_code, enum_all); } if (options[OptListFormatsExt]) { printf("ioctl: VIDIOC_ENUM_FMT\n"); - print_video_formats_ext(fd, vidcap_buftype, mbus_code); + print_video_formats_ext(fd, vidcap_buftype, mbus_code, enum_all); } if (options[OptListFields]) { diff --git a/utils/v4l2-ctl/v4l2-ctl-vidout.cpp b/utils/v4l2-ctl/v4l2-ctl-vidout.cpp index 0d06f747..a9473bc6 100644 --- a/utils/v4l2-ctl/v4l2-ctl-vidout.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-vidout.cpp @@ -5,18 +5,25 @@ static __u32 width, height, pixfmt, field, colorspace, xfer_func, ycbcr, quantiz static __u32 bytesperline[VIDEO_MAX_PLANES]; static __u32 sizeimage[VIDEO_MAX_PLANES]; static unsigned mbus_code_out; +static bool enum_all; void vidout_usage() { printf("\nVideo Output Formats options:\n" - " --list-formats-out [] display supported video output formats.\n" + " --list-formats-out [|all] display supported video output formats.\n" " is an optional media bus code, if the device has\n" " capability V4L2_CAP_IO_MC then only formats that support this\n" - " media bus code are listed [VIDIOC_ENUM_FMT]\n" - " --list-formats-out-ext [] display supported video output formats including\n" + " media bus code are listed.\n" + " When 'all' is specify it enumerates all pixel formats if\n" + " V4L2_FMTDESC_FLAG_ENUM_ALL flag is supported by the driver.\n" + " [VIDIOC_ENUM_FMT]\n" + " --list-formats-out-ext [|all] display supported video output formats including\n" " frame sizes and intervals. is an optional media bus code,\n" " if the device has capability V4L2_CAP_IO_MC then only formats that\n" - " support this media bus code are listed [VIDIOC_ENUM_FMT]\n" + " support this media bus code are listed\n" + " When 'all' is specify it enumerates all pixel formats if\n" + " V4L2_FMTDESC_FLAG_ENUM_ALL flag is supported by the driver.\n" + " [VIDIOC_ENUM_FMT]\n" " --list-fields-out list supported fields for the current output format\n" " -X, --get-fmt-video-out\n" " query the video output format [VIDIOC_G_FMT]\n" @@ -93,8 +100,12 @@ void vidout_cmd(int ch, char *optarg) break; case OptListOutFormats: case OptListOutFormatsExt: - if (optarg) - mbus_code_out = strtoul(optarg, nullptr, 0); + if (optarg) { + if (strstr(optarg , "all")) + enum_all = true; + else + mbus_code_out = strtoul(optarg, nullptr, 0); + } break; } } @@ -226,12 +237,12 @@ void vidout_list(cv4l_fd &fd) { if (options[OptListOutFormats]) { printf("ioctl: VIDIOC_ENUM_FMT\n"); - print_video_formats(fd, vidout_buftype, mbus_code_out); + print_video_formats(fd, vidout_buftype, mbus_code_out, enum_all); } if (options[OptListOutFormatsExt]) { printf("ioctl: VIDIOC_ENUM_FMT\n"); - print_video_formats_ext(fd, vidout_buftype, mbus_code_out); + print_video_formats_ext(fd, vidout_buftype, mbus_code_out, enum_all); } if (options[OptListOutFields]) { diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index a64fa514..513ac8b7 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -602,7 +602,7 @@ void print_frmival(const struct v4l2_frmivalenum &frmival, const char *prefix) } } -void print_video_formats(cv4l_fd &fd, __u32 type, unsigned int mbus_code) +void print_video_formats(cv4l_fd &fd, __u32 type, unsigned int mbus_code, bool enum_all) { cv4l_disable_trace dt(fd); struct v4l2_fmtdesc fmt = {}; @@ -611,7 +611,7 @@ void print_video_formats(cv4l_fd &fd, __u32 type, unsigned int mbus_code) mbus_code = 0; printf("\tType: %s\n\n", buftype2s(type).c_str()); - if (fd.enum_fmt(fmt, true, 0, type, mbus_code)) + if (fd.enum_fmt(fmt, true, 0, type, mbus_code, enum_all)) return; do { printf("\t[%d]: '%s' (%s", fmt.index, fcc2s(fmt.pixelformat).c_str(), @@ -623,10 +623,10 @@ void print_video_formats(cv4l_fd &fd, __u32 type, unsigned int mbus_code) printf(", %s", fmtdesc2s(fmt.flags, is_hsv).c_str()); } printf(")\n"); - } while (!fd.enum_fmt(fmt)); + } while (!fd.enum_fmt(fmt, false, 0, type, mbus_code, enum_all)); } -void print_video_formats_ext(cv4l_fd &fd, __u32 type, unsigned int mbus_code) +void print_video_formats_ext(cv4l_fd &fd, __u32 type, unsigned int mbus_code, bool enum_all) { cv4l_disable_trace dt(fd); struct v4l2_fmtdesc fmt = {}; @@ -637,7 +637,7 @@ void print_video_formats_ext(cv4l_fd &fd, __u32 type, unsigned int mbus_code) mbus_code = 0; printf("\tType: %s\n\n", buftype2s(type).c_str()); - if (fd.enum_fmt(fmt, true, 0, type, mbus_code)) + if (fd.enum_fmt(fmt, true, 0, type, mbus_code, enum_all)) return; do { printf("\t[%d]: '%s' (%s", fmt.index, fcc2s(fmt.pixelformat).c_str(), @@ -649,6 +649,10 @@ void print_video_formats_ext(cv4l_fd &fd, __u32 type, unsigned int mbus_code) printf(", %s", fmtdesc2s(fmt.flags, is_hsv).c_str()); } printf(")\n"); + + if (enum_all) + continue; + if (fd.enum_framesizes(frmsize, fmt.pixelformat)) continue; do { @@ -664,7 +668,7 @@ void print_video_formats_ext(cv4l_fd &fd, __u32 type, unsigned int mbus_code) print_frmival(frmival, "\t\t"); } while (!fd.enum_frameintervals(frmival)); } while (!fd.enum_framesizes(frmsize)); - } while (!fd.enum_fmt(fmt)); + } while (!fd.enum_fmt(fmt,false, 0, type, mbus_code, enum_all)); } int parse_subopt(char **subs, const char * const *subopts, char **value) diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index a1911e80..d8c25da5 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -315,8 +315,8 @@ bool valid_pixel_format(int fd, __u32 pixelformat, bool output, bool mplane); void print_frmsize(const struct v4l2_frmsizeenum &frmsize, const char *prefix); void print_frmival(const struct v4l2_frmivalenum &frmival, const char *prefix); void printfmt(int fd, const struct v4l2_format &vfmt); -void print_video_formats(cv4l_fd &fd, __u32 type, unsigned int mbus_code); -void print_video_formats_ext(cv4l_fd &fd, __u32 type, unsigned int mbus_code); +void print_video_formats(cv4l_fd &fd, __u32 type, unsigned int mbus_code, bool enum_all); +void print_video_formats_ext(cv4l_fd &fd, __u32 type, unsigned int mbus_code, bool enum_all); static inline bool subscribe_event(cv4l_fd &fd, __u32 type) {