xref: /openbsd/share/man/man9/rasops.9 (revision 274d7c50)
1.\"	$OpenBSD: rasops.9,v 1.18 2017/08/21 11:49:50 fcambus 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: August 21 2017 $
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.In dev/wscons/wsdisplayvar.h
41.In dev/rasops/rasops.h
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 4 .
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	struct wsdisplay_charcell *ri_bs; /* character backing store */
76	int	ri_crow;	/* cursor row */
77	int	ri_ccol;	/* cursor column */
78	int	ri_flg;		/* various operational flags */
79
80	/*
81	 * These are optional and will default if zero. Meaningless
82	 * on depths other than 15, 16, 24 and 32 bits per pel. On
83	 * 24 bit displays, ri_{r,g,b}num must be 8.
84	 */
85	u_char	ri_rnum;	/* number of bits for red */
86	u_char	ri_gnum;	/* number of bits for green */
87	u_char	ri_bnum;	/* number of bits for blue */
88	u_char	ri_rpos;	/* which bit red starts at */
89	u_char	ri_gpos;	/* which bit green starts at */
90	u_char	ri_bpos;	/* which bit blue starts at */
91
92	/*
93	 * These are filled in by rasops_init()
94	 */
95	int	ri_emuwidth;	/* width we actually care about */
96	int	ri_emuheight;	/* height we actually care about */
97	int	ri_emustride;	/* bytes per row we actually care about */
98	int	ri_rows;	/* number of rows (characters) */
99	int	ri_cols;	/* number of columns (characters) */
100	int	ri_delta;	/* row delta in bytes */
101	int	ri_pelbytes;	/* bytes per pel (may be zero) */
102	int	ri_fontscale;	/* fontheight * fontstride */
103	int	ri_xscale;	/* fontwidth * pelbytes */
104	int	ri_yscale;	/* fontheight * stride */
105	u_char  *ri_origbits;	/* where screen bits actually start */
106	int	ri_xorigin;	/* where ri_bits begins (x) */
107	int	ri_yorigin;	/* where ri_bits begins (y) */
108	int32_t	ri_devcmap[16]; /* color -\*[Gt] framebuffer data */
109
110	/*
111	 * The emulops you need to use, and the screen caps for wscons
112	 */
113	struct	wsdisplay_emulops ri_ops;
114	int	ri_caps;
115
116	/*
117	 * Callbacks so we can share some code
118	 */
119	void	(*ri_do_cursor)(struct rasops_info *);
120	void	(*ri_updatecursor)(struct rasops_info *);
121
122#if NRASOPS_ROTATION > 0
123	/* Used to intercept putchar to permit display rotation */
124	struct	wsdisplay_emulops ri_real_ops;
125#endif
126};
127.Ed
128.Pp
129The value of the
130.Em ri_flg
131member is formed by OR'ing the following values:
132.Pp
133.Bl -tag -offset indent -width RI_CLEARMARGINS -compact
134.It RI_FULLCLEAR
135Force eraserows() to clear the whole screen instead of only text lines,
136when invoked with an
137.Em nrows
138parameter equal to the number of text lines.
139.It RI_FORCEMONO
140Do not output coloured text, even if the display supports it.
141.It RI_BSWAP
142Specifies that the frame buffer endianness is different from the CPU's.
143.It RI_CURSOR
144Set when the text cursor is enabled.
145.It RI_CLEAR
146Clear the display upon initialization.
147.It RI_CLEARMARGINS
148Clear display margins upon initialization.
149.It RI_CENTER
150Center the text area.
151.\" Only honoured if option RASOPS_CLIPPING which we don't use.
152.\" .It RI_CURSORCLIP
153.\" Cursor is currently clipped
154.It RI_ROTATE_CW
155Rotate the text display quarter clockwise.
156.It RI_ROTATE_CCW
157Rotate the text display quarter counter-clockwise.
158.It RI_CFGDONE
159.Fn rasops_reconfig
160completed successfully
161.It RI_VCONS
162Support the use of multiple screens.
163.It RI_WRONLY
164Do not read back pixels from the frame buffer memory when performing
165screen-to-screen copy operations.
166This flag is ignored unless
167.Dv RI_VCONS
168is set or the
169.Em ri_bs
170member is set.
171.El
172.Sh FUNCTIONS
173.Bl -tag -width compact
174.It Fn rasops_init "ri" "wantrows" "wantcols"
175Initialise a
176.Em rasops_info
177descriptor.
178The arguments
179.Fa wantrows
180and
181.Fa wantcols
182are the number of rows and columns we'd like.
183In terms of
184optimization, fonts that are a multiple of 8 pixels wide work the
185best.
186.It Fn rasops_reconfig "ri" "wantrows" "wantcols"
187Reconfigure a
188.Em rasops_info
189descriptor because parameters have changed in some way.
190The arguments
191.Fa wantrows
192and
193.Fa wantcols
194are the number of rows and columns we'd like.
195If calling
196.Fn rasops_reconfig
197to change the font and ri_wsfcookie \*[Ge] 0, you must call
198.Fn wsfont_unlock
199on it, and reset it to -1 (or a new, valid cookie).
200.El
201.Sh CODE REFERENCES
202This section describes places within the
203.Ox
204source tree where actual code implementing or utilising the rasops
205subsystem can be found.
206All pathnames are relative to
207.Pa /usr/src .
208.Pp
209The rasops subsystem is implemented within the directory
210.Pa sys/dev/rasops .
211The
212.Nm
213module itself is implemented within the file
214.Pa sys/dev/rasops/rasops.c .
215.Sh SEE ALSO
216.Xr intro 9
217.\" XXX These don't exist yet
218.\" .Xr wscons 9 ,
219.\" .Xr wsdisplay 9 ,
220.\" .Xr wsfont 9
221.Sh HISTORY
222The
223.Nm
224subsystem appeared in
225.Nx 1.5
226and
227.Ox
228first support appeared in
229.Ox 2.9 .
230.Sh AUTHORS
231.An -nosplit
232The
233.Nm
234subsystem was written by
235.An Andrew Doran Aq Mt ad@NetBSD.org .
236Display rotation was written by
237.An Christopher Pascoe Aq Mt pascoe@openbsd.org .
238.Sh CAVEATS
239Display rotation only works for 16bpp displays.
240