Deleted Added
full compact
28c28
< * $FreeBSD: head/sys/dev/sound/isa/mss.c 53512 1999-11-21 17:15:12Z cg $
---
> * $FreeBSD: head/sys/dev/sound/isa/mss.c 53553 1999-11-22 06:07:49Z tanimura $
36a37
> #include <dev/sound/chip.h>
37a39,43
> #include "gusc.h"
> #if notyet
> #include "midi.h"
> #endif /* notyet */
>
174a181
> #define MD_GUSMAX 0xB9
244c251
< #if NPNP > 0
---
> #if NPNP > 0 || NGUSC > 0
258c265
< #endif
---
> #endif /* NPNP > 0 || NGUSC > 0 */
331a339,396
> #if NGUSC > 0
> /*
> * XXX This might be better off in the gusc driver.
> */
> static void
> gusmax_setup(struct mss_info *mss, device_t dev, struct resource *alt)
> {
> static const unsigned char irq_bits[16] = {
> 0, 0, 0, 3, 0, 2, 0, 4, 0, 1, 0, 5, 6, 0, 0, 7
> };
> static const unsigned char dma_bits[8] = {
> 0, 1, 0, 2, 0, 3, 4, 5
> };
> device_t parent = device_get_parent(dev);
> unsigned char irqctl, dmactl;
> int s;
>
> s = splhigh();
>
> port_wr(alt, 0x0f, 0x05);
> port_wr(alt, 0x00, 0x0c);
> port_wr(alt, 0x0b, 0x00);
>
> port_wr(alt, 0x0f, 0x00);
>
> irqctl = irq_bits[isa_get_irq(parent)];
> #if notyet
> #if NMIDI > 0
> /* Share the IRQ with the MIDI driver. */
> irqctl |= 0x40;
> #endif /* NMIDI > 0 */
> #endif /* notyet */
> dmactl = dma_bits[isa_get_drq(parent)];
> if (device_get_flags(parent) & DV_F_DUAL_DMA)
> dmactl |= dma_bits[device_get_flags(parent) & DV_F_DRQ_MASK]
> << 3;
>
> /*
> * Set the DMA and IRQ control latches.
> */
> port_wr(alt, 0x00, 0x0c);
> port_wr(alt, 0x0b, dmactl | 0x80);
> port_wr(alt, 0x00, 0x4c);
> port_wr(alt, 0x0b, irqctl);
>
> port_wr(alt, 0x00, 0x0c);
> port_wr(alt, 0x0b, dmactl);
> port_wr(alt, 0x00, 0x4c);
> port_wr(alt, 0x0b, irqctl);
>
> port_wr(mss->conf_base, 2, 0);
> port_wr(alt, 0x00, 0x0c);
> port_wr(mss->conf_base, 2, 0);
>
> splx(s);
> }
> #endif /* NGUSC > 0 */
>
358a424
> #endif /* NPNP > 0 */
359a426
> #if NPNP > 0 || NGUSC > 0
360a428
> case MD_GUSMAX:
370a439,442
> if (alt == NULL) {
> printf("XXX couldn't init GUS PnP/MAX\n");
> break;
> }
371a444,447
> #if NGUSC > 0
> if (mss->bd_id == MD_GUSMAX)
> gusmax_setup(mss, dev, alt);
> #endif
392c468,469
< #endif
---
> #endif /* NPNP > 0 || NGUSC > 0 */
>
1018c1095,1110
< for (t = 100; t > 0 && (ad_read(mss, 11) & 0x20) == 0; t--) DELAY(100);
---
> /*
> * There is no guarantee that we'll ever see ACI go on,
> * calibration may finish before we get here.
> *
> * XXX Are there docs that even state that it might ever be
> * visible off before calibration starts using any chip?
> */
> if (mss->bd_id == MD_GUSMAX) {
> /* 10 ms of busy-waiting is not reasonable normal behavior */
> for (t = 100; t > 0 && (ad_read(mss, 11) & 0x20) == 0; t--)
> ;
> if (t > 0 && t != 100)
> printf("debug: ACI turned on: t = %d\n", t);
> } else {
> for (t = 100; t > 0 && (ad_read(mss, 11) & 0x20) == 0; t--) DELAY(100);
> }
1292a1385
> #if 0
1295a1389
> #endif
1363a1458
> #if 0
1371a1467
> #endif
1455a1552,1553
> #if NGUSC > 0
>
1456a1555,1637
> guspcm_probe(device_t dev)
> {
> struct sndcard_func *func;
>
> func = device_get_ivars(dev);
> if (func == NULL || func->func != SCF_PCM)
> return ENXIO;
>
> device_set_desc(dev, "GUS CS4231");
> return 0;
> }
>
> static int
> guspcm_attach(device_t dev)
> {
> device_t parent = device_get_parent(dev);
> struct mss_info *mss;
> int base, flags;
> unsigned char ctl;
>
> mss = (struct mss_info *)malloc(sizeof *mss, M_DEVBUF, M_NOWAIT);
> if (mss == NULL)
> return ENOMEM;
> bzero(mss, sizeof *mss);
>
> mss->bd_flags = BD_F_MSS_OFFSET;
> mss->io_rid = 2;
> mss->conf_rid = 1;
> mss->irq_rid = 0;
> mss->drq1_rid = 1;
> mss->drq2_rid = -1;
>
> if (isa_get_vendorid(parent) == 0)
> mss->bd_id = MD_GUSMAX;
> else {
> mss->bd_id = MD_GUSPNP;
> mss->drq2_rid = 0;
> goto skip_setup;
> }
>
> flags = device_get_flags(parent);
> if (flags & DV_F_DUAL_DMA)
> mss->drq2_rid = 0;
>
> mss->conf_base = bus_alloc_resource(dev, SYS_RES_IOPORT, &mss->conf_rid,
> 0, ~0, 8, RF_ACTIVE);
>
> if (mss->conf_base == NULL) {
> mss_release_resources(mss, dev);
> return ENXIO;
> }
>
> base = isa_get_port(parent);
>
> ctl = 0x40; /* CS4231 enable */
> if (isa_get_drq(dev) > 3)
> ctl |= 0x10; /* 16-bit dma channel 1 */
> if ((flags & DV_F_DUAL_DMA) != 0 && (flags & DV_F_DRQ_MASK) > 3)
> ctl |= 0x20; /* 16-bit dma channel 2 */
> ctl |= (base >> 4) & 0x0f; /* 2X0 -> 3XC */
> port_wr(mss->conf_base, 6, ctl);
>
> skip_setup:
> return mss_doattach(dev, mss);
> }
>
> static device_method_t guspcm_methods[] = {
> DEVMETHOD(device_probe, guspcm_probe),
> DEVMETHOD(device_attach, guspcm_attach),
>
> { 0, 0 }
> };
>
> static driver_t guspcm_driver = {
> "pcm",
> guspcm_methods,
> sizeof(snddev_info),
> };
>
> DRIVER_MODULE(guspcm, gusc, guspcm_driver, pcm_devclass, 0, 0);
> #endif /* NGUSC > 0 */
>
> static int
1474a1656
> case MD_GUSMAX:
1633a1816
> case MD_GUSMAX: