summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorrobert <robert@openbsd.org>2008-01-24 14:50:38 +0000
committerrobert <robert@openbsd.org>2008-01-24 14:50:38 +0000
commit48bafddaf971b50f6a34b8a40546a6593ebd4017 (patch)
tree8a124bf82d467a63973c7713798caaead6d49148 /sys
parentOops, make fit in 80 cols. (diff)
downloadwireguard-openbsd-48bafddaf971b50f6a34b8a40546a6593ebd4017.tar.xz
wireguard-openbsd-48bafddaf971b50f6a34b8a40546a6593ebd4017.zip
provide an external hook for beeper devices just like pckbd(4) does
ok miod@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/ukbd.c37
-rw-r--r--sys/dev/usb/ukbdvar.h5
2 files changed, 40 insertions, 2 deletions
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c
index 63fd7adb16e..d73e1bb7ca9 100644
--- a/sys/dev/usb/ukbd.c
+++ b/sys/dev/usb/ukbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukbd.c,v 1.38 2007/11/23 19:21:40 deraadt Exp $ */
+/* $OpenBSD: ukbd.c,v 1.39 2008/01/24 14:50:38 robert Exp $ */
/* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */
/*
@@ -296,14 +296,21 @@ int ukbd_is_console;
void ukbd_cngetc(void *, u_int *, int *);
void ukbd_cnpollc(void *, int);
+void ukbd_cnbell(void *, u_int, u_int, u_int);
const struct wskbd_consops ukbd_consops = {
ukbd_cngetc,
ukbd_cnpollc,
+ ukbd_cnbell,
};
const char *ukbd_parse_desc(struct ukbd_softc *sc);
+void (*ukbd_bell_fn)(void *, u_int, u_int, u_int, int);
+void *ukbd_bell_fn_arg;
+
+void ukbd_bell(u_int, u_int, u_int, int);
+
void ukbd_intr(struct uhidev *addr, void *ibuf, u_int len);
void ukbd_decode(struct ukbd_softc *sc, struct ukbd_data *ud);
void ukbd_delayed_decode(void *addr);
@@ -803,6 +810,11 @@ ukbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
case WSKBDIO_GETLEDS:
*(int *)data = sc->sc_leds;
return (0);
+ case WSKBDIO_COMPLEXBELL:
+#define d ((struct wskbd_bell_data *)data)
+ ukbd_bell(d->pitch, d->period, d->volume, 0);
+#undef d
+ return (0);
#ifdef WSDISPLAY_COMPAT_RAWKBD
case WSKBDIO_SETMODE:
DPRINTF(("ukbd_ioctl: set raw = %d\n", *(int *)data));
@@ -814,6 +826,23 @@ ukbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
return (-1);
}
+void
+ukbd_bell(u_int pitch, u_int period, u_int volume, int poll)
+{
+ if (ukbd_bell_fn != NULL)
+ (*ukbd_bell_fn)(ukbd_bell_fn_arg, pitch, period,
+ volume, poll);
+}
+
+void
+ukbd_hookup_bell(void (*fn)(void *, u_int, u_int, u_int, int), void *arg)
+{
+ if (ukbd_bell_fn == NULL) {
+ ukbd_bell_fn = fn;
+ ukbd_bell_fn_arg = arg;
+ }
+}
+
/*
* This is a hack to work around some broken ports that don't call
* cnpollc() before cngetc().
@@ -875,6 +904,12 @@ ukbd_cnpollc(void *v, int on)
usbd_set_polling(dev, on);
}
+void
+ukbd_cnbell(void *v, u_int pitch, u_int period, u_int volume)
+{
+ ukbd_bell(pitch, period, volume, 1);
+}
+
int
ukbd_cnattach(void)
{
diff --git a/sys/dev/usb/ukbdvar.h b/sys/dev/usb/ukbdvar.h
index 968de7c810d..82c018cb4a7 100644
--- a/sys/dev/usb/ukbdvar.h
+++ b/sys/dev/usb/ukbdvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukbdvar.h,v 1.2 2000/11/08 18:10:38 aaron Exp $ */
+/* $OpenBSD: ukbdvar.h,v 1.3 2008/01/24 14:50:38 robert Exp $ */
/* $NetBSD: ukbdvar.h,v 1.2 2000/06/01 14:29:00 augustss Exp $ */
/*-
@@ -43,4 +43,7 @@
int ukbd_cnattach(void);
+void ukbd_hookup_bell(void (*fn)(void *, u_int, u_int, u_int, int),
+ void *);
+
#endif /* _DEV_USB_UKBDVAR_H_ */