Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hpcmips Change btnmgr to wskbd device from pseudo d...
details: https://anonhg.NetBSD.org/src/rev/6b91fcbb4271
branches: trunk
changeset: 483541:6b91fcbb4271
user: takemura <takemura%NetBSD.org@localhost>
date: Sun Mar 12 12:08:16 2000 +0000
description:
Change btnmgr to wskbd device from pseudo device.
diffstat:
sys/arch/hpcmips/conf/GENERIC | 7 +-
sys/arch/hpcmips/conf/files.hpcmips | 9 +-
sys/arch/hpcmips/dev/btnmgr.c | 207 ++++++++++++++++++++++++++++++-----
sys/arch/hpcmips/hpcmips/mainbus.c | 4 +-
4 files changed, 189 insertions(+), 38 deletions(-)
diffs (truncated from 358 to 300 lines):
diff -r 8c74f2699dd9 -r 6b91fcbb4271 sys/arch/hpcmips/conf/GENERIC
--- a/sys/arch/hpcmips/conf/GENERIC Sun Mar 12 11:58:15 2000 +0000
+++ b/sys/arch/hpcmips/conf/GENERIC Sun Mar 12 12:08:16 2000 +0000
@@ -2,11 +2,11 @@
# Distribution kernel (any model) kernel config file
#
-# $NetBSD: GENERIC,v 1.35 2000/03/12 05:04:44 takemura Exp $
+# $NetBSD: GENERIC,v 1.36 2000/03/12 12:08:16 takemura Exp $
#
include "arch/hpcmips/conf/std.hpcmips"
-#ident "GENERIC-$Revision: 1.35 $"
+#ident "GENERIC-$Revision: 1.36 $"
maxusers 8
@@ -126,6 +126,8 @@
wsdisplay* at hpcfb?
wskbd* at vrkiu? mux 1
wsmouse* at vrpiu? mux 0
+btnmgr0 at mainbus0
+wskbd* at btnmgr0 mux 1
#
# hpcmips isa? bus irq locator means:
@@ -297,7 +299,6 @@
pseudo-device ccd 4 # concatenated disks
pseudo-device biconsdev 1 # build-in console device
-pseudo-device btnmgr 1 # button event handler
# for IPv6
pseudo-device gif 4 # IPv[46] over IPv[46] tunnel (RFC1933)
diff -r 8c74f2699dd9 -r 6b91fcbb4271 sys/arch/hpcmips/conf/files.hpcmips
--- a/sys/arch/hpcmips/conf/files.hpcmips Sun Mar 12 11:58:15 2000 +0000
+++ b/sys/arch/hpcmips/conf/files.hpcmips Sun Mar 12 12:08:16 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.hpcmips,v 1.25 2000/03/12 05:04:44 takemura Exp $
+# $NetBSD: files.hpcmips,v 1.26 2000/03/12 12:08:16 takemura Exp $
# maxpartitions must be first item in files.${ARCH}.
maxpartitions 8
@@ -82,6 +82,10 @@
file arch/hpcmips/dev/bivideo.c bivideo needs-flag
attach bivideo at mainbus
+device btnmgr: wskbddev
+attach btnmgr at mainbus
+file arch/hpcmips/dev/btnmgr.c btnmgr
+
#
# ISA bus support
#
@@ -92,8 +96,6 @@
#
defpseudo biconsdev
file arch/hpcmips/dev/biconsdev.c biconsdev needs-count
-defpseudo btnmgr
-file arch/hpcmips/dev/btnmgr.c btnmgr
#
# Vr41x1 integrated peripherals
@@ -141,6 +143,7 @@
device vrkiu: wskbddev
attach vrkiu at vrip
file arch/hpcmips/vr/vrkiu.c vrkiu needs-flag
+
#
# XXX files.pckbc XXX
#
diff -r 8c74f2699dd9 -r 6b91fcbb4271 sys/arch/hpcmips/dev/btnmgr.c
--- a/sys/arch/hpcmips/dev/btnmgr.c Sun Mar 12 11:58:15 2000 +0000
+++ b/sys/arch/hpcmips/dev/btnmgr.c Sun Mar 12 12:08:16 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: btnmgr.c,v 1.2 2000/02/27 16:34:13 uch Exp $ */
+/* $NetBSD: btnmgr.c,v 1.3 2000/03/12 12:08:17 takemura Exp $ */
/*-
* Copyright (c) 1999
@@ -43,6 +43,12 @@
#include <sys/malloc.h>
#include <sys/kernel.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wskbdvar.h>
+#include <dev/wscons/wsksymdef.h>
+
+#include <machine/bus.h>
+#include <machine/autoconf.h>
#include <machine/config_hook.h>
#ifdef BTNMGRDEBUG
@@ -57,56 +63,141 @@
cdev_decl(btnmgr);
struct btnmgr_softc {
+ struct device sc_dev;
config_hook_tag sc_hook_tag;
+ int sc_enabled;
+ struct device *sc_wskbddev;
};
+/*
static struct btnmgr_softc *the_btnmgr_sc;
+*/
+/*
void btnmgrattach __P((int));
+ */
+int btnmgrmatch __P((struct device *, struct cfdata *, void *));
+void btnmgrattach __P((struct device *, struct device *, void *));
char* btnmgr_name __P((long));
static int btnmgr_hook __P((void *, int, long, void *));
+
+/*
+ * global/static data
+ */
+struct cfattach btnmgr_ca = {
+ sizeof(struct btnmgr_softc), btnmgrmatch, btnmgrattach
+};
+
+/* wskbd accessopts */
+int btnmgr_wskbd_enable __P((void *, int));
+void btnmgr_wskbd_set_leds __P((void *, int));
+int btnmgr_wskbd_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
+
+const struct wskbd_accessops btnmgr_wskbd_accessops = {
+ btnmgr_wskbd_enable,
+ btnmgr_wskbd_set_leds,
+ btnmgr_wskbd_ioctl,
+};
+
static const struct {
long id;
char *name;
} button_names[] = {
- { CONFIG_HOOK_BUTTONEVENT_POWER, "Power" },
- { CONFIG_HOOK_BUTTONEVENT_OK, "OK" },
- { CONFIG_HOOK_BUTTONEVENT_CANCEL, "Cancel" },
- { CONFIG_HOOK_BUTTONEVENT_UP, "Up" },
- { CONFIG_HOOK_BUTTONEVENT_DOWN, "Down" },
- { CONFIG_HOOK_BUTTONEVENT_REC, "Rec" },
- { CONFIG_HOOK_BUTTONEVENT_COVER, "Cover" },
- { CONFIG_HOOK_BUTTONEVENT_LIGHT, "Light" },
- { CONFIG_HOOK_BUTTONEVENT_CONTRAST, "Contrast" },
- { CONFIG_HOOK_BUTTONEVENT_APP0, "Application 0" },
- { CONFIG_HOOK_BUTTONEVENT_APP1, "Application 1" },
- { CONFIG_HOOK_BUTTONEVENT_APP2, "Application 2" },
- { CONFIG_HOOK_BUTTONEVENT_APP3, "Application 3" },
+/* button id name key code */
+ { CONFIG_HOOK_BUTTONEVENT_POWER, "Power" }, /* 1 */
+ { CONFIG_HOOK_BUTTONEVENT_OK, "OK" }, /* 2 */
+ { CONFIG_HOOK_BUTTONEVENT_CANCEL, "Cancel" }, /* 3 */
+ { CONFIG_HOOK_BUTTONEVENT_UP, "Up" }, /* 4 */
+ { CONFIG_HOOK_BUTTONEVENT_DOWN, "Down" }, /* 5 */
+ { CONFIG_HOOK_BUTTONEVENT_REC, "Rec" }, /* 6 */
+ { CONFIG_HOOK_BUTTONEVENT_COVER, "Cover" }, /* 7 */
+ { CONFIG_HOOK_BUTTONEVENT_LIGHT, "Light" }, /* 8 */
+ { CONFIG_HOOK_BUTTONEVENT_CONTRAST, "Contrast" }, /* 9 */
+ { CONFIG_HOOK_BUTTONEVENT_APP0, "Application 0" }, /* 10 */
+ { CONFIG_HOOK_BUTTONEVENT_APP1, "Application 1" }, /* 11 */
+ { CONFIG_HOOK_BUTTONEVENT_APP2, "Application 2" }, /* 12 */
+ { CONFIG_HOOK_BUTTONEVENT_APP3, "Application 3" }, /* 13 */
};
static const int n_button_names =
sizeof(button_names) / sizeof(*button_names);
+#define KC(n) KS_KEYCODE(n)
+static const keysym_t btnmgr_keydesc_default[] = {
+/* pos normal shifted altgr shift-altgr */
+ KC(1), KS_A,
+ KC(2), KS_B,
+ KC(3), KS_C,
+ KC(4), KS_D,
+ KC(5), KS_E,
+ KC(6), KS_F,
+ KC(7), KS_G,
+ KC(8), KS_H,
+ KC(9), KS_I,
+ KC(10), KS_J,
+ KC(11), KS_K,
+ KC(12), KS_L,
+ KC(13), KS_M,
+};
+#undef KC
+#define KBD_MAP(name, base, map) \
+ { name, base, sizeof(map)/sizeof(keysym_t), map }
+const struct wscons_keydesc btnmgr_keydesctab[] = {
+ KBD_MAP(KB_US, 0, btnmgr_keydesc_default),
+ {0, 0, 0, 0}
+};
+#undef KBD_MAP
+
+struct wskbd_mapdata btnmgr_keymapdata = {
+ btnmgr_keydesctab,
+ KB_US, /* XXX, This is bad idea... */
+};
+
+/*
+ * function bodies
+ */
+int
+btnmgrmatch(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct mainbus_attach_args *ma = aux;
+
+ if (strcmp(ma->ma_name, match->cf_driver->cd_name))
+ return 0;
+
+ return (1);
+}
+
void
-btnmgrattach (n)
- int n;
+btnmgrattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
int id;
+ struct btnmgr_softc *sc = (struct btnmgr_softc *)self;
+ struct wskbddev_attach_args wa;
- printf("button manager\n");
+ printf("\n");
- the_btnmgr_sc = malloc(sizeof(struct btnmgr_softc), M_DEVBUF,
- cold ? M_NOWAIT : M_WAITOK);
- if (the_btnmgr_sc == NULL)
- panic("button manager: malloc failed");
- bzero(the_btnmgr_sc, sizeof(struct btnmgr_softc));
+ /*
+ * install button event listener
+ */
+ for (id = 0; id < 16; id++)
+ sc->sc_hook_tag = config_hook(CONFIG_HOOK_BUTTONEVENT,
+ id, CONFIG_HOOK_SHARE,
+ btnmgr_hook, sc);
- for (id = 0; id < 16; id++)
- the_btnmgr_sc->sc_hook_tag =
- config_hook(CONFIG_HOOK_BUTTONEVENT,
- id, CONFIG_HOOK_SHARE,
- btnmgr_hook,
- the_btnmgr_sc);
+ /*
+ * attach wskbd
+ */
+ wa.console = 0;
+ wa.keymap = &btnmgr_keymapdata;
+ wa.accessops = &btnmgr_wskbd_accessops;
+ wa.accesscookie = sc;
+
+ sc->sc_wskbddev = config_found(self, &wa, wskbddevprint);
}
static int
@@ -116,12 +207,14 @@
long id;
void *msg;
{
-#ifdef notyet
struct btnmgr_softc *sc = ctx;
-#endif /* not yet */
DPRINTF(("%s button: %s\n", btnmgr_name(id), msg ? "ON" : "OFF"));
+ wskbd_input(sc->sc_wskbddev,
+ msg ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP,
+ id + 1);
+
return (0);
}
@@ -137,6 +230,60 @@
return ("unknown");
}
+int
+btnmgr_wskbd_enable(scx, on)
+ void *scx;
+ int on;
+{
+ struct btnmgr_softc *sc = scx;
+
+ if (on) {
+ if (sc->sc_enabled)
+ return (EBUSY);
+ sc->sc_enabled = 1;
+ } else {
+ sc->sc_enabled = 0;
+ }
+
+ return (0);
+}
Home |
Main Index |
Thread Index |
Old Index