Subject: Re: snapper for recent powerbook G4
To: None <port-macppc@NetBSD.org>
From: Antoine Reilles <Antoine.Reilles@loria.fr>
List: port-macppc
Date: 02/14/2006 17:27:27
--IpbVkmxF4tDyP/Kb
Content-Type: multipart/mixed; boundary="QKdGvSO+nmPlgiQ/"
Content-Disposition: inline


--QKdGvSO+nmPlgiQ/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Feb 13, 2006 at 10:59:01PM +0100, Antoine Reilles wrote:
> I built a kernel with SNAPPER_DEBUG
>=20
> When i try to play something, i get
>=20
> I2SSetDataWordSizeReg 0x02020202 -> 0x02000200
> I2SSetSerialFormatReg 0x0 -> 0x3190000
> I2SSetDataWordSizeReg 0x02020202 -> 0x02000200
> I2SSetSerialFormatReg 0x0 -> 0x81190000
> I2SSetDataWordSizeReg 0x02020202 -> 0x02000200
> I2SSetSerialFormatReg 0x0 -> 0x3190000
> I2SSetDataWordSizeReg 0x02020202 -> 0x02000200
> I2SSetSerialFormatReg 0x0 -> 0x81190000
> I2SSetDataWordSizeReg 0x02020202 -> 0x02000200
> I2SSetSerialFormatReg 0x0 -> 0x3190000
> I2SSetDataWordSizeReg 0x02020202 -> 0x02000200
> I2SSetSerialFormatReg 0x0 -> 0x41190000
> trigger_output 0xd049c000 0xd04ac000 0x2000
>=20
> in dmesg, and it looks like the player application is blocked
> in the write operation
>  1106 tonio     10    0  2328K 1576K aud_wr     0:00  0.00%  0.00% mpg321

Also, the snapper irq is 1: in dmesg:
snapper0 at obio0 offset 0x0: irq 30,1,2 (and looking at the sources, it us=
es
the second number) but here vmstat -v -i gives only one interrupt sent for =
irq 1

I tried to modify a little the snapper_attach, since i saw a commit log in
openbsd's i2s that changes the way snapper is attached, to work with newer
models:
http://www.openbsd.org/cgi-bin/cvsweb/src/sys/arch/macppc/dev/i2s.c
between -r 1.3 and -r 1.4

(get resources from soundbus instead of i2s)

