34#ifdef HAVE_KERNEL_OPTION_HEADERS
43#include <isa/isavar.h>
49#define SB16_BUFFSIZE 4096
50#define PLAIN_SB16(x) ((((x)->bd_flags) & (BD_F_SB16|BD_F_SB16X)) == BD_F_SB16)
144 return bus_space_read_1(rman_get_bustag(port), rman_get_bushandle(port), off);
150 bus_space_write_1(rman_get_bustag(port), rman_get_bushandle(port), off,
data);
170 for (i = 0; i < 1000; i++) {
172 DELAY((i > 100)? 1000 : 10);
178 if (curthread->td_intr_nesting_level == 0)
179 printf(
"sb_dspwr(0x%02x) timed out.\n",
val);
187 printf(
"sb_cmd: %x\n",
val);
211 printf(
"sb_cmd2: %x, %x\n", cmd,
val);
260 for (i = 1000; i > 0; i--) {
280 DEB(printf(
"sb_reset_dsp 0x%lx failed\n",
297 [SOUND_MIXER_VOLUME] = { 0x30, 5, 3, 1 },
298 [SOUND_MIXER_PCM] = { 0x32, 5, 3, 1 },
299 [SOUND_MIXER_SYNTH] = { 0x34, 5, 3, 1 },
300 [SOUND_MIXER_CD] = { 0x36, 5, 3, 1 },
301 [SOUND_MIXER_LINE] = { 0x38, 5, 3, 1 },
302 [SOUND_MIXER_MIC] = { 0x3a, 5, 3, 0 },
303 [SOUND_MIXER_SPEAKER] = { 0x3b, 5, 3, 0 },
304 [SOUND_MIXER_IGAIN] = { 0x3f, 2, 6, 1 },
305 [SOUND_MIXER_OGAIN] = { 0x41, 2, 6, 1 },
306 [SOUND_MIXER_TREBLE] = { 0x44, 4, 4, 1 },
307 [SOUND_MIXER_BASS] = { 0x46, 4, 4, 1 },
308 [SOUND_MIXER_LINE1] = { 0x52, 5, 3, 1 }
316 mix_setdevs(
m, SOUND_MASK_SYNTH | SOUND_MASK_PCM | SOUND_MASK_SPEAKER |
317 SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD |
318 SOUND_MASK_IGAIN | SOUND_MASK_OGAIN | SOUND_MASK_LINE1 |
319 SOUND_MASK_VOLUME | SOUND_MASK_BASS | SOUND_MASK_TREBLE);
322 SOUND_MASK_LINE1 | SOUND_MASK_MIC | SOUND_MASK_CD);
337 temp = ((x *
max) + 50) / 100;
374 u_char recdev_l, recdev_r;
378 if (
src & SOUND_MASK_MIC) {
383 if (
src & SOUND_MASK_CD) {
388 if (
src & SOUND_MASK_LINE) {
393 if (
src & SOUND_MASK_SYNTH) {
402 if (
src & SOUND_MASK_LINE1)
435 bus_teardown_intr(
dev, sb->
irq, sb->
ih);
436 bus_release_resource(
dev, SYS_RES_IRQ, 0, sb->
irq);
441 isa_dma_release(rman_get_start(sb->
drq2));
442 bus_release_resource(
dev, SYS_RES_DRQ, 1, sb->
drq2);
447 isa_dma_release(rman_get_start(sb->
drq1));
448 bus_release_resource(
dev, SYS_RES_DRQ, 0, sb->
drq1);
452 bus_release_resource(
dev, SYS_RES_IOPORT, 0, sb->
io_base);
469 sb->
io_base = bus_alloc_resource_any(
dev, SYS_RES_IOPORT,
474 sb->
irq = bus_alloc_resource_any(
dev, SYS_RES_IRQ, &
rid,
479 sb->
drq1 = bus_alloc_resource_any(
dev, SYS_RES_DRQ, &
rid,
484 sb->
drq2 = bus_alloc_resource_any(
dev, SYS_RES_DRQ, &
rid,
488 isa_dma_acquire(rman_get_start(sb->
drq1));
489 isa_dmainit(rman_get_start(sb->
drq1), sb->
bufsize);
492 isa_dma_acquire(rman_get_start(sb->
drq2));
493 isa_dmainit(rman_get_start(sb->
drq2), sb->
bufsize);
544 if (sb->pch.dch == 1)
550 if (sb->pch.dch == 2)
557 printf(
"sb_intr: reason=%d c=0x%x\n", reason,
c);
559 if ((reason & 1) && (sb->pch.run))
562 if ((reason & 2) && (sb->
rch.
run))
584 pprio = sb->pch.run? 1 : 0;
586 sb->pch.dch = pprio? 1 : 0;
588 sb->
rch.
dch = pprio? 2 : 1;
590 if (sb->pch.run && sb->
rch.
run) {
593 sb->pch.dch = pprio? 2 : 1;
595 sb->
rch.
dch = pprio? 1 : 2;
599 sb->pch.dch = (sb->pch.fmt &
AFMT_16BIT)? 2 : 1;
791 uintptr_t
func, ver,
r, f;
794 r = BUS_READ_IVAR(device_get_parent(
dev),
dev, 0, &
func);
798 r = BUS_READ_IVAR(device_get_parent(
dev),
dev, 1, &ver);
799 f = (ver & 0xffff0000) >> 16;
802 snprintf(
buf,
sizeof buf,
"SB16 DSP %d.%02d%s", (
int) ver >> 8, (
int) ver & 0xff,
804 device_set_desc_copy(
dev,
buf);
817 gone_in_dev(
dev, 14,
"ISA sound driver");
818 sb = malloc(
sizeof(*sb), M_DEVBUF, M_WAITOK | M_ZERO);
821 sb->
bd_id = ver & 0x0000ffff;
822 sb->
bd_flags = (ver & 0xffff0000) >> 16;
843 if (bus_dma_tag_create(bus_get_dma_tag(
dev), 2,
845 BUS_SPACE_MAXADDR_24BIT,
852 device_printf(
dev,
"unable to create dma tag\n");
862 rman_get_start(sb->
io_base), rman_get_start(sb->
irq),
int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags, unsigned int size)
void chn_intr(struct pcm_channel *c)
#define PCMTRIG_COMMON(x)
struct pcmchan_matrix * m
static int mixer_setrecsrc(struct snd_mixer *mixer, u_int32_t src)
int mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
static int mixer_set(struct snd_mixer *m, u_int dev, u_int32_t muted, u_int lev)
void mix_setdevs(struct snd_mixer *m, u_int32_t v)
void * mix_getdevinfo(struct snd_mixer *m)
void mix_setrecdevs(struct snd_mixer *m, u_int32_t v)
Record mask of available recording devices.
static int sb_reset_dsp(struct sb_info *sb)
MODULE_DEPEND(snd_sb16, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
static void sb_intr(void *arg)
CHANNEL_DECLARE(sb16chan)
static int rel2abs_volume(int x, int max)
static void sb_lock(struct sb_info *sb)
static device_method_t sb16_methods[]
static int port_rd(struct resource *port, int off)
static u_int32_t sb16chan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
static int sb16mix_init(struct snd_mixer *m)
static u_int sb_get_byte(struct sb_info *sb)
static int sb16mix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
static struct pcmchan_caps sb16_caps8
static int sb16chan_setformat(kobj_t obj, void *data, u_int32_t format)
static u_int32_t sb16_fmt16[]
static const struct sb16_mixent sb16_mixtab[32]
static void sb_setmixer(struct sb_info *sb, u_int port, u_int value)
static void sb_wr(struct sb_info *sb, int reg, u_int8_t val)
static int sb16chan_trigger(kobj_t obj, void *data, int go)
static int sb_cmd2(struct sb_info *sb, u_char cmd, int val)
SND_DECLARE_FILE("$FreeBSD$")
static kobj_method_t sb16chan_methods[]
static u_int32_t sb16chan_setspeed(kobj_t obj, void *data, u_int32_t speed)
static void port_wr(struct resource *port, int off, u_int8_t data)
static int sb16_attach(device_t dev)
static u_int32_t sb16chan_getptr(kobj_t obj, void *data)
static int sb_getmixer(struct sb_info *sb, u_int port)
static int sb_cmd(struct sb_info *sb, u_char val)
static u_int32_t sb16_fmt8[]
static kobj_method_t sb16mix_mixer_methods[]
static int sb16_detach(device_t dev)
static u_int32_t sb16x_fmt[]
static int sb16_alloc_resources(struct sb_info *sb, device_t dev)
static int sb_rd(struct sb_info *sb, int reg)
static struct pcmchan_caps * sb16chan_getcaps(kobj_t obj, void *data)
static void sb_lockassert(struct sb_info *sb)
static struct pcmchan_caps sb16_caps16
static int sb16_probe(device_t dev)
static int sb_setup(struct sb_info *sb)
static driver_t sb16_driver
static void sb_unlock(struct sb_info *sb)
static void * sb16chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
static u_int32_t sb16mix_setrecsrc(struct snd_mixer *m, u_int32_t src)
static int sb_dspwr(struct sb_info *sb, u_char val)
MIXER_DECLARE(sb16mix_mixer)
DRIVER_MODULE(snd_sb16, sbc, sb16_driver, pcm_devclass, 0, 0)
static int sb16chan_resetdone(kobj_t obj, void *data)
static struct pcmchan_caps sb16x_caps
static void sb16_release_resources(struct sb_info *sb, device_t dev)
MODULE_VERSION(snd_sb16, 1)
void sbc_unlock(struct sbc_softc *)
void sbc_lock(struct sbc_softc *)
void sbc_lockassert(struct sbc_softc *)
#define RANGE(var, low, high)
int sndbuf_dmasetup(struct snd_dbuf *b, struct resource *drq)
void sndbuf_dma(struct snd_dbuf *b, int go)
int sndbuf_dmaptr(struct snd_dbuf *b)
int sndbuf_dmasetdir(struct snd_dbuf *b, int dir)
void pcm_setflags(device_t dev, uint32_t val)
void * pcm_getdevinfo(device_t dev)
uint32_t pcm_getflags(device_t dev)
int pcm_setstatus(device_t dev, char *str)
int pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo)
int pcm_unregister(device_t dev)
int pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
int snd_setup_intr(device_t dev, struct resource *res, int flags, driver_intr_t hand, void *param, void **cookiep)
unsigned int pcm_getbuffersize(device_t dev, unsigned int minbufsz, unsigned int deflt, unsigned int maxbufsz)
#define SND_FORMAT(f, c, e)
struct pcm_channel * channel
struct resource * io_base
bus_dma_tag_t parent_dmat