summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2013-11-04 11:57:27 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2013-11-04 11:57:27 +0000
commit80a45b38d4288005c113217084fe2013700780cd (patch)
tree1c11c2d90aeb4569c2d849fab54744c9c29ff3dd /sys
parent7bc7d64f305711b4a1792780ed48d7a6e66b3b5e (diff)
Convert wskbd_set_mixervolume() to use a task internally instead of
being called in a workq. ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/macppc/dev/abtn.c13
-rw-r--r--sys/arch/sgi/hpc/panel.c8
-rw-r--r--sys/dev/acpi/acpiasus.c14
-rw-r--r--sys/dev/acpi/acpithinkpad.c8
-rw-r--r--sys/dev/audio.c69
-rw-r--r--sys/dev/audiovar.h3
-rw-r--r--sys/dev/wscons/wskbd.c14
7 files changed, 68 insertions, 61 deletions
diff --git a/sys/arch/macppc/dev/abtn.c b/sys/arch/macppc/dev/abtn.c
index 44db50ad7d7..01587e9d390 100644
--- a/sys/arch/macppc/dev/abtn.c
+++ b/sys/arch/macppc/dev/abtn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: abtn.c,v 1.14 2011/06/15 21:32:04 miod Exp $ */
+/* $OpenBSD: abtn.c,v 1.15 2013/11/04 11:57:26 mpi Exp $ */
/* $NetBSD: abtn.c,v 1.1 1999/07/12 17:48:26 tsubai Exp $ */
/*-
@@ -61,7 +61,7 @@ void abtn_adbcomplete(caddr_t, caddr_t, int);
#if NWSKBD > 0
extern int cd_eject(void);
#if NAUDIO > 0
-extern int wskbd_set_mixervolume(long dir);
+extern int wskbd_set_mixervolume(long, long);
#endif
#endif
@@ -130,18 +130,15 @@ abtn_adbcomplete(caddr_t buffer, caddr_t data, int adb_command)
#if NAUDIO > 0 && NWSKBD > 0
case 0x08: /* mute */
case 0x01: /* mute, AV hardware */
- workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
- (void *)(long)0, (void *)(int)1);
+ wskbd_set_mixervolume(0, 1);
break;
case 0x07: /* decrease volume */
case 0x02: /* decrease volume, AV hardware */
- workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
- (void *)(long)-1, (void *)(int)1);
+ wskbd_set_mixervolume(-1, 1);
break;
case 0x06: /* increase volume */
case 0x03: /* increase volume, AV hardware */
- workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
- (void *)(long)1, (void *)(int)1);
+ wskbd_set_mixervolume(1, 1);
break;
#endif
case 0x0c: /* mirror display key */
diff --git a/sys/arch/sgi/hpc/panel.c b/sys/arch/sgi/hpc/panel.c
index e9e8bb16b7d..2e4e1ed5467 100644
--- a/sys/arch/sgi/hpc/panel.c
+++ b/sys/arch/sgi/hpc/panel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: panel.c,v 1.1 2012/04/17 15:23:01 miod Exp $ */
+/* $OpenBSD: panel.c,v 1.2 2013/11/04 11:57:26 mpi Exp $ */
/*
* Copyright (c) 2012 Miodrag Vallat.
@@ -22,7 +22,6 @@
#include <sys/proc.h>
#include <sys/signalvar.h>
#include <sys/timeout.h>
-#include <sys/workq.h>
#include <machine/autoconf.h>
#include <mips64/archtype.h>
@@ -36,7 +35,7 @@
#include "audio.h"
#include "wskbd.h"
-extern int wskbd_set_mixervolume(long);
+extern int wskbd_set_mixervolume(long, long);
struct panel_softc {
struct device sc_dev;
@@ -222,7 +221,6 @@ panel_volume_adjust(struct panel_softc *sc, uint8_t reg)
return;
}
- workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
- (void *)adjust, (void *)(int)1);
+ wskbd_set_mixervolume(adjust, 1);
}
#endif
diff --git a/sys/dev/acpi/acpiasus.c b/sys/dev/acpi/acpiasus.c
index 48e1bc59d31..e20f6d6dc29 100644
--- a/sys/dev/acpi/acpiasus.c
+++ b/sys/dev/acpi/acpiasus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpiasus.c,v 1.13 2013/06/20 09:52:09 mpi Exp $ */
+/* $OpenBSD: acpiasus.c,v 1.14 2013/11/04 11:57:26 mpi Exp $ */
/* $NetBSD: asus_acpi.c,v 1.2.2.2 2008/04/03 12:42:37 mjf Exp $ */
/*
* Copyright (c) 2007, 2008 Jared D. McNeill <jmcneill@invisible.ca>
@@ -33,7 +33,6 @@
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
-#include <sys/workq.h>
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
@@ -84,7 +83,7 @@ int acpiasus_notify(struct aml_node *, int, void *);
int acpiasus_activate(struct device *, int);
#if NAUDIO > 0 && NWSKBD > 0
-extern int wskbd_set_mixervolume(long dir, int out);
+extern int wskbd_set_mixervolume(long, long);
#endif
struct cfattach acpiasus_ca = {
@@ -166,16 +165,13 @@ acpiasus_notify(struct aml_node *node, int notify, void *arg)
break;
#if NAUDIO > 0 && NWSKBD > 0
case ASUS_NOTIFY_VOLUMEMUTE:
- workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
- (void *)(long)0, (void *)(int)1);
+ wskbd_set_mixervolume(0, 1);
break;
case ASUS_NOTIFY_VOLUMEDOWN:
- workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
- (void *)(long)-1, (void *)(int)1);
+ wskbd_set_mixervolume(-1, 1);
break;
case ASUS_NOTIFY_VOLUMEUP:
- workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
- (void *)(long)1, (void *)(int)1);
+ wskbd_set_mixervolume(1, 1);
break;
#else
case ASUS_NOTIFY_VOLUMEMUTE:
diff --git a/sys/dev/acpi/acpithinkpad.c b/sys/dev/acpi/acpithinkpad.c
index 7fa99bdbbcb..ceb150cfb94 100644
--- a/sys/dev/acpi/acpithinkpad.c
+++ b/sys/dev/acpi/acpithinkpad.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpithinkpad.c,v 1.33 2013/10/30 05:03:16 mlarkin Exp $ */
+/* $OpenBSD: acpithinkpad.c,v 1.34 2013/11/04 11:57:26 mpi Exp $ */
/*
* Copyright (c) 2008 joshua stein <jcs@openbsd.org>
*
@@ -18,7 +18,6 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
-#include <sys/workq.h>
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
@@ -116,7 +115,7 @@ void thinkpad_sensor_attach(struct acpithinkpad_softc *sc);
void thinkpad_sensor_refresh(void *);
#if NAUDIO > 0 && NWSKBD > 0
-extern int wskbd_set_mixervolume(long dir, int out);
+extern int wskbd_set_mixervolume(long, long);
#endif
struct cfattach acpithinkpad_ca = {
@@ -318,8 +317,7 @@ thinkpad_hotkey(struct aml_node *node, int notify_type, void *arg)
break;
case THINKPAD_BUTTON_MICROPHONE_MUTE:
#if NAUDIO > 0 && NWSKBD > 0
- workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
- (void *)(long)0, (void *)(int)0);
+ wskbd_set_mixervolume(0, 0);
#endif
handled = 1;
break;
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index b7a8f933418..7c41df8cdaa 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: audio.c,v 1.116 2013/10/30 02:13:52 dlg Exp $ */
+/* $OpenBSD: audio.c,v 1.117 2013/11/04 11:57:26 mpi Exp $ */
/* $NetBSD: audio.c,v 1.119 1999/11/09 16:50:47 augustss Exp $ */
/*
@@ -217,7 +217,8 @@ struct filterops audioread_filtops =
#if NWSKBD > 0
/* Mixer manipulation using keyboard */
-int wskbd_set_mixervolume(long, int);
+int wskbd_set_mixervolume(long, long);
+void wskbd_set_mixervolume_callback(void *, void *);
#endif
/*
@@ -354,6 +355,10 @@ audioattach(struct device *parent, struct device *self, void *aux)
timeout_set(&sc->sc_resume_to, audio_resume_to, sc);
task_set(&sc->sc_resume_task, audio_resume_task, sc, NULL);
+#if NWSKBD > 0
+ task_set(&sc->sc_mixer_task, wskbd_set_mixervolume_callback, NULL,
+ NULL);
+#endif /* NWSKBD > 0 */
}
int
@@ -3334,25 +3339,47 @@ filt_audiowrite(struct knote *kn, long hint)
#if NWSKBD > 0
int
-wskbd_set_mixervolume(long dir, int out)
+wskbd_set_mixervolume(long dir, long out)
{
struct audio_softc *sc;
- mixer_devinfo_t mi;
- int error;
- u_int gain;
- u_char balance, mute;
- struct au_mixer_ports *ports;
if (audio_cd.cd_ndevs == 0 || (sc = audio_cd.cd_devs[0]) == NULL) {
DPRINTF(("wskbd_set_mixervolume: audio_cd\n"));
return (ENXIO);
}
+ task_del(systq, &sc->sc_mixer_task);
+ task_set(&sc->sc_mixer_task, wskbd_set_mixervolume_callback,
+ (void *)dir, (void *)out);
+ task_add(systq, &sc->sc_mixer_task);
+
+ return (0);
+}
+
+void
+wskbd_set_mixervolume_callback(void *arg1, void *arg2)
+{
+ struct audio_softc *sc;
+ struct au_mixer_ports *ports;
+ mixer_devinfo_t mi;
+ u_char balance, mute;
+ long dir, out;
+ u_int gain;
+ int error;
+
+ if (audio_cd.cd_ndevs == 0 || (sc = audio_cd.cd_devs[0]) == NULL) {
+ DPRINTF(("%s: audio_cd\n", __func__));
+ return;
+ }
+
+ dir = (long)arg1;
+ out = (long)arg2;
+
ports = out ? &sc->sc_outports : &sc->sc_inports;
if (ports->master == -1) {
- DPRINTF(("wskbd_set_mixervolume: master == -1\n"));
- return (ENXIO);
+ DPRINTF(("%s: master == -1\n", __func__));
+ return;
}
if (dir == 0) {
@@ -3360,18 +3387,16 @@ wskbd_set_mixervolume(long dir, int out)
error = au_get_mute(sc, ports, &mute);
if (error != 0) {
- DPRINTF(("wskbd_set_mixervolume:"
- " au_get_mute: %d\n", error));
- return (error);
+ DPRINTF(("%s: au_get_mute: %d\n", __func__, error));
+ return;
}
mute = !mute;
error = au_set_mute(sc, ports, mute);
if (error != 0) {
- DPRINTF(("wskbd_set_mixervolume:"
- " au_set_mute: %d\n", error));
- return (error);
+ DPRINTF(("%s: au_set_mute: %d\n", __func__, error));
+ return;
}
} else {
/* Raise or lower volume */
@@ -3379,9 +3404,8 @@ wskbd_set_mixervolume(long dir, int out)
mi.index = ports->master;
error = sc->hw_if->query_devinfo(sc->hw_hdl, &mi);
if (error != 0) {
- DPRINTF(("wskbd_set_mixervolume:"
- " query_devinfo: %d\n", error));
- return (error);
+ DPRINTF(("%s: query_devinfo: %d\n", __func__, error));
+ return;
}
au_get_gain(sc, ports, &gain, &balance);
@@ -3393,12 +3417,9 @@ wskbd_set_mixervolume(long dir, int out)
error = au_set_gain(sc, ports, gain, balance);
if (error != 0) {
- DPRINTF(("wskbd_set_mixervolume:"
- " au_set_gain: %d\n", error));
- return (error);
+ DPRINTF(("%s: au_set_gain: %d\n", __func__, error));
+ return;
}
}
-
- return (0);
}
#endif /* NWSKBD > 0 */
diff --git a/sys/dev/audiovar.h b/sys/dev/audiovar.h
index 43b0c1fe3a2..8886c88fe87 100644
--- a/sys/dev/audiovar.h
+++ b/sys/dev/audiovar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: audiovar.h,v 1.14 2013/10/30 02:13:53 dlg Exp $ */
+/* $OpenBSD: audiovar.h,v 1.15 2013/11/04 11:57:26 mpi Exp $ */
/* $NetBSD: audiovar.h,v 1.18 1998/03/03 09:16:16 augustss Exp $ */
/*
@@ -141,6 +141,7 @@ struct audio_softc {
#define AUDIO_QUIESCE_SILENT 2
struct timeout sc_resume_to;
struct task sc_resume_task;
+ struct task sc_mixer_task;
u_char sc_mute;
#ifdef AUDIO_INTR_TIME
diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c
index 0cc9e91d46d..d9cca40c364 100644
--- a/sys/dev/wscons/wskbd.c
+++ b/sys/dev/wscons/wskbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wskbd.c,v 1.74 2013/10/18 22:06:42 miod Exp $ */
+/* $OpenBSD: wskbd.c,v 1.75 2013/11/04 11:57:26 mpi Exp $ */
/* $NetBSD: wskbd.c,v 1.80 2005/05/04 01:52:16 augustss Exp $ */
/*
@@ -95,7 +95,6 @@
#include <sys/fcntl.h>
#include <sys/vnode.h>
#include <sys/poll.h>
-#include <sys/workq.h>
#include <ddb/db_var.h>
@@ -298,7 +297,7 @@ 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, int out);
+extern int wskbd_set_mixervolume(long, long);
#endif
void
@@ -1644,16 +1643,13 @@ wskbd_translate(struct wskbd_internal *id, u_int type, int value)
switch (ksym) {
#if NAUDIO > 0
case KS_AudioMute:
- workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
- (void *)(long)0, (void *)(int)1);
+ wskbd_set_mixervolume(0, 1);
return (0);
case KS_AudioLower:
- workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
- (void *)(long)-1, (void*)(int)1);
+ wskbd_set_mixervolume(-1, 1);
return (0);
case KS_AudioRaise:
- workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
- (void *)(long)1, (void*)(int)1);
+ wskbd_set_mixervolume(1, 1);
return (0);
#endif
default: