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/15/2006 02:08:53
--oJ71EGRlYNjSvfq7
Content-Type: multipart/mixed; boundary="wq9mPyueHGvFACwf"
Content-Disposition: inline
--wq9mPyueHGvFACwf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Feb 14, 2006 at 05:27:27PM +0100, Antoine Reilles wrote:
> Also, the snapper irq is 1: in dmesg:
> snapper0 at obio0 offset 0x0: irq 30,1,2 (and looking at the sources, it =
uses
> the second number) but here vmstat -v -i gives only one interrupt sent fo=
r irq 1
>=20
> 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
>=20
> (get resources from soundbus instead of i2s)
>=20
> With this patch, i still get no sound ;-(, but at least, now mpg321 and m=
adplay
> do not block any more, but behave just like if it played sound.
>=20
> [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
those values are strange: it was due to the gpio stuff not being
initialized correctly: snapper searches "audio-gpio" property, but it
is not present in the powerbook. instead, i do have "reg". The
following patch lets snapper find the "reg" values for the gpio.=20
(thanks macallan)
Now in dmesg i get:
audio0 at snapper0: full duplex
I2SSetDataWordSizeReg 0x00000200 -> 0x02000200
I2SSetSerialFormatReg 0x41190000 -> 0x3190000
FCR(0x3c) 0x1803440<I2S0EN,I2S0CLKEN>
/gpio 0xff981010
headphone-mute 0x1f
amp-mute 0x20
headphone-detect 0x17
headphone-detect active 0
headphone-detect intr 3d
audio-hw-reset 0x0
headphone detect =3D 0xa0
headphone is inserted
amp-mute 0x20
headphonemute 0 --> 1
I2SSetDataWordSizeReg 0x02000200 -> 0x02000200
I2SSetSerialFormatReg 0x3190000 -> 0x41190000
headphone detect =3D 0xa0
headphone is inserted
ampmute 0 --> 0
headphonemute 1 --> 1
plugging and unplugginig the headphones are correctly detected, and i
get the corresponding messages in dmesg.
However, it looks like there are still problems (and indeed, i get no
sound)
For example, the snapper_set_treble function do not correctly set the
value with iic_exec. for instance, the debug output i tried to set
there gives me:
snapper_set_port dev =3D 10, type =3D 3
tonio: just writing: 114
tonio: just read: 1: res 0
snapper_get_port dev =3D 10, type =3D 3
when i want to re read the value 114
Hope it helps,
antoine
--wq9mPyueHGvFACwf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="snapper.diff"
Content-Transfer-Encoding: quoted-printable
Index: deq.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/deq.c,v
retrieving revision 1.2
diff -u -r1.2 deq.c
--- deq.c 11 Dec 2005 12:18:03 -0000 1.2
+++ deq.c 15 Feb 2006 01:04:30 -0000
@@ -64,12 +64,13 @@
struct ki2c_confargs *ka =3D aux;
char compat[32];
=09
- if (strcmp(ka->ka_name, "deq") !=3D 0)
+ if ((strcmp(ka->ka_name, "deq") !=3D 0) && (strcmp(ka->ka_name, "codec") =
!=3D 0))
return 0;
=20
memset(compat, 0, sizeof(compat));
if(OF_getprop(ka->ka_node, "i2c-address", compat, sizeof(compat)))
return 1;
+
return 0;
}
=20
Index: pbms.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/pbms.c,v
retrieving revision 1.3
diff -u -r1.3 pbms.c
--- pbms.c 6 Feb 2006 20:13:25 -0000 1.3
+++ pbms.c 15 Feb 2006 01:04:30 -0000
@@ -108,14 +108,10 @@
* implementation already detects two fingers, so this should be
* relatively easy.
*
- * Implement some of the mouse ioctls?
- *
* Take care of the XXXs.
*
*/
=20
-#include <sys/cdefs.h>
-
#include <sys/param.h>
#include <sys/device.h>
#include <sys/errno.h>
@@ -239,7 +235,7 @@
.y_sensors =3D 16 \
}
/* 12 inch PowerBooks */
- POWERBOOK_TOUCHPAD(12, 0x030a, 69, 16, 52), /* XXX Not tested. */
+ POWERBOOK_TOUCHPAD(12, 0x030a, 64, 16, 43), /* XXX Not tested. */
/* 15 inch PowerBooks */
POWERBOOK_TOUCHPAD(15, 0x020e, 85, 16, 57), /* XXX Not tested. */
POWERBOOK_TOUCHPAD(15, 0x020f, 85, 16, 57),
@@ -265,7 +261,7 @@
signed char sc_sample[PBMS_SENSORS]; /* Current sample. */
struct device *sc_wsmousedev; /* WSMouse device. */
int sc_noise; /* Amount of noise. */
- int sc_theshold; /* Threshold value. */
+ int sc_threshold; /* Threshold value. */
int sc_x; /* Virtual position in horizontal=20
* direction (wsmouse position). */
int sc_x_factor; /* X-coordinate factor. */
@@ -350,10 +346,6 @@
int i;
uint16_t vendor, product;
=20
- sc->sc_hdev.sc_intr =3D pbms_intr;
- sc->sc_hdev.sc_parent =3D uha->parent;
- sc->sc_hdev.sc_report_id =3D uha->reportid;
-
/* Fill in device-specific parameters. */
if ((udd =3D usbd_get_device_descriptor(uha->parent->sc_udev)) !=3D NULL)=
{
product =3D UGETW(udd->idProduct);
@@ -363,7 +355,7 @@
if (product =3D=3D pd->product && vendor =3D=3D pd->vendor) {
printf(": %s\n", pd->descr);
sc->sc_noise =3D pd->noise;
- sc->sc_theshold =3D pd->threshold;
+ sc->sc_threshold =3D pd->threshold;
sc->sc_x_factor =3D pd->x_factor;
sc->sc_x_sensors =3D pd->x_sensors;
sc->sc_y_factor =3D pd->y_factor;
@@ -372,8 +364,16 @@
}
}
}
- KASSERT(0 <=3D sc->sc_x_sensors && sc->sc_x_sensors <=3D PBMS_X_SENSORS);
- KASSERT(0 <=3D sc->sc_y_sensors && sc->sc_y_sensors <=3D PBMS_Y_SENSORS);
+ if (sc->sc_x_sensors <=3D 0 || sc->sc_x_sensors > PBMS_X_SENSORS ||
+ sc->sc_y_sensors <=3D 0 || sc->sc_y_sensors > PBMS_Y_SENSORS) {
+ printf(": unexpected sensors configuration (%d:%d)\n",
+ sc->sc_x_sensors, sc->sc_y_sensors);
+ USB_ATTACH_ERROR_RETURN;
+ }
+
+ sc->sc_hdev.sc_intr =3D pbms_intr;
+ sc->sc_hdev.sc_parent =3D uha->parent;
+ sc->sc_hdev.sc_report_id =3D uha->reportid;
=20
sc->sc_status =3D 0;
=20
@@ -458,13 +458,16 @@
uhidev_close(&sc->sc_hdev);
}
=20
-
-/* XXX ioctl not implemented. */
-
static int
pbms_ioctl(void *v, unsigned long cmd, caddr_t data, int flag, struct lwp =
*p)
{
- return EPASSTHROUGH;
+ switch (cmd) {
+ case WSMOUSEIO_GTYPE:
+ *(u_int *)data =3D WSMOUSE_TYPE_TPANEL;
+ return 0;
+ }
+
+ return -1;
}
=20
=20
@@ -575,10 +578,10 @@
{
int x_det, y_det, x_raw, y_raw, x_fingers, y_fingers, fingers, x, y;
=20
- x_det =3D detect_pos(sc->sc_acc, sc->sc_x_sensors, sc->sc_theshold,
+ x_det =3D detect_pos(sc->sc_acc, sc->sc_x_sensors, sc->sc_threshold,
sc->sc_x_factor, &x_raw, &x_fingers);
y_det =3D detect_pos(sc->sc_acc + PBMS_X_SENSORS, sc->sc_y_sensors,
- sc->sc_theshold, sc->sc_y_factor,
+ sc->sc_threshold, sc->sc_y_factor,
&y_raw, &y_fingers);
fingers =3D max(x_fingers, y_fingers);
=20
Index: 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
--- snapper.c 24 Dec 2005 22:45:35 -0000 1.8
+++ snapper.c 15 Feb 2006 01:04:31 -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];
@@ -993,12 +998,21 @@
=20
void snapper_set_treble(struct snapper_softc *sc, int stuff)
{
- uint8_t reg;
+ uint8_t reg, deq_treble;
+ int res;
if((stuff>=3D0) && (stuff<=3D255) && (sc->sc_treble!=3Dstuff)) {
reg=3Dsnapper_basstab[(stuff>>3)+2];
sc->sc_treble=3Dstuff;
+ printf("tonio: just writing: %d\n", reg);
tas3004_write(sc, DEQ_TREBLE,®);
}
+ /* tonio: try to read what we wrote ! */
+ reg=3D1;
+ deq_treble=3DDEQ_TREBLE;
+ iic_acquire_bus(sc->sc_i2c, 0);
+ res =3D iic_exec(sc->sc_i2c, I2C_OP_READ, sc->sc_deqaddr, &deq_treble, 1,=
®, 1, 0);
+ iic_release_bus(sc->sc_i2c, 0);
+ printf("tonio: just read: %d: res %d\n", reg, res);
}
=20
void snapper_set_bass(struct snapper_softc *sc, int stuff)
@@ -1413,18 +1427,22 @@
bzero(audio_gpio, sizeof audio_gpio);
addr =3D 0;
OF_getprop(gpio, "name", name, sizeof name);
- OF_getprop(gpio, "audio-gpio", audio_gpio, sizeof audio_gpio);
- OF_getprop(gpio, "AAPL,address", &addr, sizeof addr);
- /* printf("0x%x %s %s\n", gpio, name, audio_gpio); */
+ if(OF_getprop(gpio, "audio-gpio", audio_gpio,=20
+ sizeof audio_gpio) =3D=3D sizeof audio_gpio) {
+ OF_getprop(gpio, "AAPL,address", &addr, sizeof addr);
+ } else {
+ OF_getprop(gpio, "reg", &addr, sizeof addr);
+ }
+ /* printf("0x%x %s :%s:%x:\n", gpio, name, audio_gpio, addr);*/
=20
/* gpio5 */
- if (strcmp(audio_gpio, "headphone-mute") =3D=3D 0)
+ if (strcmp(audio_gpio, "headphone-mute") =3D=3D 0 || strcmp(name, "headp=
hone-mute") =3D=3D 0)
headphone_mute =3D addr;
/* gpio6 */
- if (strcmp(audio_gpio, "amp-mute") =3D=3D 0)
+ if (strcmp(audio_gpio, "amp-mute") =3D=3D 0 || strcmp(name, "amp-mute") =
=3D=3D 0)
amp_mute =3D addr;
/* extint-gpio15 */
- if (strcmp(audio_gpio, "headphone-detect") =3D=3D 0) {
+ if (strcmp(audio_gpio, "headphone-detect") =3D=3D 0 || strcmp(name, "hea=
dphone-detect") =3D=3D 0) {
headphone_detect =3D addr;
OF_getprop(gpio, "audio-gpio-active-state",
&headphone_detect_active, 4);
@@ -1433,7 +1451,7 @@
headphone_detect_intrtype =3D intr[1];
}
/* gpio11 (keywest-11) */
- if (strcmp(audio_gpio, "audio-hw-reset") =3D=3D 0)
+ if (strcmp(audio_gpio, "audio-hw-reset") =3D=3D 0 || strcmp(audio_gpio, =
"audio-hw-reset") =3D=3D 0)
audio_hw_reset =3D addr;
gpio =3D OF_peer(gpio);
}
--wq9mPyueHGvFACwf--
--oJ71EGRlYNjSvfq7
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (NetBSD)
iD8DBQFD8n8l4VqmoGDE/mwRAicYAJ439Ja6gs5hPyZ40XZ288dwy4eGZgCdEffM
zu8WpSE2AAHjMWfBgb8pGd0=
=Opki
-----END PGP SIGNATURE-----
--oJ71EGRlYNjSvfq7--