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

Frame buffer use on Coldfire problem

I'm running a 2.6.10 kernel on a Coldfire (M5484) and I'm trying to
get some frame buffer graphics going. The video chip I'm using is a
Epson S1D13a04 and there was actually a driver for Linux kernel 2.6.8
from Epson that I was able to port to my kernel. Thought life was good
but I have yet to get anything on the screen at all. My first attempt
is listed below. The problem occurs on the memory map (mmap) command.
Thought the /dev/fb0 device opens and the call to ioctl returns valid
information, when I call mmap to set up the memory the call fails
(returns -1). The device resides at physical address 0x44040000.

Any help, advice, or experience you can share on Linux frame buffer use
or my specific issue would be much appreciated!

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

int main()
    int fbfd = 0;
    long int screensize = 0;
    unsigned long Size;
    void *fbp;

    struct fb_var_screeninfo vinfo;
    struct fb_fix_screeninfo finfo;

    off_t PageOffset, PageAddress, PhysAddr;

    fbfd = open("/dev/fb0", O_RDWR);

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

    if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo))
        printf("Error reading fixed information.\n");

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

    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 = %d\n", screensize);

    fbp = mmap((caddr_t)0, screensize, PROT_READ|PROT_WRITE, MAP_SHARED,
fbfd, 0);

    if (fbp == MAP_FAILED)
        printf("Error: failed (%d) to map framebuffer device to
memory.\n", fbp);

    printf("The framebuffer device was mapped to memory successfully.\n");

    munmap(fbp, screensize);

    return 0;

Reply to: