summaryrefslogtreecommitdiff
path: root/sys/dev/dec
diff options
context:
space:
mode:
authordrochner <drochner@NetBSD.org>1998-10-22 17:55:20 +0000
committerdrochner <drochner@NetBSD.org>1998-10-22 17:55:20 +0000
commit00d699282fb8008a58ecac5b1022d441766feb08 (patch)
tree87c5c9645793e4c57fafd8dc159da551210ba635 /sys/dev/dec
parent6bb61fcc13d34e24dc84515a556bfc160fe25c28 (diff)
separate keyboard handling from serial interface handling some more,
improve bell handling, initialize kbd on powerup
Diffstat (limited to 'sys/dev/dec')
-rw-r--r--sys/dev/dec/lk201_ws.c76
-rw-r--r--sys/dev/dec/lk201var.h46
2 files changed, 116 insertions, 6 deletions
diff --git a/sys/dev/dec/lk201_ws.c b/sys/dev/dec/lk201_ws.c
index d87158dcbbe..b7d8f3694d8 100644
--- a/sys/dev/dec/lk201_ws.c
+++ b/sys/dev/dec/lk201_ws.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lk201_ws.c,v 1.1 1998/09/17 20:01:57 drochner Exp $ */
+/* $NetBSD: lk201_ws.c,v 1.2 1998/10/22 17:55:20 drochner Exp $ */
/*
* Copyright (c) 1998
@@ -41,14 +41,38 @@
#include <dev/dec/lk201var.h>
#include <dev/dec/wskbdmap_lk201.h> /* for {MIN,MAX}_LK201_KEY */
-void
-lk201_init_keystate(lks)
+#define send(lks, c) ((*((lks)->attmt.sendchar))((lks)->attmt.cookie, c))
+
+int
+lk201_init(lks)
struct lk201_state *lks;
{
int i;
+ send(lks, LK_LED_ENABLE);
+ send(lks, LK_LED_ALL);
+
+ /*
+ * set all keys to updown mode; autorepeat is
+ * done by wskbd software
+ */
+ for (i = 1; i <= 14; i++)
+ send(lks, LK_CMD_MODE(LK_UPDOWN, i));
+
+ send(lks, LK_CL_ENABLE);
+ send(lks, LK_PARAM_VOLUME(3));
+
+ lks->bellvol = -1; /* not yet set */
+
for (i = 0; i < LK_KLL; i++)
lks->down_keys_list[i] = -1;
+ send(lks, LK_KBD_ENABLE);
+
+ send(lks, LK_LED_DISABLE);
+ send(lks, LK_LED_ALL);
+ lks->leds_state = 0;
+
+ return (0);
}
int
@@ -68,7 +92,7 @@ lk201_decode(lks, datain, type, dataout)
return (1);
case LK_POWER_UP:
printf("lk201_decode: powerup detected\n");
- /* XXX should reinitialize here */
+ lk201_init(lks);
return (0);
case LK_KDOWN_ERROR:
case LK_POWER_ERROR:
@@ -108,3 +132,47 @@ lk201_decode(lks, datain, type, dataout)
lks->down_keys_list[freeslot] = datain;
return (1);
}
+
+void
+lk201_bell(lks, bell)
+ struct lk201_state *lks;
+ struct wskbd_bell_data *bell;
+{
+ unsigned int vol;
+
+ if (bell->which & WSKBD_BELL_DOVOLUME) {
+ vol = 8 - bell->volume * 8 / 100;
+ if (vol > 7)
+ vol = 7;
+ } else
+ vol = 3;
+
+ if (vol != lks->bellvol) {
+ send(lks, LK_BELL_ENABLE);
+ send(lks, LK_PARAM_VOLUME(vol));
+ lks->bellvol = vol;
+ }
+ send(lks, LK_RING_BELL);
+}
+
+void
+lk201_set_leds(lks, leds)
+ struct lk201_state *lks;
+ int leds;
+{
+ int newleds;
+
+ newleds = 0;
+ if (leds & WSKBD_LED_SCROLL)
+ newleds |= LK_LED_WAIT;
+ if (leds & WSKBD_LED_CAPS)
+ newleds |= LK_LED_LOCK;
+
+ send(lks, LK_LED_DISABLE);
+ send(lks, (0x80 | (~newleds & 0x0f)));
+
+ send(lks, LK_LED_ENABLE);
+ send(lks, (0x80 | (newleds & 0x0f)));
+
+ lks->leds_state = leds;
+}
diff --git a/sys/dev/dec/lk201var.h b/sys/dev/dec/lk201var.h
index cd652d3f9aa..19b3376d272 100644
--- a/sys/dev/dec/lk201var.h
+++ b/sys/dev/dec/lk201var.h
@@ -1,9 +1,51 @@
-/* $NetBSD: lk201var.h,v 1.1 1998/09/17 20:01:57 drochner Exp $ */
+/* $NetBSD: lk201var.h,v 1.2 1998/10/22 17:55:20 drochner Exp $ */
+
+/*
+ * Copyright (c) 1998
+ * Matthias Drochner. 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Matthias Drochner.
+ * 4. 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.
+ *
+ */
+
+struct lk201_attachment {
+ int (*sendchar) __P((void *, u_char));
+ void *cookie;
+};
struct lk201_state {
+ struct lk201_attachment attmt;
#define LK_KLL 8
int down_keys_list[LK_KLL];
+ int bellvol;
+ int leds_state;
};
-void lk201_init_keystate __P((struct lk201_state *));
+int lk201_init __P((struct lk201_state *));
int lk201_decode __P((struct lk201_state *, int, u_int *, int *));
+void lk201_bell __P((struct lk201_state *, struct wskbd_bell_data *));
+void lk201_set_leds __P((struct lk201_state *, int));