summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authornat <nat@NetBSD.org>2017-06-11 03:33:48 +0000
committernat <nat@NetBSD.org>2017-06-11 03:33:48 +0000
commitbfcf5f245a268dbbd2bafabe5d6193e554cb8094 (patch)
tree38fbea539b4e8b1492d49c37b6a3581486cb9b0c /sys/dev
parent4f352c5a8eb88739953987783cae100dc16808e4 (diff)
Add ioctls for setting and getting the beep volume. Currently only
supported on spkr devices attached to audio. Ok pgoyette@.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/spkr.c12
-rw-r--r--sys/dev/spkr_audio.c11
-rw-r--r--sys/dev/spkrio.h4
-rw-r--r--sys/dev/spkrvar.h3
4 files changed, 22 insertions, 8 deletions
diff --git a/sys/dev/spkr.c b/sys/dev/spkr.c
index 4b18a1ef200..80e3cdb4a67 100644
--- a/sys/dev/spkr.c
+++ b/sys/dev/spkr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: spkr.c,v 1.7 2017/06/01 09:44:30 pgoyette Exp $ */
+/* $NetBSD: spkr.c,v 1.8 2017/06/11 03:33:48 nat Exp $ */
/*
* Copyright (c) 1990 Eric S. Raymond (esr@snark.thyrsus.com)
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.7 2017/06/01 09:44:30 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.8 2017/06/11 03:33:48 nat Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -484,6 +484,14 @@ spkrioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
playonetone(sc, &ttp);
}
return 0;
+ case SPKRGETVOL:
+ if (data != NULL)
+ *(u_int *)data = sc->sc_vol;
+ return 0;
+ case SPKRSETVOL:
+ if (data != NULL && *(u_int *)data <= 100)
+ sc->sc_vol = *(u_int *)data;
+ return 0;
default:
return ENOTTY;
}
diff --git a/sys/dev/spkr_audio.c b/sys/dev/spkr_audio.c
index 0c95e7c1626..769df5fa7c7 100644
--- a/sys/dev/spkr_audio.c
+++ b/sys/dev/spkr_audio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: spkr_audio.c,v 1.4 2017/06/11 03:25:02 nat Exp $ */
+/* $NetBSD: spkr_audio.c,v 1.5 2017/06/11 03:33:48 nat Exp $ */
/*-
* Copyright (c) 2016 Nathanial Sloss <nathanialsloss@yahoo.com.au>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.4 2017/06/11 03:25:02 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.5 2017/06/11 03:33:48 nat Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -68,7 +68,8 @@ spkr_audio_tone(device_t self, u_int xhz, u_int ticks)
#ifdef SPKRDEBUG
aprint_debug_dev(self, "%s: %u %d\n", __func__, xhz, ticks);
#endif /* SPKRDEBUG */
- audiobell(sc->sc_audiodev, xhz, ticks * (1000 / hz), 80, 0);
+ audiobell(sc->sc_audiodev, xhz, ticks * (1000 / hz),
+ sc->sc_spkr.sc_vol, 0);
}
static void
@@ -80,7 +81,8 @@ spkr_audio_rest(device_t self, int ticks)
aprint_debug_dev(self, "%s: %d\n", __func__, ticks);
#endif /* SPKRDEBUG */
if (ticks > 0)
- audiobell(sc->sc_audiodev, 0, ticks * (1000 / hz), 80, 0);
+ audiobell(sc->sc_audiodev, 0, ticks * (1000 / hz),
+ sc->sc_spkr.sc_vol, 0);
}
static int
@@ -99,6 +101,7 @@ spkr_audio_attach(device_t parent, device_t self, void *aux)
aprint_normal(": PC Speaker (synthesized)\n");
sc->sc_audiodev = parent;
+ sc->sc_spkr.sc_vol = 80;
if (!pmf_device_register(self, NULL, NULL))
aprint_error_dev(self, "couldn't establish power handler\n");
diff --git a/sys/dev/spkrio.h b/sys/dev/spkrio.h
index db703fc2cbe..42833dee07c 100644
--- a/sys/dev/spkrio.h
+++ b/sys/dev/spkrio.h
@@ -1,4 +1,4 @@
-/* $NetBSD: spkrio.h,v 1.2 2016/12/09 04:46:39 christos Exp $ */
+/* $NetBSD: spkrio.h,v 1.3 2017/06/11 03:33:48 nat Exp $ */
/*
* spkrio.h -- interface definitions for speaker ioctl()
@@ -11,6 +11,8 @@
#define SPKRTONE _IOW('S', 1, tone_t) /* emit tone */
#define SPKRTUNE _IO('S', 2) /* emit tone sequence */
+#define SPKRGETVOL _IOR('S', 3, u_int) /* get volume */
+#define SPKRSETVOL _IOW('S', 4, u_int) /* set volume */
typedef struct {
int frequency; /* in hertz */
diff --git a/sys/dev/spkrvar.h b/sys/dev/spkrvar.h
index 7a20bab0cdf..ff73f1aec63 100644
--- a/sys/dev/spkrvar.h
+++ b/sys/dev/spkrvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: spkrvar.h,v 1.6 2017/01/06 09:32:08 pgoyette Exp $ */
+/* $NetBSD: spkrvar.h,v 1.7 2017/06/11 03:33:48 nat Exp $ */
#ifndef _SYS_DEV_SPKRVAR_H
#define _SYS_DEV_SPKRVAR_H
@@ -18,6 +18,7 @@ struct spkr_softc {
/* attachment-specific hooks */
void (*sc_tone)(device_t, u_int, u_int);
void (*sc_rest)(device_t, int);
+ u_int sc_vol; /* volume - only for audio skpr */
};
void spkr_attach(device_t,