From: hackbard Date: Wed, 18 Aug 2004 08:46:30 +0000 (+0000) Subject: initial checkin of fbutil.c and Makefile X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;p=my-code%2Ffbutil.git initial checkin of fbutil.c and Makefile --- 42614396ea24f44fb26c18dd2c98b13162eabac6 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3a28e2b --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +CFLAGS = -O3 -Wall +LIBS = +INCLUDES = +CC = gcc +OBJS = fbutil + +all: $(OBJS) + +clean: + rm -f $(OBJS) diff --git a/fbutil.c b/fbutil.c new file mode 100644 index 0000000..1edba2e --- /dev/null +++ b/fbutil.c @@ -0,0 +1,157 @@ +/* + * fbutil.c -- get/set framebuffer values + * + * hackbard@hackdaworld.dyndns.org + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#define MAXDEV 32 +#define DEVICE "/dev/fb/0" + +#define FIXED_INFO (1<<0) +#define VAR_INFO (1<<1) + +int usage() { + printf("usage:\n"); + printf("-d \t specify device (default %s)\n",DEVICE); + printf("-f \t print out fixed framebuffer info\n"); + printf("-v \t print out variable framebuffer info\n"); + printf("\n"); + return 1; +} + +int main(int argc,char **argv) { + + int i; + int fd; + char device[MAXDEV]; + unsigned char getmodes; + unsigned char setmodes; + + /* fb variables */ + struct fb_fix_screeninfo fixed_info; + struct fb_var_screeninfo var_info; + + strcpy(device,DEVICE); + getmodes=0; + setmodes=0; + + for(i=1;i 0 see )\n", + fixed_info.accel); + + } + + if(getmodes&VAR_INFO) { + if(ioctl(fd,FBIOGET_VSCREENINFO,&var_info)<0) { + printf("cannot get variable screen info\n"); + return -1; + } + printf("variable screen info:\n"); + printf("resolution: %ux%u, virtual %ux%u\n", + var_info.xres,var_info.yres, + var_info.xres_virtual,var_info.yres_virtual); + printf("bits per pixel: %u\n",var_info.bits_per_pixel); + printf("offsets: x=%u y=%u\n", + var_info.xoffset,var_info.yoffset); + printf("gray scale: %c\n",var_info.grayscale?'y':'n'); + printf("rgb:\n"); + printf("red: offset=%u length=%u msb=%c\n", + var_info.red.offset,var_info.red.length, + var_info.red.msb_right?'r':'l'); + printf("green: offset=%u length=%u msb=%c\n", + var_info.green.offset,var_info.green.length, + var_info.green.msb_right?'r':'l'); + printf("blue: offset=%u length=%u msb=%c\n", + var_info.blue.offset,var_info.blue.length, + var_info.blue.msb_right?'r':'l'); + printf("transparency: offset=%u length=%u msb=%c\n", + var_info.transp.offset,var_info.transp.length, + var_info.transp.msb_right?'r':'l'); + printf("non standard pixel format: %c\n", + var_info.nonstd?'y':'n'); + // printf("activate: + } + + close(fd); + + return 1; +} +