Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / wscons / wscons_rops.c
blobe95861bf5b9f901f81745de81796ba614c1d74c6
1 /* $NetBSD: wscons_rops.c,v 1.9.6.3 2004/09/21 13:34:29 skrll Exp $ */
3 /*
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley.
11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement:
13 * This product includes software developed by the University of
14 * California, Lawrence Berkeley Laboratory.
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
40 * @(#)rcons_subr.c 8.1 (Berkeley) 6/11/93
43 #include <sys/cdefs.h>
44 __KERNEL_RCSID(0, "$NetBSD: wscons_rops.c,v 1.9.6.3 2004/09/21 13:34:29 skrll Exp $");
46 #include <sys/param.h>
47 #include <sys/device.h>
49 #include <dev/rcons/raster.h>
50 #include <dev/wscons/wscons_raster.h>
51 #include <dev/wscons/wsdisplayvar.h>
54 * Paint (or unpaint) the cursor.
55 * Pays no lip service to hardware cursors.
57 void
58 rcons_cursor(void *id, int on, int row, int col)
60 struct rcons *rc = id;
61 int x, y;
63 /* turn the cursor off */
64 if (!on) {
65 /* make sure it's on */
66 if ((rc->rc_bits & RC_CURSOR) == 0)
67 return;
69 row = *rc->rc_crowp;
70 col = *rc->rc_ccolp;
71 } else {
72 /* unpaint the old copy. */
73 *rc->rc_crowp = row;
74 *rc->rc_ccolp = col;
77 x = col * rc->rc_font->width + rc->rc_xorigin;
78 y = row * rc->rc_font->height + rc->rc_yorigin;
80 raster_op(rc->rc_sp, x, y,
81 #ifdef notdef
82 /* XXX This is the right way but too slow */
83 rc->rc_font->chars[(int)' '].r->width,
84 rc->rc_font->chars[(int)' '].r->height,
85 #else
86 rc->rc_font->width, rc->rc_font->height,
87 #endif
88 RAS_INVERT,
89 (struct raster *) 0, 0, 0);
91 rc->rc_bits ^= RC_CURSOR;
94 int
95 rcons_mapchar(void *id, int uni, unsigned int *index)
98 if (uni < 128) {
99 *index = uni;
100 return (5);
102 *index = ' ';
103 return (0);
107 * Actually write a string to the frame buffer.
109 void
110 rcons_putchar(void *id, int row, int col, u_int uc, long attr)
112 struct rcons *rc = id;
113 int x, y, op;
114 u_char help;
116 x = col * rc->rc_font->width + rc->rc_xorigin;
117 y = row * rc->rc_font->height + rc->rc_font_ascent + rc->rc_yorigin;
119 op = RAS_SRC;
120 if ((attr != 0) ^ ((rc->rc_bits & RC_INVERT) != 0))
121 op = RAS_NOT(op);
122 help = uc & 0xff;
123 raster_textn(rc->rc_sp, x, y, op, rc->rc_font, &help, 1);
127 * Possibly change to white-on-black or black-on-white modes.
129 void
130 rcons_invert(void *id, int inverted)
132 struct rcons *rc = id;
134 if (((rc->rc_bits & RC_INVERT) != 0) ^ inverted) {
135 /* Invert the display */
136 raster_op(rc->rc_sp, 0, 0, rc->rc_sp->width, rc->rc_sp->height,
137 RAS_INVERT, (struct raster *) 0, 0, 0);
139 /* Swap things around */
140 rc->rc_bits ^= RC_INVERT;
145 * Copy columns (characters) in a row (line).
147 void
148 rcons_copycols(void *id, int row, int srccol, int dstcol, int ncols)
150 struct rcons *rc = id;
151 int y, srcx, dstx, nx;
153 y = rc->rc_yorigin + rc->rc_font->height * row;
154 srcx = rc->rc_xorigin + rc->rc_font->width * srccol;
155 dstx = rc->rc_xorigin + rc->rc_font->width * dstcol;
156 nx = rc->rc_font->width * ncols;
158 raster_op(rc->rc_sp, dstx, y,
159 nx, rc->rc_font->height, RAS_SRC,
160 rc->rc_sp, srcx, y);
164 * Clear columns (characters) in a row (line).
166 void
167 rcons_erasecols(void *id, int row, int startcol, int ncols, long fillattr)
169 struct rcons *rc = id;
170 int y, startx, nx, op;
172 y = rc->rc_yorigin + rc->rc_font->height * row;
173 startx = rc->rc_xorigin + rc->rc_font->width * startcol;
174 nx = rc->rc_font->width * ncols;
176 op = RAS_CLEAR;
177 if ((fillattr != 0) ^ ((rc->rc_bits & RC_INVERT) != 0))
178 op = RAS_NOT(op);
179 raster_op(rc->rc_sp, startx, y,
180 nx, rc->rc_font->height, op,
181 (struct raster *) 0, 0, 0);
185 * Copy rows (lines).
187 void
188 rcons_copyrows(void *id, int srcrow, int dstrow, int nrows)
190 struct rcons *rc = id;
191 int srcy, dsty, ny;
193 srcy = rc->rc_yorigin + rc->rc_font->height * srcrow;
194 dsty = rc->rc_yorigin + rc->rc_font->height * dstrow;
195 ny = rc->rc_font->height * nrows;
197 raster_op(rc->rc_sp, rc->rc_xorigin, dsty,
198 rc->rc_raswidth, ny, RAS_SRC,
199 rc->rc_sp, rc->rc_xorigin, srcy);
203 * Erase rows (lines).
205 void
206 rcons_eraserows(void *id, int startrow, int nrows, long fillattr)
208 struct rcons *rc = id;
209 int starty, ny, op;
211 starty = rc->rc_yorigin + rc->rc_font->height * startrow;
212 ny = rc->rc_font->height * nrows;
214 op = RAS_CLEAR;
215 if ((fillattr != 0) ^ ((rc->rc_bits & RC_INVERT) != 0))
216 op = RAS_NOT(op);
217 raster_op(rc->rc_sp, rc->rc_xorigin, starty,
218 rc->rc_raswidth, ny, op,
219 (struct raster *) 0, 0, 0);
223 rcons_allocattr(void *id, int fg, int bg, int flags, long *attrp)
225 if (flags & (WSATTR_HILIT | WSATTR_BLINK |
226 WSATTR_UNDERLINE | WSATTR_WSCOLORS))
227 return (EINVAL);
228 if (flags & WSATTR_REVERSE)
229 *attrp = 1;
230 else
231 *attrp = 0;
232 return (0);