Hi Igor,
Yes, I pass the parameter(if = RGB) in uboot. But, I write a test program to display blue, actually it display red. I am doubt whether I wrote the test program wrongly. As I mark below in red color, I use rgb data( b = 0x11111111; g = 0; r = 0; ) to fill mapped memory (*(fbp + location) = b; *(fbp + location + 1) = g; *(fbp + location + 2) = r;).
The test program is as follow:
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <linux/fb.h>
int main(void)
{
int fbfd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
struct fb_cmap cmapinfo;
long int screensize = 0;
char *fbp = 0;
int x = 0, y = 0;
long int location = 0;
int b, g, r;
/* open /dev/fb0 */
fbfd = open("/dev/fb0", O_RDWR);
if (fbfd < 0) {
printf("ERR: open framebuffer device failed\n");
return -1;
}
printf("open framebuffer device successfully\n");
/* map the device to memory */
fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
if ((-1 == (int)fbp)) {
printf("ERR: failed to map framebuffer device to memory\n");
return -1;
}
printf("success to map framebuffer device to memory\n");
b = 0x11111111; // blue
g = 0; // green
r = 0; // red
/* display the whole screen, and the pix is 480x240 */
vinfo.xoffset = 0; // Where we are going to put the pixel
vinfo.yoffset = 0;
// Figure out where in memory to put the pixel
for ( y = 0; y < 240; y++ )
for ( x = 0; x < 480; x++ ) {
location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
(y+vinfo.yoffset) * finfo.line_length;
if ( vinfo.bits_per_pixel == 32 ) { // 32bpp
*(fbp + location) = b; //blue
*(fbp + location + 1) = g; // green
*(fbp + location + 2) = r; // red
*(fbp + location + 3) = 0; // No transparency
} else if (vinfo.bits_per_pixel == 24) { //24bpp: r:g:b=8:8:8
*(fbp + location) = b;
*(fbp + location + 1) = g;
*(fbp + location + 2) = r;
}
}
munmap(fbp, screensize);
close(fbfd);
return 0;
}
Best regards
Edward