2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2003-09-07 16:28:03 +00:00
|
|
|
* Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
|
1998-10-02 17:26:37 +00:00
|
|
|
* Copyright 1997,1998 Luigi Rizzo.
|
1997-09-14 21:42:12 +00:00
|
|
|
*
|
|
|
|
* Derived from files in the Voxware 3.5 distribution,
|
|
|
|
* Copyright by Hannu Savolainen 1994, under the same copyright
|
|
|
|
* conditions.
|
1999-09-01 04:01:57 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
1997-09-14 21:42:12 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
1997-10-31 12:24:28 +00:00
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
1999-09-01 04:01:57 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
1997-10-31 12:24:28 +00:00
|
|
|
*
|
1999-09-01 04:01:57 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1997-09-14 21:42:12 +00:00
|
|
|
*/
|
|
|
|
|
1999-11-20 16:50:33 +00:00
|
|
|
#include <dev/sound/pcm/sound.h>
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-11-20 16:50:33 +00:00
|
|
|
#include <dev/sound/isa/sb.h>
|
1999-11-22 06:07:49 +00:00
|
|
|
#include <dev/sound/chip.h>
|
1999-09-01 04:01:57 +00:00
|
|
|
|
2003-02-07 14:05:34 +00:00
|
|
|
#include <isa/isavar.h>
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
#include "mixer_if.h"
|
|
|
|
|
2001-08-23 11:30:52 +00:00
|
|
|
SND_DECLARE_FILE("$FreeBSD$");
|
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
#define SB16_BUFFSIZE 4096
|
2000-01-10 03:22:28 +00:00
|
|
|
#define PLAIN_SB16(x) ((((x)->bd_flags) & (BD_F_SB16|BD_F_SB16X)) == BD_F_SB16)
|
1999-12-30 04:04:43 +00:00
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
static u_int32_t sb16_fmt8[] = {
|
2000-08-20 22:18:56 +00:00
|
|
|
AFMT_U8,
|
1999-09-01 04:01:57 +00:00
|
|
|
AFMT_STEREO | AFMT_U8,
|
2000-08-20 22:18:56 +00:00
|
|
|
0
|
1999-09-01 04:01:57 +00:00
|
|
|
};
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps sb16_caps8 = {5000, 45000, sb16_fmt8, 0};
|
1997-09-14 21:42:12 +00:00
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
static u_int32_t sb16_fmt16[] = {
|
2000-08-20 22:18:56 +00:00
|
|
|
AFMT_S16_LE,
|
1999-09-01 04:01:57 +00:00
|
|
|
AFMT_STEREO | AFMT_S16_LE,
|
2000-08-20 22:18:56 +00:00
|
|
|
0
|
1999-09-01 04:01:57 +00:00
|
|
|
};
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps sb16_caps16 = {5000, 45000, sb16_fmt16, 0};
|
1997-09-14 21:42:12 +00:00
|
|
|
|
2000-08-20 22:18:56 +00:00
|
|
|
static u_int32_t sb16x_fmt[] = {
|
|
|
|
AFMT_U8,
|
|
|
|
AFMT_STEREO | AFMT_U8,
|
|
|
|
AFMT_S16_LE,
|
|
|
|
AFMT_STEREO | AFMT_S16_LE,
|
|
|
|
0
|
1999-12-12 02:30:19 +00:00
|
|
|
};
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps sb16x_caps = {5000, 49000, sb16x_fmt, 0};
|
1999-12-12 02:30:19 +00:00
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
struct sb_info;
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
struct sb_chinfo {
|
|
|
|
struct sb_info *parent;
|
2001-03-24 23:10:29 +00:00
|
|
|
struct pcm_channel *channel;
|
|
|
|
struct snd_dbuf *buffer;
|
2000-10-28 19:20:03 +00:00
|
|
|
int dir, run, dch;
|
|
|
|
u_int32_t fmt, spd, blksz;
|
1999-09-01 04:01:57 +00:00
|
|
|
};
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
struct sb_info {
|
|
|
|
struct resource *io_base; /* I/O address for the board */
|
|
|
|
struct resource *irq;
|
1999-12-12 02:30:19 +00:00
|
|
|
struct resource *drq1;
|
|
|
|
struct resource *drq2;
|
2000-09-09 19:21:04 +00:00
|
|
|
void *ih;
|
2000-01-10 03:22:28 +00:00
|
|
|
bus_dma_tag_t parent_dmat;
|
1999-09-01 04:01:57 +00:00
|
|
|
|
2001-09-29 07:57:07 +00:00
|
|
|
unsigned int bufsize;
|
1999-09-01 04:01:57 +00:00
|
|
|
int bd_id;
|
|
|
|
u_long bd_flags; /* board-specific flags */
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
int prio, prio16;
|
1999-09-01 04:01:57 +00:00
|
|
|
struct sb_chinfo pch, rch;
|
2001-03-24 23:10:29 +00:00
|
|
|
device_t parent_dev;
|
1999-09-01 04:01:57 +00:00
|
|
|
};
|
1997-09-14 21:42:12 +00:00
|
|
|
|
2001-09-29 07:57:07 +00:00
|
|
|
#if 0
|
2001-03-24 23:10:29 +00:00
|
|
|
static void sb_lock(struct sb_info *sb);
|
|
|
|
static void sb_unlock(struct sb_info *sb);
|
1999-09-01 04:01:57 +00:00
|
|
|
static int sb_rd(struct sb_info *sb, int reg);
|
|
|
|
static void sb_wr(struct sb_info *sb, int reg, u_int8_t val);
|
|
|
|
static int sb_cmd(struct sb_info *sb, u_char val);
|
2000-10-28 19:20:03 +00:00
|
|
|
/* static int sb_cmd1(struct sb_info *sb, u_char cmd, int val); */
|
1999-09-01 04:01:57 +00:00
|
|
|
static int sb_cmd2(struct sb_info *sb, u_char cmd, int val);
|
|
|
|
static u_int sb_get_byte(struct sb_info *sb);
|
|
|
|
static void sb_setmixer(struct sb_info *sb, u_int port, u_int value);
|
|
|
|
static int sb_getmixer(struct sb_info *sb, u_int port);
|
|
|
|
static int sb_reset_dsp(struct sb_info *sb);
|
|
|
|
|
1999-12-12 02:30:19 +00:00
|
|
|
static void sb_intr(void *arg);
|
2001-09-29 07:57:07 +00:00
|
|
|
#endif
|
1999-09-01 04:01:57 +00:00
|
|
|
|
1997-09-14 21:42:12 +00:00
|
|
|
/*
|
1999-09-01 04:01:57 +00:00
|
|
|
* Common code for the midi and pcm functions
|
|
|
|
*
|
|
|
|
* sb_cmd write a single byte to the CMD port.
|
|
|
|
* sb_cmd1 write a CMD + 1 byte arg
|
|
|
|
* sb_cmd2 write a CMD + 2 byte arg
|
|
|
|
* sb_get_byte returns a single byte from the DSP data port
|
1997-09-14 21:42:12 +00:00
|
|
|
*/
|
|
|
|
|
2001-09-29 07:57:07 +00:00
|
|
|
static void
|
|
|
|
sb_lock(struct sb_info *sb) {
|
|
|
|
|
|
|
|
sbc_lock(device_get_softc(sb->parent_dev));
|
|
|
|
}
|
|
|
|
|
2004-05-13 11:32:54 +00:00
|
|
|
static void
|
|
|
|
sb_lockassert(struct sb_info *sb) {
|
|
|
|
|
|
|
|
sbc_lockassert(device_get_softc(sb->parent_dev));
|
|
|
|
}
|
|
|
|
|
2001-09-29 07:57:07 +00:00
|
|
|
static void
|
|
|
|
sb_unlock(struct sb_info *sb) {
|
|
|
|
|
|
|
|
sbc_unlock(device_get_softc(sb->parent_dev));
|
|
|
|
}
|
|
|
|
|
1997-09-14 21:42:12 +00:00
|
|
|
static int
|
1999-09-01 04:01:57 +00:00
|
|
|
port_rd(struct resource *port, int off)
|
1997-09-14 21:42:12 +00:00
|
|
|
{
|
2000-10-28 19:20:03 +00:00
|
|
|
return bus_space_read_1(rman_get_bustag(port), rman_get_bushandle(port), off);
|
1999-09-01 04:01:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
port_wr(struct resource *port, int off, u_int8_t data)
|
|
|
|
{
|
2002-12-18 22:53:24 +00:00
|
|
|
bus_space_write_1(rman_get_bustag(port), rman_get_bushandle(port), off, data);
|
1997-09-14 21:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-09-01 04:01:57 +00:00
|
|
|
sb_rd(struct sb_info *sb, int reg)
|
1997-09-14 21:42:12 +00:00
|
|
|
{
|
1999-09-01 04:01:57 +00:00
|
|
|
return port_rd(sb->io_base, reg);
|
|
|
|
}
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
static void
|
|
|
|
sb_wr(struct sb_info *sb, int reg, u_int8_t val)
|
|
|
|
{
|
|
|
|
port_wr(sb->io_base, reg, val);
|
1997-09-14 21:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-09-01 04:01:57 +00:00
|
|
|
sb_dspwr(struct sb_info *sb, u_char val)
|
1997-09-14 21:42:12 +00:00
|
|
|
{
|
1999-09-01 04:01:57 +00:00
|
|
|
int i;
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
for (i = 0; i < 1000; i++) {
|
2000-12-18 01:36:41 +00:00
|
|
|
if ((sb_rd(sb, SBDSP_STATUS) & 0x80))
|
|
|
|
DELAY((i > 100)? 1000 : 10);
|
|
|
|
else {
|
|
|
|
sb_wr(sb, SBDSP_CMD, val);
|
|
|
|
return 1;
|
1999-09-01 04:01:57 +00:00
|
|
|
}
|
|
|
|
}
|
2001-07-02 23:47:23 +00:00
|
|
|
#if __FreeBSD_version > 500000
|
2001-09-12 08:38:13 +00:00
|
|
|
if (curthread->td_intr_nesting_level == 0)
|
2001-03-25 21:43:24 +00:00
|
|
|
printf("sb_dspwr(0x%02x) timed out.\n", val);
|
2001-07-02 15:27:28 +00:00
|
|
|
#endif
|
1999-09-01 04:01:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
static int
|
|
|
|
sb_cmd(struct sb_info *sb, u_char val)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
printf("sb_cmd: %x\n", val);
|
|
|
|
#endif
|
|
|
|
return sb_dspwr(sb, val);
|
|
|
|
}
|
1997-09-14 21:42:12 +00:00
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
/*
|
1999-09-01 04:01:57 +00:00
|
|
|
static int
|
|
|
|
sb_cmd1(struct sb_info *sb, u_char cmd, int val)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
printf("sb_cmd1: %x, %x\n", cmd, val);
|
|
|
|
#endif
|
|
|
|
if (sb_dspwr(sb, cmd)) {
|
|
|
|
return sb_dspwr(sb, val & 0xff);
|
|
|
|
} else return 0;
|
|
|
|
}
|
2000-10-28 19:20:03 +00:00
|
|
|
*/
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
static int
|
|
|
|
sb_cmd2(struct sb_info *sb, u_char cmd, int val)
|
|
|
|
{
|
2001-09-29 07:57:07 +00:00
|
|
|
int r;
|
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
#if 0
|
|
|
|
printf("sb_cmd2: %x, %x\n", cmd, val);
|
|
|
|
#endif
|
2004-09-12 18:19:42 +00:00
|
|
|
sb_lockassert(sb);
|
2001-09-29 07:57:07 +00:00
|
|
|
r = 0;
|
1999-09-01 04:01:57 +00:00
|
|
|
if (sb_dspwr(sb, cmd)) {
|
2001-09-29 07:57:07 +00:00
|
|
|
if (sb_dspwr(sb, val & 0xff)) {
|
|
|
|
if (sb_dspwr(sb, (val >> 8) & 0xff)) {
|
|
|
|
r = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
1999-09-01 04:01:57 +00:00
|
|
|
}
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
/*
|
|
|
|
* in the SB, there is a set of indirect "mixer" registers with
|
|
|
|
* address at offset 4, data at offset 5
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
sb_setmixer(struct sb_info *sb, u_int port, u_int value)
|
|
|
|
{
|
2001-03-24 23:10:29 +00:00
|
|
|
sb_lock(sb);
|
1999-09-01 04:01:57 +00:00
|
|
|
sb_wr(sb, SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */
|
|
|
|
DELAY(10);
|
|
|
|
sb_wr(sb, SB_MIX_DATA, (u_char) (value & 0xff));
|
|
|
|
DELAY(10);
|
2001-03-24 23:10:29 +00:00
|
|
|
sb_unlock(sb);
|
1999-09-01 04:01:57 +00:00
|
|
|
}
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
static int
|
|
|
|
sb_getmixer(struct sb_info *sb, u_int port)
|
|
|
|
{
|
|
|
|
int val;
|
1997-11-23 07:03:21 +00:00
|
|
|
|
2004-09-12 18:19:42 +00:00
|
|
|
sb_lockassert(sb);
|
1999-09-01 04:01:57 +00:00
|
|
|
sb_wr(sb, SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */
|
|
|
|
DELAY(10);
|
|
|
|
val = sb_rd(sb, SB_MIX_DATA);
|
|
|
|
DELAY(10);
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
return val;
|
1997-09-14 21:42:12 +00:00
|
|
|
}
|
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
static u_int
|
|
|
|
sb_get_byte(struct sb_info *sb)
|
1997-09-14 21:42:12 +00:00
|
|
|
{
|
1999-09-01 04:01:57 +00:00
|
|
|
int i;
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
for (i = 1000; i > 0; i--) {
|
|
|
|
if (sb_rd(sb, DSP_DATA_AVAIL) & 0x80)
|
|
|
|
return sb_rd(sb, DSP_READ);
|
|
|
|
else
|
|
|
|
DELAY(20);
|
|
|
|
}
|
|
|
|
return 0xffff;
|
|
|
|
}
|
1997-09-14 21:42:12 +00:00
|
|
|
|
|
|
|
static int
|
1999-09-01 04:01:57 +00:00
|
|
|
sb_reset_dsp(struct sb_info *sb)
|
1997-09-14 21:42:12 +00:00
|
|
|
{
|
2001-03-24 23:10:29 +00:00
|
|
|
u_char b;
|
|
|
|
|
2004-05-13 11:32:54 +00:00
|
|
|
sb_lockassert(sb);
|
1999-09-01 04:01:57 +00:00
|
|
|
sb_wr(sb, SBDSP_RST, 3);
|
|
|
|
DELAY(100);
|
|
|
|
sb_wr(sb, SBDSP_RST, 0);
|
2001-03-24 23:10:29 +00:00
|
|
|
b = sb_get_byte(sb);
|
|
|
|
if (b != 0xAA) {
|
1999-09-01 04:01:57 +00:00
|
|
|
DEB(printf("sb_reset_dsp 0x%lx failed\n",
|
2002-01-25 04:14:12 +00:00
|
|
|
rman_get_start(sb->io_base)));
|
1999-09-01 04:01:57 +00:00
|
|
|
return ENXIO; /* Sorry */
|
|
|
|
}
|
|
|
|
return 0;
|
1997-09-14 21:42:12 +00:00
|
|
|
}
|
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
/************************************************************/
|
|
|
|
|
|
|
|
struct sb16_mixent {
|
|
|
|
int reg;
|
|
|
|
int bits;
|
|
|
|
int ofs;
|
|
|
|
int stereo;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct sb16_mixent sb16_mixtab[32] = {
|
|
|
|
[SOUND_MIXER_VOLUME] = { 0x30, 5, 3, 1 },
|
|
|
|
[SOUND_MIXER_PCM] = { 0x32, 5, 3, 1 },
|
|
|
|
[SOUND_MIXER_SYNTH] = { 0x34, 5, 3, 1 },
|
|
|
|
[SOUND_MIXER_CD] = { 0x36, 5, 3, 1 },
|
|
|
|
[SOUND_MIXER_LINE] = { 0x38, 5, 3, 1 },
|
|
|
|
[SOUND_MIXER_MIC] = { 0x3a, 5, 3, 0 },
|
|
|
|
[SOUND_MIXER_SPEAKER] = { 0x3b, 5, 3, 0 },
|
|
|
|
[SOUND_MIXER_IGAIN] = { 0x3f, 2, 6, 1 },
|
|
|
|
[SOUND_MIXER_OGAIN] = { 0x41, 2, 6, 1 },
|
|
|
|
[SOUND_MIXER_TREBLE] = { 0x44, 4, 4, 1 },
|
|
|
|
[SOUND_MIXER_BASS] = { 0x46, 4, 4, 1 },
|
2002-07-30 16:24:00 +00:00
|
|
|
[SOUND_MIXER_LINE1] = { 0x52, 5, 3, 1 }
|
2000-10-28 19:20:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2001-03-24 23:10:29 +00:00
|
|
|
sb16mix_init(struct snd_mixer *m)
|
2000-10-28 19:20:03 +00:00
|
|
|
{
|
|
|
|
struct sb_info *sb = mix_getdevinfo(m);
|
|
|
|
|
|
|
|
mix_setdevs(m, SOUND_MASK_SYNTH | SOUND_MASK_PCM | SOUND_MASK_SPEAKER |
|
|
|
|
SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD |
|
2002-07-30 16:24:00 +00:00
|
|
|
SOUND_MASK_IGAIN | SOUND_MASK_OGAIN | SOUND_MASK_LINE1 |
|
2000-10-28 19:20:03 +00:00
|
|
|
SOUND_MASK_VOLUME | SOUND_MASK_BASS | SOUND_MASK_TREBLE);
|
|
|
|
|
|
|
|
mix_setrecdevs(m, SOUND_MASK_SYNTH | SOUND_MASK_LINE |
|
2002-07-30 16:24:00 +00:00
|
|
|
SOUND_MASK_LINE1 | SOUND_MASK_MIC | SOUND_MASK_CD);
|
2000-10-28 19:20:03 +00:00
|
|
|
|
|
|
|
sb_setmixer(sb, 0x3c, 0x1f); /* make all output active */
|
|
|
|
|
|
|
|
sb_setmixer(sb, 0x3d, 0); /* make all inputs-l off */
|
|
|
|
sb_setmixer(sb, 0x3e, 0); /* make all inputs-r off */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-06-14 15:01:16 +00:00
|
|
|
static int
|
|
|
|
rel2abs_volume(int x, int max)
|
|
|
|
{
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
temp = ((x * max) + 50) / 100;
|
|
|
|
if (temp > max)
|
|
|
|
temp = max;
|
|
|
|
else if (temp < 0)
|
|
|
|
temp = 0;
|
|
|
|
return (temp);
|
|
|
|
}
|
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
static int
|
2001-03-24 23:10:29 +00:00
|
|
|
sb16mix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
|
2000-10-28 19:20:03 +00:00
|
|
|
{
|
|
|
|
struct sb_info *sb = mix_getdevinfo(m);
|
|
|
|
const struct sb16_mixent *e;
|
|
|
|
int max;
|
|
|
|
|
|
|
|
e = &sb16_mixtab[dev];
|
|
|
|
max = (1 << e->bits) - 1;
|
|
|
|
|
2004-06-14 15:01:16 +00:00
|
|
|
left = rel2abs_volume(left, max);
|
|
|
|
right = rel2abs_volume(right, max);
|
2000-10-28 19:20:03 +00:00
|
|
|
|
|
|
|
sb_setmixer(sb, e->reg, left << e->ofs);
|
|
|
|
if (e->stereo)
|
2000-11-06 02:47:43 +00:00
|
|
|
sb_setmixer(sb, e->reg + 1, right << e->ofs);
|
2000-10-28 19:20:03 +00:00
|
|
|
else
|
|
|
|
right = left;
|
|
|
|
|
|
|
|
left = (left * 100) / max;
|
|
|
|
right = (right * 100) / max;
|
|
|
|
|
|
|
|
return left | (right << 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-03-24 23:10:29 +00:00
|
|
|
sb16mix_setrecsrc(struct snd_mixer *m, u_int32_t src)
|
2000-10-28 19:20:03 +00:00
|
|
|
{
|
|
|
|
struct sb_info *sb = mix_getdevinfo(m);
|
|
|
|
u_char recdev;
|
|
|
|
|
|
|
|
recdev = 0;
|
|
|
|
if (src & SOUND_MASK_MIC)
|
|
|
|
recdev |= 0x01; /* mono mic */
|
|
|
|
|
|
|
|
if (src & SOUND_MASK_CD)
|
|
|
|
recdev |= 0x06; /* l+r cd */
|
|
|
|
|
|
|
|
if (src & SOUND_MASK_LINE)
|
|
|
|
recdev |= 0x18; /* l+r line */
|
|
|
|
|
|
|
|
if (src & SOUND_MASK_SYNTH)
|
|
|
|
recdev |= 0x60; /* l+r midi */
|
|
|
|
|
|
|
|
sb_setmixer(sb, SB16_IMASK_L, recdev);
|
|
|
|
sb_setmixer(sb, SB16_IMASK_R, recdev);
|
|
|
|
|
2002-07-30 16:24:00 +00:00
|
|
|
/* Switch on/off FM tuner source */
|
|
|
|
if (src & SOUND_MASK_LINE1)
|
|
|
|
sb_setmixer(sb, 0x4a, 0x0c);
|
|
|
|
else
|
|
|
|
sb_setmixer(sb, 0x4a, 0x00);
|
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
/*
|
|
|
|
* since the same volume controls apply to the input and
|
|
|
|
* output sections, the best approach to have a consistent
|
|
|
|
* behaviour among cards would be to disable the output path
|
|
|
|
* on devices which are used to record.
|
|
|
|
* However, since users like to have feedback, we only disable
|
|
|
|
* the mic -- permanently.
|
|
|
|
*/
|
|
|
|
sb_setmixer(sb, SB16_OMASK, 0x1f & ~1);
|
|
|
|
|
|
|
|
return src;
|
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static kobj_method_t sb16mix_mixer_methods[] = {
|
|
|
|
KOBJMETHOD(mixer_init, sb16mix_init),
|
|
|
|
KOBJMETHOD(mixer_set, sb16mix_set),
|
|
|
|
KOBJMETHOD(mixer_setrecsrc, sb16mix_setrecsrc),
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
MIXER_DECLARE(sb16mix_mixer);
|
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
/************************************************************/
|
|
|
|
|
1997-09-14 21:42:12 +00:00
|
|
|
static void
|
2000-10-28 19:20:03 +00:00
|
|
|
sb16_release_resources(struct sb_info *sb, device_t dev)
|
1997-09-14 21:42:12 +00:00
|
|
|
{
|
1999-09-01 04:01:57 +00:00
|
|
|
if (sb->irq) {
|
2000-09-09 19:21:04 +00:00
|
|
|
if (sb->ih)
|
|
|
|
bus_teardown_intr(dev, sb->irq, sb->ih);
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, 0, sb->irq);
|
1999-09-01 04:01:57 +00:00
|
|
|
sb->irq = 0;
|
|
|
|
}
|
2001-09-29 07:57:07 +00:00
|
|
|
if (sb->drq2) {
|
|
|
|
if (sb->drq2 != sb->drq1) {
|
|
|
|
isa_dma_release(rman_get_start(sb->drq2));
|
|
|
|
bus_release_resource(dev, SYS_RES_DRQ, 1, sb->drq2);
|
|
|
|
}
|
1999-09-01 04:01:57 +00:00
|
|
|
sb->drq2 = 0;
|
|
|
|
}
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
if (sb->drq1) {
|
2001-03-16 21:04:14 +00:00
|
|
|
isa_dma_release(rman_get_start(sb->drq1));
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_DRQ, 0, sb->drq1);
|
|
|
|
sb->drq1 = 0;
|
|
|
|
}
|
|
|
|
if (sb->io_base) {
|
1999-12-12 02:30:19 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, 0, sb->io_base);
|
1999-09-01 04:01:57 +00:00
|
|
|
sb->io_base = 0;
|
|
|
|
}
|
2000-09-09 19:21:04 +00:00
|
|
|
if (sb->parent_dmat) {
|
|
|
|
bus_dma_tag_destroy(sb->parent_dmat);
|
|
|
|
sb->parent_dmat = 0;
|
|
|
|
}
|
|
|
|
free(sb, M_DEVBUF);
|
1997-09-14 21:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-10-28 19:20:03 +00:00
|
|
|
sb16_alloc_resources(struct sb_info *sb, device_t dev)
|
1997-09-14 21:42:12 +00:00
|
|
|
{
|
1999-12-12 02:30:19 +00:00
|
|
|
int rid;
|
|
|
|
|
|
|
|
rid = 0;
|
1999-09-01 04:01:57 +00:00
|
|
|
if (!sb->io_base)
|
2004-03-17 17:50:55 +00:00
|
|
|
sb->io_base = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
|
|
|
|
&rid, RF_ACTIVE);
|
2000-10-28 19:20:03 +00:00
|
|
|
|
1999-12-12 02:30:19 +00:00
|
|
|
rid = 0;
|
1999-09-01 04:01:57 +00:00
|
|
|
if (!sb->irq)
|
2004-03-17 17:50:55 +00:00
|
|
|
sb->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
|
|
|
|
RF_ACTIVE);
|
2000-10-28 19:20:03 +00:00
|
|
|
|
1999-12-12 02:30:19 +00:00
|
|
|
rid = 0;
|
1999-09-01 04:01:57 +00:00
|
|
|
if (!sb->drq1)
|
2004-03-17 17:50:55 +00:00
|
|
|
sb->drq1 = bus_alloc_resource_any(dev, SYS_RES_DRQ, &rid,
|
|
|
|
RF_ACTIVE);
|
2000-10-28 19:20:03 +00:00
|
|
|
|
1999-12-12 02:30:19 +00:00
|
|
|
rid = 1;
|
2000-03-28 18:31:01 +00:00
|
|
|
if (!sb->drq2)
|
2004-03-17 17:50:55 +00:00
|
|
|
sb->drq2 = bus_alloc_resource_any(dev, SYS_RES_DRQ, &rid,
|
|
|
|
RF_ACTIVE);
|
1999-09-01 04:01:57 +00:00
|
|
|
|
|
|
|
if (sb->io_base && sb->drq1 && sb->irq) {
|
1999-12-12 02:30:19 +00:00
|
|
|
isa_dma_acquire(rman_get_start(sb->drq1));
|
2001-09-29 07:57:07 +00:00
|
|
|
isa_dmainit(rman_get_start(sb->drq1), sb->bufsize);
|
1999-09-01 04:01:57 +00:00
|
|
|
|
|
|
|
if (sb->drq2) {
|
1999-12-12 02:30:19 +00:00
|
|
|
isa_dma_acquire(rman_get_start(sb->drq2));
|
2001-09-29 07:57:07 +00:00
|
|
|
isa_dmainit(rman_get_start(sb->drq2), sb->bufsize);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
} else {
|
|
|
|
sb->drq2 = sb->drq1;
|
|
|
|
pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX);
|
1997-11-23 07:03:21 +00:00
|
|
|
}
|
1999-09-01 04:01:57 +00:00
|
|
|
return 0;
|
|
|
|
} else return ENXIO;
|
|
|
|
}
|
1998-12-10 18:36:10 +00:00
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
/* sbc does locking for us */
|
1999-09-01 04:01:57 +00:00
|
|
|
static void
|
|
|
|
sb_intr(void *arg)
|
|
|
|
{
|
|
|
|
struct sb_info *sb = (struct sb_info *)arg;
|
|
|
|
int reason = 3, c;
|
|
|
|
|
|
|
|
/*
|
2000-10-28 19:20:03 +00:00
|
|
|
* The Vibra16X has separate flags for 8 and 16 bit transfers, but
|
|
|
|
* I have no idea how to tell capture from playback interrupts...
|
|
|
|
*/
|
|
|
|
|
|
|
|
reason = 0;
|
2001-03-24 23:10:29 +00:00
|
|
|
sb_lock(sb);
|
2000-10-28 19:20:03 +00:00
|
|
|
c = sb_getmixer(sb, IRQ_STAT);
|
2001-03-24 23:10:29 +00:00
|
|
|
if (c & 1)
|
|
|
|
sb_rd(sb, DSP_DATA_AVAIL); /* 8-bit int ack */
|
|
|
|
|
|
|
|
if (c & 2)
|
|
|
|
sb_rd(sb, DSP_DATA_AVL16); /* 16-bit int ack */
|
|
|
|
sb_unlock(sb);
|
2000-10-28 19:20:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* this tells us if the source is 8-bit or 16-bit dma. We
|
|
|
|
* have to check the io channel to map it to read or write...
|
|
|
|
*/
|
|
|
|
|
2000-11-07 00:38:59 +00:00
|
|
|
if (sb->bd_flags & BD_F_SB16X) {
|
|
|
|
if (c & 1) { /* 8-bit format */
|
|
|
|
if (sb->pch.fmt & AFMT_8BIT)
|
|
|
|
reason |= 1;
|
|
|
|
if (sb->rch.fmt & AFMT_8BIT)
|
|
|
|
reason |= 2;
|
|
|
|
}
|
|
|
|
if (c & 2) { /* 16-bit format */
|
|
|
|
if (sb->pch.fmt & AFMT_16BIT)
|
|
|
|
reason |= 1;
|
|
|
|
if (sb->rch.fmt & AFMT_16BIT)
|
|
|
|
reason |= 2;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (c & 1) { /* 8-bit dma */
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
if (sb->pch.dch == 1)
|
2000-11-07 00:38:59 +00:00
|
|
|
reason |= 1;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
if (sb->rch.dch == 1)
|
2000-11-07 00:38:59 +00:00
|
|
|
reason |= 2;
|
|
|
|
}
|
|
|
|
if (c & 2) { /* 16-bit dma */
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
if (sb->pch.dch == 2)
|
2000-11-07 00:38:59 +00:00
|
|
|
reason |= 1;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
if (sb->rch.dch == 2)
|
2000-11-07 00:38:59 +00:00
|
|
|
reason |= 2;
|
|
|
|
}
|
|
|
|
}
|
1999-09-01 04:01:57 +00:00
|
|
|
#if 0
|
|
|
|
printf("sb_intr: reason=%d c=0x%x\n", reason, c);
|
|
|
|
#endif
|
2000-10-28 19:20:03 +00:00
|
|
|
if ((reason & 1) && (sb->pch.run))
|
1999-09-01 04:01:57 +00:00
|
|
|
chn_intr(sb->pch.channel);
|
2000-10-28 19:20:03 +00:00
|
|
|
|
|
|
|
if ((reason & 2) && (sb->rch.run))
|
1999-09-01 04:01:57 +00:00
|
|
|
chn_intr(sb->rch.channel);
|
1997-09-14 21:42:12 +00:00
|
|
|
}
|
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
static int
|
2000-10-28 19:20:03 +00:00
|
|
|
sb_setup(struct sb_info *sb)
|
1997-09-14 21:42:12 +00:00
|
|
|
{
|
2000-10-28 19:20:03 +00:00
|
|
|
struct sb_chinfo *ch;
|
|
|
|
u_int8_t v;
|
|
|
|
int l, pprio;
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
sb_lock(sb);
|
2000-10-28 19:20:03 +00:00
|
|
|
if (sb->bd_flags & BD_F_DMARUN)
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dma(sb->pch.buffer, PCMTRIG_STOP);
|
2000-10-28 19:20:03 +00:00
|
|
|
if (sb->bd_flags & BD_F_DMARUN2)
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dma(sb->rch.buffer, PCMTRIG_STOP);
|
2000-10-28 19:20:03 +00:00
|
|
|
sb->bd_flags &= ~(BD_F_DMARUN | BD_F_DMARUN2);
|
|
|
|
|
|
|
|
sb_reset_dsp(sb);
|
|
|
|
|
|
|
|
if (sb->bd_flags & BD_F_SB16X) {
|
2000-11-07 00:38:59 +00:00
|
|
|
pprio = sb->pch.run? 1 : 0;
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dmasetup(sb->pch.buffer, pprio? sb->drq1 : NULL);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
sb->pch.dch = pprio? 1 : 0;
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dmasetup(sb->rch.buffer, pprio? sb->drq2 : sb->drq1);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
sb->rch.dch = pprio? 2 : 1;
|
1999-09-01 04:01:57 +00:00
|
|
|
} else {
|
2000-10-28 19:20:03 +00:00
|
|
|
if (sb->pch.run && sb->rch.run) {
|
|
|
|
pprio = (sb->rch.fmt & AFMT_16BIT)? 0 : 1;
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dmasetup(sb->pch.buffer, pprio? sb->drq2 : sb->drq1);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
sb->pch.dch = pprio? 2 : 1;
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dmasetup(sb->rch.buffer, pprio? sb->drq1 : sb->drq2);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
sb->rch.dch = pprio? 1 : 2;
|
2000-10-28 19:20:03 +00:00
|
|
|
} else {
|
|
|
|
if (sb->pch.run) {
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dmasetup(sb->pch.buffer, (sb->pch.fmt & AFMT_16BIT)? sb->drq2 : sb->drq1);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
sb->pch.dch = (sb->pch.fmt & AFMT_16BIT)? 2 : 1;
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dmasetup(sb->rch.buffer, (sb->pch.fmt & AFMT_16BIT)? sb->drq1 : sb->drq2);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
sb->rch.dch = (sb->pch.fmt & AFMT_16BIT)? 1 : 2;
|
2000-10-28 19:20:03 +00:00
|
|
|
} else if (sb->rch.run) {
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dmasetup(sb->pch.buffer, (sb->rch.fmt & AFMT_16BIT)? sb->drq1 : sb->drq2);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
sb->pch.dch = (sb->rch.fmt & AFMT_16BIT)? 1 : 2;
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dmasetup(sb->rch.buffer, (sb->rch.fmt & AFMT_16BIT)? sb->drq2 : sb->drq1);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
sb->rch.dch = (sb->rch.fmt & AFMT_16BIT)? 2 : 1;
|
2000-10-28 19:20:03 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-01 04:01:57 +00:00
|
|
|
}
|
1997-09-14 21:42:12 +00:00
|
|
|
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dmasetdir(sb->pch.buffer, PCMDIR_PLAY);
|
|
|
|
sndbuf_dmasetdir(sb->rch.buffer, PCMDIR_REC);
|
2000-10-28 19:20:03 +00:00
|
|
|
|
|
|
|
/*
|
2000-11-07 00:38:59 +00:00
|
|
|
printf("setup: [pch = %d, pfmt = %d, pgo = %d] [rch = %d, rfmt = %d, rgo = %d]\n",
|
|
|
|
sb->pch.dch, sb->pch.fmt, sb->pch.run, sb->rch.dch, sb->rch.fmt, sb->rch.run);
|
2000-10-28 19:20:03 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
ch = &sb->pch;
|
|
|
|
if (ch->run) {
|
|
|
|
l = ch->blksz;
|
|
|
|
if (ch->fmt & AFMT_16BIT)
|
|
|
|
l >>= 1;
|
|
|
|
l--;
|
|
|
|
|
|
|
|
/* play speed */
|
|
|
|
RANGE(ch->spd, 5000, 45000);
|
|
|
|
sb_cmd(sb, DSP_CMD_OUT16);
|
|
|
|
sb_cmd(sb, ch->spd >> 8);
|
|
|
|
sb_cmd(sb, ch->spd & 0xff);
|
|
|
|
|
|
|
|
/* play format, length */
|
|
|
|
v = DSP_F16_AUTO | DSP_F16_FIFO_ON | DSP_F16_DAC;
|
|
|
|
v |= (ch->fmt & AFMT_16BIT)? DSP_DMA16 : DSP_DMA8;
|
|
|
|
sb_cmd(sb, v);
|
|
|
|
|
|
|
|
v = (ch->fmt & AFMT_STEREO)? DSP_F16_STEREO : 0;
|
|
|
|
v |= (ch->fmt & AFMT_SIGNED)? DSP_F16_SIGNED : 0;
|
|
|
|
sb_cmd2(sb, v, l);
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dma(ch->buffer, PCMTRIG_START);
|
2000-10-28 19:20:03 +00:00
|
|
|
sb->bd_flags |= BD_F_DMARUN;
|
1999-09-01 04:01:57 +00:00
|
|
|
}
|
2000-10-28 19:20:03 +00:00
|
|
|
|
|
|
|
ch = &sb->rch;
|
|
|
|
if (ch->run) {
|
|
|
|
l = ch->blksz;
|
|
|
|
if (ch->fmt & AFMT_16BIT)
|
|
|
|
l >>= 1;
|
|
|
|
l--;
|
|
|
|
|
|
|
|
/* record speed */
|
|
|
|
RANGE(ch->spd, 5000, 45000);
|
|
|
|
sb_cmd(sb, DSP_CMD_IN16);
|
|
|
|
sb_cmd(sb, ch->spd >> 8);
|
|
|
|
sb_cmd(sb, ch->spd & 0xff);
|
|
|
|
|
|
|
|
/* record format, length */
|
|
|
|
v = DSP_F16_AUTO | DSP_F16_FIFO_ON | DSP_F16_ADC;
|
|
|
|
v |= (ch->fmt & AFMT_16BIT)? DSP_DMA16 : DSP_DMA8;
|
|
|
|
sb_cmd(sb, v);
|
|
|
|
|
|
|
|
v = (ch->fmt & AFMT_STEREO)? DSP_F16_STEREO : 0;
|
|
|
|
v |= (ch->fmt & AFMT_SIGNED)? DSP_F16_SIGNED : 0;
|
|
|
|
sb_cmd2(sb, v, l);
|
2003-02-07 14:05:34 +00:00
|
|
|
sndbuf_dma(ch->buffer, PCMTRIG_START);
|
2000-10-28 19:20:03 +00:00
|
|
|
sb->bd_flags |= BD_F_DMARUN2;
|
|
|
|
}
|
2001-03-24 23:10:29 +00:00
|
|
|
sb_unlock(sb);
|
2000-10-28 19:20:03 +00:00
|
|
|
|
|
|
|
return 0;
|
1998-02-17 14:17:13 +00:00
|
|
|
}
|
|
|
|
|
2000-01-10 03:22:28 +00:00
|
|
|
/* channel interface */
|
|
|
|
static void *
|
2001-03-24 23:10:29 +00:00
|
|
|
sb16chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
|
2000-01-10 03:22:28 +00:00
|
|
|
{
|
|
|
|
struct sb_info *sb = devinfo;
|
|
|
|
struct sb_chinfo *ch = (dir == PCMDIR_PLAY)? &sb->pch : &sb->rch;
|
|
|
|
|
|
|
|
ch->parent = sb;
|
|
|
|
ch->channel = c;
|
|
|
|
ch->buffer = b;
|
2000-10-28 19:20:03 +00:00
|
|
|
ch->dir = dir;
|
|
|
|
|
2004-10-13 05:45:16 +00:00
|
|
|
if (sndbuf_alloc(ch->buffer, sb->parent_dmat, sb->bufsize) != 0)
|
2000-01-10 03:22:28 +00:00
|
|
|
return NULL;
|
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
return ch;
|
2000-01-10 03:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
sb16chan_setformat(kobj_t obj, void *data, u_int32_t format)
|
2000-01-10 03:22:28 +00:00
|
|
|
{
|
|
|
|
struct sb_chinfo *ch = data;
|
2000-10-28 19:20:03 +00:00
|
|
|
struct sb_info *sb = ch->parent;
|
2000-01-10 03:22:28 +00:00
|
|
|
|
|
|
|
ch->fmt = format;
|
2000-10-28 19:20:03 +00:00
|
|
|
sb->prio = ch->dir;
|
|
|
|
sb->prio16 = (ch->fmt & AFMT_16BIT)? 1 : 0;
|
|
|
|
|
2000-01-10 03:22:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
sb16chan_setspeed(kobj_t obj, void *data, u_int32_t speed)
|
2000-01-10 03:22:28 +00:00
|
|
|
{
|
|
|
|
struct sb_chinfo *ch = data;
|
|
|
|
|
|
|
|
ch->spd = speed;
|
2000-10-28 19:20:03 +00:00
|
|
|
return speed;
|
2000-01-10 03:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
sb16chan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
|
2000-01-10 03:22:28 +00:00
|
|
|
{
|
2000-10-28 19:20:03 +00:00
|
|
|
struct sb_chinfo *ch = data;
|
|
|
|
|
|
|
|
ch->blksz = blocksize;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
return ch->blksz;
|
2000-01-10 03:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
sb16chan_trigger(kobj_t obj, void *data, int go)
|
2000-01-10 03:22:28 +00:00
|
|
|
{
|
|
|
|
struct sb_chinfo *ch = data;
|
2000-10-28 19:20:03 +00:00
|
|
|
struct sb_info *sb = ch->parent;
|
2000-01-10 03:22:28 +00:00
|
|
|
|
2000-05-26 21:15:47 +00:00
|
|
|
if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD)
|
2000-01-10 03:22:28 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (go == PCMTRIG_START)
|
2000-10-28 19:20:03 +00:00
|
|
|
ch->run = 1;
|
2000-01-10 03:22:28 +00:00
|
|
|
else
|
2000-10-28 19:20:03 +00:00
|
|
|
ch->run = 0;
|
2000-11-06 02:47:43 +00:00
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
sb_setup(sb);
|
|
|
|
|
2000-01-10 03:22:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
sb16chan_getptr(kobj_t obj, void *data)
|
2000-01-10 03:22:28 +00:00
|
|
|
{
|
|
|
|
struct sb_chinfo *ch = data;
|
|
|
|
|
2003-02-07 14:05:34 +00:00
|
|
|
return sndbuf_dmaptr(ch->buffer);
|
2000-01-10 03:22:28 +00:00
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps *
|
2000-12-18 01:36:41 +00:00
|
|
|
sb16chan_getcaps(kobj_t obj, void *data)
|
2000-01-10 03:22:28 +00:00
|
|
|
{
|
|
|
|
struct sb_chinfo *ch = data;
|
2000-10-28 19:20:03 +00:00
|
|
|
struct sb_info *sb = ch->parent;
|
2000-01-10 03:22:28 +00:00
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
if ((sb->prio == 0) || (sb->prio == ch->dir))
|
2000-01-10 03:22:28 +00:00
|
|
|
return &sb16x_caps;
|
|
|
|
else
|
2000-10-28 19:20:03 +00:00
|
|
|
return sb->prio16? &sb16_caps8 : &sb16_caps16;
|
2000-01-10 03:22:28 +00:00
|
|
|
}
|
|
|
|
|
1999-09-01 04:01:57 +00:00
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
sb16chan_resetdone(kobj_t obj, void *data)
|
1999-09-01 04:01:57 +00:00
|
|
|
{
|
2000-10-28 19:20:03 +00:00
|
|
|
struct sb_chinfo *ch = data;
|
|
|
|
struct sb_info *sb = ch->parent;
|
1999-11-13 18:31:31 +00:00
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
sb->prio = 0;
|
1999-11-13 18:31:31 +00:00
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
return 0;
|
1999-09-01 04:01:57 +00:00
|
|
|
}
|
1997-09-14 21:42:12 +00:00
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static kobj_method_t sb16chan_methods[] = {
|
|
|
|
KOBJMETHOD(channel_init, sb16chan_init),
|
|
|
|
KOBJMETHOD(channel_resetdone, sb16chan_resetdone),
|
|
|
|
KOBJMETHOD(channel_setformat, sb16chan_setformat),
|
|
|
|
KOBJMETHOD(channel_setspeed, sb16chan_setspeed),
|
|
|
|
KOBJMETHOD(channel_setblocksize, sb16chan_setblocksize),
|
|
|
|
KOBJMETHOD(channel_trigger, sb16chan_trigger),
|
|
|
|
KOBJMETHOD(channel_getptr, sb16chan_getptr),
|
|
|
|
KOBJMETHOD(channel_getcaps, sb16chan_getcaps),
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
CHANNEL_DECLARE(sb16chan);
|
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
/************************************************************/
|
1997-09-14 21:42:12 +00:00
|
|
|
|
1999-11-22 06:07:49 +00:00
|
|
|
static int
|
2000-10-28 19:20:03 +00:00
|
|
|
sb16_probe(device_t dev)
|
1999-11-22 06:07:49 +00:00
|
|
|
{
|
1999-12-12 02:30:19 +00:00
|
|
|
char buf[64];
|
1999-12-24 16:22:45 +00:00
|
|
|
uintptr_t func, ver, r, f;
|
1999-11-22 06:07:49 +00:00
|
|
|
|
|
|
|
/* The parent device has already been probed. */
|
1999-12-12 02:30:19 +00:00
|
|
|
r = BUS_READ_IVAR(device_get_parent(dev), dev, 0, &func);
|
|
|
|
if (func != SCF_PCM)
|
1999-11-22 06:07:49 +00:00
|
|
|
return (ENXIO);
|
|
|
|
|
1999-12-12 02:30:19 +00:00
|
|
|
r = BUS_READ_IVAR(device_get_parent(dev), dev, 1, &ver);
|
1999-12-18 22:21:47 +00:00
|
|
|
f = (ver & 0xffff0000) >> 16;
|
1999-12-12 02:30:19 +00:00
|
|
|
ver &= 0x0000ffff;
|
2000-10-28 19:20:03 +00:00
|
|
|
if (f & BD_F_SB16) {
|
|
|
|
snprintf(buf, sizeof buf, "SB16 DSP %d.%02d%s", (int) ver >> 8, (int) ver & 0xff,
|
|
|
|
(f & BD_F_SB16X)? " (ViBRA16X)" : "");
|
|
|
|
device_set_desc_copy(dev, buf);
|
|
|
|
return 0;
|
|
|
|
} else
|
2000-03-28 18:31:01 +00:00
|
|
|
return (ENXIO);
|
1999-11-22 06:07:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-10-28 19:20:03 +00:00
|
|
|
sb16_attach(device_t dev)
|
1999-11-22 06:07:49 +00:00
|
|
|
{
|
|
|
|
struct sb_info *sb;
|
1999-12-24 16:22:45 +00:00
|
|
|
uintptr_t ver;
|
2001-09-29 07:57:07 +00:00
|
|
|
char status[SND_STATUSLEN], status2[SND_STATUSLEN];
|
1999-11-22 06:07:49 +00:00
|
|
|
|
2001-06-21 19:45:59 +00:00
|
|
|
sb = (struct sb_info *)malloc(sizeof *sb, M_DEVBUF, M_NOWAIT | M_ZERO);
|
2000-01-10 03:22:28 +00:00
|
|
|
if (!sb)
|
|
|
|
return ENXIO;
|
1999-11-22 06:07:49 +00:00
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
sb->parent_dev = device_get_parent(dev);
|
|
|
|
BUS_READ_IVAR(sb->parent_dev, dev, 1, &ver);
|
1999-12-12 02:30:19 +00:00
|
|
|
sb->bd_id = ver & 0x0000ffff;
|
|
|
|
sb->bd_flags = (ver & 0xffff0000) >> 16;
|
2001-09-29 07:57:07 +00:00
|
|
|
sb->bufsize = pcm_getbuffersize(dev, 4096, SB16_BUFFSIZE, 65536);
|
1999-12-12 02:30:19 +00:00
|
|
|
|
2004-05-13 11:33:44 +00:00
|
|
|
if (sb16_alloc_resources(sb, dev))
|
2000-10-28 19:20:03 +00:00
|
|
|
goto no;
|
2004-05-13 11:32:54 +00:00
|
|
|
sb_lock(sb);
|
|
|
|
if (sb_reset_dsp(sb)) {
|
|
|
|
sb_unlock(sb);
|
2000-10-28 19:20:03 +00:00
|
|
|
goto no;
|
2004-05-13 11:32:54 +00:00
|
|
|
}
|
|
|
|
sb_unlock(sb);
|
2000-12-18 01:36:41 +00:00
|
|
|
if (mixer_init(dev, &sb16mix_mixer_class, sb))
|
2000-10-28 19:20:03 +00:00
|
|
|
goto no;
|
2004-04-14 14:57:49 +00:00
|
|
|
if (snd_setup_intr(dev, sb->irq, 0, sb_intr, sb, &sb->ih))
|
2000-10-28 19:20:03 +00:00
|
|
|
goto no;
|
|
|
|
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
if (sb->bd_flags & BD_F_SB16X)
|
2000-10-28 19:20:03 +00:00
|
|
|
pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX);
|
|
|
|
|
|
|
|
sb->prio = 0;
|
|
|
|
|
|
|
|
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
|
|
|
|
/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
|
|
|
|
/*highaddr*/BUS_SPACE_MAXADDR,
|
|
|
|
/*filter*/NULL, /*filterarg*/NULL,
|
2001-09-29 07:57:07 +00:00
|
|
|
/*maxsize*/sb->bufsize, /*nsegments*/1,
|
2003-07-01 15:52:06 +00:00
|
|
|
/*maxsegz*/0x3ffff, /*flags*/0,
|
|
|
|
/*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant,
|
|
|
|
&sb->parent_dmat) != 0) {
|
2000-10-28 19:20:03 +00:00
|
|
|
device_printf(dev, "unable to create dma tag\n");
|
|
|
|
goto no;
|
|
|
|
}
|
|
|
|
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
if (!(pcm_getflags(dev) & SD_F_SIMPLEX))
|
2001-09-29 07:57:07 +00:00
|
|
|
snprintf(status2, SND_STATUSLEN, ":%ld", rman_get_start(sb->drq2));
|
|
|
|
else
|
|
|
|
status2[0] = '\0';
|
|
|
|
|
2004-03-06 15:52:42 +00:00
|
|
|
snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld drq %ld%s bufsz %ud %s",
|
2001-09-29 07:57:07 +00:00
|
|
|
rman_get_start(sb->io_base), rman_get_start(sb->irq),
|
2004-03-06 15:52:42 +00:00
|
|
|
rman_get_start(sb->drq1), status2, sb->bufsize,
|
|
|
|
PCM_KLDSTRING(snd_sb16));
|
2000-10-28 19:20:03 +00:00
|
|
|
|
|
|
|
if (pcm_register(dev, sb, 1, 1))
|
|
|
|
goto no;
|
2000-12-18 01:36:41 +00:00
|
|
|
pcm_addchan(dev, PCMDIR_REC, &sb16chan_class, sb);
|
|
|
|
pcm_addchan(dev, PCMDIR_PLAY, &sb16chan_class, sb);
|
2000-10-28 19:20:03 +00:00
|
|
|
|
|
|
|
pcm_setstatus(dev, status);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
no:
|
|
|
|
sb16_release_resources(sb, dev);
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
sb16_detach(device_t dev)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
struct sb_info *sb;
|
|
|
|
|
|
|
|
r = pcm_unregister(dev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
sb = pcm_getdevinfo(dev);
|
|
|
|
sb16_release_resources(sb, dev);
|
|
|
|
return 0;
|
1999-11-22 06:07:49 +00:00
|
|
|
}
|
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
static device_method_t sb16_methods[] = {
|
1999-11-22 06:07:49 +00:00
|
|
|
/* Device interface */
|
2000-10-28 19:20:03 +00:00
|
|
|
DEVMETHOD(device_probe, sb16_probe),
|
|
|
|
DEVMETHOD(device_attach, sb16_attach),
|
|
|
|
DEVMETHOD(device_detach, sb16_detach),
|
1999-11-22 06:07:49 +00:00
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
static driver_t sb16_driver = {
|
1999-11-22 06:07:49 +00:00
|
|
|
"pcm",
|
2000-10-28 19:20:03 +00:00
|
|
|
sb16_methods,
|
2001-08-23 11:30:52 +00:00
|
|
|
PCM_SOFTC_SIZE,
|
1999-11-22 06:07:49 +00:00
|
|
|
};
|
|
|
|
|
2000-10-28 19:20:03 +00:00
|
|
|
DRIVER_MODULE(snd_sb16, sbc, sb16_driver, pcm_devclass, 0, 0);
|
2004-07-16 04:00:08 +00:00
|
|
|
MODULE_DEPEND(snd_sb16, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
|
2001-03-24 23:10:29 +00:00
|
|
|
MODULE_DEPEND(snd_sb16, snd_sbc, 1, 1, 1);
|
2000-10-28 19:20:03 +00:00
|
|
|
MODULE_VERSION(snd_sb16, 1);
|