1*47672Scael.\" 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*47672Scael.\" @(#)grf.4 5.2 (Berkeley) 03/27/91 1044677Sbostic.\" 11*47672Scael.Dd 12*47672Scael.Dt GRF 4 hp300 13*47672Scael.Os 14*47672Scael.Sh NAME 15*47672Scael.Nm grf 16*47672Scael.Nd 17*47672Scael.Tn HP 18*47672Scaelgraphics frame buffer device interface 19*47672Scael.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 22*47672ScaelTopcat display cards (also known as 23*47672Scael.Tn HP300H 24*47672Scaeldevices), 2544677Sbosticthe 98548, 98549 and 98550 2644677SbosticCatseye display cards, 2744677Sbosticthe 98700 2844677SbosticGatorbox graphics box, 2944677Sbosticthe 98720 3044677SbosticRenaissance graphics box, 3144677Sbosticand the 98730 3244677SbosticDaVinci graphics box. 33*47672Scael.Pp 3444677SbosticUse of the devices can be effectively approached from two directions. 35*47672ScaelThe first is through 36*47672Scael.Tn HP-UX 37*47672Scael.Em Starbase 38*47672Scaelroutines, the second is by direct control in the 39*47672Scael.Bx 40*47672Scaelenvironment. 4144677SbosticIn order to use the Starbase libraries, 42*47672Scaelcode must be compiled in an 43*47672Scael.Tn HP-UX 44*47672Scaelenvironment, either by doing so on an 45*47672Scael.Tn HP-UX 46*47672Scaelmachine and transferring the binaries to the 47*47672Scael.Bx 48*47672Scaelmachine, or by compilation 4944677Sbosticwith the use of the 50*47672Scael.Xr hpux 1 5144677Sbosticcommand. 5244677SbosticApplications using Starbase libraries have been run successfully 53*47672Scaelon 54*47672Scael.Bx 55*47672Scaelmachines using both of these compilation techniques. 56*47672Scael.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 61*47672Scael.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. 64*47672Scael.Pp 6544677SbosticThe basic programming of the 66*47672Scael.Nm grf Ns Em \? 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 71*47672Scael.Xr ioctl 2 7244677Sbosticcall to map the device into user space, and an unmap call when finished. 73*47672ScaelThe ioctls supported by 74*47672Scael.Bx 75*47672Scaelare: 76*47672Scael.Bl -tag -width indent 77*47672Scael.It Dv GRFIOCGINFO 7844677SbosticGet Graphics Info 79*47672Scael.Pp 8044677SbosticGet info about device, setting the entries in the 81*47672Scael.Em grfinfo 8244677Sbosticstructure, as defined in <hpdev/grfioctl.h>: 83*47672Scael.Bd -literal 8444677Sbosticstruct grfinfo { 85*47672Scael int gd_id; /* HPUX identifier */ 86*47672Scael caddr_t gd_regaddr; /* control registers physaddr */ 87*47672Scael int gd_regsize; /* control registers size */ 88*47672Scael caddr_t gd_fbaddr; /* frame buffer physaddr */ 89*47672Scael int gd_fbsize; /* frame buffer size */ 90*47672Scael short gd_colors; /* number of colors */ 91*47672Scael short gd_planes; /* number of planes */ 9244677Sbostic/* new stuff */ 93*47672Scael int gd_fbwidth; /* frame buffer width */ 94*47672Scael int gd_fbheight; /* frame buffer height */ 95*47672Scael int gd_dwidth; /* displayed part width */ 96*47672Scael int gd_dheight; /* displayed part height */ 97*47672Scael int gd_pad[6]; /* for future expansion */ 9844677Sbostic}; 99*47672Scael.Ed 100*47672Scael.It Dv GRFIOCON 10144677SbosticGraphics On 102*47672Scael.Pp 103*47672ScaelTurn graphics on by enabling 104*47672Scael.Tn CRT 105*47672Scaeloutput. The screen will come on, displaying 10644677Sbosticwhatever is in the frame buffer, using whatever colormap is in place. 107*47672Scael.It Dv GRFIOCOFF 10844677SbosticGraphics Off 109*47672Scael.Pp 110*47672ScaelTurn graphics off by disabling output to the 111*47672Scael.Tn CRT . 112*47672ScaelThe frame buffer contents 11344677Sbosticare not affected. 114*47672Scael.It Dv GRFIOCMAP 11544677SbosticMap Device to user space 116*47672Scael.Pp 11744677SbosticMap in control registers and framebuffer space. Once the device file is 11844677Sbosticmapped, the frame buffer structure is accessible. 119*47672Scael.It Dv GRFIOCUNMAP 12044677SbosticUnmap Device 121*47672Scael.Pp 12244677SbosticUnmap control registers and framebuffer space. 123*47672Scael.El 124*47672Scael.Pp 12544677SbosticFor further information about the use of ioctl see the man page. 126*47672Scael.Sh EXAMPLE 12744677SbosticThis short code fragment is an example of opening some graphics device and 12844677Sbosticmapping in the control and frame buffer space: 129*47672Scael.Bd -literal 13044677Sbostic#define GRF_DEV <some_graphics_device> /* /dev/grfN */ 13144677Sbostic{ 132*47672Scael struct fbstruct *regs; /* fbstruct = gboxfb, rboxfb, etc. */ 133*47672Scael u_char *Addr, frame_buffer; 134*47672Scael struct grfinfo gi; 135*47672Scael int disp_fd; 13644677Sbostic 137*47672Scael disp_fd = open(GRF_DEV,1); 138*47672Scael if (ioctl (disp_fd, GRFIOCGINFO, &gi) < 0) return -1; 139*47672Scael (void) ioctl (disp_fd, GRFIOCON, 0); 14044677Sbostic 141*47672Scael Addr = (u_char *) 0; 142*47672Scael if (ioctl (disp_fd, GRFIOCMAP, &Addr) < 0) { 143*47672Scael (void) ioctl (disp_fd, GRFIOCOFF, 0); 144*47672Scael return -1; 145*47672Scael } 146*47672Scael regs = (fbstruct *) Addr; /* Control Registers */ 147*47672Scael frame_buffer = (u_char *) Addr + gi.gd_regsize; /* Frame buffer mem */ 14844677Sbostic} 149*47672Scael.Ed 150*47672Scael.Sh FILES 151*47672Scael.Bl -tag -width /dev/*crt*? -compact 152*47672Scael.It Pa /dev/grf? 153*47672Scael.Bx 154*47672Scaelinterface special files 155*47672Scael.It Pa /dev/*crt* 156*47672Scael.Tn HP-UX 157*47672Scael.Em starbase 158*47672Scaelinterface special files 159*47672Scael.El 160*47672Scael.Sh DIAGNOSTICS 161*47672ScaelNone under 162*47672Scael.Bx . 163*47672Scael.Tn HP-UX 164*47672ScaelThe 165*47672Scael.Tn CE.utilities/Crtadjust 166*47672Scaelprograms must be used for each specific device. 167*47672Scael.Sh ERRORS 168*47672Scael.Bl -tag -width [EINVAL] 169*47672Scael.It Bq Er ENODEV 17044677Sbosticno such device. 171*47672Scael.It Bq Er EBUSY 17244677SbosticAnother process has the device open. 173*47672Scael.It Bq Er EINVAL 17444677SbosticInvalid ioctl specification. 175*47672Scael.El 176*47672Scael.Sh SEE ALSO 177*47672Scael.Xr ioctl 2 , 178*47672Scael.Xr dv 4 , 179*47672Scael.Xr gb 4 , 180*47672Scael.Xr rb 4 , 181*47672Scael.Xr tc 4 , 182*47672Scael.Xr hil 4 183*47672Scael.Sh HISTORY 184*47672ScaelThe 185*47672Scael.Nm 186*47672Scaeldriver 187*47672Scael.Ud 188