Re: Please review: PC-Card melody beep code.

2000-10-24 Thread Warner Losh

In message [EMAIL PROTECTED] Tony Finch writes:
: I tried this on 4.1.1-STABLE with two pccards: a D-Link DE660 and a
: Lucent Wavelan card. The de card workedd fine, but the success melody
: beep for the wi card was several times slower than it should be. I can
: get more information if you need it.

I've noticed this on the unpackted -current as well.  Something in wi
keeps timeouts from firing quickly enough, or at least that's my guess.

Warner


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: Please review: PC-Card melody beep code.

2000-10-23 Thread Rich Wales

It looks like you have the "duration" and "pitch" elements reversed
in your "tone" structure.

Rich Wales [EMAIL PROTECTED] http://www.webcom.com/richw/



. . .

+struct tone {
+int duration;
+int pitch;
+};

. . .

+static struct tone success_melody_beep[] = {
+   {1200,7}, {1000,7}, { 800,   15}, {NULL, NULL}
+};

. . .





To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Please review: PC-Card melody beep code.

2000-10-22 Thread MIHIRA Sanpei Yoshiro

Hi.
FreeBSD developers.

  This is PC-Card melody beep code for
5-current(/sys/pccard/pccard_beep.c) from PAO3.  This patch does not
need to change sys/i386/isa/clock.c.

Any problems, please let me know.
---
MIHIRA, Sanpei Yoshiro
Yokohama, Japan.

Index: src/sys/pccard/driver.h
===
RCS file: /home/ncvs/src/sys/pccard/driver.h,v
retrieving revision 1.12
diff -u -r1.12 driver.h
--- src/sys/pccard/driver.h 1999/12/02 19:46:40 1.12
+++ src/sys/pccard/driver.h 2000/10/22 14:25:34
@@ -19,6 +19,6 @@
 void   pccard_remove_beep __P((void));
 void   pccard_success_beep __P((void));
 void   pccard_failure_beep __P((void));
-intpccard_beep_select __P((enum beepstate));
+intpccard_beep_select __P((int));
 
 #endif /* !_PCCARD_DRIVER_H_ */
Index: src/sys/pccard/pccard_beep.c
===
RCS file: /home/ncvs/src/sys/pccard/pccard_beep.c,v
retrieving revision 1.3
diff -u -r1.3 pccard_beep.c
--- src/sys/pccard/pccard_beep.c1999/12/02 19:46:41 1.3
+++ src/sys/pccard/pccard_beep.c2000/10/22 14:25:34
@@ -13,67 +13,118 @@
 
 #include pccard/driver.h
 
-#definePCCARD_BEEP_PITCH0  1600
-#definePCCARD_BEEP_DURATION0   20
-#definePCCARD_BEEP_PITCH1  1200
-#definePCCARD_BEEP_DURATION1   40
-#definePCCARD_BEEP_PITCH2  3200
-#definePCCARD_BEEP_DURATION2   40
-
-static struct callout_handle beeptimeout_ch
-= CALLOUT_HANDLE_INITIALIZER(beeptimeout_ch);
-
 static enum beepstate allow_beep = BEEP_OFF;
+static int melody_type = 0;
 
-/*
- * 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);
+#define MAX_TONE_MODE  3
+#define MAX_STATE  4 
 
-   allow_beep = BEEP_ON;
+struct tone {
+int duration;
+int pitch;
+};
+
+
+static struct tone silent_beep[] = {
+   {NULL, NULL}
+};
+
+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)
+{
+   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_insert_beep(void)
+static void
+pccard_beep_start(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;
 
-void pccard_remove_beep(void)
-{
-   if (allow_beep == BEEP_ON) {
-   sysbeep(PCCARD_BEEP_PITCH0, PCCARD_BEEP_DURATION0);
+   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)
+{
+   pccard_beep_start(melody_table[melody_type][2]);
+}
+
+void