lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 27 Jun 2022 18:11:31 +0200
From:   José Expósito <jose.exposito89@...il.com>
To:     javierm@...hat.com
Cc:     davidgow@...gle.com, dlatypov@...gle.com, tzimmermann@...e.de,
        mripard@...nel.org, daniel@...ll.ch, airlied@...ux.ie,
        maarten.lankhorst@...ux.intel.com, jani.nikula@...ux.intel.com,
        maira.canal@....br, isabbasso@...eup.net, magalilemes00@...il.com,
        tales.aparecida@...il.com, dri-devel@...ts.freedesktop.org,
        kunit-dev@...glegroups.com, linux-kernel@...r.kernel.org,
        José Expósito <jose.exposito89@...il.com>
Subject: [PATCH 3/4] drm/format-helper: Add support for conversion functions with swab

The RGB565 conversion functions take an extra parameter ("swab")
indicating whether the bytes should be swapped into the clip buffer or
not.

Create a union in the "convert_xrgb8888_result" structure holding the
value of the "swab" parameter as well as the conversion function
pointer.

Signed-off-by: José Expósito <jose.exposito89@...il.com>
---
 .../gpu/drm/tests/drm_format_helper_test.c    | 44 ++++++++++++++-----
 1 file changed, 34 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index 732d945e7f4e..52dc41cc7c60 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -16,12 +16,29 @@
 
 #define TEST_BUF_SIZE 50
 
+struct convert_xrgb8888_func {
+	void (*func)(void *dst, unsigned int dst_pitch,
+		     const void *src,
+		     const struct drm_framebuffer *fb,
+		     const struct drm_rect *clip);
+};
+
+struct convert_xrgb8888_func_swab {
+	void (*func)(void *dst, unsigned int dst_pitch,
+		     const void *src,
+		     const struct drm_framebuffer *fb,
+		     const struct drm_rect *clip,
+		     bool swab);
+	bool swab;
+};
+
 struct convert_xrgb8888_result {
 	u32 dst_format;
-	void (*conv_func)(void *dst, unsigned int dst_pitch,
-			  const void *src,
-			  const struct drm_framebuffer *fb,
-			  const struct drm_rect *clip);
+	bool has_swab;
+	union {
+		struct convert_xrgb8888_func conv;
+		struct convert_xrgb8888_func_swab conv_swab;
+	};
 	unsigned int dst_pitch;
 	const u8 expected[4 * TEST_BUF_SIZE];
 };
@@ -43,7 +60,7 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
 		.results = {
 			{
 				.dst_format = DRM_FORMAT_RGB332,
-				.conv_func = drm_fb_xrgb8888_to_rgb332,
+				.conv = { .func = drm_fb_xrgb8888_to_rgb332 },
 				.dst_pitch = 0,
 				.expected = { 0xE0 },
 			},
@@ -60,7 +77,7 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
 		.results = {
 			{
 				.dst_format = DRM_FORMAT_RGB332,
-				.conv_func = drm_fb_xrgb8888_to_rgb332,
+				.conv = { .func = drm_fb_xrgb8888_to_rgb332 },
 				.dst_pitch = 0,
 				.expected = { 0xE0 },
 			},
@@ -84,7 +101,7 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
 		.results = {
 			{
 				.dst_format = DRM_FORMAT_RGB332,
-				.conv_func = drm_fb_xrgb8888_to_rgb332,
+				.conv = { .func = drm_fb_xrgb8888_to_rgb332 },
 				.dst_pitch = 0,
 				.expected = {
 					0xFF, 0x00,
@@ -108,7 +125,7 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
 		.results = {
 			{
 				.dst_format = DRM_FORMAT_RGB332,
-				.conv_func = drm_fb_xrgb8888_to_rgb332,
+				.conv = { .func = drm_fb_xrgb8888_to_rgb332 },
 				.dst_pitch = 5,
 				.expected = {
 					0x0A, 0x08, 0xA0, 0x00, 0x00,
@@ -177,8 +194,15 @@ static void convert_xrgb8888_test(struct kunit *test)
 		dst = kunit_kzalloc(test, dst_size, GFP_KERNEL);
 		KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dst);
 
-		result->conv_func(dst, result->dst_pitch, params->xrgb8888,
-				  &fb, &params->clip);
+		if (result->has_swab) {
+			result->conv_swab.func(dst, result->dst_pitch,
+					       params->xrgb8888, &fb,
+					       &params->clip,
+					       result->conv_swab.swab);
+		} else {
+			result->conv.func(dst, result->dst_pitch,
+					  params->xrgb8888, &fb, &params->clip);
+		}
 		KUNIT_EXPECT_EQ(test, memcmp(dst, result->expected, dst_size), 0);
 	}
 }
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