/* * From "Testing the Linux Framebuffer" * http://doc.trolltech.com/4.2/qtopiacore-testingframebuffer.html * * "To test that the Linux framebuffer is set up correctly, and that the device * permissions are correct, use the program below which opens the frame buffer * and draws a gradient-filled red square." * * Use this after making changes to the framebuffer driver. See * http://mrobefan.devjavu.com/projects/mrobefan/wiki/Fbtest. */ #include #include #include #include #include #include #include int main(int argc, char* argv[]) { int fbfd = 0; struct fb_var_screeninfo vinfo; char *device="/dev/fb0"; if(argc>1) { device=argv[1]; } // Open the file for reading and writing fbfd = open(device, O_RDWR); if (!fbfd) { printf("Error: cannot open framebuffer device.\n"); exit(1); } printf("The framebuffer device was opened successfully.\n"); // Get variable screen information if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { printf("Error reading variable information.\n"); exit(3); } vinfo.yres_virtual=482; int err = ioctl(fbfd, FBIOPUT_VSCREENINFO, &vinfo); if (err) { printf("***ERROR*** File %s, Line %i, errorcode:%i\n", __FILE__, __LINE__,err); printf("Warning: FBIOPUT_VSCREENINFO Failed, could not set new virtual yres."); return -1; } printf("%dx%d, virt: %d\n", vinfo.xres, vinfo.yres, vinfo.yres_virtual); vinfo.yoffset = 2; err = ioctl(fbfd,FBIOPAN_DISPLAY, &vinfo); if(err) { printf("***ERROR*** File %s, Line %i, errorcode:%i\n", __FILE__, __LINE__,err); printf("Setting PAN failed (ioctl:FBIOPAN_DISPLAY)\n"); return -1; } close(fbfd); return 0; }