Subject: port-i386/9751: eso driver does not work after the resume on ThinkPad240
To: None <netbsd-bugs@netbsd.org>
From: John Darrow <John.P.Darrow@wheaton.edu>
List: netbsd-bugs
Date: 04/05/2000 14:58:21
Date: Sun, 2 Apr 2000 23:51:13 +0900 (JST)
From: kanetacr.chiba-u.ac.jp@cr.chiba-u.ac.jp
Reply-To: kaneta@cr.chiba-u.ac.jp
To: gnats-bugs@gnats.netbsd.org
Subject: eso driver does not work after the resume on ThinkPad240


>Number:         9751
>Category:       port-i386
>Synopsis:       eso driver does not work after the resume on ThinkPad240
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-i386-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 02 07:54:00 PDT 2000
>Closed-Date:    
>Last-Modified:  
>Originator:     KANETA Shin-ichi
>Release:        Mar 30, 2000
>Organization:
KANETA Shin-ichi
Center for Environmental Remote Sensing, Chiba University
1-33 Yayoicho, Inage-ku, Chiba 263-8522, Japan
Phone/Fax: +81-43-290-3844/+81-43-290-3857
>Environment:
ThinkPad240
System: NetBSD more 1.4X NetBSD 1.4X (MORE) #19: Sun Apr 2 17:39:46 JST 2000 kaneta@more:/exports/NetBSD/src/sys/arch/i386/compile/MORE i386


>Description:
My laptop (IBM ThinkPad240) has ESS Solo-1 PCI AudioDrive. I use it
with the eso driver. When I suspend the laptop (with 'zzz' command or
function key), then resume the laptop and start audio software (mpg123,
audioplay), the eso driver prints error message 'eso0: WDR timeout'
and can not play audio. I made small patch against /sys/dev/pci/eso.c
NetBSD: eso.c,v 1.18 2000/03/22 14:37:43 kleink Exp. This patch
works well for me, but if suspend during audio plaing, esp driver
still has problem (does not work after resume)... I don't know this is
right way to fix the problem, I checked this only on my laptop PC.


--- configuration file ---
# Audio Devices


# PCI audio devices
#clcs*  at pci? dev ? function ?        # Cirrus Logic CS4280
#eap*   at pci? dev ? function ?        # Ensoniq AudioPCI
eso*    at pci? dev ? function ?        # ESS Solo-1 PCI AudioDrive
#fms*   at pci? dev ? function ?        # Forte Media FM801
#sbl*   at pci? dev ? function ?        # SoundBlaster Live!
#sv*    at pci? dev ? function ?        # S3 SonicVibes


# ISA Plug-and-Play audio devices
#ess*   at isapnp?                      # ESS Tech ES1887, ES1888, ES888 audio
#guspnp*        at isapnp?                      # Gravis Ultra Sound PnP audio
#sb*    at isapnp?                      # SoundBlaster-compatible audio
#wss*   at isapnp?                      # Windows Sound System
#ym*    at isapnp?                      # Yamaha OPL3-SA3 audio


# ISA audio devices
# the "aria" probe might give false hits
#aria0  at isa? port 0x290 irq 10               # Aria
#ess0   at isa? port 0x220 irq 5 drq 1 drq2 5   # ESS 18XX
#gus0   at isa? port 0x220 irq 7 drq 1 drq2 6   # Gravis Ultra Sound
#pas0   at isa? port 0x220 irq 7 drq 1          # ProAudio Spectrum
#pss0   at isa? port 0x220 irq 7 drq 6          # Personal Sound System
#sp0    at pss0 port 0x530 irq 10 drq 0         #       sound port driver
#sb0    at isa? port 0x220 irq 5 drq 1 drq2 5   # SoundBlaster
#wss0   at isa? port 0x530 irq 10 drq 0 drq2 1  # Windows Sound System


# OPL[23] FM synthesizers
#opl0   at isa? port 0x388      # use only if not attached to sound card
opl*    at eso?
#opl*   at ess?
#opl*   at fms?
#opl*   at sb?
#opl*   at sv?
#opl*   at wss?
#opl*   at ym?


# Audio support
#audio* at aria?
#audio* at clcs?
#audio* at eap?
audio*  at eso?
#audio* at ess?
#audio* at fms?
#audio* at gus?
#audio* at guspnp?
#audio* at pas?
#audio* at sb?
#audio* at sbl?
#audio* at sp?
#audio* at sv?
#audio* at uaudio?
#audio* at wss?
#audio* at ym?


