diff options
Diffstat (limited to 'sys')
35 files changed, 783 insertions, 717 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 846d5f518f5..ffc8c7f1547 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,5 @@ -/* $NetBSD: com.c,v 1.62 1995/10/15 19:43:04 mycroft Exp $ */ +/* $OpenBSD: com.c,v 1.7 1996/03/08 16:42:51 niklas Exp $ */ +/* $NetBSD: com.c,v 1.65 1996/02/10 20:23:18 christos Exp $ */ /*- * Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved. @@ -61,10 +62,12 @@ #include <dev/isa/isavar.h> #include <dev/isa/comreg.h> #include <dev/ic/ns16550reg.h> -#include <dev/ic/espreg.h> +#ifdef COM_HAYESP +#include <dev/ic/hayespreg.h> +#endif #define com_lcr com_cfcr -#define COM_IBUFSIZE (2 * 256) +#define COM_IBUFSIZE (2 * 512) #define COM_IHIGHWATER ((3 * COM_IBUFSIZE) / 4) struct com_softc { @@ -77,11 +80,13 @@ struct com_softc { int sc_errors; int sc_iobase; - int sc_espbase; +#ifdef COM_HAYESP + int sc_hayespbase; +#endif u_char sc_hwflags; #define COM_HW_NOIEN 0x01 #define COM_HW_FIFO 0x02 -#define COM_HW_ESP 0x04 +#define COM_HW_HAYESP 0x04 #define COM_HW_CONSOLE 0x40 u_char sc_swflags; #define COM_SW_SOFTCAR 0x01 @@ -226,64 +231,84 @@ comprobe1(iobase) return 1; } +#ifdef COM_HAYESP int -comprobe(parent, match, aux) - struct device *parent; - void *match, *aux; +comprobeHAYESP(iobase, sc) + int iobase; + struct com_softc *sc; { - struct isa_attach_args *ia = aux; - int iobase = ia->ia_iobase; + char val, dips; + int combaselist[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; - if (!comprobe1(iobase)) - return 0; + /* + * Hayes ESP cards have two iobases. One is for compatibility with + * 16550 serial chips, and at the same ISA PC base addresses. The + * other is for ESP-specific enhanced features, and lies at a + * different addressing range entirely (0x140, 0x180, 0x280, or 0x300). + */ - ia->ia_iosize = COM_NPORTS; - ia->ia_msize = 0; - return 1; -} + /* Test for ESP signature */ + if ((inb(iobase) & 0xf3) == 0) + return 0; -int -comprobeESP(esp_port, sc) - int esp_port; - struct com_softc *sc; -{ - char val, dips; - int com_base_list[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; + /* + * ESP is present at ESP enhanced base address; unknown com port + */ - /* Test for ESP signature at the ESP i/o port. */ - if ((inb(esp_port) & 0xf3) == 0) - return(0); + /* Get the dip-switch configurations */ + outb(iobase + HAYESP_CMD1, HAYESP_GETDIPS); + dips = inb(iobase + HAYESP_STATUS1); - /* Check compatibility mode settings */ - outb(esp_port + ESP_CMD1, ESP_GETDIPS); - dips = inb(esp_port + ESP_STATUS1); + /* Determine which com port this ESP card services: bits 0,1 of */ + /* dips is the port # (0-3); combaselist[val] is the com_iobase */ + if (sc->sc_iobase != combaselist[dips & 0x03]) + return 0; - /* Does this ESP board service this com port?: Bits 0,1 == COM0..3 */ - if (sc->sc_iobase != com_base_list[(dips & 0x03)]) { - return(0); - } printf(": ESP"); - /* Check ESP Self Test bits. */ + /* Check ESP Self Test bits. */ /* Check for ESP version 2.0: bits 4,5,6 == 010 */ - outb(esp_port + ESP_CMD1, ESP_GETTEST); - val = inb(esp_port + ESP_STATUS1); /* Always 0x00 */ - val = inb(esp_port + ESP_STATUS2); + outb(iobase + HAYESP_CMD1, HAYESP_GETTEST); + val = inb(iobase + HAYESP_STATUS1); /* Clear reg 1 */ + val = inb(iobase + HAYESP_STATUS2); if ((val & 0x70) < 0x20) { printf("-old (%o)", val & 0x70); - return(0); + /* we do not support the necessary features */ + return 0; } - /* Check for ability to emulate 16550: bit 7 set */ - if (ISSET(dips, 0x80) == 0) { + /* Check for ability to emulate 16550: bit 8 == 1 */ + if ((dips & 0x80) == 0) { printf(" slave"); - return(0); + /* XXX Does slave really mean no 16550 support?? */ + return 0; } - /* We're a full featured ESP card at the right com port. */ - SET(sc->sc_hwflags, COM_HW_ESP); - printf(", 1024 byte fifo\n"); - return(1); + /* + * If we made it this far, we are a full-featured ESP v2.0 (or + * better), at the correct com port address. + */ + + SET(sc->sc_hwflags, COM_HW_HAYESP); + printf(", 1024k fifo\n"); + return 1; +} +#endif + +int +comprobe(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct isa_attach_args *ia = aux; + int iobase = ia->ia_iobase; + + if (!comprobe1(iobase)) + return 0; + + ia->ia_iosize = COM_NPORTS; + ia->ia_msize = 0; + return 1; } void @@ -296,8 +321,10 @@ comattach(parent, self, aux) struct cfdata *cf = sc->sc_dev.dv_cfdata; int iobase = ia->ia_iobase; struct tty *tp; - int esp_ports[] = { 0x140, 0x180, 0x280, 0 }; - int *espp; +#ifdef COM_HAYESP + int hayesp_ports[] = { 0x140, 0x180, 0x280, 0x300, 0 }; + int *hayespp; +#endif sc->sc_iobase = iobase; sc->sc_hwflags = ISSET(cf->cf_flags, COM_HW_NOIEN); @@ -306,29 +333,33 @@ comattach(parent, self, aux) if (sc->sc_dev.dv_unit == comconsole) delay(1000); +#ifdef COM_HAYESP /* Look for a Hayes ESP board. */ - for (espp = esp_ports; *espp != 0; espp++) - if (comprobeESP(*espp, sc)) { - sc->sc_espbase = *espp; + for (hayespp = hayesp_ports; *hayespp != 0; hayespp++) + if (comprobeHAYESP(*hayespp, sc)) { + sc->sc_hayespbase = *hayespp; break; } /* No ESP; look for other things. */ - if (*espp == 0) { - /* look for a NS 16550AF UART with FIFOs */ - outb(iobase + com_fifo, - FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14); - delay(100); - if (ISSET(inb(iobase + com_iir), IIR_FIFO_MASK) == IIR_FIFO_MASK) - if (ISSET(inb(iobase + com_fifo), FIFO_TRIGGER_14) == - FIFO_TRIGGER_14) { - SET(sc->sc_hwflags, COM_HW_FIFO); - printf(": ns16550a, working fifo\n"); - } else - printf(": ns16550, broken fifo\n"); - else - printf(": ns8250 or ns16450, no fifo\n"); - outb(iobase + com_fifo, 0); + if (*hayespp == 0) { +#endif + + /* look for a NS 16550AF UART with FIFOs */ + outb(iobase + com_fifo, + FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14); + delay(100); + if (ISSET(inb(iobase + com_iir), IIR_FIFO_MASK) == IIR_FIFO_MASK) + if (ISSET(inb(iobase + com_fifo), FIFO_TRIGGER_14) == FIFO_TRIGGER_14) { + SET(sc->sc_hwflags, COM_HW_FIFO); + printf(": ns16550a, working fifo\n"); + } else + printf(": ns16550, broken fifo\n"); + else + printf(": ns8250 or ns16450, no fifo\n"); + outb(iobase + com_fifo, 0); +#ifdef COM_HAYESP } +#endif /* disable interrupts */ outb(iobase + com_ier, 0); @@ -424,32 +455,39 @@ comopen(dev, flag, mode, p) sc->sc_ibufend = sc->sc_ibuf + COM_IBUFSIZE; iobase = sc->sc_iobase; +#ifdef COM_HAYESP + /* Setup the ESP board */ + if (ISSET(sc->sc_hwflags, COM_HW_HAYESP)) { + int hayespbase = sc->sc_hayespbase; - /* Set up the ESP board */ - if (ISSET(sc->sc_hwflags, COM_HW_ESP)) { outb(iobase + com_fifo, - /* XXX - bug in ESP requires DMA flag set */ - FIFO_DMA_MODE | - FIFO_ENABLE | FIFO_RCV_RST | - FIFO_XMT_RST | FIFO_TRIGGER_8); + FIFO_DMA_MODE|FIFO_ENABLE| + FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_8); /* Set 16550 compatibility mode */ - outb(sc->sc_espbase + ESP_CMD1, ESP_SETMODE); - outb(sc->sc_espbase + ESP_CMD2, - ESP_MODE_FIFO | ESP_MODE_RTS | ESP_MODE_SCALE); + outb(hayespbase + HAYESP_CMD1, HAYESP_SETMODE); + outb(hayespbase + HAYESP_CMD2, + HAYESP_MODE_FIFO|HAYESP_MODE_RTS| + HAYESP_MODE_SCALE); /* Set RTS/CTS flow control */ - outb(sc->sc_espbase + ESP_CMD1, ESP_SETFLOWTYPE); - outb(sc->sc_espbase + ESP_CMD2, ESP_FLOW_RTS); - outb(sc->sc_espbase + ESP_CMD2, ESP_FLOW_CTS); + outb(hayespbase + HAYESP_CMD1, HAYESP_SETFLOWTYPE); + outb(hayespbase + HAYESP_CMD2, HAYESP_FLOW_RTS); + outb(hayespbase + HAYESP_CMD2, HAYESP_FLOW_CTS); /* Set flow control levels */ - outb(sc->sc_espbase + ESP_CMD1, ESP_SETRXFLOW); - outb(sc->sc_espbase + ESP_CMD2, HIBYTE(RXHIGHWATER)); - outb(sc->sc_espbase + ESP_CMD2, LOBYTE(RXHIGHWATER)); - outb(sc->sc_espbase + ESP_CMD2, HIBYTE(RXLOWWATER)); - outb(sc->sc_espbase + ESP_CMD2, LOBYTE(RXLOWWATER)); - } else if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) + outb(hayespbase + HAYESP_CMD1, HAYESP_SETRXFLOW); + outb(hayespbase + HAYESP_CMD2, + HAYESP_HIBYTE(HAYESP_RXHIWMARK)); + outb(hayespbase + HAYESP_CMD2, + HAYESP_LOBYTE(HAYESP_RXHIWMARK)); + outb(hayespbase + HAYESP_CMD2, + HAYESP_HIBYTE(HAYESP_RXLOWMARK)); + outb(hayespbase + HAYESP_CMD2, + HAYESP_LOBYTE(HAYESP_RXLOWMARK)); + } else +#endif + if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) /* Set the FIFO threshold based on the receive speed. */ outb(iobase + com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | @@ -829,13 +867,18 @@ comstart(tp) selwakeup(&tp->t_wsel); } SET(tp->t_state, TS_BUSY); - if (ISSET(sc->sc_hwflags, COM_HW_ESP)) { + +#ifdef COM_HAYESP + if (ISSET(sc->sc_hwflags, COM_HW_HAYESP)) { u_char buffer[1024], *cp = buffer; int n = q_to_b(&tp->t_outq, cp, sizeof buffer); - do { + do outb(iobase + com_data, *cp++); - } while (--n); - } else if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) { + while (--n); + } + else +#endif + if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) { u_char buffer[16], *cp = buffer; int n = q_to_b(&tp->t_outq, cp, sizeof buffer); do { diff --git a/sys/dev/ic/comreg.h b/sys/dev/ic/comreg.h index 96c92944e2b..1769ac9b679 100644 --- a/sys/dev/ic/comreg.h +++ b/sys/dev/ic/comreg.h @@ -1,4 +1,5 @@ -/* $NetBSD: comreg.h,v 1.7 1995/10/15 19:43:07 mycroft Exp $ */ +/* $OpenBSD: comreg.h,v 1.4 1996/03/08 16:42:52 niklas Exp $ */ +/* $NetBSD: comreg.h,v 1.8 1996/02/05 23:01:50 scottr Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -41,27 +42,27 @@ #define COM_TOLERANCE 30 /* baud rate tolerance, in 0.1% units */ /* interrupt enable register */ -#define IER_ERXRDY 0x1 /* Character received */ -#define IER_ETXRDY 0x2 /* Transmitter empty */ -#define IER_ERLS 0x4 /* Error condition */ -#define IER_EMSC 0x8 /* RS-232 line state change */ +#define IER_ERXRDY 0x1 /* Enable receiver interrupt */ +#define IER_ETXRDY 0x2 /* Enable transmitter empty interrupt */ +#define IER_ERLS 0x4 /* Enable line status interrupt */ +#define IER_EMSC 0x8 /* Enable modem status interrupt */ /* interrupt identification register */ #define IIR_IMASK 0xf #define IIR_RXTOUT 0xc -#define IIR_RLS 0x6 -#define IIR_RXRDY 0x4 -#define IIR_TXRDY 0x2 +#define IIR_RLS 0x6 /* Line status change */ +#define IIR_RXRDY 0x4 /* Receiver ready */ +#define IIR_TXRDY 0x2 /* Transmitter ready */ +#define IIR_MLSC 0x0 /* Modem status */ #define IIR_NOPEND 0x1 /* No pending interrupts */ -#define IIR_MLSC 0x0 #define IIR_FIFO_MASK 0xc0 /* set if FIFOs are enabled */ /* fifo control register */ #define FIFO_ENABLE 0x01 /* Turn the FIFO on */ #define FIFO_RCV_RST 0x02 /* Reset RX FIFO */ #define FIFO_XMT_RST 0x04 /* Reset TX FIFO */ -#define FIFO_DMA_MODE 0x08 /* DMA mode? */ -#define FIFO_TRIGGER_1 0x00 /* Trigger RXRDY Interrupt on 1 character */ +#define FIFO_DMA_MODE 0x08 +#define FIFO_TRIGGER_1 0x00 /* Trigger RXRDY intr on 1 character */ #define FIFO_TRIGGER_4 0x40 /* ibid 4 */ #define FIFO_TRIGGER_8 0x80 /* ibid 8 */ #define FIFO_TRIGGER_14 0xc0 /* ibid 14 */ @@ -83,9 +84,9 @@ /* modem control register */ #define MCR_LOOPBACK 0x10 /* Loop test: echos from TX to RX */ -#define MCR_IENABLE 0x08 /* Output 2: enables UART interrupts */ -#define MCR_DRS 0x04 /* Output 1: resets some internal modems */ -#define MCR_RTS 0x02 /* RTS: ready to receive data */ +#define MCR_IENABLE 0x08 /* Out2: enables UART interrupts */ +#define MCR_DRS 0x04 /* Out1: resets some internal modems */ +#define MCR_RTS 0x02 /* Request To Send */ #define MCR_DTR 0x01 /* Data Terminal Ready */ /* line status register */ diff --git a/sys/dev/isa/ad1848.c b/sys/dev/isa/ad1848.c index 124f9bdd5fa..1c9abfec602 100644 --- a/sys/dev/isa/ad1848.c +++ b/sys/dev/isa/ad1848.c @@ -1,4 +1,5 @@ -/* $NetBSD: ad1848.c,v 1.7 1995/11/10 04:30:36 mycroft Exp $ */ +/* $OpenBSD: ad1848.c,v 1.3 1996/03/08 16:42:45 niklas Exp $ */ +/* $NetBSD: ad1848.c,v 1.8 1996/02/05 21:32:26 scottr Exp $ */ /* * Copyright (c) 1994 John Brezak @@ -1124,8 +1125,7 @@ ad1848_round_blocksize(addr, blk) sc->sc_lastcc = -1; /* Higher speeds need bigger blocks to avoid popping and silence gaps. */ - if ((sc->sc_orate > 8000 || sc->sc_irate > 8000) && - (blk > NBPG/2 || blk < NBPG/4)) + if ((sc->sc_orate > 8000 || sc->sc_irate > 8000) && blk < NBPG/2) blk = NBPG/2; /* don't try to DMA too much at once, though. */ if (blk > NBPG) diff --git a/sys/dev/isa/aha.c b/sys/dev/isa/aha.c index 786326551f1..62e24d72122 100644 --- a/sys/dev/isa/aha.c +++ b/sys/dev/isa/aha.c @@ -1,4 +1,5 @@ -/* $NetBSD: aha1542.c,v 1.53 1995/10/03 20:58:56 mycroft Exp $ */ +/* $OpenBSD: aha.c,v 1.11 1996/03/08 16:42:47 niklas Exp $ */ +/* $NetBSD: aha1542.c,v 1.55 1995/12/24 02:31:06 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. diff --git a/sys/dev/isa/aha1542.c b/sys/dev/isa/aha1542.c index 786326551f1..63a29631d67 100644 --- a/sys/dev/isa/aha1542.c +++ b/sys/dev/isa/aha1542.c @@ -1,4 +1,5 @@ -/* $NetBSD: aha1542.c,v 1.53 1995/10/03 20:58:56 mycroft Exp $ */ +/* $OpenBSD: aha1542.c,v 1.11 1996/03/08 16:42:47 niklas Exp $ */ +/* $NetBSD: aha1542.c,v 1.55 1995/12/24 02:31:06 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. diff --git a/sys/dev/isa/ast.c b/sys/dev/isa/ast.c index 79bc9c7dc57..7647e77cdf3 100644 --- a/sys/dev/isa/ast.c +++ b/sys/dev/isa/ast.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ast.c,v 1.4 1996/03/08 16:42:48 niklas Exp $ */ /* $NetBSD: ast.c,v 1.18 1995/06/26 04:08:04 cgd Exp $ */ /* diff --git a/sys/dev/isa/boca.c b/sys/dev/isa/boca.c index ca375bb6a14..9b329add9ce 100644 --- a/sys/dev/isa/boca.c +++ b/sys/dev/isa/boca.c @@ -1,4 +1,5 @@ -/* $NetBSD: boca.c,v 1.5 1995/06/26 04:08:06 cgd Exp $ */ +/* $OpenBSD: boca.c,v 1.4 1996/03/08 16:42:49 niklas Exp $ */ +/* $NetBSD: boca.c,v 1.6 1995/12/24 02:31:11 mycroft Exp $ */ /* * Copyright (c) 1995 Charles Hannum. All rights reserved. diff --git a/sys/dev/isa/bt.c b/sys/dev/isa/bt.c index ceccaee8a6b..6350eeb8a68 100644 --- a/sys/dev/isa/bt.c +++ b/sys/dev/isa/bt.c @@ -1,4 +1,5 @@ -/* $NetBSD: bt742a.c,v 1.49 1995/10/03 20:58:58 mycroft Exp $ */ +/* $OpenBSD: bt.c,v 1.4 1996/03/08 16:42:50 niklas Exp $ */ +/* $NetBSD: bt742a.c,v 1.50 1995/12/24 02:31:13 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. diff --git a/sys/dev/isa/bt742a.c b/sys/dev/isa/bt742a.c index ceccaee8a6b..20e66853db3 100644 --- a/sys/dev/isa/bt742a.c +++ b/sys/dev/isa/bt742a.c @@ -1,4 +1,5 @@ -/* $NetBSD: bt742a.c,v 1.49 1995/10/03 20:58:58 mycroft Exp $ */ +/* $OpenBSD: bt742a.c,v 1.4 1996/03/08 16:42:50 niklas Exp $ */ +/* $NetBSD: bt742a.c,v 1.50 1995/12/24 02:31:13 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. diff --git a/sys/dev/isa/com.c b/sys/dev/isa/com.c index 846d5f518f5..ffc8c7f1547 100644 --- a/sys/dev/isa/com.c +++ b/sys/dev/isa/com.c @@ -1,4 +1,5 @@ -/* $NetBSD: com.c,v 1.62 1995/10/15 19:43:04 mycroft Exp $ */ +/* $OpenBSD: com.c,v 1.7 1996/03/08 16:42:51 niklas Exp $ */ +/* $NetBSD: com.c,v 1.65 1996/02/10 20:23:18 christos Exp $ */ /*- * Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved. @@ -61,10 +62,12 @@ #include <dev/isa/isavar.h> #include <dev/isa/comreg.h> #include <dev/ic/ns16550reg.h> -#include <dev/ic/espreg.h> +#ifdef COM_HAYESP +#include <dev/ic/hayespreg.h> +#endif #define com_lcr com_cfcr -#define COM_IBUFSIZE (2 * 256) +#define COM_IBUFSIZE (2 * 512) #define COM_IHIGHWATER ((3 * COM_IBUFSIZE) / 4) struct com_softc { @@ -77,11 +80,13 @@ struct com_softc { int sc_errors; int sc_iobase; - int sc_espbase; +#ifdef COM_HAYESP + int sc_hayespbase; +#endif u_char sc_hwflags; #define COM_HW_NOIEN 0x01 #define COM_HW_FIFO 0x02 -#define COM_HW_ESP 0x04 +#define COM_HW_HAYESP 0x04 #define COM_HW_CONSOLE 0x40 u_char sc_swflags; #define COM_SW_SOFTCAR 0x01 @@ -226,64 +231,84 @@ comprobe1(iobase) return 1; } +#ifdef COM_HAYESP int -comprobe(parent, match, aux) - struct device *parent; - void *match, *aux; +comprobeHAYESP(iobase, sc) + int iobase; + struct com_softc *sc; { - struct isa_attach_args *ia = aux; - int iobase = ia->ia_iobase; + char val, dips; + int combaselist[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; - if (!comprobe1(iobase)) - return 0; + /* + * Hayes ESP cards have two iobases. One is for compatibility with + * 16550 serial chips, and at the same ISA PC base addresses. The + * other is for ESP-specific enhanced features, and lies at a + * different addressing range entirely (0x140, 0x180, 0x280, or 0x300). + */ - ia->ia_iosize = COM_NPORTS; - ia->ia_msize = 0; - return 1; -} + /* Test for ESP signature */ + if ((inb(iobase) & 0xf3) == 0) + return 0; -int -comprobeESP(esp_port, sc) - int esp_port; - struct com_softc *sc; -{ - char val, dips; - int com_base_list[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; + /* + * ESP is present at ESP enhanced base address; unknown com port + */ - /* Test for ESP signature at the ESP i/o port. */ - if ((inb(esp_port) & 0xf3) == 0) - return(0); + /* Get the dip-switch configurations */ + outb(iobase + HAYESP_CMD1, HAYESP_GETDIPS); + dips = inb(iobase + HAYESP_STATUS1); - /* Check compatibility mode settings */ - outb(esp_port + ESP_CMD1, ESP_GETDIPS); - dips = inb(esp_port + ESP_STATUS1); + /* Determine which com port this ESP card services: bits 0,1 of */ + /* dips is the port # (0-3); combaselist[val] is the com_iobase */ + if (sc->sc_iobase != combaselist[dips & 0x03]) + return 0; - /* Does this ESP board service this com port?: Bits 0,1 == COM0..3 */ - if (sc->sc_iobase != com_base_list[(dips & 0x03)]) { - return(0); - } printf(": ESP"); - /* Check ESP Self Test bits. */ + /* Check ESP Self Test bits. */ /* Check for ESP version 2.0: bits 4,5,6 == 010 */ - outb(esp_port + ESP_CMD1, ESP_GETTEST); - val = inb(esp_port + ESP_STATUS1); /* Always 0x00 */ - val = inb(esp_port + ESP_STATUS2); + outb(iobase + HAYESP_CMD1, HAYESP_GETTEST); + val = inb(iobase + HAYESP_STATUS1); /* Clear reg 1 */ + val = inb(iobase + HAYESP_STATUS2); if ((val & 0x70) < 0x20) { printf("-old (%o)", val & 0x70); - return(0); + /* we do not support the necessary features */ + return 0; } - /* Check for ability to emulate 16550: bit 7 set */ - if (ISSET(dips, 0x80) == 0) { + /* Check for ability to emulate 16550: bit 8 == 1 */ + if ((dips & 0x80) == 0) { printf(" slave"); - return(0); + /* XXX Does slave really mean no 16550 support?? */ + return 0; } - /* We're a full featured ESP card at the right com port. */ - SET(sc->sc_hwflags, COM_HW_ESP); - printf(", 1024 byte fifo\n"); - return(1); + /* + * If we made it this far, we are a full-featured ESP v2.0 (or + * better), at the correct com port address. + */ + + SET(sc->sc_hwflags, COM_HW_HAYESP); + printf(", 1024k fifo\n"); + return 1; +} +#endif + +int +comprobe(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct isa_attach_args *ia = aux; + int iobase = ia->ia_iobase; + + if (!comprobe1(iobase)) + return 0; + + ia->ia_iosize = COM_NPORTS; + ia->ia_msize = 0; + return 1; } void @@ -296,8 +321,10 @@ comattach(parent, self, aux) struct cfdata *cf = sc->sc_dev.dv_cfdata; int iobase = ia->ia_iobase; struct tty *tp; - int esp_ports[] = { 0x140, 0x180, 0x280, 0 }; - int *espp; +#ifdef COM_HAYESP + int hayesp_ports[] = { 0x140, 0x180, 0x280, 0x300, 0 }; + int *hayespp; +#endif sc->sc_iobase = iobase; sc->sc_hwflags = ISSET(cf->cf_flags, COM_HW_NOIEN); @@ -306,29 +333,33 @@ comattach(parent, self, aux) if (sc->sc_dev.dv_unit == comconsole) delay(1000); +#ifdef COM_HAYESP /* Look for a Hayes ESP board. */ - for (espp = esp_ports; *espp != 0; espp++) - if (comprobeESP(*espp, sc)) { - sc->sc_espbase = *espp; + for (hayespp = hayesp_ports; *hayespp != 0; hayespp++) + if (comprobeHAYESP(*hayespp, sc)) { + sc->sc_hayespbase = *hayespp; break; } /* No ESP; look for other things. */ - if (*espp == 0) { - /* look for a NS 16550AF UART with FIFOs */ - outb(iobase + com_fifo, - FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14); - delay(100); - if (ISSET(inb(iobase + com_iir), IIR_FIFO_MASK) == IIR_FIFO_MASK) - if (ISSET(inb(iobase + com_fifo), FIFO_TRIGGER_14) == - FIFO_TRIGGER_14) { - SET(sc->sc_hwflags, COM_HW_FIFO); - printf(": ns16550a, working fifo\n"); - } else - printf(": ns16550, broken fifo\n"); - else - printf(": ns8250 or ns16450, no fifo\n"); - outb(iobase + com_fifo, 0); + if (*hayespp == 0) { +#endif + + /* look for a NS 16550AF UART with FIFOs */ + outb(iobase + com_fifo, + FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14); + delay(100); + if (ISSET(inb(iobase + com_iir), IIR_FIFO_MASK) == IIR_FIFO_MASK) + if (ISSET(inb(iobase + com_fifo), FIFO_TRIGGER_14) == FIFO_TRIGGER_14) { + SET(sc->sc_hwflags, COM_HW_FIFO); + printf(": ns16550a, working fifo\n"); + } else + printf(": ns16550, broken fifo\n"); + else + printf(": ns8250 or ns16450, no fifo\n"); + outb(iobase + com_fifo, 0); +#ifdef COM_HAYESP } +#endif /* disable interrupts */ outb(iobase + com_ier, 0); @@ -424,32 +455,39 @@ comopen(dev, flag, mode, p) sc->sc_ibufend = sc->sc_ibuf + COM_IBUFSIZE; iobase = sc->sc_iobase; +#ifdef COM_HAYESP + /* Setup the ESP board */ + if (ISSET(sc->sc_hwflags, COM_HW_HAYESP)) { + int hayespbase = sc->sc_hayespbase; - /* Set up the ESP board */ - if (ISSET(sc->sc_hwflags, COM_HW_ESP)) { outb(iobase + com_fifo, - /* XXX - bug in ESP requires DMA flag set */ - FIFO_DMA_MODE | - FIFO_ENABLE | FIFO_RCV_RST | - FIFO_XMT_RST | FIFO_TRIGGER_8); + FIFO_DMA_MODE|FIFO_ENABLE| + FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_8); /* Set 16550 compatibility mode */ - outb(sc->sc_espbase + ESP_CMD1, ESP_SETMODE); - outb(sc->sc_espbase + ESP_CMD2, - ESP_MODE_FIFO | ESP_MODE_RTS | ESP_MODE_SCALE); + outb(hayespbase + HAYESP_CMD1, HAYESP_SETMODE); + outb(hayespbase + HAYESP_CMD2, + HAYESP_MODE_FIFO|HAYESP_MODE_RTS| + HAYESP_MODE_SCALE); /* Set RTS/CTS flow control */ - outb(sc->sc_espbase + ESP_CMD1, ESP_SETFLOWTYPE); - outb(sc->sc_espbase + ESP_CMD2, ESP_FLOW_RTS); - outb(sc->sc_espbase + ESP_CMD2, ESP_FLOW_CTS); + outb(hayespbase + HAYESP_CMD1, HAYESP_SETFLOWTYPE); + outb(hayespbase + HAYESP_CMD2, HAYESP_FLOW_RTS); + outb(hayespbase + HAYESP_CMD2, HAYESP_FLOW_CTS); /* Set flow control levels */ - outb(sc->sc_espbase + ESP_CMD1, ESP_SETRXFLOW); - outb(sc->sc_espbase + ESP_CMD2, HIBYTE(RXHIGHWATER)); - outb(sc->sc_espbase + ESP_CMD2, LOBYTE(RXHIGHWATER)); - outb(sc->sc_espbase + ESP_CMD2, HIBYTE(RXLOWWATER)); - outb(sc->sc_espbase + ESP_CMD2, LOBYTE(RXLOWWATER)); - } else if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) + outb(hayespbase + HAYESP_CMD1, HAYESP_SETRXFLOW); + outb(hayespbase + HAYESP_CMD2, + HAYESP_HIBYTE(HAYESP_RXHIWMARK)); + outb(hayespbase + HAYESP_CMD2, + HAYESP_LOBYTE(HAYESP_RXHIWMARK)); + outb(hayespbase + HAYESP_CMD2, + HAYESP_HIBYTE(HAYESP_RXLOWMARK)); + outb(hayespbase + HAYESP_CMD2, + HAYESP_LOBYTE(HAYESP_RXLOWMARK)); + } else +#endif + if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) /* Set the FIFO threshold based on the receive speed. */ outb(iobase + com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | @@ -829,13 +867,18 @@ comstart(tp) selwakeup(&tp->t_wsel); } SET(tp->t_state, TS_BUSY); - if (ISSET(sc->sc_hwflags, COM_HW_ESP)) { + +#ifdef COM_HAYESP + if (ISSET(sc->sc_hwflags, COM_HW_HAYESP)) { u_char buffer[1024], *cp = buffer; int n = q_to_b(&tp->t_outq, cp, sizeof buffer); - do { + do outb(iobase + com_data, *cp++); - } while (--n); - } else if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) { + while (--n); + } + else +#endif + if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) { u_char buffer[16], *cp = buffer; int n = q_to_b(&tp->t_outq, cp, sizeof buffer); do { diff --git a/sys/dev/isa/comreg.h b/sys/dev/isa/comreg.h index 96c92944e2b..1769ac9b679 100644 --- a/sys/dev/isa/comreg.h +++ b/sys/dev/isa/comreg.h @@ -1,4 +1,5 @@ -/* $NetBSD: comreg.h,v 1.7 1995/10/15 19:43:07 mycroft Exp $ */ +/* $OpenBSD: comreg.h,v 1.4 1996/03/08 16:42:52 niklas Exp $ */ +/* $NetBSD: comreg.h,v 1.8 1996/02/05 23:01:50 scottr Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -41,27 +42,27 @@ #define COM_TOLERANCE 30 /* baud rate tolerance, in 0.1% units */ /* interrupt enable register */ -#define IER_ERXRDY 0x1 /* Character received */ -#define IER_ETXRDY 0x2 /* Transmitter empty */ -#define IER_ERLS 0x4 /* Error condition */ -#define IER_EMSC 0x8 /* RS-232 line state change */ +#define IER_ERXRDY 0x1 /* Enable receiver interrupt */ +#define IER_ETXRDY 0x2 /* Enable transmitter empty interrupt */ +#define IER_ERLS 0x4 /* Enable line status interrupt */ +#define IER_EMSC 0x8 /* Enable modem status interrupt */ /* interrupt identification register */ #define IIR_IMASK 0xf #define IIR_RXTOUT 0xc -#define IIR_RLS 0x6 -#define IIR_RXRDY 0x4 -#define IIR_TXRDY 0x2 +#define IIR_RLS 0x6 /* Line status change */ +#define IIR_RXRDY 0x4 /* Receiver ready */ +#define IIR_TXRDY 0x2 /* Transmitter ready */ +#define IIR_MLSC 0x0 /* Modem status */ #define IIR_NOPEND 0x1 /* No pending interrupts */ -#define IIR_MLSC 0x0 #define IIR_FIFO_MASK 0xc0 /* set if FIFOs are enabled */ /* fifo control register */ #define FIFO_ENABLE 0x01 /* Turn the FIFO on */ #define FIFO_RCV_RST 0x02 /* Reset RX FIFO */ #define FIFO_XMT_RST 0x04 /* Reset TX FIFO */ -#define FIFO_DMA_MODE 0x08 /* DMA mode? */ -#define FIFO_TRIGGER_1 0x00 /* Trigger RXRDY Interrupt on 1 character */ +#define FIFO_DMA_MODE 0x08 +#define FIFO_TRIGGER_1 0x00 /* Trigger RXRDY intr on 1 character */ #define FIFO_TRIGGER_4 0x40 /* ibid 4 */ #define FIFO_TRIGGER_8 0x80 /* ibid 8 */ #define FIFO_TRIGGER_14 0xc0 /* ibid 14 */ @@ -83,9 +84,9 @@ /* modem control register */ #define MCR_LOOPBACK 0x10 /* Loop test: echos from TX to RX */ -#define MCR_IENABLE 0x08 /* Output 2: enables UART interrupts */ -#define MCR_DRS 0x04 /* Output 1: resets some internal modems */ -#define MCR_RTS 0x02 /* RTS: ready to receive data */ +#define MCR_IENABLE 0x08 /* Out2: enables UART interrupts */ +#define MCR_DRS 0x04 /* Out1: resets some internal modems */ +#define MCR_RTS 0x02 /* Request To Send */ #define MCR_DTR 0x01 /* Data Terminal Ready */ /* line status register */ diff --git a/sys/dev/isa/cs4231var.h b/sys/dev/isa/cs4231var.h index 02a901b987b..9ae2b516d61 100644 --- a/sys/dev/isa/cs4231var.h +++ b/sys/dev/isa/cs4231var.h @@ -1,31 +1,40 @@ -/* $NetBSD: cs4231var.h,v 1.1 1995/07/07 02:11:57 brezak Exp $ */ -/* - * Copyright (c) 1995 John T. Kohl - * All rights reserved. +/* $OpenBSD: cs4231var.h,v 1.2 1996/03/08 16:42:53 niklas Exp $ */ +/* $NetBSD: cs4231var.h,v 1.2 1996/02/05 02:21:51 jtc Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * This code is derived from software contributed to The NetBSD Foundation + * by Ken Hornstein and John Kohl. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `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 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. + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 REGENTS 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. */ /* diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c index 231d61e7dcc..bdf18af3edf 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,8 +1,12 @@ -/* $NetBSD: gus.c,v 1.3 1995/11/10 04:30:44 mycroft Exp $ */ +/* $OpenBSD: gus.c,v 1.5 1996/03/08 16:42:54 niklas Exp $ */ +/* $NetBSD: gus.c,v 1.7 1996/02/16 08:18:37 mycroft Exp $ */ -/* - * Copyright (c) 1994, 1995 Ken Hornstein. All rights reserved. - * Copyright (c) 1995 John T. Kohl. All rights reserved. +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Ken Hornstein and John Kohl. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -14,20 +18,23 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Ken Hornstein. - * 4. The name of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 REGENTS 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. */ /* @@ -336,8 +343,6 @@ int dmarecord_index = 0; int gusopen __P((dev_t, int)); void gusclose __P((void *)); void gusmax_close __P((void *)); -int gusprobe ()/*__P((struct device *, struct device *, void *))*/; -void gusattach __P((struct device *, struct device *, void *)); int gusintr __P((void *)); int gus_set_in_gain __P((caddr_t, u_int, u_char)); int gus_get_in_gain __P((caddr_t)); @@ -444,6 +449,9 @@ static void gusics_cd_mute __P((struct ics2101_softc *, int)); * ISA bus driver routines */ +int gusprobe __P((struct device *, void *, void *)); +void gusattach __P((struct device *, struct device *, void *)); + struct cfdriver guscd = { NULL, "gus", gusprobe, gusattach, DV_DULL, sizeof(struct gus_softc) }; @@ -653,11 +661,11 @@ struct audio_device gus_device = { int -gusprobe(parent, self, aux) +gusprobe(parent, match, aux) struct device *parent, *self; - void *aux; + void *match, *aux; { - register struct gus_softc *sc = (void *) self; + register struct gus_softc *sc = match; register struct isa_attach_args *ia = aux; struct cfdata *cf = sc->sc_dev.dv_cfdata; register int iobase = ia->ia_iobase; diff --git a/sys/dev/isa/gusreg.h b/sys/dev/isa/gusreg.h index de9ab296cca..975ba6ec74e 100644 --- a/sys/dev/isa/gusreg.h +++ b/sys/dev/isa/gusreg.h @@ -1,11 +1,12 @@ -/* $NetBSD: gusreg.h,v 1.1 1995/07/19 19:58:47 brezak Exp $ */ +/* $OpenBSD: gusreg.h,v 1.2 1996/03/08 16:42:56 niklas Exp $ */ +/* $NetBSD: gusreg.h,v 1.3 1996/02/05 02:22:10 jtc Exp $ */ + /*- - * Copyright (c) 1995 John T. Kohl. All Rights Reserved. - * Copyright (c) 1994 The Regents of the University of California. + * Copyright (c) 1996 The NetBSD Foundation, Inc. * All rights reserved. * - * This code is derived from software contributed to Berkeley by - * Ken Hornstein. + * This code is derived from software contributed to The NetBSD Foundation + * by Ken Hornstein and John Kohl. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -17,25 +18,23 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * $Id: gusreg.h,v 1.1 1995/10/18 08:52:34 deraadt Exp $ + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 REGENTS 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. */ /* diff --git a/sys/dev/isa/ics2101.c b/sys/dev/isa/ics2101.c index c27f05eeaa5..97bd6f97502 100644 --- a/sys/dev/isa/ics2101.c +++ b/sys/dev/isa/ics2101.c @@ -1,11 +1,12 @@ -/* $NetBSD: ics2101.c,v 1.1 1995/07/19 19:58:49 brezak Exp $ */ +/* $OpenBSD: ics2101.c,v 1.2 1996/03/08 16:42:57 niklas Exp $ */ +/* $NetBSD: ics2101.c,v 1.3 1996/02/05 02:22:11 jtc Exp $ */ + /*- - * Copyright (c) 1995 John T. Kohl. All Rights Reserved. - * Copyright (c) 1994 The Regents of the University of California. + * Copyright (c) 1996 The NetBSD Foundation, Inc. * All rights reserved. * - * This code is derived from software contributed to Berkeley by - * Ken Hornstein. + * This code is derived from software contributed to The NetBSD Foundation + * by Ken Hornstein and John Kohl. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -17,25 +18,23 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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: ics2101.c,v 1.1 1995/10/18 08:52:34 deraadt Exp $ + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 REGENTS 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. */ #include <sys/param.h> diff --git a/sys/dev/isa/ics2101var.h b/sys/dev/isa/ics2101var.h index 53d1ea1b658..b9a61a63758 100644 --- a/sys/dev/isa/ics2101var.h +++ b/sys/dev/isa/ics2101var.h @@ -1,7 +1,12 @@ -/* $NetBSD: ics2101var.h,v 1.1 1995/07/19 19:58:50 brezak Exp $ */ -/* - * Copyright (c) 1994, 1995 Ken Hornstein. All rights reserved. - * Copyright (c) 1995 John T. Kohl. All rights reserved. +/* $OpenBSD: ics2101var.h,v 1.2 1996/03/08 16:42:58 niklas Exp $ */ +/* $NetBSD: ics2101var.h,v 1.3 1996/02/05 02:22:12 jtc Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Ken Hornstein and John Kohl. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -13,22 +18,23 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Ken Hornstein. - * 4. The name of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * $Id: ics2101var.h,v 1.1 1995/10/18 08:52:34 deraadt Exp $ + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 REGENTS 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. */ #define ICSMIX_LEFT 0 /* Value for left channel */ diff --git a/sys/dev/isa/if_ed.c b/sys/dev/isa/if_ed.c index 72898d40edd..8871d539682 100644 --- a/sys/dev/isa/if_ed.c +++ b/sys/dev/isa/if_ed.c @@ -1,4 +1,5 @@ -/* $NetBSD: if_ed.c,v 1.85 1995/07/25 05:11:11 mycroft Exp $ */ +/* $OpenBSD: if_ed.c,v 1.6 1996/03/08 16:42:59 niklas Exp $ */ +/* $NetBSD: if_ed.c,v 1.87 1996/01/10 16:49:25 chuck Exp $ */ /* * Device driver for National Semiconductor DS8390/WD83C690 based ethernet @@ -58,6 +59,7 @@ #include <dev/isa/isareg.h> #include <dev/isa/isavar.h> #include <i386/isa/isa_machdep.h> /* XXX USES ISA HOLE DIRECTLY */ +#define ED_BYTE_ORDER LITTLE_ENDIAN #include <dev/ic/dp8390reg.h> #include <dev/isa/if_edreg.h> diff --git a/sys/dev/isa/if_edreg.h b/sys/dev/isa/if_edreg.h index 9a2bd122b58..044143188dd 100644 --- a/sys/dev/isa/if_edreg.h +++ b/sys/dev/isa/if_edreg.h @@ -1,4 +1,5 @@ -/* $NetBSD: if_edreg.h,v 1.14 1995/04/11 04:46:22 mycroft Exp $ */ +/* $OpenBSD: if_edreg.h,v 1.3 1996/03/08 16:43:00 niklas Exp $ */ +/* $NetBSD: if_edreg.h,v 1.15 1996/01/10 16:49:22 chuck Exp $ */ /* * National Semiconductor DS8390 NIC register definitions. diff --git a/sys/dev/isa/if_el.c b/sys/dev/isa/if_el.c index b7313b4785b..2fdb2855939 100644 --- a/sys/dev/isa/if_el.c +++ b/sys/dev/isa/if_el.c @@ -1,4 +1,5 @@ -/* $NetBSD: if_el.c,v 1.33 1995/08/05 23:53:18 mycroft Exp $ */ +/* $OpenBSD: if_el.c,v 1.4 1996/03/08 16:43:01 niklas Exp $ */ +/* $NetBSD: if_el.c,v 1.34 1995/12/24 02:31:25 mycroft Exp $ */ /* * Copyright (c) 1994, Matthew E. Kimmel. Permission is hereby granted diff --git a/sys/dev/isa/if_ep.c b/sys/dev/isa/if_ep.c index 3748e4f0d18..10c04236591 100644 --- a/sys/dev/isa/if_ep.c +++ b/sys/dev/isa/if_ep.c @@ -1,4 +1,5 @@ -/* $NetBSD: if_ep.c,v 1.85 1995/12/05 03:30:15 christos Exp $ */ +/* $OpenBSD: if_ep.c,v 1.7 1996/03/08 16:43:02 niklas Exp $ */ +/* $NetBSD: if_ep.c,v 1.86 1995/12/24 02:31:27 mycroft Exp $ */ /* * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> @@ -477,9 +478,8 @@ epconfig(sc, conn) */ for (i = 0; i < 3; i++) { u_short x; - if (epbusyeeprom(sc)) { + if (epbusyeeprom(sc)) return; - } outw(BASE + EP_W0_EEPROM_COMMAND, READ_EEPROM | i); if (epbusyeeprom(sc)) return; diff --git a/sys/dev/isa/if_hp.c b/sys/dev/isa/if_hp.c index aeebb013df3..96cf87fe405 100644 --- a/sys/dev/isa/if_hp.c +++ b/sys/dev/isa/if_hp.c @@ -1,4 +1,5 @@ -/* $NetBSD: if_hp.c,v 1.20 1995/04/17 12:09:01 cgd Exp $ */ +/* $OpenBSD: if_hp.c,v 1.3 1996/03/08 16:43:03 niklas Exp $ */ +/* $NetBSD: if_hp.c,v 1.21 1995/12/24 02:31:31 mycroft Exp $ */ /* XXX THIS DRIVER IS BROKEN. IT WILL NOT EVEN COMPILE. */ diff --git a/sys/dev/isa/if_ie.c b/sys/dev/isa/if_ie.c index fde8d97b909..204051bd2f8 100644 --- a/sys/dev/isa/if_ie.c +++ b/sys/dev/isa/if_ie.c @@ -1,4 +1,5 @@ -/* $NetBSD: if_ie.c,v 1.44 1995/09/26 13:24:48 hpeyerl Exp $ */ +/* $OpenBSD: if_ie.c,v 1.4 1996/03/08 16:43:04 niklas Exp $ */ +/* $NetBSD: if_ie.c,v 1.45 1995/12/24 02:31:33 mycroft Exp $ */ /*- * Copyright (c) 1993, 1994, 1995 Charles Hannum. diff --git a/sys/dev/isa/if_le.c b/sys/dev/isa/if_le.c index 3e5ca0ef005..529ee9acd58 100644 --- a/sys/dev/isa/if_le.c +++ b/sys/dev/isa/if_le.c @@ -1,4 +1,5 @@ -/* $NetBSD: if_le.c,v 1.37 1995/11/25 01:24:00 cgd Exp $ */ +/* $OpenBSD: if_le.c,v 1.5 1996/03/08 16:43:05 niklas Exp $ */ +/* $NetBSD: if_le.c,v 1.38 1995/12/24 02:31:35 mycroft Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. diff --git a/sys/dev/isa/isa.c b/sys/dev/isa/isa.c index 9dbe1d5cb1f..d0398b52591 100644 --- a/sys/dev/isa/isa.c +++ b/sys/dev/isa/isa.c @@ -1,5 +1,5 @@ -/* $OpenBSD: isa.c,v 1.3 1996/02/27 10:31:32 niklas Exp $ */ -/* $NetBSD: isa.c,v 1.74 1995/06/07 06:46:04 cgd Exp $ */ +/* $OpenBSD: isa.c,v 1.4 1996/03/08 16:43:06 niklas Exp $ */ +/* $NetBSD: isa.c,v 1.76 1996/01/16 07:52:38 mycroft Exp $ */ /*- * Copyright (c) 1993, 1994 Charles Hannum. All rights reserved. @@ -72,7 +72,7 @@ isascan(parent, match) struct isa_attach_args ia; if (cf->cf_fstate == FSTATE_STAR) - panic("not bloody likely"); + panic("clone devices not supported on ISA bus"); ia.ia_iobase = cf->cf_loc[0]; ia.ia_iosize = 0x666; diff --git a/sys/dev/isa/isavar.h b/sys/dev/isa/isavar.h index 77649082241..ab8036c8066 100644 --- a/sys/dev/isa/isavar.h +++ b/sys/dev/isa/isavar.h @@ -1,4 +1,5 @@ -/* $NetBSD: isavar.h,v 1.16 1995/06/07 06:45:44 cgd Exp $ */ +/* $OpenBSD: isavar.h,v 1.4 1996/03/08 16:43:07 niklas Exp $ */ +/* $NetBSD: isavar.h,v 1.17 1995/12/24 02:31:38 mycroft Exp $ */ /* * Copyright (c) 1995 Chris G. Demetriou diff --git a/sys/dev/isa/lpt.c b/sys/dev/isa/lpt.c index 4809dbf470c..fe7edf4ab96 100644 --- a/sys/dev/isa/lpt.c +++ b/sys/dev/isa/lpt.c @@ -1,4 +1,5 @@ -/* $NetBSD: lpt.c,v 1.30 1995/04/17 12:09:17 cgd Exp $ */ +/* $OpenBSD: lpt.c,v 1.5 1996/03/08 16:43:08 niklas Exp $ */ +/* $NetBSD: lpt.c,v 1.31 1995/12/24 02:31:40 mycroft Exp $ */ /* * Copyright (c) 1993, 1994 Charles Hannum. diff --git a/sys/dev/isa/mcd.c b/sys/dev/isa/mcd.c index ebec3cfd4aa..6cfb6958f17 100644 --- a/sys/dev/isa/mcd.c +++ b/sys/dev/isa/mcd.c @@ -1,4 +1,5 @@ -/* $NetBSD: mcd.c,v 1.44 1996/01/07 22:03:37 thorpej Exp $ */ +/* $OpenBSD: mcd.c,v 1.6 1996/03/08 16:43:09 niklas Exp $ */ +/* $NetBSD: mcd.c,v 1.45 1996/01/30 18:28:05 thorpej Exp $ */ /* * Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved. @@ -617,12 +618,16 @@ mcdioctl(dev, cmd, addr, flag, p) return EINVAL; case CDIOCSTOP: return mcd_stop(sc); - case CDIOCEJECT: + case CDIOCEJECT: /* FALLTHROUGH */ + case DIOCEJECT: return mcd_eject(sc); case CDIOCALLOW: return mcd_setlock(sc, MCD_LK_UNLOCK); case CDIOCPREVENT: return mcd_setlock(sc, MCD_LK_LOCK); + case DIOCLOCK: + return mcd_setlock(sc, + (*(int *)addr) ? MCD_LK_LOCK : MCD_LK_UNLOCK); case CDIOCSETDEBUG: sc->debug = 1; return 0; diff --git a/sys/dev/isa/pas.c b/sys/dev/isa/pas.c index 389bab91fb6..34181d47442 100644 --- a/sys/dev/isa/pas.c +++ b/sys/dev/isa/pas.c @@ -1,4 +1,5 @@ -/* $NetBSD: pas.c,v 1.10 1995/11/10 05:05:18 mycroft Exp $ */ +/* $OpenBSD: pas.c,v 1.5 1996/03/08 16:43:10 niklas Exp $ */ +/* $NetBSD: pas.c,v 1.12 1996/02/16 08:18:34 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -100,10 +101,6 @@ struct pas_softc { }; int pasopen __P((dev_t, int)); - -int pasprobe(); -void pasattach(); - int pas_getdev __P((void *, struct audio_device *)); @@ -250,6 +247,9 @@ pasconf(int model, int sbbase, int sbirq, int sbdrq) paswrite(P_M_MV508_INPUTMIX | 30, PARALLEL_MIXER); } +int pasprobe __P((struct device *, void *, void *)); +void pasattach __P((struct device *, struct device *, void *)); + struct cfdriver pascd = { NULL, "pas", pasprobe, pasattach, DV_DULL, sizeof(struct pas_softc) }; @@ -262,11 +262,11 @@ struct cfdriver pascd = { * Probe for the soundblaster hardware. */ int -pasprobe(parent, self, aux) - struct device *parent, *self; - void *aux; +pasprobe(parent, match, aux) + struct device *parent; + void *match, *aux; { - register struct pas_softc *sc = (void *)self; + register struct pas_softc *sc = match; register struct isa_attach_args *ia = aux; register int iobase; u_char id, t; diff --git a/sys/dev/isa/pss.c b/sys/dev/isa/pss.c index cd8eb338b36..88c6a68246c 100644 --- a/sys/dev/isa/pss.c +++ b/sys/dev/isa/pss.c @@ -1,4 +1,5 @@ -/* $NetBSD: pss.c,v 1.10 1995/11/10 04:30:49 mycroft Exp $ */ +/* $OpenBSD: pss.c,v 1.5 1996/03/08 16:43:11 niklas Exp $ */ +/* $NetBSD: pss.c,v 1.11 1995/12/24 02:31:45 mycroft Exp $ */ /* * Copyright (c) 1994 John Brezak diff --git a/sys/dev/isa/rtfps.c b/sys/dev/isa/rtfps.c index 311f04ccfeb..90a49c7e8be 100644 --- a/sys/dev/isa/rtfps.c +++ b/sys/dev/isa/rtfps.c @@ -1,4 +1,5 @@ -/* $NetBSD: rtfps.c,v 1.13 1995/06/26 04:12:01 cgd Exp $ */ +/* $OpenBSD: rtfps.c,v 1.4 1996/03/08 16:43:12 niklas Exp $ */ +/* $NetBSD: rtfps.c,v 1.14 1995/12/24 02:31:48 mycroft Exp $ */ /* * Copyright (c) 1995 Charles Hannum. All rights reserved. diff --git a/sys/dev/isa/sb.c b/sys/dev/isa/sb.c index 561066e70a1..53636ba7f57 100644 --- a/sys/dev/isa/sb.c +++ b/sys/dev/isa/sb.c @@ -1,4 +1,5 @@ -/* $NetBSD: sb.c,v 1.28 1995/11/10 05:01:05 mycroft Exp $ */ +/* $OpenBSD: sb.c,v 1.5 1996/03/08 16:43:13 niklas Exp $ */ +/* $NetBSD: sb.c,v 1.30 1996/02/16 08:18:32 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -71,7 +72,7 @@ struct sb_softc { struct sbdsp_softc sc_sbdsp; }; -int sbprobe(); +int sbprobe __P((struct device *, void *, void *)); void sbattach __P((struct device *, struct device *, void *)); struct cfdriver sbcd = { @@ -85,10 +86,6 @@ struct audio_device sb_device = { }; int sbopen __P((dev_t, int)); - -int sbprobe(); -void sbattach(); - int sb_getdev __P((void *, struct audio_device *)); /* @@ -143,11 +140,11 @@ struct audio_hw_if sb_hw_if = { * Probe for the soundblaster hardware. */ int -sbprobe(parent, self, aux) - struct device *parent, *self; - void *aux; +sbprobe(parent, match, aux) + struct device *parent; + void *match, *aux; { - register struct sbdsp_softc *sc = (void *)self; + register struct sbdsp_softc *sc = match; register struct isa_attach_args *ia = aux; register int iobase = ia->ia_iobase; static u_char drq_conf[4] = { diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c index da55f376015..fb87ad28aa9 100644 --- a/sys/dev/isa/sbdsp.c +++ b/sys/dev/isa/sbdsp.c @@ -1,4 +1,5 @@ -/* $NetBSD: sbdsp.c,v 1.14 1995/11/10 05:01:06 mycroft Exp $ */ +/* $OpenBSD: sbdsp.c,v 1.3 1996/03/08 16:43:14 niklas Exp $ */ +/* $NetBSD: sbdsp.c,v 1.16 1996/02/16 10:10:21 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -81,23 +82,57 @@ struct { int wmidi; } sberr; +/* + * Time constant routines follow. See SBK, section 12. + * Although they don't come out and say it (in the docs), + * the card clearly uses a 1MHz countdown timer, as the + * low-speed formula (p. 12-4) is: + * tc = 256 - 10^6 / sr + * In high-speed mode, the constant is the upper byte of a 16-bit counter, + * and a 256MHz clock is used: + * tc = 65536 - 256 * 10^ 6 / sr + * Since we can only use the upper byte of the HS TC, the two formulae + * are equivalent. (Why didn't they say so?) E.g., + * (65536 - 256 * 10 ^ 6 / x) >> 8 = 256 - 10^6 / x + * + * The crossover point (from low- to high-speed modes) is different + * for the SBPRO and SB20. The table on p. 12-5 gives the following data: + * + * SBPRO SB20 + * ----- -------- + * input ls min 4 KHz 4 KHz + * input ls max 23 KHz 13 KHz + * input hs max 44.1 KHz 15 KHz + * output ls min 4 KHz 4 KHz + * output ls max 23 KHz 23 KHz + * output hs max 44.1 KHz 44.1 KHz + */ +#define SB_LS_MIN 0x06 /* 4000 Hz */ +#define SB_8K 0x83 /* 8000 Hz */ +#define SBPRO_ADC_LS_MAX 0xd4 /* 22727 Hz */ +#define SBPRO_ADC_HS_MAX 0xea /* 45454 Hz */ +#define SBCLA_ADC_LS_MAX 0xb3 /* 12987 Hz */ +#define SBCLA_ADC_HS_MAX 0xbd /* 14925 Hz */ +#define SB_DAC_LS_MAX 0xd4 /* 22727 Hz */ +#define SB_DAC_HS_MAX 0xea /* 45454 Hz */ + #ifdef AUDIO_DEBUG void sb_printsc(struct sbdsp_softc *sc) { int i; - printf("open %d dmachan %d iobase %x locked %d\n", sc->sc_open, sc->sc_drq, - sc->sc_iobase, sc->sc_locked); - printf("hispeed %d irate %d orate %d encoding %x\n", - sc->sc_adacmode, sc->sc_irate, sc->sc_orate, sc->encoding); + printf("open %d dmachan %d iobase %x\n", + sc->sc_open, sc->sc_drq, sc->sc_iobase); + printf("itc %d imode %d otc %d omode %d encoding %x\n", + sc->sc_itc, sc->sc_imode, sc->sc_otc, sc->sc_omode, sc->encoding); printf("outport %d inport %d spkron %d nintr %d\n", - sc->out_port, sc->in_port, sc->spkr_state, sc->sc_interrupts); - printf("tc %x chans %x scintr %x arg %x\n", sc->sc_adactc, sc->sc_chans, - sc->sc_intr, sc->sc_arg); + sc->out_port, sc->in_port, sc->spkr_state, sc->sc_interrupts); + printf("chans %x intr %x arg %x\n", + sc->sc_chans, sc->sc_intr, sc->sc_arg); printf("gain: "); for (i = 0; i < SB_NDEVS; i++) - printf("%d ", sc->gain[i]); + printf("%d ", sc->gain[i]); printf("\n"); } #endif @@ -134,19 +169,14 @@ sbdsp_attach(sc) { register int iobase = sc->sc_iobase; - sc->sc_locked = 0; - /* Set defaults */ if (ISSBPROCLASS(sc)) - sc->sc_irate = sc->sc_orate = 45454; + sc->sc_itc = sc->sc_otc = SBPRO_ADC_HS_MAX; else - sc->sc_irate = sc->sc_orate = 14925; + sc->sc_itc = sc->sc_otc = SBCLA_ADC_HS_MAX; sc->sc_chans = 1; sc->encoding = AUDIO_ENCODING_LINEAR; - (void) sbdsp_set_in_sr_real(sc, sc->sc_irate); - (void) sbdsp_set_out_sr_real(sc, sc->sc_orate); - (void) sbdsp_set_in_port(sc, SB_MIC_PORT); (void) sbdsp_set_out_port(sc, SB_SPEAKER); @@ -166,8 +196,9 @@ sbdsp_attach(sc) sbdsp_mix_write(sc, SBP_LINE_VOL, sbdsp_stereo_vol(SBP_MAXVOL, SBP_MAXVOL)); for (i = 0; i < SB_NDEVS; i++) - sc->gain[i] = sbdsp_stereo_vol(SBP_MAXVOL, SBP_MAXVOL); + sc->gain[i] = sbdsp_stereo_vol(SBP_MAXVOL, SBP_MAXVOL); } + printf(": dsp v%d.%02d\n", SBVER_MAJOR(sc->sc_model), SBVER_MINOR(sc->sc_model)); } @@ -207,25 +238,7 @@ sbdsp_set_in_sr(addr, sr) { register struct sbdsp_softc *sc = addr; - sc->sc_irate = sr; - - return 0; -} - -int -sbdsp_set_in_sr_real(addr, sr) - void *addr; - u_long sr; -{ - register struct sbdsp_softc *sc = addr; - int rval; - - if (rval = sbdsp_set_sr(sc, &sr, SB_INPUT_RATE)) - return rval; - sc->sc_irate = sr; - sc->sc_dmain_inprogress = 0; /* do it again on next DMA out */ - sc->sc_dmaout_inprogress = 0; - return(0); + return (sbdsp_srtotc(sc, sr, SB_INPUT_RATE, &sc->sc_itc, &sc->sc_imode)); } u_long @@ -234,7 +247,7 @@ sbdsp_get_in_sr(addr) { register struct sbdsp_softc *sc = addr; - return(sc->sc_irate); + return (sbdsp_tctosr(sc, sc->sc_itc)); } int @@ -244,23 +257,7 @@ sbdsp_set_out_sr(addr, sr) { register struct sbdsp_softc *sc = addr; - sc->sc_orate = sr; - return(0); -} - -int -sbdsp_set_out_sr_real(addr, sr) - void *addr; - u_long sr; -{ - register struct sbdsp_softc *sc = addr; - int rval; - - if (rval = sbdsp_set_sr(sc, &sr, SB_OUTPUT_RATE)) - return rval; - sc->sc_orate = sr; - sc->sc_dmain_inprogress = 0; /* do it again on next DMA out */ - return(0); + return (sbdsp_srtotc(sc, sr, SB_OUTPUT_RATE, &sc->sc_otc, &sc->sc_omode)); } u_long @@ -269,30 +266,29 @@ sbdsp_get_out_sr(addr) { register struct sbdsp_softc *sc = addr; - return(sc->sc_orate); + return (sbdsp_tctosr(sc, sc->sc_otc)); } int sbdsp_query_encoding(addr, fp) - void *addr; - struct audio_encoding *fp; + void *addr; + struct audio_encoding *fp; { - register struct sbdsp_softc *sc = addr; + register struct sbdsp_softc *sc = addr; - switch (fp->index) { - case 0: - strcpy(fp->name, AudioEmulaw); - fp->format_id = AUDIO_ENCODING_ULAW; - break; - case 1: - strcpy(fp->name, AudioEpcm16); - fp->format_id = AUDIO_ENCODING_PCM16; - break; - default: - return(EINVAL); - /*NOTREACHED*/ - } - return (0); + switch (fp->index) { + case 0: + strcpy(fp->name, AudioEmulaw); + fp->format_id = AUDIO_ENCODING_ULAW; + break; + case 1: + strcpy(fp->name, AudioEpcm16); + fp->format_id = AUDIO_ENCODING_PCM16; + break; + default: + return (EINVAL); + } + return (0); } int @@ -321,7 +317,7 @@ sbdsp_get_encoding(addr) { register struct sbdsp_softc *sc = addr; - return(sc->encoding); + return (sc->encoding); } int @@ -331,15 +327,15 @@ sbdsp_set_precision(addr, prec) { if (prec != 8) - return(EINVAL); - return(0); + return (EINVAL); + return (0); } int sbdsp_get_precision(addr) void *addr; { - return(8); + return (8); } int @@ -348,29 +344,30 @@ sbdsp_set_channels(addr, chans) int chans; { register struct sbdsp_softc *sc = addr; - int rval; if (ISSBPROCLASS(sc)) { if (chans != 1 && chans != 2) - return(EINVAL); - + return (EINVAL); sc->sc_chans = chans; + +#if 0 if (rval = sbdsp_set_in_sr_real(addr, sc->sc_irate)) - return rval; + return rval; +#endif + sbdsp_mix_write(sc, SBP_STEREO, (sbdsp_mix_read(sc, SBP_STEREO) & ~SBP_PLAYMODE_MASK) | (chans == 2 ? SBP_PLAYMODE_STEREO : SBP_PLAYMODE_MONO)); /* recording channels needs to be done right when we start DMA recording. Just record number of channels for now and set stereo when ready. */ - } - else { + } else { if (chans != 1) - return(EINVAL); - sc->sc_chans = 1; + return (EINVAL); + sc->sc_chans = chans; } - return(0); + return (0); } int @@ -382,19 +379,15 @@ sbdsp_get_channels(addr) #if 0 /* recording stereo may frob the mixer output */ if (ISSBPROCLASS(sc)) { - if ((sbdsp_mix_read(sc, SBP_STEREO) & SBP_PLAYMODE_MASK) == SBP_PLAYMODE_STEREO) { + if ((sbdsp_mix_read(sc, SBP_STEREO) & SBP_PLAYMODE_MASK) == SBP_PLAYMODE_STEREO) sc->sc_chans = 2; - } - else { + else sc->sc_chans = 1; - } - } - else { + } else sc->sc_chans = 1; - } #endif - return(sc->sc_chans); + return (sc->sc_chans); } int @@ -406,7 +399,7 @@ sbdsp_set_out_port(addr, port) sc->out_port = port; /* Just record it */ - return(0); + return (0); } int @@ -415,7 +408,7 @@ sbdsp_get_out_port(addr) { register struct sbdsp_softc *sc = addr; - return(sc->out_port); + return (sc->out_port); } @@ -428,36 +421,33 @@ sbdsp_set_in_port(addr, port) int mixport, sbport; if (ISSBPROCLASS(sc)) { - switch (port) { - case SB_MIC_PORT: - sbport = SBP_FROM_MIC; - mixport = SBP_MIC_VOL; - break; - case SB_LINE_IN_PORT: - sbport = SBP_FROM_LINE; - mixport = SBP_LINE_VOL; - break; - case SB_CD_PORT: - sbport = SBP_FROM_CD; - mixport = SBP_CD_VOL; - break; - case SB_DAC_PORT: - case SB_FM_PORT: - default: - return(EINVAL); - /*NOTREACHED*/ - } - } - else { - switch (port) { - case SB_MIC_PORT: - sbport = SBP_FROM_MIC; - mixport = SBP_MIC_VOL; - break; - default: - return(EINVAL); - /*NOTREACHED*/ - } + switch (port) { + case SB_MIC_PORT: + sbport = SBP_FROM_MIC; + mixport = SBP_MIC_VOL; + break; + case SB_LINE_IN_PORT: + sbport = SBP_FROM_LINE; + mixport = SBP_LINE_VOL; + break; + case SB_CD_PORT: + sbport = SBP_FROM_CD; + mixport = SBP_CD_VOL; + break; + case SB_DAC_PORT: + case SB_FM_PORT: + default: + return (EINVAL); + } + } else { + switch (port) { + case SB_MIC_PORT: + sbport = SBP_FROM_MIC; + mixport = SBP_MIC_VOL; + break; + default: + return (EINVAL); + } } sc->in_port = port; /* Just record it */ @@ -471,7 +461,7 @@ sbdsp_set_in_port(addr, port) sc->gain[port] = sbdsp_mix_read(sc, mixport); } - return(0); + return (0); } int @@ -480,7 +470,7 @@ sbdsp_get_in_port(addr) { register struct sbdsp_softc *sc = addr; - return(sc->in_port); + return (sc->in_port); } @@ -511,36 +501,39 @@ sbdsp_round_blocksize(addr, blk) { register struct sbdsp_softc *sc = addr; - sc->sc_last_hsr_size = sc->sc_last_hsw_size = 0; + sc->sc_last_hs_size = 0; /* Higher speeds need bigger blocks to avoid popping and silence gaps. */ - if ((sc->sc_orate > 8000 || sc->sc_irate > 8000) && + if ((sc->sc_otc > SB_8K || sc->sc_itc > SB_8K) && (blk > NBPG/2 || blk < NBPG/4)) blk = NBPG/2; /* don't try to DMA too much at once, though. */ - if (blk > NBPG) blk = NBPG; + if (blk > NBPG) + blk = NBPG; if (sc->sc_chans == 2) return (blk & ~1); /* must be even to preserve stereo separation */ else - return(blk); /* Anything goes :-) */ + return (blk); /* Anything goes :-) */ } int sbdsp_commit_settings(addr) void *addr; { + register struct sbdsp_softc *sc = addr; + /* due to potentially unfortunate ordering in the above layers, re-do a few sets which may be important--input gains (adjust the proper channels), number of input channels (hit the record rate and set mode) */ - register struct sbdsp_softc *sc = addr; - - sbdsp_set_out_sr_real(addr, sc->sc_orate); - sbdsp_set_in_sr_real(addr, sc->sc_irate); + /* + * XXX + * Should wait for chip to be idle. + */ + sc->sc_dmadir = SB_DMA_NONE; - sc->sc_last_hsw_size = sc->sc_last_hsr_size = 0; - return(0); + return 0; } @@ -557,16 +550,11 @@ sbdsp_open(sc, dev, flags) sc->sc_open = 1; sc->sc_mintr = 0; - sc->sc_intr = 0; - sc->sc_arg = 0; - sc->sc_locked = 0; if (ISSBPROCLASS(sc) && sbdsp_wdsp(sc->sc_iobase, SB_DSP_RECORD_MONO) < 0) { DPRINTF(("sbdsp_open: can't set mono mode\n")); /* we'll readjust when it's time for DMA. */ } - sc->sc_dmain_inprogress = 0; - sc->sc_dmaout_inprogress = 0; /* * Leave most things as they were; users must change things if @@ -590,10 +578,8 @@ sbdsp_close(addr) sc->sc_open = 0; sbdsp_spkroff(sc); sc->spkr_state = SPKR_OFF; - sc->sc_intr = 0; sc->sc_mintr = 0; - /* XXX this will turn off any dma */ - sbdsp_reset(sc); + sbdsp_haltdma(sc); DPRINTF(("sbdsp_close: closed\n")); } @@ -612,20 +598,25 @@ sbdsp_reset(sc) { register int iobase = sc->sc_iobase; - /* - * erase any memory of last transfer size. - */ - sc->sc_last_hsr_size = sc->sc_last_hsw_size = 0; + sc->sc_intr = 0; + if (sc->sc_dmadir != SB_DMA_NONE) { + isa_dmaabort(sc->sc_drq); + sc->sc_dmadir = SB_DMA_NONE; + } + sc->sc_last_hs_size = 0; + /* * See SBK, section 11.3. * We pulse a reset signal into the card. * Gee, what a brilliant hardware design. */ outb(iobase + SBP_DSP_RESET, 1); - delay(3); + delay(10); outb(iobase + SBP_DSP_RESET, 0); + delay(30); if (sbdsp_rdsp(iobase) != SB_MAGIC) return -1; + return 0; } @@ -640,10 +631,13 @@ sbdsp_wdsp(int iobase, int v) register int i; for (i = SBDSP_NPOLL; --i >= 0; ) { - if ((inb(iobase + SBP_DSP_WSTAT) & SB_DSP_BUSY) != 0) { - delay(10); continue; - } + register u_char x; + x = inb(iobase + SBP_DSP_WSTAT); + delay(10); + if ((x & SB_DSP_BUSY) != 0) + continue; outb(iobase + SBP_DSP_WRITE, v); + delay(10); return 0; } ++sberr.wdsp; @@ -659,9 +653,14 @@ sbdsp_rdsp(int iobase) register int i; for (i = SBDSP_NPOLL; --i >= 0; ) { - if ((inb(iobase + SBP_DSP_RSTAT) & SB_DSP_READY) == 0) + register u_char x; + x = inb(iobase + SBP_DSP_RSTAT); + delay(10); + if ((x & SB_DSP_READY) == 0) continue; - return inb(iobase + SBP_DSP_READ); + x = inb(iobase + SBP_DSP_READ); + delay(10); + return x; } ++sberr.rdsp; return -1; @@ -747,18 +746,8 @@ sbdsp_haltdma(addr) DPRINTF(("sbdsp_haltdma: sc=0x%x\n", sc)); - if (sc->sc_locked) - sbdsp_reset(sc); - else - (void)sbdsp_wdsp(sc->sc_iobase, SB_DSP_HALT); - - isa_dmaabort(sc->sc_drq); - sc->dmaaddr = 0; - sc->dmacnt = 0; - sc->sc_locked = 0; - sc->dmaflags = 0; - sc->sc_dmain_inprogress = sc->sc_dmaout_inprogress = 0; - return(0); + sbdsp_reset(sc); + return 0; } int @@ -775,39 +764,6 @@ sbdsp_contdma(addr) } /* - * Time constant routines follow. See SBK, section 12. - * Although they don't come out and say it (in the docs), - * the card clearly uses a 1MHz countdown timer, as the - * low-speed formula (p. 12-4) is: - * tc = 256 - 10^6 / sr - * In high-speed mode, the constant is the upper byte of a 16-bit counter, - * and a 256MHz clock is used: - * tc = 65536 - 256 * 10^ 6 / sr - * Since we can only use the upper byte of the HS TC, the two formulae - * are equivalent. (Why didn't they say so?) E.g., - * (65536 - 256 * 10 ^ 6 / x) >> 8 = 256 - 10^6 / x - * - * The crossover point (from low- to high-speed modes) is different - * for the SBPRO and SB20. The table on p. 12-5 gives the following data: - * - * SBPRO SB20 - * ----- -------- - * input ls min 4 KHz 4 KHz - * input ls max 23 KHz 13 KHz - * input hs max 44.1 KHz 15 KHz - * output ls min 4 KHz 4 KHz - * output ls max 23 KHz 23 KHz - * output hs max 44.1 KHz 44.1 KHz - */ -#define SB_LS_MIN 0x06 /* 4000 Hz */ -#define SBPRO_ADC_LS_MAX 0xd4 /* 22727 Hz */ -#define SBPRO_ADC_HS_MAX 0xea /* 45454 Hz */ -#define SBCLA_ADC_LS_MAX 0xb3 /* 12987 Hz */ -#define SBCLA_ADC_HS_MAX 0xbd /* 14925 Hz */ -#define SB_DAC_LS_MAX 0xd4 /* 22727 Hz */ -#define SB_DAC_HS_MAX 0xea /* 45454 Hz */ - -/* * Convert a linear sampling rate into the DAC time constant. * Set *mode to indicate the high/low-speed DMA operation. * Because of limitations of the card, not all rates are possible. @@ -816,53 +772,60 @@ sbdsp_contdma(addr) * so isdac indicates output, and !isdac indicates input. */ int -sbdsp_srtotc(sc, sr, mode, isdac) +sbdsp_srtotc(sc, sr, isdac, tcp, modep) register struct sbdsp_softc *sc; int sr; - int *mode; int isdac; + int *tcp, *modep; { - int adc_ls_max, adc_hs_max; - register int tc; + int tc, mode; if (sr == 0) { - *mode = SB_ADAC_LS; - return SB_LS_MIN; + tc = SB_LS_MIN; + mode = SB_ADAC_LS; + goto out; } - tc = 256 - 1000000 / sr; + + tc = 256 - (1000000 / sr); - /* XXX use better rounding--compare distance to nearest tc on both - sides of requested speed */ - if (ISSBPROCLASS(sc)) { - adc_ls_max = SBPRO_ADC_LS_MAX; - adc_hs_max = SBPRO_ADC_HS_MAX; - } - else { - adc_ls_max = SBCLA_ADC_LS_MAX; - adc_hs_max = SBCLA_ADC_HS_MAX; - } - if (tc < SB_LS_MIN) { tc = SB_LS_MIN; - *mode = SB_ADAC_LS; + mode = SB_ADAC_LS; + goto out; } else if (isdac) { if (tc <= SB_DAC_LS_MAX) - *mode = SB_ADAC_LS; + mode = SB_ADAC_LS; else { - *mode = SB_ADAC_HS; + mode = SB_ADAC_HS; if (tc > SB_DAC_HS_MAX) tc = SB_DAC_HS_MAX; } } else { + int adc_ls_max, adc_hs_max; + + /* XXX use better rounding--compare distance to nearest tc on both + sides of requested speed */ + if (ISSBPROCLASS(sc)) { + adc_ls_max = SBPRO_ADC_LS_MAX; + adc_hs_max = SBPRO_ADC_HS_MAX; + } else { + adc_ls_max = SBCLA_ADC_LS_MAX; + adc_hs_max = SBCLA_ADC_HS_MAX; + } + if (tc <= adc_ls_max) - *mode = SB_ADAC_LS; + mode = SB_ADAC_LS; else { - *mode = SB_ADAC_HS; + mode = SB_ADAC_HS; if (tc > adc_hs_max) tc = adc_hs_max; } } - return tc; + +out: + *tcp = tc; + *modep = mode; + return (0); } /* @@ -888,47 +851,27 @@ sbdsp_tctosr(sc, tc) } int -sbdsp_set_sr(sc, srp, isdac) +sbdsp_set_tc(sc, tc) register struct sbdsp_softc *sc; - u_long *srp; - int isdac; + int tc; { - register int tc; - int mode; - int sr = *srp; register int iobase; /* * A SBPro in stereo mode uses time constants at double the * actual rate. */ - if (ISSBPRO(sc) && sc->sc_chans == 2) { - if (sr > 22727) - sr = 22727; /* Can't bounce it...order of - operations may yield bogus - sr here. */ - sr *= 2; - } - else if (!ISSBPROCLASS(sc) && sc->sc_chans != 1) - return EINVAL; + if (ISSBPRO(sc) && sc->sc_chans == 2) + tc = 256 - ((256 - tc) / 2); - tc = sbdsp_srtotc(sc, sr, &mode, isdac); - DPRINTF(("sbdsp_set_sr: sc=0x%x sr=%d mode=0x%x\n", sc, sr, mode)); + DPRINTF(("sbdsp_set_tc: sc=%p tc=%d\n", sc, tc)); iobase = sc->sc_iobase; if (sbdsp_wdsp(iobase, SB_DSP_TIMECONST) < 0 || sbdsp_wdsp(iobase, tc) < 0) - return EIO; + return (EIO); - sr = sbdsp_tctosr(sc, tc); - if (ISSBPRO(sc) && sc->sc_chans == 2) - *srp = sr / 2; - else - *srp = sr; - - sc->sc_adacmode = mode; - sc->sc_adactc = tc; - return 0; + return (0); } int @@ -950,30 +893,27 @@ sbdsp_dma_input(addr, p, cc, intr, arg) DPRINTF(("sbdsp_dma_input: stereo input, odd bytecnt\n")); return EIO; } + iobase = sc->sc_iobase; - if (ISSBPROCLASS(sc) && !sc->sc_dmain_inprogress) { - if (sc->sc_chans == 2) { - if (sbdsp_wdsp(iobase, SB_DSP_RECORD_STEREO) < 0) - goto badmode; - sbdsp_mix_write(sc, SBP_STEREO, - sbdsp_mix_read(sc, SBP_STEREO) & ~SBP_PLAYMODE_MASK); - sbdsp_mix_write(sc, SBP_INFILTER, - sbdsp_mix_read(sc, SBP_INFILTER) | SBP_FILTER_OFF); - } - else { - if (sbdsp_wdsp(iobase, SB_DSP_RECORD_MONO) < 0) - goto badmode; - sbdsp_mix_write(sc, SBP_STEREO, - sbdsp_mix_read(sc, SBP_STEREO) & ~SBP_PLAYMODE_MASK); - sbdsp_mix_write(sc, SBP_INFILTER, - sc->sc_irate <= 8000 ? - sbdsp_mix_read(sc, SBP_INFILTER) & ~SBP_FILTER_MASK : - sbdsp_mix_read(sc, SBP_INFILTER) | SBP_FILTER_OFF); + if (sc->sc_dmadir != SB_DMA_IN) { + if (ISSBPROCLASS(sc)) { + if (sc->sc_chans == 2) { + if (sbdsp_wdsp(iobase, SB_DSP_RECORD_STEREO) < 0) + goto badmode; + sbdsp_mix_write(sc, SBP_INFILTER, + sbdsp_mix_read(sc, SBP_INFILTER) | SBP_FILTER_OFF); + } else { + if (sbdsp_wdsp(iobase, SB_DSP_RECORD_MONO) < 0) + goto badmode; + sbdsp_mix_write(sc, SBP_INFILTER, sc->sc_itc > SB_8K ? + sbdsp_mix_read(sc, SBP_INFILTER) | SBP_FILTER_OFF : + sbdsp_mix_read(sc, SBP_INFILTER) & ~SBP_FILTER_MASK); + } } - sc->sc_dmain_inprogress = 1; - sc->sc_last_hsr_size = 0; /* restarting */ + + sbdsp_set_tc(sc, sc->sc_itc); + sc->sc_dmadir = SB_DMA_IN; } - sc->sc_dmaout_inprogress = 0; isa_dmastart(B_READ, p, cc, sc->sc_drq); sc->sc_intr = intr; @@ -981,33 +921,36 @@ sbdsp_dma_input(addr, p, cc, intr, arg) sc->dmaflags = B_READ; sc->dmaaddr = p; sc->dmacnt = --cc; /* DMA controller is strange...? */ - if (sc->sc_adacmode == SB_ADAC_LS) { + + if (sc->sc_imode == SB_ADAC_LS) { if (sbdsp_wdsp(iobase, SB_DSP_RDMA) < 0 || sbdsp_wdsp(iobase, cc) < 0 || sbdsp_wdsp(iobase, cc >> 8) < 0) { + DPRINTF(("sbdsp_dma_input: LS DMA start failed\n")); goto giveup; } } else { - if (cc != sc->sc_last_hsr_size) { + if (cc != sc->sc_last_hs_size) { if (sbdsp_wdsp(iobase, SB_DSP_BLOCKSIZE) < 0 || sbdsp_wdsp(iobase, cc) < 0 || - sbdsp_wdsp(iobase, cc >> 8) < 0) + sbdsp_wdsp(iobase, cc >> 8) < 0) { + DPRINTF(("sbdsp_dma_input: HS DMA start failed\n")); goto giveup; + } + sc->sc_last_hs_size = cc; } - if (sbdsp_wdsp(iobase, SB_DSP_HS_INPUT) < 0) + if (sbdsp_wdsp(iobase, SB_DSP_HS_INPUT) < 0) { + DPRINTF(("sbdsp_dma_input: HS DMA restart failed\n")); goto giveup; - sc->sc_last_hsr_size = cc; - sc->sc_locked = 1; + } } return 0; giveup: - isa_dmaabort(sc->sc_drq); sbdsp_reset(sc); - sc->sc_intr = 0; - sc->sc_arg = 0; return EIO; + badmode: DPRINTF(("sbdsp_dma_input: can't set %s mode\n", sc->sc_chans == 2 ? "stereo" : "mono")); @@ -1029,22 +972,25 @@ sbdsp_dma_output(addr, p, cc, intr, arg) if (sbdspdebug > 1) Dprintf("sbdsp_dma_output: cc=%d 0x%x (0x%x)\n", cc, intr, arg); #endif - if (sc->sc_chans == 2 && cc & 1) { + if (sc->sc_chans == 2 && (cc & 1)) { DPRINTF(("stereo playback odd bytes (%d)\n", cc)); return EIO; } - if (ISSBPROCLASS(sc) && !sc->sc_dmaout_inprogress) { - /* make sure we re-set stereo mixer bit when we start - output. */ - sbdsp_mix_write(sc, SBP_STEREO, - (sbdsp_mix_read(sc, SBP_STEREO) & ~SBP_PLAYMODE_MASK) | - (sc->sc_chans == 2 ? - SBP_PLAYMODE_STEREO : SBP_PLAYMODE_MONO)); - sc->sc_dmaout_inprogress = 1; - sc->sc_last_hsw_size = 0; /* restarting */ + iobase = sc->sc_iobase; + if (sc->sc_dmadir != SB_DMA_OUT) { + if (ISSBPROCLASS(sc)) { + /* make sure we re-set stereo mixer bit when we start + output. */ + sbdsp_mix_write(sc, SBP_STEREO, + (sbdsp_mix_read(sc, SBP_STEREO) & ~SBP_PLAYMODE_MASK) | + (sc->sc_chans == 2 ? SBP_PLAYMODE_STEREO : SBP_PLAYMODE_MONO)); + } + + sbdsp_set_tc(sc, sc->sc_otc); + sc->sc_dmadir = SB_DMA_OUT; } - sc->sc_dmain_inprogress = 0; + isa_dmastart(B_WRITE, p, cc, sc->sc_drq); sc->sc_intr = intr; sc->sc_arg = arg; @@ -1052,8 +998,7 @@ sbdsp_dma_output(addr, p, cc, intr, arg) sc->dmaaddr = p; sc->dmacnt = --cc; /* a vagary of how DMA works, apparently. */ - iobase = sc->sc_iobase; - if (sc->sc_adacmode == SB_ADAC_LS) { + if (sc->sc_omode == SB_ADAC_LS) { if (sbdsp_wdsp(iobase, SB_DSP_WDMA) < 0 || sbdsp_wdsp(iobase, cc) < 0 || sbdsp_wdsp(iobase, cc >> 8) < 0) { @@ -1062,39 +1007,24 @@ sbdsp_dma_output(addr, p, cc, intr, arg) } } else { - if (cc != sc->sc_last_hsw_size) { - if (sbdsp_wdsp(iobase, SB_DSP_BLOCKSIZE) < 0) { - /* sometimes fails initial startup?? */ - delay(100); - if (sbdsp_wdsp(iobase, SB_DSP_BLOCKSIZE) < 0) { - DPRINTF(("sbdsp_dma_output: BLOCKSIZE failed\n")); - goto giveup; - } - } - if (sbdsp_wdsp(iobase, cc) < 0 || + if (cc != sc->sc_last_hs_size) { + if (sbdsp_wdsp(iobase, SB_DSP_BLOCKSIZE) < 0 || + sbdsp_wdsp(iobase, cc) < 0 || sbdsp_wdsp(iobase, cc >> 8) < 0) { DPRINTF(("sbdsp_dma_output: HS DMA start failed\n")); goto giveup; } - sc->sc_last_hsw_size = cc; + sc->sc_last_hs_size = cc; } if (sbdsp_wdsp(iobase, SB_DSP_HS_OUTPUT) < 0) { - delay(100); - if (sbdsp_wdsp(iobase, SB_DSP_HS_OUTPUT) < 0) { - DPRINTF(("sbdsp_dma_output: HS DMA restart failed\n")); - goto giveup; - } + DPRINTF(("sbdsp_dma_output: HS DMA restart failed\n")); + goto giveup; } - sc->sc_locked = 1; } - return 0; - giveup: - isa_dmaabort(sc->sc_drq); +giveup: sbdsp_reset(sc); - sc->sc_intr = 0; - sc->sc_arg = 0; return EIO; } @@ -1110,36 +1040,40 @@ sbdsp_intr(arg) void *arg; { register struct sbdsp_softc *sc = arg; + u_char x; #ifdef AUDIO_DEBUG if (sbdspdebug > 1) Dprintf("sbdsp_intr: intr=0x%x\n", sc->sc_intr); #endif sc->sc_interrupts++; - sc->sc_locked = 0; /* clear interrupt */ - inb(sc->sc_iobase + SBP_DSP_RSTAT); + x = inb(sc->sc_iobase + SBP_DSP_RSTAT); + delay(10); +#if 0 + if ((x & SB_DSP_READY) == 0) { + printf("sbdsp_intr: still busy\n"); + return 0; + } +#endif #if 0 if (sc->sc_mintr != 0) { - int c = sbdsp_rdsp(sc->sc_iobase); - (*sc->sc_mintr)(sc->sc_arg, c); + x = sbdsp_rdsp(sc->sc_iobase); + (*sc->sc_mintr)(sc->sc_arg, x); } else #endif if (sc->sc_intr != 0) { - /* - * The SBPro used to develop and test this driver often - * generated dma underruns--it interrupted to signal - * completion of the DMA input recording block, but the - * ISA DMA controller didn't think the channel was - * finished. Maybe this is just a bus speed issue, I dunno, - * but it seems strange and leads to channel-flipping with stereo - * recording. Sigh. - */ + /* + * The SBPro used to develop and test this driver often + * generated dma underruns--it interrupted to signal + * completion of the DMA input recording block, but the + * ISA DMA controller didn't think the channel was + * finished. Maybe this is just a bus speed issue, I dunno, + * but it seems strange and leads to channel-flipping with + * stereo recording. Sigh. + */ isa_dmadone(sc->dmaflags, sc->dmaaddr, sc->dmacnt, sc->sc_drq); - sc->dmaflags = 0; - sc->dmaaddr = 0; - sc->dmacnt = 0; (*sc->sc_intr)(sc->sc_arg); } else diff --git a/sys/dev/isa/sbdspvar.h b/sys/dev/isa/sbdspvar.h index 6b07bbc5522..326103454c9 100644 --- a/sys/dev/isa/sbdspvar.h +++ b/sys/dev/isa/sbdspvar.h @@ -1,4 +1,5 @@ -/* $NetBSD: sbdspvar.h,v 1.7 1995/11/10 05:01:08 mycroft Exp $ */ +/* $OpenBSD: sbdspvar.h,v 1.3 1996/03/08 16:43:15 niklas Exp $ */ +/* $NetBSD: sbdspvar.h,v 1.9 1996/02/16 10:10:23 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -80,11 +81,6 @@ struct sbdsp_softc { int sc_drq; /* DMA */ u_short sc_open; /* reference count of open calls */ - u_short sc_locked; /* true when doing HS DMA */ - u_short sc_adacmode; /* low/high speed mode indicator */ - - u_long sc_irate; /* Sample rate for input */ - u_long sc_orate; /* ...and output */ u_int gain[SB_NDEVS]; /* kept in SB levels: right/left each in a nibble */ @@ -96,9 +92,14 @@ struct sbdsp_softc { u_int spkr_state; /* non-null is on */ + int sc_itc; /* Sample rate for input */ + int sc_otc; /* ...and output */ + + int sc_imode; + int sc_omode; #define SB_ADAC_LS 0 #define SB_ADAC_HS 1 - u_short sc_adactc; /* current adac time constant */ + u_long sc_interrupts; /* number of interrupts taken */ void (*sc_intr)(void*); /* dma completion intr handler */ void (*sc_mintr)(void*, int);/* midi input intr handler */ @@ -107,11 +108,12 @@ struct sbdsp_softc { int dmaflags; caddr_t dmaaddr; vm_size_t dmacnt; - int sc_last_hsw_size; /* last HS dma size */ - int sc_last_hsr_size; /* last HS dma size */ + int sc_last_hs_size; /* last HS dma size */ int sc_chans; /* # of channels */ - char sc_dmain_inprogress; /* DMA input in progress? */ - char sc_dmaout_inprogress; /* DMA output in progress? */ + int sc_dmadir; /* DMA direction */ +#define SB_DMA_NONE 0 +#define SB_DMA_IN 1 +#define SB_DMA_OUT 2 u_int sc_model; /* DSP model */ #define SBVER_MAJOR(v) ((v)>>8) diff --git a/sys/dev/isa/ultra14f.c b/sys/dev/isa/ultra14f.c index 74b2d644f8a..ac40be426ba 100644 --- a/sys/dev/isa/ultra14f.c +++ b/sys/dev/isa/ultra14f.c @@ -1,4 +1,5 @@ -/* $NetBSD: ultra14f.c,v 1.60 1995/12/26 17:16:55 mycroft Exp $ */ +/* $OpenBSD: ultra14f.c,v 1.9 1996/03/08 16:43:16 niklas Exp $ */ +/* $NetBSD: ultra14f.c,v 1.61 1996/02/09 17:38:09 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. @@ -917,15 +918,15 @@ u14_find(uha, ia) if (ia->ia_iobase == IOBASEUNK) return ENXIO; - model = htons(inw(iobase + U14_ID)); + model = inb(iobase + U14_ID) | (inb(iobase + U14_ID + 1) << 8); if ((model & 0xfff0) != 0x5640) return ENXIO; - config = htons(inw(iobase + U14_CONFIG)); + config = inb(iobase + U14_CONFIG) | (inb(iobase + U14_CONFIG + 1) << 8); switch (model & 0x000f) { case 0x0001: - /* This is a 34f, and doens't need an ISA DMA channel. */ + /* This is a 34f, and doesn't need an ISA DMA channel. */ uha->sc_drq = DRQUNK; break; default: @@ -1362,10 +1363,10 @@ uha_print_mscp(mscp) { printf("mscp:%x op:%x cmdlen:%d senlen:%d\n", - mscp, mscp->opcode, mscp->cdblen, mscp->senselen); + mscp, mscp->opcode, mscp->scsi_cmd_length, mscp->req_sense_length); printf(" sg:%d sgnum:%x datlen:%d hstat:%x tstat:%x flags:%x\n", - mscp->sgth, mscp->sg_num, mscp->datalen, mscp->host_stat, - mscp->target_stat, mscp->flags); + mscp->sgth, mscp->sg_num, mscp->datalen, mscp->host_stat, + mscp->target_stat, mscp->flags); show_scsi_cmd(mscp->xs); } diff --git a/sys/dev/isa/wss.c b/sys/dev/isa/wss.c index 3a277fcc3eb..ad432c23384 100644 --- a/sys/dev/isa/wss.c +++ b/sys/dev/isa/wss.c @@ -1,4 +1,5 @@ -/* $NetBSD: wss.c,v 1.7 1995/11/10 04:30:52 mycroft Exp $ */ +/* $OpenBSD: wss.c,v 1.5 1996/03/08 16:43:17 niklas Exp $ */ +/* $NetBSD: wss.c,v 1.9 1996/02/16 08:18:36 mycroft Exp $ */ /* * Copyright (c) 1994 John Brezak @@ -101,10 +102,7 @@ struct audio_device wss_device = { "WSS" }; -int wssprobe(); -void wssattach(); int wssopen __P((dev_t, int)); - int wss_getdev __P((void *, struct audio_device *)); int wss_setfd __P((void *, int)); @@ -164,6 +162,9 @@ struct audio_hw_if wss_hw_if = { #define at_dma(flags, ptr, cc, chan) isa_dmastart(flags, ptr, cc, chan) #endif +int wssprobe __P((struct device *, void *, void *)); +void wssattach __P((struct device *, struct device *, void *)); + struct cfdriver wsscd = { NULL, "wss", wssprobe, wssattach, DV_DULL, sizeof(struct wss_softc) }; @@ -172,11 +173,11 @@ struct cfdriver wsscd = { * Probe for the Microsoft Sound System hardware. */ int -wssprobe(parent, self, aux) - struct device *parent, *self; - void *aux; +wssprobe(parent, match, aux) + struct device *parent; + void *match, *aux; { - register struct wss_softc *sc = (void *)self; + register struct wss_softc *sc = match; register struct isa_attach_args *ia = aux; register int iobase = ia->ia_iobase; static u_char interrupt_bits[12] = { |