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