more spkr rework.
This commit is contained in:
parent
13f6a6536b
commit
2fb257653e
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.audio,v 1.5 2016/12/08 11:31:08 nat Exp $
|
||||
# $NetBSD: files.audio,v 1.6 2016/12/09 04:32:39 christos Exp $
|
||||
|
||||
define audiobus { }
|
||||
define midibus { }
|
||||
@ -33,4 +33,5 @@ file dev/midi.c midi needs-flag
|
||||
file dev/midictl.c midisyn
|
||||
file dev/midisyn.c midisyn
|
||||
file dev/mulaw.c mulaw needs-flag
|
||||
file dev/spkr_synth.c spkr & vaudiospeaker needs-flag
|
||||
file dev/spkr.c spkr needs-flag
|
||||
file dev/spkr_synth.c spkr_synth needs-flag
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.isa,v 1.166 2016/12/09 02:22:34 christos Exp $
|
||||
# $NetBSD: files.isa,v 1.167 2016/12/09 04:32:39 christos Exp $
|
||||
#
|
||||
# Config file and device description for machine-independent ISA code.
|
||||
# Included by ports that need it. Requires that the SCSI files be
|
||||
@ -435,7 +435,6 @@ attach pcppi at isa
|
||||
file dev/isa/pcppi.c pcppi needs-flag
|
||||
|
||||
attach spkr at pcppi with spkr_pcppi
|
||||
file dev/isa/spkr.c spkr needs-flag
|
||||
file dev/isa/spkr_pcppi.c spkr_pcppi
|
||||
|
||||
attach midi at pcppi with midi_pcppi: midisyn
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: spkr_pcppi.c,v 1.1 2016/12/09 02:22:34 christos Exp $ */
|
||||
/* $NetBSD: spkr_pcppi.c,v 1.2 2016/12/09 04:32:39 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 Eric S. Raymond (esr@snark.thyrsus.com)
|
||||
@ -43,7 +43,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: spkr_pcppi.c,v 1.1 2016/12/09 02:22:34 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: spkr_pcppi.c,v 1.2 2016/12/09 04:32:39 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -61,21 +61,27 @@ __KERNEL_RCSID(0, "$NetBSD: spkr_pcppi.c,v 1.1 2016/12/09 02:22:34 christos Exp
|
||||
|
||||
#include <dev/isa/pcppivar.h>
|
||||
|
||||
#include <dev/isa/spkrio.h>
|
||||
#include <dev/spkrio.h>
|
||||
|
||||
void spkrattach(device_t, device_t, void *);
|
||||
int spkrdetach(device_t, int);
|
||||
int spkrprobe(device_t, cfdata_t, void *);
|
||||
extern int spkr_attached;
|
||||
static void spkrattach(device_t, device_t, void *);
|
||||
static int spkrdetach(device_t, int);
|
||||
|
||||
#include "ioconf.h"
|
||||
|
||||
MODULE(MODULE_CLASS_DRIVER, spkr, NULL /* "pcppi" */);
|
||||
|
||||
static int
|
||||
spkr_modcmd(modcmd_t cmd, void *arg)
|
||||
{
|
||||
return spkr__modcmd(cmd, arg);
|
||||
}
|
||||
|
||||
#ifdef _MODULE
|
||||
#include "ioconf.c"
|
||||
#endif
|
||||
|
||||
CFATTACH_DECL_NEW(spkr_pcppi, 0, spkrprobe, spkrattach, spkrdetach, NULL);
|
||||
CFATTACH_DECL_NEW(spkr_pcppi, 0, spkr_probe, spkrattach, spkrdetach, NULL);
|
||||
|
||||
static pcppi_tag_t ppicookie;
|
||||
|
||||
@ -104,18 +110,7 @@ spkr_rest(int ticks)
|
||||
tsleep(spkr_rest, SPKRPRI | PCATCH, "rest", ticks);
|
||||
}
|
||||
|
||||
extern int spkr_active; /* exclusion flag */
|
||||
extern const struct cdevsw spkr_cdevsw;
|
||||
|
||||
int spkr_attached = 0;
|
||||
|
||||
int
|
||||
spkrprobe(device_t parent, cfdata_t match, void *aux)
|
||||
{
|
||||
return (!spkr_attached);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
spkrattach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
aprint_naive("\n");
|
||||
@ -126,7 +121,7 @@ spkrattach(device_t parent, device_t self, void *aux)
|
||||
aprint_error_dev(self, "couldn't establish power handler\n");
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
spkrdetach(device_t self, int flags)
|
||||
{
|
||||
|
||||
@ -136,44 +131,3 @@ spkrdetach(device_t self, int flags)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spkr_modcmd(modcmd_t cmd, void *arg)
|
||||
{
|
||||
#ifdef _MODULE
|
||||
devmajor_t bmajor, cmajor;
|
||||
#endif
|
||||
int error = 0;
|
||||
|
||||
#ifdef _MODULE
|
||||
switch(cmd) {
|
||||
case MODULE_CMD_INIT:
|
||||
bmajor = cmajor = -1;
|
||||
error = devsw_attach(spkr_cd.cd_name, NULL, &bmajor,
|
||||
&spkr_cdevsw, &cmajor);
|
||||
if (error)
|
||||
break;
|
||||
|
||||
error = config_init_component(cfdriver_ioconf_spkr,
|
||||
cfattach_ioconf_spkr, cfdata_ioconf_spkr);
|
||||
if (error) {
|
||||
devsw_detach(NULL, &spkr_cdevsw);
|
||||
}
|
||||
break;
|
||||
|
||||
case MODULE_CMD_FINI:
|
||||
if (spkr_active)
|
||||
return EBUSY;
|
||||
error = config_fini_component(cfdriver_ioconf_spkr,
|
||||
cfattach_ioconf_spkr, cfdata_ioconf_spkr);
|
||||
devsw_detach(NULL, &spkr_cdevsw);
|
||||
break;
|
||||
default:
|
||||
error = ENOTTY;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: spkr.c,v 1.39 2016/12/09 02:22:34 christos Exp $ */
|
||||
/* $NetBSD: spkr.c,v 1.1 2016/12/09 04:32:39 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 Eric S. Raymond (esr@snark.thyrsus.com)
|
||||
@ -43,7 +43,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.39 2016/12/09 02:22:34 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.1 2016/12/09 04:32:39 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -59,7 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.39 2016/12/09 02:22:34 christos Exp $");
|
||||
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <dev/isa/spkrio.h>
|
||||
#include <dev/spkrio.h>
|
||||
|
||||
dev_type_open(spkropen);
|
||||
dev_type_close(spkrclose);
|
||||
@ -366,10 +366,16 @@ playstring(char *cp, int slen)
|
||||
* and spkr_rest() functions defined above.
|
||||
*/
|
||||
|
||||
int spkr_active; /* exclusion flag */
|
||||
extern int spkr_attached;
|
||||
static int spkr_active; /* exclusion flag */
|
||||
int spkr_attached;
|
||||
static void *spkr_inbuf;
|
||||
|
||||
int
|
||||
spkr_probe(device_t parent, cfdata_t match, void *aux)
|
||||
{
|
||||
return (!spkr_attached);
|
||||
}
|
||||
|
||||
int
|
||||
spkropen(dev_t dev, int flags, int mode, struct lwp *l)
|
||||
{
|
||||
@ -470,3 +476,43 @@ spkrioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
|
||||
return(EINVAL);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
spkr__modcmd(modcmd_t cmd, void *arg)
|
||||
{
|
||||
#ifdef _MODULE
|
||||
devmajor_t bmajor, cmajor;
|
||||
#endif
|
||||
int error = 0;
|
||||
|
||||
#ifdef _MODULE
|
||||
switch(cmd) {
|
||||
case MODULE_CMD_INIT:
|
||||
bmajor = cmajor = -1;
|
||||
error = devsw_attach(spkr_cd.cd_name, NULL, &bmajor,
|
||||
&spkr_cdevsw, &cmajor);
|
||||
if (error)
|
||||
break;
|
||||
|
||||
error = config_init_component(cfdriver_ioconf_spkr,
|
||||
cfattach_ioconf_spkr, cfdata_ioconf_spkr);
|
||||
if (error) {
|
||||
devsw_detach(NULL, &spkr_cdevsw);
|
||||
}
|
||||
break;
|
||||
|
||||
case MODULE_CMD_FINI:
|
||||
if (spkr_active)
|
||||
return EBUSY;
|
||||
error = config_fini_component(cfdriver_ioconf_spkr,
|
||||
cfattach_ioconf_spkr, cfdata_ioconf_spkr);
|
||||
devsw_detach(NULL, &spkr_cdevsw);
|
||||
break;
|
||||
default:
|
||||
error = ENOTTY;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: spkr_synth.c,v 1.1 2016/12/08 11:31:08 nat Exp $ */
|
||||
/* $NetBSD: spkr_synth.c,v 1.2 2016/12/09 04:32:39 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2016 Nathanial Sloss <nathanialsloss@yahoo.com.au>
|
||||
@ -26,9 +26,8 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef VAUDIOSPEAKER
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: spkr_synth.c,v 1.1 2016/12/08 11:31:08 nat Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: spkr_synth.c,v 1.2 2016/12/09 04:32:39 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -62,26 +61,29 @@ static int beep_sysctl_device(SYSCTLFN_PROTO);
|
||||
#include <dev/audiobellvar.h>
|
||||
|
||||
#include <dev/spkrvar.h>
|
||||
#include <dev/isa/spkrio.h>
|
||||
#include <dev/spkrio.h>
|
||||
|
||||
#include "isa/spkr.c"
|
||||
|
||||
int spkrprobe(device_t, cfdata_t, void *);
|
||||
void spkrattach(device_t, device_t, void *);
|
||||
int spkrdetach(device_t, int);
|
||||
static void spkrattach(device_t, device_t, void *);
|
||||
static int spkrdetach(device_t, int);
|
||||
device_t speakerattach_mi(device_t);
|
||||
|
||||
#include "ioconf.h"
|
||||
|
||||
MODULE(MODULE_CLASS_DRIVER, spkr, NULL /* "audio" */);
|
||||
|
||||
static int
|
||||
spkr_modcmd(modcmd_t cmd, void *arg)
|
||||
{
|
||||
return spkr__modcmd(cmd, arg);
|
||||
}
|
||||
|
||||
#ifdef _MODULE
|
||||
#include "ioconf.c"
|
||||
#endif
|
||||
|
||||
|
||||
CFATTACH_DECL3_NEW(spkr_synth, 0,
|
||||
spkrprobe, spkrattach, spkrdetach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
|
||||
spkr_probe, spkrattach, spkrdetach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
|
||||
|
||||
extern struct cfdriver audio_cd;
|
||||
|
||||
@ -97,17 +99,17 @@ struct spkr_attach_args {
|
||||
device_t dev;
|
||||
};
|
||||
|
||||
static void
|
||||
tone(u_int xhz, u_int ticks)
|
||||
void
|
||||
spkr_tone(u_int xhz, u_int ticks)
|
||||
{
|
||||
audiobell(beep_index, xhz, ticks * (1000 / hz), 80, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
rest(int ticks)
|
||||
void
|
||||
spkr_rest(int ticks)
|
||||
{
|
||||
#ifdef SPKRDEBUG
|
||||
printf("rest: %d\n", ticks);
|
||||
printf("%s: %d\n", __func__, ticks);
|
||||
#endif /* SPKRDEBUG */
|
||||
if (ticks > 0)
|
||||
audiobell(beep_index, 0, ticks * (1000 / hz), 80, 0);
|
||||
@ -121,7 +123,7 @@ speakerattach_mi(device_t dev)
|
||||
return config_found(dev, &sa, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
spkrattach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
const struct sysctlnode *node;
|
||||
@ -160,7 +162,7 @@ spkrattach(device_t parent, device_t self, void *aux)
|
||||
bell_thread, &sc_bell_args, &sc_bellthread, "vbell");
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
spkrdetach(device_t self, int flags)
|
||||
{
|
||||
|
||||
@ -250,6 +252,3 @@ beep_sysctl_device(SYSCTLFN_ARGS)
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
#endif /* VAUDIOSPEAKER */
|
||||
/* spkr.c ends here */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: spkrio.h,v 1.3 2016/12/09 02:22:34 christos Exp $ */
|
||||
/* $NetBSD: spkrio.h,v 1.1 2016/12/09 04:32:39 christos Exp $ */
|
||||
|
||||
/*
|
||||
* spkr.h -- interface definitions for speaker ioctl()
|
||||
@ -19,5 +19,8 @@ typedef struct {
|
||||
|
||||
void spkr_tone(u_int, u_int);
|
||||
void spkr_rest(int);
|
||||
int spkr__modcmd(modcmd_t, void *);
|
||||
int spkr_probe(device_t, cfdata_t, void *);
|
||||
extern int spkr_attached;
|
||||
|
||||
#endif /* _DEV_ISA_SPKR_H_ */
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user