I am developing an image processor using a Verdin iMX8M Plus SoM.
When I switch the output-image from white to black, as shown in the attached image, the output is a mixture of white and black images in the process of switching.
The output image is a 1280x720 RGBA image.
The code for the output part was implemented as follows.
void show_image(int width, int height, uint32_t color)
{
int fd;
fd = open("/dev/fb0", O_RDWR);
uint32_t *frameBuffer = (uint32_t *)mmap(NULL, width * height * 4, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
memset(frameBuffer, color, width * height * 4);
msync(frameBuffer, width * height * 4, 0);
munmap(frameBuffer, width * height * 4);
close(fd);
}
How do I synchronize /dev/fb0 and frameBuffer?