Android 獲取framebuffer相關信息

/********************************************************************************
 *                      Android 獲取framebuffer信息
 * 聲明:
 *     調試顯示屏的時候,我們可能會需要去知道我們設置的信息是否正確,或者有時候
 * 需要去確認別人的設置的是否正確。
 *
 *******************************************************************************/

參考文章:
    【Linux】FrameBuffer操作入門
        http://blog.csdn.net/tianshuai1111/article/details/8502613

一、cat fbinfo.c
    #include <unistd.h>  
    #include <stdio.h>  
    #include <fcntl.h>  
    #include <linux/fb.h>  
    #include <sys/mman.h>  
    #include <stdlib.h>  

    // I.MX6 android fb0 ----> "/dev/graphics/fb0"
    int main (int argc, char **argv)   
    {  
        int fp = 0;  
        struct fb_var_screeninfo vinfo;  
        struct fb_fix_screeninfo finfo;  
        fp = open (argv[1], O_RDWR);  
        if (fp < 0){  
            printf("Error : Can not open framebuffer device\n");  
            exit(1);  
        }  

        if (ioctl(fp,FBIOGET_FSCREENINFO,&finfo)){  
            printf("Error reading fixed information\n");  
            exit(2);  
        }  

        if (ioctl(fp,FBIOGET_VSCREENINFO,&vinfo)){  
            printf("Error reading variable information\n");  
            exit(3);  
        }  

        printf("The mem is :%d\n",finfo.smem_len);  
        printf("The line_length is :%d\n",finfo.line_length);  
        printf("The xres is :%d\n",vinfo.xres);  
        printf("The yres is :%d\n",vinfo.yres);  
        printf("bits_per_pixel is :%d\n",vinfo.bits_per_pixel);  
        close (fp);  
    }  

二、Android.mk
    LOCAL_PATH := $(call my-dir)

    include $(CLEAR_VARS)
    LOCAL_MODULE    := fbinfo 
    LOCAL_SRC_FILES := fbinfo.c

    include $(BUILD_EXECUTABLE)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章