xref: /csrg-svn/share/man/man4/man4.hp300/grf.4 (revision 50731)
147672Scael.\" Copyright (c) 1990, 1991 The Regents of the University of California.
244677Sbostic.\" All rights reserved.
344677Sbostic.\"
444677Sbostic.\" This code is derived from software contributed to Berkeley by
544677Sbostic.\" the Systems Programming Group of the University of Utah Computer
644677Sbostic.\" Science Department.
744677Sbostic.\" %sccs.include.redist.man%
844677Sbostic.\"
9*50731Scael.\"     @(#)grf.4	5.3 (Berkeley) 07/31/91
1044677Sbostic.\"
1147672Scael.Dd
1247672Scael.Dt GRF 4 hp300
1347672Scael.Os
1447672Scael.Sh NAME
1547672Scael.Nm grf
1647672Scael.Nd
1747672Scael.Tn HP
1847672Scaelgraphics frame buffer device interface
1947672Scael.Sh DESCRIPTION
2044677SbosticThis is a generic description of the frame buffer device interface.
2144677SbosticThe devices to which this applies are the 98544, 98545 and 98547
2247672ScaelTopcat display cards (also known as
2347672Scael.Tn HP300H
2447672Scaeldevices),
2544677Sbosticthe 98548, 98549 and 98550
2644677SbosticCatseye display cards,
2744677Sbosticthe 98700
2844677SbosticGatorbox graphics box,
2944677Sbosticthe 98720
3044677SbosticRenaissance graphics box,
3144677Sbosticand the 98730
3244677SbosticDaVinci graphics box.
3347672Scael.Pp
3444677SbosticUse of the devices can be effectively approached from two directions.
3547672ScaelThe first is through
3647672Scael.Tn HP-UX
3747672Scael.Em Starbase
3847672Scaelroutines, the second is by direct control in the
3947672Scael.Bx
4047672Scaelenvironment.
4144677SbosticIn order to use the Starbase libraries,
4247672Scaelcode must be compiled in an
4347672Scael.Tn HP-UX
4447672Scaelenvironment, either by doing so on an
4547672Scael.Tn HP-UX
4647672Scaelmachine and transferring the binaries to the
4747672Scael.Bx
4847672Scaelmachine, or by compilation
4944677Sbosticwith the use of the
5047672Scael.Xr hpux 1
5144677Sbosticcommand.
5244677SbosticApplications using Starbase libraries have been run successfully
5347672Scaelon
5447672Scael.Bx
5547672Scaelmachines using both of these compilation techniques.
5647672Scael.Pp
5744677SbosticDirect compilation,
5844677Sbosticsuch as that used for the X Window System servers, has also been successful.
5944677SbosticExamples of some frame buffer operations can be found in
6044677Sbosticthe device dependent X Window system sources, for example the
6147672Scael.Pa /usr/src/new/X/libhp.fb
6244677Sbosticdirectory.  These files contain examples of device dependent color map
6344677Sbosticinitialization, frame buffer operations, bit moving routines etc.
6447672Scael.Pp
6544677SbosticThe basic programming of the
66*50731Scael.Nm grf Ns ?
6744677Sbosticdevices involves opening the device
6844677Sbosticfile, mapping the control registers and frame buffer addresses into user
6944677Sbosticspace, and then manipulating the device as the application requires.
7044677SbosticThe address mapping is controlled by an
7147672Scael.Xr ioctl 2
7244677Sbosticcall to map the device into user space, and an unmap call when finished.
7347672ScaelThe ioctls supported by
7447672Scael.Bx
7547672Scaelare:
7647672Scael.Bl -tag -width indent
7747672Scael.It Dv GRFIOCGINFO
7844677SbosticGet Graphics Info
7947672Scael.Pp
8044677SbosticGet info about device, setting the entries in the
8147672Scael.Em grfinfo
8244677Sbosticstructure, as defined in <hpdev/grfioctl.h>:
8347672Scael.Bd -literal
8444677Sbosticstruct	grfinfo {
8547672Scael	int	gd_id;		/* HPUX identifier */
8647672Scael	caddr_t	gd_regaddr;	/* control registers physaddr */
8747672Scael	int	gd_regsize;	/* control registers size */
8847672Scael	caddr_t	gd_fbaddr;	/* frame buffer physaddr */
8947672Scael	int	gd_fbsize;	/* frame buffer size */
9047672Scael	short	gd_colors;	/* number of colors */
9147672Scael	short	gd_planes;	/* number of planes */
9244677Sbostic/* new stuff */
9347672Scael	int	gd_fbwidth;	/* frame buffer width */
9447672Scael	int	gd_fbheight;	/* frame buffer height */
9547672Scael	int	gd_dwidth;	/* displayed part width */
9647672Scael	int	gd_dheight;	/* displayed part height */
9747672Scael	int	gd_pad[6];	/* for future expansion */
9844677Sbostic};
9947672Scael.Ed
10047672Scael.It Dv GRFIOCON
10144677SbosticGraphics On
10247672Scael.Pp
10347672ScaelTurn graphics on by enabling
10447672Scael.Tn CRT
10547672Scaeloutput.  The screen will come on, displaying
10644677Sbosticwhatever is in the frame buffer, using whatever colormap is in place.
10747672Scael.It Dv GRFIOCOFF
10844677SbosticGraphics Off
10947672Scael.Pp
11047672ScaelTurn graphics off by disabling output to the
11147672Scael.Tn CRT .
11247672ScaelThe frame buffer contents
11344677Sbosticare not affected.
11447672Scael.It Dv GRFIOCMAP
11544677SbosticMap Device to user space
11647672Scael.Pp
11744677SbosticMap in control registers and framebuffer space. Once the device file is
11844677Sbosticmapped, the frame buffer structure is accessible.
11947672Scael.It Dv GRFIOCUNMAP
12044677SbosticUnmap Device
12147672Scael.Pp
12244677SbosticUnmap control registers and framebuffer space.
12347672Scael.El
12447672Scael.Pp
12544677SbosticFor further information about the use of ioctl see the man page.
12647672Scael.Sh EXAMPLE
12744677SbosticThis short code fragment is an example of opening some graphics device and
12844677Sbosticmapping in the control and frame buffer space:
12947672Scael.Bd -literal
13044677Sbostic#define GRF_DEV <some_graphics_device>  /* /dev/grfN */
13144677Sbostic{
13247672Scael	struct fbstruct *regs;  /*  fbstruct = gboxfb, rboxfb, etc. */
13347672Scael	u_char *Addr, frame_buffer;
13447672Scael	struct grfinfo gi;
13547672Scael	int disp_fd;
13644677Sbostic
13747672Scael	disp_fd = open(GRF_DEV,1);
13847672Scael	if (ioctl (disp_fd, GRFIOCGINFO, &gi) < 0) return -1;
13947672Scael	(void) ioctl (disp_fd, GRFIOCON, 0);
14044677Sbostic
14147672Scael	Addr = (u_char *) 0;
14247672Scael	if (ioctl (disp_fd, GRFIOCMAP, &Addr) < 0) {
14347672Scael		(void) ioctl (disp_fd, GRFIOCOFF, 0);
14447672Scael		return -1;
14547672Scael	}
14647672Scael	regs = (fbstruct *) Addr;               /* Control Registers   */
14747672Scael	frame_buffer = (u_char *) Addr + gi.gd_regsize; /* Frame buffer mem */
14844677Sbostic}
14947672Scael.Ed
15047672Scael.Sh FILES
15147672Scael.Bl -tag -width /dev/*crt*? -compact
15247672Scael.It Pa /dev/grf?
15347672Scael.Bx
15447672Scaelinterface special files
15547672Scael.It Pa /dev/*crt*
15647672Scael.Tn HP-UX
15747672Scael.Em starbase
15847672Scaelinterface special files
15947672Scael.El
16047672Scael.Sh DIAGNOSTICS
16147672ScaelNone under
16247672Scael.Bx .
16347672Scael.Tn HP-UX
16447672ScaelThe
16547672Scael.Tn CE.utilities/Crtadjust
16647672Scaelprograms must be used for each specific device.
16747672Scael.Sh ERRORS
16847672Scael.Bl -tag -width [EINVAL]
16947672Scael.It Bq Er ENODEV
17044677Sbosticno such device.
17147672Scael.It Bq Er EBUSY
17244677SbosticAnother process has the device open.
17347672Scael.It Bq Er EINVAL
17444677SbosticInvalid ioctl specification.
17547672Scael.El
17647672Scael.Sh SEE ALSO
17747672Scael.Xr ioctl 2 ,
17847672Scael.Xr dv 4 ,
17947672Scael.Xr gb 4 ,
18047672Scael.Xr rb 4 ,
18147672Scael.Xr tc 4 ,
18247672Scael.Xr hil 4
18347672Scael.Sh HISTORY
18447672ScaelThe
18547672Scael.Nm
18647672Scaeldriver
18747672Scael.Ud
188