LCD testing C program Problem in Android!

Discuss Android on the Wandboard, as well as app development for or on the Wandboard.

LCD testing C program Problem in Android!

Postby khiremandar » Fri Jan 02, 2015 7:13 am

Hi,
I have one c program which show full Screen Read color. By this program i can check RGB proper or not!
When i run this program in Yocto it works very fine.
But when i run in Andorid it shows 'Segmentation fault'.
Code: Select all
#include <linux/fb.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/mman.h>

const char *FB_NAME = "/dev/graphics/fb0";
void* m_FrameBuffer;
struct fb_fix_screeninfo m_FixInfo;
struct fb_var_screeninfo m_VarInfo;
int m_FBFD;

int main() {
   int iFrameBufferSize;
   /* Open the framebuffer device in read write */
   m_FBFD = open(FB_NAME, O_RDWR);
   if (m_FBFD < 0) {
      printf("Unable to open %s.\n", FB_NAME);
      return 1;
   } else {
      /* Do Ioctl. Retrieve fixed screen info. */
      if (ioctl(m_FBFD, FBIOGET_FSCREENINFO, &m_FixInfo) < 0) {
         printf("get fixed screen info failed: %s\n", strerror(errno));
         close(m_FBFD);
         return 1;
      } else {
         /* Do Ioctl. Get the variable screen info. */
         if (ioctl(m_FBFD, FBIOGET_VSCREENINFO, &m_VarInfo) < 0) {
            printf("Unable to retrieve variable screen info: %s\n",
                  strerror(errno));
            close(m_FBFD);
            return 1;
         } else {
            /* Calculate the size to mmap */
            iFrameBufferSize = m_FixInfo.line_length * m_VarInfo.yres;
            printf("Line length %d\n", m_FixInfo.line_length);
            /* Now mmap the framebuffer. */
            m_FrameBuffer = mmap(NULL, iFrameBufferSize,
                  PROT_READ | PROT_WRITE, MAP_SHARED, m_FBFD, 0);
            if (m_FrameBuffer == NULL) {
               printf("mmap failed:\n");
               close(m_FBFD);
               return 1;
            } else {
               printf("\nFB: x-res=%d, y-res=%d\n", (int) m_VarInfo.xres,
                     (int) m_VarInfo.yres);
               {
                  int *p = (int *) m_FrameBuffer;
                  int x, y, t = 0;
                  while (1) {
                     for (y = 0; y < m_VarInfo.yres; y++) {
                        for (x = 0; x < m_VarInfo.xres; x++) {
                           p[x + y * m_VarInfo.xres] =
                                 (int) 0xffff0000;

                        }
                     }
                  }
                  t++;
               }
            }
         }
      }
   }
}


Is there any Idea how to solve this?
khiremandar
 
Posts: 86
Joined: Wed Sep 03, 2014 11:38 am

Re: LCD testing C program Problem in Android!

Postby khiremandar » Tue Feb 17, 2015 1:22 pm

Hi,
47 days ago from today i asked question but still no one try to answer, Why?
Is it not relevent question?
Waiting for some answer!
khiremandar
 
Posts: 86
Joined: Wed Sep 03, 2014 11:38 am

Re: LCD testing C program Problem in Android!

Postby waleed030 » Mon Apr 06, 2015 8:53 am

47 days ago from today i asked question but still no one try to answer, Why?
waleed030
 
Posts: 2
Joined: Mon Apr 06, 2015 8:47 am


Return to Software - Android

Who is online

Users browsing this forum: No registered users and 4 guests