Index: sys/i386/conf/files.i386 diff -c sys/i386/conf/files.i386:1.1.1.1 sys/i386/conf/files.i386:1.1.1.1.6.2 *** sys/i386/conf/files.i386:1.1.1.1 Fri Jul 2 01:33:53 1999 --- sys/i386/conf/files.i386 Tue Aug 3 05:00:57 1999 *************** *** 356,359 **** --- 356,360 ---- gnu/i386/isa/dgm.c optional dgm device-driver gnu/i386/isa/sound/awe_wave.c optional awe device-driver pci/es1370.c optional pcm device-driver + pci/dsxg.c optional dsxg device-driver pci/ide_pci.c optional wd device-driver Index: sys/i386/isa/snd/sb_dsp.c diff -c sys/i386/isa/snd/sb_dsp.c:1.1.1.1 sys/i386/isa/snd/sb_dsp.c:1.1.1.1.6.1 *** sys/i386/isa/snd/sb_dsp.c:1.1.1.1 Fri Jul 2 01:34:10 1999 --- sys/i386/isa/snd/sb_dsp.c Tue Aug 3 05:01:01 1999 *************** *** 122,136 **** static int sb_probe(struct isa_device *dev) { bzero(&pcm_info[dev->id_unit], sizeof(pcm_info[dev->id_unit]) ); if (dev->id_iobase == -1) { dev->id_iobase = 0x220; BVDDB(printf("sb_probe: no address supplied, try defaults (0x220,0x240)\n");) - if (snd_conflict(dev->id_iobase)) - dev->id_iobase = 0x240; } if (snd_conflict(dev->id_iobase)) ! return 0 ; if (sb_reset_dsp(dev->id_iobase)) return 16 ; /* the SB uses 16 registers... */ --- 122,159 ---- static int sb_probe(struct isa_device *dev) { + int fl_noaddr = 0; + struct snd_lac_ent *ent; + bzero(&pcm_info[dev->id_unit], sizeof(pcm_info[dev->id_unit]) ); if (dev->id_iobase == -1) { + fl_noaddr = -1; dev->id_iobase = 0x220; BVDDB(printf("sb_probe: no address supplied, try defaults (0x220,0x240)\n");) } + + if ( !(dev->id_flags&DV_F_DISABLE_LAC) && + NULL!=(ent=snd_lac_find(NULL, SND_LAC_TYPE_SBPRO)) ) { + /* legacy audio control */ + int i, j; + struct snd_lac_conf c; + bzero(&c, sizeof(c)); + + c.u.sb_pro.sb_en = 1; + c.u.sb_pro.dma_no = dev->id_drq; + j=dev->id_irq; + for ( i=-1; j; i++, j>>=1 ) + ; + c.u.sb_pro.sb_irq_no = i; + c.u.sb_pro.sb_io = dev->id_iobase; + (*ent->setup_func)(ent, &c); + } + if (snd_conflict(dev->id_iobase)) ! if ( fl_noaddr ) ! dev->id_iobase = 0x240; ! else ! return 0 ; if (sb_reset_dsp(dev->id_iobase)) return 16 ; /* the SB uses 16 registers... */ Index: sys/i386/isa/snd/sound.c diff -c sys/i386/isa/snd/sound.c:1.1.1.1 sys/i386/isa/snd/sound.c:1.1.1.1.6.1 *** sys/i386/isa/snd/sound.c:1.1.1.1 Fri Jul 2 01:34:10 1999 --- sys/i386/isa/snd/sound.c Tue Aug 3 05:01:01 1999 *************** *** 91,96 **** --- 91,99 ---- u_long nsnd = NPCM ; /* total number of sound devices */ + static struct snd_lac_ent lac_entries[SND_LAC_MAX]; + static int nlas = 0; + /* * Hooks for APM support, but code not operational yet. */ *************** *** 1515,1520 **** --- 1518,1552 ---- for (i = 0; i < n; ++i) buff[i] = table[buff[i]]; + } + + + /* + * Legacy Audio Control + */ + + int + snd_lac_add(struct snd_lac_ent *ent) + { + if ( nlas >= SND_LAC_MAX ) + return -1; + bcopy(ent, &lac_entries[nlas++], sizeof(*ent)); + return 0; + } + + struct snd_lac_ent * + snd_lac_find(struct snd_lac_ent *next, int lac_type) + { + int i; + + if ( !next ) + next = &lac_entries[0]; + + for (i=(int)(next-&lac_entries[0]); i>=0&&ilac_type==lac_type ) + return next; + + return NULL; } #endif /* NPCM > 0 */ Index: sys/i386/isa/snd/sound.h diff -c sys/i386/isa/snd/sound.h:1.1.1.1 sys/i386/isa/snd/sound.h:1.1.1.1.6.1 *** sys/i386/isa/snd/sound.h:1.1.1.1 Fri Jul 2 01:34:10 1999 --- sys/i386/isa/snd/sound.h Tue Aug 3 05:01:01 1999 *************** *** 411,416 **** --- 411,452 ---- typedef struct mixer_def mixer_ent; typedef struct mixer_def mixer_tab[32][2]; + + /* + * Legacy Audio Control + */ + + #define SND_LAC_MAX 4 /* max number of legacy audio systems */ + + struct snd_lac_conf { + union { + struct { + int sb_en; /* SB enable */ + int fm_en; /* FM enable */ + int mpu_en; /* MPU enable */ + int js_en; /* Joy Stick enable */ + int dma_no; /* DMA number for SB */ + int sb_irq_no; /* IRQ number for SB */ + int mpu_irq_no; /* IRQ number for MPU */ + u_short sb_io; /* I/O port for SB */ + u_short fm_io; /* I/O port for FM */ + u_short mpu_io; /* I/O port for MPU */ + u_short js_io; /* I/O port for Joy Stick */ + } sb_pro; + struct { + char pad[128]; + } pad; + } u; + }; + + struct snd_lac_ent { + int (*setup_func)(struct snd_lac_ent *ent, struct snd_lac_conf *conf); + int lac_type; + #define SND_LAC_TYPE_SBPRO 1 + void *lac_private; + }; + + #ifdef KERNEL #define FULL_DUPLEX(d) (d->dbuf_out.chan != d->dbuf_in.chan) *************** *** 499,504 **** --- 535,547 ---- void sb_setmixer (int io_base, u_int port, u_int value); int sb_getmixer (int io_base, u_int port); + /* + * Legacy Audio Control + */ + + int snd_lac_add(struct snd_lac_ent *ent); + struct snd_lac_ent *snd_lac_find(struct snd_lac_ent *next, int lac_type); + #endif /* KERNEL */ /* *************** *** 519,524 **** --- 562,572 ---- /* almost all modern cards do not have this set of registers, * so it is better to make this the default behaviour */ + + /* + * Legacy Audio Control Disable + */ + #define DV_F_DISABLE_LAC 0x40000000 /* * the following flags are for PnP cards only and are undocumented Index: sys/pci/dsxg.c diff -c /dev/null sys/pci/dsxg.c:1.1.4.2 *** /dev/null Tue Aug 3 05:03:23 1999 --- sys/pci/dsxg.c Tue Aug 3 05:01:04 1999 *************** *** 0 **** --- 1,315 ---- + /*- + * This is the driver for YAMAHA DS-XG chips. + * + * Copyright (c)1999 Takuya SHIOZAKI + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * 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 + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 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. + * + * $Id: dsxg.c,v 1.1.4.2 1999/08/02 20:01:04 tshiozak Exp $ + */ + + + /* + * Current Status : Supporting the "Legacy Audio" only. + */ + + #include "pci.h" + + /* XXX - sound.h should not be in such directory. */ + #include + + #if (NPCI>0) && (NPCM>0) + + #include + #include + #include + + #include + #include + + #include + + + static const char *dsxg_probe __P((pcici_t, pcidi_t)); + static void dsxg_attach __P((pcici_t, int)); + + static int setup_legacy __P((struct snd_lac_ent *, + struct snd_lac_conf *)); + static int val_to_bp __P((int *, int)); + #if 0 + /*XXX*/ + static int bp_to_val __P((int *, int)); + #endif + + + static u_long dsxg_count; + + static struct pci_device dsxg_device = { + "dsxg", + dsxg_probe, + dsxg_attach, + &dsxg_count, + NULL + }; + DATA_SET(pcidevice_set, dsxg_device); + + + static struct dsxg_lac_private lac_info[NDSXG_MAX]; + + + static const char * + dsxg_probe(config_id, device_id) + pcici_t config_id; + pcidi_t device_id; + { + switch (device_id) { + case DEVID_YMF724: + return "YAMAHA YMF-724 DS-XG Sound Card"; + break; + case DEVID_YMF744: + return "YAMAHA YMF-744 DS-XG Sound Card"; + break; + } + return NULL; + } + + static void + dsxg_attach(config_id, unit) + pcici_t config_id; + int unit; + { + struct dsxg_lac_private *d; + struct snd_lac_ent e; + + if ( unit>=NDSXG_MAX ) + return; + + d = &lac_info[unit]; + d->config_id = config_id; + d->device_id = pci_conf_read(config_id, PCIR_DEVVENDOR); + + e.setup_func = &setup_legacy; + e.lac_type = SND_LAC_TYPE_SBPRO; + e.lac_private = (void *)d; + snd_lac_add(&e); + } + + + static int irq_bp[] = { + 5, 7, 9, 10, 11, -1 + }; + + static int fmio_bp724[] = { + 0x388, 0x398, 0x3A0, 0x3A8, -1 + }; + + static int sbio_bp724[] = { + 0x220, 0x240, 0x260, 0x280, -1 + }; + + static int mpuio_bp724[] = { + 0x330, 0x300, 0x332, 0x334, -1 + }; + + static int jsio_bp724[] = { + 0x201, 0x202, 0x204, 0x205, -1 + }; + + + static int + val_to_bp(tab, val) + int *tab; + int val; + { + int i; + + for (i=0; tab[i]!=-1; i++) + if ( tab[i]==val ) + return i; + + return -1; + } + + #if 0 + /*XXX*/ + static int + bp_to_val(tab, bp) + int *tab; + int bp; + { + int i; + + for (i=0; tab[i]!=-1; i++) + if ( i==bp ) + return tab[i]; + + return -1; + } + #endif + + + static int + setup_legacy(ent, conf) + struct snd_lac_ent *ent; + struct snd_lac_conf *conf; + { + u_long lac = 0; + struct dsxg_lac_private *prv = (struct dsxg_lac_private *)ent->lac_private; + int unit = (int)(prv-&lac_info[0]); + int tmp; + + printf("dsxg%d: ", unit); + if ( conf->u.sb_pro.sb_en ) { + printf("SBEN "); + DSXG_SET(lac, DSXG_LAC_SBEN_MASK); + } else + DSXG_CLEAR(lac, DSXG_LAC_SBEN_MASK); + if ( conf->u.sb_pro.fm_en ) { + printf("FMEN "); + DSXG_SET(lac, DSXG_LAC_FMEN_MASK); + } else + DSXG_CLEAR(lac, DSXG_LAC_FMEN_MASK); + if ( conf->u.sb_pro.js_en ) { + printf("GPEN "); + DSXG_SET(lac, DSXG_LAC_GPEN_MASK); + } else + DSXG_CLEAR(lac, DSXG_LAC_GPEN_MASK); + if ( conf->u.sb_pro.mpu_en ) { + printf("MEN "); + DSXG_SET(lac, DSXG_LAC_MEN_MASK); + } else + DSXG_CLEAR(lac, DSXG_LAC_MEN_MASK); + + DSXG_CLEAR(lac, DSXG_LAC_SIEN_MASK); + DSXG_CLEAR(lac, DSXG_LAC_LAD_MASK); + + if ( conf->u.sb_pro.sb_en ) { + printf("DRQ=%d ", conf->u.sb_pro.dma_no); + DSXG_SETBITFIELD(lac, DSXG_LAC_SDMA_MASK, DSXG_LAC_SDMA_BADR, + conf->u.sb_pro.dma_no); + + printf("SBIRQ=%d ", conf->u.sb_pro.sb_irq_no); + if ( 0 > (tmp=val_to_bp(irq_bp, conf->u.sb_pro.sb_irq_no)) ) { + printf("\ndsxg%d: unrecognized IRQ number %d for SB port.\n", + unit, conf->u.sb_pro.sb_irq_no); + return -1; + } + DSXG_SETBITFIELD(lac, DSXG_LAC_SBIRQ_MASK, DSXG_LAC_SBIRQ_BADR, tmp); + } + + if ( conf->u.sb_pro.mpu_en ) { + printf("MPUIRQ=%d ", conf->u.sb_pro.mpu_irq_no); + if ( 0 > (tmp=val_to_bp(irq_bp, conf->u.sb_pro.mpu_irq_no)) ) { + printf("\ndsxg%d: unrecognized IRQ number %d for MPU port.\n", + unit, conf->u.sb_pro.mpu_irq_no); + return -1; + } + DSXG_SETBITFIELD(lac, DSXG_LAC_MPUIRQ_MASK, DSXG_LAC_MPUIRQ_BADR, tmp); + } + + /* I/O port setting */ + switch (prv->device_id) { + case DEVID_YMF724: + if ( conf->u.sb_pro.fm_en ) { + printf("FMIO=0x%04x ", conf->u.sb_pro.fm_io); + if ( 0 > (tmp=val_to_bp(fmio_bp724, conf->u.sb_pro.fm_io)) ) { + printf("\ndsxg%d: unrecognized I/O number %d for FM port.\n", + unit, conf->u.sb_pro.fm_io); + return -1; + } + DSXG_SETBITFIELD(lac, DSXG_LAC_FMIO_MASK, DSXG_LAC_FMIO_BADR, tmp); + } + if ( conf->u.sb_pro.sb_en ) { + printf("SBIO=0x%04x ", conf->u.sb_pro.sb_io); + if ( 0 > (tmp=val_to_bp(sbio_bp724, conf->u.sb_pro.sb_io)) ) { + printf("\ndsxg%d: unrecognized I/O number %d for SB port.\n", + unit, conf->u.sb_pro.sb_io); + return -1; + } + DSXG_SETBITFIELD(lac, DSXG_LAC_SBIO_MASK, DSXG_LAC_SBIO_BADR, tmp); + } + if ( conf->u.sb_pro.mpu_en ) { + printf("MPUIO=0x%04x ", conf->u.sb_pro.mpu_io); + if ( 0 > (tmp=val_to_bp(mpuio_bp724, conf->u.sb_pro.mpu_io)) ) { + printf("\ndsxg%d: unrecognized I/O number %d for MPU port.\n", + unit, conf->u.sb_pro.mpu_io); + return -1; + } + DSXG_SETBITFIELD(lac, DSXG_LAC_MPUIO_MASK, DSXG_LAC_MPUIO_BADR, + tmp); + } + if ( conf->u.sb_pro.js_en ) { + printf("JSIO=0x%04x ", conf->u.sb_pro.js_io); + if ( 0 > (tmp=val_to_bp(jsio_bp724, conf->u.sb_pro.js_io)) ) { + printf("\ndsxg%d: unrecognized I/O number %d for " + "joy stick port.\n", + unit, conf->u.sb_pro.js_io); + return -1; + } + DSXG_SETBITFIELD(lac, DSXG_LAC_JSIO_MASK, DSXG_LAC_JSIO_BADR, tmp); + } + break; + + + case DEVID_YMF744: + if ( conf->u.sb_pro.fm_en ) { + printf("FMIO=0x%04x ", conf->u.sb_pro.fm_io); + } + if ( conf->u.sb_pro.sb_en ) { + printf("SBIO=0x%04x ", conf->u.sb_pro.sb_io); + } + tmp = ((u_long)conf->u.sb_pro.sb_io<<16) | conf->u.sb_pro.fm_io; + pci_conf_write(prv->config_id, DSXG_BASE_SBFM_REG, tmp); + + if ( conf->u.sb_pro.mpu_en ) { + printf("MPUIO=0x%04x ", conf->u.sb_pro.mpu_io); + } + if ( conf->u.sb_pro.js_en ) { + printf("JSIO=0x%04x ", conf->u.sb_pro.js_io); + } + tmp = ((u_long)conf->u.sb_pro.js_io<<16) | conf->u.sb_pro.mpu_io; + pci_conf_write(prv->config_id, DSXG_BASE_JSMPU_REG, tmp); + break; + } + + DSXG_SET(lac, DSXG_LAC_MAIM_MASK); + DSXG_SETBITFIELD(lac, DSXG_LAC_SMOD_MASK, DSXG_LAC_SMOD_BADR, + DSXG_LAC_SMOD_PC_PCI); + #if 0 + DSXG_SETBITFIELD(lac, DSXG_LAC_SMOD_MASK, DSXG_LAC_SMOD_BADR, + DSXG_LAC_SMOD_DDMA); + #endif + DSXG_SETBITFIELD(lac, DSXG_LAC_SBVER_MASK, DSXG_LAC_SBVER_BADR, + DSXG_LAC_SBVER_3_01); + DSXG_CLEAR(lac, DSXG_LAC_IMOD_MASK); + + pci_conf_write(prv->config_id, DSXG_LAC_REG, lac); + printf("\ndsxg%d: ELAC/LAC=0x%08x\n", unit, (int)lac); + + return 0; + } + + + #endif /* NPCI>0 && NPCM>0 */ + + /* end of file */ Index: sys/pci/dsxg_reg.h diff -c /dev/null sys/pci/dsxg_reg.h:1.1.2.2 *** /dev/null Tue Aug 3 05:03:23 1999 --- sys/pci/dsxg_reg.h Tue Aug 3 05:01:04 1999 *************** *** 0 **** --- 1,109 ---- + /*- + * This is the driver for YAMAHA DS-XG chips. + * + * Copyright (c)1999 Takuya SHIOZAKI + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * 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 + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 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. + * + * $Id: dsxg_reg.h,v 1.1.2.2 1999/08/02 20:01:04 tshiozak Exp $ + */ + + #ifndef _DSXG_REG_H_ + #define _DSXG_REG_H_ + + #define NDSXG_MAX 4 + + /* Device IDs */ + + #define DEVID_YMF724 0x000D1073 + #define DEVID_YMF744 0x00101073 + + + /* Legacy Audio Control / Extended Legacy Audio Control Register */ + /* LAC (low 16bit) */ + #define DSXG_LAC_REG 0x40 + #define DSXG_LAC_SBEN_MASK 0x00000001 + #define DSXG_LAC_SBEN_BADR 0 + #define DSXG_LAC_FMEN_MASK 0x00000002 + #define DSXG_LAC_FMEN_BADR 1 + #define DSXG_LAC_GPEN_MASK 0x00000004 + #define DSXG_LAC_GPEN_BADR 2 + #define DSXG_LAC_MEN_MASK 0x00000008 + #define DSXG_LAC_MEN_BADR 3 + #define DSXG_LAC_MIEN_MASK 0x00000010 + #define DSXG_LAC_MIEN_BADR 4 + #define DSXG_LAC_IO_MASK 0x00000020 + #define DSXG_LAC_IO_BADR 5 + #define DSXG_LAC_SDMA_MASK 0x000000c0 + #define DSXG_LAC_SDMA_BADR 6 + #define DSXG_LAC_SBIRQ_MASK 0x00000700 + #define DSXG_LAC_SBIRQ_BADR 8 + #define DSXG_LAC_MPUIRQ_MASK 0x00003800 + #define DSXG_LAC_MPUIRQ_BADR 11 + #define DSXG_LAC_SIEN_MASK 0x00004000 + #define DSXG_LAC_SIEN_BADR 14 + #define DSXG_LAC_LAD_MASK 0x00008000 + #define DSXG_LAC_LAD_BADR 15 + /* ELAC (high 16bit) */ + #define DSXG_LAC_FMIO_MASK 0x00030000 + #define DSXG_LAC_FMIO_BADR 16 + #define DSXG_LAC_SBIO_MASK 0x000c0000 + #define DSXG_LAC_SBIO_BADR 18 + #define DSXG_LAC_MPUIO_MASK 0x00300000 + #define DSXG_LAC_MPUIO_BADR 20 + #define DSXG_LAC_JSIO_MASK 0x00c00000 + #define DSXG_LAC_JSIO_BADR 22 + #define DSXG_LAC_MAIM_MASK 0x01000000 + #define DSXG_LAC_MAIM_BADR 24 + #define DSXG_LAC_SMOD_MASK 0x18000000 + #define DSXG_LAC_SMOD_BADR 27 + #define DSXG_LAC_SMOD_PC_PCI 0 + #define DSXG_LAC_SMOD_DDMA 2 + #define DSXG_LAC_SBVER_MASK 0x60000000 + #define DSXG_LAC_SBVER_BADR 29 + #define DSXG_LAC_SBVER_3_01 0 + #define DSXG_LAC_SBVER_2_01 1 + #define DSXG_LAC_SBVER_1_05 2 + #define DSXG_LAC_IMOD_MASK 0x80000000 + #define DSXG_LAC_IMOD_BADR 31 + + /* Base Address (YMF-744) */ + #define DSXG_BASE_SBFM_REG 0x60 + #define DSXG_BASE_JSMPU_REG 0x64 + + + #define DSXG_SET(r, m) ((r) |= (m)) + #define DSXG_CLEAR(r, m) ((r) &= ~(m)) + #define DSXG_SETBITFIELD(r, m, a, v) ((r) = ((r)&~(m)) | (((v)<<(a))&(m))) + #define DSXG_GETBITFIELD(r, m, a) (((r)&(m))>>(a)) + + + + struct dsxg_lac_private { + pcidi_t device_id; + pcici_t config_id; + }; + + #endif /* _DSXG_REG_H_ */ + + /* end of file */