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