FBIOGET_FSCREENINFO is not reading in Lepton Linux and Redhat Linux

Crazy Boy <[email protected]> Sun, 22 Jan 2006 23:22:05 -0800 (PST)
Newsgroups gmane.linux.fbdev.user
Message-ID <20060123072205.33929.qmail__41218.3143351742$1138006455$gmane$org@web37111.mail.mud.yahoo.com>
 Hi,
  
  I am using Lepton Floppy Linux and Redhat Linux. When I am trying to execute the Framebuffer sample program, It is displaying the below error message:
  
  The framebuffer device was opened successfully.
  Error reading fixed screen information.
  Error reading variable screen information.
  
  Actually, It is opening Framebuffer (/dev/fb0) device successfully. But, it is unable to read the Fixed screen information (FBIOGET_FSCREENINFO) and Variable screen information (FBIOGET_VSCREENINFO). fbset command is also not working. What can I do? Please give me the solution. Here, I am giving the sample code of framebuffer. Please run this and see the output. 
  
  #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 screen information.\n");
          exit(2);
      } 
      else
      printf("\nSuccesfully Read the Fixed Screen Information\n");
      
      /* Get variable screen information */
      if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) 
      {
          printf("Error reading variable screen information.\n");
          exit(3); 
      } 
      else
      printf("\n Successfully Read the Variable Information\n");
  
      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;
  }
  
  
  I will be waiting for your reply. Thank you.
  
  With regards,
  Chandra.
 

		
---------------------------------
 
 What are the most popular cars?  Find out at Yahoo! Autos