/*
 * $Header: /smsa/bsd:include/dev/fbioctl.h:bsd  1.6  $
 * $Source: /smsa/bsd:include/dev/fbioctl.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 *
 */
/* fbioctl.h */

#ifndef	__dev_fbioctl_h
#define	__dev_fbioctl_h

/* Formats and ioctl defs relating to frame-buffer devices */
    

/*
 * Bitmap descriptions
 *
 * A BitMap is always specified in the orientation that consecutive pixels in
 * memory have the same y offset and consecutive x-offsets, unless the first
 * pixel is at the right-hand end of a raster.
 *
 * The definitions below allow for quite a range of physical bitmap organisations,
 * from 1 bit/pixel simple mono map to e.g. (bits 8-31 out of 32)/pixel colour map,
 * (bits 0-2 out of 8)/pixel overlay plane map.
 */
typedef struct _fbbitmapinfo_
{
    unsigned char  bits_per_pixel;	/* active bits for each pixel */
    unsigned char  pixel_cell_bits;	/* bit distance from <x,y> to <x+1,y> */
    unsigned char  pixel_start_bits;	/* bit offset to start of pixel in cell */
    unsigned int   raster_step_bits;	/* bit distance from <x,y> to <x,y+1> */
    unsigned int   x_pixels;		/* viewable area x dimension */
    unsigned int   y_pixels;		/* viewable area y dimension */
    unsigned int   map_bytes;		/* size in bytes of a full bitmap */
} FBBitMapInfo, *FBBitMapInfoRef;


/*
 * A particular frame buffer device may consist of a number of distinct
 * sub-bitmaps (e.g. a colour display with 1x8bpp colour map + 2x1bpp
 * overlay maps).  Each sub bit-map may or may not be mappable into user 
 * address space.  If it is, the base_address field of a FBBitMap record 
 * will contain the address in user-space.  If not, it will be zero.
 */

typedef struct _fbbitmap_
{
    caddr_t     base_address;			/* #0 => mappable address */
    FBBitMapInfo  info;				/* info on bitmap */
} FBBitMap, *FBBitMapRef;

/*
 * The maximum number of distinct maps supported using this interface, for a
 * given device subtype, is specified as FB_MAXBITMAPS.  This limit is derived
 * from the operation of the ioctl interface (i.e. max 127 bytes in/out) and
 * the sizes of FBBitMap and FBInfo structures.
 */

typedef struct _fbinfo_
{
    int	    type;				/* from list below */
    int	    subtypes;				/* # possible subtypes */
    int	    subtype;				/* current subtype */
    int	    bitmaps;				/* # bitmaps for subtype */
/*
#define FB_MAXBITMAPS	((127-4*sizeof(int))/sizeof(FBBitMap))
*/
#define FB_MAXBITMAPS	4			/* layout-sensitive! */
    FBBitMap  bitmap[FB_MAXBITMAPS];
} FBInfo, *FBInfoRef;


/* Possible frame buffer device types */

#define FB_DISPLAY_SCREEN	0		/* video frame buffer */
#define FB_LASER_PRINTER	1		/* lbp (not mappable!) */
#define FB__TYPE_COUNT		2		/* how many types so far */

/* Ioctl call commands */

#define FBIOGCURINFO	_IOR('F', 0, FBInfo)	/* get full info on current state */
#define FBIOGINFO	_IOWR('F', 1, FBInfo)	/* get info on specified subtype */
#define FBIOSINFO	_IOW('F', 3, FBInfo)	/* set info for (soft) subtype */
#define FBIOGSUBTYPE	_IOR('F', 4, int)	/* get current subtype */
#define FBIOSSUBTYPE	_IOW('F', 2, int)	/* set current subtype */

/*
 * Frame buffer blanking control ("screen saver").  This applies to
 * FB_DISPLAY_SCREEN type devices (obviously!).  The timeout value defines
 * the interval between user activity and automatic blanking of the screen.
 * The lull value is the present recorded interval: note that the command
 * FBIOSETBLANKLULL allows this to be written, with potentially useful
 * consequences.
 */
#define FBIOGETBLANKTIMEOUT	_IOR('F', 5, int) /* read current blank timeout */
#define FBIOSETBLANKTIMEOUT	_IOW('F', 6, int) /* write blank timeout */
#define FBIOGETBLANKLULL	_IOW('F', 7, int) /* read current lull time */
#define FBIOSETBLANKLULL	_IOW('F', 8, int) /* write current lull time */

#define FBBLANK_INFINITY	(-1)
#define FBBLANK_MAXTIME		0x7FFFFFFF	/* for timeout or lull */

#endif/*__dev_fbioctl_h*/

/* EOF fbioctl.h */
