⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fbinfo.c

📁 Source files for pxa LCD driver ======================================== The packet contains the
💻 C
📖 第 1 页 / 共 2 页
字号:

/*
 * Copyright (c) 2d3D, Inc.
 * Written by Abraham vd Merwe <abraham@2d3d.co.za>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *	  notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *	  notice, this list of conditions and the following disclaimer in the
 *	  documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the author nor the names of other contributors
 *	  may be used to endorse or promote products derived from this software
 *	  without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <linux/fb.h>

static const char *fb_type_flags (__u32 flags)
{
   static char buf[100];
   switch (flags)
	 {
	  case FB_TYPE_PACKED_PIXELS:
		return ("Packed Pixels");
	  case FB_TYPE_PLANES:
		return ("Non interleaved planes");
	  case FB_TYPE_INTERLEAVED_PLANES:
		return ("Interleaved planes");
	  case FB_TYPE_TEXT:
		return ("Text/attributes");
	  case FB_TYPE_VGA_PLANES:
		return ("EGA/VGA planes");
	  default:
		sprintf (buf,"UNKNOWN (flags == %u)",flags);
		return (buf);
	 }
}

static const char *fb_aux_text_flags (__u32 flags)
{
   static char buf[100];
   switch (flags)
	 {
	  case FB_AUX_TEXT_MDA:
		return ("Monochrome text");
	  case FB_AUX_TEXT_CGA:
		return ("CGA/EGA/VGA Color text");
	  case FB_AUX_TEXT_S3_MMIO:
		return ("S3 MMIO fasttext");
	  case FB_AUX_TEXT_MGA_STEP16:
		return ("MGA Millenium I: text, attr, 14 reserved bytes");
	  case FB_AUX_TEXT_MGA_STEP8:
		return ("other MGA Milleniums: text, attr, 6 reserved bytes");
	  default:
		sprintf (buf,"UNKNOWN (flags == %u)",flags);
		return (buf);
	 }
}

static const char *fb_aux_vga_flags (__u32 flags)
{
   static char buf[100];
   switch (flags)
	 {
	  case FB_AUX_VGA_PLANES_VGA4:
		return ("16 color planes (EGA/VGA)");
	  case FB_AUX_VGA_PLANES_CFB4:
		return ("CFB4 in planes (VGA)");
	  case FB_AUX_VGA_PLANES_CFB8:
		return ("CFB8 in planes (VGA)");
	  default:
		sprintf (buf,"UNKNOWN (flags == %u)",flags);
		return (buf);
	 }
}

static const char *fb_visual_flags (__u32 flags)
{
   static char buf[100];
   switch (flags)
	 {
	  case FB_VISUAL_MONO01:
		return ("Monochrome. 1=Black 0=White");
	  case FB_VISUAL_MONO10:
		return ("Monochrome. 1=White 0=Black");
	  case FB_VISUAL_TRUECOLOR:
		return ("True color");
	  case FB_VISUAL_PSEUDOCOLOR:
		return ("Pseudo color (like atari)");
	  case FB_VISUAL_DIRECTCOLOR:
		return ("Direct color");
	  case FB_VISUAL_STATIC_PSEUDOCOLOR:
		return ("Pseudo color readonly");
	  default:
		sprintf (buf,"UNKNOWN (flags == %u)",flags);
		return (buf);
	 }
}

static const char *fb_accel_flags (__u32 flags)
{
   static char buf[100];
   switch (flags)
	 {
	  case FB_ACCEL_NONE:
		return ("no hardware accelerator");
	  case FB_ACCEL_ATARIBLITT:
		return ("Atari Blitter");
	  case FB_ACCEL_AMIGABLITT:
		return ("Amiga Blitter");
	  case FB_ACCEL_S3_TRIO64:
		return ("Cybervision64 (S3 Trio64)");
	  case FB_ACCEL_NCR_77C32BLT:
		return ("RetinaZ3 (NCR 77C32BLT)");
	  case FB_ACCEL_S3_VIRGE:
		return ("Cybervision64/3D (S3 ViRGE)");
	  case FB_ACCEL_ATI_MACH64GX:
		return ("ATI Mach 64GX family");
	  case FB_ACCEL_DEC_TGA:
		return ("DEC 21030 TGA");
	  case FB_ACCEL_ATI_MACH64CT:
		return ("ATI Mach 64CT family");
	  case FB_ACCEL_ATI_MACH64VT:
		return ("ATI Mach 64CT family VT class");
	  case FB_ACCEL_ATI_MACH64GT:
		return ("ATI Mach 64CT family GT class");
	  case FB_ACCEL_SUN_CREATOR:
		return ("Sun Creator/Creator3D");
	  case FB_ACCEL_SUN_CGSIX:
		return ("Sun cg6");
	  case FB_ACCEL_SUN_LEO:
		return ("Sun leo/zx");
	  case FB_ACCEL_IMS_TWINTURBO:
		return ("IMS Twin Turbo");
	  case FB_ACCEL_3DLABS_PERMEDIA2:
		return ("3Dlabs Permedia 2");
	  case FB_ACCEL_MATROX_MGA2064W:
		return ("Matrox MGA2064W (Millenium)");
	  case FB_ACCEL_MATROX_MGA1064SG:
		return ("Matrox MGA1064SG (Mystique)");
	  case FB_ACCEL_MATROX_MGA2164W:
		return ("Matrox MGA2164W (Millenium II)");
	  case FB_ACCEL_MATROX_MGA2164W_AGP:
		return ("Matrox MGA2164W (Millenium II) AGP");
	  case FB_ACCEL_MATROX_MGAG100:
		return ("Matrox G100 (Productiva G100)");
	  case FB_ACCEL_MATROX_MGAG200:
		return ("Matrox G200 (Myst, Mill, ...)");
	  case FB_ACCEL_SUN_CG14:
		return ("Sun cgfourteen");
	  case FB_ACCEL_SUN_BWTWO:
		return ("Sun bwtwo");
	  case FB_ACCEL_SUN_CGTHREE:
		return ("Sun cgthree");
	  case FB_ACCEL_SUN_TCX:
		return ("Sun tcx");
	  case FB_ACCEL_MATROX_MGAG400:
		return ("Matrox G400");
	  case FB_ACCEL_NV3:
		return ("nVidia RIVA 128");
	  case FB_ACCEL_NV4:
		return ("nVidia RIVA TNT");
	  case FB_ACCEL_NV5:
		return ("nVidia RIVA TNT2");
	  case FB_ACCEL_CT_6555x:
		return ("C&T 6555x");
	  case FB_ACCEL_3DFX_BANSHEE:
		return ("3Dfx Banshee");
	  case FB_ACCEL_ATI_RAGE128:
		return ("ATI Rage128 family");
	  case FB_ACCEL_IGS_CYBER2000:
		return ("CyberPro 2000");
	  case FB_ACCEL_IGS_CYBER2010:
		return ("CyberPro 2010");
	  case FB_ACCEL_IGS_CYBER5000:
		return ("CyberPro 5000");
	  case FB_ACCEL_SIS_GLAMOUR:
		return ("SiS 300/630/540");
	  default:
		sprintf (buf,"UNKNOWN (flags == %u)",flags);
		return (buf);
	 }
}

static void get_fixed_screen_info (int fd)
{
   struct fb_fix_screeninfo buf;

   if (ioctl (fd,FBIOGET_FSCREENINFO,&buf))
	 {
		perror ("ioctl(FBIOGET_FSCREENINFO)");
		exit (1);
	 }

   fprintf (stdout,
			"fb_fix_screeninfo = {\n"
			"   id = \"%s\"\n"
			"   smem_start = 0x%.8lx\n"
			"   smem_len = %u\n"
			"   type = %s\n"
			"   type_aux = %s\n"
			"   visual = %s\n"
			"   xpanstep = %u\n"
			"   ypanstep = %u\n"
			"   ywrapstep = %u\n"
			"   line_length = %u\n"
			"   mmio_start = 0x%.8lx\n"
			"   mmio_len = %u\n"
			"   accel = %s\n"
			"}\n\n",
			buf.id,
			buf.smem_start,
			buf.smem_len,
			fb_type_flags (buf.type),
			buf.type == FB_TYPE_TEXT ? fb_aux_text_flags (buf.type_aux) : fb_aux_vga_flags (buf.type_aux),
			fb_visual_flags (buf.visual),
			buf.xpanstep,
			buf.ypanstep,
			buf.ywrapstep,
			buf.line_length,
			buf.mmio_start,
			buf.mmio_len,
			fb_accel_flags (buf.accel));
   fflush (stdout);
}

static char const *fb_activate_flags (__u32 flags)
{
   static char buf[1024];
   *buf = '\0';
   if (flags & FB_ACTIVATE_NOW) strcat (buf,"set values immediately (or vbl)");
   if (flags & FB_ACTIVATE_NXTOPEN)
	 {
		strcat (buf,"activate on next open");
	 }
   if (flags & FB_ACTIVATE_TEST)
	 {
		if (strlen (buf)) strcat (buf,", ");
		strcat (buf,"don't set, round up impossible");
	 }
   if (flags & FB_ACTIVATE_VBL)
	 {
		if (strlen (buf)) strcat (buf,", ");
		strcat (buf,"activate values on next vbl");
	 }
   if (flags & FB_CHANGE_CMAP_VBL)
	 {
		if (strlen (buf)) strcat (buf,", ");
		strcat (buf,"change colormap on vbl");
	 }
   if (flags & FB_ACTIVATE_ALL)
	 {
		if (strlen (buf)) strcat (buf,", ");
		strcat (buf,"change all VCs on this fb");
	 }
   return (buf);
}

static char const *fb_accel_hints_flags (__u32 flags)
{
   static char buf[100];
   switch (flags)
	 {
	  case FB_ACCELF_TEXT:
		return ("text mode acceleration");
	  default:
		sprintf (buf,"UNKNOWN (flags == %u)",flags);
		return (buf);
	 }
}

static char const *fb_sync_flags (__u32 flags)
{
   static char buf[1024];
   *buf = '\0';
   if (flags & FB_SYNC_HOR_HIGH_ACT) strcat (buf,"horizontal sync high active");
   if (flags & FB_SYNC_VERT_HIGH_ACT)
	 {
		if (strlen (buf)) strcat (buf,", ");
		strcat (buf,"vertical sync high active");
	 }
   if (flags & FB_SYNC_EXT)
	 {
		if (strlen (buf)) strcat (buf,", ");
		strcat (buf,"external sync");
	 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -