FW: Problem diplaying a pixel

"Nitin Mahajan" <[email protected]>
Newsgroups gmane.linux.fbdev.user
Message-ID <[email protected]>
Hello  Every one !
Iam trying to put one pixel on the scrren with the attached program. The
program runs fine ,but Iam not able to see the pixel on the screen. Is
there somehting which Iam missing? Or what can be the problem ?Can u
lpease help me out tof this? Thanking u in advanace, Regards,

Nitin Mahajan
Socrates Software India Pvt Ltd...
mail:[email protected]
Ph:51101667. Mobile : 9448260513
======================================
The Lord gave us two ends -- one to sit on and the other to think with.
Success depends on which one we use the most.
putpixel.c (application/octet-stream, 2.3 KB)
#include<unistd.h>
#include<stdio.h>
#include<fcntl.h>
#include<linux/fb.h>
#include<sys/mman.h>
#include<errno.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;
  int retval = 0;
  /*open the file for reading and writing*/
  fbfd = open("/dev/fb0",O_NONBLOCK);
  
  perror(strerror(errno));
  if(!fbfd)
    {
      printf("Error:cannot open frame buffer device.\n");
      exit(1);
    }
  printf("The frame buffer device was opened successfully.\n");
  
  /*Get fixed screen information.*/
  if(retval = ioctl(fbfd,FBIOGET_FSCREENINFO,&finfo)){
    printf("Error reading fixed information.\n");
    // exit(2);
  }
  switch(retval)
    {
    case EBADF:
      printf("Invalid descriptor.\n");break;
    case EFAULT:
      printf("Third argument references inaccessible memory area.\n");break;
    case ENOTTY:
      printf("Descriptor not associated with a character special device.\n OR\
The specified request does not apply to the kind of descriptor given.\n");break;
    case EINVAL:
      printf("Request or Third argument is invalid\n");

    }
        

  printf("The frame buffer device was opened successfully.\n");

  
  /*Get var screen information.*/
  if(ioctl(fbfd,FBIOGET_VSCREENINFO,&vinfo)){
    printf("Error reading var 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 top map frame buffer device to ememory.\n");
       exit(4);
     }

     printf("The frame buffer device was mapped to memory successfully.\n");
     
     x = 100;y = 100; /*Where r we going to put the pixel.*/
     
     /*Figure out where in memory to pu the pixel*/
     location  = (x + vinfo.xoffset)*(vinfo.bits_per_pixel / 8)  + (y + vinfo.yoffset) * finfo.line_length;
     *(fbp + location + 1) = 15;
     *(fbp + location + 2) = 200;
     *(fbp + location + 3) = 0;
     
     munmap(fbp, screensize);

     close(fbfd);
     return 0;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.