summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/defaults/rc.conf2
-rw-r--r--release/sysinstall/pccard.c2
-rw-r--r--share/man/man5/rc.conf.52
-rw-r--r--sys/pccard/driver.h2
-rw-r--r--sys/pccard/pccard_beep.c131
-rw-r--r--usr.sbin/pccard/pccardc/pccardc.82
-rw-r--r--usr.sbin/sysinstall/pccard.c2
7 files changed, 99 insertions, 44 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index fdfa655..0e65914 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -25,7 +25,7 @@ apmd_enable="NO" # Run apmd to handle APM event from userland.
apmd_flags="" # Flags to apmd (if enabled).
pccard_enable="NO" # Set to YES if you want to configure PCCARD devices.
pccard_mem="DEFAULT" # If pccard_enable=YES, this is card memory address.
-pccard_beep="1" # pccard beep type.
+pccard_beep="2" # pccard beep type.
pccard_ifconfig="NO" # Specialized pccard ethernet configuration (or NO).
pccardd_flags="" # Additional flags for pccardd.
pccard_conf="/etc/defaults/pccard.conf" # pccardd(8) config file
diff --git a/release/sysinstall/pccard.c b/release/sysinstall/pccard.c
index ba7a9bd..546b5b7 100644
--- a/release/sysinstall/pccard.c
+++ b/release/sysinstall/pccard.c
@@ -223,7 +223,7 @@ pccardInitialize(void)
restorescr(w);
return;
}
- beep_newstat = 1;
+ beep_newstat = 2;
if (ioctl(fd, PIOCSBEEP, &beep_newstat) < 0) {
msgNotify("Warning: unable to set pccard insertion beep type for %s",
card_device);
diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5
index 261da1e..0fbfedb 100644
--- a/share/man/man5/rc.conf.5
+++ b/share/man/man5/rc.conf.5
@@ -114,6 +114,8 @@ for a fixed address or "DHCP" for a DHCP client).
set the PCCARD controller to silent mode.
If 1,
set it to beep mode.
+If 2,
+set it to melody mode.
.It Ar pccard_conf
(str) Path to the configuration file for the
.Xr pccardd 8
diff --git a/sys/pccard/driver.h b/sys/pccard/driver.h
index 7df99dd..3b237f3 100644
--- a/sys/pccard/driver.h
+++ b/sys/pccard/driver.h
@@ -19,6 +19,6 @@ void pccard_insert_beep __P((void));
void pccard_remove_beep __P((void));
void pccard_success_beep __P((void));
void pccard_failure_beep __P((void));
-int pccard_beep_select __P((enum beepstate));
+int pccard_beep_select __P((int));
#endif /* !_PCCARD_DRIVER_H_ */
diff --git a/sys/pccard/pccard_beep.c b/sys/pccard/pccard_beep.c
index 98b58ca..587eb6b 100644
--- a/sys/pccard/pccard_beep.c
+++ b/sys/pccard/pccard_beep.c
@@ -13,67 +13,118 @@
#include <pccard/driver.h>
-#define PCCARD_BEEP_PITCH0 1600
-#define PCCARD_BEEP_DURATION0 20
-#define PCCARD_BEEP_PITCH1 1200
-#define PCCARD_BEEP_DURATION1 40
-#define PCCARD_BEEP_PITCH2 3200
-#define PCCARD_BEEP_DURATION2 40
+static enum beepstate allow_beep = BEEP_OFF;
+static int melody_type = 0;
-static struct callout_handle beeptimeout_ch
- = CALLOUT_HANDLE_INITIALIZER(&beeptimeout_ch);
+#define MAX_TONE_MODE 3
+#define MAX_STATE 4
-static enum beepstate allow_beep = BEEP_OFF;
+struct tone {
+ int pitch;
+ int duration;
+};
-/*
- * timeout function to keep lots of noise from
- * happening with insertion/removals.
- */
-static void enable_beep(void *dummy)
-{
- /* Should never be needed */
- untimeout(enable_beep, (void *)NULL, beeptimeout_ch);
- allow_beep = BEEP_ON;
-}
+static struct tone silent_beep[] = {
+ {NULL, NULL}
+};
-void pccard_insert_beep(void)
+static struct tone success_beep[] = {
+ {1200, 40}, {NULL, NULL}
+};
+static struct tone failure_beep[] = {
+ {3200, 40}, {NULL, NULL}
+};
+static struct tone insert_remove_beep[] = {
+ {1600, 20}, {NULL, NULL}
+};
+
+static struct tone success_melody_beep[] = {
+ {1200, 7}, {1000, 7}, { 800, 15}, {NULL, NULL}
+};
+static struct tone failure_melody_beep[] = {
+ {2000, 7}, {2400, 7}, {2800, 15}, {NULL, NULL}
+};
+static struct tone insert_melody_beep[] = {
+ {1600, 10}, {1200, 5}, {NULL, NULL}
+};
+static struct tone remove_melody_beep[] = {
+ {1200, 10}, {1600, 5}, {NULL, NULL}
+};
+
+static struct tone *melody_table[MAX_TONE_MODE][MAX_STATE] = {
+ { /* silent mode */
+ silent_beep, silent_beep, silent_beep, silent_beep,
+ },
+ { /* simple beep mode */
+ success_beep, failure_beep,
+ insert_remove_beep, insert_remove_beep,
+ },
+ { /* melody beep mode */
+ success_melody_beep, failure_melody_beep,
+ insert_melody_beep, remove_melody_beep,
+ },
+};
+
+
+static void
+pccard_beep_sub(void *arg)
{
- if (allow_beep == BEEP_ON) {
- sysbeep(PCCARD_BEEP_PITCH0, PCCARD_BEEP_DURATION0);
- allow_beep = BEEP_OFF;
- beeptimeout_ch = timeout(enable_beep, (void *)NULL, hz / 5);
- }
+ struct tone *melody;
+ melody = (struct tone *)arg;
+
+ if (melody->duration != NULL) {
+ sysbeep(melody->duration, melody->pitch);
+ timeout(pccard_beep_sub, ++melody, melody->pitch);
+ } else
+ allow_beep = BEEP_ON;
}
-void pccard_remove_beep(void)
+static void
+pccard_beep_start(void *arg)
{
- if (allow_beep == BEEP_ON) {
- sysbeep(PCCARD_BEEP_PITCH0, PCCARD_BEEP_DURATION0);
+ struct tone *melody;
+ melody = (struct tone *)arg;
+
+ if (allow_beep == BEEP_ON && melody->duration != NULL) {
allow_beep = BEEP_OFF;
- beeptimeout_ch = timeout(enable_beep, (void *)NULL, hz / 5);
+ sysbeep(melody->duration, melody->pitch);
+ timeout(pccard_beep_sub, ++melody, melody->pitch);
}
}
void pccard_success_beep(void)
{
- if (allow_beep == BEEP_ON) {
- sysbeep(PCCARD_BEEP_PITCH1, PCCARD_BEEP_DURATION1);
- }
+ pccard_beep_start(melody_table[melody_type][0]);
}
void pccard_failure_beep(void)
{
- if (allow_beep == BEEP_ON) {
- sysbeep(PCCARD_BEEP_PITCH2, PCCARD_BEEP_DURATION2);
- }
+ pccard_beep_start(melody_table[melody_type][1]);
}
-int pccard_beep_select(enum beepstate state)
+void pccard_insert_beep(void)
{
- if (state == BEEP_ON || state == BEEP_OFF) {
- allow_beep = state;
- return 0;
+ pccard_beep_start(melody_table[melody_type][2]);
+}
+
+void pccard_remove_beep(void)
+{
+ pccard_beep_start(melody_table[melody_type][3]);
+}
+
+int pccard_beep_select(int type)
+{
+ int errcode = 0;
+
+ if (type == 0) {
+ allow_beep = BEEP_OFF;
+ melody_type = 0;
+ } else if (type < 0 || type > MAX_TONE_MODE)
+ errcode = 1;
+ else {
+ allow_beep = BEEP_ON;
+ melody_type = type;
}
- return 1;
+ return errcode;
}
diff --git a/usr.sbin/pccard/pccardc/pccardc.8 b/usr.sbin/pccard/pccardc/pccardc.8
index 38bb8ef..3456444c 100644
--- a/usr.sbin/pccard/pccardc/pccardc.8
+++ b/usr.sbin/pccard/pccardc/pccardc.8
@@ -85,6 +85,8 @@ are:
silent mode
.It Li 1
simple beep mode
+.It Li 2
+melody mode
.El
.It
.Ic dumpcis
diff --git a/usr.sbin/sysinstall/pccard.c b/usr.sbin/sysinstall/pccard.c
index ba7a9bd..546b5b7 100644
--- a/usr.sbin/sysinstall/pccard.c
+++ b/usr.sbin/sysinstall/pccard.c
@@ -223,7 +223,7 @@ pccardInitialize(void)
restorescr(w);
return;
}
- beep_newstat = 1;
+ beep_newstat = 2;
if (ioctl(fd, PIOCSBEEP, &beep_newstat) < 0) {
msgNotify("Warning: unable to set pccard insertion beep type for %s",
card_device);
OpenPOWER on IntegriCloud