[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Frame buffer on Coldfire (still problems)

Hi all,
I'm using an Epson S1D13a video chip tied to a 320x240 LCD panel on a
system running a Linux 2.6.10 kernel on the MCF5484 Coldfire chip.
This electrical configuration works with the MQX OS, by the way, so I
know that things are fine from that standpoint.

I have a driver for the chip from Epson that I ported from the v2.6.8
kernel it was intended for to the v2.6.10 that my BSP port is running
on. The driver loads without errors and the LCD array lights up. So
far so good. However the simple little application I've put together
to work with the screen fails on a call to mmap() with perror()
reporting an "invalid argument". I've worked at this for days and gone
no where. What the heck could be going wrong? I've checked the memory
mapping in driver, I've tried allocating different amounts of memory
with different offsets in the application. The frame buffer device can
be opened and ioctl() calls retrieve good information but when the
mmap() function is called it always returns "invalid argument". The
only argument I'm even supplying is the screen size and I've tried
variations on that with the same result.

I'm at a total loss. Any help/suggests would be GREATLY apprciated!!

Application code prints out the following when run:

The framebuffer device was opened successfully.
vinfo.xres = 320
vinfo.yres = 240
vinfo.bits_per_pixel = 8
screensize = 0x12c00
PageSize (getpagesize):    0x2000
Call to mmap
mmap: Invalid argument

Error: failed to map framebuffer device to memory.
Illegal instruction

The code:

PHYSICAL_VMEM_ADDR           0x4404 0000
PHYSICAL _REG_SIZE             36864L
PHYSICAL_VMEM_SIZE           163840L

#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>

int main()
    int fbfd, x, y;
    long int location;
    size_t screensize;
    char *fbp;

    struct fb_var_screeninfo vinfo;
    struct fb_fix_screeninfo finfo;

    off_t PageOffset, PageAddress, PhysAddr;

    /* Open the file for reading and writing */
    fbfd = open("/dev/fb0", O_RDWR);

    if (!fbfd)
         printf("Error: cannot open framebuffer device.\n");
    printf("The framebuffer device was opened successfully.\n");

    /* Get fixed screen information */
    if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo))
         perror ("ioctl");
         printf("Error reading fixed information.\n");

    /* Get variable screen information */
    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo))
         printf("Error reading variable information.\n");

    /* Figure out the size of the screen in bytes */
    screensize = (vinfo.xres * vinfo.yres * vinfo.bits_per_pixel) / 8;

    printf ("vinfo.xres = %d\n", vinfo.xres);
    printf ("vinfo.yres = %d\n", vinfo.yres);
    printf ("vinfo.bits_per_pixel = %d\n", vinfo.bits_per_pixel);
    printf ("screensize = 0x%x\n", screensize);

    printf ("PageSize (getpagesize):    0x%x\n", getpagesize());

    /* Map the device to memory */
    fbp = mmap(0, screensize, PROT_READ|PROT_WRITE, MAP_SHARED, fbfd,

    if ((int)fbp == -1)
        printf("\nError: failed to map framebuffer device to memory.

    printf("The framebuffer device was mapped to memory successfully.

    x = 100; y = 100;    /* Where we are going to put the pixel */

    /* Figure out where in memory to put the pixel */
    location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
               (y+vinfo.yoffset) * finfo.line_length;

    *(fbp + location) = 100;        /* Some blue       */
    *(fbp + location + 1) = 15;     /* A little green  */
    *(fbp + location + 2) = 200;    /* A lot of red    */
    *(fbp + location + 3) = 0;      /* No transparency */

    munmap(fbp, screensize);

    return 0;

Reply to: