diff options
-rw-r--r-- | sys/conf/files | 1 | ||||
-rw-r--r-- | sys/pccard/card.h | 10 | ||||
-rw-r--r-- | sys/pccard/cardinfo.h | 10 | ||||
-rw-r--r-- | sys/pccard/driver.h | 8 | ||||
-rw-r--r-- | sys/pccard/pccard.c | 27 | ||||
-rw-r--r-- | sys/pccard/pccard_beep.c | 70 |
6 files changed, 84 insertions, 42 deletions
diff --git a/sys/conf/files b/sys/conf/files index 157dbdc..c0799a0 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -354,6 +354,7 @@ nfs/nfs_vnops.c optional nfs nfs/bootp_subr.c optional bootp nfs/krpc_subr.c optional bootp pccard/pccard.c optional card +pccard/pccard_beep.c optional card pccard/pcic.c optional pcic device-driver pci/aic7870.c optional ahc device-driver \ dependency "aic7xxx_reg.h $S/pci/aic7870.c" diff --git a/sys/pccard/card.h b/sys/pccard/card.h index 8be4c25..159a8e7 100644 --- a/sys/pccard/card.h +++ b/sys/pccard/card.h @@ -130,16 +130,6 @@ struct power { }; /* - * Beep parameters - */ -#define PCCARD_BEEP_PITCH0 1600 /* inserted/removed */ -#define PCCARD_BEEP_DURATION0 20 -#define PCCARD_BEEP_PITCH1 1200 /* successed */ -#define PCCARD_BEEP_DURATION1 40 -#define PCCARD_BEEP_PITCH2 3200 /* failed */ -#define PCCARD_BEEP_DURATION2 40 - -/* * Other system limits */ #define MAXSLOT 16 diff --git a/sys/pccard/cardinfo.h b/sys/pccard/cardinfo.h index 8be4c25..159a8e7 100644 --- a/sys/pccard/cardinfo.h +++ b/sys/pccard/cardinfo.h @@ -130,16 +130,6 @@ struct power { }; /* - * Beep parameters - */ -#define PCCARD_BEEP_PITCH0 1600 /* inserted/removed */ -#define PCCARD_BEEP_DURATION0 20 -#define PCCARD_BEEP_PITCH1 1200 /* successed */ -#define PCCARD_BEEP_DURATION1 40 -#define PCCARD_BEEP_PITCH2 3200 /* failed */ -#define PCCARD_BEEP_DURATION2 40 - -/* * Other system limits */ #define MAXSLOT 16 diff --git a/sys/pccard/driver.h b/sys/pccard/driver.h index 3f501e2..ee6942d 100644 --- a/sys/pccard/driver.h +++ b/sys/pccard/driver.h @@ -19,4 +19,12 @@ void pccard_configure __P((void)); void pccard_remove_driver __P((struct pccard_device *)); int pcic_probe __P((void)); /* XXX should be linker set */ +enum beepstate { BEEP_ON, BEEP_OFF }; + +void pccard_insert_beep __P((void)); +void pccard_remove_beep __P((void)); +void pccard_success_beep __P((void)); +void pccard_failure_beep __P((void)); +void pccard_beep_select __P((enum beepstate)); + #endif /* !_PCCARD_DRIVER_H_ */ diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c index 630fc79..cf6f62d 100644 --- a/sys/pccard/pccard.c +++ b/sys/pccard/pccard.c @@ -56,7 +56,6 @@ #include <pccard/driver.h> #include <pccard/slot.h> -#include <machine/clock.h> #include <machine/md_var.h> /* @@ -649,16 +648,6 @@ inserted(void *arg) } /* - * Insert/Remove beep - */ -static int beepok = 0; - -static void enable_beep(void *dummy) -{ - beepok = 1; -} - -/* * Card event callback. Called at splhigh to prevent * device interrupts from interceding. */ @@ -682,20 +671,14 @@ pccard_event(struct slot *slt, enum card_event event) slt->state = empty; splx(s); printf("Card removed, slot %d\n", slt->slotnum); - if (beepok) - sysbeep(PCCARD_BEEP_PITCH0, PCCARD_BEEP_DURATION0); - beepok = 0; - timeout(enable_beep, (void *)NULL, hz/5); + pccard_remove_beep(); selwakeup(&slt->selp); } break; case card_inserted: slt->insert_seq = 1; slt->insert_ch = timeout(inserted, (void *)slt, hz/4); - if (beepok) - sysbeep(PCCARD_BEEP_PITCH0, PCCARD_BEEP_DURATION0); - beepok = 0; - timeout(enable_beep, (void *)NULL, hz/5); + pccard_remove_beep(); break; } } @@ -868,7 +851,7 @@ crdioctl(dev_t dev, int cmd, caddr_t data, int fflag, struct proc *p) int s, err; /* beep is disabled until the 1st call of crdioctl() */ - enable_beep(NULL); + pccard_beep_select(BEEP_ON); if (slt == 0 && cmd != PIOCRWMEM) return(ENXIO); @@ -989,9 +972,9 @@ crdioctl(dev_t dev, int cmd, caddr_t data, int fflag, struct proc *p) return(EPERM); err = allocate_driver(slt, (struct dev_desc *)data); if (!err) - sysbeep(PCCARD_BEEP_PITCH1, PCCARD_BEEP_DURATION1); + pccard_success_beep(); else - sysbeep(PCCARD_BEEP_PITCH2, PCCARD_BEEP_DURATION2); + pccard_failure_beep(); return err; } return(0); diff --git a/sys/pccard/pccard_beep.c b/sys/pccard/pccard_beep.c new file mode 100644 index 0000000..63c6098 --- /dev/null +++ b/sys/pccard/pccard_beep.c @@ -0,0 +1,70 @@ +/*- + * pccard noise interface. + * Nate Williams, October 1997. + * This file is in the public domain. + */ + +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/systm.h> + +#include <machine/clock.h> + +#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 struct callout_handle beeptimeout_ch + = CALLOUT_HANDLE_INITIALIZER(&beeptimeout_ch); + +static enum beepstate allow_beep = BEEP_OFF; + +/* + * 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 = 1; +} + +void pccard_insert_beep(void) +{ + if (allow_beep == BEEP_ON) { + sysbeep(PCCARD_BEEP_PITCH0, PCCARD_BEEP_DURATION0); + allow_beep = 0; + beeptimeout_ch = timeout(enable_beep, (void *)NULL, hz / 5); + } +} + +void pccard_remove_beep(void) +{ + if (allow_beep == BEEP_ON) { + sysbeep(PCCARD_BEEP_PITCH0, PCCARD_BEEP_DURATION0); + allow_beep = 0; + beeptimeout_ch = timeout(enable_beep, (void *)NULL, hz / 5); + } +} + +void pccard_success_beep(void) +{ + sysbeep(PCCARD_BEEP_PITCH1, PCCARD_BEEP_DURATION1); +} + +void pccard_failure_beep(void) +{ + sysbeep(PCCARD_BEEP_PITCH2, PCCARD_BEEP_DURATION2); +} + +void pccard_beep_select(enum beepstate state) +{ + allow_beep = state; +} |