/******************************************************************************** * I.MX6 android 获取framebuffer信息 * 声明: * 调试显示屏的时候,我们可能会需要去知道我们设置的信息是否正确,或者有时候 * 需要去确认别人的设置的是否正确。 * * 2016-1-20 深圳 南山平山村 曾剑锋 *******************************************************************************/ 参考文章: 【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)