I am developing an embedded Linux system with a 24 bit LCD display. I use terasic linux-socfpga to compile the kernel and I want to use the altfb driver to show the desktop in LCD. For that, I copied the Linux driver(https://github.com/coliby/terasic_MTL/blob/master/drivers/video/altfb.c) to my kernel code and then I successfully compiled the code. But the display did not work correctly.
After several days of trial, I succeeded to display the desktop but its pixel values are not shown correctly. Finally, I succeed to display something like in the image as shown below. for that, I changed the code from
writel(fbdev->info->var.xres * fbdev->info->var.yres/(fbdev->mem_word_width/32)
to
writel(fbdev->info->var.xres * fbdev->info->var.yres/(fbdev->mem_word_width/24)
But the display showed like the attached image. Any help to solve the issue is appreciated.

https://rocketboards.org/foswiki/Projects/TouchScreenLCDForAlteraSoC
https://github.com/coliby/terasic_MTL/blob/master/drivers/video/altfb.c