Add %p4cc printk modifier for V4L2 and DRM fourcc codes
Subsystems (21)
v7 cover Add %p4cc printk modifier for V4L2 and DRM fourcc codes
Hi all,
This set adds support for %p4cc printk modifier for printing V4L2 and DRM fourcc codes. The codes are cumbersome to print manually and by adding the modifier, this task is saved from the V4L2 and DRM frameworks as well as related drivers. DRM actually had it handled in a way (see 3rd patch) but the printk modifier makes printing the format easier even there. On V4L2 side it saves quite a few lines of repeating different implementations of printing the 4cc codes.
Further work will include converting the V4L2 drivers doing the same, as well as converting DRM drivers from drm_get_format_name() to plain %p4cc. I left these out from this version since individual drivers are easier changed without dealing with multiple trees.
If DRM folks would prefer to convert drivers to %p4cc directly instead I have no problem dropping the 3rd patch. Nearly all uses in DRM are in printk family of functions that can readily use %p4cc instead of the current arrangement that relies on caller-allocated temporary buffer.
Since v6:
- Don't drop spaces in fourcc codes.
- Print unprintable characters as dot ('.') instead of hexadecimal number in parentheses.
- Convert DRM from drm_get_format_name() to %p4cc. I wonder if this should be merged through the DRM tree, albeit it's probably unlikely to conflict with other changes. Further use of the function could be a problem.
- Make tests more realistic.
Since v5:
- Added V4L2 core conversion to %p4cc, as well as change the DRM fourcc printing function to use %p4cc.
- Add missing checkpatch.pl checks for %p4cc modifier.
Sakari Ailus (3):
lib/vsprintf: Add support for printing V4L2 and DRM fourccs
v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
drm: Switch to %p4cc format modifier
Documentation/core-api/printk-formats.rst | 16 ++++ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 5 +- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 5 +- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 5 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 5 +- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +- .../arm/display/komeda/komeda_format_caps.h | 11 --- .../arm/display/komeda/komeda_framebuffer.c | 4 +- .../gpu/drm/arm/display/komeda/komeda_plane.c | 6 +- drivers/gpu/drm/arm/malidp_mw.c | 7 +- drivers/gpu/drm/drm_atomic.c | 8 +- drivers/gpu/drm/drm_crtc.c | 7 +- drivers/gpu/drm/drm_fourcc.c | 25 ------ drivers/gpu/drm/drm_framebuffer.c | 11 +-- drivers/gpu/drm/drm_mipi_dbi.c | 5 +- drivers/gpu/drm/drm_plane.c | 8 +- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 5 +- drivers/gpu/drm/i915/display/intel_display.c | 14 +-- .../drm/i915/display/intel_display_debugfs.c | 19 ++--- drivers/gpu/drm/i915/display/intel_sprite.c | 6 +- drivers/gpu/drm/mcde/mcde_display.c | 6 +- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 6 +- drivers/gpu/drm/nouveau/nouveau_display.c | 9 +- drivers/gpu/drm/radeon/atombios_crtc.c | 10 +-- drivers/gpu/drm/sun4i/sun4i_backend.c | 6 +- drivers/gpu/drm/vkms/vkms_writeback.c | 7 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 15 ++-- drivers/media/v4l2-core/v4l2-ioctl.c | 85 +++++-------------- include/drm/drm_fourcc.h | 1 - lib/test_printf.c | 17 ++++ lib/vsprintf.c | 39 +++++++++ scripts/checkpatch.pl | 6 +- 32 files changed, 161 insertions(+), 223 deletions(-)
Signature · 5 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v7 1/3 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.
--- Documentation/core-api/printk-formats.rst | 16 ++++++++++ lib/test_printf.c | 17 ++++++++++ lib/vsprintf.c | 39 +++++++++++++++++++++++ scripts/checkpatch.pl | 6 ++-- 4 files changed, 76 insertions(+), 2 deletions(-)
Documentation/core-api/printk-formats.rst +16 -0
@@ -567,6 +567,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
@@ -647,6 +647,22 @@ static void __init fwnode_pointer(void)software_node_unregister_nodes (softnodes); } +static void __init fourcc_pointer (void ) +{ +struct { +u32 code; +char *str; + }const try[] = { + {0x3231564e ,"NV12 little-endian (0x3231564e)" , }, + {0xb231564e ,"NV12 big-endian (0xb231564e)" , }, + {0x10111213 ,".... 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 ) {
@@ -692,6 +708,7 @@ test_pointer(void)flags ();errptr ();fwnode_pointer (); +fourcc_pointer (); }static void __init selftest (void )
lib/vsprintf.c +39 -0
@@ -1733,6 +1733,42 @@ char *netdev_bits(char *buf, char *end, const void *addr,return special_hex_number (buf, end, num, size); } +static noinline_for_stack +char *fourcc_string(char *buf, char *end, const u32 *fourcc, +struct printf_spec spec,const char *fmt) +{ +char output[sizeof ("1234 little-endian (0x01234567)" )]; +char *p = output; +unsigned int i; +u32 val; + +if (fmt[1 ] !='c' || fmt[2 ] !='c' ) +return error_string (buf, end,"(%p4?)" , spec); + +if (check_pointer (&buf, end, fourcc, spec)) +return buf; + + val = *fourcc & ~BIT (31 ); + +for (i =0 ; i <sizeof (*fourcc); i++) { +unsigned char c = val >> (i *8 ); + +/* Print non-control ASCII characters as-is, dot otherwise */ + *p++ =isascii (c) &&isprint (c) ? c :'.' ; + } + +strcpy (p, *fourcc &BIT (31 ) ?" big-endian" :" little-endian" ); + p +=strlen (p); + + *p++ =' ' ; + *p++ ='(' ; + p =special_hex_number (p, output +sizeof (output) -2 , *fourcc,sizeof (u32)); + *p++ =')' ; + *p ='\0' ; + +return string (buf, end, output, spec); +} +static noinline_for_stack char *address_val(char *buf, char *end, const void *addr,struct printf_spec spec,const char *fmt)
@@ -2162,6 +2198,7 @@ char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode,* correctness of the format string and va_list arguments. * - 'K' For a kernel pointer that should be hidden from unprivileged users * - 'NF' For a netdev_features_t +* - '4cc' V4L2 or DRM FourCC code, with endianness and raw numerical value. * - 'h[CDN]' For a variable-length buffer, it prints it as a hex string with * a certain separator (' ' by default): * C colon
@@ -2259,6 +2296,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,return restricted_pointer (buf, end, ptr, spec);case 'N' :return netdev_bits (buf, end, ptr, spec, fmt); +case '4' : +return fourcc_string (buf, end, ptr, spec, fmt);case 'a' :return address_val (buf, end, ptr, spec, fmt);case 'd' :
scripts/checkpatch.pl +4 -2
@@ -6557,9 +6557,11 @@ sub process { $specifier = $1; $extension = $2; $qualifier = $3; - if ($extension !~ /[SsBKRraEehMmIiUDdgVCbGNOxtf]/ || + if ($extension !~ /[4SsBKRraEehMmIiUDdgVCbGNOxtf]/ || ($extension eq "f" && - defined $qualifier && $qualifier !~ /^w/)) { + defined $qualifier && $qualifier !~ /^w/) || + ($extension eq "4" && + defined $qualifier && $qualifier !~ /^cc/)) { $bad_specifier = $specifier; last; }
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 1/3] lib/vsprintf: Add support for printing V4L2 and DRM fourccs
Quoted 3 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.
This version I almost like, feel free to add
after considering addressing below nit-picks.
Quoted 24 lines
Suggested-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Sakari Ailus <[email protected]>Reviewed-by Petr Mladek <[email protected]>Reviewed-by Sergey Senozhatsky <[email protected]>--- Documentation/core-api/printk-formats.rst | 16 ++++++++++ lib/test_printf.c | 17 ++++++++++ lib/vsprintf.c | 39 +++++++++++++++++++++++ scripts/checkpatch.pl | 6 ++-- 4 files changed, 76 insertions(+), 2 deletions(-)Documentation/core-api/printk-formats.rst +5
-0@@ -567,6 +567,22 @@ For printing netdev_features_t. Passed by reference. +V4L2 and DRM FourCC code (pixel format) +--------------------------------------- + +:: +
Documentation/core-api/printk-formats.rst For printing netdev_features_t. · line 584
Quoted 10 lines
Documentation/core-api/printk-formats.rst +10
-0+ %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)
No examples with spaces / non-printable / non-ascii characters
Quoted 44 lines
Documentation/core-api/printk-formats.rst +1
-0+ Thanks ======lib/test_printf.c +17
-0@@ -647,6 +647,22 @@ static void __init fwnode_pointer(void)software_node_unregister_nodes (softnodes); } +static void __init fourcc_pointer (void ) +{ +struct { +u32 code; +char *str; + }const try[] = { + {0x3231564e ,"NV12 little-endian (0x3231564e)" , }, + {0xb231564e ,"NV12 big-endian (0xb231564e)" , }, + {0x10111213 ,".... 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 ) {@@ -692,6 +708,7 @@ test_pointer(void)flags ();errptr ();fwnode_pointer (); +fourcc_pointer (); }static void __init selftest (void )lib/vsprintf.c +0
-0
lib/vsprintf.c char *netdev_bits(char *buf, char *end, const void *addr, · line 1740
Quoted 8 lines
lib/vsprintf.c +5
-0@@ -1733,6 +1733,42 @@ char *netdev_bits(char *buf, char *end, const void *addr,return special_hex_number (buf, end, num, size); } +static noinline_for_stack +char *fourcc_string(char *buf, char *end, const u32 *fourcc, +struct printf_spec spec,const char *fmt) +{ +char output[sizeof ("1234 little-endian (0x01234567)" )];
1234 -> ABCD ? (Or XY12 to be closer to the reality)
Quoted 72 lines
lib/vsprintf.c +34
-0+char *p = output; +unsigned int i; +u32 val; + +if (fmt[1 ] !='c' || fmt[2 ] !='c' ) +return error_string (buf, end,"(%p4?)" , spec); + +if (check_pointer (&buf, end, fourcc, spec)) +return buf; + + val = *fourcc & ~BIT (31 ); + +for (i =0 ; i <sizeof (*fourcc); i++) { +unsigned char c = val >> (i *8 ); + +/* Print non-control ASCII characters as-is, dot otherwise */ + *p++ =isascii (c) &&isprint (c) ? c :'.' ; + } + +strcpy (p, *fourcc &BIT (31 ) ?" big-endian" :" little-endian" ); + p +=strlen (p); + + *p++ =' ' ; + *p++ ='(' ; + p =special_hex_number (p, output +sizeof (output) -2 , *fourcc,sizeof (u32)); + *p++ =')' ; + *p ='\0' ; + +return string (buf, end, output, spec); +} +static noinline_for_stack char *address_val(char *buf, char *end, const void *addr,struct printf_spec spec,const char *fmt)@@ -2162,6 +2198,7 @@ char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode,* correctness of the format string and va_list arguments. * - 'K' For a kernel pointer that should be hidden from unprivileged users * - 'NF' For a netdev_features_t +* - '4cc' V4L2 or DRM FourCC code, with endianness and raw numerical value. * - 'h[CDN]' For a variable-length buffer, it prints it as a hex string with * a certain separator (' ' by default): * C colon @@ -2259,6 +2296,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,return restricted_pointer (buf, end, ptr, spec);case 'N' :return netdev_bits (buf, end, ptr, spec, fmt); +case '4' : +return fourcc_string (buf, end, ptr, spec, fmt);case 'a' :return address_val (buf, end, ptr, spec, fmt);case 'd' :scripts/checkpatch.pl +4
-2@@ -6557,9 +6557,11 @@ sub process { $specifier = $1; $extension = $2; $qualifier = $3; - if ($extension !~ /[SsBKRraEehMmIiUDdgVCbGNOxtf]/ || + if ($extension !~ /[4SsBKRraEehMmIiUDdgVCbGNOxtf]/ || ($extension eq "f" && - defined $qualifier && $qualifier !~ /^w/)) { + defined $qualifier && $qualifier !~ /^w/) || + ($extension eq "4" && + defined $qualifier && $qualifier !~ /^cc/)) { $bad_specifier = $specifier; last; }Signature · 1 line
2.29.2
Signature · 8 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 1/3] lib/vsprintf: Add support for printing V4L2 and DRM fourccs
Hi Andy,
Quoted 37 lines · Andy Shevchenko
Quoted 3 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.
This version I almost like, feel free to add
Reviewed-by From: Andy Shevchenko <[email protected]>after considering addressing below nit-picks.
Quoted 28 lines
Suggested-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Sakari Ailus <[email protected]>Reviewed-by Petr Mladek <[email protected]>Reviewed-by Sergey Senozhatsky <[email protected]>--- Documentation/core-api/printk-formats.rst | 16 ++++++++++ lib/test_printf.c | 17 ++++++++++ lib/vsprintf.c | 39 +++++++++++++++++++++++ scripts/checkpatch.pl | 6 ++-- 4 files changed, 76 insertions(+), 2 deletions(-)Documentation/core-api/printk-formats.rst +9
-0@@ -567,6 +567,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.
Quoted 8 lines
Documentation/core-api/printk-formats.rst For printing netdev_features_t. · line 584
Quoted 6 lines
Documentation/core-api/printk-formats.rst +6
-0+ +Passed by reference. + +Examples:: + + %p4cc BG12 little-endian (0x32314742)No examples with spaces / non-printable / non-ascii characters
I can sure add an example that has a space. But do you think I really should add an example where invalid information is being printed?
Quoted 48 lines
Quoted 48 lines
Documentation/core-api/printk-formats.rst +1
-0+ Thanks ======lib/test_printf.c +17
-0@@ -647,6 +647,22 @@ static void __init fwnode_pointer(void)software_node_unregister_nodes (softnodes); } +static void __init fourcc_pointer (void ) +{ +struct { +u32 code; +char *str; + }const try[] = { + {0x3231564e ,"NV12 little-endian (0x3231564e)" , }, + {0xb231564e ,"NV12 big-endian (0xb231564e)" , }, + {0x10111213 ,".... 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 ) {@@ -692,6 +708,7 @@ test_pointer(void)flags ();errptr ();fwnode_pointer (); +fourcc_pointer (); }static void __init selftest (void )lib/vsprintf.c +0
-0@@ -1733,6 +1733,42 @@ char *netdev_bits(char *buf, char *end, const void *addr,return special_hex_number (buf, end, num, size); }
Quoted 7 lines
lib/vsprintf.c char *netdev_bits(char *buf, char *end, const void *addr, · line 1740
Quoted 5 lines
lib/vsprintf.c +5
-0+static noinline_for_stack +char *fourcc_string(char *buf, char *end, const u32 *fourcc, +struct printf_spec spec,const char *fmt) +{ +char output[sizeof ("1234 little-endian (0x01234567)" )];1234 -> ABCD ? (Or XY12 to be closer to the reality)
I count in numbers... albeit the hexadecimal number there starts from zero.
I guess both would work though.
0123 would be consistent.
Signature · 7 lines
Regards, Sakari Ailus _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Andy Shevchenko
reviewerRe: [PATCH v7 1/3] lib/vsprintf: Add support for printing V4L2 and DRM fourccs
Quoted 10 lines · Sakari Ailus
Quoted 8 lines · Andy Shevchenko
Quoted 3 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.
This version I almost like, feel free to add
Reviewed-by From: Andy Shevchenko <[email protected]>after considering addressing below nit-picks.
Quoted 8 lines
Quoted 5 lines
Documentation/core-api/printk-formats.rst For printing netdev_features_t. · line 584
Quoted 3 lines
Documentation/core-api/printk-formats.rst +3
-0+Examples:: + + %p4cc BG12 little-endian (0x32314742)No examples with spaces / non-printable / non-ascii characters
I can sure add an example that has a space. But do you think I really should add an example where invalid information is being printed?
I think you have to provide better coverage of what user can get out of this. Perhaps one example with space and non-printable character is enough.
Quoted 9 lines
Quoted 3 lines
lib/vsprintf.c char *netdev_bits(char *buf, char *end, const void *addr, · line 1740
Quoted 1 line
lib/vsprintf.c +1
-0+char output[sizeof ("1234 little-endian (0x01234567)" )];1234 -> ABCD ? (Or XY12 to be closer to the reality)
I count in numbers... albeit the hexadecimal number there starts from zero.
I guess both would work though.
0123 would be consistent.
Since letters can be printed the above is confusing a bit. I think XY12 is closer to the reality than 0123.
Signature · 8 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 1/3] lib/vsprintf: Add support for printing V4L2 and DRM fourccs
Quoted 27 lines · Andy Shevchenko
Quoted 10 lines · Sakari Ailus
Quoted 8 lines · Andy Shevchenko
Quoted 3 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.
This version I almost like, feel free to add
Reviewed-by From: Andy Shevchenko <[email protected]>after considering addressing below nit-picks.
Quoted 8 lines
Quoted 5 lines
Documentation/core-api/printk-formats.rst For printing netdev_features_t. · line 584
Quoted 3 lines
Documentation/core-api/printk-formats.rst +3
-0+Examples:: + + %p4cc BG12 little-endian (0x32314742)No examples with spaces / non-printable / non-ascii characters
I can sure add an example that has a space. But do you think I really should add an example where invalid information is being printed?
I think you have to provide better coverage of what user can get out of this. Perhaps one example with space and non-printable character is enough.
Quoted 4 lines
Quoted 3 lines
lib/vsprintf.c char *netdev_bits(char *buf, char *end, const void *addr, · line 1740
Quoted 1 line
lib/vsprintf.c +1
-0+char output[sizeof ("1234 little-endian (0x01234567)" )];1234 -> ABCD ? (Or XY12 to be closer to the reality)
Quoted 8 lines
Quoted 5 lines
I count in numbers... albeit the hexadecimal number there starts from zero.
I guess both would work though.
0123 would be consistent.
Since letters can be printed the above is confusing a bit. I think XY12 is closer to the reality than 0123.
Ailus, are you going to send v8 with the two small changes? I mean a selftest with the space and the above sample code.
Anyway, feel free to add:
Best Regards,
Petr
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 1/3] lib/vsprintf: Add support for printing V4L2 and DRM fourccs
Hi Petr,
Quoted 32 lines · Petr Mladek
Quoted 31 lines · Andy Shevchenko
Quoted 10 lines · Sakari Ailus
Quoted 8 lines · Andy Shevchenko
Quoted 3 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.
This version I almost like, feel free to add
Reviewed-by From: Andy Shevchenko <[email protected]>after considering addressing below nit-picks.
Quoted 8 lines
Quoted 5 lines
Documentation/core-api/printk-formats.rst For printing netdev_features_t. · line 584
Quoted 3 lines
Documentation/core-api/printk-formats.rst +3
-0+Examples:: + + %p4cc BG12 little-endian (0x32314742)No examples with spaces / non-printable / non-ascii characters
I can sure add an example that has a space. But do you think I really should add an example where invalid information is being printed?
I think you have to provide better coverage of what user can get out of this. Perhaps one example with space and non-printable character is enough.
Quoted 8 lines
Quoted 3 lines
lib/vsprintf.c char *netdev_bits(char *buf, char *end, const void *addr, · line 1740
Quoted 1 line
lib/vsprintf.c +1
-0+char output[sizeof ("1234 little-endian (0x01234567)" )];1234 -> ABCD ? (Or XY12 to be closer to the reality)
I count in numbers... albeit the hexadecimal number there starts from zero.
I guess both would work though.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
0123 would be consistent.
Since letters can be printed the above is confusing a bit. I think XY12 is closer to the reality than 0123.
Ailus, are you going to send v8 with the two small changes? I mean a selftest with the space and the above sample code.
Yes, and a few more examples.
Quoted 4 lines
Anyway, feel free to add:
Reviewed-by Petr Mladek <[email protected]>
Thank you.
It'd be great if we could merge this through the printk tree. Acks are needed from the DRM people first.
Signature · 7 lines
Regards, Sakari Ailus _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v7 2/3 v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
In reply to Sakari AilusNow that we can print FourCC codes directly using printk, make use of the feature in V4L2 core.
--- drivers/media/v4l2-core/v4l2-ioctl.c | 85 +++++++--------------------- 1 file changed, 21 insertions(+), 64 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +21 -64
@@ -265,13 +265,9 @@ static void v4l_print_fmtdesc(const void *arg, bool write_only) {const struct v4l2_fmtdesc *p = arg; -pr_cont ("index=%u, type=%s, flags=0x%x, pixelformat=%c%c%c%c, mbus_code=0x%04x, description='%.*s'\n" , +pr_cont ("index=%u, type=%s, flags=0x%x, pixelformat=%p4cc, mbus_code=0x%04x, description='%.*s'\n" , p->index,prt_names (p->type, v4l2_type_names), - p->flags, (p->pixelformat &0xff ), - (p->pixelformat >>8 ) &0xff , - (p->pixelformat >>16 ) &0xff , - (p->pixelformat >>24 ) &0xff , - p->mbus_code, + p->flags, &p->pixelformat, p->mbus_code, (int )sizeof (p->description), p->description); }
@@ -293,12 +289,8 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_VIDEO_CAPTURE :case V4L2_BUF_TYPE_VIDEO_OUTPUT : pix = &p->fmt.pix; - pr_cont(", width=%u, height=%u, pixelformat=%c%c%c%c, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n", - pix->width, pix->height, - (pix->pixelformat & 0xff), - (pix->pixelformat >> 8) & 0xff, - (pix->pixelformat >> 16) & 0xff, - (pix->pixelformat >> 24) & 0xff, + pr_cont(", width=%u, height=%u, pixelformat=%p4cc, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n", + pix->width, pix->height, &pix->pixelformat, prt_names(pix->field, v4l2_field_names), pix->bytesperline, pix->sizeimage, pix->colorspace, pix->flags, pix->ycbcr_enc,
@@ -307,12 +299,8 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE :case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : mp = &p->fmt.pix_mp; -pr_cont (", width=%u, height=%u, format=%c%c%c%c, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n" , - mp->width, mp->height, - (mp->pixelformat &0xff ), - (mp->pixelformat >>8 ) &0xff , - (mp->pixelformat >>16 ) &0xff , - (mp->pixelformat >>24 ) &0xff , +pr_cont (", width=%u, height=%u, format=%p4cc, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n" , + mp->width, mp->height, &mp->pixelformat,prt_names (mp->field, v4l2_field_names), mp->colorspace, mp->num_planes, mp->flags, mp->ycbcr_enc, mp->quantization, mp->xfer_func);
@@ -337,13 +325,9 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_VBI_CAPTURE :case V4L2_BUF_TYPE_VBI_OUTPUT : vbi = &p->fmt.vbi; -pr_cont (", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%c%c%c%c, start=%u,%u, count=%u,%u\n" , +pr_cont (", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%p4cc, start=%u,%u, count=%u,%u\n" , vbi->sampling_rate, vbi->offset, - vbi->samples_per_line, - (vbi->sample_format &0xff ), - (vbi->sample_format >>8 ) &0xff , - (vbi->sample_format >>16 ) &0xff , - (vbi->sample_format >>24 ) &0xff , + vbi->samples_per_line, &vbi->sample_format, vbi->start[0 ], vbi->start[1 ], vbi->count[0 ], vbi->count[1 ]);break ;
@@ -360,21 +344,13 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_SDR_CAPTURE :case V4L2_BUF_TYPE_SDR_OUTPUT : sdr = &p->fmt.sdr; -pr_cont (", pixelformat=%c%c%c%c\n" , - (sdr->pixelformat >>0 ) &0xff , - (sdr->pixelformat >>8 ) &0xff , - (sdr->pixelformat >>16 ) &0xff , - (sdr->pixelformat >>24 ) &0xff ); +pr_cont (", pixelformat=%p4cc\n" , &sdr->pixelformat);break ;case V4L2_BUF_TYPE_META_CAPTURE :case V4L2_BUF_TYPE_META_OUTPUT : meta = &p->fmt.meta; -pr_cont (", dataformat=%c%c%c%c, buffersize=%u\n" , - (meta->dataformat >>0 ) &0xff , - (meta->dataformat >>8 ) &0xff , - (meta->dataformat >>16 ) &0xff , - (meta->dataformat >>24 ) &0xff , - meta->buffersize); +pr_cont (", dataformat=%p4cc, buffersize=%u\n" , + &meta->dataformat, meta->buffersize);break ; } }
@@ -383,15 +359,10 @@ static void v4l_print_framebuffer(const void *arg, bool write_only) {const struct v4l2_framebuffer *p = arg; -pr_cont ("capability=0x%x, flags=0x%x, base=0x%p, width=%u, height=%u, pixelformat=%c%c%c%c, bytesperline=%u, sizeimage=%u, colorspace=%d\n" , - p->capability, p->flags, p->base, - p->fmt.width, p->fmt.height, - (p->fmt.pixelformat &0xff ), - (p->fmt.pixelformat >>8 ) &0xff , - (p->fmt.pixelformat >>16 ) &0xff , - (p->fmt.pixelformat >>24 ) &0xff , - p->fmt.bytesperline, p->fmt.sizeimage, - p->fmt.colorspace); +pr_cont ("capability=0x%x, flags=0x%x, base=0x%p, width=%u, height=%u, pixelformat=%p4cc, bytesperline=%u, sizeimage=%u, colorspace=%d\n" , + p->capability, p->flags, p->base, p->fmt.width, p->fmt.height, + &p->fmt.pixelformat, p->fmt.bytesperline, p->fmt.sizeimage, + p->fmt.colorspace); }static void v4l_print_buftype (const void *arg,bool write_only)
@@ -761,13 +732,8 @@ static void v4l_print_frmsizeenum(const void *arg, bool write_only) {const struct v4l2_frmsizeenum *p = arg; -pr_cont ("index=%u, pixelformat=%c%c%c%c, type=%u" , - p->index, - (p->pixel_format &0xff ), - (p->pixel_format >>8 ) &0xff , - (p->pixel_format >>16 ) &0xff , - (p->pixel_format >>24 ) &0xff , - p->type); +pr_cont ("index=%u, pixelformat=%p4cc, type=%u" , + p->index, &p->pixel_format, p->type);switch (p->type) {case V4L2_FRMSIZE_TYPE_DISCRETE : pr_cont(", wxh=%ux%u\n",
@@ -793,13 +759,8 @@ static void v4l_print_frmivalenum(const void *arg, bool write_only) {const struct v4l2_frmivalenum *p = arg; -pr_cont ("index=%u, pixelformat=%c%c%c%c, wxh=%ux%u, type=%u" , - p->index, - (p->pixel_format &0xff ), - (p->pixel_format >>8 ) &0xff , - (p->pixel_format >>16 ) &0xff , - (p->pixel_format >>24 ) &0xff , - p->width, p->height, p->type); +pr_cont ("index=%u, pixelformat=%p4cc, wxh=%ux%u, type=%u" , + p->index, &p->pixel_format, p->width, p->height, p->type);switch (p->type) {case V4L2_FRMIVAL_TYPE_DISCRETE : pr_cont(", fps=%d/%d\n",
@@ -1459,12 +1420,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)return ;WARN (1 ,"Unknown pixelformat 0x%08x\n" , fmt->pixelformat); flags =0 ; -snprintf (fmt->description, sz,"%c%c%c%c%s" , - (char )(fmt->pixelformat &0x7f ), - (char )((fmt->pixelformat >>8 ) &0x7f ), - (char )((fmt->pixelformat >>16 ) &0x7f ), - (char )((fmt->pixelformat >>24 ) &0x7f ), - (fmt->pixelformat & (1UL <<31 )) ?"-BE" :"" ); +snprintf (fmt->description, sz,"%p4cc" , + &fmt->pixelformat);break ; } }
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 2/3] v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
Quoted 2 lines · Sakari Ailus
Now that we can print FourCC codes directly using printk, make use of the feature in V4L2 core.
See also below.
Quoted 149 lines
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/v4l2-ioctl.c | 85 +++++++--------------------- 1 file changed, 21 insertions(+), 64 deletions(-)drivers/media/v4l2-core/v4l2-ioctl.c +19
-58@@ -265,13 +265,9 @@ static void v4l_print_fmtdesc(const void *arg, bool write_only) {const struct v4l2_fmtdesc *p = arg; -pr_cont ("index=%u, type=%s, flags=0x%x, pixelformat=%c%c%c%c, mbus_code=0x%04x, description='%.*s'\n" , +pr_cont ("index=%u, type=%s, flags=0x%x, pixelformat=%p4cc, mbus_code=0x%04x, description='%.*s'\n" , p->index,prt_names (p->type, v4l2_type_names), - p->flags, (p->pixelformat &0xff ), - (p->pixelformat >>8 ) &0xff , - (p->pixelformat >>16 ) &0xff , - (p->pixelformat >>24 ) &0xff , - p->mbus_code, + p->flags, &p->pixelformat, p->mbus_code, (int )sizeof (p->description), p->description); }@@ -293,12 +289,8 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_VIDEO_CAPTURE :case V4L2_BUF_TYPE_VIDEO_OUTPUT : pix = &p->fmt.pix; - pr_cont(", width=%u, height=%u, pixelformat=%c%c%c%c, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n", - pix->width, pix->height, - (pix->pixelformat & 0xff), - (pix->pixelformat >> 8) & 0xff, - (pix->pixelformat >> 16) & 0xff, - (pix->pixelformat >> 24) & 0xff, + pr_cont(", width=%u, height=%u, pixelformat=%p4cc, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n", + pix->width, pix->height, &pix->pixelformat, prt_names(pix->field, v4l2_field_names), pix->bytesperline, pix->sizeimage, pix->colorspace, pix->flags, pix->ycbcr_enc,@@ -307,12 +299,8 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE :case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : mp = &p->fmt.pix_mp; -pr_cont (", width=%u, height=%u, format=%c%c%c%c, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n" , - mp->width, mp->height, - (mp->pixelformat &0xff ), - (mp->pixelformat >>8 ) &0xff , - (mp->pixelformat >>16 ) &0xff , - (mp->pixelformat >>24 ) &0xff , +pr_cont (", width=%u, height=%u, format=%p4cc, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n" , + mp->width, mp->height, &mp->pixelformat,prt_names (mp->field, v4l2_field_names), mp->colorspace, mp->num_planes, mp->flags, mp->ycbcr_enc, mp->quantization, mp->xfer_func);@@ -337,13 +325,9 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_VBI_CAPTURE :case V4L2_BUF_TYPE_VBI_OUTPUT : vbi = &p->fmt.vbi; -pr_cont (", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%c%c%c%c, start=%u,%u, count=%u,%u\n" , +pr_cont (", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%p4cc, start=%u,%u, count=%u,%u\n" , vbi->sampling_rate, vbi->offset, - vbi->samples_per_line, - (vbi->sample_format &0xff ), - (vbi->sample_format >>8 ) &0xff , - (vbi->sample_format >>16 ) &0xff , - (vbi->sample_format >>24 ) &0xff , + vbi->samples_per_line, &vbi->sample_format, vbi->start[0 ], vbi->start[1 ], vbi->count[0 ], vbi->count[1 ]);break ;@@ -360,21 +344,13 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_SDR_CAPTURE :case V4L2_BUF_TYPE_SDR_OUTPUT : sdr = &p->fmt.sdr; -pr_cont (", pixelformat=%c%c%c%c\n" , - (sdr->pixelformat >>0 ) &0xff , - (sdr->pixelformat >>8 ) &0xff , - (sdr->pixelformat >>16 ) &0xff , - (sdr->pixelformat >>24 ) &0xff ); +pr_cont (", pixelformat=%p4cc\n" , &sdr->pixelformat);break ;case V4L2_BUF_TYPE_META_CAPTURE :case V4L2_BUF_TYPE_META_OUTPUT : meta = &p->fmt.meta; -pr_cont (", dataformat=%c%c%c%c, buffersize=%u\n" , - (meta->dataformat >>0 ) &0xff , - (meta->dataformat >>8 ) &0xff , - (meta->dataformat >>16 ) &0xff , - (meta->dataformat >>24 ) &0xff , - meta->buffersize); +pr_cont (", dataformat=%p4cc, buffersize=%u\n" , + &meta->dataformat, meta->buffersize);break ; } }@@ -383,15 +359,10 @@ static void v4l_print_framebuffer(const void *arg, bool write_only) {const struct v4l2_framebuffer *p = arg; -pr_cont ("capability=0x%x, flags=0x%x, base=0x%p, width=%u, height=%u, pixelformat=%c%c%c%c, bytesperline=%u, sizeimage=%u, colorspace=%d\n" , - p->capability, p->flags, p->base, - p->fmt.width, p->fmt.height, - (p->fmt.pixelformat &0xff ), - (p->fmt.pixelformat >>8 ) &0xff , - (p->fmt.pixelformat >>16 ) &0xff , - (p->fmt.pixelformat >>24 ) &0xff , - p->fmt.bytesperline, p->fmt.sizeimage, - p->fmt.colorspace); +pr_cont ("capability=0x%x, flags=0x%x, base=0x%p, width=%u, height=%u, pixelformat=%p4cc, bytesperline=%u, sizeimage=%u, colorspace=%d\n" , + p->capability, p->flags, p->base, p->fmt.width, p->fmt.height, + &p->fmt.pixelformat, p->fmt.bytesperline, p->fmt.sizeimage, + p->fmt.colorspace); }static void v4l_print_buftype (const void *arg,bool write_only)@@ -761,13 +732,8 @@ static void v4l_print_frmsizeenum(const void *arg, bool write_only) {const struct v4l2_frmsizeenum *p = arg; -pr_cont ("index=%u, pixelformat=%c%c%c%c, type=%u" , - p->index, - (p->pixel_format &0xff ), - (p->pixel_format >>8 ) &0xff , - (p->pixel_format >>16 ) &0xff , - (p->pixel_format >>24 ) &0xff , - p->type); +pr_cont ("index=%u, pixelformat=%p4cc, type=%u" , + p->index, &p->pixel_format, p->type);switch (p->type) {case V4L2_FRMSIZE_TYPE_DISCRETE : pr_cont(", wxh=%ux%u\n",@@ -793,13 +759,8 @@ static void v4l_print_frmivalenum(const void *arg, bool write_only) {const struct v4l2_frmivalenum *p = arg; -pr_cont ("index=%u, pixelformat=%c%c%c%c, wxh=%ux%u, type=%u" , - p->index, - (p->pixel_format &0xff ), - (p->pixel_format >>8 ) &0xff , - (p->pixel_format >>16 ) &0xff , - (p->pixel_format >>24 ) &0xff , - p->width, p->height, p->type); +pr_cont ("index=%u, pixelformat=%p4cc, wxh=%ux%u, type=%u" , + p->index, &p->pixel_format, p->width, p->height, p->type);switch (p->type) {case V4L2_FRMIVAL_TYPE_DISCRETE : pr_cont(", fps=%d/%d\n",
drivers/media/v4l2-core/v4l2-ioctl.c static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) · line 1467
Quoted 9 lines
drivers/media/v4l2-core/v4l2-ioctl.c +0
-6@@ -1459,12 +1420,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)return ;WARN (1 ,"Unknown pixelformat 0x%08x\n" , fmt->pixelformat); flags =0 ; -snprintf (fmt->description, sz,"%c%c%c%c%s" , - (char )(fmt->pixelformat &0x7f ), - (char )((fmt->pixelformat >>8 ) &0x7f ), - (char )((fmt->pixelformat >>16 ) &0x7f ), - (char )((fmt->pixelformat >>24 ) &0x7f ), - (fmt->pixelformat & (1UL <<31 )) ?"-BE" :"" );
I'm wondering how it handled before the characters 0x80 or so...
Quoted 8 lines
drivers/media/v4l2-core/v4l2-ioctl.c +2
-0+snprintf (fmt->description, sz,"%p4cc" , + &fmt->pixelformat);break ; } }Signature · 1 line
2.29.2
Signature · 8 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 2/3] v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
Hi Andy,
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Sakari Ailus
Now that we can print FourCC codes directly using printk, make use of the feature in V4L2 core.
Reviewed-by Andy Shevchenko <[email protected]>See also below.
Thanks for the review, and the tag!
Quoted 153 lines
Quoted 153 lines
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/v4l2-ioctl.c | 85 +++++++--------------------- 1 file changed, 21 insertions(+), 64 deletions(-)drivers/media/v4l2-core/v4l2-ioctl.c +19
-58@@ -265,13 +265,9 @@ static void v4l_print_fmtdesc(const void *arg, bool write_only) {const struct v4l2_fmtdesc *p = arg; -pr_cont ("index=%u, type=%s, flags=0x%x, pixelformat=%c%c%c%c, mbus_code=0x%04x, description='%.*s'\n" , +pr_cont ("index=%u, type=%s, flags=0x%x, pixelformat=%p4cc, mbus_code=0x%04x, description='%.*s'\n" , p->index,prt_names (p->type, v4l2_type_names), - p->flags, (p->pixelformat &0xff ), - (p->pixelformat >>8 ) &0xff , - (p->pixelformat >>16 ) &0xff , - (p->pixelformat >>24 ) &0xff , - p->mbus_code, + p->flags, &p->pixelformat, p->mbus_code, (int )sizeof (p->description), p->description); }@@ -293,12 +289,8 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_VIDEO_CAPTURE :case V4L2_BUF_TYPE_VIDEO_OUTPUT : pix = &p->fmt.pix; - pr_cont(", width=%u, height=%u, pixelformat=%c%c%c%c, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n", - pix->width, pix->height, - (pix->pixelformat & 0xff), - (pix->pixelformat >> 8) & 0xff, - (pix->pixelformat >> 16) & 0xff, - (pix->pixelformat >> 24) & 0xff, + pr_cont(", width=%u, height=%u, pixelformat=%p4cc, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n", + pix->width, pix->height, &pix->pixelformat, prt_names(pix->field, v4l2_field_names), pix->bytesperline, pix->sizeimage, pix->colorspace, pix->flags, pix->ycbcr_enc,@@ -307,12 +299,8 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE :case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : mp = &p->fmt.pix_mp; -pr_cont (", width=%u, height=%u, format=%c%c%c%c, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n" , - mp->width, mp->height, - (mp->pixelformat &0xff ), - (mp->pixelformat >>8 ) &0xff , - (mp->pixelformat >>16 ) &0xff , - (mp->pixelformat >>24 ) &0xff , +pr_cont (", width=%u, height=%u, format=%p4cc, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n" , + mp->width, mp->height, &mp->pixelformat,prt_names (mp->field, v4l2_field_names), mp->colorspace, mp->num_planes, mp->flags, mp->ycbcr_enc, mp->quantization, mp->xfer_func);@@ -337,13 +325,9 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_VBI_CAPTURE :case V4L2_BUF_TYPE_VBI_OUTPUT : vbi = &p->fmt.vbi; -pr_cont (", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%c%c%c%c, start=%u,%u, count=%u,%u\n" , +pr_cont (", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%p4cc, start=%u,%u, count=%u,%u\n" , vbi->sampling_rate, vbi->offset, - vbi->samples_per_line, - (vbi->sample_format &0xff ), - (vbi->sample_format >>8 ) &0xff , - (vbi->sample_format >>16 ) &0xff , - (vbi->sample_format >>24 ) &0xff , + vbi->samples_per_line, &vbi->sample_format, vbi->start[0 ], vbi->start[1 ], vbi->count[0 ], vbi->count[1 ]);break ;@@ -360,21 +344,13 @@ static void v4l_print_format(const void *arg, bool write_only)case V4L2_BUF_TYPE_SDR_CAPTURE :case V4L2_BUF_TYPE_SDR_OUTPUT : sdr = &p->fmt.sdr; -pr_cont (", pixelformat=%c%c%c%c\n" , - (sdr->pixelformat >>0 ) &0xff , - (sdr->pixelformat >>8 ) &0xff , - (sdr->pixelformat >>16 ) &0xff , - (sdr->pixelformat >>24 ) &0xff ); +pr_cont (", pixelformat=%p4cc\n" , &sdr->pixelformat);break ;case V4L2_BUF_TYPE_META_CAPTURE :case V4L2_BUF_TYPE_META_OUTPUT : meta = &p->fmt.meta; -pr_cont (", dataformat=%c%c%c%c, buffersize=%u\n" , - (meta->dataformat >>0 ) &0xff , - (meta->dataformat >>8 ) &0xff , - (meta->dataformat >>16 ) &0xff , - (meta->dataformat >>24 ) &0xff , - meta->buffersize); +pr_cont (", dataformat=%p4cc, buffersize=%u\n" , + &meta->dataformat, meta->buffersize);break ; } }@@ -383,15 +359,10 @@ static void v4l_print_framebuffer(const void *arg, bool write_only) {const struct v4l2_framebuffer *p = arg; -pr_cont ("capability=0x%x, flags=0x%x, base=0x%p, width=%u, height=%u, pixelformat=%c%c%c%c, bytesperline=%u, sizeimage=%u, colorspace=%d\n" , - p->capability, p->flags, p->base, - p->fmt.width, p->fmt.height, - (p->fmt.pixelformat &0xff ), - (p->fmt.pixelformat >>8 ) &0xff , - (p->fmt.pixelformat >>16 ) &0xff , - (p->fmt.pixelformat >>24 ) &0xff , - p->fmt.bytesperline, p->fmt.sizeimage, - p->fmt.colorspace); +pr_cont ("capability=0x%x, flags=0x%x, base=0x%p, width=%u, height=%u, pixelformat=%p4cc, bytesperline=%u, sizeimage=%u, colorspace=%d\n" , + p->capability, p->flags, p->base, p->fmt.width, p->fmt.height, + &p->fmt.pixelformat, p->fmt.bytesperline, p->fmt.sizeimage, + p->fmt.colorspace); }static void v4l_print_buftype (const void *arg,bool write_only)@@ -761,13 +732,8 @@ static void v4l_print_frmsizeenum(const void *arg, bool write_only) {const struct v4l2_frmsizeenum *p = arg; -pr_cont ("index=%u, pixelformat=%c%c%c%c, type=%u" , - p->index, - (p->pixel_format &0xff ), - (p->pixel_format >>8 ) &0xff , - (p->pixel_format >>16 ) &0xff , - (p->pixel_format >>24 ) &0xff , - p->type); +pr_cont ("index=%u, pixelformat=%p4cc, type=%u" , + p->index, &p->pixel_format, p->type);switch (p->type) {case V4L2_FRMSIZE_TYPE_DISCRETE : pr_cont(", wxh=%ux%u\n",@@ -793,13 +759,8 @@ static void v4l_print_frmivalenum(const void *arg, bool write_only) {const struct v4l2_frmivalenum *p = arg; -pr_cont ("index=%u, pixelformat=%c%c%c%c, wxh=%ux%u, type=%u" , - p->index, - (p->pixel_format &0xff ), - (p->pixel_format >>8 ) &0xff , - (p->pixel_format >>16 ) &0xff , - (p->pixel_format >>24 ) &0xff , - p->width, p->height, p->type); +pr_cont ("index=%u, pixelformat=%p4cc, wxh=%ux%u, type=%u" , + p->index, &p->pixel_format, p->width, p->height, p->type);switch (p->type) {case V4L2_FRMIVAL_TYPE_DISCRETE : pr_cont(", fps=%d/%d\n",@@ -1459,12 +1420,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)return ;WARN (1 ,"Unknown pixelformat 0x%08x\n" , fmt->pixelformat); flags =0 ;
Quoted 8 lines
drivers/media/v4l2-core/v4l2-ioctl.c static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) · line 1467
Quoted 6 lines
drivers/media/v4l2-core/v4l2-ioctl.c +0
-6-snprintf (fmt->description, sz,"%c%c%c%c%s" , - (char )(fmt->pixelformat &0x7f ), - (char )((fmt->pixelformat >>8 ) &0x7f ), - (char )((fmt->pixelformat >>16 ) &0x7f ), - (char )((fmt->pixelformat >>24 ) &0x7f ), - (fmt->pixelformat & (1UL <<31 )) ?"-BE" :"" );I'm wondering how it handled before the characters
0x80or so...
The code is different in here than in the other instances but in practice the output has been the same as the MSB is only set for the endianness byte.
Signature · 7 lines
Regards, Sakari Ailus _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 2/3] v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
In reply to Sakari AilusQuoted 4 lines · Sakari Ailus
Now that we can print FourCC codes directly using printk, make use of the feature in V4L2 core.
Signed-off-by Sakari Ailus <[email protected]>
I am curious whether I could take this via printk tree or if Mauro would prefer to take this via his tree.
Anyway, there will be v8 with small changes in the 1st patch.
Best Regards,
Petr
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Mauro Carvalho Chehab
Acked-byRe: [PATCH v7 2/3] v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
Em Mon, 15 Feb 2021 17:56:27 +0100
Petr Mladek <[email protected]> escreveu:
Quoted 10 lines · Sakari Ailus
Quoted 4 lines
Now that we can print FourCC codes directly using printk, make use of the feature in V4L2 core.
Signed-off-by Sakari Ailus <[email protected]>Reviewed-by Petr Mladek <[email protected]>I am curious whether I could take this via printk tree or if Mauro would prefer to take this via his tree.
IMO, the best would be if the entire series gets merged via a single tree.
Feel free to merge via the printk one.
Quoted 5 lines
Anyway, there will be v8 with small changes in the 1st patch.
Best Regards,
Petr
Thanks,
Mauro
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 2/3] v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
Quoted 14 lines · Mauro Carvalho Chehab
Em Mon, 15 Feb 2021 17:56:27 +0100
Petr Mladek <[email protected]> escreveu:Quoted 10 lines · Sakari Ailus
Quoted 4 lines
Now that we can print FourCC codes directly using printk, make use of the feature in V4L2 core.
Signed-off-by Sakari Ailus <[email protected]>Reviewed-by Petr Mladek <[email protected]>I am curious whether I could take this via printk tree or if Mauro would prefer to take this via his tree.
Quoted 6 lines
IMO, the best would be if the entire series gets merged via a single tree.
Feel free to merge via the printk one.
Thanks, Mauro!
Signature · 5 lines
Sakari Ailus _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v7 3/3 drm: Switch to %p4cc format modifier
In reply to Sakari AilusSwitch DRM drivers from drm_get_format_name() to %p4cc. This gets rid of a large number of temporary variables at the same time.
--- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 5 ++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 ++-- .../arm/display/komeda/komeda_format_caps.h | 11 -------- .../arm/display/komeda/komeda_framebuffer.c | 4 +-- .../gpu/drm/arm/display/komeda/komeda_plane.c | 6 ++--- drivers/gpu/drm/arm/malidp_mw.c | 7 ++---- drivers/gpu/drm/drm_atomic.c | 8 ++---- drivers/gpu/drm/drm_crtc.c | 7 ++---- drivers/gpu/drm/drm_fourcc.c | 25 ------------------- drivers/gpu/drm/drm_framebuffer.c | 11 +++----- drivers/gpu/drm/drm_mipi_dbi.c | 5 ++-- drivers/gpu/drm/drm_plane.c | 8 ++---- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 5 ++-- drivers/gpu/drm/i915/display/intel_display.c | 14 +++-------- .../drm/i915/display/intel_display_debugfs.c | 19 ++++++-------- drivers/gpu/drm/i915/display/intel_sprite.c | 6 ++--- drivers/gpu/drm/mcde/mcde_display.c | 6 ++--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 6 ++--- drivers/gpu/drm/nouveau/nouveau_display.c | 9 +++---- drivers/gpu/drm/radeon/atombios_crtc.c | 10 +++----- drivers/gpu/drm/sun4i/sun4i_backend.c | 6 ++--- drivers/gpu/drm/vkms/vkms_writeback.c | 7 ++---- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 15 +++++------ include/drm/drm_fourcc.h | 1 - 27 files changed, 64 insertions(+), 157 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +2 -3
@@ -1862,7 +1862,6 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1981,8 +1980,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +2 -3
@@ -1904,7 +1904,6 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2023,8 +2022,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2 -3
@@ -1820,7 +1820,6 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1929,8 +1928,8 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +2 -3
@@ -1791,7 +1791,6 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1902,8 +1901,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -3
@@ -4465,7 +4465,6 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev,const struct drm_framebuffer *fb = plane_state->fb;const struct amdgpu_framebuffer *afb =to_amdgpu_framebuffer (plane_state->fb); -struct drm_format_name_buf format_name;int ret;memset (plane_info,0 ,sizeof (*plane_info));
@@ -4513,8 +4512,8 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev,break ;default :DRM_ERROR ( -"Unsupported screen format %s\n" , -drm_get_format_name (fb->format->format, &format_name)); +"Unsupported screen format %p4cc\n" , + &fb->format->format);return -EINVAL ; }
drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h +0 -11
@@ -82,17 +82,6 @@ struct komeda_format_caps_table {extern u64 komeda_supported_modifiers[]; -static inline const char *komeda_get_format_name (u32 fourcc,u64 modifier) -{ -struct drm_format_name_buf buf; -static char name[64 ]; - -snprintf (name,sizeof (name),"%s with modifier: 0x%llx." , -drm_get_format_name (fourcc, &buf), modifier); - -return name; -} -const struct komeda_format_caps *komeda_get_format_caps (struct komeda_format_caps_table *table,u32 fourcc,u64 modifier);
drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c +2 -2
@@ -276,8 +276,8 @@ bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type, supported =komeda_format_mod_supported (&mdev->fmt_tbl, layer_type, fourcc, modifier, rot);if (!supported) -DRM_DEBUG_ATOMIC ("Layer TYPE: %d doesn't support fb FMT: %s.\n" , - layer_type,komeda_get_format_name (fourcc, modifier)); +DRM_DEBUG_ATOMIC ("Layer TYPE: %d doesn't support fb FMT: %p4cc with modifier: 0x%llx.\n" , + layer_type, &fourcc, modifier);return supported; }
drivers/gpu/drm/arm/display/komeda/komeda_plane.c +2 -4
@@ -49,10 +49,8 @@ komeda_plane_init_data_flow(struct drm_plane_state *st, dflow->rot =drm_rotation_simplify (st->rotation, caps->supported_rots);if (!has_bits (dflow->rot, caps->supported_rots)) { -DRM_DEBUG_ATOMIC ("rotation(0x%x) isn't supported by %s.\n" , - dflow->rot, -komeda_get_format_name (caps->fourcc, - fb->modifier)); +DRM_DEBUG_ATOMIC ("rotation(0x%x) isn't supported by %p4cc with modifier: 0x%llx.\n" , + dflow->rot, &caps->fourcc, fb->modifier);return -EINVAL ; }
drivers/gpu/drm/arm/malidp_mw.c +2 -5
@@ -151,11 +151,8 @@ malidp_mw_encoder_atomic_check(struct drm_encoder *encoder,malidp_hw_get_format_id (&malidp->dev->hw->map,SE_MEMWRITE , fb->format->format, !!fb->modifier);if (mw_state->format ==MALIDP_INVALID_FORMAT_ID ) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , -drm_get_format_name (fb->format->format, - &format_name)); +DRM_DEBUG_KMS ("Invalid pixel format %p4cc\n" , + &fb->format->format);return -EINVAL ; }
drivers/gpu/drm/drm_atomic.c +2 -6
@@ -578,13 +578,9 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, ret =drm_plane_check_pixel_format (plane, fb->format->format, fb->modifier);if (ret) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_ATOMIC ("[PLANE:%d:%s] invalid pixel format %s, modifier 0x%llx\n" , +DRM_DEBUG_ATOMIC ("[PLANE:%d:%s] invalid pixel format %p4cc, modifier 0x%llx\n" , plane->base.id, plane->name, -drm_get_format_name (fb->format->format, - &format_name), - fb->modifier); + &fb->format->format, fb->modifier);return ret; }
drivers/gpu/drm/drm_crtc.c +2 -5
@@ -663,11 +663,8 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, fb->format->format, fb->modifier);if (ret) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s, modifier 0x%llx\n" , -drm_get_format_name (fb->format->format, - &format_name), +DRM_DEBUG_KMS ("Invalid pixel format %p4cc, modifier 0x%llx\n" , + &fb->format->format, fb->modifier); goto out; }
drivers/gpu/drm/drm_fourcc.c +0 -25
@@ -30,11 +30,6 @@#include <drm/drm_device.h> #include <drm/drm_fourcc.h> -static char printable_char (int c) -{ -return isascii (c) &&isprint (c) ? c :'?' ; -} -/** * drm_mode_legacy_fb_format - compute drm fourcc code from legacy description * @bpp: bits per pixels
@@ -130,26 +125,6 @@ uint32_t drm_driver_legacy_fb_format(struct drm_device *dev, }EXPORT_SYMBOL (drm_driver_legacy_fb_format); -/** -* drm_get_format_name - fill a string with a drm fourcc format's name -* @format: format to compute name of -* @buf: caller-supplied buffer -*/ -const char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf) -{ -snprintf (buf->str,sizeof (buf->str), -"%c%c%c%c %s-endian (0x%08x)" , -printable_char (format &0xff ), -printable_char ((format >>8 ) &0xff ), -printable_char ((format >>16 ) &0xff ), -printable_char ((format >>24 ) &0x7f ), - format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , - format); - -return buf->str; -} -EXPORT_SYMBOL (drm_get_format_name); -/* * Internal function to query information for a given format. See * drm_format_info() for the public API.
drivers/gpu/drm/drm_framebuffer.c +3 -8
@@ -177,11 +177,8 @@ static int framebuffer_check(struct drm_device *dev,/* check if the format is supported at all */ if (!__drm_format_info (r->pixel_format)) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , -drm_get_format_name (r->pixel_format, - &format_name)); +DRM_DEBUG_KMS ("bad framebuffer format %p4cc\n" , + &r->pixel_format);return -EINVAL ; }
@@ -1160,14 +1157,12 @@ EXPORT_SYMBOL(drm_framebuffer_plane_height);void drm_framebuffer_print_info (struct drm_printer *p,unsigned int indent,const struct drm_framebuffer *fb) { -struct drm_format_name_buf format_name;unsigned int i;drm_printf_indent (p, indent,"allocated by = %s\n" , fb->comm);drm_printf_indent (p, indent,"refcount=%u\n" ,drm_framebuffer_read_refcount (fb)); -drm_printf_indent (p, indent,"format=%s\n" , -drm_get_format_name (fb->format->format, &format_name)); +drm_printf_indent (p, indent,"format=%p4cc\n" , &fb->format->format);drm_printf_indent (p, indent,"modifier=0x%llx\n" , fb->modifier);drm_printf_indent (p, indent,"size=%ux%u\n" , fb->width, fb->height);drm_printf_indent (p, indent,"layers:\n" );
drivers/gpu/drm/drm_mipi_dbi.c +2 -3
@@ -203,7 +203,6 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,struct drm_gem_object *gem =drm_gem_fb_get_obj (fb,0 );struct drm_gem_cma_object *cma_obj =to_drm_gem_cma_obj (gem);struct dma_buf_attachment *import_attach = gem->import_attach; -struct drm_format_name_buf format_name;void *src = cma_obj->vaddr;int ret =0 ;
@@ -225,8 +224,8 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,drm_fb_xrgb8888_to_rgb565 (dst, src, fb, clip, swap);break ;default : -drm_err_once (fb->dev,"Format is not supported: %s\n" , -drm_get_format_name (fb->format->format, &format_name)); +drm_err_once (fb->dev,"Format is not supported: %p4cc\n" , + &fb->format->format);return -EINVAL ; }
drivers/gpu/drm/drm_plane.c +2 -6
@@ -623,12 +623,8 @@ static int __setplane_check(struct drm_plane *plane, ret =drm_plane_check_pixel_format (plane, fb->format->format, fb->modifier);if (ret) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s, modifier 0x%llx\n" , -drm_get_format_name (fb->format->format, - &format_name), - fb->modifier); +DRM_DEBUG_KMS ("Invalid pixel format %p4cc, modifier 0x%llx\n" , + &fb->format->format, fb->modifier);return ret; }
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +2 -3
@@ -549,16 +549,15 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -struct drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); -DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , +DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%p4cc)\n" , addr, fb->width, fb->height, fmt, -drm_get_format_name (fb->format->format, &format_name)); + &fb->format->format);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);
drivers/gpu/drm/i915/display/intel_display.c +4 -10
@@ -13319,7 +13319,6 @@ static void intel_dump_plane_state(const struct intel_plane_state *plane_state)struct intel_plane *plane =to_intel_plane (plane_state->uapi.plane);struct drm_i915_private *i915 =to_i915 (plane->base.dev);const struct drm_framebuffer *fb = plane_state->hw.fb; -struct drm_format_name_buf format_name;if (!fb) { drm_dbg_kms(&i915->drm,
@@ -13330,10 +13329,9 @@ static void intel_dump_plane_state(const struct intel_plane_state *plane_state) }drm_dbg_kms (&i915->drm, -"[PLANE:%d:%s] fb: [FB:%d] %ux%u format = %s modifier = 0x%llx, visible: %s\n" , +"[PLANE:%d:%s] fb: [FB:%d] %ux%u format = %p4cc modifier = 0x%llx, visible: %s\n" , plane->base.base.id, plane->base.name, - fb->base.id, fb->width, fb->height, -drm_get_format_name (fb->format->format, &format_name), + fb->base.id, fb->width, fb->height, &fb->format->format, fb->modifier,yesno (plane_state->uapi.visible));drm_dbg_kms (&i915->drm,"\trotation: 0x%x, scaler: %d\n" , plane_state->hw.rotation, plane_state->scaler_id);
@@ -17927,13 +17925,9 @@ static int intel_framebuffer_init(struct intel_framebuffer *intel_fb,if (!drm_any_plane_has_format (&dev_priv->drm, mode_cmd->pixel_format, mode_cmd->modifier[0 ])) { -struct drm_format_name_buf format_name; -drm_dbg_kms (&dev_priv->drm, -"unsupported pixel format %s / modifier 0x%llx\n" , -drm_get_format_name (mode_cmd->pixel_format, - &format_name), - mode_cmd->modifier[0 ]); +"unsupported pixel format %p4cc / modifier 0x%llx\n" , + &mode_cmd->pixel_format, mode_cmd->modifier[0 ]); goto err; }
drivers/gpu/drm/i915/display/intel_display_debugfs.c +8 -11
@@ -771,21 +771,21 @@ static void intel_plane_uapi_info(struct seq_file *m, struct intel_plane *plane)const struct intel_plane_state *plane_state =to_intel_plane_state (plane->base.state);const struct drm_framebuffer *fb = plane_state->uapi.fb; -struct drm_format_name_buf format_name;struct drm_rect src, dst;char rot_str[48 ]; src =drm_plane_state_src (&plane_state->uapi); dst =drm_plane_state_dest (&plane_state->uapi); -if (fb) -drm_get_format_name (fb->format->format, &format_name); -plane_rotation (rot_str,sizeof (rot_str), plane_state->uapi.rotation); - seq_printf(m, "\t\tuapi: [FB:%d] %s,0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", - fb ? fb->base.id : 0, fb ? format_name.str : "n/a", +seq_printf (m,"\t\tuapi: [FB:%d] " , fb ? fb->base.id :0 ); +if (fb) +seq_printf (m,"%p4cc" , &fb->format->format); +else +seq_puts (m,"n/a" ); + seq_printf(m, ",0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", fb ? fb->modifier : 0, fb ? fb->width : 0, fb ? fb->height : 0, plane_visibility(plane_state),
@@ -804,19 +804,16 @@ static void intel_plane_hw_info(struct seq_file *m, struct intel_plane *plane)const struct intel_plane_state *plane_state =to_intel_plane_state (plane->base.state);const struct drm_framebuffer *fb = plane_state->hw.fb; -struct drm_format_name_buf format_name;char rot_str[48 ];if (!fb)return ; -drm_get_format_name (fb->format->format, &format_name); -plane_rotation (rot_str,sizeof (rot_str), plane_state->hw.rotation); - seq_printf(m, "\t\thw: [FB:%d] %s,0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", - fb->base.id, format_name.str, + seq_printf(m, "\t\thw: [FB:%d] %p4cc,0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", + fb->base.id, &fb->format->format, fb->modifier, fb->width, fb->height, yesno(plane_state->uapi.visible), DRM_RECT_FP_ARG(&plane_state->uapi.src),
drivers/gpu/drm/i915/display/intel_sprite.c +2 -4
@@ -2285,7 +2285,6 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state,struct drm_i915_private *dev_priv =to_i915 (plane->base.dev);const struct drm_framebuffer *fb = plane_state->hw.fb;unsigned int rotation = plane_state->hw.rotation; -struct drm_format_name_buf format_name;if (!fb)return 0 ;
@@ -2333,9 +2332,8 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state,case DRM_FORMAT_XVYU12_16161616 :case DRM_FORMAT_XVYU16161616 :drm_dbg_kms (&dev_priv->drm, -"Unsupported pixel format %s for 90/270!\n" , -drm_get_format_name (fb->format->format, - &format_name)); +"Unsupported pixel format %p4cc for 90/270!\n" , + &fb->format->format);return -EINVAL ;default :break ;
drivers/gpu/drm/mcde/mcde_display.c +2 -4
@@ -1161,7 +1161,6 @@ static void mcde_display_enable(struct drm_simple_display_pipe *pipe,int dsi_pkt_size;int fifo_wtrmrk;int cpp = fb->format->cpp[0 ]; -struct drm_format_name_buf tmp;u32 dsi_formatter_frame;u32 val;int ret;
@@ -1173,9 +1172,8 @@ static void mcde_display_enable(struct drm_simple_display_pipe *pipe,return ; } -dev_info (drm->dev,"enable MCDE, %d x %d format %s\n" , - mode->hdisplay, mode->vdisplay, -drm_get_format_name (format, &tmp)); +dev_info (drm->dev,"enable MCDE, %d x %d format %p4cc\n" , + mode->hdisplay, mode->vdisplay, &format);/* Clear any pending interrupts */
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +2 -4
@@ -71,7 +71,6 @@ static void _dpu_crtc_setup_blend_cfg(struct dpu_crtc_mixer *mixer, {struct dpu_hw_mixer *lm = mixer->hw_lm;uint32_t blend_op; -struct drm_format_name_buf format_name;/* default to opaque blending */ blend_op = DPU_BLEND_FG_ALPHA_FG_CONST |
@@ -87,9 +86,8 @@ static void _dpu_crtc_setup_blend_cfg(struct dpu_crtc_mixer *mixer, lm->ops.setup_blend_config (lm, pstate->stage,0xFF ,0 , blend_op); -DPU_DEBUG ("format:%s, alpha_en:%u blend_op:0x%x\n" , -drm_get_format_name (format->base.pixel_format, &format_name), - format->alpha_enable, blend_op); +DPU_DEBUG ("format:%p4cc, alpha_en:%u blend_op:0x%x\n" , + &format->base.pixel_format, format->alpha_enable, blend_op); }static void _dpu_crtc_program_lm_output_roi (struct drm_crtc *crtc)
drivers/gpu/drm/nouveau/nouveau_display.c +3 -6
@@ -322,12 +322,9 @@ nouveau_framebuffer_new(struct drm_device *dev, mode_cmd->pitches[0] >= 0x10000 || /* at most 64k pitch */ (mode_cmd->pitches[1] && /* pitches for planes must match */ mode_cmd->pitches[0] != mode_cmd->pitches[1]))) { -struct drm_format_name_buf format_name; -DRM_DEBUG_KMS ("Unsuitable framebuffer: format: %s; pitches: 0x%x\n 0x%x\n" , -drm_get_format_name (mode_cmd->pixel_format, - &format_name), - mode_cmd->pitches[0 ], - mode_cmd->pitches[1 ]); +DRM_DEBUG_KMS ("Unsuitable framebuffer: format: %p4cc; pitches: 0x%x\n 0x%x\n" , + &mode_cmd->pixel_format, + mode_cmd->pitches[0 ], mode_cmd->pitches[1 ]);return -EINVAL ; }
drivers/gpu/drm/radeon/atombios_crtc.c +4 -6
@@ -1157,7 +1157,6 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1267,8 +1266,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }
@@ -1478,7 +1477,6 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1579,8 +1577,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }
drivers/gpu/drm/sun4i/sun4i_backend.c +2 -4
@@ -510,7 +510,6 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine,struct sun4i_layer_state *layer_state =state_to_sun4i_layer_state (plane_state);struct drm_framebuffer *fb = plane_state->fb; -struct drm_format_name_buf format_name;if (!sun4i_backend_plane_is_supported (plane_state, &layer_state->uses_frontend))
@@ -527,9 +526,8 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine, } } -DRM_DEBUG_DRIVER ("Plane FB format is %s\n" , -drm_get_format_name (fb->format->format, - &format_name)); +DRM_DEBUG_DRIVER ("Plane FB format is %p4cc\n" , + &fb->format->format);if (fb->format->has_alpha || (plane_state->alpha !=DRM_BLEND_ALPHA_OPAQUE )) num_alpha_planes++;
drivers/gpu/drm/vkms/vkms_writeback.c +2 -5
@@ -42,11 +42,8 @@ static int vkms_wb_encoder_atomic_check(struct drm_encoder *encoder, }if (fb->format->format != vkms_wb_formats[0 ]) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , -drm_get_format_name (fb->format->format, - &format_name)); +DRM_DEBUG_KMS ("Invalid pixel format %p4cc\n" , + &fb->format->format);return -EINVAL ; }
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +6 -9
@@ -895,7 +895,6 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,struct vmw_framebuffer_surface *vfbs;enum SVGA3dSurfaceFormat format;int ret; -struct drm_format_name_buf format_name;/* 3D is only supported on HWv8 and newer hosts */ if (dev_priv->active_display_unit == vmw_du_legacy)
@@ -933,8 +932,8 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv, format =SVGA3D_A1R5G5B5 ;break ;default : -DRM_ERROR ("Invalid pixel format: %s\n" , -drm_get_format_name (mode_cmd->pixel_format, &format_name)); +DRM_ERROR ("Invalid pixel format: %p4cc\n" , + &mode_cmd->pixel_format);return -EINVAL ; }
@@ -1149,7 +1148,6 @@ static int vmw_create_bo_proxy(struct drm_device *dev,uint32_t format;struct vmw_resource *res;unsigned int bytes_pp; -struct drm_format_name_buf format_name;int ret;switch (mode_cmd->pixel_format) {
@@ -1171,8 +1169,8 @@ static int vmw_create_bo_proxy(struct drm_device *dev,break ;default : -DRM_ERROR ("Invalid framebuffer format %s\n" , -drm_get_format_name (mode_cmd->pixel_format, &format_name)); +DRM_ERROR ("Invalid framebuffer format %p4cc\n" , + &mode_cmd->pixel_format);return -EINVAL ; }
@@ -1216,7 +1214,6 @@ static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv,struct drm_device *dev = dev_priv->dev;struct vmw_framebuffer_bo *vfbd;unsigned int requested_size; -struct drm_format_name_buf format_name;int ret; requested_size = mode_cmd->height * mode_cmd->pitches[0 ];
@@ -1236,8 +1233,8 @@ static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv,case DRM_FORMAT_RGB565 :break ;default : -DRM_ERROR ("Invalid pixel format: %s\n" , -drm_get_format_name (mode_cmd->pixel_format, &format_name)); +DRM_ERROR ("Invalid pixel format: %p4cc\n" , + &mode_cmd->pixel_format);return -EINVAL ; } }
include/drm/drm_fourcc.h +0 -1
@@ -318,6 +318,5 @@ unsigned int drm_format_info_block_height(const struct drm_format_info *info, int plane);uint64_t drm_format_info_min_pitch (const struct drm_format_info *info,int plane,unsigned int buffer_width); -const char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);#endif /* __DRM_FOURCC_H__ */
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 3/3] drm: Switch to %p4cc format modifier
Quoted 2 lines · Sakari Ailus
Switch DRM drivers from
drm_get_format_name()to %p4cc. This gets rid of a large number of temporary variables at the same time.
What a nice clean up!
after addressing nit-picks below.
Side note (no need to implement esp. right now): it seems often it's coupled with modifier, would be nice to have them together that %p4ccM or so can do it in one go.
Quoted 261 lines
Signed-off-by Sakari Ailus <[email protected]>--- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 5 ++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 ++-- .../arm/display/komeda/komeda_format_caps.h | 11 -------- .../arm/display/komeda/komeda_framebuffer.c | 4 +-- .../gpu/drm/arm/display/komeda/komeda_plane.c | 6 ++--- drivers/gpu/drm/arm/malidp_mw.c | 7 ++---- drivers/gpu/drm/drm_atomic.c | 8 ++---- drivers/gpu/drm/drm_crtc.c | 7 ++---- drivers/gpu/drm/drm_fourcc.c | 25 ------------------- drivers/gpu/drm/drm_framebuffer.c | 11 +++----- drivers/gpu/drm/drm_mipi_dbi.c | 5 ++-- drivers/gpu/drm/drm_plane.c | 8 ++---- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 5 ++-- drivers/gpu/drm/i915/display/intel_display.c | 14 +++-------- .../drm/i915/display/intel_display_debugfs.c | 19 ++++++-------- drivers/gpu/drm/i915/display/intel_sprite.c | 6 ++--- drivers/gpu/drm/mcde/mcde_display.c | 6 ++--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 6 ++--- drivers/gpu/drm/nouveau/nouveau_display.c | 9 +++---- drivers/gpu/drm/radeon/atombios_crtc.c | 10 +++----- drivers/gpu/drm/sun4i/sun4i_backend.c | 6 ++--- drivers/gpu/drm/vkms/vkms_writeback.c | 7 ++---- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 15 +++++------ include/drm/drm_fourcc.h | 1 - 27 files changed, 64 insertions(+), 157 deletions(-)drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +2
-3@@ -1862,7 +1862,6 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1981,8 +1980,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +2
-3@@ -1904,7 +1904,6 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2023,8 +2022,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2
-3@@ -1820,7 +1820,6 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1929,8 +1928,8 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +2
-3@@ -1791,7 +1791,6 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1902,8 +1901,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-3@@ -4465,7 +4465,6 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev,const struct drm_framebuffer *fb = plane_state->fb;const struct amdgpu_framebuffer *afb =to_amdgpu_framebuffer (plane_state->fb); -struct drm_format_name_buf format_name;int ret;memset (plane_info,0 ,sizeof (*plane_info));@@ -4513,8 +4512,8 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev,break ;default :DRM_ERROR ( -"Unsupported screen format %s\n" , -drm_get_format_name (fb->format->format, &format_name)); +"Unsupported screen format %p4cc\n" , + &fb->format->format);return -EINVAL ; }drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h +0
-11@@ -82,17 +82,6 @@ struct komeda_format_caps_table {extern u64 komeda_supported_modifiers[]; -static inline const char *komeda_get_format_name (u32 fourcc,u64 modifier) -{ -struct drm_format_name_buf buf; -static char name[64 ]; - -snprintf (name,sizeof (name),"%s with modifier: 0x%llx." , -drm_get_format_name (fourcc, &buf), modifier); - -return name; -} -const struct komeda_format_caps *komeda_get_format_caps (struct komeda_format_caps_table *table,u32 fourcc,u64 modifier);drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c +2
-2@@ -276,8 +276,8 @@ bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type, supported =komeda_format_mod_supported (&mdev->fmt_tbl, layer_type, fourcc, modifier, rot);if (!supported) -DRM_DEBUG_ATOMIC ("Layer TYPE: %d doesn't support fb FMT: %s.\n" , - layer_type,komeda_get_format_name (fourcc, modifier)); +DRM_DEBUG_ATOMIC ("Layer TYPE: %d doesn't support fb FMT: %p4cc with modifier: 0x%llx.\n" , + layer_type, &fourcc, modifier);return supported; }drivers/gpu/drm/arm/display/komeda/komeda_plane.c +2
-4@@ -49,10 +49,8 @@ komeda_plane_init_data_flow(struct drm_plane_state *st, dflow->rot =drm_rotation_simplify (st->rotation, caps->supported_rots);if (!has_bits (dflow->rot, caps->supported_rots)) { -DRM_DEBUG_ATOMIC ("rotation(0x%x) isn't supported by %s.\n" , - dflow->rot, -komeda_get_format_name (caps->fourcc, - fb->modifier)); +DRM_DEBUG_ATOMIC ("rotation(0x%x) isn't supported by %p4cc with modifier: 0x%llx.\n" , + dflow->rot, &caps->fourcc, fb->modifier);return -EINVAL ; }drivers/gpu/drm/arm/malidp_mw.c +2
-5@@ -151,11 +151,8 @@ malidp_mw_encoder_atomic_check(struct drm_encoder *encoder,malidp_hw_get_format_id (&malidp->dev->hw->map,SE_MEMWRITE , fb->format->format, !!fb->modifier);if (mw_state->format ==MALIDP_INVALID_FORMAT_ID ) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , -drm_get_format_name (fb->format->format, - &format_name)); +DRM_DEBUG_KMS ("Invalid pixel format %p4cc\n" , + &fb->format->format);return -EINVAL ; }drivers/gpu/drm/drm_atomic.c +2
-6@@ -578,13 +578,9 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, ret =drm_plane_check_pixel_format (plane, fb->format->format, fb->modifier);if (ret) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_ATOMIC ("[PLANE:%d:%s] invalid pixel format %s, modifier 0x%llx\n" , +DRM_DEBUG_ATOMIC ("[PLANE:%d:%s] invalid pixel format %p4cc, modifier 0x%llx\n" , plane->base.id, plane->name, -drm_get_format_name (fb->format->format, - &format_name), - fb->modifier); + &fb->format->format, fb->modifier);return ret; }drivers/gpu/drm/drm_crtc.c +2
-5@@ -663,11 +663,8 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, fb->format->format, fb->modifier);if (ret) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s, modifier 0x%llx\n" , -drm_get_format_name (fb->format->format, - &format_name), +DRM_DEBUG_KMS ("Invalid pixel format %p4cc, modifier 0x%llx\n" , + &fb->format->format, fb->modifier); goto out; }drivers/gpu/drm/drm_fourcc.c +0
-0
drivers/gpu/drm/drm_fourcc.c line 36
Quoted 7 lines
drivers/gpu/drm/drm_fourcc.c +0
-4@@ -30,11 +30,6 @@#include <drm/drm_device.h> #include <drm/drm_fourcc.h> -static char printable_char (int c) -{ -return isascii (c) &&isprint (c) ? c :'?' ; -}
If it goes as an ABI than your dot is incompatible with this and '?' should be used instead in the patch 1. And I bend towards suggested '?' rather than '.'.
Also it means that you probably would need different specifiers for full and short formats.
Quoted 190 lines
drivers/gpu/drm/drm_fourcc.c +0
-20/** * drm_mode_legacy_fb_format - compute drm fourcc code from legacy description * @bpp: bits per pixels @@ -130,26 +125,6 @@ uint32_t drm_driver_legacy_fb_format(struct drm_device *dev, }EXPORT_SYMBOL (drm_driver_legacy_fb_format); -/** -* drm_get_format_name - fill a string with a drm fourcc format's name -* @format: format to compute name of -* @buf: caller-supplied buffer -*/ -const char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf) -{ -snprintf (buf->str,sizeof (buf->str), -"%c%c%c%c %s-endian (0x%08x)" , -printable_char (format &0xff ), -printable_char ((format >>8 ) &0xff ), -printable_char ((format >>16 ) &0xff ), -printable_char ((format >>24 ) &0x7f ), - format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , - format); - -return buf->str; -} -EXPORT_SYMBOL (drm_get_format_name); -/* * Internal function to query information for a given format. See * drm_format_info() for the public API. drivers/gpu/drm/drm_framebuffer.c +3
-8@@ -177,11 +177,8 @@ static int framebuffer_check(struct drm_device *dev,/* check if the format is supported at all */ if (!__drm_format_info (r->pixel_format)) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , -drm_get_format_name (r->pixel_format, - &format_name)); +DRM_DEBUG_KMS ("bad framebuffer format %p4cc\n" , + &r->pixel_format);return -EINVAL ; }@@ -1160,14 +1157,12 @@ EXPORT_SYMBOL(drm_framebuffer_plane_height);void drm_framebuffer_print_info (struct drm_printer *p,unsigned int indent,const struct drm_framebuffer *fb) { -struct drm_format_name_buf format_name;unsigned int i;drm_printf_indent (p, indent,"allocated by = %s\n" , fb->comm);drm_printf_indent (p, indent,"refcount=%u\n" ,drm_framebuffer_read_refcount (fb)); -drm_printf_indent (p, indent,"format=%s\n" , -drm_get_format_name (fb->format->format, &format_name)); +drm_printf_indent (p, indent,"format=%p4cc\n" , &fb->format->format);drm_printf_indent (p, indent,"modifier=0x%llx\n" , fb->modifier);drm_printf_indent (p, indent,"size=%ux%u\n" , fb->width, fb->height);drm_printf_indent (p, indent,"layers:\n" );drivers/gpu/drm/drm_mipi_dbi.c +2
-3@@ -203,7 +203,6 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,struct drm_gem_object *gem =drm_gem_fb_get_obj (fb,0 );struct drm_gem_cma_object *cma_obj =to_drm_gem_cma_obj (gem);struct dma_buf_attachment *import_attach = gem->import_attach; -struct drm_format_name_buf format_name;void *src = cma_obj->vaddr;int ret =0 ;@@ -225,8 +224,8 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,drm_fb_xrgb8888_to_rgb565 (dst, src, fb, clip, swap);break ;default : -drm_err_once (fb->dev,"Format is not supported: %s\n" , -drm_get_format_name (fb->format->format, &format_name)); +drm_err_once (fb->dev,"Format is not supported: %p4cc\n" , + &fb->format->format);return -EINVAL ; }drivers/gpu/drm/drm_plane.c +2
-6@@ -623,12 +623,8 @@ static int __setplane_check(struct drm_plane *plane, ret =drm_plane_check_pixel_format (plane, fb->format->format, fb->modifier);if (ret) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s, modifier 0x%llx\n" , -drm_get_format_name (fb->format->format, - &format_name), - fb->modifier); +DRM_DEBUG_KMS ("Invalid pixel format %p4cc, modifier 0x%llx\n" , + &fb->format->format, fb->modifier);return ret; }drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +2
-3@@ -549,16 +549,15 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -struct drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); -DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , +DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%p4cc)\n" , addr, fb->width, fb->height, fmt, -drm_get_format_name (fb->format->format, &format_name)); + &fb->format->format);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);drivers/gpu/drm/i915/display/intel_display.c +4
-10@@ -13319,7 +13319,6 @@ static void intel_dump_plane_state(const struct intel_plane_state *plane_state)struct intel_plane *plane =to_intel_plane (plane_state->uapi.plane);struct drm_i915_private *i915 =to_i915 (plane->base.dev);const struct drm_framebuffer *fb = plane_state->hw.fb; -struct drm_format_name_buf format_name;if (!fb) { drm_dbg_kms(&i915->drm,@@ -13330,10 +13329,9 @@ static void intel_dump_plane_state(const struct intel_plane_state *plane_state) }drm_dbg_kms (&i915->drm, -"[PLANE:%d:%s] fb: [FB:%d] %ux%u format = %s modifier = 0x%llx, visible: %s\n" , +"[PLANE:%d:%s] fb: [FB:%d] %ux%u format = %p4cc modifier = 0x%llx, visible: %s\n" , plane->base.base.id, plane->base.name, - fb->base.id, fb->width, fb->height, -drm_get_format_name (fb->format->format, &format_name), + fb->base.id, fb->width, fb->height, &fb->format->format, fb->modifier,yesno (plane_state->uapi.visible));drm_dbg_kms (&i915->drm,"\trotation: 0x%x, scaler: %d\n" , plane_state->hw.rotation, plane_state->scaler_id);@@ -17927,13 +17925,9 @@ static int intel_framebuffer_init(struct intel_framebuffer *intel_fb,if (!drm_any_plane_has_format (&dev_priv->drm, mode_cmd->pixel_format, mode_cmd->modifier[0 ])) { -struct drm_format_name_buf format_name; -drm_dbg_kms (&dev_priv->drm, -"unsupported pixel format %s / modifier 0x%llx\n" , -drm_get_format_name (mode_cmd->pixel_format, - &format_name), - mode_cmd->modifier[0 ]); +"unsupported pixel format %p4cc / modifier 0x%llx\n" , + &mode_cmd->pixel_format, mode_cmd->modifier[0 ]); goto err; }drivers/gpu/drm/i915/display/intel_display_debugfs.c +0
-4@@ -771,21 +771,21 @@ static void intel_plane_uapi_info(struct seq_file *m, struct intel_plane *plane)const struct intel_plane_state *plane_state =to_intel_plane_state (plane->base.state);const struct drm_framebuffer *fb = plane_state->uapi.fb; -struct drm_format_name_buf format_name;struct drm_rect src, dst;char rot_str[48 ]; src =drm_plane_state_src (&plane_state->uapi); dst =drm_plane_state_dest (&plane_state->uapi); -if (fb) -drm_get_format_name (fb->format->format, &format_name); -plane_rotation (rot_str,sizeof (rot_str), plane_state->uapi.rotation);
drivers/gpu/drm/i915/display/intel_display_debugfs.c static void intel_plane_uapi_info(struct seq_file *m, struct intel_plane *plane) · line 789
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_display_debugfs.c +6
-2- seq_printf(m, "\t\tuapi: [FB:%d] %s,0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", - fb ? fb->base.id : 0, fb ? format_name.str : "n/a", +seq_printf (m,"\t\tuapi: [FB:%d] " , fb ? fb->base.id :0 ); +if (fb) +seq_printf (m,"%p4cc" , &fb->format->format); +else +seq_puts (m,"n/a" ); + seq_printf(m, ",0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n",
Why not to keep two seq_printf() calls?
if (fb) {
seq_printf();
} else {
seq_printf();
}?
Quoted 276 lines
drivers/gpu/drm/i915/display/intel_display_debugfs.c +0
-0fb ? fb->modifier :0 , fb ? fb->width : 0, fb ? fb->height : 0,drivers/gpu/drm/i915/display/intel_display_debugfs.c +2
-5plane_visibility(plane_state),@@ -804,19 +804,16 @@ static void intel_plane_hw_info(struct seq_file *m, struct intel_plane *plane)const struct intel_plane_state *plane_state =to_intel_plane_state (plane->base.state);const struct drm_framebuffer *fb = plane_state->hw.fb; -struct drm_format_name_buf format_name;char rot_str[48 ];if (!fb)return ; -drm_get_format_name (fb->format->format, &format_name); -plane_rotation (rot_str,sizeof (rot_str), plane_state->hw.rotation); - seq_printf(m, "\t\thw: [FB:%d] %s,0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", - fb->base.id, format_name.str, + seq_printf(m, "\t\thw: [FB:%d] %p4cc,0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", + fb->base.id, &fb->format->format, fb->modifier, fb->width, fb->height, yesno(plane_state->uapi.visible), DRM_RECT_FP_ARG(&plane_state->uapi.src),drivers/gpu/drm/i915/display/intel_sprite.c +2
-4@@ -2285,7 +2285,6 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state,struct drm_i915_private *dev_priv =to_i915 (plane->base.dev);const struct drm_framebuffer *fb = plane_state->hw.fb;unsigned int rotation = plane_state->hw.rotation; -struct drm_format_name_buf format_name;if (!fb)return 0 ;@@ -2333,9 +2332,8 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state,case DRM_FORMAT_XVYU12_16161616 :case DRM_FORMAT_XVYU16161616 :drm_dbg_kms (&dev_priv->drm, -"Unsupported pixel format %s for 90/270!\n" , -drm_get_format_name (fb->format->format, - &format_name)); +"Unsupported pixel format %p4cc for 90/270!\n" , + &fb->format->format);return -EINVAL ;default :break ;drivers/gpu/drm/mcde/mcde_display.c +2
-4@@ -1161,7 +1161,6 @@ static void mcde_display_enable(struct drm_simple_display_pipe *pipe,int dsi_pkt_size;int fifo_wtrmrk;int cpp = fb->format->cpp[0 ]; -struct drm_format_name_buf tmp;u32 dsi_formatter_frame;u32 val;int ret;@@ -1173,9 +1172,8 @@ static void mcde_display_enable(struct drm_simple_display_pipe *pipe,return ; } -dev_info (drm->dev,"enable MCDE, %d x %d format %s\n" , - mode->hdisplay, mode->vdisplay, -drm_get_format_name (format, &tmp)); +dev_info (drm->dev,"enable MCDE, %d x %d format %p4cc\n" , + mode->hdisplay, mode->vdisplay, &format);/* Clear any pending interrupts */ drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +2
-4@@ -71,7 +71,6 @@ static void _dpu_crtc_setup_blend_cfg(struct dpu_crtc_mixer *mixer, {struct dpu_hw_mixer *lm = mixer->hw_lm;uint32_t blend_op; -struct drm_format_name_buf format_name;/* default to opaque blending */ blend_op = DPU_BLEND_FG_ALPHA_FG_CONST |@@ -87,9 +86,8 @@ static void _dpu_crtc_setup_blend_cfg(struct dpu_crtc_mixer *mixer, lm->ops.setup_blend_config (lm, pstate->stage,0xFF ,0 , blend_op); -DPU_DEBUG ("format:%s, alpha_en:%u blend_op:0x%x\n" , -drm_get_format_name (format->base.pixel_format, &format_name), - format->alpha_enable, blend_op); +DPU_DEBUG ("format:%p4cc, alpha_en:%u blend_op:0x%x\n" , + &format->base.pixel_format, format->alpha_enable, blend_op); }static void _dpu_crtc_program_lm_output_roi (struct drm_crtc *crtc)drivers/gpu/drm/nouveau/nouveau_display.c +3
-6@@ -322,12 +322,9 @@ nouveau_framebuffer_new(struct drm_device *dev, mode_cmd->pitches[0] >= 0x10000 || /* at most 64k pitch */ (mode_cmd->pitches[1] && /* pitches for planes must match */ mode_cmd->pitches[0] != mode_cmd->pitches[1]))) { -struct drm_format_name_buf format_name; -DRM_DEBUG_KMS ("Unsuitable framebuffer: format: %s; pitches: 0x%x\n 0x%x\n" , -drm_get_format_name (mode_cmd->pixel_format, - &format_name), - mode_cmd->pitches[0 ], - mode_cmd->pitches[1 ]); +DRM_DEBUG_KMS ("Unsuitable framebuffer: format: %p4cc; pitches: 0x%x\n 0x%x\n" , + &mode_cmd->pixel_format, + mode_cmd->pitches[0 ], mode_cmd->pitches[1 ]);return -EINVAL ; }drivers/gpu/drm/radeon/atombios_crtc.c +4
-6@@ -1157,7 +1157,6 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1267,8 +1266,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }@@ -1478,7 +1477,6 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1579,8 +1577,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }drivers/gpu/drm/sun4i/sun4i_backend.c +2
-4@@ -510,7 +510,6 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine,struct sun4i_layer_state *layer_state =state_to_sun4i_layer_state (plane_state);struct drm_framebuffer *fb = plane_state->fb; -struct drm_format_name_buf format_name;if (!sun4i_backend_plane_is_supported (plane_state, &layer_state->uses_frontend))@@ -527,9 +526,8 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine, } } -DRM_DEBUG_DRIVER ("Plane FB format is %s\n" , -drm_get_format_name (fb->format->format, - &format_name)); +DRM_DEBUG_DRIVER ("Plane FB format is %p4cc\n" , + &fb->format->format);if (fb->format->has_alpha || (plane_state->alpha !=DRM_BLEND_ALPHA_OPAQUE )) num_alpha_planes++;drivers/gpu/drm/vkms/vkms_writeback.c +2
-5@@ -42,11 +42,8 @@ static int vkms_wb_encoder_atomic_check(struct drm_encoder *encoder, }if (fb->format->format != vkms_wb_formats[0 ]) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , -drm_get_format_name (fb->format->format, - &format_name)); +DRM_DEBUG_KMS ("Invalid pixel format %p4cc\n" , + &fb->format->format);return -EINVAL ; }drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +6
-9@@ -895,7 +895,6 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,struct vmw_framebuffer_surface *vfbs;enum SVGA3dSurfaceFormat format;int ret; -struct drm_format_name_buf format_name;/* 3D is only supported on HWv8 and newer hosts */ if (dev_priv->active_display_unit == vmw_du_legacy)@@ -933,8 +932,8 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv, format =SVGA3D_A1R5G5B5 ;break ;default : -DRM_ERROR ("Invalid pixel format: %s\n" , -drm_get_format_name (mode_cmd->pixel_format, &format_name)); +DRM_ERROR ("Invalid pixel format: %p4cc\n" , + &mode_cmd->pixel_format);return -EINVAL ; }@@ -1149,7 +1148,6 @@ static int vmw_create_bo_proxy(struct drm_device *dev,uint32_t format;struct vmw_resource *res;unsigned int bytes_pp; -struct drm_format_name_buf format_name;int ret;switch (mode_cmd->pixel_format) {@@ -1171,8 +1169,8 @@ static int vmw_create_bo_proxy(struct drm_device *dev,break ;default : -DRM_ERROR ("Invalid framebuffer format %s\n" , -drm_get_format_name (mode_cmd->pixel_format, &format_name)); +DRM_ERROR ("Invalid framebuffer format %p4cc\n" , + &mode_cmd->pixel_format);return -EINVAL ; }@@ -1216,7 +1214,6 @@ static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv,struct drm_device *dev = dev_priv->dev;struct vmw_framebuffer_bo *vfbd;unsigned int requested_size; -struct drm_format_name_buf format_name;int ret; requested_size = mode_cmd->height * mode_cmd->pitches[0 ];@@ -1236,8 +1233,8 @@ static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv,case DRM_FORMAT_RGB565 :break ;default : -DRM_ERROR ("Invalid pixel format: %s\n" , -drm_get_format_name (mode_cmd->pixel_format, &format_name)); +DRM_ERROR ("Invalid pixel format: %p4cc\n" , + &mode_cmd->pixel_format);return -EINVAL ; } }include/drm/drm_fourcc.h +0
-1@@ -318,6 +318,5 @@ unsigned int drm_format_info_block_height(const struct drm_format_info *info, int plane);uint64_t drm_format_info_min_pitch (const struct drm_format_info *info,int plane,unsigned int buffer_width); -const char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);#endif /* __DRM_FOURCC_H__ */ Signature · 1 line
2.29.2
Signature · 8 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 3/3] drm: Switch to %p4cc format modifier
Hi Andy,
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Sakari Ailus
Switch DRM drivers from
drm_get_format_name()to %p4cc. This gets rid of a large number of temporary variables at the same time.What a nice clean up!
Reviewed-by Andy Shevchenko <[email protected]>
Thanks!
Quoted 5 lines
after addressing nit-picks below.
Side note (no need to implement esp. right now): it seems often it's coupled with modifier, would be nice to have them together that %p4ccM or so can do it in one go.
...
Quoted 16 lines
drivers/gpu/drm/drm_fourcc.c line 36
Quoted 12 lines
drivers/gpu/drm/drm_fourcc.c +0
-4@@ -30,11 +30,6 @@#include <drm/drm_device.h> #include <drm/drm_fourcc.h> -static char printable_char (int c) -{ -return isascii (c) &&isprint (c) ? c :'?' ; -}If it goes as an ABI than your dot is incompatible with this and '?' should be used instead in the patch 1. And I bend towards suggested '?' rather than '.'.
Quoted 2 lines
Also it means that you probably would need different specifiers for full and short formats.
I thought of that, but then the resulting string would be indeed different and comparing short and long formats would be harder. Remember this is for debug prints. If the format is too long, then it should be made shorter, but during the earlier review rounds people have expressed interest in having this information there.
"?" can be expanded by the shell whereas "." is not. If DRM folks think we should go back to "?" I'm fine with that. Also note that there's something wrong with the fourcc code to begin with if it's got either "." or "?".
Signature · 7 lines
Regards, Sakari Ailus _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 3/3] drm: Switch to %p4cc format modifier
In reply to Andy ShevchenkoOn Mon, Feb 15, 2021 at 03:41:14PM +0200, Andy Shevchenko wrote:
...
Quoted 33 lines
Quoted 20 lines
drivers/gpu/drm/i915/display/intel_display_debugfs.c +0
-4@@ -771,21 +771,21 @@ static void intel_plane_uapi_info(struct seq_file *m, struct intel_plane *plane)const struct intel_plane_state *plane_state =to_intel_plane_state (plane->base.state);const struct drm_framebuffer *fb = plane_state->uapi.fb; -struct drm_format_name_buf format_name;struct drm_rect src, dst;char rot_str[48 ]; src =drm_plane_state_src (&plane_state->uapi); dst =drm_plane_state_dest (&plane_state->uapi); -if (fb) -drm_get_format_name (fb->format->format, &format_name); -plane_rotation (rot_str,sizeof (rot_str), plane_state->uapi.rotation);drivers/gpu/drm/i915/display/intel_display_debugfs.c static void intel_plane_uapi_info(struct seq_file *m, struct intel_plane *plane) · line 789
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_display_debugfs.c +6
-2- seq_printf(m, "\t\tuapi: [FB:%d] %s,0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", - fb ? fb->base.id : 0, fb ? format_name.str : "n/a", +seq_printf (m,"\t\tuapi: [FB:%d] " , fb ? fb->base.id :0 ); +if (fb) +seq_printf (m,"%p4cc" , &fb->format->format); +else +seq_puts (m,"n/a" ); + seq_printf(m, ",0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n",Why not to keep two
seq_printf()calls?
Quoted 7 lines
if (fb) { seq_printf(); } else { seq_printf(); }?
I could, but it'd repeat a lot of the same format string that is very complicated right now. Therefore I thought it's better to split.
Or do you mean seq_printf() vs. seq_puts()? checkpatch.pl (rightly) warns about it.
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_display_debugfs.c +0
-0fb ? fb->modifier :0 , fb ? fb->width : 0, fb ? fb->height : 0,
plane_visibility(plane_state),
Signature · 5 lines
Sakari Ailus _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Andy Shevchenko
reviewerRe: [PATCH v7 3/3] drm: Switch to %p4cc format modifier
Quoted 18 lines · Sakari Ailus
On Mon, Feb 15, 2021 at 03:41:14PM +0200, Andy Shevchenko wrote:
...Quoted 16 lines
drivers/gpu/drm/i915/display/intel_display_debugfs.c static void intel_plane_uapi_info(struct seq_file *m, struct intel_plane *plane) · line 788
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_display_debugfs.c +6
-0+seq_printf (m,"\t\tuapi: [FB:%d] " , fb ? fb->base.id :0 ); +if (fb) +seq_printf (m,"%p4cc" , &fb->format->format); +else +seq_puts (m,"n/a" ); + seq_printf(m, ",0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n",Why not to keep two
seq_printf()calls?if (fb) { seq_printf(); } else { seq_printf(); }
Quoted 4 lines
Quoted 1 line
?
I could, but it'd repeat a lot of the same format string that is very complicated right now. Therefore I thought it's better to split.
It's fine, why not?
Quoted 2 lines
Or do you mean
seq_printf()vs.seq_puts()? checkpatch.pl (rightly) warns about it.
If it doesn't take run-time parameters, then definitely if (fb)
seq_printf(); else seq_puts();
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_display_debugfs.c +0
-0fb ? fb->modifier :0 , fb ? fb->width :0 , fb ? fb->height :0 , plane_visibility(plane_state),
Signature · 8 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 3/3] drm: Switch to %p4cc format modifier
In reply to Sakari AilusQuoted 4 lines · Sakari Ailus
Switch DRM drivers from
drm_get_format_name()to %p4cc. This gets rid of a large number of temporary variables at the same time.Signed-off-by Sakari Ailus <[email protected]>
I wonder if I could this via printk tree. Or if should rather go via DRM tree.
Anyway, there will be v8 with small changes in the 1st patch.
Best Regards,
Petr
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 3/3] drm: Switch to %p4cc format modifier
In reply to Sakari AilusHi
Am 15.02.21 um 12:40 schrieb Sakari Ailus:
Quoted 25 lines
Switch DRM drivers from
drm_get_format_name()to %p4cc. This gets rid of a large number of temporary variables at the same time.Signed-off-by Sakari Ailus <[email protected]>--- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 5 ++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 ++-- .../arm/display/komeda/komeda_format_caps.h | 11 -------- .../arm/display/komeda/komeda_framebuffer.c | 4 +-- .../gpu/drm/arm/display/komeda/komeda_plane.c | 6 ++--- drivers/gpu/drm/arm/malidp_mw.c | 7 ++---- drivers/gpu/drm/drm_atomic.c | 8 ++---- drivers/gpu/drm/drm_crtc.c | 7 ++---- drivers/gpu/drm/drm_fourcc.c | 25 ------------------- drivers/gpu/drm/drm_framebuffer.c | 11 +++----- drivers/gpu/drm/drm_mipi_dbi.c | 5 ++-- drivers/gpu/drm/drm_plane.c | 8 ++---- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 5 ++-- drivers/gpu/drm/i915/display/intel_display.c | 14 +++-------- .../drm/i915/display/intel_display_debugfs.c | 19 ++++++-------- drivers/gpu/drm/i915/display/intel_sprite.c | 6 ++--- drivers/gpu/drm/mcde/mcde_display.c | 6 ++---
Quoted 8 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 6 ++--- drivers/gpu/drm/nouveau/nouveau_display.c | 9 +++---- drivers/gpu/drm/radeon/atombios_crtc.c | 10 +++----- drivers/gpu/drm/sun4i/sun4i_backend.c | 6 ++--- drivers/gpu/drm/vkms/vkms_writeback.c | 7 ++---- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 15 +++++------ include/drm/drm_fourcc.h | 1 - 27 files changed, 64 insertions(+), 157 deletions(-)
This is a nice patchset. For the driver-related changes:
But landing this patch will certainly give us build errors. There are at least 3 git trees involved: drm-misc-next, amd and i915. I'd expect at least one of them to have additional changes that still require drm_get_format_name().
IMHO we should remove drm_get_format_name() in a later patch. Please remove the changes in drm_fourcc.{c,h} from this patch and maybe add a TODO comment to the declaration that the function is supposed to be removed.
I would merge the patchset through drm-misc-next. And the final removal patch during the next cycle. Ok?
Best regard
Thomas
Quoted 712 lines
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +2
-3@@ -1862,7 +1862,6 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1981,8 +1980,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +2
-3@@ -1904,7 +1904,6 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2023,8 +2022,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2
-3@@ -1820,7 +1820,6 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1929,8 +1928,8 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +2
-3@@ -1791,7 +1791,6 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1902,8 +1901,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-3@@ -4465,7 +4465,6 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev,const struct drm_framebuffer *fb = plane_state->fb;const struct amdgpu_framebuffer *afb =to_amdgpu_framebuffer (plane_state->fb); -struct drm_format_name_buf format_name;int ret;memset (plane_info,0 ,sizeof (*plane_info));@@ -4513,8 +4512,8 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev,break ;default :DRM_ERROR ( -"Unsupported screen format %s\n" , -drm_get_format_name (fb->format->format, &format_name)); +"Unsupported screen format %p4cc\n" , + &fb->format->format);return -EINVAL ; }drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h +0
-11@@ -82,17 +82,6 @@ struct komeda_format_caps_table {extern u64 komeda_supported_modifiers[]; -static inline const char *komeda_get_format_name (u32 fourcc,u64 modifier) -{ -struct drm_format_name_buf buf; -static char name[64 ]; - -snprintf (name,sizeof (name),"%s with modifier: 0x%llx." , -drm_get_format_name (fourcc, &buf), modifier); - -return name; -} -const struct komeda_format_caps *komeda_get_format_caps (struct komeda_format_caps_table *table,u32 fourcc,u64 modifier);drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c +2
-2@@ -276,8 +276,8 @@ bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type, supported =komeda_format_mod_supported (&mdev->fmt_tbl, layer_type, fourcc, modifier, rot);if (!supported) -DRM_DEBUG_ATOMIC ("Layer TYPE: %d doesn't support fb FMT: %s.\n" , - layer_type,komeda_get_format_name (fourcc, modifier)); +DRM_DEBUG_ATOMIC ("Layer TYPE: %d doesn't support fb FMT: %p4cc with modifier: 0x%llx.\n" , + layer_type, &fourcc, modifier);return supported; }drivers/gpu/drm/arm/display/komeda/komeda_plane.c +2
-4@@ -49,10 +49,8 @@ komeda_plane_init_data_flow(struct drm_plane_state *st, dflow->rot =drm_rotation_simplify (st->rotation, caps->supported_rots);if (!has_bits (dflow->rot, caps->supported_rots)) { -DRM_DEBUG_ATOMIC ("rotation(0x%x) isn't supported by %s.\n" , - dflow->rot, -komeda_get_format_name (caps->fourcc, - fb->modifier)); +DRM_DEBUG_ATOMIC ("rotation(0x%x) isn't supported by %p4cc with modifier: 0x%llx.\n" , + dflow->rot, &caps->fourcc, fb->modifier);return -EINVAL ; }drivers/gpu/drm/arm/malidp_mw.c +2
-5@@ -151,11 +151,8 @@ malidp_mw_encoder_atomic_check(struct drm_encoder *encoder,malidp_hw_get_format_id (&malidp->dev->hw->map,SE_MEMWRITE , fb->format->format, !!fb->modifier);if (mw_state->format ==MALIDP_INVALID_FORMAT_ID ) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , -drm_get_format_name (fb->format->format, - &format_name)); +DRM_DEBUG_KMS ("Invalid pixel format %p4cc\n" , + &fb->format->format);return -EINVAL ; }drivers/gpu/drm/drm_atomic.c +2
-6@@ -578,13 +578,9 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, ret =drm_plane_check_pixel_format (plane, fb->format->format, fb->modifier);if (ret) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_ATOMIC ("[PLANE:%d:%s] invalid pixel format %s, modifier 0x%llx\n" , +DRM_DEBUG_ATOMIC ("[PLANE:%d:%s] invalid pixel format %p4cc, modifier 0x%llx\n" , plane->base.id, plane->name, -drm_get_format_name (fb->format->format, - &format_name), - fb->modifier); + &fb->format->format, fb->modifier);return ret; }drivers/gpu/drm/drm_crtc.c +2
-5@@ -663,11 +663,8 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, fb->format->format, fb->modifier);if (ret) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s, modifier 0x%llx\n" , -drm_get_format_name (fb->format->format, - &format_name), +DRM_DEBUG_KMS ("Invalid pixel format %p4cc, modifier 0x%llx\n" , + &fb->format->format, fb->modifier); goto out; }drivers/gpu/drm/drm_fourcc.c +0
-25@@ -30,11 +30,6 @@#include <drm/drm_device.h> #include <drm/drm_fourcc.h> -static char printable_char (int c) -{ -return isascii (c) &&isprint (c) ? c :'?' ; -} -/** * drm_mode_legacy_fb_format - compute drm fourcc code from legacy description * @bpp: bits per pixels @@ -130,26 +125,6 @@ uint32_t drm_driver_legacy_fb_format(struct drm_device *dev, }EXPORT_SYMBOL (drm_driver_legacy_fb_format); -/** -* drm_get_format_name - fill a string with a drm fourcc format's name -* @format: format to compute name of -* @buf: caller-supplied buffer -*/ -const char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf) -{ -snprintf (buf->str,sizeof (buf->str), -"%c%c%c%c %s-endian (0x%08x)" , -printable_char (format &0xff ), -printable_char ((format >>8 ) &0xff ), -printable_char ((format >>16 ) &0xff ), -printable_char ((format >>24 ) &0x7f ), - format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , - format); - -return buf->str; -} -EXPORT_SYMBOL (drm_get_format_name); -/* * Internal function to query information for a given format. See * drm_format_info() for the public API. drivers/gpu/drm/drm_framebuffer.c +3
-8@@ -177,11 +177,8 @@ static int framebuffer_check(struct drm_device *dev,/* check if the format is supported at all */ if (!__drm_format_info (r->pixel_format)) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , -drm_get_format_name (r->pixel_format, - &format_name)); +DRM_DEBUG_KMS ("bad framebuffer format %p4cc\n" , + &r->pixel_format);return -EINVAL ; }@@ -1160,14 +1157,12 @@ EXPORT_SYMBOL(drm_framebuffer_plane_height);void drm_framebuffer_print_info (struct drm_printer *p,unsigned int indent,const struct drm_framebuffer *fb) { -struct drm_format_name_buf format_name;unsigned int i;drm_printf_indent (p, indent,"allocated by = %s\n" , fb->comm);drm_printf_indent (p, indent,"refcount=%u\n" ,drm_framebuffer_read_refcount (fb)); -drm_printf_indent (p, indent,"format=%s\n" , -drm_get_format_name (fb->format->format, &format_name)); +drm_printf_indent (p, indent,"format=%p4cc\n" , &fb->format->format);drm_printf_indent (p, indent,"modifier=0x%llx\n" , fb->modifier);drm_printf_indent (p, indent,"size=%ux%u\n" , fb->width, fb->height);drm_printf_indent (p, indent,"layers:\n" );drivers/gpu/drm/drm_mipi_dbi.c +2
-3@@ -203,7 +203,6 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,struct drm_gem_object *gem =drm_gem_fb_get_obj (fb,0 );struct drm_gem_cma_object *cma_obj =to_drm_gem_cma_obj (gem);struct dma_buf_attachment *import_attach = gem->import_attach; -struct drm_format_name_buf format_name;void *src = cma_obj->vaddr;int ret =0 ;@@ -225,8 +224,8 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,drm_fb_xrgb8888_to_rgb565 (dst, src, fb, clip, swap);break ;default : -drm_err_once (fb->dev,"Format is not supported: %s\n" , -drm_get_format_name (fb->format->format, &format_name)); +drm_err_once (fb->dev,"Format is not supported: %p4cc\n" , + &fb->format->format);return -EINVAL ; }drivers/gpu/drm/drm_plane.c +2
-6@@ -623,12 +623,8 @@ static int __setplane_check(struct drm_plane *plane, ret =drm_plane_check_pixel_format (plane, fb->format->format, fb->modifier);if (ret) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s, modifier 0x%llx\n" , -drm_get_format_name (fb->format->format, - &format_name), - fb->modifier); +DRM_DEBUG_KMS ("Invalid pixel format %p4cc, modifier 0x%llx\n" , + &fb->format->format, fb->modifier);return ret; }drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +2
-3@@ -549,16 +549,15 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -struct drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); -DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , +DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%p4cc)\n" , addr, fb->width, fb->height, fmt, -drm_get_format_name (fb->format->format, &format_name)); + &fb->format->format);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);drivers/gpu/drm/i915/display/intel_display.c +4
-10@@ -13319,7 +13319,6 @@ static void intel_dump_plane_state(const struct intel_plane_state *plane_state)struct intel_plane *plane =to_intel_plane (plane_state->uapi.plane);struct drm_i915_private *i915 =to_i915 (plane->base.dev);const struct drm_framebuffer *fb = plane_state->hw.fb; -struct drm_format_name_buf format_name;if (!fb) { drm_dbg_kms(&i915->drm,@@ -13330,10 +13329,9 @@ static void intel_dump_plane_state(const struct intel_plane_state *plane_state) }drm_dbg_kms (&i915->drm, -"[PLANE:%d:%s] fb: [FB:%d] %ux%u format = %s modifier = 0x%llx, visible: %s\n" , +"[PLANE:%d:%s] fb: [FB:%d] %ux%u format = %p4cc modifier = 0x%llx, visible: %s\n" , plane->base.base.id, plane->base.name, - fb->base.id, fb->width, fb->height, -drm_get_format_name (fb->format->format, &format_name), + fb->base.id, fb->width, fb->height, &fb->format->format, fb->modifier,yesno (plane_state->uapi.visible));drm_dbg_kms (&i915->drm,"\trotation: 0x%x, scaler: %d\n" , plane_state->hw.rotation, plane_state->scaler_id);@@ -17927,13 +17925,9 @@ static int intel_framebuffer_init(struct intel_framebuffer *intel_fb,if (!drm_any_plane_has_format (&dev_priv->drm, mode_cmd->pixel_format, mode_cmd->modifier[0 ])) { -struct drm_format_name_buf format_name; -drm_dbg_kms (&dev_priv->drm, -"unsupported pixel format %s / modifier 0x%llx\n" , -drm_get_format_name (mode_cmd->pixel_format, - &format_name), - mode_cmd->modifier[0 ]); +"unsupported pixel format %p4cc / modifier 0x%llx\n" , + &mode_cmd->pixel_format, mode_cmd->modifier[0 ]); goto err; }drivers/gpu/drm/i915/display/intel_display_debugfs.c +8
-11@@ -771,21 +771,21 @@ static void intel_plane_uapi_info(struct seq_file *m, struct intel_plane *plane)const struct intel_plane_state *plane_state =to_intel_plane_state (plane->base.state);const struct drm_framebuffer *fb = plane_state->uapi.fb; -struct drm_format_name_buf format_name;struct drm_rect src, dst;char rot_str[48 ]; src =drm_plane_state_src (&plane_state->uapi); dst =drm_plane_state_dest (&plane_state->uapi); -if (fb) -drm_get_format_name (fb->format->format, &format_name); -plane_rotation (rot_str,sizeof (rot_str), plane_state->uapi.rotation); - seq_printf(m, "\t\tuapi: [FB:%d] %s,0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", - fb ? fb->base.id : 0, fb ? format_name.str : "n/a", +seq_printf (m,"\t\tuapi: [FB:%d] " , fb ? fb->base.id :0 ); +if (fb) +seq_printf (m,"%p4cc" , &fb->format->format); +else +seq_puts (m,"n/a" ); + seq_printf(m, ",0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", fb ? fb->modifier : 0, fb ? fb->width : 0, fb ? fb->height : 0, plane_visibility(plane_state),@@ -804,19 +804,16 @@ static void intel_plane_hw_info(struct seq_file *m, struct intel_plane *plane)const struct intel_plane_state *plane_state =to_intel_plane_state (plane->base.state);const struct drm_framebuffer *fb = plane_state->hw.fb; -struct drm_format_name_buf format_name;char rot_str[48 ];if (!fb)return ; -drm_get_format_name (fb->format->format, &format_name); -plane_rotation (rot_str,sizeof (rot_str), plane_state->hw.rotation); - seq_printf(m, "\t\thw: [FB:%d] %s,0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", - fb->base.id, format_name.str, + seq_printf(m, "\t\thw: [FB:%d] %p4cc,0x%llx,%dx%d, visible=%s, src=" DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n", + fb->base.id, &fb->format->format, fb->modifier, fb->width, fb->height, yesno(plane_state->uapi.visible), DRM_RECT_FP_ARG(&plane_state->uapi.src),drivers/gpu/drm/i915/display/intel_sprite.c +2
-4@@ -2285,7 +2285,6 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state,struct drm_i915_private *dev_priv =to_i915 (plane->base.dev);const struct drm_framebuffer *fb = plane_state->hw.fb;unsigned int rotation = plane_state->hw.rotation; -struct drm_format_name_buf format_name;if (!fb)return 0 ;@@ -2333,9 +2332,8 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state,case DRM_FORMAT_XVYU12_16161616 :case DRM_FORMAT_XVYU16161616 :drm_dbg_kms (&dev_priv->drm, -"Unsupported pixel format %s for 90/270!\n" , -drm_get_format_name (fb->format->format, - &format_name)); +"Unsupported pixel format %p4cc for 90/270!\n" , + &fb->format->format);return -EINVAL ;default :break ;drivers/gpu/drm/mcde/mcde_display.c +2
-4@@ -1161,7 +1161,6 @@ static void mcde_display_enable(struct drm_simple_display_pipe *pipe,int dsi_pkt_size;int fifo_wtrmrk;int cpp = fb->format->cpp[0 ]; -struct drm_format_name_buf tmp;u32 dsi_formatter_frame;u32 val;int ret;@@ -1173,9 +1172,8 @@ static void mcde_display_enable(struct drm_simple_display_pipe *pipe,return ; } -dev_info (drm->dev,"enable MCDE, %d x %d format %s\n" , - mode->hdisplay, mode->vdisplay, -drm_get_format_name (format, &tmp)); +dev_info (drm->dev,"enable MCDE, %d x %d format %p4cc\n" , + mode->hdisplay, mode->vdisplay, &format);/* Clear any pending interrupts */ drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +2
-4@@ -71,7 +71,6 @@ static void _dpu_crtc_setup_blend_cfg(struct dpu_crtc_mixer *mixer, {struct dpu_hw_mixer *lm = mixer->hw_lm;uint32_t blend_op; -struct drm_format_name_buf format_name;/* default to opaque blending */ blend_op = DPU_BLEND_FG_ALPHA_FG_CONST |@@ -87,9 +86,8 @@ static void _dpu_crtc_setup_blend_cfg(struct dpu_crtc_mixer *mixer, lm->ops.setup_blend_config (lm, pstate->stage,0xFF ,0 , blend_op); -DPU_DEBUG ("format:%s, alpha_en:%u blend_op:0x%x\n" , -drm_get_format_name (format->base.pixel_format, &format_name), - format->alpha_enable, blend_op); +DPU_DEBUG ("format:%p4cc, alpha_en:%u blend_op:0x%x\n" , + &format->base.pixel_format, format->alpha_enable, blend_op); }static void _dpu_crtc_program_lm_output_roi (struct drm_crtc *crtc)drivers/gpu/drm/nouveau/nouveau_display.c +3
-6@@ -322,12 +322,9 @@ nouveau_framebuffer_new(struct drm_device *dev, mode_cmd->pitches[0] >= 0x10000 || /* at most 64k pitch */ (mode_cmd->pitches[1] && /* pitches for planes must match */ mode_cmd->pitches[0] != mode_cmd->pitches[1]))) { -struct drm_format_name_buf format_name; -DRM_DEBUG_KMS ("Unsuitable framebuffer: format: %s; pitches: 0x%x\n 0x%x\n" , -drm_get_format_name (mode_cmd->pixel_format, - &format_name), - mode_cmd->pitches[0 ], - mode_cmd->pitches[1 ]); +DRM_DEBUG_KMS ("Unsuitable framebuffer: format: %p4cc; pitches: 0x%x\n 0x%x\n" , + &mode_cmd->pixel_format, + mode_cmd->pitches[0 ], mode_cmd->pitches[1 ]);return -EINVAL ; }drivers/gpu/drm/radeon/atombios_crtc.c +4
-6@@ -1157,7 +1157,6 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1267,8 +1266,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }@@ -1478,7 +1477,6 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1579,8 +1577,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,#endif break ;default : -DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->format->format, &format_name)); +DRM_ERROR ("Unsupported screen format %p4cc\n" , + &target_fb->format->format);return -EINVAL ; }drivers/gpu/drm/sun4i/sun4i_backend.c +2
-4@@ -510,7 +510,6 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine,struct sun4i_layer_state *layer_state =state_to_sun4i_layer_state (plane_state);struct drm_framebuffer *fb = plane_state->fb; -struct drm_format_name_buf format_name;if (!sun4i_backend_plane_is_supported (plane_state, &layer_state->uses_frontend))@@ -527,9 +526,8 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine, } } -DRM_DEBUG_DRIVER ("Plane FB format is %s\n" , -drm_get_format_name (fb->format->format, - &format_name)); +DRM_DEBUG_DRIVER ("Plane FB format is %p4cc\n" , + &fb->format->format);if (fb->format->has_alpha || (plane_state->alpha !=DRM_BLEND_ALPHA_OPAQUE )) num_alpha_planes++;drivers/gpu/drm/vkms/vkms_writeback.c +2
-5@@ -42,11 +42,8 @@ static int vkms_wb_encoder_atomic_check(struct drm_encoder *encoder, }if (fb->format->format != vkms_wb_formats[0 ]) { -struct drm_format_name_buf format_name; - -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , -drm_get_format_name (fb->format->format, - &format_name)); +DRM_DEBUG_KMS ("Invalid pixel format %p4cc\n" , + &fb->format->format);return -EINVAL ; }drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +6
-9@@ -895,7 +895,6 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,struct vmw_framebuffer_surface *vfbs;enum SVGA3dSurfaceFormat format;int ret; -struct drm_format_name_buf format_name;/* 3D is only supported on HWv8 and newer hosts */ if (dev_priv->active_display_unit == vmw_du_legacy)@@ -933,8 +932,8 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv, format =SVGA3D_A1R5G5B5 ;break ;default : -DRM_ERROR ("Invalid pixel format: %s\n" , -drm_get_format_name (mode_cmd->pixel_format, &format_name)); +DRM_ERROR ("Invalid pixel format: %p4cc\n" , + &mode_cmd->pixel_format);return -EINVAL ; }@@ -1149,7 +1148,6 @@ static int vmw_create_bo_proxy(struct drm_device *dev,uint32_t format;struct vmw_resource *res;unsigned int bytes_pp; -struct drm_format_name_buf format_name;int ret;switch (mode_cmd->pixel_format) {@@ -1171,8 +1169,8 @@ static int vmw_create_bo_proxy(struct drm_device *dev,break ;default : -DRM_ERROR ("Invalid framebuffer format %s\n" , -drm_get_format_name (mode_cmd->pixel_format, &format_name)); +DRM_ERROR ("Invalid framebuffer format %p4cc\n" , + &mode_cmd->pixel_format);return -EINVAL ; }@@ -1216,7 +1214,6 @@ static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv,struct drm_device *dev = dev_priv->dev;struct vmw_framebuffer_bo *vfbd;unsigned int requested_size; -struct drm_format_name_buf format_name;int ret; requested_size = mode_cmd->height * mode_cmd->pitches[0 ];@@ -1236,8 +1233,8 @@ static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv,case DRM_FORMAT_RGB565 :break ;default : -DRM_ERROR ("Invalid pixel format: %s\n" , -drm_get_format_name (mode_cmd->pixel_format, &format_name)); +DRM_ERROR ("Invalid pixel format: %p4cc\n" , + &mode_cmd->pixel_format);return -EINVAL ; } }include/drm/drm_fourcc.h +0
-1@@ -318,6 +318,5 @@ unsigned int drm_format_info_block_height(const struct drm_format_info *info, int plane);uint64_t drm_format_info_min_pitch (const struct drm_format_info *info,int plane,unsigned int buffer_width); -const char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);#endif /* __DRM_FOURCC_H__ */
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v7 3/3] drm: Switch to %p4cc format modifier
Hi Thomas,
Thanks for the review.
Quoted 46 lines · Thomas Zimmermann
Hi
Am 15.02.21 um 12:40 schrieb Sakari Ailus:
Quoted 25 lines
Switch DRM drivers from
drm_get_format_name()to %p4cc. This gets rid of a large number of temporary variables at the same time.Signed-off-by Sakari Ailus <[email protected]>--- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 5 ++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 ++-- .../arm/display/komeda/komeda_format_caps.h | 11 -------- .../arm/display/komeda/komeda_framebuffer.c | 4 +-- .../gpu/drm/arm/display/komeda/komeda_plane.c | 6 ++--- drivers/gpu/drm/arm/malidp_mw.c | 7 ++---- drivers/gpu/drm/drm_atomic.c | 8 ++---- drivers/gpu/drm/drm_crtc.c | 7 ++---- drivers/gpu/drm/drm_fourcc.c | 25 ------------------- drivers/gpu/drm/drm_framebuffer.c | 11 +++----- drivers/gpu/drm/drm_mipi_dbi.c | 5 ++-- drivers/gpu/drm/drm_plane.c | 8 ++---- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 5 ++-- drivers/gpu/drm/i915/display/intel_display.c | 14 +++-------- .../drm/i915/display/intel_display_debugfs.c | 19 ++++++-------- drivers/gpu/drm/i915/display/intel_sprite.c | 6 ++--- drivers/gpu/drm/mcde/mcde_display.c | 6 ++---Quoted 8 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 6 ++--- drivers/gpu/drm/nouveau/nouveau_display.c | 9 +++---- drivers/gpu/drm/radeon/atombios_crtc.c | 10 +++----- drivers/gpu/drm/sun4i/sun4i_backend.c | 6 ++--- drivers/gpu/drm/vkms/vkms_writeback.c | 7 ++---- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 15 +++++------ include/drm/drm_fourcc.h | 1 - 27 files changed, 64 insertions(+), 157 deletions(-)This is a nice patchset. For the driver-related changes:
But landing this patch will certainly give us build errors. There are at least 3 git trees involved: drm-misc-next, amd and i915. I'd expect at least one of them to have additional changes that still require
drm_get_format_name().
Quoted 6 lines
IMHO we should remove
drm_get_format_name()in a later patch. Please remove the changes in drm_fourcc.{c,h} from this patch and maybe add a TODO comment to the declaration that the function is supposed to be removed.I would merge the patchset through drm-misc-next. And the final removal patch during the next cycle. Ok?
Sounds good. I'll split the third patch into two then.
Signature · 7 lines
Kind regards, Sakari Ailus _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Petr Mladek
maintainerRe: [PATCH v7 3/3] drm: Switch to %p4cc format modifier
In reply to Thomas ZimmermannQuoted 46 lines · Thomas Zimmermann
Hi
Am 15.02.21 um 12:40 schrieb Sakari Ailus:
Quoted 25 lines
Switch DRM drivers from
drm_get_format_name()to %p4cc. This gets rid of a large number of temporary variables at the same time.Signed-off-by Sakari Ailus <[email protected]>--- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 5 ++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 ++-- .../arm/display/komeda/komeda_format_caps.h | 11 -------- .../arm/display/komeda/komeda_framebuffer.c | 4 +-- .../gpu/drm/arm/display/komeda/komeda_plane.c | 6 ++--- drivers/gpu/drm/arm/malidp_mw.c | 7 ++---- drivers/gpu/drm/drm_atomic.c | 8 ++---- drivers/gpu/drm/drm_crtc.c | 7 ++---- drivers/gpu/drm/drm_fourcc.c | 25 ------------------- drivers/gpu/drm/drm_framebuffer.c | 11 +++----- drivers/gpu/drm/drm_mipi_dbi.c | 5 ++-- drivers/gpu/drm/drm_plane.c | 8 ++---- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 5 ++-- drivers/gpu/drm/i915/display/intel_display.c | 14 +++-------- .../drm/i915/display/intel_display_debugfs.c | 19 ++++++-------- drivers/gpu/drm/i915/display/intel_sprite.c | 6 ++--- drivers/gpu/drm/mcde/mcde_display.c | 6 ++---Quoted 8 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 6 ++--- drivers/gpu/drm/nouveau/nouveau_display.c | 9 +++---- drivers/gpu/drm/radeon/atombios_crtc.c | 10 +++----- drivers/gpu/drm/sun4i/sun4i_backend.c | 6 ++--- drivers/gpu/drm/vkms/vkms_writeback.c | 7 ++---- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 15 +++++------ include/drm/drm_fourcc.h | 1 - 27 files changed, 64 insertions(+), 157 deletions(-)This is a nice patchset. For the driver-related changes:
But landing this patch will certainly give us build errors. There are at least 3 git trees involved: drm-misc-next, amd and i915. I'd expect at least one of them to have additional changes that still require
drm_get_format_name().
Quoted 6 lines
IMHO we should remove
drm_get_format_name()in a later patch. Please remove the changes in drm_fourcc.{c,h} from this patch and maybe add a TODO comment to the declaration that the function is supposed to be removed.I would merge the patchset through drm-misc-next. And the final removal patch during the next cycle. Ok?
Sounds like a plan. I am fine with it from the vsprintf side.
Best Regards,
Petr
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel