Bug 17796

Summary: pcm drivers failes to load for Neomagic on IBM Thinkpad 390
Product: Base System Reporter: Edwin Groothuis <mavetju>
Component: kernAssignee: cg
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-RELEASE   
Hardware: Any   
OS: Any   

Description Edwin Groothuis 2000-04-04 21:20:00 UTC
	I've talked to Guido van Rooij about this, he advised me
	to use the new sources. It didn't work, it hangs just before
	the detection of the exact chipset.

	What is happening is that the call to ac97_create() works
	and returns a valid value, then ac97_initmixer() is called,
	the call to "i=rdcd(codec,AC97_REG_RESET)" is done and that
	one never returns. When looking deeper into it, it hangs
	in the call to nm_rd called from nm_rdcd() in neomagic.c:
	x=nm_rd(sc,sc->ac97_base+regno,2)

	In the kernel config it's defined as:
		device pcm

Fix: 

None known by us, we don't have enough information regarding the hardware.
	We would like to be used as guinnae-pigs for this if needed.
	If more information is needed please let us know.
Comment 1 Eric Masson 2000-08-07 13:24:49 UTC
Hello,

Here's a quick'n'dirty fix. Add a kernel option to disable probing of
Neomagic 256AV chip by pcm.

Kernel configuration file

options		NEOMAGIC_TP390
device		pcm0	at isa? port 0x530 irq 5 drq 0 flags 0x11

Here are the diffs to implement the kernel option :

--- options.i386.orig	Mon Aug  7 13:16:44 2000
+++ options.i386	Mon Aug  7 13:19:43 2000
@@ -139,6 +139,9 @@
 GUS_DMA			opt_sound.h
 GUS_IRQ			opt_sound.h
 
+# newpcm options
+NEOMAGIC_TP390			opt_sound.h
+
 # Video spigot
 SPIGOT_UNSECURE		opt_spigot.h
 
--- neomagic.c.orig	Mon Aug  7 12:42:31 2000
+++ neomagic.c	Mon Aug  7 13:39:05 2000
@@ -28,6 +28,7 @@
  * $FreeBSD: src/sys/dev/sound/pci/neomagic.c,v 1.7.2.3 2000/07/19 21:18:45 cg Exp $
  */
 
+#include <opt_sound.h>
 #include <dev/sound/pcm/sound.h>
 #include <dev/sound/pcm/ac97.h>
 #include <dev/sound/pci/neomagic.h>
