xref: /openbsd-src/share/man/man9/rasops.9 (revision 2b0358df1d88d06ef4139321dd05bd5e05d91eaf)
1.\"	$OpenBSD: rasops.9,v 1.10 2008/06/26 05:42:08 ray Exp $
2.\"     $NetBSD: rasops.9,v 1.4 2002/02/13 08:18:50 ross Exp $
3.\"
4.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
5.\" All rights reserved.
6.\"
7.\" This code is derived from software contributed to The NetBSD Foundation
8.\" by Gregory McGarry.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29.\" POSSIBILITY OF SUCH DAMAGE.
30.\"
31.Dd $Mdocdate: June 26 2008 $
32.Dt RASOPS 9
33.Os
34.Sh NAME
35.Nm rasops ,
36.Nm rasops_init ,
37.Nm rasops_reconfig
38.Nd raster display operations
39.Sh SYNOPSIS
40.Fd #include \*[Lt]dev/wscons/wsdisplayvar.h\*[Gt]
41.Fd #include \*[Lt]dev/rasops/rasops.h\*[Gt]
42.Ft int
43.Fn rasops_init "struct rasops_info *ri" "int wantrows" "int wantcols"
44.Ft int
45.Fn rasops_reconfig "struct rasops_info *ri" "int wantrows" "int wantcols"
46.Sh DESCRIPTION
47The
48.Nm
49subsystem is a set of raster operations for
50.Xr wscons .
51.Pp
52The primary data type for using the raster operations is the
53.Em rasops_info
54structure in
55.Pa dev/rasops/rasops.h :
56.Bd -literal
57struct rasops_info {
58
59	/*
60	 * These must be filled in by the caller
61	 */
62	int	ri_depth;	/* depth in bits */
63	u_char	*ri_bits;	/* ptr to bits */
64	int	ri_width;	/* width (pels) */
65	int	ri_height;	/* height (pels) */
66	int	ri_stride;	/* stride in bytes */
67
68	/*
69	 * These can optionally be left zeroed out. If you fill ri_font,
70	 * but aren't using wsfont, set ri_wsfcookie to -1.
71	 */
72	struct	wsdisplay_font *ri_font;
73	int	ri_wsfcookie;	/* wsfont cookie */
74	void	*ri_hw;		/* driver private data */
75	int	ri_crow;	/* cursor row */
76	int	ri_ccol;	/* cursor column */
77	int	ri_flg;		/* various operational flags */
78
79	/*
80	 * These are optional and will default if zero. Meaningless
81	 * on depths other than 15, 16, 24 and 32 bits per pel. On
82	 * 24 bit displays, ri_{r,g,b}num must be 8.
83	 */
84	u_char	ri_rnum;	/* number of bits for red */
85	u_char	ri_gnum;	/* number of bits for green */
86	u_char	ri_bnum;	/* number of bits for blue */
87	u_char	ri_rpos;	/* which bit red starts at */
88	u_char	ri_gpos;	/* which bit green starts at */
89	u_char	ri_bpos;	/* which bit blue starts at */
90
91	/*
92	 * These are filled in by rasops_init()
93	 */
94	int	ri_emuwidth;	/* width we actually care about */
95	int	ri_emuheight;	/* height we actually care about */
96	int	ri_emustride;	/* bytes per row we actually care about */
97	int	ri_rows;	/* number of rows (characters) */
98	int	ri_cols;	/* number of columns (characters) */
99	int	ri_delta;	/* row delta in bytes */
100	int	ri_pelbytes;	/* bytes per pel (may be zero) */
101	int	ri_fontscale;	/* fontheight * fontstride */
102	int	ri_xscale;	/* fontwidth * pelbytes */
103	int	ri_yscale;	/* fontheight * stride */
104	u_char  *ri_origbits;	/* where screen bits actually start */
105	int	ri_xorigin;	/* where ri_bits begins (x) */
106	int	ri_yorigin;	/* where ri_bits begins (y) */
107	int32_t	ri_devcmap[16]; /* color -\*[Gt] framebuffer data */
108
109	/*
110	 * The emulops you need to use, and the screen caps for wscons
111	 */
112	struct	wsdisplay_emulops ri_ops;
113	int	ri_caps;
114
115	/*
116	 * Callbacks so we can share some code
117	 */
118	void	(*ri_do_cursor)(struct rasops_info *);
119	void	(*ri_updatecursor)(struct rasops_info *);
120
121#if NRASOPS_ROTATION > 0
122	/* Used to intercept putchar to permit display rotation */
123	struct	wsdisplay_emulops ri_real_ops;
124#endif
125};
126.Ed
127.Pp
128The value of the
129.Em ri_flg
130member is formed by OR'ing the following values:
131.Pp
132.Bl -tag -offset indent -width RI_CURSORCLIP -compact
133.It RI_FULLCLEAR
134Force eraserows() to clear the whole screen instead of only text lines,
135when invoked with an
136.Em nrows
137parameter equal to the number of text lines.
138.It RI_FORCEMONO
139Do not output coloured text, even if the display supports it.
140.It RI_BSWAP
141Specifies that the frame buffer endianness is different from the CPU's.
142.It RI_CURSOR
143Set when the text cursor is enabled.
144.It RI_CLEAR
145Clear the display upon initialization.
146.It RI_CENTER
147Center the text area.
148.\" Only honoured if option RASOPS_CLIPPING which we don't use.
149.\" .It RI_CURSORCLIP
150.\" Cursor is currently clipped
151.It RI_ROTATE_CW
152Rotate the text display quarter clockwise.
153.It RI_CFGDONE
154.Fn rasops_reconfig
155completed successfully
156.El
157.Sh FUNCTIONS
158.Bl -tag -width compact
159.It Fn rasops_init "ri" "wantrows" "wantcols"
160Initialise a
161.Em rasops_info
162descriptor.
163The arguments
164.Fa wantrows
165and
166.Fa wantcols
167are the number of rows and columns we'd like.
168In terms of
169optimization, fonts that are a multiple of 8 pixels wide work the
170best.
171.It Fn rasops_reconfig "ri" "wantrows" "wantcols"
172Reconfigure a
173.Em rasops_info
174descriptor because parameters have changed in some way.
175The arguments
176.Fa wantrows
177and
178.Fa wantcols
179are the number of rows and columns we'd like.
180If calling
181.Fn rasops_reconfig
182to change the font and ri_wsfcookie \*[Ge] 0, you must call
183.Fn wsfont_unlock
184on it, and reset it to -1 (or a new, valid cookie).
185.El
186.Sh CODE REFERENCES
187This section describes places within the
188.Ox
189source tree where actual code implementing or utilising the rasops
190subsystem can be found.
191All pathnames are relative to
192.Pa /usr/src .
193.Pp
194The rasops subsystem is implemented within the directory
195.Pa sys/dev/rasops .
196The
197.Nm
198module itself is implemented within the file
199.Pa sys/dev/rasops/rasops.c .
200.Sh SEE ALSO
201.Xr intro 9
202.\" XXX These don't exist yet
203.\" .Xr wscons 9 ,
204.\" .Xr wsdisplay 9 ,
205.\" .Xr wsfont 9
206.Sh HISTORY
207The
208.Nm
209subsystem appeared in
210.Nx 1.5
211and
212.Ox
213first support appeared in
214.Ox 2.9 .
215.Sh AUTHORS
216.An -nosplit
217The
218.Nm
219subsystem was written by
220.An Andrew Doran
221.Aq ad@NetBSD.org .
222Display rotation was written by
223.An Christopher Pascoe
224.Aq pascoe@openbsd.org .
225.Sh CAVEATS
226Display rotation only works for 16bpp displays.
227