Subject: Re: ProAudio Spectrum broken in -current?
To: John F. Woods <jfw@jfwhome.funhouse.com>
From: John F. Woods <jfw@jfwhome.funhouse.com>
List: current-users
Date: 07/13/1997 12:19:48
> I'll see if I can get something working quickly...

For the other users (user?) of the PAS, the following diffs make it work.
It still uses inb() and outb() (to fixed addresses) to configure the PAS
as a SoundBlaster, but at least it works everywhere it worked in 1.2 now.
(i.e. a 386)

I have sent this in with send-pr; if someone knows of a PCI ProAudio Spectrum
(or some other reason why making this driver fully correct is worthwhile),
then it can be modified further to be a proper citizen...

*** 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