2009-02-01
BUGFIX: jfbterm (5)
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>       // include frame buffer header files
#include <sys/ioctl.h>
int main(void)
{
  int fbfd = 0 ;            // frame buffer file description
  /* Get device independent unchangeable information about a frame buffer
   * device and a specific video mode by FBIOGET_FSCREENINFO ioctl. */
  struct  fb_fix_screeninfo finfo;
  fbfd = open( "/dev/fb0" , 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 screen information.\n");
    exit(2);
  } else {
    printf("Succesfully Read the Fixed Screen Information\n");
  }
  printf("fb_fix_screeninfo.smem_len = %d\n", finfo.smem_len);
  printf("fb_fix_screeninfo.mmio_len = %d\n", finfo.mmio_len);
}
- 在 Ubuntu Intrepid 上執行結果
root@intrepid:~# uname -a
Linux intrepid 2.6.27-7-server #1 SMP Tue Nov 4 20:16:57 UTC 2008 x86_64 GNU/Linux
root@intrepid:~# ./fbinfo
The framebuffer device was opened successfully.
Succesfully Read the Fixed Screen Information
fb_fix_screeninfo.smem_len = 16777216
fb_fix_screeninfo.mmio_len = 0
 - 以下是在 Debian Sarge 上執行結果,值得一提的是 jfbterm 在 2.6.8 核心上可以正常執行。(不過還有字型問題需要調整)
root@wsu-admin:~# uname -a
Linux wsu-admin 2.6.8-2-386 #1 Tue Aug 16 12:46:35 UTC 2005 i686 GNU/Linux
root@wsu-admin:~# ./fbinfo
The framebuffer device was opened successfully.
Succesfully Read the Fixed Screen Information
fb_fix_screeninfo.smem_len = 65536
fb_fix_screeninfo.mmio_len = 0
 - 以下是在 Debian Etch 上執行結果,有趣的是 jfbterm 0.4.7-7 在 2.6.18 上執行,縱使有 cannot mmap(mmio) : Invalid argument 的錯誤訊息,但仍舊可以正常進入 jfbterm 的環境。
root@etch:~# uname -a
Linux etch 2.6.18-4-686 #1 SMP Wed May 9 23:03:12 UTC 2007 i686 GNU/Linux
root@etch:~# ./fbinfo
The framebuffer device was opened successfully.
Succesfully Read the Fixed Screen Information
fb_fix_screeninfo.smem_len = 1920000
fb_fix_screeninfo.mmio_len = 0
 - 在 Debian Lenny 上執行結果