diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/zaurus/conf/GENERIC | 5 | ||||
-rw-r--r-- | sys/arch/zaurus/conf/RAMDISK | 5 | ||||
-rw-r--r-- | sys/arch/zaurus/conf/files.zaurus | 2 | ||||
-rw-r--r-- | sys/arch/zaurus/dev/zaurus_kbd.c | 129 | ||||
-rw-r--r-- | sys/arch/zaurus/dev/zaurus_kbdmap.h | 98 |
5 files changed, 221 insertions, 18 deletions
diff --git a/sys/arch/zaurus/conf/GENERIC b/sys/arch/zaurus/conf/GENERIC index 90f28aa1df6..41f6e02f327 100644 --- a/sys/arch/zaurus/conf/GENERIC +++ b/sys/arch/zaurus/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.10 2005/01/13 20:47:57 drahn Exp $ +# $OpenBSD: GENERIC,v 1.11 2005/01/13 23:33:37 drahn Exp $ # # GENERIC machine description file # @@ -78,7 +78,8 @@ ohci0 at pxaip? addr 0x4c000000 size 0x70 intr 3 usb* at ohci? # keyboard -zkbd0 at pxaip? # mux 1 +zkbd0 at pxaip? +wskbd* at zkbd? mux 1 # USB bus support usb* at ohci? flags 0x1 diff --git a/sys/arch/zaurus/conf/RAMDISK b/sys/arch/zaurus/conf/RAMDISK index f852e338eac..2555dc0df5f 100644 --- a/sys/arch/zaurus/conf/RAMDISK +++ b/sys/arch/zaurus/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.9 2005/01/13 20:47:57 drahn Exp $ +# $OpenBSD: RAMDISK,v 1.10 2005/01/13 23:33:37 drahn Exp $ # $NetBSD: GENERIC,v 1.27.4.1 2002/08/01 04:18:06 lukem Exp $ # # GENERIC machine description file @@ -86,7 +86,8 @@ ohci0 at pxaip? addr 0x4c000000 size 0x70 intr 3 usb* at ohci? # keyboard -zkbd0 at pxaip? # mux 1 +zkbd0 at pxaip? +wskbd* at zkbd? mux 1 # USB bus support usb* at ohci? flags 0x1 diff --git a/sys/arch/zaurus/conf/files.zaurus b/sys/arch/zaurus/conf/files.zaurus index d6db8616aad..9690f8b2ff4 100644 --- a/sys/arch/zaurus/conf/files.zaurus +++ b/sys/arch/zaurus/conf/files.zaurus @@ -29,7 +29,7 @@ attach lcd at pxaip with lcd_pxaip file arch/zaurus/zaurus/zaurus_lcd.c lcd_pxaip # GPIO keyboard -device zkbd +device zkbd: wskbddev attach zkbd at pxaip file arch/zaurus/dev/zaurus_kbd.c zkbd diff --git a/sys/arch/zaurus/dev/zaurus_kbd.c b/sys/arch/zaurus/dev/zaurus_kbd.c index aa0f96ac0de..fd3a0627af9 100644 --- a/sys/arch/zaurus/dev/zaurus_kbd.c +++ b/sys/arch/zaurus/dev/zaurus_kbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zaurus_kbd.c,v 1.1 2005/01/13 20:47:57 drahn Exp $ */ +/* $OpenBSD: zaurus_kbd.c,v 1.2 2005/01/13 23:33:37 drahn Exp $ */ /* * Copyright (c) 2005 Dale Rahn <drahn@openbsd.org> * @@ -24,6 +24,12 @@ #include <arm/xscale/pxa2x0reg.h> #include <arm/xscale/pxa2x0_gpio.h> +#include <dev/wscons/wsconsio.h> +#include <dev/wscons/wskbdvar.h> +#include <dev/wscons/wsksymdef.h> +#include <dev/wscons/wsksymvar.h> + +#include <zaurus/dev/zaurus_kbdmap.h> int gpio_sense_pins_c3000[] = { @@ -69,6 +75,11 @@ struct zkbd_softc { int sc_swb_pin; char *sc_okeystate; char *sc_keystate; + + + /* wskbd bits */ + struct device *sc_wskbddev; + int sc_rawkbd; }; int zkbd_match(struct device *, void *, void *); @@ -86,6 +97,30 @@ struct cfdriver zkbd_cd = { NULL, "zkbd", DV_DULL }; +int zkbd_enable(void *, int); +void zkbd_set_leds(void *, int); +int zkbd_ioctl(void *, u_long, caddr_t, int, struct proc *); +void zkbd_rawrepeat(void *v); + +struct wskbd_accessops zkbd_accessops = { + zkbd_enable, + zkbd_set_leds, + zkbd_ioctl, +}; + +void zkbd_cngetc(void *, u_int *, int *); +void zkbd_cnpollc(void *, int); + +struct wskbd_consops zkbd_consops = { + zkbd_cngetc, + zkbd_cnpollc, +}; + +struct wskbd_mapdata zkbd_keymapdata = { + zkbd_keydesctab, + KB_US, +}; + int @@ -100,6 +135,7 @@ zkbd_attach(struct device *parent, struct device *self, void *aux) { struct zkbd_softc *sc = (struct zkbd_softc *)self; int pin, i; + struct wskbddev_attach_args a; /* Determine which system we are - XXX */ @@ -145,6 +181,13 @@ zkbd_attach(struct device *parent, struct device *self, void *aux) zkbd_hinge, sc, sc->sc_dev.dv_xname); pxa2x0_gpio_intr_establish(sc->sc_swb_pin, IST_EDGE_BOTH, IPL_BIO, zkbd_hinge, sc, sc->sc_dev.dv_xname); + + a.console = 0; + a.keymap = &zkbd_keymapdata; + a.accessops = &zkbd_accessops; + a.accesscookie = sc; + + sc->sc_wskbddev = config_found(self, &a, wskbddevprint); } /* XXX only deal with keys that can be pressed when display is open? */ @@ -156,6 +199,7 @@ zkbd_irq(void *v) struct zkbd_softc *sc = v; int i, col; int pin; + int type; /* discharge all */ for (i = 0; i < sc->sc_nstrobe; i++) { @@ -192,18 +236,6 @@ zkbd_irq(void *v) /* reset_col */ pxa2x0_gpio_set_dir(pin, GPIO_IN); } - - printf("zkbd_irq\n"); - for (i = 0; i < (sc->sc_nsense * sc->sc_nstrobe); i++) { - if (sc->sc_okeystate[i] != sc->sc_keystate[i]) { - if (sc->sc_keystate[i]) - printf("key %d pressed\n", i); - else - printf("key %d released\n", i); - } - sc->sc_okeystate[i] = sc->sc_keystate[i]; - } - /* charge all */ for (i = 0; i < sc->sc_nstrobe; i++) { pin = sc->sc_strobe_array[i]; @@ -218,6 +250,24 @@ zkbd_irq(void *v) if (sc->sc_sense_array[i] != -1) pxa2x0_gpio_clear_intr(sc->sc_sense_array[i]); + /* process after resetting interrupt */ + + for (i = 0; i < (sc->sc_nsense * sc->sc_nstrobe); i++) { + if (sc->sc_okeystate[i] != sc->sc_keystate[i]) { + + type = sc->sc_keystate[i] ? WSCONS_EVENT_KEY_DOWN : + WSCONS_EVENT_KEY_UP; + +/* +printf("key %d %s\n", i, sc->sc_keystate[i] ? "pressed" : "released"); +*/ + + wskbd_input(sc->sc_wskbddev, type, i); + + sc->sc_okeystate[i] = sc->sc_keystate[i]; + } + } + return 1; } @@ -241,3 +291,56 @@ zkbd_hinge(void *v) printf("hing event pressed\n"); return 1; } + +int +zkbd_enable(void *v, int on) +{ + return 0; +} + +void +zkbd_set_leds(void *v, int on) +{ +} + +int +zkbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) +{ +#ifdef WSDISPLAY_COMPAT_RAWKBD + struct akbd_softc *sc = v; +#endif + + switch (cmd) { + + case WSKBDIO_GTYPE: + *(int *)data = WSKBD_TYPE_ADB; + return 0; + case WSKBDIO_SETLEDS: + return 0; + case WSKBDIO_GETLEDS: + *(int *)data = 0; + return 0; +#ifdef WSDISPLAY_COMPAT_RAWKBD + case WSKBDIO_SETMODE: + sc->sc_rawkbd = *(int *)data == WSKBD_RAW; + timeout_del(&sc->sc_rawrepeat_ch); + return (0); +#endif + + } + /* kbdioctl(...); */ + + return -1; +} + +/* implement polling for zaurus_kbd */ +void +zkbd_cngetc(void *v, u_int *type, int *data) +{ +} + +void +zkbd_cnpollc(void *v, int on) +{ +} + diff --git a/sys/arch/zaurus/dev/zaurus_kbdmap.h b/sys/arch/zaurus/dev/zaurus_kbdmap.h new file mode 100644 index 00000000000..84fcbe66bc7 --- /dev/null +++ b/sys/arch/zaurus/dev/zaurus_kbdmap.h @@ -0,0 +1,98 @@ +/* $OpenBSD: zaurus_kbdmap.h,v 1.1 2005/01/13 23:33:37 drahn Exp $ */ + +/* + * Copyright (c) 2005 Dale Rahn <drahn@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#define KC(n) KS_KEYCODE(n) + +static const keysym_t zkbd_keydesc_us[] = { + KC(0), KS_Control_L, + KC(2), KS_Tab, + /* KC(3), Addr, */ + /* KC(4), Cal, */ + /* KC(5), Mail, */ + /* KC(6), Home, */ + KC(8), KS_1, + KC(9), KS_2, + KC(10), KS_q, + KC(11), KS_w, + KC(12), KS_a, + KC(13), KS_z, + KC(16), KS_3, + KC(17), KS_4, + KC(18), KS_e, + KC(18), KS_e, + KC(19), KS_s, + KC(20), KS_d, + KC(21), KS_x, + /* KC(22), ^/t (right japanese) */ + KC(24), KS_5, + KC(25), KS_r, + KC(26), KS_t, + KC(27), KS_f, + KC(28), KS_c, + KC(29), KS_minus, + /* KC(30), Cancel */ + KC(32), KS_6, + KC(33), KS_y, + KC(34), KS_g, + KC(35), KS_v, + KC(36), KS_b, + KC(37), KS_space, + /* KC(38), ok */ + KC(40), KS_7, + KC(41), KS_8, + KC(42), KS_u, + KC(43), KS_h, + KC(44), KS_n, + KC(45), KS_slash, + /* KC(46), Menu, */ + KC(48), KS_9, + KC(49), KS_i, + KC(50), KS_j, + KC(51), KS_m, + KC(52), KS_question, + /* KC(54), left, */ + KC(56), KS_0, + KC(57), KS_o, + KC(58), KS_k, + KC(59), KS_l, + /* KC(61), up, */ + /* KC(62), down, */ + KC(64), KS_BackSpace, + KC(65), KS_p, + /* KC(68), US, (left japanese) */ + /* KC(70), right, */ + /* KC(80), OK, (ext) */ + /* KC(81), tog left, */ + KC(83), KS_Return, + KC(83), KS_Shift_R, + KC(84), KS_Shift_L, + /* KC(88), cancel (ext), */ + /* KC(89), tog right, */ + KC(93), KS_Mode_switch /* Fn */ +}; + +#define KBD_MAP(name, base, map) \ + { name, base, sizeof(map)/sizeof(keysym_t), map } + +static const struct wscons_keydesc zkbd_keydesctab[] = { + KBD_MAP(KB_US, 0, zkbd_keydesc_us), + {0, 0, 0, 0} +}; + +#undef KBD_MAP +#undef KC |