With this patch, i still get no sound ;-(, but at least, now mpg321 and mad=
play
do not block any more, but behave just like if it played sound.
Also, now, irq 1 is getting interrupts, and i get:

$ vmstat -v -i
interrupt                                     total     rate
[snip]
openpic irq 1                                   297        0
[snip]
Total                                        963064      377

I still don't know why i don't get any sound. Here are parts of my dmesg wi=
th
the attached patch, and SNAPPER_DEBUG set:

[snip]
uni_n0 at mainbus0 address 0xf8000000
hw-clock at uni_n0 not configured
ki2c0 at uni_n0 address 0xf8001000
iic0 at ki2c0: I2C bus
[snip]
obio0 at pci1 dev 23 function 0: addr 0x80000000
zsc0 at obio0 offset 0x13000: irq 22,23
[snip]
snapper0 at obio0 offset 0x0: irq 30,1,2
[snip]
battery at obio0 offset 0x0 not configured
backlight at obio0 offset 0xf300 not configured
ki2c1 at obio0
iic1 at ki2c1: I2C bus
deq0 at ki2c1 Apple Digital Equalizer, addr 6a
[snip]
audio0 at snapper0: full duplex
I2SSetDataWordSizeReg 0x00000200 -> 0x02000200
I2SSetSerialFormatReg 0x41190000 -> 0x3190000
FCR(0x3c) 0x1803440<I2S0EN,I2S0CLKEN>
 /gpio 0xff981010
 headphone-mute 0x0
 amp-mute 0x0
 headphone-detect 0x0
 headphone-detect active 0
 headphone-detect intr ffffffff
 audio-hw-reset 0x0
I2SSetDataWordSizeReg 0x02000200 -> 0x02000200
I2SSetSerialFormatReg 0x3190000 -> 0x41190000
headphone detect =3D 0xfc
headphone is inserted
ampmute 0 --> 0
headphonemute 0 --> 1
[snip]

I don't know into which direction to go now, since i don't know how to iden=
tify
at which moment things go wrong.

Best regards,
antoine

Oh, i also placed dumps from "./ofdump" and "./ofdump -p" at
http://www.loria.fr/~reilles/divers/ofdump.dump
http://www.loria.fr/~reilles/divers/ofdump-p.dump

--QKdGvSO+nmPlgiQ/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="snapper.diff"
Content-Transfer-Encoding: quoted-printable

Index: sys/arch/macppc/dev/snapper.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/sys/arch/macppc/dev/snapper.c,v
retrieving revision 1.8
diff -u -r1.8 snapper.c
--- sys/arch/macppc/dev/snapper.c	24 Dec 2005 22:45:35 -0000	1.8
+++ sys/arch/macppc/dev/snapper.c	14 Feb 2006 16:01:09 -0000
@@ -335,7 +335,7 @@
 snapper_match(struct device *parent, struct cfdata *match, void *aux)
 {
 	struct confargs *ca;
-	int soundbus, soundchip;
+	int soundbus, soundchip, soundcodec;
 	char compat[32];
=20
 	ca =3D aux;
@@ -349,10 +349,14 @@
 	bzero(compat, sizeof compat);
 	OF_getprop(soundchip, "compatible", compat, sizeof compat);
=20
-	if (strcmp(compat, "snapper") !=3D 0)
-		return 0;
+	if (strcmp(compat, "snapper") =3D=3D 0)
+		return 1;
=20
-	return 1;
+	if (OF_getprop(soundchip,"platform-tas-codec-ref",
+	    &soundcodec, sizeof soundcodec) =3D=3D sizeof soundcodec)
+		return 1;
+
+	return 0;
 }
=20
 void
@@ -362,7 +366,7 @@
 	struct confargs *ca;
 	unsigned long v;
 	int cirq, oirq, iirq, cirq_type, oirq_type, iirq_type;
-	int soundbus, intr[6];
+	int soundbus, intr[6], reg[6];
=20
 	sc =3D (struct snapper_softc *)self;
 	ca =3D aux;
@@ -378,16 +382,17 @@
 	}
 #endif
=20
-	ca->ca_reg[0] +=3D ca->ca_baseaddr;
-	ca->ca_reg[2] +=3D ca->ca_baseaddr;
-	ca->ca_reg[4] +=3D ca->ca_baseaddr;
-
 	sc->sc_node =3D ca->ca_node;
-	sc->sc_reg =3D (void *)ca->ca_reg[0];
-	sc->sc_odma =3D (void *)ca->ca_reg[2];
-	sc->sc_idma =3D (void *)ca->ca_reg[4];
-
 	soundbus =3D OF_child(ca->ca_node);
+	OF_getprop(soundbus, "reg", reg, sizeof reg);
+	reg[0] +=3D ca->ca_baseaddr;
+	reg[2] +=3D ca->ca_baseaddr;
+	reg[4] +=3D ca->ca_baseaddr;
+
+	sc->sc_reg =3D (void *)reg[0];
+	sc->sc_odma =3D (void *)reg[2];
+	sc->sc_idma =3D (void *)reg[4];
+
 	OF_getprop(soundbus, "interrupts", intr, sizeof intr);
 	cirq =3D intr[0];
 	oirq =3D intr[2];

--QKdGvSO+nmPlgiQ/--

--IpbVkmxF4tDyP/Kb
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (NetBSD)

iD8DBQFD8gTv4VqmoGDE/mwRAr5bAJ9ohfFgXQw3HkKYc9jOG+dbGYooXgCdGb9V
0rw5NwEuUfkc/fDSv/hAD3w=
=9NCm
-----END PGP SIGNATURE-----

--IpbVkmxF4tDyP/Kb--