Ashok Kumar Reddy

i.MX6: fb2 Framebuffer issue

Discussion created by Ashok Kumar Reddy on Aug 15, 2012
Latest reply on Nov 12, 2012 by Weihua Zou

Hi ,  

Imx6 has 6 frame buffers - fb0 to fb5. We are able to get fb0 and fb1 working using the standard fb test program. Also, we are able to get fb0 and fb1 simultaneously working with alpha values set.

But, we are unable to get any other fbs working. We understand that fb2 is also BG like fb0. All the IOCTLs seem to work well, but we are unable to see any visual display for fb.

We have allocated vram for fb2, tried setting vscreen info in code corresponding to 800 * 480 and used vsync ioctl too. Setting vscreeninfo corresponding to fb0 - 1024 * 768 also does not solve the issue. But we are unable to see any output on screen, though there is no error. We have not got the LCD up for our board and hence trying to test the same using monitor currently.

Find code snippet below used and also the setenv values:  

bootargs :console=tty1 console=ttymxc1,115200 video=mxcfb0:dev=hdmi,1280x720M@60,if=RGB24 root=/dev/mmcblk0p2 rootfs=ext4 rw rootwait vmalloc=192M vram=1:3M,2:3M,3:3M,4:3M,5:3M  

 

 #include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include "mxcfb.h"
#include <linux/ioctl.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 rc,errno;
        /* Open the file for reading and writing */
        fbfd = open("/dev/fb2", 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);
        }

       /* Figure out the size of the screen in bytes */
        screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
        struct fb_var_screeninfo * screenInfo =  &vinfo;

        rc = ioctl(fbfd, FBIOBLANK, FB_BLANK_UNBLANK);
        if (rc)
        {
         printf("Error setting size on device /dev/fb1, errno %d", errno);
         }

        screenInfo->bits_per_pixel = 16;
        screenInfo->xres = 1280;
        screenInfo->yres = 720;
        screenInfo->xres_virtual = screenInfo->xres;
        screenInfo->yres_virtual = screenInfo->yres;
        screenInfo->xoffset = 0;
        screenInfo->yoffset = 0;

        rc = ioctl(fbfd, FBIOPUT_VSCREENINFO, screenInfo);
        screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
        printf("%dx%d, %dbpp\n screensize=%ld", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel,screensize);

        ioctl(fbfd, MXCFB_WAIT_FOR_VSYNC, 0);
       

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

         

        for (x=50000; x < 400000;x++)      { 

         /* Figure out where in memory to put the pixel */

         location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +(y+vinfo.yoffset) * finfo.line_length;

        *(fbp + x) = 0xffffff; }

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

Is there any specific settings that we need to use to get fb2 working?
Also for our application use case, we need 3 layers - one of the menu, one for display for video like map and one more layer to show directions. So we need to simultaneously use 3 fbs.
Please suggest which fb combination to use and setting to be done for the same

Thanks,

Ashok

 

Outcomes