38#ifdef HAVE_KERNEL_OPTION_HEADERS
59#define ALS_DEFAULT_BUFSZ 16384
79 bus_space_handle_t
sh;
160 }
while (--tries != 0);
163 device_printf(sc->
dev,
"als_esp_wr timeout");
171 u_int32_t tries, u, v;
189 }
while (--tries != 0);
192 device_printf(sc->
dev,
"als_esp_reset timeout");
199 u_int8_t
r = bus_space_read_1(sc->
st, sc->
sh,
addr);
254 if (other->dma_active) {
287 return (2 * sz - pos - 1) % sz;
308 DEB(printf(
"speed locked at %d (tried %d)\n",
315#define ALS_8BIT_CMD(x, y) { (x), (y), DSP_DMA8, DSP_CMD_DMAPAUSE_8 }
316#define ALS_16BIT_CMD(x, y) { (x), (y), DSP_DMA16, DSP_CMD_DMAPAUSE_16 }
336 for (i = 0; i <
n; i++) {
341 DEB(printf(
"als_get_playback_command: invalid format 0x%08x\n",
446 device_printf(sc->
dev,
"format not found: 0x%08x\n",
format);
538}
static const amt[SOUND_MIXER_NRDEVICES] = {
539 [SOUND_MIXER_VOLUME] = { 0x30, 0x31, 5, 0x00, 0x00 },
540 [SOUND_MIXER_PCM] = { 0x32, 0x33, 5, 0x00, 0x00 },
541 [SOUND_MIXER_SYNTH] = { 0x34, 0x35, 5, 0x60, 0x40 },
542 [SOUND_MIXER_CD] = { 0x36, 0x37, 5, 0x06, 0x04 },
543 [SOUND_MIXER_LINE] = { 0x38, 0x39, 5, 0x18, 0x10 },
544 [SOUND_MIXER_MIC] = { 0x3a, 0x00, 5, 0x01, 0x01 },
545 [SOUND_MIXER_SPEAKER] = { 0x3b, 0x00, 2, 0x00, 0x00 },
546 [SOUND_MIXER_IGAIN] = { 0x3f, 0x40, 2, 0x00, 0x00 },
547 [SOUND_MIXER_OGAIN] = { 0x41, 0x42, 2, 0x00, 0x00 },
549 [SOUND_MIXER_TREBLE] = { 0x44, 0x45, 4, 0x00, 0x00 },
550 [SOUND_MIXER_BASS] = { 0x46, 0x47, 4, 0x00, 0x00 }
558 for (i = v = 0; i < SOUND_MIXER_NRDEVICES; i++) {
559 if (
amt[i].bits) v |= 1 << i;
563 for (i = v = 0; i < SOUND_MIXER_NRDEVICES; i++) {
564 if (
amt[i].iselect) v |= 1 << i;
574 u_int32_t
r, l, v,
mask;
593 if (l == 0 &&
r == 0) {
594 v &= ~amt[
dev].oselect;
608 for (i = l =
r = 0; i < SOUND_MIXER_NRDEVICES; i++) {
609 if (
src & (1 << i)) {
610 if (
amt[i].iselect == 1) {
640 u_int8_t
intr, sb_status;
704 for (i = 0x91; i <= 0x96; i++) {
711 DEB(printf(
"GCR_DMA_EMULATION 0x%08x\n", v));
729 device_set_desc(
dev,
"Avance Logic ALS4000");
730 return BUS_PROBE_DEFAULT;
739 bus_release_resource(
dev, SYS_RES_IOPORT, sc->
regid, sc->
reg);
743 bus_teardown_intr(
dev, sc->
irq, sc->
ih);
747 bus_release_resource(
dev, SYS_RES_IRQ, sc->
irqid, sc->
irq);
764 sc->
reg = bus_alloc_resource_any(
dev, SYS_RES_IOPORT, &sc->
regid,
766 if (sc->
reg == NULL) {
767 device_printf(
dev,
"unable to allocate register space\n");
770 sc->
st = rman_get_bustag(sc->
reg);
771 sc->
sh = rman_get_bushandle(sc->
reg);
773 sc->
irq = bus_alloc_resource_any(
dev, SYS_RES_IRQ, &sc->
irqid,
774 RF_ACTIVE | RF_SHAREABLE);
775 if (sc->
irq == NULL) {
776 device_printf(
dev,
"unable to allocate interrupt\n");
782 device_printf(
dev,
"unable to setup interrupt\n");
788 if (bus_dma_tag_create(bus_get_dma_tag(
dev),
790 BUS_SPACE_MAXADDR_24BIT,
797 device_printf(
dev,
"unable to create dma tag\n");
812 sc = malloc(
sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
816 pci_enable_busmaster(
dev);
822 if (pci_get_powerstate(
dev) != PCI_POWERSTATE_D0) {
824 device_printf(
dev,
"chip is in D%d power mode "
825 "-- setting to D0\n", pci_get_powerstate(
dev));
826 pci_set_powerstate(
dev, PCI_POWERSTATE_D0);
830 device_printf(
dev,
"failed to allocate resources\n");
835 device_printf(
dev,
"failed to initialize hardware\n");
840 device_printf(
dev,
"failed to initialize mixer\n");
845 device_printf(
dev,
"failed to register pcm entries\n");
900 device_printf(
dev,
"unable to reinitialize the card\n");
906 device_printf(
dev,
"unable to reinitialize the mixer\n");
static int als_resource_grab(device_t dev, struct sc_info *sc)
static u_int32_t alsmix_setrecsrc(struct snd_mixer *m, u_int32_t src)
static struct pcmchan_caps als_caps
static int als_pci_probe(device_t dev)
static driver_t als_driver
static u_int32_t als_gcr_rd(struct sc_info *sc, int index)
static void als_resource_free(device_t dev, struct sc_info *sc)
#define ALS_8BIT_CMD(x, y)
DRIVER_MODULE(snd_als4000, pci, als_driver, pcm_devclass, 0, 0)
static kobj_method_t als_mixer_methods[]
static int als_pci_resume(device_t dev)
MODULE_VERSION(snd_als4000, 1)
#define ALS_DEFAULT_BUFSZ
static int als_capture_stop(struct sc_chinfo *ch)
static int alsrchan_trigger(kobj_t obj, void *data, int go)
static u_int32_t als_format[]
static kobj_method_t alsrchan_methods[]
static void als_capture_start(struct sc_chinfo *ch)
struct playback_command playback_cmds[]
static int als_pci_suspend(device_t dev)
struct sb16props amt[SOUND_MIXER_NRDEVICES]
static void als_gcr_wr(struct sc_info *sc, int index, int data)
static const struct playback_command * als_get_playback_command(u_int32_t format)
static int alschan_setformat(kobj_t obj, void *data, u_int32_t format)
static void als_intr(void *p)
SND_DECLARE_FILE("$FreeBSD$")
static u_int32_t alschan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
static int als_playback_stop(struct sc_chinfo *ch)
CHANNEL_DECLARE(alspchan)
static void als_esp_wr(struct sc_info *sc, u_int8_t data)
static int als_esp_reset(struct sc_info *sc)
static void als_playback_start(struct sc_chinfo *ch)
static int als_init(struct sc_info *sc)
static u_int8_t als_intr_rd(struct sc_info *sc)
static int als_pci_detach(device_t dev)
static u_int32_t alschan_getptr(kobj_t obj, void *data)
static u_int32_t alschan_setspeed(kobj_t obj, void *data, u_int32_t speed)
MODULE_DEPEND(snd_als4000, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
static void als_mix_wr(struct sc_info *sc, u_int8_t index, u_int8_t data)
static device_method_t als_methods[]
static void als_set_speed(struct sc_chinfo *ch)
static u_int8_t als_get_fifo_format(struct sc_info *sc, u_int32_t format)
static int alspchan_trigger(kobj_t obj, void *data, int go)
static kobj_method_t alspchan_methods[]
static int alsmix_init(struct snd_mixer *m)
static struct pcmchan_caps * alschan_getcaps(kobj_t obj, void *data)
static u_int8_t als_ack_read(struct sc_info *sc, u_int8_t addr)
static int alsmix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
static void als_uninit(struct sc_info *sc)
static u_int8_t als_mix_rd(struct sc_info *sc, u_int8_t index)
static void als_intr_wr(struct sc_info *sc, u_int8_t data)
static int als_pci_attach(device_t dev)
static void * alschan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
#define ALS_16BIT_CMD(x, y)
#define ALS_ESP_WR_STATUS
#define ALS_CR1E_ACK_PORT
#define ALS_GCR_FIFO1_COUNT
#define ALS_FIFO1_CONTROL
#define ALS_SB16_DMA_SETUP
#define ALS_GCR_FIFO0_STATUS
#define ALS_GCR_DMA0_START
#define ALS_FIFO1_LENGTH_LO
#define ALS_GCR_DMA0_MODE
#define ALS_ESP_RD_STATUS16
#define ALS_GCR_DMA_EMULATION
#define ALS_ESP_SAMPLE_RATE
#define ALS_GCR_FIFO1_START
#define ALS_FIFO1_LENGTH_HI
#define ALS_GCR_FIFO1_STATUS
#define ALS_ESP_RD_STATUS8
int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags, unsigned int size)
bus_addr_t sndbuf_getbufaddr(struct snd_dbuf *buf)
unsigned int sndbuf_getsize(struct snd_dbuf *b)
int sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz)
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)
int mixer_reinit(device_t dev)
void * mix_getdevinfo(struct snd_mixer *m)
void mix_setrecdevs(struct snd_mixer *m, u_int32_t v)
Record mask of available recording devices.
#define DSP_MODE_U8STEREO
#define DSP_MODE_S16STEREO
void * snd_mtxcreate(const char *desc, const char *type)
void * pcm_getdevinfo(device_t dev)
int pcm_setstatus(device_t dev, char *str)
void snd_mtxfree(void *m)
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)
#define DSP_DEFAULT_SPEED
struct pcm_channel * channel
bus_dma_tag_t parent_dmat