#include "mpu.h"
#if NMPU > 0
#include <dev/ic/mpuvar.h>
#endif
#define SB_MASTER_VOL 0
#define SB_MIDI_VOL 1
#define SB_CD_VOL 2
#define SB_VOICE_VOL 3
#define SB_OUTPUT_CLASS 4
#define SB_MIC_VOL 5
#define SB_LINE_IN_VOL 6
#define SB_RECORD_SOURCE 7
#define SB_TREBLE 8
#define SB_BASS 9
#define SB_RECORD_CLASS 10
#define SB_INPUT_CLASS 11
#define SB_PCSPEAKER 12
#define SB_INPUT_GAIN 13
#define SB_OUTPUT_GAIN 14
#define SB_AGC 15
#define SB_EQUALIZATION_CLASS 16
#define SB_CD_IN_MUTE 17
#define SB_MIC_IN_MUTE 18
#define SB_LINE_IN_MUTE 19
#define SB_MIDI_IN_MUTE 20
#define SB_CD_SWAP 21
#define SB_MIC_SWAP 22
#define SB_LINE_SWAP 23
#define SB_MIDI_SWAP 24
#define SB_CD_OUT_MUTE 25
#define SB_MIC_OUT_MUTE 26
#define SB_LINE_OUT_MUTE 27
#define SB_NDEVS 28
#define SB_IS_IN_MUTE(x) ((x) < SB_CD_SWAP)
struct sbdsp_softc {
device_t sc_dev;
isa_chipset_tag_t sc_ic;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
void *sc_ih;
kmutex_t sc_lock;
kmutex_t sc_intr_lock;
int sc_iobase;
int sc_irq;
int sc_drq8;
bus_size_t sc_drq8_maxsize;
int sc_drq16;
bus_size_t sc_drq16_maxsize;
u_int sc_quirks;
#define SB_QUIRK_NO_INIT_DRQ 0x01
int sc_open;
#define SB_CLOSED 0
#define SB_OPEN_AUDIO 1
#define SB_OPEN_MIDI 2
u_char gain[SB_NDEVS][2];
#define SB_LEFT 0
#define SB_RIGHT 1
#define SB_LR 0
u_int in_mask;
u_int in_port;
u_int in_filter;
u_int spkr_state;
struct sbdsp_state {
u_int rate;
u_char tc;
struct sbmode *modep;
u_char bmode;
int dmachan;
int blksize;
u_char run;
#define SB_NOTRUNNING 0
#define SB_RUNNING 3
#define SB_LOOPING 2
} sc_i, sc_o;
u_long sc_interrupts;
int (*sc_intr8)(void*);
int (*sc_intr16)(void*);
void (*sc_intrp)(void*);
void *sc_argp;
void (*sc_intrr)(void*);
void *sc_argr;
void (*sc_intrm)(void*, int);
void *sc_argm;
u_int sc_mixer_model;
#define SBM_NONE 0
#define SBM_CT1335 1
#define SBM_CT1345 2
#define SBM_CT1XX5 3
#define SBM_CT1745 4
#define ISSBM1745(x) ((x)->sc_mixer_model >= SBM_CT1XX5)
u_int sc_model;
#define SB_UNK -1
#define SB_1 0
#define SB_20 1
#define SB_2x 2
#define SB_PRO 3
#define SB_JAZZ 4
#define SB_16 5
#define SB_32 6
#define SB_64 7
#define SB_NAMES { "SB_1", "SB_2.0", "SB_2.x", "SB_Pro", "Jazz_16", "SB_16", \
"SB_AWE_32", "SB_AWE_64" }
u_int sc_version;
#define SBVER_MAJOR(v) (((v)>>8) & 0xff)
#define SBVER_MINOR(v) ((v)&0xff)
struct audio_format sc_formats[4];
int sc_nformats;
#if NMPU > 0
int sc_hasmpu;
#define SBMPU_EXTERNAL 1
#define SBMPU_INTERNAL 0
#define SBMPU_NONE -1
device_t sc_mpudev;
bus_space_tag_t sc_mpu_iot;
bus_space_handle_t sc_mpu_ioh;
#endif
};
#define ISSBPRO(sc) ((sc)->sc_model == SB_PRO || (sc)->sc_model == SB_JAZZ)
#define ISSBPROCLASS(sc) ((sc)->sc_model >= SB_PRO)
#define ISSB16CLASS(sc) ((sc)->sc_model >= SB_16)
#ifdef _KERNEL
struct malloc_type;
int sbdsp_open(void *, int);
void sbdsp_close(void *);
int sbdsp_probe(struct sbdsp_softc *, cfdata_t);
void sbdsp_attach(struct sbdsp_softc *);
int sbdsp_set_in_gain(void *, u_int, u_char);
int sbdsp_set_in_gain_real(void *, u_int, u_char);
int sbdsp_get_in_gain(void *);
int sbdsp_set_out_gain(void *, u_int, u_char);
int sbdsp_set_out_gain_real(void *, u_int, u_char);
int sbdsp_get_out_gain(void *);
int sbdsp_set_monitor_gain(void *, u_int);
int sbdsp_get_monitor_gain(void *);
int sbdsp_query_format(void *, audio_format_query_t *);
int sbdsp_set_format(void *, int,
const audio_params_t *, const audio_params_t *,
audio_filter_reg_t *, audio_filter_reg_t *);
int sbdsp_round_blocksize(void *, int, int, const audio_params_t *);
int sbdsp_get_avail_in_ports(void *);
int sbdsp_get_avail_out_ports(void *);
int sbdsp_speaker_ctl(void *, int);
int sbdsp_commit(void *);
int sbdsp_trigger_output(void *, void *, void *, int, void (*)(void *),
void *, const audio_params_t *);
int sbdsp_trigger_input(void *, void *, void *, int, void (*)(void *),
void *, const audio_params_t *);
int sbdsp_halt_output(void *);
int sbdsp_halt_input(void *);
void sbdsp_compress(int, u_char *, int);
void sbdsp_expand(int, u_char *, int);
int sbdsp_reset(struct sbdsp_softc *);
void sbdsp_spkron(struct sbdsp_softc *);
void sbdsp_spkroff(struct sbdsp_softc *);
int sbdsp_wdsp(struct sbdsp_softc *, int);
int sbdsp_rdsp(struct sbdsp_softc *);
int sbdsp_intr(void *);
int sbdsp_set_sr(struct sbdsp_softc *, u_long *, int);
void sbdsp_mix_write(struct sbdsp_softc *, int, int);
int sbdsp_mix_read(struct sbdsp_softc *, int);
int sbdsp_mixer_set_port(void *, mixer_ctrl_t *);
int sbdsp_mixer_get_port(void *, mixer_ctrl_t *);
int sbdsp_mixer_query_devinfo(void *, mixer_devinfo_t *);
void *sb_malloc(void *, int, size_t);
void sb_free(void *, void *, size_t);
size_t sb_round_buffersize(void *, int, size_t);
int sbdsp_get_props(void *);
void sbdsp_get_locks(void *, kmutex_t **, kmutex_t **);
int sbdsp_midi_open(void *, int, void (*iintr)(void *, int),
void (*ointr)(void *), void *);
void sbdsp_midi_close(void *);
int sbdsp_midi_output(void *, int);
void sbdsp_midi_getinfo(void *, struct midi_info *);
#endif