2 * pccard noise interface.
3 * Nate Williams, October 1997.
4 * This file is in the public domain.
10 #include <sys/param.h>
11 #include <sys/kernel.h>
12 #include <sys/systm.h>
14 #include <machine/clock.h>
16 #include <pccard/driver.h>
18 static enum beepstate allow_beep = BEEP_OFF;
19 static int melody_type = 0;
21 #define MAX_TONE_MODE 3
29 static struct tone silent_beep[] = {
33 static struct tone success_beep[] = {
36 static struct tone failure_beep[] = {
39 static struct tone insert_remove_beep[] = {
43 static struct tone success_melody_beep[] = {
44 {1200, 7}, {1000, 7}, { 800, 15}, {0, 0}
46 static struct tone failure_melody_beep[] = {
47 {2000, 7}, {2400, 7}, {2800, 15}, {0, 0}
49 static struct tone insert_melody_beep[] = {
50 {1600, 10}, {1200, 5}, {0, 0}
52 static struct tone remove_melody_beep[] = {
53 {1200, 10}, {1600, 5}, {0, 0}
56 static struct tone *melody_table[MAX_TONE_MODE][MAX_STATE] = {
58 silent_beep, silent_beep, silent_beep, silent_beep,
60 { /* simple beep mode */
61 success_beep, failure_beep,
62 insert_remove_beep, insert_remove_beep,
64 { /* melody beep mode */
65 success_melody_beep, failure_melody_beep,
66 insert_melody_beep, remove_melody_beep,
72 pccard_beep_sub(void *arg)
75 melody = (struct tone *)arg;
77 if (melody->pitch != 0) {
78 sysbeep(melody->pitch, (melody->duration * hz + 99) / 100);
79 timeout(pccard_beep_sub, melody + 1,
80 (melody->duration * hz + 99) / 100);
86 pccard_beep_start(void *arg)
89 melody = (struct tone *)arg;
91 if (allow_beep == BEEP_ON && melody->pitch != 0) {
92 allow_beep = BEEP_OFF;
93 sysbeep(melody->pitch, (melody->duration * hz + 99) / 100);
94 timeout(pccard_beep_sub, melody + 1,
95 (melody->duration * hz + 99) / 100);
100 pccard_success_beep(void)
102 pccard_beep_start(melody_table[melody_type][0]);
106 pccard_failure_beep(void)
108 pccard_beep_start(melody_table[melody_type][1]);
112 pccard_insert_beep(void)
114 pccard_beep_start(melody_table[melody_type][2]);
118 pccard_remove_beep(void)
120 pccard_beep_start(melody_table[melody_type][3]);
124 pccard_beep_select(int type)
129 allow_beep = BEEP_OFF;
131 } else if (type < 0 || MAX_TONE_MODE - 1 < type) {
134 allow_beep = BEEP_ON;