How to discover screen depth

Doug Arnold dna at emmy.umd.edu
Wed Nov 23 17:43:13 AEST 1988


>>  Is there an easy way to find out the screen depth?

I use the following simple program, which I call displaytype.  It works
like this:

emmy% displaytype
Sun 2 or 3 color  900 x 1152 x 8 pixels
emmy% rsh athena displaytype
Sun 2 or 3 monochrome  900 x 1152 x 1 pixels

There should be a better way to handle color 3/60's or other machines with
two framebuffers correctly.   It currently reports monochrome.  Perhaps
someone knows how to do it?

  -- Doug Arnold (dna at emmy.umd.edu or arnold at eneevax.umd.edu)

/*
 *  displaytype  --  identify type of display connected to Sun workstation
 *       compile with "cc -o displaytype displaytype.c"
 */

#include <stdio.h>
#include <errno.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sun/fbio.h>

extern int      errno;

char           *displaytype[] =
{
    "Sun 1 monochrome",
    "Sun 1 color",
    "Sun 2 or 3 monochrome",
    "Sun 2 or 3 color",
    "Sun 2 or 3 graphics processor",
    "type unknown",
    "type unknown",
    "Sun 4 monochrome",
    "Sun 4 color",
    ""
};

main()
{
    int             fd;
    struct fbtype   fbinfo;	/* struct for frame buffer info */

    fd = open("/dev/fb", O_RDONLY);
    if (fd < 0)
    {
	printf("Error opening /dev/fb, error #%d\n", errno);
	exit(2);
    }
    if (ioctl(fd, FBIOGTYPE, &fbinfo) == -1)
    {
	printf("Ioctl error on /dev/fb, error #%d\n", errno);
	exit(3);
    }
    printf("%s  %d x %d x %d pixels\n",
	   displaytype[fbinfo.fb_type],
	   fbinfo.fb_height, fbinfo.fb_width, fbinfo.fb_depth);
    exit(0);
}



More information about the Comp.sys.sun mailing list