From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Petr Mladek <pmladek@suse.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-media@vger.kernel.org,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com,
mchehab@kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Joe Perches <joe@perches.com>,
Jani Nikula <jani.nikula@linux.intel.com>
Subject: Re: [PATCH v2 1/1] lib/vsprintf: Add support for printing V4L2 and DRM fourccs
Date: Mon, 6 Apr 2020 10:28:58 +0300 [thread overview]
Message-ID: <20200406072857.GD5835@kekkonen.localdomain> (raw)
In-Reply-To: <1105bfe5-88f1-040e-db40-54d7761747d5@rasmusvillemoes.dk>
Hi Rasmus,
Thanks for the comments.
On Fri, Apr 03, 2020 at 02:10:53PM +0200, Rasmus Villemoes wrote:
> On 03/04/2020 11.11, Sakari Ailus wrote:
> > Add a printk modifier %ppf (for pixel format) for printing V4L2 and DRM
> > pixel formats denoted by 4ccs. The 4cc encoding is the same for both so
> > the same implementation can be used.
>
> This seems quite niche to me, I'm not sure that belongs in vsprintf.c.
> What's wrong with having a
>
> char *fourcc_string(char *buf, u32 x)
>
> that formats x into buf and returns buf, so it can be used in a
>
> char buf[8];
> pr_debug("bla: %s\n", fourcc_string(buf, x))
I guess that could be one option. But changing the implementation could
require changing the size of all those buffers.
We had this approach, too:
<URL:https://lore.kernel.org/linux-media/20190916100433.24367-1-hverkuil-cisco@xs4all.nl/>
Let's see if we'll get more comments on this.
>
> Or, for that matter, since it's for debugging, why not just print x with
> 0x%08x?
People generally prefer readable output that they can understand. The codes
are currently being printed in characters, and that's how they are defined
in kernel headers, too. Therefore the hexadecimal values are of secondary
importance (although they could be printed too, as apparently a similar
function in DRM does).
>
> At the very least, the "case '4'" in pointer() should be guarded by
> appropriate CONFIG_*.
>
> Good that Documentation/ gets updated, but test_printf needs updating as
> well.
Agreed.
>
>
> > Suggested-by: Mauro Carvalho Chehab <mchehab@kernel.org>
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> > since v1:
> >
> > - Improve documentation (add -BE suffix, refer to "FourCC".
> >
> > - Use '%p4cc' conversion specifier instead of '%ppf'.
>
> Cute. Remember to update the commit log (which still says %ppf).
I will.
>
> > - Fix 31st bit handling in printing FourCC codes.
> >
> > - Use string() correctly, to allow e.g. proper field width handling.
> >
> > - Remove loop, use put_unaligned_le32() instead.
> >
> > Documentation/core-api/printk-formats.rst | 12 +++++++++++
> > lib/vsprintf.c | 25 +++++++++++++++++++++++
> > 2 files changed, 37 insertions(+)
> >
> > diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
> > index 8ebe46b1af39..550568520ab6 100644
> > --- a/Documentation/core-api/printk-formats.rst
> > +++ b/Documentation/core-api/printk-formats.rst
> > @@ -545,6 +545,18 @@ For printing netdev_features_t.
> >
> > Passed by reference.
> >
> > +V4L2 and DRM FourCC code (pixel format)
> > +---------------------------------------
> > +
> > +::
> > +
> > + %p4cc
> > +
> > +Print a FourCC code used by V4L2 or DRM. The "-BE" suffix is added on big endian
> > +formats.
> > +
> > +Passed by reference.
>
> Maybe it's obvious to anyone in that business, but perhaps make it more
> clear the 4cc is stored in a u32 (and not, e.g., a __le32 or some other
> integer), that obviously matters when the code treats the pointer as a u32*.
The established practice is to use u32 (as this is really no hardware
involved) but I guess it'd be good to document that here, too.
> > +
> > + put_unaligned_le32(*fourcc & ~BIT(31), s);
> > +
> > + if (*fourcc & BIT(31))
> > + strscpy(s + sizeof(*fourcc), FOURCC_STRING_BE,
> > + sizeof(FOURCC_STRING_BE));
>
> put_unaligned_le32(0x0045422d, s + 4) probably generates smaller code,
> and is more in line with building the first part of the string with
> put_unaligned_le32().
Uh. The fourcc code is made of printable characters (apart from the 31st
bit) so it can be printed, but I wouldn't use that here. "-BE" is just a
string and not related to 4ccs.
--
Regards,
Sakari Ailus
next prev parent reply other threads:[~2020-04-06 7:29 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-03 9:11 Sakari Ailus
2020-04-03 9:31 ` Andy Shevchenko
2020-04-03 9:39 ` Sakari Ailus
2020-04-03 9:54 ` Andy Shevchenko
2020-04-03 10:10 ` Sakari Ailus
2020-04-03 10:24 ` Laurent Pinchart
2020-04-03 10:47 ` Sakari Ailus
2020-04-03 11:19 ` Mauro Carvalho Chehab
2020-04-03 11:54 ` Andy Shevchenko
2020-04-03 18:38 ` Joe Perches
2020-04-03 23:36 ` Sakari Ailus
2020-04-03 23:55 ` Joe Perches
2020-04-03 12:10 ` Rasmus Villemoes
2020-04-03 14:22 ` Mauro Carvalho Chehab
2020-04-03 16:56 ` Joe Perches
2020-04-03 17:32 ` Mauro Carvalho Chehab
2020-04-03 17:48 ` Joe Perches
2020-04-03 18:32 ` Andy Shevchenko
2020-04-04 0:14 ` Sakari Ailus
2020-04-04 0:21 ` Laurent Pinchart
2020-04-06 7:17 ` Sakari Ailus
2020-04-06 7:46 ` Mauro Carvalho Chehab
2020-04-06 10:44 ` Andy Shevchenko
2020-04-06 13:01 ` Joe Perches
2020-04-06 7:28 ` Sakari Ailus [this message]
2020-04-06 7:37 ` Jani Nikula
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=20200406072857.GD5835@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hverkuil@xs4all.nl \
--cc=jani.nikula@linux.intel.com \
--cc=joe@perches.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mchehab@kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
/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
all inboxes | Powered by JetHome®