Subject: kern/3859: ProAudio Spectrum driver broken in -current
To: None <gnats-bugs@gnats.netbsd.org>
From: John F. Woods <jfw@jfwhome.funhouse.com>
List: netbsd-bugs
Date: 07/13/1997 12:15:57
>Number:         3859
>Category:       kern
>Synopsis:       ProAudio Spectrum driver not converted to bus-space mechanism
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 13 09:20:02 1997
>Last-Modified:
>Originator:     John F. Woods
>Organization:
Misanthropes-R-Us
>Release:        1.2G Fri Jul 11 1997
>Environment:
	
System: NetBSD jfwhome.funhouse.com 1.2G NetBSD 1.2G (JFW) #22: Sun Jul 13 11:58:09 EDT 1997 jfw@jfwhome.funhouse.com:/usr/src/sys/arch/i386/compile/JFW i386


>Description:
	The ProAudio Spectrum sound card fails to probe with NetBSD-current.
	The problem is that the PAS driver has not been modified to use the
	bus-space mechanism, but depends on the SoundBlaster common code which
	has been modified to use it (and depends on proper setup thereof).
>How-To-Repeat:
	Plug it in.  Configure it.  Boot it.  It don' work.
>Fix:
	The following changes set up the bus-space configuration structures
	for the sound-blaster emulation of the PAS.  It retains the 386/ISA
	restriction for the initial PAS configuration (as well as the inability
	to has the PAS at other than the default address).  Because this is
	a dead line, it is probably not worthwhile making the code fully
	generic, but it would at least be nice to support the existing PAS
	users (all two of us, I think).

*** pas.c.orig	Sun Jul 13 11:11:12 1997
--- pas.c	Sun Jul 13 11:57:43 1997
***************
*** 34,39 ****
--- 34,46 ----
   *
   */
  /*
+  * jfw 7/13/97 - The soundblaster code requires the generic bus-space 
+  * structures to be set up properly.  Rather than go to the effort of making
+  * code for a dead line fully generic, properly set up the SB structures and
+  * leave the rest x86/ISA/default-configuration specific.  If you have a
+  * REAL computer, go buy a REAL sound card.
+  */
+ /*
   * Todo:
   * 	- look at other PAS drivers (for PAS native suport)
   * 	- use common sb.c once emulation is setup
***************
*** 258,263 ****
--- 265,276 ----
  	register int iobase;
  	u_char id, t;
  
+         /* ensure we can set this up as a sound blaster */
+        	if (!SB_BASE_VALID(ia->ia_iobase)) {
+ 		printf("pas: configured SB iobase 0x%x invalid\n", ia->ia_iobase);
+ 		return 0;
+ 	}
+ 
  	/*
  	 * WARNING: Setting an option like W:1 or so that disables
  	 * warm boot reset of the card will screw up this detect code
***************
*** 329,340 ****
                  return (0);
          }
  
! 	/* Now a SoundBlaster */
  	sc->sc_sbdsp.sc_iobase = ia->ia_iobase;
  	sc->sc_sbdsp.sc_iot = ia->ia_iot;
  	if (sbdsp_reset(&sc->sc_sbdsp) < 0) {
  		DPRINTF(("pas: couldn't reset card\n"));
! 		return 0;
  	}
  
  	/*
--- 342,365 ----
                  return (0);
          }
  
! 	/* Now a SoundBlaster, so set up proper bus-space hooks
!          * appropriately
!          */
! 
  	sc->sc_sbdsp.sc_iobase = ia->ia_iobase;
  	sc->sc_sbdsp.sc_iot = ia->ia_iot;
+ 
+ 	/* Map i/o space [we map 24 ports which is the max of the sb and pro */
+ 	if (bus_space_map(sc->sc_sbdsp.sc_iot, ia->ia_iobase, SBP_NPORT, 0,
+ 	    &sc->sc_sbdsp.sc_ioh)) {
+ 		printf("pas: can't map i/o space 0x%x/%d in probe\n",
+ 		    ia->ia_iobase, SBP_NPORT);
+ 		return 0;
+ 	}
+ 
  	if (sbdsp_reset(&sc->sc_sbdsp) < 0) {
  		DPRINTF(("pas: couldn't reset card\n"));
! 		goto unmap;
  	}
  
  	/*
***************
*** 342,348 ****
  	 */
  	if (!SB_DRQ_VALID(ia->ia_drq)) {
  		printf("pas: configured dma chan %d invalid\n", ia->ia_drq);
! 		return 0;
  	}
  #ifdef NEWCONFIG
  	/*
--- 367,373 ----
  	 */
  	if (!SB_DRQ_VALID(ia->ia_drq)) {
  		printf("pas: configured dma chan %d invalid\n", ia->ia_drq);
! 		goto unmap;
  	}
  #ifdef NEWCONFIG
  	/*
***************
*** 353,365 ****
  		sbdsp_reset(&sc->sc_sbdsp);
  		if (!SB_IRQ_VALID(ia->ia_irq)) {
  			printf("pas: couldn't auto-detect interrupt");
! 			return 0;
  		}
  	} else
  #endif
  	if (!SB_IRQ_VALID(ia->ia_irq)) {
  		printf("pas: configured irq chan %d invalid\n", ia->ia_irq);
! 		return 0;
  	}
  
  	sc->sc_sbdsp.sc_irq = ia->ia_irq;
--- 378,390 ----
  		sbdsp_reset(&sc->sc_sbdsp);
  		if (!SB_IRQ_VALID(ia->ia_irq)) {
  			printf("pas: couldn't auto-detect interrupt");
! 			goto unmap;
  		}
  	} else
  #endif
  	if (!SB_IRQ_VALID(ia->ia_irq)) {
  		printf("pas: configured irq chan %d invalid\n", ia->ia_irq);
! 		goto unmap;
  	}
  
  	sc->sc_sbdsp.sc_irq = ia->ia_irq;
***************
*** 368,378 ****
  	
  	if (sbdsp_probe(&sc->sc_sbdsp) == 0) {
  		DPRINTF(("pas: sbdsp probe failed\n"));
! 		return 0;
  	}
  
  	ia->ia_iosize = SB_NPORT;
  	return 1;
  }
  
  #ifdef NEWCONFIG
--- 393,407 ----
  	
  	if (sbdsp_probe(&sc->sc_sbdsp) == 0) {
  		DPRINTF(("pas: sbdsp probe failed\n"));
! 		goto unmap;
  	}
  
  	ia->ia_iosize = SB_NPORT;
  	return 1;
+ 
+  unmap:
+ 	bus_space_unmap(sc->sc_sbdsp.sc_iot, sc->sc_sbdsp.sc_ioh, SBP_NPORT);
+ 	return 0;
  }
  
  #ifdef NEWCONFIG

>Audit-Trail:
>Unformatted: