From: Francesco Valla <francesco@valla.it>
To: Jocelyn Falempe <jfalempe@redhat.com>,
Javier Martinez Canillas <javierm@redhat.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Francesco Valla <francesco@valla.it>
Subject: [PATCH v2 1/3] drm/draw: add drm_draw_can_convert_from_xrgb8888
Date: Tue, 14 Oct 2025 22:08:12 +0200 [thread overview]
Message-ID: <20251014-drm_draw_conv_check-v2-1-05bef3eb06fb@valla.it> (raw)
In-Reply-To: <20251014-drm_draw_conv_check-v2-0-05bef3eb06fb@valla.it>
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.
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 9dc0408fbbeadbe8282a2d6b210e0bfb0672967f..ccdd6b16e73fc01d58f45759cf3824be7aac155b 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 f121ee7339dc11537f677c833f0ee94fe0e799cd..2ab4cb341df94fc4173dd6f5e7a512bdcfa5e55c 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.51.0
next prev parent reply other threads:[~2025-10-14 20:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 20:08 [PATCH v2 0/3] drm/draw: add check API to avoid spurious WARN Francesco Valla
2025-10-14 20:08 ` Francesco Valla [this message]
2025-10-15 7:39 ` [PATCH v2 1/3] drm/draw: add drm_draw_can_convert_from_xrgb8888 Jocelyn Falempe
2025-10-14 20:08 ` [PATCH v2 2/3] drm/log: avoid WARN when searching for usable format Francesco Valla
2025-10-15 7:40 ` Jocelyn Falempe
2025-10-14 20:08 ` [PATCH v2 3/3] drm/panic: avoid WARN when checking format support Francesco Valla
2025-10-15 7:40 ` Jocelyn Falempe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251014-drm_draw_conv_check-v2-1-05bef3eb06fb@valla.it \
--to=francesco@valla.it \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=jfalempe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®