aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/tty_cons.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2008-03-26 20:09:21 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2008-03-26 20:09:21 +0000
commite46598588587b4897f6604489364f83fffd4d033 (patch)
treee91c04a22676482787a397cde06c51737c92138e /sys/kern/tty_cons.c
parentf794f567e973adcbce58955f646a53fe4c0f08c8 (diff)
downloadsrc-e46598588587b4897f6604489364f83fffd4d033.tar.gz
src-e46598588587b4897f6604489364f83fffd4d033.zip
The "free-lance" timer in the i8254 is only used for the speaker
these days, so de-generalize the acquire_timer/release_timer api to just deal with speakers. The new (optional) MD functions are: timer_spkr_acquire() timer_spkr_release() and timer_spkr_setfreq() the last of which configures the timer to generate a tone of a given frequency, in Hz instead of 1/1193182th of seconds. Drop entirely timer2 on pc98, it is not used anywhere at all. Move sysbeep() to kern/tty_cons.c and use the timer_spkr*() if they exist, and do nothing otherwise. Remove prototypes and empty acquire-/release-timer() and sysbeep() functions from the non-beeping archs. This eliminate the need for the speaker driver to know about i8254frequency at all. In theory this makes the speaker driver MI, contingent on the timer_spkr_*() functions existing but the driver does not know this yet and still attaches to the ISA bus. Syscons is more tricky, in one function, sc_tone(), it knows the hz and things are just fine. In the other function, sc_bell() it seems to get the period from the KDMKTONE ioctl in terms if 1/1193182th second, so we hardcode the 1193182 and leave it at that. It's probably not important. Change a few other sysbeep() uses which obviously knew that the argument was in terms of i8254 frequency, and leave alone those that look like people thought sysbeep() took frequency in hertz. This eliminates the knowledge of i8254_freq from all but the actual clock.c code and the prof_machdep.c on amd64 and i386, where I think it would be smart to ask for help from the timecounters anyway [TBD].
Notes
Notes: svn path=/head/; revision=177642
Diffstat (limited to 'sys/kern/tty_cons.c')
-rw-r--r--sys/kern/tty_cons.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c
index 624ae85a785b..99f6f5195276 100644
--- a/sys/kern/tty_cons.c
+++ b/sys/kern/tty_cons.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <ddb/ddb.h>
#include <machine/cpu.h>
+#include <machine/clock.h>
static d_open_t cnopen;
static d_close_t cnclose;
@@ -732,3 +733,53 @@ cn_drvinit(void *unused)
}
SYSINIT(cndev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, cn_drvinit, NULL);
+
+/*
+ * Sysbeep(), if we have hardware for it
+ */
+
+#ifdef HAS_TIMER_SPKR
+
+static int beeping;
+
+static void
+sysbeepstop(void *chan)
+{
+
+ timer_spkr_release();
+ beeping = 0;
+}
+
+int
+sysbeep(int pitch, int period)
+{
+
+ if (timer_spkr_acquire()) {
+ if (!beeping) {
+ /* Something else owns it. */
+ return (EBUSY);
+ }
+ }
+ timer_spkr_setfreq(pitch);
+ if (!beeping) {
+ beeping = period;
+ timeout(sysbeepstop, (void *)NULL, period);
+ }
+ return (0);
+}
+
+#else
+
+/*
+ * No hardware, no sound
+ */
+
+int
+sysbeep(int pitch __unused, int period __unused)
+{
+
+ return (ENODEV);
+}
+
+#endif
+