xref: /openbsd/sys/arch/luna88k/dev/lunaws.c (revision 5b133f3f)
1*5b133f3fSguenther /*	$OpenBSD: lunaws.c,v 1.16 2023/03/08 04:43:07 guenther Exp $	*/
202b01b5eSaoyama /* $NetBSD: lunaws.c,v 1.6 2002/03/17 19:40:42 atatat Exp $ */
302b01b5eSaoyama 
402b01b5eSaoyama /*-
502b01b5eSaoyama  * Copyright (c) 2000 The NetBSD Foundation, Inc.
602b01b5eSaoyama  * All rights reserved.
702b01b5eSaoyama  *
802b01b5eSaoyama  * This code is derived from software contributed to The NetBSD Foundation
902b01b5eSaoyama  * by Tohru Nishimura.
1002b01b5eSaoyama  *
1102b01b5eSaoyama  * Redistribution and use in source and binary forms, with or without
1202b01b5eSaoyama  * modification, are permitted provided that the following conditions
1302b01b5eSaoyama  * are met:
1402b01b5eSaoyama  * 1. Redistributions of source code must retain the above copyright
1502b01b5eSaoyama  *    notice, this list of conditions and the following disclaimer.
1602b01b5eSaoyama  * 2. Redistributions in binary form must reproduce the above copyright
1702b01b5eSaoyama  *    notice, this list of conditions and the following disclaimer in the
1802b01b5eSaoyama  *    documentation and/or other materials provided with the distribution.
1902b01b5eSaoyama  *
2002b01b5eSaoyama  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2102b01b5eSaoyama  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2202b01b5eSaoyama  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2302b01b5eSaoyama  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2402b01b5eSaoyama  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2502b01b5eSaoyama  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2602b01b5eSaoyama  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2702b01b5eSaoyama  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2802b01b5eSaoyama  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2902b01b5eSaoyama  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3002b01b5eSaoyama  * POSSIBILITY OF SUCH DAMAGE.
3102b01b5eSaoyama  */
3202b01b5eSaoyama 
3302b01b5eSaoyama #include <sys/param.h>
3402b01b5eSaoyama #include <sys/systm.h>
3502b01b5eSaoyama #include <sys/conf.h>
3602b01b5eSaoyama #include <sys/device.h>
3702b01b5eSaoyama 
3802b01b5eSaoyama #include <dev/wscons/wsconsio.h>
3902b01b5eSaoyama #include <dev/wscons/wskbdvar.h>
4002b01b5eSaoyama #include <dev/wscons/wsksymdef.h>
4102b01b5eSaoyama #include <dev/wscons/wsksymvar.h>
4213f46f24Saoyama #ifdef WSDISPLAY_COMPAT_RAWKBD
4313f46f24Saoyama #include <dev/wscons/wskbdraw.h>
4413f46f24Saoyama #endif
4551ac1ff4Saoyama #include "wsmouse.h"
4651ac1ff4Saoyama #if NWSMOUSE > 0
4702b01b5eSaoyama #include <dev/wscons/wsmousevar.h>
4851ac1ff4Saoyama #endif
4902b01b5eSaoyama 
5051ac1ff4Saoyama #include <luna88k/dev/omkbdmap.h>
5102b01b5eSaoyama #include <luna88k/dev/sioreg.h>
5202b01b5eSaoyama #include <luna88k/dev/siovar.h>
5302b01b5eSaoyama 
5465958cb6Saoyama #define OMKBD_RXQ_LEN		64
5565958cb6Saoyama #define OMKBD_RXQ_LEN_MASK	(OMKBD_RXQ_LEN - 1)
5665958cb6Saoyama #define OMKBD_NEXTRXQ(x)	(((x) + 1) & OMKBD_RXQ_LEN_MASK)
5765958cb6Saoyama 
5802b01b5eSaoyama static const u_int8_t ch1_regs[6] = {
5902b01b5eSaoyama 	WR0_RSTINT,				/* Reset E/S Interrupt */
6002b01b5eSaoyama 	WR1_RXALLS,				/* Rx per char, No Tx */
6102b01b5eSaoyama 	0,					/* */
6202b01b5eSaoyama 	WR3_RX8BIT | WR3_RXENBL,		/* Rx */
6302b01b5eSaoyama 	WR4_BAUD96 | WR4_STOP1 | WR4_NPARITY,	/* Tx/Rx */
6402b01b5eSaoyama 	WR5_TX8BIT | WR5_TXENBL,		/* Tx */
6502b01b5eSaoyama };
6602b01b5eSaoyama 
6702b01b5eSaoyama struct ws_softc {
6865958cb6Saoyama 	struct device	sc_dev;
6902b01b5eSaoyama 	struct sioreg	*sc_ctl;
7002b01b5eSaoyama 	u_int8_t	sc_wr[6];
7102b01b5eSaoyama 	struct device	*sc_wskbddev;
7265958cb6Saoyama 	u_int8_t	sc_rxq[OMKBD_RXQ_LEN];
7365958cb6Saoyama 	u_int		sc_rxqhead;
7465958cb6Saoyama 	u_int		sc_rxqtail;
7502b01b5eSaoyama #if NWSMOUSE > 0
7602b01b5eSaoyama 	struct device	*sc_wsmousedev;
7702b01b5eSaoyama 	int		sc_msreport;
7865958cb6Saoyama 	int		sc_msbuttons, sc_msdx, sc_msdy;
7902b01b5eSaoyama #endif
8065958cb6Saoyama 	void		*sc_si;
8113f46f24Saoyama #ifdef WSDISPLAY_COMPAT_RAWKBD
8213f46f24Saoyama 	int		sc_rawkbd;
8313f46f24Saoyama #endif
8402b01b5eSaoyama };
8502b01b5eSaoyama 
8602b01b5eSaoyama void omkbd_input(void *, int);
8702b01b5eSaoyama void omkbd_decode(void *, int, u_int *, int *);
8802b01b5eSaoyama int  omkbd_enable(void *, int);
8902b01b5eSaoyama void omkbd_set_leds(void *, int);
9002b01b5eSaoyama int  omkbd_ioctl(void *, u_long, caddr_t, int, struct proc *);
9102b01b5eSaoyama 
9202b01b5eSaoyama const struct wskbd_mapdata omkbd_keymapdata = {
9302b01b5eSaoyama 	omkbd_keydesctab,
9402b01b5eSaoyama #ifdef	OMKBD_LAYOUT
9502b01b5eSaoyama 	OMKBD_LAYOUT,
9602b01b5eSaoyama #else
97c8b0a2fbSmiod 	KB_JP | KB_DEFAULT,
9802b01b5eSaoyama #endif
9902b01b5eSaoyama };
10002b01b5eSaoyama 
10102b01b5eSaoyama const struct wskbd_accessops omkbd_accessops = {
10202b01b5eSaoyama 	omkbd_enable,
10302b01b5eSaoyama 	omkbd_set_leds,
10402b01b5eSaoyama 	omkbd_ioctl,
10502b01b5eSaoyama };
10602b01b5eSaoyama 
10702b01b5eSaoyama void ws_cnattach(void);
10802b01b5eSaoyama void ws_cngetc(void *, u_int *, int *);
10902b01b5eSaoyama void ws_cnpollc(void *, int);
11002b01b5eSaoyama const struct wskbd_consops ws_consops = {
11102b01b5eSaoyama 	ws_cngetc,
11202b01b5eSaoyama 	ws_cnpollc,
11302b01b5eSaoyama 	NULL	/* bell */
11402b01b5eSaoyama };
11502b01b5eSaoyama 
11602b01b5eSaoyama #if NWSMOUSE > 0
11702b01b5eSaoyama int  omms_enable(void *);
11802b01b5eSaoyama int  omms_ioctl(void *, u_long, caddr_t, int, struct proc *);
11902b01b5eSaoyama void omms_disable(void *);
12002b01b5eSaoyama 
12102b01b5eSaoyama const struct wsmouse_accessops omms_accessops = {
12202b01b5eSaoyama 	omms_enable,
12302b01b5eSaoyama 	omms_ioctl,
12402b01b5eSaoyama 	omms_disable,
12502b01b5eSaoyama };
12602b01b5eSaoyama #endif
12702b01b5eSaoyama 
128b6c895f4Saoyama void wsintr(void *);
12965958cb6Saoyama void wssoftintr(void *);
13002b01b5eSaoyama 
13102b01b5eSaoyama int  wsmatch(struct device *, void *, void *);
13202b01b5eSaoyama void wsattach(struct device *, struct device *, void *);
13302b01b5eSaoyama int  ws_submatch_kbd(struct device *, void *, void *);
13402b01b5eSaoyama #if NWSMOUSE > 0
13502b01b5eSaoyama int  ws_submatch_mouse(struct device *, void *, void *);
13602b01b5eSaoyama #endif
13702b01b5eSaoyama 
13802b01b5eSaoyama const struct cfattach ws_ca = {
13902b01b5eSaoyama 	sizeof(struct ws_softc), wsmatch, wsattach
14002b01b5eSaoyama };
14102b01b5eSaoyama 
14210e8dd75Smiod struct cfdriver ws_cd = {
14302b01b5eSaoyama 	NULL, "ws", DV_TTY
14402b01b5eSaoyama };
14502b01b5eSaoyama 
14602b01b5eSaoyama extern int  syscngetc(dev_t);
14702b01b5eSaoyama extern void syscnputc(dev_t, int);
14802b01b5eSaoyama 
14902b01b5eSaoyama int
wsmatch(struct device * parent,void * match,void * aux)15080bc78ddSaoyama wsmatch(struct device *parent, void *match, void *aux)
15102b01b5eSaoyama {
15202b01b5eSaoyama 	struct sio_attach_args *args = aux;
15302b01b5eSaoyama 
15402b01b5eSaoyama 	if (args->channel != 1)
15502b01b5eSaoyama 		return 0;
15602b01b5eSaoyama 	return 1;
15702b01b5eSaoyama }
15802b01b5eSaoyama 
15902b01b5eSaoyama void
wsattach(struct device * parent,struct device * self,void * aux)16080bc78ddSaoyama wsattach(struct device *parent, struct device *self, void *aux)
16102b01b5eSaoyama {
16202b01b5eSaoyama 	struct ws_softc *sc = (struct ws_softc *)self;
163b6c895f4Saoyama 	struct sio_softc *siosc = (struct sio_softc *)parent;
16402b01b5eSaoyama 	struct sio_attach_args *args = aux;
165b6c895f4Saoyama 	int channel = args->channel;
16602b01b5eSaoyama 	struct wskbddev_attach_args a;
16702b01b5eSaoyama 
168b6c895f4Saoyama 	sc->sc_ctl = &siosc->sc_ctl[channel];
169b6c895f4Saoyama 	memcpy(sc->sc_wr, ch1_regs, sizeof(ch1_regs));
170b6c895f4Saoyama 	siosc->sc_intrhand[channel].ih_func = wsintr;
171b6c895f4Saoyama 	siosc->sc_intrhand[channel].ih_arg = sc;
17202b01b5eSaoyama 
17302b01b5eSaoyama 	setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]);
17402b01b5eSaoyama 	setsioreg(sc->sc_ctl, WR4, sc->sc_wr[WR4]);
17502b01b5eSaoyama 	setsioreg(sc->sc_ctl, WR3, sc->sc_wr[WR3]);
17602b01b5eSaoyama 	setsioreg(sc->sc_ctl, WR5, sc->sc_wr[WR5]);
17702b01b5eSaoyama 	setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]);
17802b01b5eSaoyama 	setsioreg(sc->sc_ctl, WR1, sc->sc_wr[WR1]);
17902b01b5eSaoyama 
18002b01b5eSaoyama 	syscnputc((dev_t)1, 0x20); /* keep quiet mouse */
18102b01b5eSaoyama 
18265958cb6Saoyama 	sc->sc_rxqhead = 0;
18365958cb6Saoyama 	sc->sc_rxqtail = 0;
18465958cb6Saoyama 
18565958cb6Saoyama 	sc->sc_si = softintr_establish(IPL_SOFTTTY, wssoftintr, sc);
18665958cb6Saoyama 
18702b01b5eSaoyama 	printf("\n");
18802b01b5eSaoyama 
18902b01b5eSaoyama 	a.console = (args->hwflags == 1);
19002b01b5eSaoyama 	a.keymap = &omkbd_keymapdata;
19102b01b5eSaoyama 	a.accessops = &omkbd_accessops;
19202b01b5eSaoyama 	a.accesscookie = (void *)sc;
19302b01b5eSaoyama 	sc->sc_wskbddev = config_found_sm(self, &a, wskbddevprint,
19402b01b5eSaoyama 					ws_submatch_kbd);
19502b01b5eSaoyama 
19602b01b5eSaoyama #if NWSMOUSE > 0
19702b01b5eSaoyama 	{
19802b01b5eSaoyama 	struct wsmousedev_attach_args b;
19902b01b5eSaoyama 	b.accessops = &omms_accessops;
20002b01b5eSaoyama 	b.accesscookie = (void *)sc;
20102b01b5eSaoyama 	sc->sc_wsmousedev = config_found_sm(self, &b, wsmousedevprint,
20202b01b5eSaoyama 					ws_submatch_mouse);
20302b01b5eSaoyama 	sc->sc_msreport = 0;
20402b01b5eSaoyama 	}
20502b01b5eSaoyama #endif
20602b01b5eSaoyama }
20702b01b5eSaoyama 
20802b01b5eSaoyama int
ws_submatch_kbd(struct device * parent,void * match,void * aux)20980bc78ddSaoyama ws_submatch_kbd(struct device *parent, void *match, void *aux)
21002b01b5eSaoyama {
21102b01b5eSaoyama 	struct cfdata *cf = match;
21202b01b5eSaoyama 
21302b01b5eSaoyama 	if (strcmp(cf->cf_driver->cd_name, "wskbd"))
21402b01b5eSaoyama 		return (0);
21502b01b5eSaoyama 	return ((*cf->cf_attach->ca_match)(parent, cf, aux));
21602b01b5eSaoyama }
21702b01b5eSaoyama 
21802b01b5eSaoyama #if NWSMOUSE > 0
21902b01b5eSaoyama 
22002b01b5eSaoyama int
ws_submatch_mouse(struct device * parent,void * match,void * aux)22180bc78ddSaoyama ws_submatch_mouse(struct device *parent, void *match, void *aux)
22202b01b5eSaoyama {
22302b01b5eSaoyama 	struct cfdata *cf = match;
22402b01b5eSaoyama 
22502b01b5eSaoyama 	if (strcmp(cf->cf_driver->cd_name, "wsmouse"))
22602b01b5eSaoyama 		return (0);
22702b01b5eSaoyama 	return ((*cf->cf_attach->ca_match)(parent, cf, aux));
22802b01b5eSaoyama }
22902b01b5eSaoyama 
23002b01b5eSaoyama #endif
23102b01b5eSaoyama 
23202b01b5eSaoyama void
wsintr(void * arg)233b6c895f4Saoyama wsintr(void *arg)
23402b01b5eSaoyama {
235b6c895f4Saoyama 	struct ws_softc *sc = arg;
23602b01b5eSaoyama 	struct sioreg *sio = sc->sc_ctl;
23702b01b5eSaoyama 	u_int code;
23802b01b5eSaoyama 	int rr;
23902b01b5eSaoyama 
24002b01b5eSaoyama 	rr = getsiocsr(sio);
24102b01b5eSaoyama 	if (rr & RR_RXRDY) {
24202b01b5eSaoyama 		do {
24302b01b5eSaoyama 			code = sio->sio_data;
24402b01b5eSaoyama 			if (rr & (RR_FRAMING | RR_OVERRUN | RR_PARITY)) {
24502b01b5eSaoyama 				sio->sio_cmd = WR0_ERRRST;
24602b01b5eSaoyama 				continue;
24702b01b5eSaoyama 			}
24865958cb6Saoyama 			sc->sc_rxq[sc->sc_rxqtail] = code;
24965958cb6Saoyama 			sc->sc_rxqtail = OMKBD_NEXTRXQ(sc->sc_rxqtail);
25065958cb6Saoyama 		} while ((rr = getsiocsr(sio)) & RR_RXRDY);
25165958cb6Saoyama 		softintr_schedule(sc->sc_si);
25265958cb6Saoyama 	}
25365958cb6Saoyama 	if (rr & RR_TXRDY)
25465958cb6Saoyama 		sio->sio_cmd = WR0_RSTPEND;
25565958cb6Saoyama 	/* not capable of transmit, yet */
25665958cb6Saoyama }
25765958cb6Saoyama 
25865958cb6Saoyama void
wssoftintr(void * arg)25965958cb6Saoyama wssoftintr(void *arg)
26065958cb6Saoyama {
26165958cb6Saoyama 	struct ws_softc *sc = arg;
26265958cb6Saoyama 	uint8_t code;
26365958cb6Saoyama 
26465958cb6Saoyama 	while (sc->sc_rxqhead != sc->sc_rxqtail) {
26565958cb6Saoyama 		code = sc->sc_rxq[sc->sc_rxqhead];
26665958cb6Saoyama 		sc->sc_rxqhead = OMKBD_NEXTRXQ(sc->sc_rxqhead);
26702b01b5eSaoyama #if NWSMOUSE > 0
26802b01b5eSaoyama 		/*
26902b01b5eSaoyama 		 * if (code >= 0x80 && code <= 0x87), then
27002b01b5eSaoyama 		 * it's the first byte of 3 byte long mouse report
27102b01b5eSaoyama 		 * 	code[0] & 07 -> LMR button condition
27202b01b5eSaoyama 		 * 	code[1], [2] -> x,y delta
27302b01b5eSaoyama 		 * otherwise, key press or release event.
27402b01b5eSaoyama 		 */
27502b01b5eSaoyama 		if (sc->sc_msreport == 0) {
27602b01b5eSaoyama 			if (code < 0x80 || code > 0x87) {
27702b01b5eSaoyama 				omkbd_input(sc, code);
27802b01b5eSaoyama 				continue;
27902b01b5eSaoyama 			}
28002b01b5eSaoyama 			code = (code & 07) ^ 07;
28102b01b5eSaoyama 			/* LMR->RML: wsevent counts 0 for leftmost */
28265958cb6Saoyama 			sc->sc_msbuttons = (code & 02);
28365958cb6Saoyama 			if ((code & 01) != 0)
28465958cb6Saoyama 				sc->sc_msbuttons |= 04;
28565958cb6Saoyama 			if ((code & 04) != 0)
28665958cb6Saoyama 				sc->sc_msbuttons |= 01;
28702b01b5eSaoyama 			sc->sc_msreport = 1;
28865958cb6Saoyama 		} else if (sc->sc_msreport == 1) {
28965958cb6Saoyama 			sc->sc_msdx = (int8_t)code;
29002b01b5eSaoyama 			sc->sc_msreport = 2;
29165958cb6Saoyama 		} else if (sc->sc_msreport == 2) {
29265958cb6Saoyama 			sc->sc_msdy = (int8_t)code;
29394712de5Sbru 			WSMOUSE_INPUT(sc->sc_wsmousedev,
29465958cb6Saoyama 			    sc->sc_msbuttons, sc->sc_msdx, sc->sc_msdy, 0, 0);
29502b01b5eSaoyama 			sc->sc_msreport = 0;
29602b01b5eSaoyama 		}
29702b01b5eSaoyama #else
29802b01b5eSaoyama 		omkbd_input(sc, code);
29902b01b5eSaoyama #endif
30002b01b5eSaoyama 	}
30102b01b5eSaoyama }
30202b01b5eSaoyama 
30302b01b5eSaoyama void
omkbd_input(void * v,int data)30480bc78ddSaoyama omkbd_input(void *v, int data)
30502b01b5eSaoyama {
30602b01b5eSaoyama 	struct ws_softc *sc = v;
30702b01b5eSaoyama 	u_int type;
30802b01b5eSaoyama 	int key;
30902b01b5eSaoyama 
31002b01b5eSaoyama 	omkbd_decode(v, data, &type, &key);
31113f46f24Saoyama 
31213f46f24Saoyama #if WSDISPLAY_COMPAT_RAWKBD
31313f46f24Saoyama 	if (sc->sc_rawkbd) {
31413f46f24Saoyama 		u_char cbuf[2];
31513f46f24Saoyama 		int c, j = 0;
31613f46f24Saoyama 
31713f46f24Saoyama 		c = omkbd_raw[key];
31813f46f24Saoyama 		if (c != RAWKEY_Null) {
31913f46f24Saoyama 			/* fake extended scancode if necessary */
32013f46f24Saoyama 			if (c & 0x80)
32113f46f24Saoyama 				cbuf[j++] = 0xe0;
32213f46f24Saoyama 			cbuf[j] = c & 0x7f;
32313f46f24Saoyama 			if (type == WSCONS_EVENT_KEY_UP)
32413f46f24Saoyama 				cbuf[j] |= 0x80;
32513f46f24Saoyama 			j++;
32613f46f24Saoyama 
32713f46f24Saoyama 			wskbd_rawinput(sc->sc_wskbddev, cbuf, j);
32813f46f24Saoyama 		}
32913f46f24Saoyama 	} else
33013f46f24Saoyama #endif
33113f46f24Saoyama 	{
33202b01b5eSaoyama 		if (sc->sc_wskbddev != NULL)
33302b01b5eSaoyama 			wskbd_input(sc->sc_wskbddev, type, key);
33402b01b5eSaoyama 	}
33513f46f24Saoyama }
33602b01b5eSaoyama 
33702b01b5eSaoyama void
omkbd_decode(void * v,int datain,u_int * type,int * dataout)33880bc78ddSaoyama omkbd_decode(void *v, int datain, u_int *type, int *dataout)
33902b01b5eSaoyama {
34002b01b5eSaoyama 	*type = (datain & 0x80) ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN;
34102b01b5eSaoyama 	*dataout = datain & 0x7f;
34202b01b5eSaoyama }
34302b01b5eSaoyama 
34402b01b5eSaoyama void
ws_cngetc(void * v,u_int * type,int * data)34580bc78ddSaoyama ws_cngetc(void *v, u_int *type, int *data)
34602b01b5eSaoyama {
34702b01b5eSaoyama 	int code;
34802b01b5eSaoyama 
34902b01b5eSaoyama 	code = syscngetc((dev_t)1);
35002b01b5eSaoyama 	omkbd_decode(v, code, type, data);
35102b01b5eSaoyama }
35202b01b5eSaoyama 
35302b01b5eSaoyama void
ws_cnpollc(void * v,int on)35480bc78ddSaoyama ws_cnpollc(void *v, int on)
35502b01b5eSaoyama {
35602b01b5eSaoyama }
35702b01b5eSaoyama 
35802b01b5eSaoyama /* EXPORT */ void
ws_cnattach()35902b01b5eSaoyama ws_cnattach()
36002b01b5eSaoyama {
36102b01b5eSaoyama 	static int voidfill;
36202b01b5eSaoyama 
36302b01b5eSaoyama 	/* XXX need CH.B initialization XXX */
36402b01b5eSaoyama 
36502b01b5eSaoyama 	wskbd_cnattach(&ws_consops, &voidfill, &omkbd_keymapdata);
36602b01b5eSaoyama }
36702b01b5eSaoyama 
36802b01b5eSaoyama int
omkbd_enable(void * v,int on)36980bc78ddSaoyama omkbd_enable(void *v, int on)
37002b01b5eSaoyama {
37102b01b5eSaoyama 	return 0;
37202b01b5eSaoyama }
37302b01b5eSaoyama 
37402b01b5eSaoyama void
omkbd_set_leds(void * v,int leds)37580bc78ddSaoyama omkbd_set_leds(void *v, int leds)
37602b01b5eSaoyama {
37702b01b5eSaoyama #if 0
37802b01b5eSaoyama 	syscnputc((dev_t)1, 0x10); /* kana LED on */
37902b01b5eSaoyama 	syscnputc((dev_t)1, 0x00); /* kana LED off */
38002b01b5eSaoyama 	syscnputc((dev_t)1, 0x11); /* caps LED on */
38102b01b5eSaoyama 	syscnputc((dev_t)1, 0x01); /* caps LED off */
38202b01b5eSaoyama #endif
38302b01b5eSaoyama }
38402b01b5eSaoyama 
38502b01b5eSaoyama int
omkbd_ioctl(void * v,u_long cmd,caddr_t data,int flag,struct proc * p)38680bc78ddSaoyama omkbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
38702b01b5eSaoyama {
38813f46f24Saoyama #if WSDISPLAY_COMPAT_RAWKBD
38902b01b5eSaoyama 	struct ws_softc *sc = v;
39002b01b5eSaoyama #endif
39102b01b5eSaoyama 
39202b01b5eSaoyama 	switch (cmd) {
39302b01b5eSaoyama 	case WSKBDIO_GTYPE:
3941893bbf6Smiod 		*(int *)data = WSKBD_TYPE_LUNA;
39502b01b5eSaoyama 		return 0;
39602b01b5eSaoyama 	case WSKBDIO_SETLEDS:
39702b01b5eSaoyama 	case WSKBDIO_GETLEDS:
39802b01b5eSaoyama 	case WSKBDIO_COMPLEXBELL:	/* XXX capable of complex bell */
39902b01b5eSaoyama 		return -1;
40013f46f24Saoyama #if WSDISPLAY_COMPAT_RAWKBD
40113f46f24Saoyama 	case WSKBDIO_SETMODE:
40213f46f24Saoyama 		sc->sc_rawkbd = *(int *)data == WSKBD_RAW;
40313f46f24Saoyama 		return 0;
40413f46f24Saoyama 	case WSKBDIO_GETMODE:
40513f46f24Saoyama 		*(int *)data = sc->sc_rawkbd;
40613f46f24Saoyama 		return 0;
40713f46f24Saoyama #endif
40802b01b5eSaoyama 	}
40902b01b5eSaoyama 	return -1;
41002b01b5eSaoyama }
41102b01b5eSaoyama 
41202b01b5eSaoyama #if NWSMOUSE > 0
41302b01b5eSaoyama 
41402b01b5eSaoyama int
omms_enable(void * v)41580bc78ddSaoyama omms_enable(void *v)
41602b01b5eSaoyama {
41702b01b5eSaoyama 	struct ws_softc *sc = v;
41802b01b5eSaoyama 
41902b01b5eSaoyama 	syscnputc((dev_t)1, 0x60); /* enable 3 byte long mouse reporting */
42002b01b5eSaoyama 	sc->sc_msreport = 0;
42102b01b5eSaoyama 	return 0;
42202b01b5eSaoyama }
42302b01b5eSaoyama 
42402b01b5eSaoyama /*ARGUSED*/
42502b01b5eSaoyama int
omms_ioctl(void * v,u_long cmd,caddr_t data,int flag,struct proc * p)42680bc78ddSaoyama omms_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
42702b01b5eSaoyama {
42802b01b5eSaoyama 
42902b01b5eSaoyama 	switch (cmd) {
43002b01b5eSaoyama 	case WSMOUSEIO_GTYPE:
4311893bbf6Smiod 		*(u_int *)data = WSMOUSE_TYPE_LUNA;
43202b01b5eSaoyama 		return 0;
43302b01b5eSaoyama 	}
43402b01b5eSaoyama 
43502b01b5eSaoyama 	return -1;
43602b01b5eSaoyama }
43702b01b5eSaoyama 
43802b01b5eSaoyama void
omms_disable(void * v)43980bc78ddSaoyama omms_disable(void *v)
44002b01b5eSaoyama {
44102b01b5eSaoyama 	struct ws_softc *sc = v;
44202b01b5eSaoyama 
44302b01b5eSaoyama 	syscnputc((dev_t)1, 0x20); /* quiet mouse */
44402b01b5eSaoyama 	sc->sc_msreport = 0;
44502b01b5eSaoyama }
44602b01b5eSaoyama #endif
447