2 * pccard noise interface.
3 * Nate Williams, October 1997.
4 * This file is in the public domain.
6 /* $FreeBSD: src/sys/pccard/pccard_beep.c,v 1.3.2.3 2001/06/05 19:11:34 imp Exp $ */
9 #include <sys/kernel.h>
10 #include <sys/systm.h>
12 #include <machine/clock.h>
14 #include <pccard/driver.h>
16 static enum beepstate allow_beep = BEEP_OFF;
17 static int melody_type = 0;
19 #define MAX_TONE_MODE 3
27 static struct tone silent_beep[] = {
31 static struct tone success_beep[] = {
34 static struct tone failure_beep[] = {
37 static struct tone insert_remove_beep[] = {
41 static struct tone success_melody_beep[] = {
42 {1200, 7}, {1000, 7}, { 800, 15}, {0, 0}
44 static struct tone failure_melody_beep[] = {
45 {2000, 7}, {2400, 7}, {2800, 15}, {0, 0}
47 static struct tone insert_melody_beep[] = {
48 {1600, 10}, {1200, 5}, {0, 0}
50 static struct tone remove_melody_beep[] = {
51 {1200, 10}, {1600, 5}, {0, 0}
54 static struct tone *melody_table[MAX_TONE_MODE][MAX_STATE] = {
56 silent_beep, silent_beep, silent_beep, silent_beep,
58 { /* simple beep mode */
59 success_beep, failure_beep,
60 insert_remove_beep, insert_remove_beep,
62 { /* melody beep mode */
63 success_melody_beep, failure_melody_beep,
64 insert_melody_beep, remove_melody_beep,
70 pccard_beep_sub(void *arg)
73 melody = (struct tone *)arg;
75 if (melody->pitch != 0) {
76 sysbeep(melody->pitch, melody->duration);
77 timeout(pccard_beep_sub, melody + 1, melody->duration);
83 pccard_beep_start(void *arg)
86 melody = (struct tone *)arg;
88 if (allow_beep == BEEP_ON && melody->pitch != 0) {
89 allow_beep = BEEP_OFF;
90 sysbeep(melody->pitch, melody->duration);
91 timeout(pccard_beep_sub, melody + 1, melody->duration);
96 pccard_success_beep(void)
98 pccard_beep_start(melody_table[melody_type][0]);
102 pccard_failure_beep(void)
104 pccard_beep_start(melody_table[melody_type][1]);
108 pccard_insert_beep(void)
110 pccard_beep_start(melody_table[melody_type][2]);
114 pccard_remove_beep(void)
116 pccard_beep_start(melody_table[melody_type][3]);
120 pccard_beep_select(int type)
125 allow_beep = BEEP_OFF;
127 } else if (type < 0 || MAX_TONE_MODE - 1 < type) {
130 allow_beep = BEEP_ON;