pm.c revision 1.1.16.1 1 1.1.16.1 ad /* $NetBSD: pm.c,v 1.1.16.1 2002/03/15 14:22:42 ad Exp $ */
2 1.1.16.1 ad
3 1.1.16.1 ad /*-
4 1.1.16.1 ad * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 1.1.16.1 ad * All rights reserved.
6 1.1.16.1 ad *
7 1.1.16.1 ad * This code is derived from software contributed to The NetBSD Foundation
8 1.1.16.1 ad * by Andrew Doran.
9 1.1.16.1 ad *
10 1.1.16.1 ad * Redistribution and use in source and binary forms, with or without
11 1.1.16.1 ad * modification, are permitted provided that the following conditions
12 1.1.16.1 ad * are met:
13 1.1.16.1 ad * 1. Redistributions of source code must retain the above copyright
14 1.1.16.1 ad * notice, this list of conditions and the following disclaimer.
15 1.1.16.1 ad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.16.1 ad * notice, this list of conditions and the following disclaimer in the
17 1.1.16.1 ad * documentation and/or other materials provided with the distribution.
18 1.1.16.1 ad * 3. All advertising materials mentioning features or use of this software
19 1.1.16.1 ad * must display the following acknowledgement:
20 1.1.16.1 ad * This product includes software developed by the NetBSD
21 1.1.16.1 ad * Foundation, Inc. and its contributors.
22 1.1.16.1 ad * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.16.1 ad * contributors may be used to endorse or promote products derived
24 1.1.16.1 ad * from this software without specific prior written permission.
25 1.1.16.1 ad *
26 1.1.16.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.16.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.16.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.16.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.16.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.16.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.16.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.16.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.16.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.16.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.16.1 ad * POSSIBILITY OF SUCH DAMAGE.
37 1.1.16.1 ad */
38 1.1.16.1 ad
39 1.1.16.1 ad /*
40 1.1.16.1 ad * Copyright (c) 1998, 1999 Tohru Nishimura. All rights reserved.
41 1.1.16.1 ad *
42 1.1.16.1 ad * Redistribution and use in source and binary forms, with or without
43 1.1.16.1 ad * modification, are permitted provided that the following conditions
44 1.1.16.1 ad * are met:
45 1.1.16.1 ad * 1. Redistributions of source code must retain the above copyright
46 1.1.16.1 ad * notice, this list of conditions and the following disclaimer.
47 1.1.16.1 ad * 2. Redistributions in binary form must reproduce the above copyright
48 1.1.16.1 ad * notice, this list of conditions and the following disclaimer in the
49 1.1.16.1 ad * documentation and/or other materials provided with the distribution.
50 1.1.16.1 ad * 3. All advertising materials mentioning features or use of this software
51 1.1.16.1 ad * must display the following acknowledgement:
52 1.1.16.1 ad * This product includes software developed by Tohru Nishimura
53 1.1.16.1 ad * for the NetBSD Project.
54 1.1.16.1 ad * 4. The name of the author may not be used to endorse or promote products
55 1.1.16.1 ad * derived from this software without specific prior written permission
56 1.1.16.1 ad *
57 1.1.16.1 ad * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
58 1.1.16.1 ad * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 1.1.16.1 ad * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 1.1.16.1 ad * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
61 1.1.16.1 ad * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62 1.1.16.1 ad * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63 1.1.16.1 ad * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64 1.1.16.1 ad * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65 1.1.16.1 ad * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
66 1.1.16.1 ad * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 1.1.16.1 ad */
68 1.1.16.1 ad
69 1.1.16.1 ad #include <sys/cdefs.h>
70 1.1.16.1 ad __KERNEL_RCSID(0, "$NetBSD: pm.c,v 1.1.16.1 2002/03/15 14:22:42 ad Exp $");
71 1.1.16.1 ad
72 1.1.16.1 ad #include <sys/param.h>
73 1.1.16.1 ad #include <sys/systm.h>
74 1.1.16.1 ad #include <sys/kernel.h>
75 1.1.16.1 ad #include <sys/device.h>
76 1.1.16.1 ad #include <sys/malloc.h>
77 1.1.16.1 ad #include <sys/buf.h>
78 1.1.16.1 ad #include <sys/ioctl.h>
79 1.1.16.1 ad
80 1.1.16.1 ad #include <machine/bus.h>
81 1.1.16.1 ad #include <machine/intr.h>
82 1.1.16.1 ad
83 1.1.16.1 ad #include <dev/wscons/wsconsio.h>
84 1.1.16.1 ad #include <dev/wscons/wsdisplayvar.h>
85 1.1.16.1 ad #include <dev/rasops/rasops.h>
86 1.1.16.1 ad #include <dev/wsfont/wsfont.h>
87 1.1.16.1 ad
88 1.1.16.1 ad #include <pmax/pmax/kn01.h>
89 1.1.16.1 ad
90 1.1.16.1 ad #include <pmax/ibus/ibusvar.h>
91 1.1.16.1 ad #include <pmax/ibus/pmreg.h>
92 1.1.16.1 ad
93 1.1.16.1 ad #include <uvm/uvm_extern.h>
94 1.1.16.1 ad
95 1.1.16.1 ad struct hwcmap256 {
96 1.1.16.1 ad u_int8_t r[256];
97 1.1.16.1 ad u_int8_t g[256];
98 1.1.16.1 ad u_int8_t b[256];
99 1.1.16.1 ad };
100 1.1.16.1 ad
101 1.1.16.1 ad struct hwcursor64 {
102 1.1.16.1 ad struct wsdisplay_curpos cc_pos;
103 1.1.16.1 ad struct wsdisplay_curpos cc_hot;
104 1.1.16.1 ad struct wsdisplay_curpos cc_size;
105 1.1.16.1 ad #define CURSOR_MAX_SIZE 16
106 1.1.16.1 ad u_int8_t cc_color[6];
107 1.1.16.1 ad u_short cc_image[16 + 16];
108 1.1.16.1 ad };
109 1.1.16.1 ad
110 1.1.16.1 ad struct pm_softc {
111 1.1.16.1 ad struct device sc_dev;
112 1.1.16.1 ad size_t sc_cmap_size;
113 1.1.16.1 ad size_t sc_fb_size;
114 1.1.16.1 ad int sc_type;
115 1.1.16.1 ad int sc_blanked;
116 1.1.16.1 ad int sc_curenb;
117 1.1.16.1 ad int sc_changed;
118 1.1.16.1 ad int sc_nscreens;
119 1.1.16.1 ad struct hwcursor64 sc_cursor;
120 1.1.16.1 ad struct hwcmap256 sc_cmap;
121 1.1.16.1 ad };
122 1.1.16.1 ad #define WSDISPLAY_CMAP_DOLUT 0x20
123 1.1.16.1 ad
124 1.1.16.1 ad int pmmatch(struct device *, struct cfdata *, void *);
125 1.1.16.1 ad void pmattach(struct device *, struct device *, void *);
126 1.1.16.1 ad int pm_ioctl(void *, u_long, caddr_t, int, struct proc *);
127 1.1.16.1 ad paddr_t pm_mmap(void *, off_t, int);
128 1.1.16.1 ad int pm_alloc_screen(void *, const struct wsscreen_descr *,
129 1.1.16.1 ad void **, int *, int *, long *);
130 1.1.16.1 ad void pm_free_screen(void *, void *);
131 1.1.16.1 ad int pm_show_screen(void *, void *, int,
132 1.1.16.1 ad void (*) (void *, int, int), void *);
133 1.1.16.1 ad void pm_cursor_off(struct rasops_info *);
134 1.1.16.1 ad void pm_cursor_on(struct pm_softc *);
135 1.1.16.1 ad int pm_cnattach(void);
136 1.1.16.1 ad void pm_common_init(struct rasops_info *);
137 1.1.16.1 ad int pm_flush(struct pm_softc *);
138 1.1.16.1 ad int pm_get_cmap(struct pm_softc *, struct wsdisplay_cmap *);
139 1.1.16.1 ad int pm_set_cmap(struct pm_softc *, struct wsdisplay_cmap *);
140 1.1.16.1 ad int pm_set_cursor(struct pm_softc *, struct wsdisplay_cursor *);
141 1.1.16.1 ad int pm_get_cursor(struct pm_softc *, struct wsdisplay_cursor *);
142 1.1.16.1 ad void pm_set_curpos(struct pm_softc *, struct wsdisplay_curpos *);
143 1.1.16.1 ad void pm_init_cmap(struct pm_softc *);
144 1.1.16.1 ad
145 1.1.16.1 ad const struct cfattach pm_ca = {
146 1.1.16.1 ad sizeof(struct pm_softc), pmmatch, pmattach,
147 1.1.16.1 ad };
148 1.1.16.1 ad
149 1.1.16.1 ad struct rasops_info pm_ri;
150 1.1.16.1 ad
151 1.1.16.1 ad struct wsscreen_descr pm_stdscreen = {
152 1.1.16.1 ad "std", 0, 0,
153 1.1.16.1 ad 0, /* textops */
154 1.1.16.1 ad 0, 0,
155 1.1.16.1 ad WSSCREEN_REVERSE
156 1.1.16.1 ad };
157 1.1.16.1 ad
158 1.1.16.1 ad const struct wsscreen_descr *_pm_scrlist[] = {
159 1.1.16.1 ad &pm_stdscreen,
160 1.1.16.1 ad };
161 1.1.16.1 ad
162 1.1.16.1 ad const struct wsscreen_list pm_screenlist = {
163 1.1.16.1 ad sizeof(_pm_scrlist) / sizeof(struct wsscreen_descr *), _pm_scrlist
164 1.1.16.1 ad };
165 1.1.16.1 ad
166 1.1.16.1 ad const struct wsdisplay_accessops pm_accessops = {
167 1.1.16.1 ad pm_ioctl,
168 1.1.16.1 ad pm_mmap,
169 1.1.16.1 ad pm_alloc_screen,
170 1.1.16.1 ad pm_free_screen,
171 1.1.16.1 ad pm_show_screen,
172 1.1.16.1 ad 0 /* load_font */
173 1.1.16.1 ad };
174 1.1.16.1 ad
175 1.1.16.1 ad u_int pm_creg;
176 1.1.16.1 ad
177 1.1.16.1 ad int
178 1.1.16.1 ad pmmatch(struct device *parent, struct cfdata *match, void *aux)
179 1.1.16.1 ad {
180 1.1.16.1 ad struct ibus_attach_args *ia;
181 1.1.16.1 ad caddr_t pmaddr;
182 1.1.16.1 ad
183 1.1.16.1 ad ia = aux;
184 1.1.16.1 ad pmaddr = (caddr_t)ia->ia_addr;
185 1.1.16.1 ad
186 1.1.16.1 ad if (strcmp(ia->ia_name, "pm") != 0)
187 1.1.16.1 ad return (0);
188 1.1.16.1 ad
189 1.1.16.1 ad if (badaddr(pmaddr, 4))
190 1.1.16.1 ad return (0);
191 1.1.16.1 ad
192 1.1.16.1 ad return (1);
193 1.1.16.1 ad }
194 1.1.16.1 ad
195 1.1.16.1 ad void
196 1.1.16.1 ad pmattach(struct device *parent, struct device *self, void *aux)
197 1.1.16.1 ad {
198 1.1.16.1 ad struct pm_softc *sc;
199 1.1.16.1 ad struct rasops_info *ri;
200 1.1.16.1 ad struct wsemuldisplaydev_attach_args waa;
201 1.1.16.1 ad int console;
202 1.1.16.1 ad
203 1.1.16.1 ad sc = (struct pm_softc *)self;
204 1.1.16.1 ad ri = &pm_ri;
205 1.1.16.1 ad console = (ri->ri_bits != NULL);
206 1.1.16.1 ad
207 1.1.16.1 ad if (console)
208 1.1.16.1 ad sc->sc_nscreens = 1;
209 1.1.16.1 ad else
210 1.1.16.1 ad pm_common_init(ri);
211 1.1.16.1 ad
212 1.1.16.1 ad printf(": %dx%d, %dbpp\n", ri->ri_width, ri->ri_height, ri->ri_depth);
213 1.1.16.1 ad
214 1.1.16.1 ad pm_init_cmap(sc);
215 1.1.16.1 ad
216 1.1.16.1 ad sc->sc_blanked = 0;
217 1.1.16.1 ad sc->sc_curenb = 0;
218 1.1.16.1 ad
219 1.1.16.1 ad waa.console = console;
220 1.1.16.1 ad waa.scrdata = &pm_screenlist;
221 1.1.16.1 ad waa.accessops = &pm_accessops;
222 1.1.16.1 ad waa.accesscookie = sc;
223 1.1.16.1 ad
224 1.1.16.1 ad config_found(self, &waa, wsemuldisplaydevprint);
225 1.1.16.1 ad }
226 1.1.16.1 ad
227 1.1.16.1 ad void
228 1.1.16.1 ad pm_init_cmap(struct pm_softc *sc)
229 1.1.16.1 ad {
230 1.1.16.1 ad struct hwcmap256 *cm;
231 1.1.16.1 ad struct rasops_info *ri;
232 1.1.16.1 ad const u_int8_t *p;
233 1.1.16.1 ad int index;
234 1.1.16.1 ad
235 1.1.16.1 ad cm = &sc->sc_cmap;
236 1.1.16.1 ad ri = &pm_ri;
237 1.1.16.1 ad
238 1.1.16.1 ad if (ri->ri_depth == 8) {
239 1.1.16.1 ad p = rasops_cmap;
240 1.1.16.1 ad for (index = 0; index < 256; index++, p += 3) {
241 1.1.16.1 ad cm->r[index] = p[0];
242 1.1.16.1 ad cm->g[index] = p[1];
243 1.1.16.1 ad cm->b[index] = p[2];
244 1.1.16.1 ad }
245 1.1.16.1 ad
246 1.1.16.1 ad sc->sc_type = WSDISPLAY_TYPE_PM_COLOR;
247 1.1.16.1 ad sc->sc_cmap_size = 256;
248 1.1.16.1 ad sc->sc_fb_size = 0x100000;
249 1.1.16.1 ad } else {
250 1.1.16.1 ad cm->r[0] = 0;
251 1.1.16.1 ad cm->g[0] = 0;
252 1.1.16.1 ad cm->b[0] = 0;
253 1.1.16.1 ad for (index = 1; index < 256; index++) {
254 1.1.16.1 ad cm->r[0] = 0xff;
255 1.1.16.1 ad cm->g[0] = 0xff;
256 1.1.16.1 ad cm->b[0] = 0xff;
257 1.1.16.1 ad }
258 1.1.16.1 ad
259 1.1.16.1 ad sc->sc_type = WSDISPLAY_TYPE_PM_MONO;
260 1.1.16.1 ad sc->sc_cmap_size = 2;
261 1.1.16.1 ad sc->sc_fb_size = 0x20000;
262 1.1.16.1 ad }
263 1.1.16.1 ad }
264 1.1.16.1 ad
265 1.1.16.1 ad void
266 1.1.16.1 ad pm_common_init(struct rasops_info *ri)
267 1.1.16.1 ad {
268 1.1.16.1 ad int cookie, bior;
269 1.1.16.1 ad PCCRegs *pcc;
270 1.1.16.1 ad #if 0
271 1.1.16.1 ad VDACRegs *vdac;
272 1.1.16.1 ad int i;
273 1.1.16.1 ad #endif
274 1.1.16.1 ad u_int16_t kn01csr;
275 1.1.16.1 ad
276 1.1.16.1 ad printf("pm_common_init: 0\n");
277 1.1.16.1 ad
278 1.1.16.1 ad kn01csr = *(volatile u_int16_t *)MIPS_PHYS_TO_KSEG1(KN01_SYS_CSR);
279 1.1.16.1 ad
280 1.1.16.1 ad ri->ri_flg = RI_CENTER;
281 1.1.16.1 ad ri->ri_depth = ((kn01csr & KN01_CSR_MONO) != 0 ? 1 : 8);
282 1.1.16.1 ad ri->ri_width = 1024;
283 1.1.16.1 ad ri->ri_height = 864;
284 1.1.16.1 ad ri->ri_stride = (ri->ri_depth == 8 ? 1024 : 2048 / 8);
285 1.1.16.1 ad ri->ri_bits = (void *)MIPS_PHYS_TO_KSEG1(KN01_PHYS_FBUF_START);
286 1.1.16.1 ad
287 1.1.16.1 ad printf("pm_common_init: 1\n");
288 1.1.16.1 ad
289 1.1.16.1 ad /*
290 1.1.16.1 ad * Clear the screen.
291 1.1.16.1 ad */
292 1.1.16.1 ad #if 0
293 1.1.16.1 ad memset(ri->ri_bits, 0, ri->ri_stride * ri->ri_height);
294 1.1.16.1 ad #endif
295 1.1.16.1 ad
296 1.1.16.1 ad /*
297 1.1.16.1 ad * Get a font to use.
298 1.1.16.1 ad */
299 1.1.16.1 ad bior = (ri->ri_depth == 8 ? WSDISPLAY_FONTORDER_L2R :
300 1.1.16.1 ad WSDISPLAY_FONTORDER_R2L);
301 1.1.16.1 ad
302 1.1.16.1 ad printf("pm_common_init: 2\n");
303 1.1.16.1 ad
304 1.1.16.1 ad wsfont_init();
305 1.1.16.1 ad cookie = wsfont_find(NULL, 8, 0, 0, bior, WSDISPLAY_FONTORDER_L2R);
306 1.1.16.1 ad if (cookie <= 0)
307 1.1.16.1 ad cookie = wsfont_find(NULL, 0, 0, 0, bior,
308 1.1.16.1 ad WSDISPLAY_FONTORDER_L2R);
309 1.1.16.1 ad if (cookie <= 0) {
310 1.1.16.1 ad printf("pm: font table is empty\n");
311 1.1.16.1 ad return;
312 1.1.16.1 ad }
313 1.1.16.1 ad
314 1.1.16.1 ad printf("pm_common_init: 3\n");
315 1.1.16.1 ad
316 1.1.16.1 ad if (wsfont_lock(cookie, &ri->ri_font)) {
317 1.1.16.1 ad printf("pm: couldn't lock font\n");
318 1.1.16.1 ad return;
319 1.1.16.1 ad }
320 1.1.16.1 ad ri->ri_wsfcookie = cookie;
321 1.1.16.1 ad
322 1.1.16.1 ad printf("pm_common_init: 4\n");
323 1.1.16.1 ad
324 1.1.16.1 ad /*
325 1.1.16.1 ad * Set up the raster operations set.
326 1.1.16.1 ad */
327 1.1.16.1 ad rasops_init(ri, 34, 80);
328 1.1.16.1 ad
329 1.1.16.1 ad printf("pm_common_init: 5\n");
330 1.1.16.1 ad
331 1.1.16.1 ad pm_stdscreen.nrows = ri->ri_rows;
332 1.1.16.1 ad pm_stdscreen.ncols = ri->ri_cols;
333 1.1.16.1 ad pm_stdscreen.textops = &ri->ri_ops;
334 1.1.16.1 ad pm_stdscreen.capabilities = ri->ri_caps;
335 1.1.16.1 ad
336 1.1.16.1 ad printf("pm_common_init: 6\n");
337 1.1.16.1 ad
338 1.1.16.1 ad #if 0
339 1.1.16.1 ad /*
340 1.1.16.1 ad * Initalize the VDAC.
341 1.1.16.1 ad */
342 1.1.16.1 ad vdac = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_VDAC);
343 1.1.16.1 ad vdac->overWA = 0x04; wbflush();
344 1.1.16.1 ad vdac->over = 0x00; wbflush();
345 1.1.16.1 ad vdac->over = 0x00; wbflush();
346 1.1.16.1 ad vdac->over = 0x00; wbflush();
347 1.1.16.1 ad vdac->overWA = 0x08; wbflush();
348 1.1.16.1 ad vdac->over = 0x00; wbflush();
349 1.1.16.1 ad vdac->over = 0x00; wbflush();
350 1.1.16.1 ad vdac->over = 0x7f; wbflush();
351 1.1.16.1 ad vdac->overWA = 0x0c; wbflush();
352 1.1.16.1 ad vdac->over = 0xff; wbflush();
353 1.1.16.1 ad vdac->over = 0xff; wbflush();
354 1.1.16.1 ad vdac->over = 0xff; wbflush();
355 1.1.16.1 ad
356 1.1.16.1 ad /*
357 1.1.16.1 ad * Set in the initial colormap.
358 1.1.16.1 ad */
359 1.1.16.1 ad if (ri->ri_depth == 8) {
360 1.1.16.1 ad vdac->mapWA = 0;
361 1.1.16.1 ad wbflush();
362 1.1.16.1 ad
363 1.1.16.1 ad for (i = 0; i < 256 * 3; i += 3) {
364 1.1.16.1 ad vdac->map = rasops_cmap[i];
365 1.1.16.1 ad wbflush();
366 1.1.16.1 ad vdac->map = rasops_cmap[i + 1];
367 1.1.16.1 ad wbflush();
368 1.1.16.1 ad vdac->map = rasops_cmap[i + 2];
369 1.1.16.1 ad wbflush();
370 1.1.16.1 ad }
371 1.1.16.1 ad } else {
372 1.1.16.1 ad vdac->mapWA = 0;
373 1.1.16.1 ad wbflush();
374 1.1.16.1 ad
375 1.1.16.1 ad vdac->map = 0x00;
376 1.1.16.1 ad wbflush();
377 1.1.16.1 ad vdac->map = 0x00;
378 1.1.16.1 ad wbflush();
379 1.1.16.1 ad vdac->map = 0x00;
380 1.1.16.1 ad wbflush();
381 1.1.16.1 ad
382 1.1.16.1 ad for (i = 1; i < 256; i++) {
383 1.1.16.1 ad vdac->map = 0xff;
384 1.1.16.1 ad wbflush();
385 1.1.16.1 ad vdac->map = 0xff;
386 1.1.16.1 ad wbflush();
387 1.1.16.1 ad vdac->map = 0xff;
388 1.1.16.1 ad wbflush();
389 1.1.16.1 ad }
390 1.1.16.1 ad }
391 1.1.16.1 ad #endif
392 1.1.16.1 ad printf("pm_common_init: 7 - sleeping for 3 seconds\n");
393 1.1.16.1 ad DELAY(1000*1000*3)
394 1.1.16.1 ad
395 1.1.16.1 ad /*
396 1.1.16.1 ad * Turn off the hardware cursor sprite for rcons text mode.
397 1.1.16.1 ad */
398 1.1.16.1 ad pcc->cmdr = (pm_creg = PCC_FOPB | PCC_VBHI);
399 1.1.16.1 ad wbflush();
400 1.1.16.1 ad
401 1.1.16.1 ad printf("pm_common_init: 8 - sleeping for 3 seconds\n");
402 1.1.16.1 ad DELAY(1000*1000*3)
403 1.1.16.1 ad
404 1.1.16.1 ad pm_cursor_off(ri);
405 1.1.16.1 ad
406 1.1.16.1 ad printf("pm_common_init: 9 - sleeping for 3 seconds\n");
407 1.1.16.1 ad DELAY(1000*1000*3)
408 1.1.16.1 ad }
409 1.1.16.1 ad
410 1.1.16.1 ad void
411 1.1.16.1 ad pm_cursor_off(struct rasops_info *ri)
412 1.1.16.1 ad {
413 1.1.16.1 ad PCCRegs *pcc;
414 1.1.16.1 ad VDACRegs *vdac;
415 1.1.16.1 ad int i;
416 1.1.16.1 ad
417 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
418 1.1.16.1 ad vdac = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_VDAC);
419 1.1.16.1 ad pcc->cmdr = (pm_creg &= ~(PCC_ENPA | PCC_ENPB));
420 1.1.16.1 ad wbflush();
421 1.1.16.1 ad
422 1.1.16.1 ad vdac->overWA = 0x0c;
423 1.1.16.1 ad wbflush();
424 1.1.16.1 ad
425 1.1.16.1 ad for (i = 0; i < 3; i++) {
426 1.1.16.1 ad vdac->over = 0;
427 1.1.16.1 ad wbflush();
428 1.1.16.1 ad }
429 1.1.16.1 ad }
430 1.1.16.1 ad
431 1.1.16.1 ad void
432 1.1.16.1 ad pm_cursor_on(struct pm_softc *sc)
433 1.1.16.1 ad {
434 1.1.16.1 ad PCCRegs *pcc;
435 1.1.16.1 ad
436 1.1.16.1 ad if (sc->sc_curenb) {
437 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
438 1.1.16.1 ad pcc->cmdr = (pm_creg |= (PCC_ENPA | PCC_ENPB));
439 1.1.16.1 ad wbflush();
440 1.1.16.1 ad sc->sc_changed |= WSDISPLAY_CURSOR_DOCMAP;
441 1.1.16.1 ad }
442 1.1.16.1 ad }
443 1.1.16.1 ad
444 1.1.16.1 ad int
445 1.1.16.1 ad pm_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
446 1.1.16.1 ad {
447 1.1.16.1 ad struct pm_softc *sc;
448 1.1.16.1 ad struct rasops_info *ri;
449 1.1.16.1 ad int turnoff, rv;
450 1.1.16.1 ad PCCRegs *pcc;
451 1.1.16.1 ad
452 1.1.16.1 ad sc = v;
453 1.1.16.1 ad ri = &pm_ri;
454 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
455 1.1.16.1 ad
456 1.1.16.1 ad switch (cmd) {
457 1.1.16.1 ad case WSDISPLAYIO_GTYPE:
458 1.1.16.1 ad *(u_int *)data = sc->sc_type;
459 1.1.16.1 ad rv = 0;
460 1.1.16.1 ad break;
461 1.1.16.1 ad
462 1.1.16.1 ad case WSDISPLAYIO_SMODE:
463 1.1.16.1 ad if (*(u_int *)data == WSDISPLAYIO_MODE_EMUL) {
464 1.1.16.1 ad pm_cursor_off(ri);
465 1.1.16.1 ad pm_init_cmap(sc);
466 1.1.16.1 ad memset(ri->ri_bits, 0, ri->ri_stride * ri->ri_height);
467 1.1.16.1 ad sc->sc_changed |= WSDISPLAY_CMAP_DOLUT;
468 1.1.16.1 ad }
469 1.1.16.1 ad rv = 0;
470 1.1.16.1 ad break;
471 1.1.16.1 ad
472 1.1.16.1 ad case WSDISPLAYIO_GINFO:
473 1.1.16.1 ad #define wsd_fbip ((struct wsdisplay_fbinfo *)data)
474 1.1.16.1 ad wsd_fbip->height = ri->ri_height;
475 1.1.16.1 ad wsd_fbip->width = ri->ri_width;
476 1.1.16.1 ad wsd_fbip->depth = ri->ri_depth;
477 1.1.16.1 ad wsd_fbip->cmsize = sc->sc_cmap_size;
478 1.1.16.1 ad #undef fbt
479 1.1.16.1 ad rv = 0;
480 1.1.16.1 ad break;
481 1.1.16.1 ad
482 1.1.16.1 ad case WSDISPLAYIO_GETCMAP:
483 1.1.16.1 ad rv = pm_get_cmap(sc, (struct wsdisplay_cmap *)data);
484 1.1.16.1 ad break;
485 1.1.16.1 ad
486 1.1.16.1 ad case WSDISPLAYIO_PUTCMAP:
487 1.1.16.1 ad rv = pm_set_cmap(sc, (struct wsdisplay_cmap *)data);
488 1.1.16.1 ad break;
489 1.1.16.1 ad
490 1.1.16.1 ad case WSDISPLAYIO_SVIDEO:
491 1.1.16.1 ad turnoff = *(int *)data == WSDISPLAYIO_VIDEO_OFF;
492 1.1.16.1 ad if ((sc->sc_blanked == 0) ^ turnoff) {
493 1.1.16.1 ad sc->sc_blanked = turnoff;
494 1.1.16.1 ad if (turnoff == 1) {
495 1.1.16.1 ad pcc->cmdr =
496 1.1.16.1 ad (pm_creg &= ~(PCC_FOPA | PCC_FOPB));
497 1.1.16.1 ad pm_cursor_on(sc);
498 1.1.16.1 ad } else {
499 1.1.16.1 ad pcc->cmdr =
500 1.1.16.1 ad (pm_creg |= (PCC_FOPA | PCC_FOPB));
501 1.1.16.1 ad pm_cursor_off(ri);
502 1.1.16.1 ad }
503 1.1.16.1 ad }
504 1.1.16.1 ad rv = 0;
505 1.1.16.1 ad break;
506 1.1.16.1 ad
507 1.1.16.1 ad case WSDISPLAYIO_GVIDEO:
508 1.1.16.1 ad *(u_int *)data = sc->sc_blanked ?
509 1.1.16.1 ad WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON;
510 1.1.16.1 ad rv = 0;
511 1.1.16.1 ad break;
512 1.1.16.1 ad
513 1.1.16.1 ad case WSDISPLAYIO_GCURPOS:
514 1.1.16.1 ad *(struct wsdisplay_curpos *)data = sc->sc_cursor.cc_pos;
515 1.1.16.1 ad rv = 0;
516 1.1.16.1 ad break;
517 1.1.16.1 ad
518 1.1.16.1 ad case WSDISPLAYIO_SCURPOS:
519 1.1.16.1 ad pm_set_curpos(sc, (struct wsdisplay_curpos *)data);
520 1.1.16.1 ad rv = 0;
521 1.1.16.1 ad break;
522 1.1.16.1 ad
523 1.1.16.1 ad case WSDISPLAYIO_GCURMAX:
524 1.1.16.1 ad ((struct wsdisplay_curpos *)data)->x =
525 1.1.16.1 ad ((struct wsdisplay_curpos *)data)->y = CURSOR_MAX_SIZE;
526 1.1.16.1 ad rv = 0;
527 1.1.16.1 ad break;
528 1.1.16.1 ad
529 1.1.16.1 ad case WSDISPLAYIO_GCURSOR:
530 1.1.16.1 ad rv = pm_get_cursor(sc, (struct wsdisplay_cursor *)data);
531 1.1.16.1 ad break;
532 1.1.16.1 ad
533 1.1.16.1 ad case WSDISPLAYIO_SCURSOR:
534 1.1.16.1 ad rv = pm_set_cursor(sc, (struct wsdisplay_cursor *)data);
535 1.1.16.1 ad break;
536 1.1.16.1 ad
537 1.1.16.1 ad default:
538 1.1.16.1 ad rv = ENOTTY;
539 1.1.16.1 ad break;
540 1.1.16.1 ad }
541 1.1.16.1 ad
542 1.1.16.1 ad pm_flush(sc);
543 1.1.16.1 ad return (rv);
544 1.1.16.1 ad }
545 1.1.16.1 ad
546 1.1.16.1 ad paddr_t
547 1.1.16.1 ad pm_mmap(void *v, off_t offset, int prot)
548 1.1.16.1 ad {
549 1.1.16.1 ad struct pm_softc *sc;
550 1.1.16.1 ad
551 1.1.16.1 ad sc = v;
552 1.1.16.1 ad
553 1.1.16.1 ad if (offset >= sc->sc_fb_size || offset < 0)
554 1.1.16.1 ad return (-1);
555 1.1.16.1 ad
556 1.1.16.1 ad return (mips_btop((caddr_t)pm_ri.ri_bits + offset));
557 1.1.16.1 ad }
558 1.1.16.1 ad
559 1.1.16.1 ad int
560 1.1.16.1 ad pm_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
561 1.1.16.1 ad int *curxp, int *curyp, long *attrp)
562 1.1.16.1 ad {
563 1.1.16.1 ad struct pm_softc *sc;
564 1.1.16.1 ad struct rasops_info *ri;
565 1.1.16.1 ad long defattr;
566 1.1.16.1 ad
567 1.1.16.1 ad sc = v;
568 1.1.16.1 ad ri = &pm_ri;
569 1.1.16.1 ad
570 1.1.16.1 ad if (sc->sc_nscreens > 0)
571 1.1.16.1 ad return (ENOMEM);
572 1.1.16.1 ad
573 1.1.16.1 ad *cookiep = ri; /* one and only for now */
574 1.1.16.1 ad *curxp = 0;
575 1.1.16.1 ad *curyp = 0;
576 1.1.16.1 ad (*ri->ri_ops.alloc_attr)(ri, 0, 0, 0, &defattr);
577 1.1.16.1 ad *attrp = defattr;
578 1.1.16.1 ad sc->sc_nscreens++;
579 1.1.16.1 ad return (0);
580 1.1.16.1 ad }
581 1.1.16.1 ad
582 1.1.16.1 ad void
583 1.1.16.1 ad pm_free_screen(void *v, void *cookie)
584 1.1.16.1 ad {
585 1.1.16.1 ad
586 1.1.16.1 ad panic("pm_free_screen: console");
587 1.1.16.1 ad }
588 1.1.16.1 ad
589 1.1.16.1 ad int
590 1.1.16.1 ad pm_show_screen(void *v, void *cookie, int waitok,
591 1.1.16.1 ad void (*cb)(void *, int, int), void *cbarg)
592 1.1.16.1 ad {
593 1.1.16.1 ad
594 1.1.16.1 ad return (0);
595 1.1.16.1 ad }
596 1.1.16.1 ad
597 1.1.16.1 ad /* EXPORT */ int
598 1.1.16.1 ad pm_cnattach(void)
599 1.1.16.1 ad {
600 1.1.16.1 ad struct rasops_info *ri;
601 1.1.16.1 ad long defattr;
602 1.1.16.1 ad
603 1.1.16.1 ad printf("pm_cnattach: 0\n");
604 1.1.16.1 ad
605 1.1.16.1 ad ri = &pm_ri;
606 1.1.16.1 ad pm_common_init(ri);
607 1.1.16.1 ad
608 1.1.16.1 ad printf("pm_cnattach: 1\n");
609 1.1.16.1 ad
610 1.1.16.1 ad (*ri->ri_ops.alloc_attr)(ri, 0, 0, 0, &defattr);
611 1.1.16.1 ad
612 1.1.16.1 ad printf("pm_cnattach: 2\n");
613 1.1.16.1 ad
614 1.1.16.1 ad wsdisplay_cnattach(&pm_stdscreen, ri, 0, 0, defattr);
615 1.1.16.1 ad
616 1.1.16.1 ad printf("pm_cnattach: 3\n");
617 1.1.16.1 ad
618 1.1.16.1 ad return(0);
619 1.1.16.1 ad }
620 1.1.16.1 ad
621 1.1.16.1 ad int
622 1.1.16.1 ad pm_flush(struct pm_softc *sc)
623 1.1.16.1 ad {
624 1.1.16.1 ad VDACRegs *vdac;
625 1.1.16.1 ad PCCRegs *pcc;
626 1.1.16.1 ad u_int8_t *cp;
627 1.1.16.1 ad int v, i, x, y;
628 1.1.16.1 ad u_short *p, *pe;
629 1.1.16.1 ad struct hwcmap256 *cm;
630 1.1.16.1 ad struct rasops_info *ri;
631 1.1.16.1 ad
632 1.1.16.1 ad if (sc->sc_changed == 0)
633 1.1.16.1 ad return (1);
634 1.1.16.1 ad
635 1.1.16.1 ad vdac = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_VDAC);
636 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
637 1.1.16.1 ad ri = &pm_ri;
638 1.1.16.1 ad
639 1.1.16.1 ad if ((sc->sc_changed & WSDISPLAY_CURSOR_DOCUR) != 0) {
640 1.1.16.1 ad if (sc->sc_curenb)
641 1.1.16.1 ad pm_cursor_on(sc);
642 1.1.16.1 ad else
643 1.1.16.1 ad pm_cursor_off(ri);
644 1.1.16.1 ad }
645 1.1.16.1 ad
646 1.1.16.1 ad /*
647 1.1.16.1 ad * sc_changed may be modified by pm_cursor_on().
648 1.1.16.1 ad */
649 1.1.16.1 ad v = sc->sc_changed;
650 1.1.16.1 ad
651 1.1.16.1 ad if ((v & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT)) != 0) {
652 1.1.16.1 ad x = sc->sc_cursor.cc_pos.x - sc->sc_cursor.cc_hot.x;
653 1.1.16.1 ad y = sc->sc_cursor.cc_pos.y - sc->sc_cursor.cc_hot.y;
654 1.1.16.1 ad pcc->xpos = x + PCC_X_OFFSET;
655 1.1.16.1 ad pcc->ypos = y + PCC_Y_OFFSET;
656 1.1.16.1 ad wbflush();
657 1.1.16.1 ad }
658 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCMAP) != 0) {
659 1.1.16.1 ad cp = sc->sc_cursor.cc_color;
660 1.1.16.1 ad
661 1.1.16.1 ad vdac->overWA = 0x04;
662 1.1.16.1 ad wbflush();
663 1.1.16.1 ad for (i = 0; i < 6; i += 2) {
664 1.1.16.1 ad vdac->over = cp[i];
665 1.1.16.1 ad wbflush();
666 1.1.16.1 ad }
667 1.1.16.1 ad
668 1.1.16.1 ad vdac->overWA = 0x08;
669 1.1.16.1 ad wbflush();
670 1.1.16.1 ad vdac->over = 0x00;
671 1.1.16.1 ad wbflush();
672 1.1.16.1 ad vdac->over = 0x00;
673 1.1.16.1 ad wbflush();
674 1.1.16.1 ad vdac->over = 0x7f;
675 1.1.16.1 ad wbflush();
676 1.1.16.1 ad
677 1.1.16.1 ad vdac->overWA = 0x0c;
678 1.1.16.1 ad wbflush();
679 1.1.16.1 ad for (i = 1; i < 6; i += 2) {
680 1.1.16.1 ad vdac->over = cp[i];
681 1.1.16.1 ad wbflush();
682 1.1.16.1 ad }
683 1.1.16.1 ad }
684 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOSHAPE) != 0) {
685 1.1.16.1 ad pcc->cmdr = (pm_creg | PCC_LODSA);
686 1.1.16.1 ad wbflush();
687 1.1.16.1 ad
688 1.1.16.1 ad p = sc->sc_cursor.cc_image;
689 1.1.16.1 ad pe = p + 32;
690 1.1.16.1 ad while (p < pe) {
691 1.1.16.1 ad pcc->memory = *p++;
692 1.1.16.1 ad wbflush();
693 1.1.16.1 ad }
694 1.1.16.1 ad
695 1.1.16.1 ad pcc->cmdr = (pm_creg &= ~PCC_LODSA);
696 1.1.16.1 ad wbflush();
697 1.1.16.1 ad }
698 1.1.16.1 ad
699 1.1.16.1 ad if ((v & WSDISPLAY_CMAP_DOLUT) != 0) {
700 1.1.16.1 ad cm = &sc->sc_cmap;
701 1.1.16.1 ad
702 1.1.16.1 ad vdac->mapWA = 0;
703 1.1.16.1 ad wbflush();
704 1.1.16.1 ad
705 1.1.16.1 ad for (i = 0; i < sc->sc_cmap_size; i++) {
706 1.1.16.1 ad vdac->map = cm->r[i];
707 1.1.16.1 ad wbflush();
708 1.1.16.1 ad vdac->map = cm->g[i];
709 1.1.16.1 ad wbflush();
710 1.1.16.1 ad vdac->map = cm->b[i];
711 1.1.16.1 ad wbflush();
712 1.1.16.1 ad }
713 1.1.16.1 ad }
714 1.1.16.1 ad
715 1.1.16.1 ad sc->sc_changed = 0;
716 1.1.16.1 ad return (1);
717 1.1.16.1 ad }
718 1.1.16.1 ad
719 1.1.16.1 ad int
720 1.1.16.1 ad pm_get_cmap(struct pm_softc *sc, struct wsdisplay_cmap *p)
721 1.1.16.1 ad {
722 1.1.16.1 ad u_int index, count;
723 1.1.16.1 ad
724 1.1.16.1 ad index = p->index;
725 1.1.16.1 ad count = p->count;
726 1.1.16.1 ad
727 1.1.16.1 ad if (index >= sc->sc_cmap_size || (index + count) > sc->sc_cmap_size)
728 1.1.16.1 ad return (EINVAL);
729 1.1.16.1 ad
730 1.1.16.1 ad if (!uvm_useracc(p->red, count, B_WRITE) ||
731 1.1.16.1 ad !uvm_useracc(p->green, count, B_WRITE) ||
732 1.1.16.1 ad !uvm_useracc(p->blue, count, B_WRITE))
733 1.1.16.1 ad return (EFAULT);
734 1.1.16.1 ad
735 1.1.16.1 ad copyout(&sc->sc_cmap.r[index], p->red, count);
736 1.1.16.1 ad copyout(&sc->sc_cmap.g[index], p->green, count);
737 1.1.16.1 ad copyout(&sc->sc_cmap.b[index], p->blue, count);
738 1.1.16.1 ad
739 1.1.16.1 ad return (0);
740 1.1.16.1 ad }
741 1.1.16.1 ad
742 1.1.16.1 ad int
743 1.1.16.1 ad pm_set_cmap(struct pm_softc *sc, struct wsdisplay_cmap *p)
744 1.1.16.1 ad {
745 1.1.16.1 ad u_int index, count;
746 1.1.16.1 ad
747 1.1.16.1 ad index = p->index;
748 1.1.16.1 ad count = p->count;
749 1.1.16.1 ad
750 1.1.16.1 ad if (index >= sc->sc_cmap_size || (index + count) > sc->sc_cmap_size)
751 1.1.16.1 ad return (EINVAL);
752 1.1.16.1 ad
753 1.1.16.1 ad if (!uvm_useracc(p->red, count, B_READ) ||
754 1.1.16.1 ad !uvm_useracc(p->green, count, B_READ) ||
755 1.1.16.1 ad !uvm_useracc(p->blue, count, B_READ))
756 1.1.16.1 ad return (EFAULT);
757 1.1.16.1 ad
758 1.1.16.1 ad copyin(p->red, &sc->sc_cmap.r[index], count);
759 1.1.16.1 ad copyin(p->green, &sc->sc_cmap.g[index], count);
760 1.1.16.1 ad copyin(p->blue, &sc->sc_cmap.b[index], count);
761 1.1.16.1 ad sc->sc_changed |= WSDISPLAY_CMAP_DOLUT;
762 1.1.16.1 ad return (0);
763 1.1.16.1 ad }
764 1.1.16.1 ad
765 1.1.16.1 ad int
766 1.1.16.1 ad pm_set_cursor(struct pm_softc *sc, struct wsdisplay_cursor *p)
767 1.1.16.1 ad {
768 1.1.16.1 ad #define cc (&sc->sc_cursor)
769 1.1.16.1 ad u_int v, index, count;
770 1.1.16.1 ad
771 1.1.16.1 ad v = p->which;
772 1.1.16.1 ad
773 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCMAP) != 0) {
774 1.1.16.1 ad index = p->cmap.index;
775 1.1.16.1 ad count = p->cmap.count;
776 1.1.16.1 ad if (index >= 2 || (index + count) > 2)
777 1.1.16.1 ad return (EINVAL);
778 1.1.16.1 ad if (!uvm_useracc(p->cmap.red, count, B_READ) ||
779 1.1.16.1 ad !uvm_useracc(p->cmap.green, count, B_READ) ||
780 1.1.16.1 ad !uvm_useracc(p->cmap.blue, count, B_READ))
781 1.1.16.1 ad return (EFAULT);
782 1.1.16.1 ad }
783 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOSHAPE) != 0) {
784 1.1.16.1 ad if (p->size.x > CURSOR_MAX_SIZE ||
785 1.1.16.1 ad p->size.y > CURSOR_MAX_SIZE ||
786 1.1.16.1 ad p->size.x < 9)
787 1.1.16.1 ad return (EINVAL);
788 1.1.16.1 ad if (!uvm_useracc(p->image, p->size.y * 2, B_READ) ||
789 1.1.16.1 ad !uvm_useracc(p->mask, p->size.y * 2, B_READ))
790 1.1.16.1 ad return (EFAULT);
791 1.1.16.1 ad }
792 1.1.16.1 ad
793 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCUR) != 0)
794 1.1.16.1 ad sc->sc_curenb = p->enable;
795 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOPOS) != 0)
796 1.1.16.1 ad pm_set_curpos(sc, &p->pos);
797 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOHOT) != 0)
798 1.1.16.1 ad cc->cc_hot = p->hot;
799 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCMAP) != 0) {
800 1.1.16.1 ad copyin(p->cmap.red, &cc->cc_color[index], count);
801 1.1.16.1 ad copyin(p->cmap.green, &cc->cc_color[index + 2], count);
802 1.1.16.1 ad copyin(p->cmap.blue, &cc->cc_color[index + 4], count);
803 1.1.16.1 ad }
804 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOSHAPE) != 0) {
805 1.1.16.1 ad cc->cc_size = p->size;
806 1.1.16.1 ad memset(cc->cc_image, 0, sizeof(cc->cc_image));
807 1.1.16.1 ad copyin(p->image, cc->cc_image, p->size.y * 2);
808 1.1.16.1 ad copyin(p->mask, cc->cc_image+CURSOR_MAX_SIZE, p->size.y * 2);
809 1.1.16.1 ad }
810 1.1.16.1 ad sc->sc_changed |= v;
811 1.1.16.1 ad
812 1.1.16.1 ad return (0);
813 1.1.16.1 ad #undef cc
814 1.1.16.1 ad }
815 1.1.16.1 ad
816 1.1.16.1 ad int
817 1.1.16.1 ad pm_get_cursor(struct pm_softc *sc, struct wsdisplay_cursor *p)
818 1.1.16.1 ad {
819 1.1.16.1 ad
820 1.1.16.1 ad return (ENOTTY); /* XXX */
821 1.1.16.1 ad }
822 1.1.16.1 ad
823 1.1.16.1 ad void
824 1.1.16.1 ad pm_set_curpos(struct pm_softc *sc, struct wsdisplay_curpos *curpos)
825 1.1.16.1 ad {
826 1.1.16.1 ad struct rasops_info *ri;
827 1.1.16.1 ad int x, y;
828 1.1.16.1 ad
829 1.1.16.1 ad ri = &pm_ri;
830 1.1.16.1 ad x = curpos->x;
831 1.1.16.1 ad y = curpos->y;
832 1.1.16.1 ad
833 1.1.16.1 ad if (y < 0)
834 1.1.16.1 ad y = 0;
835 1.1.16.1 ad else if (y > ri->ri_height)
836 1.1.16.1 ad y = ri->ri_height;
837 1.1.16.1 ad if (x < 0)
838 1.1.16.1 ad x = 0;
839 1.1.16.1 ad else if (x > ri->ri_width)
840 1.1.16.1 ad x = ri->ri_width;
841 1.1.16.1 ad sc->sc_cursor.cc_pos.x = x;
842 1.1.16.1 ad sc->sc_cursor.cc_pos.y = y;
843 1.1.16.1 ad }
844