Subject: patch for eap.c
To: None <port-i386@netbsd.org>
From: Masahiro =Rhythm Drive= Ishiyama <masahiro@isl.rdc.toshiba.co.jp>
List: port-i386
Date: 03/03/2000 01:28:17
	I bought a "Creative Soundblaster PCI Digital" card. It is
	recognized as Ensoniq AudioPCI, but it did not work.

NetBSD 1.4.1 (MJOLLNIR+KAME) #0: Mon Feb 28 13:45:39 JST 2000
    masahiro@mjollnir.isl.rdc.toshiba.co.jp:/am/mjollnir/usr1/kame/kame-20000214-netbsd141-stable/kame/netbsd/sys/arch/i386/compile/MJOLLNIR+KAME
cpu0: family 6 model 6 step 5
cpu0: Intel Pentium II (Celeron) (686-class)
[snip]
eap0 at pci0 dev 9 function 0: Ensoniq AudioPCI 97 (rev. 0x07)
eap0: interrupting at irq 5
eap: timeout writing to codec
eap: timeout writing to codec
de0 at pci0 dev 11 function 0
...

	I took a look at FreeBSD's code, and I found a hack there.
	I imported it to current eap.c, and my card works fine.
	Here is a patch: 

*** /vol/NetBSD/NetBSD-current/src/sys/dev/pci/eap.c	Wed Nov  3 19:24:36 1999
--- eap.c	Mon Feb 28 13:52:50 2000
***************
*** 734,742 ****
  	char devinfo[256];
  	mixer_ctrl_t ctl;
  	int i;
  
  	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
! 	printf(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class));
  
          /* Flag if we're "creative" */
  	sc->sc_1371 = PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ENSONIQ_AUDIOPCI97;
--- 734,743 ----
  	char devinfo[256];
  	mixer_ctrl_t ctl;
  	int i;
+ 	int revision;
  
  	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
! 	printf(": %s (rev. 0x%02x)\n", devinfo, (revision = PCI_REVISION(pa->pa_class)));
  
          /* Flag if we're "creative" */
  	sc->sc_1371 = PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ENSONIQ_AUDIOPCI97;
***************
*** 815,821 ****
  		eap_hw_if->set_port(sc, &ctl);
  	} else {
                  /* clean slate */
!                 EWRITE4(sc, EAP_SIC, 0);
                  EWRITE4(sc, EAP_ICSC, 0);
                  EWRITE4(sc, E1371_LEGACY, 0);
  
--- 816,829 ----
  		eap_hw_if->set_port(sc, &ctl);
  	} else {
                  /* clean slate */
! 
! #define ES1371_BINTSUMM_OFF 0x07
! 	        if ((revision == 7) || (revision >= 9)) {
! 		     EWRITE4(sc, ES1371_BINTSUMM_OFF, 0x20);
! 		} else {
! 		     EWRITE4(sc, EAP_SIC, 0);
! 		}
! 
                  EWRITE4(sc, EAP_ICSC, 0);
                  EWRITE4(sc, E1371_LEGACY, 0);
  
	I'd be very happy if someone who are using an ES1371-based card
	try this patch and confirm that there are no bad side effects.

	BTW, I couldn't find this product on americas.creative.com, so
	it may be sold only in Japan. But I believe this is a "PCI
	128", because an English manual in the CD-ROM is for "PCI 128". 

	And I wonder what sound card is a good choice for NetBSD/i386.

	Thanks in advance.

  --------------------------------------------------------------------------
    When you hear the music, after over it, | Masahiro Ishiyama
    it's gone into the air.                 | Communication Platform
    You can never capture it again.         | Laboratory, R&D Center, 
                          --- Eric Dolphy   | TOSHIBA CORPORATION
  --------------------------------------------------------------------------