Hi..Challenging problem and doubt

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Hi,

First of all, I would like to thankful to you for giving good
guidelines and encouragement to solve my problem. Your suggessions are
very helpful to me and for my work. Thank you very much for your quick
response.

I have one more doubt. i.e.,

When I am trying to execute the below Framebuffer example program in
Lepton (http://mulinux.dotsrc.org/lepton.html ) linux, My program is
unable to read the Fixed screen information(FBIOGET_FSCREENINFO) and
Variable screen information (FBIOGET_VSCREENINFO). But, it is
successfully initialized and open the framebuffer (/dev/fb0) device.
The same thing (problem) is repeating in RedHat Linux also. What can I
do? Please show me a solution.

The below program is successfully running in SuSe Linux 9.3. But, it is
not running in Lepton Linux.

The example program is:

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

int main(void)
{
    int fbfd = 0;
    struct fb_var_screeninfo vinfo;
    struct fb_fix_screeninfo finfo;
    long int screensize = 0;
    char *fbp = 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);
    }
    printf("The framebuffer device was opened successfully.\n");

    /* 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);
    }

    printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres,
vinfo.bits_per_pixel );

    /* 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);
    }
    printf("The framebuffer device was mapped to memory
successfully.\n");

    munmap(fbp, screensize);
    close(fbfd);
    return 0;
}

The above program is displaying 3 errors. Those are:

Error reading fixed information
Error reading variable information.
Error: failed to map framebuffer device to memory.

Please show me a solution. I will be waiting for your reply. Thank you
very much for considering your valuable time for me.

With regards,
Chandra.


Site Timeline