/*-
* Copyright (c) 2005 Izumi Tsutsui. All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* Copyright (c) 2004 Steve Rumble
* All rights reserved.
*
* 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.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* EWS4800 serial keyboard driver attached to zs channel 0 at 4800 bps.
* This layer is the parent of wskbd.
*
* This driver is taken from sgimips.
*/
static int
ewskbd_wskbd_enable(void *cookie, int on)
{
struct zs_chanstate *cs;
struct ewskbd_softc *sc;
cs = cookie;
sc = cs->cs_private;
if (on) {
if (sc->sc_dc->enabled)
return EBUSY;
else
sc->sc_dc->enabled = 1;
} else
sc->sc_dc->enabled = 0;
DPRINTF(("ewskbd_wskbd_enable: %s\n", on ? "enabled" : "disabled"));
return 0;
}
static void
ewskbd_wskbd_set_leds(void *cookie, int leds)
{
struct zs_chanstate *cs;
struct ewskbd_softc *sc;
int s;
uint8_t cmd;
cs = cookie;
sc = cs->cs_private;
cmd = 0;
if (leds & WSKBD_LED_CAPS)
cmd |= EWSKBD_CAPSLOCK;
sc->sc_dc->leds = cmd;
cmd |= EWSKBD_SETLEDS;
s = splzs();
ewskbd_zsc_send(cs, &cmd, 1);
splx(s);
}
static int
ewskbd_wskbd_get_leds(void *cookie)
{
struct zs_chanstate *cs;
struct ewskbd_softc *sc;
int leds;
cs = cookie;
sc = cs->cs_private;
leds = 0;
if (sc->sc_dc->leds & EWSKBD_CAPSLOCK)
leds |= WSKBD_LED_CAPS;
return leds;
}
static int
ewskbd_wskbd_ioctl(void *cookie, u_long cmd, void *data, int flag,
struct lwp *l)
{
switch (cmd) {
case WSKBDIO_GTYPE:
*(int *)data = WSKBD_TYPE_EWS4800;
break;
#ifdef notyet
case WSKBDIO_COMPLEXBELL:
case WSKBDIO_SETKEYREPEAT:
case WSKBDIO_GETKEYREPEAT:
case WSKBDIO_SETDEFAULTKEYREPEAT:
case WSKBDIO_GETDEFAULTKEYREPEAT:
#endif
case WSKBDIO_SETLEDS:
ewskbd_wskbd_set_leds(cookie, *(int *)data);
break;
case WSKBDIO_GETLEDS:
*(int *)data = ewskbd_wskbd_get_leds(cookie);
break;
#ifdef notyet
case WSKBDIO_GETMAP:
case WSKBDIO_SETMAP:
case WSKBDIO_GETENCODING:
case WSKBDIO_SETENCODING:
case WSKBDIO_SETMODE:
case WSKBDIO_GETMODE:
case WSKBDIO_SETKEYCLICK:
case WSKBDIO_GETKEYCLICK:
#endif