From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: laurent.pinchart@ideasonboard.com
Subject: [yavta PATCH 1/1] Print V4L2 fourcc code in format enumeration
Date: Fri, 26 Apr 2024 00:08:15 +0300 [thread overview]
Message-ID: <20240425210815.1820591-1-sakari.ailus@linux.intel.com> (raw)
Also print the V4L2 fourcc code in format enumeration (--enum-formats).
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
yavta.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/yavta.c b/yavta.c
index b2283aed09cb..2153e8b5775f 100644
--- a/yavta.c
+++ b/yavta.c
@@ -370,6 +370,18 @@ static struct v4l2_format_info {
{ "GENERIC_CSI2_24", V4L2_META_FMT_GENERIC_CSI2_24, 1 },
};
+void v4l2_format_fourcc(__u32 fourcc, char name[5])
+{
+ unsigned int i;
+
+ for (i = 0; i < 4; ++i) {
+ name[i] = fourcc & 0xff;
+ fourcc >>= 8;
+ }
+
+ name[4] = '\0';
+}
+
static void list_formats(void)
{
unsigned int i;
@@ -412,18 +424,13 @@ static const char *v4l2_format_name(unsigned int fourcc)
{
const struct v4l2_format_info *info;
static char name[5];
- unsigned int i;
info = v4l2_format_by_fourcc(fourcc);
if (info)
return info->name;
- for (i = 0; i < 4; ++i) {
- name[i] = fourcc & 0xff;
- fourcc >>= 8;
- }
+ v4l2_format_fourcc(fourcc, name);
- name[4] = '\0';
return name;
}
@@ -1815,6 +1822,8 @@ static void video_enum_formats(struct device *dev, enum v4l2_buf_type type)
int ret;
for (i = 0; ; ++i) {
+ char fourcc[5];
+
memset(&fmt, 0, sizeof fmt);
fmt.index = i;
fmt.type = type;
@@ -1829,8 +1838,10 @@ static void video_enum_formats(struct device *dev, enum v4l2_buf_type type)
printf("Warning: driver returned wrong format type "
"%u.\n", fmt.type);
- printf("\tFormat %u: %s (%08x)\n", i,
- v4l2_format_name(fmt.pixelformat), fmt.pixelformat);
+ v4l2_format_fourcc(fmt.pixelformat, fourcc);
+ printf("\tFormat %u: %s (%08x, \"%s\")\n", i,
+ v4l2_format_name(fmt.pixelformat), fmt.pixelformat,
+ fourcc);
printf("\tType: %s (%u)\n", v4l2_buf_type_name(fmt.type),
fmt.type);
printf("\tName: %.32s\n", fmt.description);
--
2.39.2
next reply other threads:[~2024-04-25 21:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-25 21:08 Sakari Ailus [this message]
2024-05-02 22:53 ` [yavta PATCH 1/1] Print V4L2 fourcc code in format enumeration Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240425210815.1820591-1-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).