📄 fbinfo.c
字号:
if (flags & FB_SYNC_COMP_HIGH_ACT)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"composite sync high active");
}
if (flags & FB_SYNC_BROADCAST)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"broadcast video timings (vtotal = 144d/288n/576i => PAL, vtotal = 121d/242n/484i => NTSC)");
}
if (flags & FB_SYNC_ON_GREEN)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"sync on green");
}
return (buf);
}
static const char *fb_vmode_flags (__u32 flags)
{
static char buf[1024];
*buf = '\0';
if (flags & FB_VMODE_INTERLACED) strcat (buf,"interlaced"); else strcat (buf,"non interlaced");
if (flags & FB_VMODE_DOUBLE)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"double scan");
}
if (flags & FB_VMODE_YWRAP)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"ywrap instead of panning");
}
if (flags & FB_VMODE_SMOOTH_XPAN)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"smooth xpan possible (internally used)");
}
if (flags & FB_VMODE_CONUPDATE)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"don't update x/yoffset");
}
return (buf);
}
static const char *bitfield_string (const struct fb_bitfield *pixel)
{
static int count = 0;
static char buf[10][256];
if (pixel == NULL)
sprintf (buf[count++],"(null)");
else
sprintf (buf[count++],
"{ offset: %u, length: %u, %s }",
pixel->offset,
pixel->length,
pixel->msb_right ? "most significant bit is right" : "most significant bit is left");
return (buf[count - 1]);
}
static void get_variable_screen_info (int fd)
{
struct fb_var_screeninfo buf;
if (ioctl (fd,FBIOGET_VSCREENINFO,&buf))
{
perror ("ioctl(FBIOGET_VSCREENINFO)");
exit (1);
}
fprintf (stdout,
"fb_var_screeninfo = {\n"
" xres = %u\n"
" yres = %u\n"
" xres_virtual = %u\n"
" yres_virtual = %u\n"
" xoffset = %u\n"
" yoffset = %u\n"
" bits_per_pixel = %u\n"
" grayscale = %s\n"
" red = %s\n"
" green = %s\n"
" blue = %s\n"
" transp = %s\n"
" nonstd = %s\n"
" activate = %s\n"
" height = %u mm\n"
" width = %u mm\n"
" accel_flags = %s (hints)\n"
" pixclocks = %u pico seconds\n"
" left_margin = %u clocks (time from sync to picture)\n"
" right_margin = %u clocks (time from picture to sync)\n"
" upper_margin = %u clocks (time from sync to picture)\n"
" lower_margin = %u clocks\n"
" hsync_len = %u clocks (length of horizontal sync)\n"
" vsync_len = %u clocks (length of vertical sync)\n"
" sync = %s\n"
" vmode = %s\n"
"}\n\n",
buf.xres,
buf.yres,
buf.xres_virtual,
buf.yres_virtual,
buf.xoffset,
buf.yoffset,
buf.bits_per_pixel,
buf.grayscale ? "Graylevels instead of colors" : "Colors instead of graylevels",
bitfield_string (&buf.red),
bitfield_string (&buf.green),
bitfield_string (&buf.blue),
bitfield_string (&buf.transp),
buf.nonstd ? "Non standard pixel format" : "Standard pixel format",
fb_activate_flags (buf.activate),
buf.height,
buf.width,
fb_accel_hints_flags (buf.accel_flags),
buf.pixclock,
buf.left_margin,
buf.right_margin,
buf.upper_margin,
buf.lower_margin,
buf.hsync_len,
buf.vsync_len,
fb_sync_flags (buf.sync),
fb_vmode_flags (buf.vmode));
fflush (stdout);
}
#ifdef FBIOGET_MONITORSPEC
static void get_monitor_specs (int fd)
{
struct fb_monspecs buf;
if (ioctl (fd,FBIOGET_MONITORSPEC,&buf))
{
perror ("ioctl(FBIOGET_MONITORSPEC)");
exit (1);
}
fprintf (stdout,
"fb_monspecs = {\n"
" hfmin = %u Hz\n"
" hfmax = %u Hz\n"
" vfmin = %u Hz\n"
" vfmax = %u Hz\n"
" %s\n"
"}\n\n",
buf.hfmin,
buf.hfmax,
buf.vfmin,
buf.vfmax,
buf.dpms ? "supports DPMS" : "doesn't support DPMS");
fflush (stdout);
}
#endif
static const char *fb_vblank_flags (__u32 flags)
{
static char buf[1024];
*buf = '\0';
if (flags & FB_VBLANK_VBLANKING) strcat (buf,"currently in a vertical blank");
if (flags & FB_VBLANK_HBLANKING)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"currently in a horizontal blank");
}
if (flags & FB_VBLANK_HAVE_VBLANK)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"vertical blanks can be detected");
}
if (flags & FB_VBLANK_HAVE_HBLANK)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"horizontal blanks can be detected");
}
if (flags & FB_VBLANK_HAVE_COUNT)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"global retrace counter is available");
}
if (flags & FB_VBLANK_HAVE_VCOUNT)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"the vcount field is valid");
}
if (flags & FB_VBLANK_HAVE_HCOUNT)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"the hcount field is valid");
}
if (flags & FB_VBLANK_VSYNCING)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"currently in a vsync");
}
if (flags & FB_VBLANK_HAVE_VSYNC)
{
if (strlen (buf)) strcat (buf,", ");
strcat (buf,"vertical syncs can be detected");
}
return (buf);
}
#if 0
static void get_vblank_info (int fd)
{
struct fb_vblank buf;
if (ioctl (fd,FBIOGET_VBLANK,&buf))
{
perror ("ioctl(FBIOGET_VBLANK)");
exit (1);
}
fprintf (stdout,
"fb_vblank = {\n"
" flags = %s\n"
" count = %u (counter of retraces since boot)\n"
" vcount = %u (current scanline position)\n"
" hcount = %u (current scandot position)\n"
"}\n\n",
fb_vblank_flags (buf.flags),
buf.count,
buf.vcount,
buf.hcount);
fflush (stdout);
}
static void get_colormap_info (int fd)
{
struct fb_cmap buf;
int i;
if (ioctl (fd,FBIOGETCMAP,&buf))
{
perror ("ioctl(FBIOGETCMAP)");
exit (1);
}
fprintf (stdout,"fb_cmap = {\n");
for (i = 0; i < buf.len - buf.start; i++)
fprintf (stdout,
" { red: %u, green: %u, blue: %u, transp: %u }\n",
buf.red[i],
buf.green[i],
buf.blue[i],
buf.transp[i]);
fprintf (stdout,"}\n\n");
fflush (stdout);
}
#endif
/********************/
static int fd = 0;
static void close_fd ()
{
if (fd) close (fd);
}
int main (int argc,char *argv[])
{
const char *progname;
struct stat filestat;
/* sanity checks */
(progname = strrchr (argv[0],'/')) ? progname++ : (progname = argv[0]);
if (argc != 2)
{
fprintf (stderr,"usage: %s <fb-device>\n",progname);
exit (1);
}
if (lstat (argv[1],&filestat) < 0)
{
perror ("lstat()");
exit (1);
}
if (!(filestat.st_mode & S_IFCHR))
{
fprintf (stderr,"%s is not a character device!\n",argv[1]);
exit (1);
}
/* open device for reading/writing */
if ((fd = open (argv[1],O_RDWR | O_SYNC)) < 0)
{
fprintf (stderr,"Couldn't open %s for reading!\n",argv[1]);
exit (1);
}
atexit (close_fd);
get_fixed_screen_info (fd);
get_variable_screen_info (fd);
#ifdef FBIOGET_MONITORSPEC
get_monitor_specs (fd);
#endif
#if 0
get_colormap_info (fd);
get_vblank_info (fd);
#endif
exit (0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -