On 11/12/2024 22:34, Kees Bakker wrote:
Op 04-12-2024 om 16:45 schreef Jocelyn Falempe:
Move the color conversions, blit and fill functions to drm_draw.c,
so that they can be re-used by drm_log.
drm_draw is internal to the drm subsystem, and shouldn't be used by
gpu drivers.
Signed-off-by: Jocelyn Falempe <jfalempe@xxxxxxxxxx>
Reviewed-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
---
v5:
* Export drm_draw symbols, so they can be used if drm_client_lib is
built as module.
v6:
* rebase and solve conflict with "drm/panic: Add ABGR2101010 support"
v9:
* Rename drm_draw.h to drm_draw_internal.h (Jani Nikula)
drivers/gpu/drm/Kconfig | 5 +
drivers/gpu/drm/Makefile | 1 +
drivers/gpu/drm/drm_draw.c | 233 +++++++++++++++++++++++++
drivers/gpu/drm/drm_draw_internal.h | 56 ++++++
drivers/gpu/drm/drm_panic.c | 257 +++-------------------------
5 files changed, 318 insertions(+), 234 deletions(-)
create mode 100644 drivers/gpu/drm/drm_draw.c
create mode 100644 drivers/gpu/drm/drm_draw_internal.h
[...]
diff --git a/drivers/gpu/drm/drm_draw.c b/drivers/gpu/drm/drm_draw.c
new file mode 100644
index 000000000000..cb2ad12bce57
--- /dev/null
+++ b/drivers/gpu/drm/drm_draw.c
@@ -0,0 +1,233 @@
+[...]
+void drm_draw_fill24(struct iosys_map *dmap, unsigned int dpitch,
+ unsigned int height, unsigned int width,
+ u16 color)
+{
+ unsigned int y, x;
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ unsigned int off = y * dpitch + x * 3;
+
+ /* write blue-green-red to output in little endianness */
+ iosys_map_wr(dmap, off, u8, (color & 0x000000FF) >> 0);
+ iosys_map_wr(dmap, off + 1, u8, (color & 0x0000FF00) >> 8);
+ iosys_map_wr(dmap, off + 2, u8, (color & 0x00FF0000) >> 16);
+ }
+ }
+}
u16 is not wide enough for a 24bit color
Good catch, I will send a fix when I get some time.
Best regards,
--
Jocelyn