# MPU 401 UARTs
#mpu*   at isa? port 0x330 irq 9        # MPU401 or compatible card
mpu*    at eso?
#mpu*   at fms?
#mpu*   at sb?
#mpu*   at ym?


# MIDI support
#midi*  at eap?                 # 137[01] MIDI port
midi*   at mpu?                 # MPU 401
midi*   at opl?                 # OPL FM synth
midi*   at pcppi?               # MIDI interface to the PC speaker
#midi*  at sb?                  # SB1 MIDI port


# The spkr driver provides a simple tone interface to the built in speaker.
spkr0   at pcppi?               # PC speaker


--- /var/run/dmesg.boot ---
NetBSD 1.4X (MORE) #19: Sun Apr  2 17:39:46 JST 2000
    kaneta@more:/exports/NetBSD/src/sys/arch/i386/compile/MORE
cpu0: family 6 model 6 step a
cpu0: Intel Pentium II (Celeron) (686-class)
total memory = 97856 KB
avail memory = 87488 KB
using 1248 buffers containing 4992 KB of memory
BIOS32 rev. 0 found at 0xfd7c0
PCI BIOS rev. 2.1 found at 0xfd9e5
pcibios: config mechanism [1][x], special cycles [x][x], last bus 0
PCI IRQ Routing Table rev. 1.0 found at 0xfdf60, size 128 bytes (6 entries)
PCI Interrupt Router at 000:07:0 (vendor 0x8086 product 0x122e)
--------------------------------------------
  device vendor product pin PIRQ   IRQ stage
--------------------------------------------
000:07:2 0x8086 0x7112  D   0x03   11  0
000:10:0 0x104c 0xac1e  A   0x01   11  0
000:11:0 0x125d 0x1969  A   0x02   05  0
--------------------------------------------
PCI bridge 0: primary 0, secondary 1, subordinate 1
PCI bus #1 is the last bus
mainbus0 (root)
pnpbios0 at mainbus0: nodes 19, max len 193
lpt0 at pnpbios0 index 21 (PNP0400)
lpt0: io 3bc-3be, irq 7
pci0 at mainbus0 bus 0: configuration mode 1
pci0: i/o space, memory space enabled
pchb0 at pci0 dev 0 function 0
pchb0: vendor 0x8086 product 0x7192 (rev. 0x03)
pcib0 at pci0 dev 7 function 0
pcib0: vendor 0x8086 product 0x7110 (rev. 0x02)
pciide0 at pci0 dev 7 function 1: Intel 82371AB IDE controller (PIIX4)
pciide0: bus-master DMA support present
pciide0: primary channel wired to compatibility mode
wd0 at pciide0 channel 0 drive 0: <IBM-DARA-212000>
wd0: drive supports 16-sector pio transfers, lba addressing
wd0: 11513 MB, 16383 cyl, 16 head, 63 sec, 512 bytes/sect x 23579136 sectors
wd0: 32-bit data port
wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 4
pciide0: primary channel interrupting at irq 14
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2 (using DMA data transfers)
pciide0: secondary channel wired to compatibility mode
pciide0: disabling secondary channel (no drives)
vendor 0x8086 product 0x7112 (USB serial bus, revision 0x01) at pci0 dev 7 funct
ion 2 not configured
vendor 0x8086 product 0x7113 (miscellaneous bridge, revision 0x02) at pci0 dev 7
 function 3 not configured
