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

Alex Hung alex.hung at amd.com
Fri Sep 15 22:52:35 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 4b592825d..f60150017 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -4779,16 +4779,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.42.0



More information about the igt-dev mailing list