From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, airlied@gmail.com, javierm@redhat.com,
jose.exposito89@gmail.com, mairacanal@riseup.net,
mripard@kernel.org, maarten.lankhorst@linux.intel.com
Cc: "Maíra Canal" <mcanal@igalia.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
dri-devel@lists.freedesktop.org
Subject: [PATCH v3 04/13] drm/format-helper: Store RGB565 in little-endian order
Date: Mon, 2 Jan 2023 12:29:18 +0100 [thread overview]
Message-ID: <20230102112927.26565-5-tzimmermann@suse.de> (raw)
In-Reply-To: <20230102112927.26565-1-tzimmermann@suse.de>
Fix to-RGB565 conversion helpers to store the result in little-
endian byte order. Update test cases as well.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/gpu/drm/drm_format_helper.c | 9 +++++----
.../gpu/drm/tests/drm_format_helper_test.c | 20 ++++++++++++++++++-
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
index b98bd7c5caee..f3f3b3809a3e 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -322,7 +322,7 @@ EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb332);
static void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigned int pixels)
{
- u16 *dbuf16 = dbuf;
+ __le16 *dbuf16 = dbuf;
const __le32 *sbuf32 = sbuf;
unsigned int x;
u16 val16;
@@ -333,14 +333,15 @@ static void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigne
val16 = ((pix & 0x00F80000) >> 8) |
((pix & 0x0000FC00) >> 5) |
((pix & 0x000000F8) >> 3);
- dbuf16[x] = val16;
+ dbuf16[x] = cpu_to_le16(val16);
}
}
+/* TODO: implement this helper as conversion to RGB565|BIG_ENDIAN */
static void drm_fb_xrgb8888_to_rgb565_swab_line(void *dbuf, const void *sbuf,
unsigned int pixels)
{
- u16 *dbuf16 = dbuf;
+ __le16 *dbuf16 = dbuf;
const __le32 *sbuf32 = sbuf;
unsigned int x;
u16 val16;
@@ -351,7 +352,7 @@ static void drm_fb_xrgb8888_to_rgb565_swab_line(void *dbuf, const void *sbuf,
val16 = ((pix & 0x00F80000) >> 8) |
((pix & 0x0000FC00) >> 5) |
((pix & 0x000000F8) >> 3);
- dbuf16[x] = swab16(val16);
+ dbuf16[x] = cpu_to_le16(swab16(val16));
}
}
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index e7c49e6d3f6d..04fe373c9d97 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -264,6 +264,21 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch,
return dst_pitch * drm_rect_height(clip);
}
+static u16 *le16buf_to_cpu(struct kunit *test, const __le16 *buf, size_t buf_size)
+{
+ u16 *dst = NULL;
+ int n;
+
+ dst = kunit_kzalloc(test, sizeof(*dst) * buf_size, GFP_KERNEL);
+ if (!dst)
+ return NULL;
+
+ for (n = 0; n < buf_size; n++)
+ dst[n] = le16_to_cpu(buf[n]);
+
+ return dst;
+}
+
static u32 *le32buf_to_cpu(struct kunit *test, const u32 *buf, size_t buf_size)
{
u32 *dst = NULL;
@@ -368,7 +383,7 @@ static void drm_test_fb_xrgb8888_to_rgb565(struct kunit *test)
const struct convert_xrgb8888_case *params = test->param_value;
const struct convert_to_rgb565_result *result = ¶ms->rgb565_result;
size_t dst_size;
- __u16 *buf = NULL;
+ u16 *buf = NULL;
__le32 *xrgb8888 = NULL;
struct iosys_map dst, src;
@@ -390,9 +405,12 @@ static void drm_test_fb_xrgb8888_to_rgb565(struct kunit *test)
iosys_map_set_vaddr(&src, xrgb8888);
drm_fb_xrgb8888_to_rgb565(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip, false);
+ buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16));
KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0);
+ buf = dst.vaddr; /* restore original value of buf */
drm_fb_xrgb8888_to_rgb565(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip, true);
+ buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16));
KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected_swab, dst_size), 0);
}
--
2.39.0
next prev parent reply other threads:[~2023-01-02 11:29 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-02 11:29 [PATCH v3 00/13] drm: Fix color-format selection in fbdev emulation Thomas Zimmermann
2023-01-02 11:29 ` [PATCH v3 01/13] firmware/sysfb: Fix EFI/VESA format selection Thomas Zimmermann
2023-04-06 15:45 ` Pierre Asselin
2023-04-08 11:26 ` Linux regression tracking #adding (Thorsten Leemhuis)
2023-04-16 12:06 ` Linux regression tracking #update (Thorsten Leemhuis)
2023-04-08 16:10 ` Pierre Asselin
2023-04-11 15:56 ` Javier Martinez Canillas
2023-04-11 19:39 ` Pierre Asselin
2023-04-12 11:22 ` Javier Martinez Canillas
2023-04-17 7:34 ` Thomas Zimmermann
2023-01-02 11:29 ` [PATCH v3 02/13] drm/format-helper: Comment on RGB888 byte order Thomas Zimmermann
2023-01-02 11:29 ` [PATCH v3 03/13] drm/format-helper: Fix test-input format conversion Thomas Zimmermann
2023-01-02 11:29 ` Thomas Zimmermann [this message]
2023-01-02 11:29 ` [PATCH v3 05/13] drm/format-helper: Type fixes in format-helper tests Thomas Zimmermann
2023-01-02 11:29 ` [PATCH v3 06/13] drm/format-helper: Flip src/dst-format branches in blit helper Thomas Zimmermann
2023-01-02 11:29 ` [PATCH v3 07/13] drm/format-helper: Add conversion from XRGB8888 to ARGB8888 Thomas Zimmermann
2023-01-02 11:29 ` [PATCH v3 08/13] drm/format-helper: Add conversion from XRGB8888 to ARGB2101010 Thomas Zimmermann
2023-01-02 11:29 ` [PATCH v3 09/13] drm/format-helper: Add conversion from XRGB8888 to 15-bit RGB555 formats Thomas Zimmermann
2023-01-02 11:29 ` [PATCH v3 10/13] drm/fh-helper: Split fbdev single-probe helper Thomas Zimmermann
2023-01-02 11:29 ` [PATCH v3 11/13] drm/fb-helper: Fix single-probe color-format selection Thomas Zimmermann
2023-01-03 21:18 ` Maíra Canal
2023-01-04 8:14 ` Thomas Zimmermann
2023-01-04 10:34 ` Maíra Canal
2023-05-12 13:20 ` Linus Walleij
2023-05-12 14:11 ` Thomas Zimmermann
2023-05-15 8:01 ` Linus Walleij
2023-05-15 8:17 ` Thomas Zimmermann
2023-05-15 8:59 ` Linus Walleij
2023-05-15 9:26 ` Thomas Zimmermann
2023-05-15 9:30 ` Linus Walleij
2023-05-15 8:16 ` Daniel Vetter
2023-05-15 8:42 ` Thomas Zimmermann
2023-05-14 12:10 ` Linux regression tracking #adding (Thorsten Leemhuis)
2023-05-26 12:22 ` Linux regression tracking #update (Thorsten Leemhuis)
2023-01-02 11:29 ` [PATCH v3 12/13] drm/format-helper: Simplify drm_fb_build_fourcc_list() Thomas Zimmermann
2023-01-02 11:29 ` [PATCH v3 13/13] drm/format-helper: Remove unnecessary conversion helpers Thomas Zimmermann
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=20230102112927.26565-5-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=jose.exposito89@gmail.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mairacanal@riseup.net \
--cc=mcanal@igalia.com \
--cc=mripard@kernel.org \
/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