[igt-dev] [PATCH 1/3] lib/igt_fb: use the entire 32 bit for fnv1a_crc

Alex Hung alex.hung at amd.com
Wed Aug 16 20:53:14 UTC 2023


The function was implemented as a 32-bit hashing function. Commit
85f4c1005150 ("lib/igt_fb: Ignore the X component when computing CRC")
broke this behavior by hashing 8-bit portions. Restore the 32-bit hasing
behavior while still ignoring the X compoment.

Signed-off-by: Alex Hung <alex.hung at amd.com>
---
 lib/igt_fb.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 60b0e2669..9beb07049 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -4780,16 +4780,11 @@ int igt_fb_get_fnv1a_crc(struct igt_fb *fb, igt_crc_t *crc)
 		igt_memcpy_from_wc(line, ptr, fb->width * cpp);
 
 		for (x = 0; x < fb->width; x++) {
-			unsigned int i;
 			uint32_t pixel = le32_to_cpu(line[x]);
 			pixel &= 0x00ffffff;
 
-			for (i = 0; i < sizeof(pixel); i++) {
-				uint8_t component = (pixel >> (i * 8)) & 0xff;
-
-				hash ^= component;
-				hash *= FNV1a_PRIME;
-			}
+			hash ^= pixel;
+			hash *= FNV1a_PRIME;
 		}
 	}
 
-- 
2.34.1



More information about the igt-dev mailing list