@@ -560,10 +561,14 @@
 nm_pci_probe(device_t dev)
 {
 	char *s = NULL;
-	u_int32_t subdev, i;
+	u_int32_t subdev;
+#ifndef NEOMAGIC_TP390
+	u_int32_t i;
+#endif
 
 	subdev = (pci_get_subdevice(dev) << 16) | pci_get_subvendor(dev);
 	switch (pci_get_devid(dev)) {
+#ifndef NEOMAGIC_TP390
 	case NM256AV_PCI_ID:
 		i = 0;
 		while ((i < NUM_BADCARDS) && (badcards[i] != subdev))
@@ -573,6 +578,7 @@
 		DEB(else)
 			DEB(device_printf(dev, "this is a non-ac97 NM256AV, not attaching\n"));
 		break;
+#endif
 
 	case NM256ZX_PCI_ID:
 		s = "NeoMagic 256ZX";

Regards

Eric Masson
-- 
Progress : (n) What led from smart users in front of dumb terminals to 
dumb users in front of smart terminals.
Comment 2 Sheldon Hearn freebsd_committer freebsd_triage 2000-08-07 13:52:56 UTC
Responsible Changed
From-To: freebsd-bugs->cg

Cameron, this one now contains a quick'n'dirty fix. :-)
Comment 3 gandalf 2000-08-07 16:38:24 UTC
this is a non-ac97 NM256AV.  give me the output from 'pciconf -l' and i can
add it to the no-attach list.

    -cg
Comment 4 Eric Masson 2000-08-07 17:23:53 UTC
Hello Cameron,

Here's the output of pciconf -l on my box :

chip0@pci0:0:0:	class=0x060000 card=0x00000000 chip=0x71928086 rev=0x02 hdr=0x00
isab0@pci0:2:0:	class=0x068000 card=0x00000000 chip=0x71108086 rev=0x02 hdr=0x00
atapci0@pci0:2:1:	class=0x010180 card=0x00000000 chip=0x71118086 rev=0x01 hdr=0x00
none0@pci0:2:2:	class=0x0c0300 card=0x00000000 chip=0x71128086 rev=0x01 hdr=0x00
chip1@pci0:2:3:	class=0x068000 card=0x00000000 chip=0x71138086 rev=0x02 hdr=0x00
pcic-pci0@pci0:3:0:	class=0x060700 card=0x00921014 chip=0xac16104c rev=0x02 hdr=0x02
pcic-pci1@pci0:3:1:	class=0x060700 card=0x00921014 chip=0xac16104c rev=0x02 hdr=0x02
none1@pci0:5:0:	class=0x030000 card=0x00dd1014 chip=0x000510c8 rev=0x12 hdr=0x00
chip2@pci0:5:1:	class=0x040100 card=0x00dd1014 chip=0x800510c8 rev=0x12 hdr=0x00

Regards

Eric Masson
Comment 5 joost 2000-08-08 07:36:01 UTC
On Mon, Aug 07, 2000 at 04:38:24PM +0100, Cameron Grant wrote:
> this is a non-ac97 NM256AV.  give me the output from 'pciconf -l' and i can
> add it to the no-attach list.
> 
>     -cg
> 
 
chip0@pci0:0:0:	class=0x060000 card=0x00000000 chip=0x71008086 rev=0x01 hdr=0x00
isab0@pci0:2:0:	class=0x068000 card=0x00000000 chip=0x71108086 rev=0x02 hdr=0x00
atapci0@pci0:2:1:	class=0x010180 card=0x00000000 chip=0x71118086 rev=0x01 hdr=0x00
uhci0@pci0:2:2:	class=0x0c0300 card=0x00000000 chip=0x71128086 rev=0x01 hdr=0x00
chip1@pci0:2:3:	class=0x068000 card=0x00000000 chip=0x71138086 rev=0x02 hdr=0x00
pcic-pci0@pci0:3:0:	class=0x060700 card=0x00921014 chip=0xac16104c rev=0x02 hdr=0x02
pcic-pci1@pci0:3:1:	class=0x060700 card=0x00921014 chip=0xac16104c rev=0x02 hdr=0x02
none0@pci0:5:0:	class=0x030000 card=0x00dd1014 chip=0x000510c8 rev=0x20 hdr=0x00
chip2@pci0:5:1:	class=0x040100 card=0x00dd1014 chip=0x800510c8 rev=0x20 hdr=0x00

during boot this message is displayed:
chip2: <NeoMagic MagicMedia 256AX Audio controller> mem 0xfec00000-0xfecfffff,0x
fe400000-0xfe7fffff irq 11 at device 5.1 on pci0

greetz Joost
Comment 6 joost 2000-08-15 12:30:15 UTC
On Mon, Aug 07, 2000 at 02:24:49PM +0200, Eric Masson wrote:
> Hello,
> 
> Here's a quick'n'dirty fix. Add a kernel option to disable probing of
> Neomagic 256AV chip by pcm.
> 
> Kernel configuration file
> 
> options		NEOMAGIC_TP390
> device		pcm0	at isa? port 0x530 irq 5 drq 0 flags 0x11
> 
> Here are the diffs to implement the kernel option :
<--cut-->

it works! I've got sound!

thanx.
Comment 7 Eric Masson 2000-08-15 14:58:44 UTC
>>>>> "Joost" == Joost Bekkers <joost@bps.frust.eu.org> writes:

    Joost> it works! I've got sound!
    Joost> thanx.

All right,

I've looked at Cameron's patch in current and there's a better way to make
the sound work.

On your box issue a pciconf -l as root, you should see something like the
above :

chip0@pci0:0:0:	class=0x060000 card=0x00000000 chip=0x71928086 rev=0x02 hdr=0x00
isab0@pci0:2:0:	class=0x068000 card=0x00000000 chip=0x71108086 rev=0x02 hdr=0x00
atapci0@pci0:2:1:	class=0x010180 card=0x00000000 chip=0x71118086 rev=0x01 hdr=0x00
uhci0@pci0:2:2:	class=0x0c0300 card=0x00000000 chip=0x71128086 rev=0x01 hdr=0x00
intpm0@pci0:2:3:	class=0x068000 card=0x00000000 chip=0x71138086 rev=0x02 hdr=0x00
pcic-pci0@pci0:3:0:	class=0x060700 card=0x00921014 chip=0xac16104c rev=0x02 hdr=0x02
pcic-pci1@pci0:3:1:	class=0x060700 card=0x00921014 chip=0xac16104c rev=0x02 hdr=0x02
none0@pci0:5:0:	class=0x030000 card=0x00dd1014 chip=0x000510c8 rev=0x12 hdr=0x00
chip1@pci0:5:1:	class=0x040100 card=0x00dd1014 chip=0x800510c8 rev=0x12 hdr=0x00
                                    ^^^^^^^^^^
chip1 is the interesting line, note the value for card.

In /sys/dev/sound/pci/neomagic.c you will find the following sequence :

static u_int32_t badcards[] = {
	0x0007103c,
	0x008f1028,
};
#define NUM_BADCARDS (sizeof(badcards) / sizeof(u_int32_t))

In array badcards, add an entry for the id of the card found in pciconf -l

static u_int32_t badcards[] = {
	0x0007103c,
	0x008f1028,
	0x00dd1014,   // new id inserted here
};
#define NUM_BADCARDS (sizeof(badcards) / sizeof(u_int32_t))

Recompile your kernel and you're done.

Regards

Eric
-- 
Progress : (n) What led from smart users in front of dumb terminals to 
dumb users in front of smart terminals.
Comment 8 Edwin Groothuis 2000-11-26 09:39:22 UTC
Hello Eric,

As described earlier, the problem was fixed with the patches you
gave us. Can you please close the PR on this?

ta, Edwin

-- 
Edwin Groothuis   | Fatal Dimensions:
mavetju@chello.nl | http://fataldimensions.nl.eu.org/
------------------+ telnet://fataldimensions.nl.eu.org:4000
Trenton@FinalFantasy: y r all fucken coders wierd and negative except me?
Comment 9 greid freebsd_committer freebsd_triage 2001-04-07 02:45:38 UTC
State Changed
From-To: open->closed

Closed at submitter's request