fb(7) DEVICES AND MODULES fb(7)
NAME
fb - NEWS frame buffer device interface
SYNOPSIS
/dev/fb
#include <io/iosingle/optdrivers/framebuf.h>
DESCRIPTION
The fb interface provides access to the NEWS frame buffer
device. The black and white bitmap display has a 2048x2048
pixel frame buffer, of which 816x1024 are displayed. In the
case of the color bitmap display, the frame buffer is
2048x1024 pixels, 1280x1024 of which are displayed. This
frame buffer interface enables reading and writing of data,
raster operations, drawing lines, etc.
The operations are carried out using the ioctl(2) system
call. The ioctl call provides for operations on user-defined
(user-space) bitmaps, as well as frame buffer operations.
COLOR
The color bitmap display's frame buffer consists of 4 (or 8)
planes, so that 16 (or 256) colors can be displayed simul-
taneously. The 3 values for red, green and blue are made up
of 4 (or 8) bits each, so that the user may choose from 4096
(or 16 million) colors in the color palette.
DATA TYPES
The following data structures are used for bitmap opera-
tions.
typedef unsigned short Word;
#define BitsPerWord 16
typedef struct {
short x, y;
} sPoint;
typedef struct {
sPoint origin;
sPoint extent;
} sRectangle;
typedef struct {
char type; /* BM_FB, BM_MEM or BM_0 */
char depth; /* bitmap depth */
unsigned short width; /* width in Words */
sRectangle rect; /* defined area */
Word *base; /* for BM_MEM */
} sBitmap;
Sony NEWS Distribution 1
fb(7) DEVICES AND MODULES fb(7)
#define BM_FB 0 /* frame buffer */
#define BM_MEM 1 /* bitmap in memory (XY format) */
#define BM_0 2 /* virtual bitmap of data '0' */
Word is defined as an unsigned 16-bit (1 word) quantity.
The sPoint structure is used for points.
The sRectangle structure is used for upright rectangles,
where origin is the upper-left corner, and extent indicates
the width and height of the rectangle.
The sBitmap structure is used to define bitmaps. The type
field indicates whether the bitmap is in main memory or in
the frame buffer. BMFB is for bitmaps in the frame buffer,
while BMMEM is for bitmaps in main memory. BM_MEM bitmaps
are stored in the XY format, which means that the data for
plane 0 follows that for plane 1, and so on. BM0 is for
virtual bitmaps whose data is all 0. BM_0 bitmap can be
used only as a source bitmap at raster operation. The depth
field gives the depth of the bitmap. A black and white frame
buffer bitmap has a depth of 1, while a color frame buffer
bitmap can have a depth of 4 or 8 planes. A bitmap in main
memory or a BM_0 bitmap can have a depth of 1, 4 or 8,
whether or not a color display is used.
The width of a BM_MEM bitmap gives the number of words in
the X direction. The width does not have to be specified for
BM_FB and BM_0 bitmaps.
The rect field gives the size of the bitmap. It is only pos-
sible to carry out operations within this area.
The base field points at the start of the data.
In the case of a BM_MEM bitmap, the data has to be aligned
at a word boundary. The first bit of the first word of the
first row corresponds to the point rect.origin. This means
that a bitmap with a depth of 1 requires (width *
rect.extent.y) words, where width is just large enough to
contain rect.extent.x bits.
IOCTL
FBIOCSETDIM
FBIOCGETDIM
These requests allow the user to set or inquire the
brightness of a black and white display. The dimmer
level varies from 0 to 3, where 0 is the brightest
and the default. These requests are not supported
for color displays.
Sony NEWS Distribution 2
fb(7) DEVICES AND MODULES fb(7)
int dimmer_level;
ioctl(fildes, FBIOCSETDIM, &dimmer_level);
ioctl(fildes, FBIOCGETDIM, &dimmer_level);
FBIOCSETSCRMODE
FBIOCGETSCRMODE
The user issues these requests to set or inquire the
screen mode, which can be BLACK_ON_WHITE (default),
or WHITE_ON_BLACK. In the BLACK_ON_WHITE mode, 1 is
black and 0 is white, while the opposite is true in
the WHITE_ON_BLACK case. These requests are not
supported at this time.
/*
* set screen mode
*/
#define BLACK_ON_WHITE 0 /* white - 0, black - 1 (default) */
#define WHITE_ON_BLACK 1 /* white - 1, black - 0 */
int scrmode;
ioctl(fildes, FBIOCSETSCRMODE, &scrmode);
ioctl(fildes, FBIOCGETSCRMODE, &scrmode);
FBIOCBITBLT
This request is for two-operand raster operations
(bitblt). The source and destination bitmaps may be
in main memory or in the frame buffer. BM_0 bitmap
can be used only as a source. The depths of the
source and destination bitmaps must be equal or the
depth of one of the bitmaps must be 1.
/* 2 operand bitblt */
typedef struct {
unsigned char func; /* function code */
char transp; /* transparency */
int fore_color; /* foreground color */
int aux_color; /* auxiliary color */
int planemask; /* select plane */
sBitmap srcBitmap; /* source bitmap */
sRectangle srcRect; /* source rectangle */
sBitmap destBitmap; /* destination bitmap */
sRectangle destClip; /* clip rectangle */
sPoint destPoint; /* destination point */
} sBitblt;
/* func */
#define BF_0 0x0 /* 0 */
#define BF_SDA 0x1 /* Src & Dest */
Sony NEWS Distribution 3
fb(7) DEVICES AND MODULES fb(7)
#define BF_SDIA 0x2 /* Src & ~Dest */
#define BF_S 0x3 /* Src */
#define BF_SIDA 0x4 /* ~Src & Dest */
#define BF_D 0x5 /* Dest */
#define BF_SDX 0x6 /* Src ^ Dest */
#define BF_SDO 0x7 /* Src | Dest */
#define BF_SDOI 0x8 /* ~(Src | Dest) */
#define BF_SDXI 0x9 /* ~(Src ^ Dest) */
#define BF_DI 0xa /* ~Dest */
#define BF_SDIO 0xb /* Src | ~Dest */
#define BF_SI 0xc /* ~Src */
#define BF_SIDO 0xd /* ~Src | Dest */
#define BF_SDAI 0xe /* ~(Src & Dest) */
#define BF_1 0xf /* 1 */
/* Plane Mask */
#define FB_PLANEALL 0xff
#define FB_PLANE0 0x1
#define FB_PLANE1 0x2
#define FB_PLANE2 0x4
#define FB_PLANE3 0x8
#define FB_PLANE4 0x10
#define FB_PLANE5 0x20
#define FB_PLANE6 0x40
#define FB_PLANE7 0x80
The sBitblt structure is used for the parameters. The func
field indicates the function code of the raster operation.
The transp field is the transparency, and can be 0 or 1. If
it is 1, then the destination pixels corresponding to source
pixels that are 0 will not be affected.
The forecolor and auxcolor fields are meaningless unless
the depth of the source bitmap is 1. Source bits that have
the value 1 are taken to be (the bit pattern corresponding
to) the fore-color before performing the operation together
with the corresponding destination pixel. On the other hand,
the bitblt pretends that 0 source bits are the aux-color
while performing the function. For example, if the func is
BF_S (copy source to destination) then the pixels
corresponding to source bits that have the value 1 are
displayed in the fore-color, while the other pixels appear
in the aux-color.
The planemask field specifies which planes to use during the
operation. A 1 in the planemask tells the bitblt to involve
the corresponding plane in the operation, whereas a 0 would
indicate that that plane is to be ignored. Bit N corresponds
to plane N.
The fields srcBitmap and srcRect indicate which source bit-
map is to be used in the operation.
Sony NEWS Distribution 4
fb(7) DEVICES AND MODULES fb(7)
The fields destBitmap and destPoint specify the destination
bitmap. The destPoint is the upper-left corner, and the size
of the rectangle in which raster operations will occur is
the same as the srcRect. The field destClip is used to
specify which part of the destination is to be clipped.
sBitblt bitblt;
ioctl(fildes, FBIOCBITBLT, &bitblt);
FBIOCBATCHBITBLT
This request is used to carry out a number of bitblt
operations in one go (in a batch). The source and
destination bitmaps are the same for each operation
but the source rectangle and the destination point
may be different each time.
typedef struct {
sRectangle srcRect; /* source rectangle */
sPoint destPoint; /* destination point */
} sSrcDest;
/*
* batch bitblt
*/
typedef struct {
unsigned char func; /* function code */
char transp; /* transparency */
int fore_color; /* foreground color */
int aux_color; /* auxiliary color */
int planemask; /* select plane */
sBitmap srcBitmap; /* source bitmap */
sBitmap destBitmap; /* destination bitmap */
sRectangle destClip; /* clip rectangle */
int nSrcDest; /* number of src-dest in list */
sSrcDest *srcDestList; /* pointer to src-dest spec */
} sBatchBitblt;
#define MAX_BATCHBITBLT 1024 /* max number in src-dest list */
The sBatchBitblt structure contains source and destination
bitmaps similar to the ones in the sBitblt structure. The
srcDestList field points at a list of source rectangles and
destination points, the number of elements being given by
the nSrcDest field.
sBatchBitblt bbitblt;
ioctl(fildes, FBIOCBATCHBITBLT, &bbitblt);
Sony NEWS Distribution 5
fb(7) DEVICES AND MODULES fb(7)
FBIOCTILEBITBLT
This request is used for `pattern tiling' raster
operations.
/* tile 2 operand bitblt */
typedef struct {
unsigned char func; /* function code */
char transp; /* transparency */
int fore_color; /* foreground color */
int aux_color; /* auxiliary color */
int planemask; /* select plane */
sBitmap ptnBitmap; /* pattern bitmap */
sRectangle ptnRect; /* pattern rectangle */
sPoint refPoint; /* reference point */
sBitmap destBitmap; /* destination bitmap */
sRectangle destClip; /* clip rectangle */
sRectangle destRect; /* destination rectangle */
} sTileBitblt;
The sTileBitblt structure is used to pass the parameters.
The ptnBitmap and ptnRect fields specify the pattern to be
used. The refPoint field indicates the reference point for
the tiling operation. This means that the reference point
and the upper-left corner of the pattern are made to coin-
cide on the destination bitmap. The reference point may be
outside the destination rectangle or destination clip rec-
tangle.
sTileBitblt tbitblt;
ioctl(fildes, FBIOCTILEBITBLT, &tbitblt);
FBIOCPOLYLINE
This requests allows the user to draw polylines. The
user is free to specify any line color, line pattern
and raster operation function code.
/* line */
typedef struct {
unsigned int lptn; /* line pattern */
short np; /* number of points */
sPoint *plist; /* point list */
int fore_color; /* foreground color */
int aux_color; /* auxiliary color */
int planemask; /* select plane */
char transp; /* transparency */
unsigned char func; /* rop function code */
char dlpf; /* draw last point flag */
sRectangle clip; /* clip rectangle */
sBitmap drawBM; /* drawing bitmap */
} sPrimLine;
Sony NEWS Distribution 6
fb(7) DEVICES AND MODULES fb(7)
/* Line Pattern (sample) */
#define LINE_SLD (unsigned)0xffffffff /* solid */
#define LINE_DSH (unsigned)0xfcfcfcfc /* dash */
#define LINE_DOT (unsigned)0xcccccccc /* dot */
#define LINE_DSHDOT (unsigned)0xfff18fff /* dash dot */
#define LINE_DSHDOTDOT (unsigned)0xff8c63ff /* dash dot dot */
The sPrimLine structure is used for the polyline request. A
32-bit line pattern can be specified using the lptn field.
The plist field is used to pass np points in the call. Note
that np is the number of points and not the number of lines.
For an explanation of the forecolor, auxcolor, planemask,
transp and func fields, see FBIOCBITBLT. The dlpf flag indi-
cates whether or not to draw the last point in the list; if
it is 0 the point is not drawn, otherwise it is drawn. A 0
in this field would probably be used if a closed figure is
to be drawn. The drawBM and clip fields are used to specify
the drawing bitmap and the clip rectangle respectively.
sPrimline primline;
ioctl(fildes, FBIOCPOLYLINE, &primline);
FBIOCDJPOLYLINE
This request is rather similar to the FBIOCPOLYLINE
request. The latter is used to draw a continuous
line, whereas this one is used to draw a disjoint
line. The dlpf field is used to specify whether or
not the end-points of each line segment are to be
drawn.
sPrimline primline;
ioctl(fildes, FBIOCDJPOLYLINE, &primline);
FBIOCPOLYMARKER
This request draws polymarkers. Actually, this
request allows one to carry out raster operations
between a specified pattern and (several) bitmaps.
/* marker */
typedef struct {
short np; /* number of points */
sPoint *plist; /* point list */
sRectangle ptnRect; /* pattern rectangle */
sBitmap ptnBM; /* pattern bitmap */
int fore_color; /* foreground color */
int aux_color; /* auxiliary color */
int planemask; /* plane mask */
char transp; /* transparency */
unsigned char func; /* rop function code */
Sony NEWS Distribution 7
fb(7) DEVICES AND MODULES fb(7)
sRectangle clip; /* clip rectangle */
sBitmap drawBM; /* drawing bitmap */
} sPrimMarker;
The sPrimMarker structure is used to draw a polymarker. The
ptnBM and ptnRect fields specify which pattern is to used in
the raster operation. The fields plist and np give the point
list and number of points respectively.
sPrimMarker primmarker;
ioctl(fildes, FBIOCPOLYMARKER, &primmarker);
FBIOCRECTANGLE
An upright rectangle is filled with the given pat-
tern.
/* rectangle filling */
typedef struct {
sRectangle rect; /* rectangle */
sPoint refPoint; /* fill reference point */
sRectangle ptnRect; /* pattern rectangle */
sBitmap ptnBM; /* pattern bitmap */
int fore_color; /* foreground color */
int aux_color; /* auxiliary color */
int planemask; /* select plane */
char transp; /* transparency */
unsigned char func; /* rop function code */
sRectangle clip; /* clip rectangle */
sBitmap drawBM; /* drawing bitmap */
} sPrimRect;
For this request, the sPrimRect structure is used. The rect
field specifies the rectangle, while the ptnBM and ptnRect
fields specify which pattern is to be used in the filling.
The refPoint field contains the point which is made to coin-
cide with the upper-left corner of the pattern. It is not
necessary for the refPoint to lie within the rect and clip.
sPrimRect rect;
ioctl(fildes, FBIOCRECTANGLE, &rect);
FBIOCFILLSCAN
Pattern filling is performed along the given scan
lines.
/* scan line array */
#define SSCANL
typedef struct {
Sony NEWS Distribution 8
fb(7) DEVICES AND MODULES fb(7)
short y;
short x0, x1;
} sScanl;
/* pattern filling */
typedef struct {
short nscan; /* number of scan element */
sScanl *scan; /* scan line data */
sPoint refPoint; /* fill reference point */
sRectangle ptnRect; /* pattern rectangle */
sBitmap ptnBM; /* pattern bitmap */
int fore_color; /* foreground color */
int aux_color; /* auxiliary color */
int planemask; /* select plane */
char transp; /* transparency */
unsigned char func; /* rop function code */
sRectangle clip; /* clip rectangle */
sBitmap drawBM; /* drawing bitmap */
} sPrimFill;
The sScanl structure is used for the scan lines, while the
sPrimFill structure is used to pass all the parameters. The
scan field contains a pointer to the array of scan lines,
and the nscan field indicates how many scan lines there are.
The pattern is specified using the ptnBM and ptnRect fields.
Again, the refPoint is the reference point needed to anchor
the upper-left corner of the pattern.
sPrimFill fill;
ioctl(fildes, FBIOCFILLSCAN, &fill);
FBIOCTEXT
A string is written in the specified font. The font
to be used can be a font in a bitmap or a ROM font.
/* text */
typedef struct {
char type; /* ROM-font, etc */
short len; /* string length */
unsigned char *str; /* string */
sPoint p;
int dx, dy; /* vector (16bit left shifted) */
char ex_factor; /* expansion factor */
sPoint fp; /* bitmap font upper-left */
short width, height; /* font width, font height */
short column; /* number of characters in a row */
sBitmap fontBM; /* font bitmap */
int fore_color; /* foreground color */
int aux_color; /* auxiliary color */
char transp; /* transparency */
Sony NEWS Distribution 9
fb(7) DEVICES AND MODULES fb(7)
unsigned char func; /* rop function code */
sRectangle clip; /* clip rectangle */
sBitmap drawBM; /* drawing bitmap */
} sPrimText;
/* Bitmap Font Type */
#define ROM_ASCII 0
#define ROM_KANJI 1
#define ASCII 2
In order to write the text, the sPrimText structure must be
used. The type field indicates which font to use:
ROMASCII ROM font (1 byte code)
ROMKANJI ROM font (JIS Kanji code)
ASCII Bitmap font (1 byte code)
The len field gives the length of the string in bytes. Kanji
users should be aware that this is not the same as the
number of characters. The str field is a pointer to the
string of characters. The p field contains the point
corresponding to the upper-left corner of the first charac-
ter. The dx and dy fields indicate in which direction the
string is to be written. For example, if the characters are
to be written 26 dots to the right of the previous charac-
ters and the string is to be horizontal, then the following
values are used: dx = 26 << 16; dy = 0. The exfactor field
indicates the horizontal expansion factor. For example, if
it is 1 the normal width is used, if it is 2 the width is
doubled. The fp, width, height, and column fields define the
font bitmap. The upper-left corner of the font bitmap is
given by fp, while the width and height of the characters
are given by width and height. (The character size is con-
stant; variable pitch fonts are not supported.) The column
field contains the number of characters in a row. The fields
firstchr and lastchr indicate the first and last charac-
ters that can be found in the font bitmap.
sPrimText text;
ioctl(fildes, FBIOCTEXT, &text);
FBIOCGETSCRTYPE
This request returns the bitmap display type.
/*
* screen type
*/
typedef struct {
short colorwidth; /* color palette width */
short plane; /* number of planes */
sRectangle bufferrect; /* framebuffer region */
sRectangle visiblerect; /* visible screen region */
Sony NEWS Distribution 10
fb(7) DEVICES AND MODULES fb(7)
} sScrType;
The sScrType structure is used to pass the parameters. The
colorwidth field gives the number of bits that are used for
each of the values for red, green and blue in the color
palette. The width is either 4 or 8; if it is 4, the high-
order 4 bits of the byte are used, and if it is 8, all 8
bits are used. The plane field indicates the number of
planes, which is 1 for black and white displays, 4 (or 8)
for color displays. The bufferrect field gives the size of
the frame buffer, and the visiblerect field indicates the
visible portion of the frame buffer.
sScrType scrtype;
ioctl(fildes, FBIOCGETSCRTYPE, &scrtype);
FBIOCGETPALETTE
FBIOCSETPALETTE
These requests enable reading and writing of the
color palette data.
/*
* color
*/
typedef struct {
short index; /* palette number */
struct {
short r, g, b;
} rgb;
} sPalette;
The palette numbers vary from 0 to 15 (4 planes), or 0 to
255 (8 planes). In the case of the FBIOCGETPALETTE request,
the palette number is passed in the field index. The rgb
field will have been written after the call. In the case of
the FBIOCSETPALETTE request, both the index and the rgb
fields are set by the user (rgb = red, green, blue).
sPalette palette;
ioctl(fildes, FBIOCGETPALETTE, &palette);
ioctl(fildes, FBIOCSETPALETTE, &palette);
BUGS
FBIOCSETSCRMODE and FBIOCGETSCRMODE are not supported.
FILES
/dev/fb frame buffer
Sony NEWS Distribution 11
fb(7) DEVICES AND MODULES fb(7)
Sony NEWS Distribution 12