I'm trying to read from /dev/fb0
on a Linux machine.
I just open("/dev/fb0", O_RDWR)
, then mmap
, then memcpy
from the mapped pointer.
Everything seems fine, except the top right corner of the image I get is from the previous frame.
It seems like a cache coherency problem to me. Specifically I'm running it on an ARM chip where GPU and CPU shares memory.
Is it true? Is it common practice to invalidate cache after mmap
ing to frame buffer?
If I need to invalidate memory, which API call shall I use?
I'm trying Memory.h from TI's SDK, but is there a more standard/Linux/Posix alternative?
Make sure GPU finished writing of data into buffer before memcpy(). In this case you need not to invalidate cache as there will be no caching of your newly mmapped buffer. If you suspect there is any cached data you are copying you can use following API to invalidate cache:
See header file arch/arm/include/asm/outercache.h.