* [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN
@ 2025-12-17 8:06 Francesco Valla
2025-12-17 8:06 ` [PATCH v3 1/3] drm/draw: add drm_draw_can_convert_from_xrgb8888 Francesco Valla
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Francesco Valla @ 2025-12-17 8:06 UTC (permalink / raw)
To: Jocelyn Falempe, Javier Martinez Canillas, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel, Francesco Valla
When using the DRM draw support, the only way to check if a color can be
converted from XRGB8888 to a target format is currently to attempt an
actual conversion using drm_draw_color_from_xrgb8888(). This function
however will print a WARN the first time a conversion cannot be
performed, leading to two potential issues:
- a WARN is emitted without a real reason if the caller is only
attempting a conversion to check if a format can be supported (which
is the case for two of the current user of this API);
- a failing call following the first one is not emitting a WARN, but a
"valid" color value (0x00000000) is returned nevertheless.
The first issue was observed while using drm_log on a Beagleplay, which
lists AR12 as the first format for its HDMI modesets.
The target of this patch set is to improve this situation; the first
patch introduces a new API devoted only to check if a conversion from
XRGB8888 to the specified format can be performed, while the other two
substitute drm_draw_color_from_xrgb8888() with this new API in the
current users (drm_panic and drm_log) where relevant.
Signed-off-by: Francesco Valla <francesco@valla.it>
---
Changes in v3:
- Collected R-b tags from Jocelyn (thank you!)
- Link to v2: https://lore.kernel.org/r/20251014-drm_draw_conv_check-v2-0-05bef3eb06fb@valla.it
Changes in v2:
- Moved to dedicated switch cases in separate functions instead of
single one inside common function.
- Fix copy-paste error in commit message.
Link to v1: https://lore.kernel.org/r/20251005-drm_draw_conv_check-v1-0-9c814d9362f6@valla.it
---
Francesco Valla (3):
drm/draw: add drm_draw_can_convert_from_xrgb8888
drm/log: avoid WARN when searching for usable format
drm/panic: avoid WARN when checking format support
drivers/gpu/drm/clients/drm_log.c | 2 +-
drivers/gpu/drm/drm_draw.c | 29 +++++++++++++++++++++++++++++
drivers/gpu/drm/drm_draw_internal.h | 2 ++
drivers/gpu/drm/drm_panic.c | 2 +-
4 files changed, 33 insertions(+), 2 deletions(-)
---
base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
change-id: 20251003-drm_draw_conv_check-9cc3050ebd57
Best regards,
--
Francesco Valla <francesco@valla.it>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/3] drm/draw: add drm_draw_can_convert_from_xrgb8888
2025-12-17 8:06 [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN Francesco Valla
@ 2025-12-17 8:06 ` Francesco Valla
2025-12-17 8:06 ` [PATCH v3 2/3] drm/log: avoid WARN when searching for usable format Francesco Valla
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Francesco Valla @ 2025-12-17 8:06 UTC (permalink / raw)
To: Jocelyn Falempe, Javier Martinez Canillas, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel, Francesco Valla
Add drm_draw_can_convert_from_xrgb8888() function that can be used to
determine if a XRGB8888 color can be converted to the specified format.
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Signed-off-by: Francesco Valla <francesco@valla.it>
---
drivers/gpu/drm/drm_draw.c | 29 +++++++++++++++++++++++++++++
drivers/gpu/drm/drm_draw_internal.h | 2 ++
2 files changed, 31 insertions(+)
diff --git a/drivers/gpu/drm/drm_draw.c b/drivers/gpu/drm/drm_draw.c
index 5b956229c82fb6e232e3342705a226c8e14c8568..5043baf901b82e730cb7c3fe55aab99c91cd9fdf 100644
--- a/drivers/gpu/drm/drm_draw.c
+++ b/drivers/gpu/drm/drm_draw.c
@@ -15,6 +15,35 @@
#include "drm_draw_internal.h"
#include "drm_format_internal.h"
+/**
+ * drm_draw_can_convert_from_xrgb8888 - check if xrgb8888 can be converted to the desired format
+ * @format: format
+ *
+ * Returns:
+ * True if XRGB8888 can be converted to the specified format, false otherwise.
+ */
+bool drm_draw_can_convert_from_xrgb8888(u32 format)
+{
+ switch (format) {
+ case DRM_FORMAT_RGB565:
+ case DRM_FORMAT_RGBA5551:
+ case DRM_FORMAT_XRGB1555:
+ case DRM_FORMAT_ARGB1555:
+ case DRM_FORMAT_RGB888:
+ case DRM_FORMAT_XRGB8888:
+ case DRM_FORMAT_ARGB8888:
+ case DRM_FORMAT_XBGR8888:
+ case DRM_FORMAT_ABGR8888:
+ case DRM_FORMAT_XRGB2101010:
+ case DRM_FORMAT_ARGB2101010:
+ case DRM_FORMAT_ABGR2101010:
+ return true;
+ default:
+ return false;
+ }
+}
+EXPORT_SYMBOL(drm_draw_can_convert_from_xrgb8888);
+
/**
* drm_draw_color_from_xrgb8888 - convert one pixel from xrgb8888 to the desired format
* @color: input color, in xrgb8888 format
diff --git a/drivers/gpu/drm/drm_draw_internal.h b/drivers/gpu/drm/drm_draw_internal.h
index 20cb404e23ea6263b535ea2b81b25f84c37be8a2..2619671456359efa3406a480890a0b5ac63dd9ea 100644
--- a/drivers/gpu/drm/drm_draw_internal.h
+++ b/drivers/gpu/drm/drm_draw_internal.h
@@ -24,6 +24,8 @@ static inline const u8 *drm_draw_get_char_bitmap(const struct font_desc *font,
return font->data + (c * font->height) * font_pitch;
}
+bool drm_draw_can_convert_from_xrgb8888(u32 format);
+
u32 drm_draw_color_from_xrgb8888(u32 color, u32 format);
void drm_draw_blit16(struct iosys_map *dmap, unsigned int dpitch,
--
2.52.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 2/3] drm/log: avoid WARN when searching for usable format
2025-12-17 8:06 [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN Francesco Valla
2025-12-17 8:06 ` [PATCH v3 1/3] drm/draw: add drm_draw_can_convert_from_xrgb8888 Francesco Valla
@ 2025-12-17 8:06 ` Francesco Valla
2025-12-17 8:06 ` [PATCH v3 3/3] drm/panic: avoid WARN when checking format support Francesco Valla
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Francesco Valla @ 2025-12-17 8:06 UTC (permalink / raw)
To: Jocelyn Falempe, Javier Martinez Canillas, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel, Francesco Valla
Use drm_draw_can_convert_from_xrgb8888() instead of
drm_draw_color_from_xrgb8888() while searching for a usable color
format. This avoids a WARN in case the first format is not usable.
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Signed-off-by: Francesco Valla <francesco@valla.it>
---
drivers/gpu/drm/clients/drm_log.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/clients/drm_log.c b/drivers/gpu/drm/clients/drm_log.c
index 4d3005273b278e8c4c0ff7a411165efb7684316e..2bd5189c967e1952f9e6ad17120b2cd920c79a96 100644
--- a/drivers/gpu/drm/clients/drm_log.c
+++ b/drivers/gpu/drm/clients/drm_log.c
@@ -182,7 +182,7 @@ static u32 drm_log_find_usable_format(struct drm_plane *plane)
int i;
for (i = 0; i < plane->format_count; i++)
- if (drm_draw_color_from_xrgb8888(0xffffff, plane->format_types[i]) != 0)
+ if (drm_draw_can_convert_from_xrgb8888(plane->format_types[i]))
return plane->format_types[i];
return DRM_FORMAT_INVALID;
}
--
2.52.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 3/3] drm/panic: avoid WARN when checking format support
2025-12-17 8:06 [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN Francesco Valla
2025-12-17 8:06 ` [PATCH v3 1/3] drm/draw: add drm_draw_can_convert_from_xrgb8888 Francesco Valla
2025-12-17 8:06 ` [PATCH v3 2/3] drm/log: avoid WARN when searching for usable format Francesco Valla
@ 2025-12-17 8:06 ` Francesco Valla
2025-12-19 8:05 ` [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN Jocelyn Falempe
2025-12-19 22:11 ` Jocelyn Falempe
4 siblings, 0 replies; 6+ messages in thread
From: Francesco Valla @ 2025-12-17 8:06 UTC (permalink / raw)
To: Jocelyn Falempe, Javier Martinez Canillas, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel, Francesco Valla
Use drm_draw_can_convert_from_xrgb8888() instead of
drm_draw_color_from_xrgb8888() while checking if a color format is
usable. This avoids a WARN in case the first format is not usable.
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Signed-off-by: Francesco Valla <francesco@valla.it>
---
drivers/gpu/drm/drm_panic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c
index d4b6ea42db0fe65ea010255ff57554baf723e60c..27989a010ace38b18bc047ad87db64128ec25790 100644
--- a/drivers/gpu/drm/drm_panic.c
+++ b/drivers/gpu/drm/drm_panic.c
@@ -833,7 +833,7 @@ static bool drm_panic_is_format_supported(const struct drm_format_info *format)
{
if (format->num_planes != 1)
return false;
- return drm_draw_color_from_xrgb8888(0xffffff, format->format) != 0;
+ return drm_draw_can_convert_from_xrgb8888(format->format);
}
static void draw_panic_dispatch(struct drm_scanout_buffer *sb)
--
2.52.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN
2025-12-17 8:06 [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN Francesco Valla
` (2 preceding siblings ...)
2025-12-17 8:06 ` [PATCH v3 3/3] drm/panic: avoid WARN when checking format support Francesco Valla
@ 2025-12-19 8:05 ` Jocelyn Falempe
2025-12-19 22:11 ` Jocelyn Falempe
4 siblings, 0 replies; 6+ messages in thread
From: Jocelyn Falempe @ 2025-12-19 8:05 UTC (permalink / raw)
To: Francesco Valla, Javier Martinez Canillas, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel
On 17/12/2025 09:06, Francesco Valla wrote:
> When using the DRM draw support, the only way to check if a color can be
> converted from XRGB8888 to a target format is currently to attempt an
> actual conversion using drm_draw_color_from_xrgb8888(). This function
> however will print a WARN the first time a conversion cannot be
> performed, leading to two potential issues:
>
> - a WARN is emitted without a real reason if the caller is only
> attempting a conversion to check if a format can be supported (which
> is the case for two of the current user of this API);
> - a failing call following the first one is not emitting a WARN, but a
> "valid" color value (0x00000000) is returned nevertheless.
>
> The first issue was observed while using drm_log on a Beagleplay, which
> lists AR12 as the first format for its HDMI modesets.
>
> The target of this patch set is to improve this situation; the first
> patch introduces a new API devoted only to check if a conversion from
> XRGB8888 to the specified format can be performed, while the other two
> substitute drm_draw_color_from_xrgb8888() with this new API in the
> current users (drm_panic and drm_log) where relevant.
Hi Francesco,
Thanks for this patch. If you can't push it to drm-misc-next, let me
know, and I will push it for you.
Best regards,
--
Jocelyn
>
> Signed-off-by: Francesco Valla <francesco@valla.it>
> ---
> Changes in v3:
> - Collected R-b tags from Jocelyn (thank you!)
> - Link to v2: https://lore.kernel.org/r/20251014-drm_draw_conv_check-v2-0-05bef3eb06fb@valla.it
>
> Changes in v2:
> - Moved to dedicated switch cases in separate functions instead of
> single one inside common function.
> - Fix copy-paste error in commit message.
>
> Link to v1: https://lore.kernel.org/r/20251005-drm_draw_conv_check-v1-0-9c814d9362f6@valla.it
>
> ---
> Francesco Valla (3):
> drm/draw: add drm_draw_can_convert_from_xrgb8888
> drm/log: avoid WARN when searching for usable format
> drm/panic: avoid WARN when checking format support
>
> drivers/gpu/drm/clients/drm_log.c | 2 +-
> drivers/gpu/drm/drm_draw.c | 29 +++++++++++++++++++++++++++++
> drivers/gpu/drm/drm_draw_internal.h | 2 ++
> drivers/gpu/drm/drm_panic.c | 2 +-
> 4 files changed, 33 insertions(+), 2 deletions(-)
> ---
> base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
> change-id: 20251003-drm_draw_conv_check-9cc3050ebd57
>
> Best regards,
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN
2025-12-17 8:06 [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN Francesco Valla
` (3 preceding siblings ...)
2025-12-19 8:05 ` [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN Jocelyn Falempe
@ 2025-12-19 22:11 ` Jocelyn Falempe
4 siblings, 0 replies; 6+ messages in thread
From: Jocelyn Falempe @ 2025-12-19 22:11 UTC (permalink / raw)
To: Francesco Valla, Javier Martinez Canillas, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel
On 17/12/2025 09:06, Francesco Valla wrote:
> When using the DRM draw support, the only way to check if a color can be
> converted from XRGB8888 to a target format is currently to attempt an
> actual conversion using drm_draw_color_from_xrgb8888(). This function
> however will print a WARN the first time a conversion cannot be
> performed, leading to two potential issues:
>
> - a WARN is emitted without a real reason if the caller is only
> attempting a conversion to check if a format can be supported (which
> is the case for two of the current user of this API);
> - a failing call following the first one is not emitting a WARN, but a
> "valid" color value (0x00000000) is returned nevertheless.
>
> The first issue was observed while using drm_log on a Beagleplay, which
> lists AR12 as the first format for its HDMI modesets.
>
> The target of this patch set is to improve this situation; the first
> patch introduces a new API devoted only to check if a conversion from
> XRGB8888 to the specified format can be performed, while the other two
> substitute drm_draw_color_from_xrgb8888() with this new API in the
> current users (drm_panic and drm_log) where relevant.
I just pushed it to drm-misc/drm-misc-next
Thanks for your contribution.
--
Jocelyn
>
> Signed-off-by: Francesco Valla <francesco@valla.it>
> ---
> Changes in v3:
> - Collected R-b tags from Jocelyn (thank you!)
> - Link to v2: https://lore.kernel.org/r/20251014-drm_draw_conv_check-v2-0-05bef3eb06fb@valla.it
>
> Changes in v2:
> - Moved to dedicated switch cases in separate functions instead of
> single one inside common function.
> - Fix copy-paste error in commit message.
>
> Link to v1: https://lore.kernel.org/r/20251005-drm_draw_conv_check-v1-0-9c814d9362f6@valla.it
>
> ---
> Francesco Valla (3):
> drm/draw: add drm_draw_can_convert_from_xrgb8888
> drm/log: avoid WARN when searching for usable format
> drm/panic: avoid WARN when checking format support
>
> drivers/gpu/drm/clients/drm_log.c | 2 +-
> drivers/gpu/drm/drm_draw.c | 29 +++++++++++++++++++++++++++++
> drivers/gpu/drm/drm_draw_internal.h | 2 ++
> drivers/gpu/drm/drm_panic.c | 2 +-
> 4 files changed, 33 insertions(+), 2 deletions(-)
> ---
> base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
> change-id: 20251003-drm_draw_conv_check-9cc3050ebd57
>
> Best regards,
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-12-19 22:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-17 8:06 [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN Francesco Valla
2025-12-17 8:06 ` [PATCH v3 1/3] drm/draw: add drm_draw_can_convert_from_xrgb8888 Francesco Valla
2025-12-17 8:06 ` [PATCH v3 2/3] drm/log: avoid WARN when searching for usable format Francesco Valla
2025-12-17 8:06 ` [PATCH v3 3/3] drm/panic: avoid WARN when checking format support Francesco Valla
2025-12-19 8:05 ` [PATCH v3 0/3] drm/draw: add check API to avoid spurious WARN Jocelyn Falempe
2025-12-19 22:11 ` Jocelyn Falempe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®