vga0 at pci0 dev 9 function 0: vendor 0x10c8 product 0x0004 (rev. 0x01)
wsdisplay0 at vga0: console (80x25, vt100 emulation)
cbb0 at pci0 dev 10 function 0: vendor 0x104c product 0xac1e (rev. 0x00)
eso0 at pci0 dev 11 function 0: ESS Solo-1 PCI AudioDrive ES1946 Revision E
eso0: interrupting at irq 5
eso0: mapping Audio 1 DMA using VC I/O space at 0x1080
audio0 at eso0: full duplex, mmap, independent
opl0 at eso0: model OPL3
midi0 at opl0: ESO Yamaha OPL3
mpu0 at eso0
midi1 at mpu0: ESO MPU-401 MIDI UART
isa0 at pcib0
com0 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo
com1 at isa0 port 0x2f8-0x2ff irq 3: ns16550a, working fifo
pckbc0 at isa0 port 0x60-0x64
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pms0 mux 0
pcppi0 at isa0 port 0x61
midi2 at pcppi0: PC speaker
spkr0 at pcppi0
sysbeep0 at pcppi0
npx0 at isa0 port 0xf0-0xff: using exception 16
fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2
pcic0 at isa0 port 0x3e0-0x3e1 iomem 0xd0000-0xdffff
pcic0: controller 0 (Intel 82365SL Revision 1) has sockets A and B
pcic0: controller 1 (Intel 82365SL Revision 1) has no sockets
pcmcia0 at pcic0 controller 0 socket 0
pcmcia1 at pcic0 controller 0 socket 1
cbb0: interrupting at irq 11
cbb0: cacheline 0x0 lattimer 0x20
cbb0: bhlc 0x21000 lscp 0x20010100
cardslot0 at cbb0 slot 0 flags 0
cardbus0 at cardslot0: bus 1 device 0 cacheline 0x0, lattimer 0x20
pcmcia2 at cardslot0
apm0 at mainbus0: Power Management spec V1.2
WARNING: preposterous time in file system
biomask ef45 netmask ef45 ttymask ffc7
pcic0: controller 0 detecting irqs with mask 0xdeb8:
pcic0: no available irq; polling for socket events
com3 at pcmcia2 function 0: serial device
com3: ns16550a, working fifo
boot device: wd0
root on wd0a dumps on wd0b
root file system type: ffs


>How-To-Repeat:
	1. Suspend system (with 'zzz' or function key)
	2. Resume system
	3. Start audio software (e.g. gqmpeg, mpg123 or audioplay)
	4. eso driver prints error messages like below (100%)
eso0: WDR timeout
eso0: WDR timeout
eso0: WDR timeout
eso0: WDR timeout


>Fix:
I made small patch against /sys/dev/pci/eso.c $NetBSD: eso.c,v 1.18
2000/03/22 14:37:43 kleink Exp $. This patch works well for me, but if
suspend during audio plaing, esp driver still has problem (does not
work after resume).


--- eso.c	2000/04/01 22:21:56	1.1
+++ eso.c	2000/04/02 08:38:54	1.1.1.2
@@ -169,6 +169,8 @@
 		    int, struct eso_dma *));
 static void	eso_freemem __P((struct eso_dma *));

 
+/* for APM work around by kinta */
+static void     eso_resume __P((struct eso_softc *));

 
 static int
 eso_match(parent, match, aux)
@@ -430,6 +432,9 @@
 	}

 
 	printf("%s: WDR timeout\n", sc->sc_dev.dv_xname);
+	eso_resume(sc);
+	printf("reset ESO done\n");
 	return;
 }

 
@@ -1977,4 +1982,33 @@

 
 	eso_write_mixreg(sc, mixreg, ESO_4BIT_GAIN_TO_STEREO(
 	    sc->sc_gain[port][ESO_LEFT], sc->sc_gain[port][ESO_RIGHT]));
+}
+
+static void
+eso_resume(sc)
+     	struct eso_softc *sc;
+{
+	uint8_t a2mode, mvctl;
+
+	/* Reset the device; bail out upon failure. */
+	if (eso_reset(sc) != 0) {
+		printf("%s: can't reset\n", sc->sc_dev.dv_xname);
+		return;
+	}
+	
+	/* Enable the relevant (DMA) interrupts. */
+	bus_space_write_1(sc->sc_iot, sc->sc_ioh, ESO_IO_IRQCTL,
+	    ESO_IO_IRQCTL_A1IRQ | ESO_IO_IRQCTL_A2IRQ | ESO_IO_IRQCTL_HVIRQ |
+	    ESO_IO_IRQCTL_MPUIRQ);
+	
+	/* Set up A1's sample rate generator for new-style parameters. */
+	a2mode = eso_read_mixreg(sc, ESO_MIXREG_A2MODE);
+	a2mode |= ESO_MIXREG_A2MODE_NEWA1 | ESO_MIXREG_A2MODE_ASYNC;
+	eso_write_mixreg(sc, ESO_MIXREG_A2MODE, a2mode);
+	
+	/* Slave Master Volume to Hardware Volume Control Counter, unask IRQ. */
+	mvctl = eso_read_mixreg(sc, ESO_MIXREG_MVCTL);
+	mvctl &= ~ESO_MIXREG_MVCTL_SPLIT;
+	mvctl |= ESO_MIXREG_MVCTL_HVIRQM;
+	eso_write_mixreg(sc, ESO_MIXREG_MVCTL, mvctl);
 }
>Release-Note:
>Audit-Trail:
>Unformatted: