lib/vsprintf: Add support for printing V4L2 and DRM fourccs
Subsystems (4)
PATCH v5 1/1 lib/vsprintf: Add support for printing V4L2 and DRM fourccs
Add a printk modifier %p4cc (for pixel format) for printing V4L2 and DRM pixel formats denoted by fourccs. The fourcc encoding is the same for both so the same implementation can be used.
---
since v4:
- Use correct destination for error string (was broken in v4)
- Remove unneeded comment "/* subtract parenthesis and the space from the size */".
Documentation/core-api/printk-formats.rst | 16 +++++++ lib/test_printf.c | 17 ++++++++ lib/vsprintf.c | 51 +++++++++++++++++++++++ 3 files changed, 84 insertions(+)
Documentation/core-api/printk-formats.rst +16 -0
@@ -565,6 +565,22 @@ 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, including format endianness and +its numerical value as hexadecimal. + +Passed by reference. + +Examples:: + + %p4cc BG12 little-endian (0x32314742) + Thanks ======
lib/test_printf.c +17 -0
@@ -649,6 +649,22 @@ static void __init fwnode_pointer(void)software_node_unregister (&softnodes[0 ]); } +static void __init fourcc_pointer (void ) +{ +struct { +u32 code; +char *str; + }const try[] = { + {0x20104646 ,"FF(10) little-endian (0x20104646)" , }, + {0xa0104646 ,"FF(10) big-endian (0xa0104646)" , }, + {0x10111213 ,"(13)(12)(11)(10) little-endian (0x10111213)" , }, + }; +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (try); i++) +test (try[i].str,"%p4cc" , &try[i].code); +} +static void __init errptr (void ) {
@@ -694,6 +710,7 @@ test_pointer(void)flags ();errptr ();fwnode_pointer (); +fourcc_pointer (); }static void __init selftest (void )
lib/vsprintf.c +51 -0
69 lines not on this page · raw message
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Sakari Ailus
Add a printk modifier %p4cc (for pixel format) for printing V4L2 and DRM pixel formats denoted by fourccs. The fourcc encoding is the same for both so the same implementation can be used.
Suggested-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Sakari Ailus <[email protected]>
The last version looks fine to me.
Best Regards,
Petr
Sergey Senozhatsky
Reviewed-byQuoted 11 lines · Petr Mladek
Quoted 6 lines · Sakari Ailus
Add a printk modifier %p4cc (for pixel format) for printing V4L2 and DRM pixel formats denoted by fourccs. The fourcc encoding is the same for both so the same implementation can be used.
Suggested-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Sakari Ailus <[email protected]>The last version looks fine to me.
Reviewed-by Petr Mladek <[email protected]>
-ss
Petr Mladek
maintainerQuoted 6 lines · Sakari Ailus
Add a printk modifier %p4cc (for pixel format) for printing V4L2 and DRM pixel formats denoted by fourccs. The fourcc encoding is the same for both so the same implementation can be used.
Suggested-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Sakari Ailus <[email protected]>
Andy, Rasmus,
the last version looks fine to me. I am going to push it. Please, speak up if you are against it.
Best Regards,
Petr
Quoted 5 lines · Petr Mladek
Quoted 4 lines · Sakari Ailus
Add a printk modifier %p4cc (for pixel format) for printing V4L2 and DRM pixel formats denoted by fourccs. The fourcc encoding is the same for both so the same implementation can be used.
Quoted 7 lines
Quoted 2 lines
Suggested-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Sakari Ailus <[email protected]>Andy, Rasmus,
the last version looks fine to me. I am going to push it. Please, speak up if you are against it.
My concerns are:
- not so standard format of representation (why not to use string_escape_mem() helper?) or is it?
- no compatibility with generic 4cc
(I would rather have an additional specifier here for v4l2 cases.
OTOH generic %p4cc to me sounds like an equivalent to %4pEh (but we have similar cases with MAC where %6ph is the same as %pM).
But I'm not insisting on them, consider it like just my 2 cents to the discussion.
Signature · 6 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Andy,
Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Petr Mladek
Quoted 6 lines · Sakari Ailus
Add a printk modifier %p4cc (for pixel format) for printing V4L2 and DRM pixel formats denoted by fourccs. The fourcc encoding is the same for both so the same implementation can be used.
Suggested-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Sakari Ailus <[email protected]>
Quoted 8 lines
Quoted 4 lines
Andy, Rasmus,
the last version looks fine to me. I am going to push it. Please, speak up if you are against it.
My concerns are:
- not so standard format of representation (why not to usestring_escape_mem()helper?) or is it?
The format string may contain spaces that are not meant to be printed. Other unprintable chacaters should not be present (at least not in V4L2 pixelformats). The hexadecimal representation is there to convey the numerical value and that originally came from DRM, not V4L2.
Quoted 2 lines
- no compatibility with generic 4cc
(I would rather have an additional specifier here for v4l2 cases.
What do you mean by "generic 4cc"? There are two users of 4cc codes in the kernel that I know of: V4L2 and DRM. Something that does not refer to in-memory pixel formats?
Quoted 5 lines
OTOH generic %p4cc to me sounds like an equivalent to %4pEh (but we have similar cases with MAC where %6ph is the same as %pM).
But I'm not insisting on them, consider it like just my 2 cents to the discussion.
Ack.
Signature · 7 lines
Kind regards, Sakari Ailus _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 15 lines · Sakari Ailus
Quoted 14 lines · Andy Shevchenko
Quoted 12 lines · Petr Mladek
Quoted 6 lines · Sakari Ailus
Add a printk modifier %p4cc (for pixel format) for printing V4L2 and DRM pixel formats denoted by fourccs. The fourcc encoding is the same for both so the same implementation can be used.
Suggested-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Sakari Ailus <[email protected]>Andy, Rasmus,
the last version looks fine to me. I am going to push it. Please, speak up if you are against it.
Quoted 8 lines
Quoted 3 lines
My concerns are:
- not so standard format of representation (why not to usestring_escape_mem()helper?) or is it?The format string may contain spaces that are not meant to be printed. Other unprintable chacaters should not be present (at least not in V4L2 pixelformats). The hexadecimal representation is there to convey the numerical value and that originally came from DRM, not V4L2.
Yes, but I mean that we usually anticipate the escaped characters in a form of '\xNN' (hex) or '\NNN' (octal). The format '(NN)' is quite unusual to me.
Quoted 6 lines
Quoted 2 lines
- no compatibility with generic 4cc
(I would rather have an additional specifier here for v4l2 cases.What do you mean by "generic 4cc"? There are two users of 4cc codes in the kernel that I know of: V4L2 and DRM. Something that does not refer to in-memory pixel formats?
Of course. Everything else. 4cc is a generic term to describe something which is of 4 characters long [1]. It's not limited by media file formats. And moreover some (chip) vendors are using it as well (Synopsys). Microsoft uses 4cc in CSRT ACPI table for vendor field and so on...
[1]: https://en.wikipedia.org/wiki/FourCC
Signature · 8 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Petr Mladek
maintainerQuoted 6 lines · Andy Shevchenko
Quoted 5 lines · Sakari Ailus
Quoted 3 lines · Andy Shevchenko
My concerns are:
- not so standard format of representation (why not to usestring_escape_mem()helper?) or is it?
Quoted 7 lines
Quoted 4 lines
The format string may contain spaces that are not meant to be printed. Other unprintable chacaters should not be present (at least not in V4L2 pixelformats). The hexadecimal representation is there to convey the numerical value and that originally came from DRM, not V4L2.
Yes, but I mean that we usually anticipate the escaped characters in a form of '\xNN' (hex) or '\NNN' (octal). The format '(NN)' is quite unusual to me.
It is true that I have been a bit confused when I saw it.
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
- no compatibility with generic 4cc
(I would rather have an additional specifier here for v4l2 cases.What do you mean by "generic 4cc"? There are two users of 4cc codes in the kernel that I know of: V4L2 and DRM. Something that does not refer to in-memory pixel formats?
Of course. Everything else. 4cc is a generic term to describe something which is of 4 characters long [1]. It's not limited by media file formats. And moreover some (chip) vendors are using it as well (Synopsys). Microsoft uses 4cc in CSRT ACPI table for vendor field and so on...
Honestly, I do not even know where exactly it is going to be used.
I did not have strong opinion. So I just followed the long discussions about previous revisions. Some people loved it from the beginning. Some people were concerned. Anyway, there were discussed only implementation details in the last two revisions, so I assumed that the idea was more or less accepted.
Would it help to send another revision with some existing DRM and V4L2 code converted to use it?
It would help me/us to see how much different it is from the current output. Also it will require ack from the affected subsystem maintainers and developers.
Best Regqrds,
Petr