hpckbd.c revision 1.36 1 1.36 thorpej /* $NetBSD: hpckbd.c,v 1.36 2021/04/24 23:36:54 thorpej Exp $ */
2 1.1 uch
3 1.1 uch /*-
4 1.1 uch * Copyright (c) 1999-2001 The NetBSD Foundation, Inc.
5 1.1 uch * All rights reserved.
6 1.1 uch *
7 1.1 uch * This code is derived from software contributed to The NetBSD Foundation
8 1.1 uch * by UCHIYAMA Yasushi.
9 1.1 uch *
10 1.1 uch * Redistribution and use in source and binary forms, with or without
11 1.1 uch * modification, are permitted provided that the following conditions
12 1.1 uch * are met:
13 1.1 uch * 1. Redistributions of source code must retain the above copyright
14 1.1 uch * notice, this list of conditions and the following disclaimer.
15 1.1 uch * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 uch * notice, this list of conditions and the following disclaimer in the
17 1.1 uch * documentation and/or other materials provided with the distribution.
18 1.1 uch *
19 1.1 uch * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 uch * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 uch * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 uch * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 uch * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 uch * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 uch * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 uch * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 uch * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 uch * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 uch * POSSIBILITY OF SUCH DAMAGE.
30 1.1 uch */
31 1.6 lukem
32 1.6 lukem #include <sys/cdefs.h>
33 1.36 thorpej __KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.36 2021/04/24 23:36:54 thorpej Exp $");
34 1.1 uch
35 1.1 uch #include <sys/param.h>
36 1.1 uch #include <sys/systm.h>
37 1.1 uch #include <sys/device.h>
38 1.31 manu #include <sys/malloc.h>
39 1.1 uch
40 1.12 perry #include <sys/tty.h>
41 1.1 uch
42 1.24 ad #include <sys/bus.h>
43 1.24 ad #include <sys/intr.h>
44 1.1 uch
45 1.1 uch #include <machine/config_hook.h>
46 1.1 uch #include <machine/platid.h>
47 1.1 uch #include <machine/platid_mask.h>
48 1.1 uch
49 1.1 uch #include "opt_wsdisplay_compat.h"
50 1.1 uch #include "opt_pckbd_layout.h"
51 1.1 uch #include <dev/wscons/wsksymdef.h>
52 1.1 uch #include <dev/wscons/wsconsio.h>
53 1.1 uch #include <dev/wscons/wskbdvar.h>
54 1.1 uch #include <dev/wscons/wsksymvar.h>
55 1.11 bjh21 #include <dev/pckbport/wskbdmap_mfii.h>
56 1.1 uch #ifdef WSDISPLAY_COMPAT_RAWKBD
57 1.1 uch #include <dev/hpc/pckbd_encode.h>
58 1.1 uch #endif
59 1.1 uch
60 1.1 uch #include <dev/hpc/hpckbdvar.h>
61 1.1 uch #include <dev/hpc/hpckbdkeymap.h>
62 1.1 uch
63 1.1 uch struct hpckbd_softc;
64 1.1 uch
65 1.1 uch #define NEVENTQ 32
66 1.1 uch struct hpckbd_eventq {
67 1.1 uch u_int hq_type;
68 1.1 uch int hq_data;
69 1.1 uch };
70 1.1 uch
71 1.1 uch struct hpckbd_core {
72 1.1 uch struct hpckbd_if hc_if;
73 1.1 uch struct hpckbd_ic_if *hc_ic;
74 1.15 peter const uint8_t *hc_keymap;
75 1.1 uch const int *hc_special;
76 1.1 uch int hc_polling;
77 1.1 uch int hc_console;
78 1.1 uch #define NEVENTQ 32
79 1.1 uch struct hpckbd_eventq hc_eventq[NEVENTQ];
80 1.1 uch struct hpckbd_eventq *hc_head, *hc_tail;
81 1.1 uch int hc_nevents;
82 1.1 uch int hc_enabled;
83 1.30 chs device_t hc_wskbddev;
84 1.30 chs struct hpckbd_softc *hc_sc; /* back link */
85 1.1 uch #ifdef WSDISPLAY_COMPAT_RAWKBD
86 1.1 uch int hc_rawkbd;
87 1.1 uch #endif
88 1.1 uch };
89 1.1 uch
90 1.1 uch struct hpckbd_softc {
91 1.29 nonaka device_t sc_dev;
92 1.1 uch struct hpckbd_core *sc_core;
93 1.1 uch struct hpckbd_core sc_coredata;
94 1.1 uch };
95 1.1 uch
96 1.28 cegger int hpckbd_match(device_t, cfdata_t, void *);
97 1.28 cegger void hpckbd_attach(device_t, device_t, void *);
98 1.1 uch
99 1.1 uch void hpckbd_initcore(struct hpckbd_core *, struct hpckbd_ic_if *, int);
100 1.1 uch void hpckbd_initif(struct hpckbd_core *);
101 1.1 uch int hpckbd_getevent(struct hpckbd_core *, u_int *, int *);
102 1.1 uch int hpckbd_putevent(struct hpckbd_core *, u_int, int);
103 1.1 uch void hpckbd_keymap_lookup(struct hpckbd_core*);
104 1.1 uch void hpckbd_keymap_setup(struct hpckbd_core *, const keysym_t *, int);
105 1.1 uch int __hpckbd_input(void *, int, int);
106 1.18 peter void __hpckbd_input_hook(void *);
107 1.1 uch
108 1.29 nonaka CFATTACH_DECL_NEW(hpckbd, sizeof(struct hpckbd_softc),
109 1.10 thorpej hpckbd_match, hpckbd_attach, NULL, NULL);
110 1.1 uch
111 1.1 uch /* wskbd accessopts */
112 1.1 uch int hpckbd_enable(void *, int);
113 1.1 uch void hpckbd_set_leds(void *, int);
114 1.22 christos int hpckbd_ioctl(void *, u_long, void *, int, struct lwp *);
115 1.1 uch
116 1.1 uch /* consopts */
117 1.1 uch struct hpckbd_core hpckbd_consdata;
118 1.1 uch void hpckbd_cngetc(void *, u_int *, int*);
119 1.1 uch void hpckbd_cnpollc(void *, int);
120 1.1 uch
121 1.1 uch const struct wskbd_accessops hpckbd_accessops = {
122 1.1 uch hpckbd_enable,
123 1.1 uch hpckbd_set_leds,
124 1.1 uch hpckbd_ioctl,
125 1.1 uch };
126 1.1 uch
127 1.1 uch const struct wskbd_consops hpckbd_consops = {
128 1.1 uch hpckbd_cngetc,
129 1.1 uch hpckbd_cnpollc,
130 1.19 uwe NULL,
131 1.1 uch };
132 1.1 uch
133 1.1 uch struct wskbd_mapdata hpckbd_keymapdata = {
134 1.1 uch pckbd_keydesctab,
135 1.1 uch #ifdef PCKBD_LAYOUT
136 1.1 uch PCKBD_LAYOUT
137 1.1 uch #else
138 1.1 uch KB_US
139 1.1 uch #endif
140 1.1 uch };
141 1.1 uch
142 1.1 uch int
143 1.29 nonaka hpckbd_match(device_t parent, cfdata_t cf, void *aux)
144 1.1 uch {
145 1.1 uch return (1);
146 1.1 uch }
147 1.1 uch
148 1.1 uch void
149 1.28 cegger hpckbd_attach(device_t parent, device_t self, void *aux)
150 1.1 uch {
151 1.1 uch struct hpckbd_attach_args *haa = aux;
152 1.17 thorpej struct hpckbd_softc *sc = device_private(self);
153 1.1 uch struct hpckbd_ic_if *ic = haa->haa_ic;
154 1.1 uch struct wskbddev_attach_args wa;
155 1.1 uch
156 1.29 nonaka sc->sc_dev = self;
157 1.29 nonaka
158 1.1 uch /*
159 1.1 uch * Initialize core if it isn't console
160 1.1 uch */
161 1.1 uch if (hpckbd_consdata.hc_ic == ic) {
162 1.1 uch sc->sc_core = &hpckbd_consdata;
163 1.1 uch /* The core has been initialized in hpckbd_cnattach. */
164 1.1 uch } else {
165 1.1 uch sc->sc_core = &sc->sc_coredata;
166 1.1 uch hpckbd_initcore(sc->sc_core, ic, 0 /* not console */);
167 1.1 uch }
168 1.1 uch
169 1.1 uch if (sc->sc_core->hc_keymap == default_keymap)
170 1.1 uch printf(": no keymap.");
171 1.12 perry
172 1.1 uch printf("\n");
173 1.1 uch
174 1.1 uch /*
175 1.1 uch * setup hpckbd public interface for parent controller.
176 1.1 uch */
177 1.1 uch hpckbd_initif(sc->sc_core);
178 1.1 uch
179 1.1 uch /*
180 1.1 uch * attach wskbd
181 1.1 uch */
182 1.1 uch wa.console = sc->sc_core->hc_console;
183 1.1 uch wa.keymap = &hpckbd_keymapdata;
184 1.1 uch wa.accessops = &hpckbd_accessops;
185 1.1 uch wa.accesscookie = sc->sc_core;
186 1.36 thorpej sc->sc_core->hc_wskbddev = config_found(self, &wa, wskbddevprint,
187 1.36 thorpej CFARG_EOL);
188 1.26 uwe
189 1.26 uwe if (!pmf_device_register(self, NULL, NULL))
190 1.26 uwe aprint_error_dev(self, "unable to establish power handler\n");
191 1.1 uch }
192 1.1 uch
193 1.1 uch int
194 1.20 christos hpckbd_print(void *aux, const char *pnp)
195 1.1 uch {
196 1.1 uch return (pnp ? QUIET : UNCONF);
197 1.1 uch }
198 1.1 uch
199 1.1 uch void
200 1.1 uch hpckbd_initcore(struct hpckbd_core *hc, struct hpckbd_ic_if *ic, int console)
201 1.1 uch {
202 1.1 uch hc->hc_polling = 0;
203 1.1 uch hc->hc_console = console;
204 1.1 uch hc->hc_ic = ic;
205 1.1 uch
206 1.1 uch /* setup event queue */
207 1.1 uch hc->hc_head = hc->hc_tail = hc->hc_eventq;
208 1.1 uch hc->hc_nevents = 0;
209 1.1 uch
210 1.1 uch hpckbd_keymap_lookup(hc);
211 1.1 uch }
212 1.1 uch
213 1.1 uch void
214 1.1 uch hpckbd_initif(struct hpckbd_core *hc)
215 1.1 uch {
216 1.1 uch struct hpckbd_if *kbdif = &hc->hc_if;
217 1.1 uch
218 1.1 uch kbdif->hi_ctx = hc;
219 1.1 uch kbdif->hi_input = __hpckbd_input;
220 1.1 uch kbdif->hi_input_hook = __hpckbd_input_hook;
221 1.1 uch hpckbd_ic_establish(hc->hc_ic, &hc->hc_if);
222 1.1 uch }
223 1.1 uch
224 1.1 uch int
225 1.1 uch hpckbd_putevent(struct hpckbd_core* hc, u_int type, int data)
226 1.1 uch {
227 1.4 uch int s = spltty();
228 1.4 uch
229 1.4 uch if (hc->hc_nevents == NEVENTQ) {
230 1.4 uch splx(s);
231 1.1 uch return (0); /* queue is full */
232 1.4 uch }
233 1.1 uch
234 1.1 uch hc->hc_nevents++;
235 1.1 uch hc->hc_tail->hq_type = type;
236 1.1 uch hc->hc_tail->hq_data = data;
237 1.1 uch if (&hc->hc_eventq[NEVENTQ] <= ++hc->hc_tail)
238 1.1 uch hc->hc_tail = hc->hc_eventq;
239 1.4 uch splx(s);
240 1.1 uch
241 1.1 uch return (1);
242 1.1 uch }
243 1.1 uch
244 1.1 uch int
245 1.1 uch hpckbd_getevent(struct hpckbd_core* hc, u_int *type, int *data)
246 1.1 uch {
247 1.4 uch int s = spltty();
248 1.4 uch
249 1.4 uch if (hc->hc_nevents == 0) {
250 1.4 uch splx(s);
251 1.1 uch return (0); /* queue is empty */
252 1.4 uch }
253 1.1 uch
254 1.1 uch *type = hc->hc_head->hq_type;
255 1.1 uch *data = hc->hc_head->hq_data;
256 1.1 uch hc->hc_nevents--;
257 1.1 uch if (&hc->hc_eventq[NEVENTQ] <= ++hc->hc_head)
258 1.1 uch hc->hc_head = hc->hc_eventq;
259 1.4 uch splx(s);
260 1.1 uch
261 1.1 uch return (1);
262 1.1 uch }
263 1.1 uch
264 1.32 uwe
265 1.33 rin #if defined(hpcsh) || defined(hpcmips)
266 1.32 uwe /*
267 1.34 uwe * XXX: Use the old wrong code for now as hpcsh and hpcmips attach
268 1.34 uwe * console very early when malloc(9) is not yet available. It is
269 1.34 uwe * convenient to be able to do early DDB on wscons.
270 1.32 uwe */
271 1.32 uwe void
272 1.32 uwe hpckbd_keymap_setup(struct hpckbd_core *hc,
273 1.32 uwe const keysym_t *map, int mapsize)
274 1.32 uwe {
275 1.32 uwe int i;
276 1.32 uwe struct wscons_keydesc *desc;
277 1.32 uwe
278 1.32 uwe /* fix keydesc table */
279 1.32 uwe /*
280 1.32 uwe * XXX The way this is done is really wrong. The __UNCONST()
281 1.32 uwe * is a hint as to what is wrong. This actually ends up modifying
282 1.32 uwe * initialized data which is marked "const".
283 1.33 rin *
284 1.35 uwe * The reason we get away with it here is that on sh3 and mips
285 1.35 uwe * the kernel is directly mapped.
286 1.32 uwe */
287 1.32 uwe desc = (struct wscons_keydesc *)__UNCONST(hpckbd_keymapdata.keydesc);
288 1.32 uwe for (i = 0; desc[i].name != 0; i++) {
289 1.32 uwe if ((desc[i].name & KB_MACHDEP) && desc[i].map == NULL) {
290 1.32 uwe desc[i].map = map;
291 1.32 uwe desc[i].map_size = mapsize;
292 1.32 uwe }
293 1.32 uwe }
294 1.32 uwe
295 1.32 uwe return;
296 1.32 uwe }
297 1.32 uwe
298 1.32 uwe #else
299 1.32 uwe
300 1.1 uch void
301 1.20 christos hpckbd_keymap_setup(struct hpckbd_core *hc,
302 1.19 uwe const keysym_t *map, int mapsize)
303 1.1 uch {
304 1.1 uch int i;
305 1.31 manu const struct wscons_keydesc *desc;
306 1.31 manu static struct wscons_keydesc *ndesc = NULL;
307 1.1 uch
308 1.13 he /*
309 1.31 manu * fix keydesc table. Since it is const data, we must
310 1.31 manu * copy it once before changingg it.
311 1.13 he */
312 1.31 manu
313 1.31 manu if (ndesc == NULL) {
314 1.31 manu size_t sz;
315 1.31 manu
316 1.31 manu for (sz = 0; hpckbd_keymapdata.keydesc[sz].name != 0; sz++);
317 1.31 manu
318 1.31 manu ndesc = malloc(sz * sizeof(*ndesc), M_DEVBUF, M_WAITOK);
319 1.31 manu memcpy(ndesc, hpckbd_keymapdata.keydesc, sz * sizeof(*ndesc));
320 1.31 manu
321 1.31 manu hpckbd_keymapdata.keydesc = ndesc;
322 1.31 manu }
323 1.31 manu
324 1.31 manu desc = hpckbd_keymapdata.keydesc;
325 1.1 uch for (i = 0; desc[i].name != 0; i++) {
326 1.1 uch if ((desc[i].name & KB_MACHDEP) && desc[i].map == NULL) {
327 1.31 manu ndesc[i].map = map;
328 1.31 manu ndesc[i].map_size = mapsize;
329 1.1 uch }
330 1.1 uch }
331 1.1 uch
332 1.1 uch return;
333 1.1 uch }
334 1.32 uwe #endif
335 1.1 uch
336 1.1 uch void
337 1.1 uch hpckbd_keymap_lookup(struct hpckbd_core *hc)
338 1.1 uch {
339 1.1 uch const struct hpckbd_keymap_table *tab;
340 1.1 uch platid_mask_t mask;
341 1.1 uch
342 1.1 uch for (tab = hpckbd_keymap_table; tab->ht_platform != NULL; tab++) {
343 1.1 uch
344 1.1 uch mask = PLATID_DEREF(tab->ht_platform);
345 1.1 uch
346 1.1 uch if (platid_match(&platid, &mask)) {
347 1.1 uch hc->hc_keymap = tab->ht_keymap;
348 1.1 uch hc->hc_special = tab->ht_special;
349 1.1 uch #if !defined(PCKBD_LAYOUT)
350 1.1 uch hpckbd_keymapdata.layout = tab->ht_layout;
351 1.1 uch #endif
352 1.1 uch if (tab->ht_cmdmap.map) {
353 1.12 perry hpckbd_keymap_setup(hc, tab->ht_cmdmap.map,
354 1.4 uch tab->ht_cmdmap.size);
355 1.1 uch #if !defined(PCKBD_LAYOUT)
356 1.1 uch hpckbd_keymapdata.layout |= KB_MACHDEP;
357 1.1 uch #endif
358 1.1 uch } else {
359 1.1 uch hpckbd_keymapdata.layout &= ~KB_MACHDEP;
360 1.1 uch }
361 1.1 uch return;
362 1.1 uch }
363 1.1 uch }
364 1.1 uch
365 1.1 uch /* no keymap. use default. */
366 1.1 uch hc->hc_keymap = default_keymap;
367 1.1 uch hc->hc_special = default_special_keymap;
368 1.1 uch #if !defined(PCKBD_LAYOUT)
369 1.1 uch hpckbd_keymapdata.layout = KB_US;
370 1.1 uch #endif
371 1.1 uch }
372 1.1 uch
373 1.1 uch void
374 1.20 christos __hpckbd_input_hook(void *arg)
375 1.1 uch {
376 1.1 uch #if 0
377 1.1 uch struct hpckbd_core *hc = arg;
378 1.1 uch
379 1.1 uch if (hc->hc_polling) {
380 1.1 uch hc->hc_type = WSCONS_EVENT_ALL_KEYS_UP;
381 1.1 uch }
382 1.1 uch #endif
383 1.1 uch }
384 1.1 uch
385 1.1 uch int
386 1.1 uch __hpckbd_input(void *arg, int flag, int scancode)
387 1.1 uch {
388 1.1 uch struct hpckbd_core *hc = arg;
389 1.1 uch int type, key;
390 1.1 uch
391 1.1 uch if (flag) {
392 1.12 perry type = WSCONS_EVENT_KEY_DOWN;
393 1.1 uch } else {
394 1.1 uch type = WSCONS_EVENT_KEY_UP;
395 1.1 uch }
396 1.12 perry
397 1.16 uwe key = hc->hc_keymap[scancode];
398 1.16 uwe if (key == UNK) {
399 1.2 uch #ifdef DEBUG
400 1.2 uch printf("hpckbd: unknown scan code %#x (%d, %d)\n",
401 1.4 uch scancode, scancode >> 3,
402 1.4 uch scancode - ((scancode >> 3) << 3));
403 1.2 uch #endif /* DEBUG */
404 1.1 uch return (0);
405 1.1 uch }
406 1.1 uch
407 1.1 uch if (key == IGN) {
408 1.1 uch return (0);
409 1.1 uch }
410 1.1 uch
411 1.1 uch if (key == SPL) {
412 1.1 uch if (!flag)
413 1.1 uch return (0);
414 1.12 perry
415 1.4 uch if (scancode == hc->hc_special[KEY_SPECIAL_OFF]) {
416 1.18 peter config_hook_call(CONFIG_HOOK_BUTTONEVENT,
417 1.23 kiyohara CONFIG_HOOK_BUTTONEVENT_POWER, (void *)1 /* on */);
418 1.4 uch } else if (scancode == hc->hc_special[KEY_SPECIAL_LIGHT]) {
419 1.1 uch static int onoff; /* XXX -uch */
420 1.1 uch config_hook_call(CONFIG_HOOK_BUTTONEVENT,
421 1.4 uch CONFIG_HOOK_BUTTONEVENT_LIGHT,
422 1.4 uch (void *)(onoff ^= 1));
423 1.4 uch } else {
424 1.4 uch #ifdef DEBUG
425 1.1 uch printf("unknown special key %d\n", scancode);
426 1.4 uch #endif
427 1.4 uch }
428 1.12 perry
429 1.1 uch return (0);
430 1.1 uch }
431 1.1 uch
432 1.1 uch if (hc->hc_polling) {
433 1.15 peter if (hpckbd_putevent(hc, type, key) == 0)
434 1.15 peter printf("hpckbd: queue over flow\n");
435 1.1 uch } else {
436 1.1 uch #ifdef WSDISPLAY_COMPAT_RAWKBD
437 1.1 uch if (hc->hc_rawkbd) {
438 1.1 uch int n;
439 1.1 uch u_char data[16];
440 1.15 peter n = pckbd_encode(type, key, data);
441 1.1 uch wskbd_rawinput(hc->hc_wskbddev, data, n);
442 1.1 uch } else
443 1.1 uch #endif
444 1.15 peter wskbd_input(hc->hc_wskbddev, type, key);
445 1.1 uch }
446 1.1 uch
447 1.1 uch return (0);
448 1.1 uch }
449 1.1 uch
450 1.1 uch /*
451 1.1 uch * console support routines
452 1.1 uch */
453 1.1 uch int
454 1.1 uch hpckbd_cnattach(struct hpckbd_ic_if *ic)
455 1.1 uch {
456 1.1 uch struct hpckbd_core *hc = &hpckbd_consdata;
457 1.1 uch
458 1.1 uch hpckbd_initcore(hc, ic, 1 /* console */);
459 1.1 uch
460 1.1 uch /* attach controller */
461 1.1 uch hpckbd_initif(hc);
462 1.1 uch
463 1.1 uch /* attach wskbd */
464 1.1 uch wskbd_cnattach(&hpckbd_consops, hc, &hpckbd_keymapdata);
465 1.12 perry
466 1.1 uch return (0);
467 1.1 uch }
468 1.1 uch
469 1.1 uch void
470 1.1 uch hpckbd_cngetc(void *arg, u_int *type, int *data)
471 1.1 uch {
472 1.1 uch struct hpckbd_core *hc = arg;
473 1.1 uch
474 1.1 uch if (!hc->hc_console || !hc->hc_polling || !hc->hc_ic)
475 1.1 uch return;
476 1.1 uch
477 1.1 uch while (hpckbd_getevent(hc, type, data) == 0) /* busy loop */
478 1.1 uch hpckbd_ic_poll(hc->hc_ic);
479 1.1 uch }
480 1.1 uch
481 1.1 uch void
482 1.1 uch hpckbd_cnpollc(void *arg, int on)
483 1.1 uch {
484 1.1 uch struct hpckbd_core *hc = arg;
485 1.1 uch
486 1.1 uch hc->hc_polling = on;
487 1.1 uch }
488 1.1 uch
489 1.1 uch int
490 1.1 uch hpckbd_enable(void *arg, int on)
491 1.1 uch {
492 1.1 uch struct hpckbd_core *hc = arg;
493 1.1 uch
494 1.1 uch if (on) {
495 1.1 uch if (hc->hc_enabled)
496 1.1 uch return (EBUSY);
497 1.1 uch hc->hc_enabled = 1;
498 1.1 uch } else {
499 1.1 uch if (hc->hc_console)
500 1.1 uch return (EBUSY);
501 1.1 uch hc->hc_enabled = 0;
502 1.1 uch }
503 1.1 uch
504 1.1 uch return (0);
505 1.1 uch }
506 1.1 uch
507 1.1 uch void
508 1.20 christos hpckbd_set_leds(void *arg, int leds)
509 1.1 uch {
510 1.1 uch /* Can you find any LED which tells you about keyboard? */
511 1.1 uch }
512 1.1 uch
513 1.1 uch int
514 1.22 christos hpckbd_ioctl(void *arg, u_long cmd, void *data, int flag,
515 1.20 christos struct lwp *l)
516 1.1 uch {
517 1.1 uch #ifdef WSDISPLAY_COMPAT_RAWKBD
518 1.1 uch struct hpckbd_core *hc = arg;
519 1.1 uch #endif
520 1.1 uch switch (cmd) {
521 1.1 uch case WSKBDIO_GTYPE:
522 1.1 uch *(int *)data = WSKBD_TYPE_HPC_KBD;
523 1.1 uch return (0);
524 1.1 uch case WSKBDIO_SETLEDS:
525 1.1 uch return 0;
526 1.1 uch case WSKBDIO_GETLEDS:
527 1.1 uch *(int *)data = 0; /* dummy for wsconsctl(8) */
528 1.1 uch return (0);
529 1.1 uch #ifdef WSDISPLAY_COMPAT_RAWKBD
530 1.1 uch case WSKBDIO_SETMODE:
531 1.1 uch hc->hc_rawkbd = (*(int *)data == WSKBD_RAW);
532 1.1 uch return (0);
533 1.1 uch #endif
534 1.1 uch }
535 1.7 atatat return (EPASSTHROUGH);
536 1.1 uch }
537