summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2007-05-31 22:23:14 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2007-05-31 22:23:14 +0000
commitd9ca1e4740c71597b0d59723725882c1b2faf547 (patch)
tree0f1c86b54e0ac35ebabafa894ea504cd51e42f35 /sys
parentd602ed0e446009c66375a9bec37f600202796fdd (diff)
switch wskbd hotkeys over to workq. this eliminates quite a bit of code,
so remove the option too. if you have audio and wskbd, you have hotkeys. ok dlg
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/audio.c14
-rw-r--r--sys/dev/pckbc/files.pckbc4
-rw-r--r--sys/dev/wscons/files.wscons5
-rw-r--r--sys/dev/wscons/wskbd.c26
-rw-r--r--sys/dev/wscons/wskbd_hotkey.c162
-rw-r--r--sys/dev/wscons/wsksymvar.h8
6 files changed, 26 insertions, 193 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index 629b728de44..e1a0a858257 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: audio.c,v 1.54 2007/01/07 13:35:51 miod Exp $ */
+/* $OpenBSD: audio.c,v 1.55 2007/05/31 22:23:13 tedu Exp $ */
/* $NetBSD: audio.c,v 1.119 1999/11/09 16:50:47 augustss Exp $ */
/*
@@ -87,7 +87,7 @@
#include <machine/endian.h>
-#include "wskbd.h" /* NWSKBD_HOTKEY (mixer tuning using keyboard) */
+#include "wskbd.h" /* NWSKBD (mixer tuning using keyboard) */
#ifdef AUDIO_DEBUG
#define DPRINTF(x) if (audiodebug) printf x
@@ -210,10 +210,10 @@ int filt_audioread(struct knote *kn, long hint);
struct filterops audioread_filtops =
{ 1, NULL, filt_audiordetach, filt_audioread};
-#if NWSKBD_HOTKEY > 0
+#if NWSKBD > 0
/* Mixer manipulation using keyboard */
int wskbd_get_mixerdev(struct audio_softc *sc, int dir, int *index);
-int wskbd_set_mixervolume(int dir);
+int wskbd_set_mixervolume(long dir);
#endif
int
@@ -3107,7 +3107,7 @@ filt_audiowrite(struct knote *kn, long hint)
return AUDIO_FILTWRITE(sc);
}
-#if NAUDIO > 0 && NWSKBD_HOTKEY > 0
+#if NAUDIO > 0 && NWSKBD > 0
int
wskbd_get_mixerdev(struct audio_softc *sc, int dir, int *index)
{
@@ -3166,7 +3166,7 @@ wskbd_get_mixerdev(struct audio_softc *sc, int dir, int *index)
}
int
-wskbd_set_mixervolume(int dir)
+wskbd_set_mixervolume(long dir)
{
struct audio_softc *sc;
mixer_devinfo_t mi;
@@ -3264,4 +3264,4 @@ wskbd_set_mixervolume(int dir)
return (0);
}
-#endif /* NAUDIO > 0 && NWSKBD_HOTKEY > 0 */
+#endif /* NAUDIO > 0 && NWSKBD > 0 */
diff --git a/sys/dev/pckbc/files.pckbc b/sys/dev/pckbc/files.pckbc
index 4c60d9b9b42..7fba8a4e831 100644
--- a/sys/dev/pckbc/files.pckbc
+++ b/sys/dev/pckbc/files.pckbc
@@ -1,8 +1,8 @@
-# $OpenBSD: files.pckbc,v 1.5 2006/08/14 15:55:59 miod Exp $
+# $OpenBSD: files.pckbc,v 1.6 2007/05/31 22:23:13 tedu Exp $
# $NetBSD: files.pckbc,v 1.6 1999/01/23 16:05:56 drochner Exp $
# devices attached at pckbc, for use with wscons
-device pckbd: wskbddev, wskbd_hotkey
+device pckbd: wskbddev
attach pckbd at pckbc
file dev/pckbc/pckbd.c pckbd needs-flag
file dev/pckbc/wskbdmap_mfii.c pckbd
diff --git a/sys/dev/wscons/files.wscons b/sys/dev/wscons/files.wscons
index 362da8dce90..724347eba54 100644
--- a/sys/dev/wscons/files.wscons
+++ b/sys/dev/wscons/files.wscons
@@ -1,4 +1,4 @@
-# $OpenBSD: files.wscons,v 1.14 2006/12/09 20:06:48 miod Exp $
+# $OpenBSD: files.wscons,v 1.15 2007/05/31 22:23:13 tedu Exp $
# $NetBSD: files.wscons,v 1.34 2005/05/04 01:52:16 augustss Exp $
#
@@ -18,7 +18,6 @@ device wsdisplay #tty?
attach wsdisplay at wsemuldisplaydev with wsdisplay_emul
device wskbd
attach wskbd at wskbddev
-define wskbd_hotkey
device wsmouse
attach wsmouse at wsmousedev
@@ -28,8 +27,6 @@ file dev/wscons/wsevent.c wsdisplay | wskbd |
wsmouse | wsmux
file dev/wscons/wskbd.c wskbd needs-flag
file dev/wscons/wskbdutil.c wskbd
-file dev/wscons/wskbd_hotkey.c wskbd & wskbd_hotkey &
- !small_kernel needs-flag
file dev/wscons/wsmouse.c wsmouse needs-flag
pseudo-device wsmux
diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c
index 681d40fc480..786f2e90d39 100644
--- a/sys/dev/wscons/wskbd.c
+++ b/sys/dev/wscons/wskbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wskbd.c,v 1.54 2007/03/25 18:04:14 tedu Exp $ */
+/* $OpenBSD: wskbd.c,v 1.55 2007/05/31 22:23:13 tedu Exp $ */
/* $NetBSD: wskbd.c,v 1.80 2005/05/04 01:52:16 augustss Exp $ */
/*
@@ -95,6 +95,7 @@
#include <sys/fcntl.h>
#include <sys/vnode.h>
#include <sys/poll.h>
+#include <sys/workq.h>
#include <ddb/db_var.h>
@@ -111,10 +112,7 @@
#include "wskbd.h"
#include "wsmux.h"
-#ifdef SMALL_KERNEL
-#undef NWSKBD_HOTKEY
-#define NWSKBD_HOTKEY 0
-#else
+#ifndef SMALL_KERNEL
#define BURNER_SUPPORT
#define SCROLLBACK_SUPPORT
#endif
@@ -300,6 +298,10 @@ static struct wskbd_internal wskbd_console_data;
void wskbd_update_layout(struct wskbd_internal *, kbd_t);
+#if NAUDIO > 0
+extern int wskbd_set_mixervolume(long dir);
+#endif
+
void
wskbd_update_layout(struct wskbd_internal *id, kbd_t enc)
{
@@ -453,9 +455,6 @@ wskbd_attach(struct device *parent, struct device *self, void *aux)
}
#endif
-#if NWSKBD_HOTKEY > 0
- wskbd_hotkey_init();
-#endif
}
void
@@ -1644,22 +1643,27 @@ wskbd_translate(struct wskbd_internal *id, u_int type, int value)
}
}
-#if NWSKBD_HOTKEY > 0
/* Submit Audio keys for hotkey processing */
if (KS_GROUP(ksym) == KS_GROUP_Function) {
switch (ksym) {
#if NAUDIO > 0
case KS_AudioMute:
+ workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
+ (void *)(u_long)0, NULL);
+ break;
case KS_AudioLower:
+ workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
+ (void *)(u_long)1, NULL);
+ break;
case KS_AudioRaise:
- wskbd_hotkey_put(ksym);
+ workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
+ (void *)(u_long)1, NULL);
return (0);
#endif
default:
break;
}
}
-#endif
/* Process compose sequence and dead accents */
res = KS_voidSymbol;
diff --git a/sys/dev/wscons/wskbd_hotkey.c b/sys/dev/wscons/wskbd_hotkey.c
deleted file mode 100644
index ad7e168c185..00000000000
--- a/sys/dev/wscons/wskbd_hotkey.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2006 Alexey Vatchenko <avv@mail.zp.ua>
- *
- * 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.
- */
-
-/*
- * Processing of special key symbols.
- */
-#include "audio.h" /* NAUDIO (mixer tuning) */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kthread.h>
-#include <sys/proc.h>
-
-#include <dev/wscons/wsksymdef.h>
-#include <dev/wscons/wsksymvar.h>
-
-#define WSKBD_HOTKEY_MAXEVENTS 8
-
-static keysym_t ksym_queue[WSKBD_HOTKEY_MAXEVENTS];
-static u_int queue_head, queue_tail;
-static struct simplelock queue_lock;
-static int wskbd_hotkey_initted = 0;
-
-void init_hotkey_thread(void *);
-void hotkey_thread(void *);
-void process_hotkey(keysym_t);
-int wskbd_hotkey_get(keysym_t *);
-
-#if NAUDIO > 0
-extern int wskbd_set_mixervolume(int dir);
-#endif
-
-/* ARGSUSED */
-void
-init_hotkey_thread(void *ctx)
-{
- int error;
-
- error = kthread_create(hotkey_thread, ctx, NULL, "wskbd_hotkey");
-#ifdef DIAGNOSTIC
- if (error != 0)
- printf("init_hotkey_thread: cannot create process\n");
-#endif
-}
-
-/* ARGSUSED */
-void
-hotkey_thread(void *ctx)
-{
- keysym_t sym;
- int error;
-
- for (;;) {
- error = wskbd_hotkey_get(&sym);
- if (error == 0)
- process_hotkey(sym);
- else
- (void) tsleep(ksym_queue, PZERO, "wait", 0);
- }
-
- /* NOTREACHED */
-}
-
-void
-process_hotkey(keysym_t sym)
-{
- /* Process Audio tuning keys */
- switch (sym) {
-#if NAUDIO > 0
- case KS_AudioMute:
- (void) wskbd_set_mixervolume(0);
- break;
- case KS_AudioLower:
- (void) wskbd_set_mixervolume(-1);
- break;
- case KS_AudioRaise:
- (void) wskbd_set_mixervolume(1);
- break;
-#endif
- default:
-#ifdef DEBUG
- printf("process_hotkey: unsupported hotkey\n");
-#endif
- break;
- }
-}
-
-void
-wskbd_hotkey_init(void)
-{
-
- if (wskbd_hotkey_initted == 0) {
- simple_lock_init(&queue_lock);
- queue_head = queue_tail = 0;
- kthread_create_deferred(init_hotkey_thread, NULL);
- wskbd_hotkey_initted = 1;
- }
-}
-
-void
-wskbd_hotkey_put(keysym_t sym)
-{
- int s, changed;
- u_int nxtpos;
-
- changed = 0;
-
- s = spltty();
- simple_lock(&queue_lock);
-
- nxtpos = (queue_head + 1) % WSKBD_HOTKEY_MAXEVENTS;
- if (nxtpos != queue_tail) {
- ksym_queue[queue_head] = sym;
- queue_head = nxtpos;
- changed = 1;
- }
-#ifdef DEBUG
- else
- printf("wskbd_hotkey_put: losing hotkey\n");
-#endif
-
- simple_unlock(&queue_lock);
- splx(s);
-
- if (changed != 0)
- wakeup(ksym_queue);
-}
-
-int
-wskbd_hotkey_get(keysym_t *sym)
-{
- int s, error;
-
- s = spltty();
- simple_lock(&queue_lock);
-
- error = 0;
-
- if (queue_head != queue_tail) {
- *sym = ksym_queue[queue_tail];
- queue_tail = (queue_tail + 1) % WSKBD_HOTKEY_MAXEVENTS;
- } else
- error = EAGAIN;
-
- simple_unlock(&queue_lock);
- splx(s);
-
- return (error);
-}
diff --git a/sys/dev/wscons/wsksymvar.h b/sys/dev/wscons/wsksymvar.h
index 544a4a4cf6f..3a126176550 100644
--- a/sys/dev/wscons/wsksymvar.h
+++ b/sys/dev/wscons/wsksymvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsksymvar.h,v 1.5 2006/05/29 20:23:13 miod Exp $ */
+/* $OpenBSD: wsksymvar.h,v 1.6 2007/05/31 22:23:13 tedu Exp $ */
/* $NetBSD: wsksymvar.h,v 1.8.4.1 2000/07/07 09:50:21 hannken Exp $ */
/*-
@@ -79,12 +79,6 @@ int wskbd_load_keymap(const struct wskbd_mapdata *,
struct wscons_keymap **, int *);
keysym_t wskbd_compose_value(keysym_t *);
-/*
- * keysym_t hotkey functions.
- */
-void wskbd_hotkey_init(void);
-void wskbd_hotkey_put(keysym_t);
-
#endif
#endif /* !_DEV_WSCONS_WSKSYMVAR_H_ */