wsdisplay_compat_usl.c revision 1.16 1 1.16 augustss /* $NetBSD: wsdisplay_compat_usl.c,v 1.16 2001/10/13 15:56:15 augustss Exp $ */
2 1.1 drochner
3 1.1 drochner /*
4 1.1 drochner * Copyright (c) 1998
5 1.1 drochner * Matthias Drochner. All rights reserved.
6 1.1 drochner *
7 1.1 drochner * Redistribution and use in source and binary forms, with or without
8 1.1 drochner * modification, are permitted provided that the following conditions
9 1.1 drochner * are met:
10 1.1 drochner * 1. Redistributions of source code must retain the above copyright
11 1.1 drochner * notice, this list of conditions and the following disclaimer.
12 1.1 drochner * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 drochner * notice, this list of conditions and the following disclaimer in the
14 1.1 drochner * documentation and/or other materials provided with the distribution.
15 1.1 drochner * 3. All advertising materials mentioning features or use of this software
16 1.1 drochner * must display the following acknowledgement:
17 1.1 drochner * This product includes software developed for the NetBSD Project
18 1.1 drochner * by Matthias Drochner.
19 1.1 drochner * 4. The name of the author may not be used to endorse or promote products
20 1.1 drochner * derived from this software without specific prior written permission.
21 1.1 drochner *
22 1.1 drochner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 drochner * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 drochner * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 drochner * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 1.1 drochner * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 1.1 drochner * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 1.1 drochner * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 1.1 drochner * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 1.1 drochner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 1.1 drochner * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 drochner *
33 1.1 drochner */
34 1.4 thorpej
35 1.4 thorpej #include "opt_compat_freebsd.h"
36 1.5 jonathan #include "opt_compat_netbsd.h"
37 1.1 drochner
38 1.1 drochner #include <sys/param.h>
39 1.1 drochner #include <sys/systm.h>
40 1.12 thorpej #include <sys/callout.h>
41 1.1 drochner #include <sys/ioctl.h>
42 1.1 drochner #include <sys/kernel.h>
43 1.1 drochner #include <sys/proc.h>
44 1.1 drochner #include <sys/signalvar.h>
45 1.1 drochner #include <sys/malloc.h>
46 1.1 drochner #include <sys/errno.h>
47 1.1 drochner
48 1.1 drochner #include <dev/wscons/wsconsio.h>
49 1.1 drochner #include <dev/wscons/wsdisplayvar.h>
50 1.1 drochner #include <dev/wscons/wscons_callbacks.h>
51 1.1 drochner #include <dev/wscons/wsdisplay_usl_io.h>
52 1.1 drochner
53 1.1 drochner #include "opt_wsdisplay_compat.h"
54 1.1 drochner
55 1.1 drochner struct usl_syncdata {
56 1.1 drochner struct wsscreen *s_scr;
57 1.1 drochner struct proc *s_proc;
58 1.1 drochner pid_t s_pid;
59 1.1 drochner int s_flags;
60 1.1 drochner #define SF_DETACHPENDING 1
61 1.1 drochner #define SF_ATTACHPENDING 2
62 1.1 drochner int s_acqsig, s_relsig;
63 1.1 drochner int s_frsig; /* unused */
64 1.16 augustss void (*s_callback)(void *, int, int);
65 1.1 drochner void *s_cbarg;
66 1.12 thorpej struct callout s_attach_ch;
67 1.12 thorpej struct callout s_detach_ch;
68 1.1 drochner };
69 1.1 drochner
70 1.16 augustss static int usl_sync_init(struct wsscreen *, struct usl_syncdata **,
71 1.16 augustss struct proc *, int, int, int);
72 1.16 augustss static void usl_sync_done(struct usl_syncdata *);
73 1.16 augustss static int usl_sync_check(struct usl_syncdata *);
74 1.16 augustss static struct usl_syncdata *usl_sync_get(struct wsscreen *);
75 1.16 augustss
76 1.16 augustss static int usl_detachproc(void *, int, void (*)(void *, int, int), void *);
77 1.16 augustss static int usl_detachack(struct usl_syncdata *, int);
78 1.16 augustss static void usl_detachtimeout(void *);
79 1.16 augustss static int usl_attachproc(void *, int, void (*)(void *, int, int), void *);
80 1.16 augustss static int usl_attachack(struct usl_syncdata *, int);
81 1.16 augustss static void usl_attachtimeout(void *);
82 1.1 drochner
83 1.1 drochner static const struct wscons_syncops usl_syncops = {
84 1.1 drochner usl_detachproc,
85 1.1 drochner usl_attachproc,
86 1.16 augustss #define _usl_sync_check ((int (*)(void *))usl_sync_check)
87 1.1 drochner _usl_sync_check,
88 1.16 augustss #define _usl_sync_destroy ((void (*)(void *))usl_sync_done)
89 1.1 drochner _usl_sync_destroy
90 1.1 drochner };
91 1.1 drochner
92 1.7 drochner #ifndef WSCOMPAT_USL_SYNCTIMEOUT
93 1.7 drochner #define WSCOMPAT_USL_SYNCTIMEOUT 5 /* seconds */
94 1.7 drochner #endif
95 1.7 drochner static int wscompat_usl_synctimeout = WSCOMPAT_USL_SYNCTIMEOUT;
96 1.7 drochner
97 1.1 drochner static int
98 1.16 augustss usl_sync_init(struct wsscreen *scr, struct usl_syncdata **sdp,
99 1.16 augustss struct proc *p, int acqsig, int relsig, int frsig)
100 1.1 drochner {
101 1.1 drochner struct usl_syncdata *sd;
102 1.1 drochner int res;
103 1.1 drochner
104 1.1 drochner sd = malloc(sizeof(struct usl_syncdata), M_DEVBUF, M_WAITOK);
105 1.1 drochner if (!sd)
106 1.1 drochner return (ENOMEM);
107 1.1 drochner sd->s_scr = scr;
108 1.3 drochner sd->s_proc = p;
109 1.3 drochner sd->s_pid = p->p_pid;
110 1.2 drochner sd->s_flags = 0;
111 1.3 drochner sd->s_acqsig = acqsig;
112 1.3 drochner sd->s_relsig = relsig;
113 1.3 drochner sd->s_frsig = frsig;
114 1.12 thorpej callout_init(&sd->s_attach_ch);
115 1.12 thorpej callout_init(&sd->s_detach_ch);
116 1.1 drochner res = wsscreen_attach_sync(scr, &usl_syncops, sd);
117 1.1 drochner if (res) {
118 1.1 drochner free(sd, M_DEVBUF);
119 1.1 drochner return (res);
120 1.1 drochner }
121 1.1 drochner *sdp = sd;
122 1.1 drochner return (0);
123 1.1 drochner }
124 1.1 drochner
125 1.1 drochner static void
126 1.16 augustss usl_sync_done(struct usl_syncdata *sd)
127 1.1 drochner {
128 1.2 drochner if (sd->s_flags & SF_DETACHPENDING) {
129 1.12 thorpej callout_stop(&sd->s_detach_ch);
130 1.6 drochner (*sd->s_callback)(sd->s_cbarg, 0, 0);
131 1.2 drochner }
132 1.6 drochner if (sd->s_flags & SF_ATTACHPENDING) {
133 1.12 thorpej callout_stop(&sd->s_attach_ch);
134 1.6 drochner (*sd->s_callback)(sd->s_cbarg, ENXIO, 0);
135 1.6 drochner }
136 1.1 drochner wsscreen_detach_sync(sd->s_scr);
137 1.1 drochner free(sd, M_DEVBUF);
138 1.1 drochner }
139 1.1 drochner
140 1.1 drochner static int
141 1.16 augustss usl_sync_check(struct usl_syncdata *sd)
142 1.1 drochner {
143 1.1 drochner if (sd->s_proc == pfind(sd->s_pid))
144 1.1 drochner return (1);
145 1.1 drochner printf("usl_sync_check: process %d died\n", sd->s_pid);
146 1.1 drochner usl_sync_done(sd);
147 1.1 drochner return (0);
148 1.1 drochner }
149 1.1 drochner
150 1.1 drochner static struct usl_syncdata *
151 1.16 augustss usl_sync_get(struct wsscreen *scr)
152 1.1 drochner {
153 1.1 drochner struct usl_syncdata *sd;
154 1.1 drochner
155 1.1 drochner if (wsscreen_lookup_sync(scr, &usl_syncops, (void **)&sd))
156 1.1 drochner return (0);
157 1.1 drochner return (sd);
158 1.1 drochner }
159 1.1 drochner
160 1.1 drochner static int
161 1.16 augustss usl_detachproc(void *cookie, int waitok, void (*callback)(void *, int, int),
162 1.16 augustss void *cbarg)
163 1.1 drochner {
164 1.1 drochner struct usl_syncdata *sd = cookie;
165 1.1 drochner
166 1.1 drochner if (!usl_sync_check(sd))
167 1.1 drochner return (0);
168 1.1 drochner
169 1.11 drochner /* we really need a callback */
170 1.11 drochner if (!callback)
171 1.11 drochner return (EINVAL);
172 1.11 drochner
173 1.1 drochner /*
174 1.1 drochner * Normally, this is called from the controlling process.
175 1.1 drochner * Is is supposed to reply with a VT_RELDISP ioctl(), so
176 1.1 drochner * it is not useful to tsleep() here.
177 1.1 drochner */
178 1.1 drochner sd->s_callback = callback;
179 1.1 drochner sd->s_cbarg = cbarg;
180 1.1 drochner sd->s_flags |= SF_DETACHPENDING;
181 1.1 drochner psignal(sd->s_proc, sd->s_relsig);
182 1.12 thorpej callout_reset(&sd->s_detach_ch, wscompat_usl_synctimeout * hz,
183 1.12 thorpej usl_detachtimeout, sd);
184 1.1 drochner
185 1.1 drochner return (EAGAIN);
186 1.1 drochner }
187 1.1 drochner
188 1.1 drochner static int
189 1.16 augustss usl_detachack(struct usl_syncdata *sd, int ack)
190 1.1 drochner {
191 1.1 drochner if (!(sd->s_flags & SF_DETACHPENDING)) {
192 1.1 drochner printf("usl_detachack: not detaching\n");
193 1.1 drochner return (EINVAL);
194 1.1 drochner }
195 1.1 drochner
196 1.12 thorpej callout_stop(&sd->s_detach_ch);
197 1.1 drochner sd->s_flags &= ~SF_DETACHPENDING;
198 1.1 drochner
199 1.6 drochner if (sd->s_callback)
200 1.6 drochner (*sd->s_callback)(sd->s_cbarg, (ack ? 0 : EIO), 1);
201 1.1 drochner
202 1.1 drochner return (0);
203 1.1 drochner }
204 1.1 drochner
205 1.1 drochner static void
206 1.16 augustss usl_detachtimeout(void *arg)
207 1.1 drochner {
208 1.1 drochner struct usl_syncdata *sd = arg;
209 1.1 drochner
210 1.1 drochner printf("usl_detachtimeout\n");
211 1.1 drochner
212 1.1 drochner if (!(sd->s_flags & SF_DETACHPENDING)) {
213 1.1 drochner printf("usl_detachtimeout: not detaching\n");
214 1.1 drochner return;
215 1.1 drochner }
216 1.1 drochner
217 1.1 drochner sd->s_flags &= ~SF_DETACHPENDING;
218 1.6 drochner
219 1.6 drochner if (sd->s_callback)
220 1.6 drochner (*sd->s_callback)(sd->s_cbarg, EIO, 0);
221 1.6 drochner
222 1.1 drochner (void) usl_sync_check(sd);
223 1.1 drochner }
224 1.1 drochner
225 1.1 drochner static int
226 1.16 augustss usl_attachproc(void *cookie, int waitok, void (*callback)(void *, int, int),
227 1.16 augustss void *cbarg)
228 1.1 drochner {
229 1.1 drochner struct usl_syncdata *sd = cookie;
230 1.1 drochner
231 1.1 drochner if (!usl_sync_check(sd))
232 1.1 drochner return (0);
233 1.11 drochner
234 1.11 drochner /* we really need a callback */
235 1.11 drochner if (!callback)
236 1.11 drochner return (EINVAL);
237 1.1 drochner
238 1.6 drochner sd->s_callback = callback;
239 1.6 drochner sd->s_cbarg = cbarg;
240 1.1 drochner sd->s_flags |= SF_ATTACHPENDING;
241 1.1 drochner psignal(sd->s_proc, sd->s_acqsig);
242 1.12 thorpej callout_reset(&sd->s_attach_ch, wscompat_usl_synctimeout * hz,
243 1.12 thorpej usl_attachtimeout, sd);
244 1.1 drochner
245 1.1 drochner return (EAGAIN);
246 1.1 drochner }
247 1.1 drochner
248 1.1 drochner static int
249 1.16 augustss usl_attachack(struct usl_syncdata *sd, int ack)
250 1.1 drochner {
251 1.1 drochner if (!(sd->s_flags & SF_ATTACHPENDING)) {
252 1.1 drochner printf("usl_attachack: not attaching\n");
253 1.1 drochner return (EINVAL);
254 1.1 drochner }
255 1.1 drochner
256 1.12 thorpej callout_stop(&sd->s_attach_ch);
257 1.1 drochner sd->s_flags &= ~SF_ATTACHPENDING;
258 1.6 drochner
259 1.6 drochner if (sd->s_callback)
260 1.6 drochner (*sd->s_callback)(sd->s_cbarg, (ack ? 0 : EIO), 1);
261 1.6 drochner
262 1.1 drochner return (0);
263 1.1 drochner }
264 1.1 drochner
265 1.1 drochner static void
266 1.16 augustss usl_attachtimeout(void *arg)
267 1.1 drochner {
268 1.1 drochner struct usl_syncdata *sd = arg;
269 1.1 drochner
270 1.1 drochner printf("usl_attachtimeout\n");
271 1.1 drochner
272 1.1 drochner if (!(sd->s_flags & SF_ATTACHPENDING)) {
273 1.1 drochner printf("usl_attachtimeout: not attaching\n");
274 1.1 drochner return;
275 1.1 drochner }
276 1.1 drochner
277 1.1 drochner sd->s_flags &= ~SF_ATTACHPENDING;
278 1.6 drochner
279 1.6 drochner if (sd->s_callback)
280 1.6 drochner (*sd->s_callback)(sd->s_cbarg, EIO, 0);
281 1.6 drochner
282 1.1 drochner (void) usl_sync_check(sd);
283 1.1 drochner }
284 1.1 drochner
285 1.1 drochner int
286 1.16 augustss wsdisplay_usl_ioctl1(struct wsdisplay_softc *sc, u_long cmd, caddr_t data,
287 1.16 augustss int flag, struct proc *p)
288 1.10 mycroft {
289 1.10 mycroft int idx, maxidx;
290 1.10 mycroft
291 1.10 mycroft switch (cmd) {
292 1.10 mycroft case VT_OPENQRY:
293 1.10 mycroft maxidx = wsdisplay_maxscreenidx(sc);
294 1.10 mycroft for (idx = 0; idx <= maxidx; idx++) {
295 1.10 mycroft if (wsdisplay_screenstate(sc, idx) == 0) {
296 1.10 mycroft *(int *)data = idx + 1;
297 1.10 mycroft return (0);
298 1.10 mycroft }
299 1.10 mycroft }
300 1.10 mycroft return (ENXIO);
301 1.10 mycroft case VT_GETACTIVE:
302 1.10 mycroft idx = wsdisplay_getactivescreen(sc);
303 1.10 mycroft *(int *)data = idx + 1;
304 1.10 mycroft return (0);
305 1.10 mycroft case VT_ACTIVATE:
306 1.10 mycroft idx = *(int *)data - 1;
307 1.14 takemura if (idx < 0)
308 1.14 takemura return (EINVAL);
309 1.10 mycroft return (wsdisplay_switch((struct device *)sc, idx, 1));
310 1.10 mycroft case VT_WAITACTIVE:
311 1.10 mycroft idx = *(int *)data - 1;
312 1.14 takemura if (idx < 0)
313 1.14 takemura return (EINVAL);
314 1.10 mycroft return (wsscreen_switchwait(sc, idx));
315 1.10 mycroft case VT_GETSTATE:
316 1.10 mycroft #define ss ((struct vt_stat *)data)
317 1.10 mycroft idx = wsdisplay_getactivescreen(sc);
318 1.10 mycroft ss->v_active = idx + 1;
319 1.10 mycroft ss->v_state = 0;
320 1.10 mycroft maxidx = wsdisplay_maxscreenidx(sc);
321 1.10 mycroft for (idx = 0; idx <= maxidx; idx++)
322 1.10 mycroft if (wsdisplay_screenstate(sc, idx) == EBUSY)
323 1.10 mycroft ss->v_state |= (1 << (idx + 1));
324 1.10 mycroft #undef s
325 1.10 mycroft return (0);
326 1.10 mycroft
327 1.10 mycroft #ifdef WSDISPLAY_COMPAT_PCVT
328 1.10 mycroft case VGAPCVTID:
329 1.10 mycroft #define id ((struct pcvtid *)data)
330 1.10 mycroft strcpy(id->name, "pcvt");
331 1.10 mycroft id->rmajor = 3;
332 1.10 mycroft id->rminor = 32;
333 1.10 mycroft #undef id
334 1.10 mycroft return (0);
335 1.10 mycroft #endif
336 1.10 mycroft #ifdef WSDISPLAY_COMPAT_SYSCONS
337 1.10 mycroft case CONS_GETVERS:
338 1.10 mycroft *(int *)data = 0x200; /* version 2.0 */
339 1.10 mycroft return (0);
340 1.10 mycroft #endif
341 1.10 mycroft
342 1.10 mycroft default:
343 1.10 mycroft return (-1);
344 1.10 mycroft }
345 1.10 mycroft
346 1.10 mycroft return (0);
347 1.10 mycroft }
348 1.10 mycroft
349 1.10 mycroft int
350 1.16 augustss wsdisplay_usl_ioctl2(struct wsdisplay_softc *sc, struct wsscreen *scr,
351 1.16 augustss u_long cmd, caddr_t data, int flag, struct proc *p)
352 1.1 drochner {
353 1.15 simonb int intarg, res;
354 1.13 simonb u_long req;
355 1.15 simonb void *arg;
356 1.1 drochner struct usl_syncdata *sd;
357 1.1 drochner struct wskbd_bell_data bd;
358 1.1 drochner
359 1.1 drochner switch (cmd) {
360 1.1 drochner case VT_SETMODE:
361 1.1 drochner #define newmode ((struct vt_mode *)data)
362 1.1 drochner if (newmode->mode == VT_PROCESS) {
363 1.3 drochner res = usl_sync_init(scr, &sd, p, newmode->acqsig,
364 1.3 drochner newmode->relsig, newmode->frsig);
365 1.1 drochner if (res)
366 1.1 drochner return (res);
367 1.1 drochner } else {
368 1.1 drochner sd = usl_sync_get(scr);
369 1.1 drochner if (sd)
370 1.1 drochner usl_sync_done(sd);
371 1.1 drochner }
372 1.1 drochner #undef newmode
373 1.1 drochner return (0);
374 1.1 drochner case VT_GETMODE:
375 1.1 drochner #define cmode ((struct vt_mode *)data)
376 1.1 drochner sd = usl_sync_get(scr);
377 1.1 drochner if (sd) {
378 1.1 drochner cmode->mode = VT_PROCESS;
379 1.1 drochner cmode->relsig = sd->s_relsig;
380 1.1 drochner cmode->acqsig = sd->s_acqsig;
381 1.1 drochner cmode->frsig = sd->s_frsig;
382 1.1 drochner } else
383 1.1 drochner cmode->mode = VT_AUTO;
384 1.1 drochner #undef cmode
385 1.1 drochner return (0);
386 1.1 drochner case VT_RELDISP:
387 1.1 drochner #define d (*(int *)data)
388 1.1 drochner sd = usl_sync_get(scr);
389 1.1 drochner if (!sd)
390 1.1 drochner return (EINVAL);
391 1.1 drochner switch (d) {
392 1.1 drochner case VT_FALSE:
393 1.1 drochner case VT_TRUE:
394 1.1 drochner return (usl_detachack(sd, (d == VT_TRUE)));
395 1.1 drochner case VT_ACKACQ:
396 1.1 drochner return (usl_attachack(sd, 1));
397 1.1 drochner default:
398 1.1 drochner return (EINVAL);
399 1.1 drochner }
400 1.1 drochner #undef d
401 1.1 drochner return (0);
402 1.10 mycroft
403 1.1 drochner case KDENABIO:
404 1.1 drochner if (suser(p->p_ucred, &p->p_acflag) || securelevel > 1)
405 1.1 drochner return (EPERM);
406 1.1 drochner /* FALLTHRU */
407 1.1 drochner case KDDISABIO:
408 1.1 drochner #if defined(__i386__)
409 1.1 drochner #if defined(COMPAT_10) || defined(COMPAT_11) || defined(COMPAT_FREEBSD)
410 1.1 drochner {
411 1.1 drochner struct trapframe *fp = (struct trapframe *)p->p_md.md_regs;
412 1.1 drochner if (cmd == KDENABIO)
413 1.1 drochner fp->tf_eflags |= PSL_IOPL;
414 1.1 drochner else
415 1.1 drochner fp->tf_eflags &= ~PSL_IOPL;
416 1.1 drochner }
417 1.1 drochner #endif
418 1.1 drochner #endif
419 1.1 drochner return (0);
420 1.1 drochner case KDSETRAD:
421 1.1 drochner /* XXX ignore for now */
422 1.1 drochner return (0);
423 1.1 drochner
424 1.1 drochner default:
425 1.1 drochner return (-1);
426 1.1 drochner
427 1.1 drochner /*
428 1.1 drochner * the following are converted to wsdisplay ioctls
429 1.1 drochner */
430 1.1 drochner case KDSETMODE:
431 1.1 drochner req = WSDISPLAYIO_SMODE;
432 1.1 drochner #define d (*(int *)data)
433 1.1 drochner switch (d) {
434 1.1 drochner case KD_GRAPHICS:
435 1.1 drochner intarg = WSDISPLAYIO_MODE_MAPPED;
436 1.1 drochner break;
437 1.1 drochner case KD_TEXT:
438 1.1 drochner intarg = WSDISPLAYIO_MODE_EMUL;
439 1.1 drochner break;
440 1.1 drochner default:
441 1.1 drochner return (EINVAL);
442 1.1 drochner }
443 1.1 drochner #undef d
444 1.1 drochner arg = &intarg;
445 1.1 drochner break;
446 1.1 drochner case KDMKTONE:
447 1.1 drochner req = WSKBDIO_COMPLEXBELL;
448 1.1 drochner #define d (*(int *)data)
449 1.1 drochner if (d) {
450 1.8 christos #define PCVT_SYSBEEPF 1193182
451 1.8 christos if (d >> 16) {
452 1.8 christos bd.which = WSKBD_BELL_DOPERIOD;
453 1.8 christos bd.period = d >> 16; /* ms */
454 1.8 christos }
455 1.9 christos else
456 1.9 christos bd.which = 0;
457 1.8 christos if (d & 0xffff) {
458 1.8 christos bd.which |= WSKBD_BELL_DOPITCH;
459 1.8 christos bd.pitch = PCVT_SYSBEEPF/(d & 0xffff); /* Hz */
460 1.8 christos }
461 1.1 drochner } else
462 1.1 drochner bd.which = 0; /* default */
463 1.1 drochner #undef d
464 1.1 drochner arg = &bd;
465 1.1 drochner break;
466 1.1 drochner case KDSETLED:
467 1.1 drochner req = WSKBDIO_SETLEDS;
468 1.1 drochner intarg = 0;
469 1.1 drochner #define d (*(int *)data)
470 1.1 drochner if (d & LED_CAP)
471 1.1 drochner intarg |= WSKBD_LED_CAPS;
472 1.1 drochner if (d & LED_NUM)
473 1.1 drochner intarg |= WSKBD_LED_NUM;
474 1.1 drochner if (d & LED_SCR)
475 1.1 drochner intarg |= WSKBD_LED_SCROLL;
476 1.1 drochner #undef d
477 1.1 drochner arg = &intarg;
478 1.1 drochner break;
479 1.1 drochner case KDGETLED:
480 1.1 drochner req = WSKBDIO_GETLEDS;
481 1.1 drochner arg = &intarg;
482 1.1 drochner break;
483 1.1 drochner #ifdef WSDISPLAY_COMPAT_RAWKBD
484 1.1 drochner case KDSKBMODE:
485 1.1 drochner req = WSKBDIO_SETMODE;
486 1.1 drochner switch (*(int *)data) {
487 1.1 drochner case K_RAW:
488 1.1 drochner intarg = WSKBD_RAW;
489 1.1 drochner break;
490 1.1 drochner case K_XLATE:
491 1.1 drochner intarg = WSKBD_TRANSLATED;
492 1.1 drochner break;
493 1.1 drochner default:
494 1.1 drochner return (EINVAL);
495 1.1 drochner }
496 1.1 drochner arg = &intarg;
497 1.1 drochner break;
498 1.1 drochner case KDGKBMODE:
499 1.1 drochner req = WSKBDIO_GETMODE;
500 1.1 drochner arg = &intarg;
501 1.1 drochner break;
502 1.1 drochner #endif
503 1.1 drochner }
504 1.1 drochner
505 1.1 drochner res = wsdisplay_internal_ioctl(sc, scr, req, arg, flag, p);
506 1.1 drochner if (res)
507 1.1 drochner return (res);
508 1.1 drochner
509 1.1 drochner switch (cmd) {
510 1.1 drochner case KDGETLED:
511 1.1 drochner #define d (*(int *)data)
512 1.1 drochner d = 0;
513 1.1 drochner if (intarg & WSKBD_LED_CAPS)
514 1.1 drochner d |= LED_CAP;
515 1.1 drochner if (intarg & WSKBD_LED_NUM)
516 1.1 drochner d |= LED_NUM;
517 1.1 drochner if (intarg & WSKBD_LED_SCROLL)
518 1.1 drochner d |= LED_SCR;
519 1.1 drochner #undef d
520 1.1 drochner break;
521 1.1 drochner #ifdef WSDISPLAY_COMPAT_RAWKBD
522 1.1 drochner case KDGKBMODE:
523 1.1 drochner *(int *)data = (intarg == WSKBD_RAW ? K_RAW : K_XLATE);
524 1.1 drochner break;
525 1.1 drochner #endif
526 1.1 drochner }
527 1.1 drochner
528 1.1 drochner return (0);
529 1.1 drochner }
530