2006-03-29 10:28:38 +04:00
|
|
|
/* $NetBSD: hpckbd.c,v 1.17 2006/03/29 06:37:35 thorpej Exp $ */
|
2000-09-21 18:17:29 +04:00
|
|
|
|
|
|
|
/*-
|
2001-02-22 21:37:54 +03:00
|
|
|
* Copyright (c) 1999-2001 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by UCHIYAMA Yasushi.
|
2000-09-21 18:17:29 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2001-02-22 21:37:54 +03:00
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
2000-09-21 18:17:29 +04:00
|
|
|
*
|
2001-02-22 21:37:54 +03:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
2000-09-21 18:17:29 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-13 15:47:33 +03:00
|
|
|
#include <sys/cdefs.h>
|
2006-03-29 10:28:38 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.17 2006/03/29 06:37:35 thorpej Exp $");
|
2001-11-13 15:47:33 +03:00
|
|
|
|
2000-09-21 18:17:29 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
#include <sys/tty.h>
|
2000-09-21 18:17:29 +04:00
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/intr.h>
|
|
|
|
|
|
|
|
#include <machine/config_hook.h>
|
|
|
|
#include <machine/platid.h>
|
|
|
|
#include <machine/platid_mask.h>
|
|
|
|
|
|
|
|
#include "opt_wsdisplay_compat.h"
|
2000-10-21 11:27:41 +04:00
|
|
|
#include "opt_pckbd_layout.h"
|
2000-09-21 18:17:29 +04:00
|
|
|
#include <dev/wscons/wsksymdef.h>
|
|
|
|
#include <dev/wscons/wsconsio.h>
|
|
|
|
#include <dev/wscons/wskbdvar.h>
|
|
|
|
#include <dev/wscons/wsksymdef.h>
|
|
|
|
#include <dev/wscons/wsksymvar.h>
|
2004-03-13 20:31:33 +03:00
|
|
|
#include <dev/pckbport/wskbdmap_mfii.h>
|
2000-09-21 18:17:29 +04:00
|
|
|
#ifdef WSDISPLAY_COMPAT_RAWKBD
|
2001-02-22 21:37:54 +03:00
|
|
|
#include <dev/hpc/pckbd_encode.h>
|
2000-09-21 18:17:29 +04:00
|
|
|
#endif
|
|
|
|
|
2001-02-22 21:37:54 +03:00
|
|
|
#include <dev/hpc/hpckbdvar.h>
|
|
|
|
#include <dev/hpc/hpckbdkeymap.h>
|
2000-09-21 18:17:29 +04:00
|
|
|
|
|
|
|
struct hpckbd_softc;
|
|
|
|
|
|
|
|
#define NEVENTQ 32
|
|
|
|
struct hpckbd_eventq {
|
|
|
|
u_int hq_type;
|
|
|
|
int hq_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hpckbd_core {
|
|
|
|
struct hpckbd_if hc_if;
|
|
|
|
struct hpckbd_ic_if *hc_ic;
|
2006-02-13 02:19:14 +03:00
|
|
|
const uint8_t *hc_keymap;
|
2000-09-21 18:17:29 +04:00
|
|
|
const int *hc_special;
|
|
|
|
int hc_polling;
|
|
|
|
int hc_console;
|
|
|
|
#define NEVENTQ 32
|
|
|
|
struct hpckbd_eventq hc_eventq[NEVENTQ];
|
|
|
|
struct hpckbd_eventq *hc_head, *hc_tail;
|
|
|
|
int hc_nevents;
|
|
|
|
int hc_enabled;
|
|
|
|
struct device *hc_wskbddev;
|
|
|
|
struct hpckbd_softc* hc_sc; /* back link */
|
|
|
|
#ifdef WSDISPLAY_COMPAT_RAWKBD
|
|
|
|
int hc_rawkbd;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hpckbd_softc {
|
|
|
|
struct device sc_dev;
|
|
|
|
struct hpckbd_core *sc_core;
|
|
|
|
struct hpckbd_core sc_coredata;
|
|
|
|
};
|
|
|
|
|
2001-02-22 21:37:54 +03:00
|
|
|
int hpckbd_match(struct device *, struct cfdata *, void *);
|
|
|
|
void hpckbd_attach(struct device *, struct device *, void *);
|
2000-09-21 18:17:29 +04:00
|
|
|
|
2001-02-22 21:37:54 +03:00
|
|
|
void hpckbd_initcore(struct hpckbd_core *, struct hpckbd_ic_if *, int);
|
|
|
|
void hpckbd_initif(struct hpckbd_core *);
|
|
|
|
int hpckbd_getevent(struct hpckbd_core *, u_int *, int *);
|
|
|
|
int hpckbd_putevent(struct hpckbd_core *, u_int, int);
|
|
|
|
void hpckbd_keymap_lookup(struct hpckbd_core*);
|
|
|
|
void hpckbd_keymap_setup(struct hpckbd_core *, const keysym_t *, int);
|
|
|
|
int __hpckbd_input(void *, int, int);
|
|
|
|
void __hpckbd_input_hook(void*);
|
2000-09-21 18:17:29 +04:00
|
|
|
|
2002-10-01 01:04:24 +04:00
|
|
|
CFATTACH_DECL(hpckbd, sizeof(struct hpckbd_softc),
|
2002-10-02 20:33:28 +04:00
|
|
|
hpckbd_match, hpckbd_attach, NULL, NULL);
|
2000-09-21 18:17:29 +04:00
|
|
|
|
|
|
|
/* wskbd accessopts */
|
2001-02-22 21:37:54 +03:00
|
|
|
int hpckbd_enable(void *, int);
|
|
|
|
void hpckbd_set_leds(void *, int);
|
2005-12-11 15:16:03 +03:00
|
|
|
int hpckbd_ioctl(void *, u_long, caddr_t, int, struct lwp *);
|
2000-09-21 18:17:29 +04:00
|
|
|
|
|
|
|
/* consopts */
|
|
|
|
struct hpckbd_core hpckbd_consdata;
|
2001-02-22 21:37:54 +03:00
|
|
|
void hpckbd_cngetc(void *, u_int *, int*);
|
|
|
|
void hpckbd_cnpollc(void *, int);
|
2000-09-21 18:17:29 +04:00
|
|
|
|
|
|
|
const struct wskbd_accessops hpckbd_accessops = {
|
|
|
|
hpckbd_enable,
|
|
|
|
hpckbd_set_leds,
|
|
|
|
hpckbd_ioctl,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct wskbd_consops hpckbd_consops = {
|
|
|
|
hpckbd_cngetc,
|
|
|
|
hpckbd_cnpollc,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wskbd_mapdata hpckbd_keymapdata = {
|
|
|
|
pckbd_keydesctab,
|
2000-10-21 11:27:41 +04:00
|
|
|
#ifdef PCKBD_LAYOUT
|
|
|
|
PCKBD_LAYOUT
|
|
|
|
#else
|
2000-09-21 18:17:29 +04:00
|
|
|
KB_US
|
2000-10-21 11:27:41 +04:00
|
|
|
#endif
|
2000-09-21 18:17:29 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
int
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_match(struct device *parent, struct cfdata *cf, void *aux)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_attach(struct device *parent, struct device *self, void *aux)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
struct hpckbd_attach_args *haa = aux;
|
2006-03-29 10:28:38 +04:00
|
|
|
struct hpckbd_softc *sc = device_private(self);
|
2000-09-21 18:17:29 +04:00
|
|
|
struct hpckbd_ic_if *ic = haa->haa_ic;
|
|
|
|
struct wskbddev_attach_args wa;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize core if it isn't console
|
|
|
|
*/
|
|
|
|
if (hpckbd_consdata.hc_ic == ic) {
|
|
|
|
sc->sc_core = &hpckbd_consdata;
|
|
|
|
/* The core has been initialized in hpckbd_cnattach. */
|
|
|
|
} else {
|
|
|
|
sc->sc_core = &sc->sc_coredata;
|
|
|
|
hpckbd_initcore(sc->sc_core, ic, 0 /* not console */);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->sc_core->hc_keymap == default_keymap)
|
|
|
|
printf(": no keymap.");
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2000-09-21 18:17:29 +04:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* setup hpckbd public interface for parent controller.
|
|
|
|
*/
|
|
|
|
hpckbd_initif(sc->sc_core);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* attach wskbd
|
|
|
|
*/
|
|
|
|
wa.console = sc->sc_core->hc_console;
|
|
|
|
wa.keymap = &hpckbd_keymapdata;
|
|
|
|
wa.accessops = &hpckbd_accessops;
|
|
|
|
wa.accesscookie = sc->sc_core;
|
|
|
|
sc->sc_core->hc_wskbddev = config_found(self, &wa, wskbddevprint);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_print(void *aux, const char *pnp)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
return (pnp ? QUIET : UNCONF);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_initcore(struct hpckbd_core *hc, struct hpckbd_ic_if *ic, int console)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
hc->hc_polling = 0;
|
|
|
|
hc->hc_console = console;
|
|
|
|
hc->hc_ic = ic;
|
|
|
|
|
|
|
|
/* setup event queue */
|
|
|
|
hc->hc_head = hc->hc_tail = hc->hc_eventq;
|
|
|
|
hc->hc_nevents = 0;
|
|
|
|
|
|
|
|
hpckbd_keymap_lookup(hc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_initif(struct hpckbd_core *hc)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
struct hpckbd_if *kbdif = &hc->hc_if;
|
|
|
|
|
|
|
|
kbdif->hi_ctx = hc;
|
|
|
|
kbdif->hi_input = __hpckbd_input;
|
|
|
|
kbdif->hi_input_hook = __hpckbd_input_hook;
|
|
|
|
hpckbd_ic_establish(hc->hc_ic, &hc->hc_if);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_putevent(struct hpckbd_core* hc, u_int type, int data)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
2001-05-08 21:23:09 +04:00
|
|
|
int s = spltty();
|
|
|
|
|
|
|
|
if (hc->hc_nevents == NEVENTQ) {
|
|
|
|
splx(s);
|
2000-09-21 18:17:29 +04:00
|
|
|
return (0); /* queue is full */
|
2001-05-08 21:23:09 +04:00
|
|
|
}
|
2000-09-21 18:17:29 +04:00
|
|
|
|
|
|
|
hc->hc_nevents++;
|
|
|
|
hc->hc_tail->hq_type = type;
|
|
|
|
hc->hc_tail->hq_data = data;
|
|
|
|
if (&hc->hc_eventq[NEVENTQ] <= ++hc->hc_tail)
|
|
|
|
hc->hc_tail = hc->hc_eventq;
|
2001-05-08 21:23:09 +04:00
|
|
|
splx(s);
|
2000-09-21 18:17:29 +04:00
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_getevent(struct hpckbd_core* hc, u_int *type, int *data)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
2001-05-08 21:23:09 +04:00
|
|
|
int s = spltty();
|
|
|
|
|
|
|
|
if (hc->hc_nevents == 0) {
|
|
|
|
splx(s);
|
2000-09-21 18:17:29 +04:00
|
|
|
return (0); /* queue is empty */
|
2001-05-08 21:23:09 +04:00
|
|
|
}
|
2000-09-21 18:17:29 +04:00
|
|
|
|
|
|
|
*type = hc->hc_head->hq_type;
|
|
|
|
*data = hc->hc_head->hq_data;
|
|
|
|
hc->hc_nevents--;
|
|
|
|
if (&hc->hc_eventq[NEVENTQ] <= ++hc->hc_head)
|
|
|
|
hc->hc_head = hc->hc_eventq;
|
2001-05-08 21:23:09 +04:00
|
|
|
splx(s);
|
2000-09-21 18:17:29 +04:00
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2000-10-01 07:45:33 +04:00
|
|
|
void
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_keymap_setup(struct hpckbd_core *hc, const keysym_t *map, int mapsize)
|
2000-10-01 07:45:33 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct wscons_keydesc *desc;
|
|
|
|
|
|
|
|
/* fix keydesc table */
|
2005-06-08 11:49:45 +04:00
|
|
|
/*
|
|
|
|
* XXX The way this is done is really wrong. The __UNCONST()
|
2006-02-13 02:19:14 +03:00
|
|
|
* is a hint as to what is wrong. This actually ends up modifying
|
2005-06-08 11:49:45 +04:00
|
|
|
* initialized data which is marked "const".
|
|
|
|
* The reason we get away with it here is apparently that text
|
|
|
|
* and read-only data gets mapped read/write on the platforms
|
|
|
|
* using this code.
|
|
|
|
*/
|
|
|
|
desc = (struct wscons_keydesc *)__UNCONST(hpckbd_keymapdata.keydesc);
|
2000-10-01 07:45:33 +04:00
|
|
|
for (i = 0; desc[i].name != 0; i++) {
|
|
|
|
if ((desc[i].name & KB_MACHDEP) && desc[i].map == NULL) {
|
|
|
|
desc[i].map = map;
|
|
|
|
desc[i].map_size = mapsize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-09-21 18:17:29 +04:00
|
|
|
void
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_keymap_lookup(struct hpckbd_core *hc)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
const struct hpckbd_keymap_table *tab;
|
|
|
|
platid_mask_t mask;
|
|
|
|
|
|
|
|
for (tab = hpckbd_keymap_table; tab->ht_platform != NULL; tab++) {
|
|
|
|
|
|
|
|
mask = PLATID_DEREF(tab->ht_platform);
|
|
|
|
|
|
|
|
if (platid_match(&platid, &mask)) {
|
|
|
|
hc->hc_keymap = tab->ht_keymap;
|
|
|
|
hc->hc_special = tab->ht_special;
|
|
|
|
#if !defined(PCKBD_LAYOUT)
|
|
|
|
hpckbd_keymapdata.layout = tab->ht_layout;
|
|
|
|
#endif
|
2000-10-01 07:45:33 +04:00
|
|
|
if (tab->ht_cmdmap.map) {
|
2005-02-27 03:26:58 +03:00
|
|
|
hpckbd_keymap_setup(hc, tab->ht_cmdmap.map,
|
2001-05-08 21:23:09 +04:00
|
|
|
tab->ht_cmdmap.size);
|
2000-10-01 07:45:33 +04:00
|
|
|
#if !defined(PCKBD_LAYOUT)
|
|
|
|
hpckbd_keymapdata.layout |= KB_MACHDEP;
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
hpckbd_keymapdata.layout &= ~KB_MACHDEP;
|
|
|
|
}
|
2000-09-21 18:17:29 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no keymap. use default. */
|
|
|
|
hc->hc_keymap = default_keymap;
|
|
|
|
hc->hc_special = default_special_keymap;
|
|
|
|
#if !defined(PCKBD_LAYOUT)
|
|
|
|
hpckbd_keymapdata.layout = KB_US;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-02-22 21:37:54 +03:00
|
|
|
__hpckbd_input_hook(void *arg)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
struct hpckbd_core *hc = arg;
|
|
|
|
|
|
|
|
if (hc->hc_polling) {
|
|
|
|
hc->hc_type = WSCONS_EVENT_ALL_KEYS_UP;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-02-22 21:37:54 +03:00
|
|
|
__hpckbd_input(void *arg, int flag, int scancode)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
struct hpckbd_core *hc = arg;
|
|
|
|
int type, key;
|
|
|
|
|
|
|
|
if (flag) {
|
2005-02-27 03:26:58 +03:00
|
|
|
type = WSCONS_EVENT_KEY_DOWN;
|
2000-09-21 18:17:29 +04:00
|
|
|
} else {
|
|
|
|
type = WSCONS_EVENT_KEY_UP;
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2006-02-13 19:35:57 +03:00
|
|
|
key = hc->hc_keymap[scancode];
|
|
|
|
if (key == UNK) {
|
2001-03-01 19:41:36 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("hpckbd: unknown scan code %#x (%d, %d)\n",
|
2001-05-08 21:23:09 +04:00
|
|
|
scancode, scancode >> 3,
|
|
|
|
scancode - ((scancode >> 3) << 3));
|
2001-03-01 19:41:36 +03:00
|
|
|
#endif /* DEBUG */
|
2000-09-21 18:17:29 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key == IGN) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key == SPL) {
|
|
|
|
if (!flag)
|
|
|
|
return (0);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-05-08 21:23:09 +04:00
|
|
|
if (scancode == hc->hc_special[KEY_SPECIAL_OFF]) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("off button\n"); // XXX notyet -uch
|
|
|
|
#endif
|
|
|
|
} else if (scancode == hc->hc_special[KEY_SPECIAL_LIGHT]) {
|
2000-10-22 14:42:31 +04:00
|
|
|
static int onoff; /* XXX -uch */
|
2000-09-21 18:17:29 +04:00
|
|
|
config_hook_call(CONFIG_HOOK_BUTTONEVENT,
|
2001-05-08 21:23:09 +04:00
|
|
|
CONFIG_HOOK_BUTTONEVENT_LIGHT,
|
|
|
|
(void *)(onoff ^= 1));
|
|
|
|
} else {
|
|
|
|
#ifdef DEBUG
|
2000-09-21 18:17:29 +04:00
|
|
|
printf("unknown special key %d\n", scancode);
|
2001-05-08 21:23:09 +04:00
|
|
|
#endif
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2000-09-21 18:17:29 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hc->hc_polling) {
|
2006-02-13 02:19:14 +03:00
|
|
|
if (hpckbd_putevent(hc, type, key) == 0)
|
|
|
|
printf("hpckbd: queue over flow\n");
|
2000-09-21 18:17:29 +04:00
|
|
|
} else {
|
|
|
|
#ifdef WSDISPLAY_COMPAT_RAWKBD
|
|
|
|
if (hc->hc_rawkbd) {
|
|
|
|
int n;
|
|
|
|
u_char data[16];
|
2006-02-13 02:19:14 +03:00
|
|
|
n = pckbd_encode(type, key, data);
|
2000-09-21 18:17:29 +04:00
|
|
|
wskbd_rawinput(hc->hc_wskbddev, data, n);
|
|
|
|
} else
|
|
|
|
#endif
|
2006-02-13 02:19:14 +03:00
|
|
|
wskbd_input(hc->hc_wskbddev, type, key);
|
2000-09-21 18:17:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* console support routines
|
|
|
|
*/
|
|
|
|
int
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_cnattach(struct hpckbd_ic_if *ic)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
struct hpckbd_core *hc = &hpckbd_consdata;
|
|
|
|
|
|
|
|
hpckbd_initcore(hc, ic, 1 /* console */);
|
|
|
|
|
|
|
|
/* attach controller */
|
|
|
|
hpckbd_initif(hc);
|
|
|
|
|
|
|
|
/* attach wskbd */
|
|
|
|
wskbd_cnattach(&hpckbd_consops, hc, &hpckbd_keymapdata);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2000-09-21 18:17:29 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_cngetc(void *arg, u_int *type, int *data)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
struct hpckbd_core *hc = arg;
|
|
|
|
|
|
|
|
if (!hc->hc_console || !hc->hc_polling || !hc->hc_ic)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while (hpckbd_getevent(hc, type, data) == 0) /* busy loop */
|
|
|
|
hpckbd_ic_poll(hc->hc_ic);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_cnpollc(void *arg, int on)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
struct hpckbd_core *hc = arg;
|
|
|
|
|
|
|
|
hc->hc_polling = on;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_enable(void *arg, int on)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
struct hpckbd_core *hc = arg;
|
|
|
|
|
|
|
|
if (on) {
|
|
|
|
if (hc->hc_enabled)
|
|
|
|
return (EBUSY);
|
|
|
|
hc->hc_enabled = 1;
|
|
|
|
} else {
|
|
|
|
if (hc->hc_console)
|
|
|
|
return (EBUSY);
|
|
|
|
hc->hc_enabled = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-02-22 21:37:54 +03:00
|
|
|
hpckbd_set_leds(void *arg, int leds)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
/* Can you find any LED which tells you about keyboard? */
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-12-11 15:16:03 +03:00
|
|
|
hpckbd_ioctl(void *arg, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
2000-09-21 18:17:29 +04:00
|
|
|
{
|
|
|
|
#ifdef WSDISPLAY_COMPAT_RAWKBD
|
|
|
|
struct hpckbd_core *hc = arg;
|
|
|
|
#endif
|
|
|
|
switch (cmd) {
|
|
|
|
case WSKBDIO_GTYPE:
|
|
|
|
*(int *)data = WSKBD_TYPE_HPC_KBD;
|
|
|
|
return (0);
|
2001-01-10 11:43:13 +03:00
|
|
|
case WSKBDIO_SETLEDS:
|
|
|
|
return 0;
|
|
|
|
case WSKBDIO_GETLEDS:
|
|
|
|
*(int *)data = 0; /* dummy for wsconsctl(8) */
|
|
|
|
return (0);
|
2000-09-21 18:17:29 +04:00
|
|
|
#ifdef WSDISPLAY_COMPAT_RAWKBD
|
|
|
|
case WSKBDIO_SETMODE:
|
|
|
|
hc->hc_rawkbd = (*(int *)data == WSKBD_RAW);
|
|
|
|
return (0);
|
|
|
|
#endif
|
|
|
|
}
|
2002-03-17 22:40:26 +03:00
|
|
|
return (EPASSTHROUGH);
|
2000-09-21 18:17:29 +04:00
|
|
|
}
|