Results 1 to 1 of 1
Hi guys, I'm trying to create a LCD driver to control Samsung LT121S1-153.
Following the guide "Using the color LCD controller (CLCD) in the SPEAr embedded MPU family"( eu.st.com/stonline/products/literature/an/14027.pdf ), ...
- 09-07-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 1
STLinux - using LCD
Hi guys, I'm trying to create a LCD driver to control Samsung LT121S1-153.
Following the guide "Using the color LCD controller (CLCD) in the SPEAr embedded MPU family"( eu.st.com/stonline/products/literature/an/14027.pdf ), I modified the file /arch/arm/mach-spear600/spear600.c adding this code:
Then, I've compiled the kernel, I've loaded it on spear600 and after the boot I've tested the following program described at page 26 in the guide:Code:#ifdef CONFIG_FB_ARMCLCD_SAMSUNG_LT121S1_153 static struct clcd_panel samsung_LT121S1_153 = { .mode = { .name = "Samsung LT121S1_153", .refresh = 0, .xres = 800, .yres = 600, //600 .pixclock = 24038, //number of picosecond pixel clock (40MHz->25000),(41,6MHz->24038) .left_margin = 88, //clock .right_margin = 40, //clock .upper_margin = 23,//lines .lower_margin = 3, //lines .hsync_len = 128,//clock .vsync_len = 5,//lines .sync = 0, /* FB_SYNC_HOR_HIGH_ACT | * FB_SYNC_VERT_HIGH_ACT, */ .vmode = FB_VMODE_NONINTERLACED, }, .width = -1, .height = -1, .tim2 = 2,//41,6MHz .cntl = CNTL_LCDTFT , .bpp = 32, }; #endif #ifdef CONFIG_FB_ARMCLCD_SAMSUNG_LT121S1_153 panel = &samsung_LT121S1_153; #endif //static unsigned long framesize = 0x00180000; //(800*480)pixel*4bytes= 0x00180000 static unsigned long framesize = 0x001D4C00; //(800*600)pixel*4bytes= 0x001D4C00
But the execution of instruction mmap fail and I get this error "Error: failed to map framebuffer device to memory.\n"...Code:#include <unistd.h> #include <stdio.h> #include <fcntl.h> #include <linux/fb.h> #include <sys/mman.h> int main() { int fbfd = 0; struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; long int screensize = 0; char *fbp = 0; int x = 0, y = 0; long int location = 0; // Open the file for reading and writing fbfd = open("/dev/fb0", O_RDWR); if (!fbfd) { printf("Error: cannot open framebuffer device.\n"); exit(1); } // Get fixed screen information if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) { printf("Error reading fixed information.\n"); exit(2); } // Get variable screen information if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { printf("Error reading variable information.\n"); exit(3); } // Put variable screen information to Switch ON CLCD Panel vinfo.activate |= FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW; if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &vinfo)) { printf("Error writing variable information.\n"); exit(3); } // Figure out the size of the screen in bytes screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; // Map the device to memory fbp = (char *)mmap( 0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0 ); if ((int)fbp == -1) { printf("Error: failed to map framebuffer device to memory.\n"); exit(4); } //Loop will draw 3 color bands: blue, green and red for ( location = 0, y = 0; y < vinfo.yres; y++ ) for ( x = 0; x < vinfo.xres; x++ ) { if ( y < (vinfo.yres/3) ) { *(fbp + location) = 0xFF;//show Blue *(fbp + location+1) = 0;//no Green *(fbp + location+2) = 0;//no Red *(fbp + location+3) = 0;//No Transparency } else if ( y < (2*vinfo.yres/3) ) { *(fbp + location) = 0xFF;// no Blue *(fbp + location + 1) = 0;// show Green *(fbp + location + 2) = 0;// no Red *(fbp + location + 3) = 0;// No transparency } else { *(fbp + location) = 0;// no Blue *(fbp + location + 1) = 0; // no Green *(fbp + location + 2) = 0xFF;// show Red *(fbp + location + 3) = 0;// No transparency } location +=4; } munmap(fbp, screensize); close(fbfd); return 0; }
I don't understand why mmap fail since I extended the framebuffer up to 0x001D4C00= 1,9MB
Can anyone help me??
P.S.:If I change .yres member of struct clcd_panel to 598 instead of 600, mmap instruction won't fail!!! If I keep yres =600 and I change static unsigned long framesize=0x00300000, mmap instruction will fail again...


Reply With Quote