linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pmac: sound support for latest laptops
@ 2005-04-10  6:16 Benjamin Herrenschmidt
  2005-04-10  8:37 ` Antonio-M. Corbi Bellot
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2005-04-10  6:16 UTC (permalink / raw)
  To: debian-powerpc@lists.debian.org, linuxppc-dev list
  Cc: Takashi Iwai, Andrew Morton

Hi !

This patch hacks the current Alsa snd-powermac driver to add support for
recent machine models with the tas3004 chip, that is basically new
laptop models. The Mac Mini is _NOT_ yet supported by this patch (soon
soon ...). The G5s (iMac or Desktop) will need the rewritten sound
driver on which I'm working on (I _might_ get a hack for analog only on
some G5s on the current driver, but no promise).

diff -urN linux-2.6.12-rc2/sound/ppc/pmac.c linux-2.6.12-rc2+snd/sound/ppc/pmac.c
--- linux-2.6.12-rc2/sound/ppc/pmac.c	2005-04-10 15:21:33.000000000 +1000
+++ linux-2.6.12-rc2+snd/sound/ppc/pmac.c	2005-04-10 15:16:07.000000000 +1000
@@ -881,7 +881,8 @@
 {
 	struct device_node *sound;
 	unsigned int *prop, l;
-
+	u32 layout_id = 0;
+	
 	if (_machine != _MACH_Pmac)
 		return -ENODEV;
 
@@ -929,6 +930,9 @@
 	prop = (unsigned int *) get_property(sound, "sub-frame", NULL);
 	if (prop && *prop < 16)
 		chip->subframe = *prop;
+	prop = (unsigned int *) get_property(sound, "layout-id", NULL);
+	if (prop)
+		layout_id = *prop;
 	/* This should be verified on older screamers */
 	if (device_is_compatible(sound, "screamer")) {
 		chip->model = PMAC_SCREAMER;
@@ -961,12 +965,22 @@
 		chip->freq_table = tumbler_freqs;
 		chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
 	}
-	if (device_is_compatible(sound, "AOAKeylargo")) {
-		/* Seems to support the stock AWACS frequencies, but has
-		   a snapper mixer */
-		chip->model = PMAC_SNAPPER;
-		// chip->can_byte_swap = 0; /* FIXME: check this */
-		chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
+	if (device_is_compatible(sound, "AOAKeylargo") ||
+	    device_is_compatible(sound, "AOAbase")) {
+		/* For now, only support very basic TAS3004 based machines with
+		 * single frequency until proper i2s control is implemented
+		 */
+		switch(layout_id) {
+		case 0x48:
+		case 0x46:
+		case 0x33:
+		case 0x29:
+			chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
+			chip->model = PMAC_SNAPPER;
+			chip->can_byte_swap = 0; /* FIXME: check this */
+			chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
+			break;
+		}
 	}
 	prop = (unsigned int *)get_property(sound, "device-id", NULL);
 	if (prop)
diff -urN linux-2.6.12-rc2/sound/ppc/tumbler.c linux-2.6.12-rc2+snd/sound/ppc/tumbler.c
--- linux-2.6.12-rc2/sound/ppc/tumbler.c	2005-03-05 10:20:29.000000000 +1100
+++ linux-2.6.12-rc2+snd/sound/ppc/tumbler.c	2005-04-10 15:08:00.000000000 +1000
@@ -37,6 +37,8 @@
 #include <asm/irq.h>
 #ifdef CONFIG_PPC_HAS_FEATURE_CALLS
 #include <asm/pmac_feature.h>
+#else
+#error old crap
 #endif
 #include "pmac.h"
 #include "tumbler_volume.h"
@@ -950,10 +952,10 @@
 }
 
 /* find an audio device and get its address */
-static unsigned long tumbler_find_device(const char *device, pmac_gpio_t *gp, int is_compatible)
+static long tumbler_find_device(const char *device, pmac_gpio_t *gp, int is_compatible)
 {
 	struct device_node *node;
-	u32 *base;
+	u32 *base, addr;
 
 	if (is_compatible)
 		node = find_compatible_audio_device(device);
@@ -966,21 +968,31 @@
 
 	base = (u32 *)get_property(node, "AAPL,address", NULL);
 	if (! base) {
-		snd_printd("cannot find address for device %s\n", device);
-		return -ENODEV;
-	}
+		base = (u32 *)get_property(node, "reg", NULL);
+		if (!base) {
+			snd_printd("cannot find address for device %s\n", device);
+			return -ENODEV;
+		}
+		/* this only work if PPC_HAS_FEATURE_CALLS is set as we
+		 * are only getting the low part of the address
+		 */
+		addr = *base;
+		if (addr < 0x50)
+			addr += 0x50;
+	} else
+		addr = *base;
 
 #ifdef CONFIG_PPC_HAS_FEATURE_CALLS
-	gp->addr = (*base) & 0x0000ffff;
+	gp->addr = addr & 0x0000ffff;
 #else
-	gp->addr = ioremap((unsigned long)(*base), 1);
+	gp->addr = ioremap((unsigned long)addr, 1);
 #endif
+	/* Try to find the active state, default to 0 ! */
 	base = (u32 *)get_property(node, "audio-gpio-active-state", NULL);
 	if (base)
 		gp->active_state = *base;
 	else
-		gp->active_state = 1;
-
+		gp->active_state = 0;
 
 	return (node->n_intrs > 0) ? node->intrs[0].line : 0;
 }
@@ -1039,11 +1051,16 @@
 	pmac_tumbler_t *mix = chip->mixer_data;
 	snd_assert(mix, return -EINVAL);
 
-	tumbler_find_device("audio-hw-reset", &mix->audio_reset, 0);
-	tumbler_find_device("amp-mute", &mix->amp_mute, 0);
-	tumbler_find_device("headphone-mute", &mix->hp_mute, 0);
+	if (tumbler_find_device("audio-hw-reset", &mix->audio_reset, 0) < 0)
+		tumbler_find_device("hw-reset", &mix->audio_reset, 1);
+	if (tumbler_find_device("amp-mute", &mix->amp_mute, 0) < 0)
+		tumbler_find_device("amp-mute", &mix->amp_mute, 1);
+	if (tumbler_find_device("headphone-mute", &mix->hp_mute, 0) < 0)
+		tumbler_find_device("headphone-mute", &mix->hp_mute, 1);
 	irq = tumbler_find_device("headphone-detect", &mix->hp_detect, 0);
 	if (irq < 0)
+		irq = tumbler_find_device("headphone-detect", &mix->hp_detect, 1);
+	if (irq < 0)
 		irq = tumbler_find_device("keywest-gpio15", &mix->hp_detect, 1);
 
 	tumbler_reset_audio(chip);
@@ -1109,9 +1126,13 @@
 	/* set up TAS */
 	tas_node = find_devices("deq");
 	if (tas_node == NULL)
+		tas_node = find_devices("codec");
+	if (tas_node == NULL)
 		return -ENODEV;
 
 	paddr = (u32 *)get_property(tas_node, "i2c-address", NULL);
+	if (paddr == NULL)
+		paddr = (u32 *)get_property(tas_node, "reg", NULL);
 	if (paddr)
 		mix->i2c.addr = (*paddr) >> 1;
 	else
@@ -1129,7 +1150,7 @@
 
 	if ((err = snd_pmac_keywest_init(&mix->i2c)) < 0)
 		return err;
-
+	
 	/*
 	 * build mixers
 	 */
@@ -1156,7 +1177,6 @@
 	if ((err = snd_ctl_add(chip->card, chip->drc_sw_ctl)) < 0)
 		return err;
 
-
 #ifdef CONFIG_PMAC_PBOOK
 	chip->resume = tumbler_resume;
 #endif

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pmac: sound support for latest laptops
  2005-04-10  6:16 [PATCH] pmac: sound support for latest laptops Benjamin Herrenschmidt
@ 2005-04-10  8:37 ` Antonio-M. Corbi Bellot
  2005-04-11 14:46 ` Takashi Iwai
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Antonio-M. Corbi Bellot @ 2005-04-10  8:37 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Takashi Iwai, linuxppc-dev list, debian-powerpc@lists.debian.org,
	Andrew Morton

El dom, 10-04-2005 a las 16:16 +1000, Benjamin Herrenschmidt escribió:
> Hi !
> 
> This patch hacks the current Alsa snd-powermac driver to add support for
> recent machine models with the tas3004 chip, that is basically new
> laptop models. 

It's working here (pbook 12" post-feb05) superb!. 

Thanks (once again) :=) Ben!

Antonio Corbi.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pmac: sound support for latest laptops
  2005-04-10  6:16 [PATCH] pmac: sound support for latest laptops Benjamin Herrenschmidt
  2005-04-10  8:37 ` Antonio-M. Corbi Bellot
@ 2005-04-11 14:46 ` Takashi Iwai
  2005-04-11 15:07 ` Johannes Berg
  2005-04-14 12:55 ` Johannes Berg
  3 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2005-04-11 14:46 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Andrew Morton, linuxppc-dev list, debian-powerpc@lists.debian.org

At Sun, 10 Apr 2005 16:16:32 +1000,
Benjamin Herrenschmidt wrote:
> 
> Hi !
> 
> This patch hacks the current Alsa snd-powermac driver to add support for
> recent machine models with the tas3004 chip, that is basically new
> laptop models. The Mac Mini is _NOT_ yet supported by this patch (soon
> soon ...). The G5s (iMac or Desktop) will need the rewritten sound
> driver on which I'm working on (I _might_ get a hack for analog only on
> some G5s on the current driver, but no promise).

Thanks.  I applied this to ALSA tree (together with your another patch
for tumbler).


Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pmac: sound support for latest laptops
  2005-04-10  6:16 [PATCH] pmac: sound support for latest laptops Benjamin Herrenschmidt
  2005-04-10  8:37 ` Antonio-M. Corbi Bellot
  2005-04-11 14:46 ` Takashi Iwai
@ 2005-04-11 15:07 ` Johannes Berg
  2005-04-11 15:21   ` Takashi Iwai
  2005-04-12  0:04   ` Benjamin Herrenschmidt
  2005-04-14 12:55 ` Johannes Berg
  3 siblings, 2 replies; 10+ messages in thread
From: Johannes Berg @ 2005-04-11 15:07 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Takashi Iwai, linuxppc-dev list, debian-powerpc@lists.debian.org

Hi,

>This patch hacks the current Alsa snd-powermac driver to add support for
>recent machine models with the tas3004 chip, that is basically new
>laptop models. The Mac Mini is _NOT_ yet supported by this patch (soon
>soon ...). The G5s (iMac or Desktop) will need the rewritten sound
>driver on which I'm working on (I _might_ get a hack for analog only on
>some G5s on the current driver, but no promise).
>  
>
That's cool. I do have one slight problem with it though: When I turn 
down the Master mixer and up PCM it sounds badly overmodulated. I can 
keep PCM at about 75% and turn up master, and all is fine. Would it make 
sense to limit the PCM mixer to about 75% of its current limits, or how 
does that actually work in the hardware?

johannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pmac: sound support for latest laptops
  2005-04-11 15:07 ` Johannes Berg
@ 2005-04-11 15:21   ` Takashi Iwai
  2005-04-12  0:04   ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2005-04-11 15:21 UTC (permalink / raw)
  To: Johannes Berg; +Cc: debian-powerpc@lists.debian.org, linuxppc-dev list

At Mon, 11 Apr 2005 17:07:29 +0200,
Johannes Berg wrote:
> 
> Hi,
> 
> >This patch hacks the current Alsa snd-powermac driver to add support for
> >recent machine models with the tas3004 chip, that is basically new
> >laptop models. The Mac Mini is _NOT_ yet supported by this patch (soon
> >soon ...). The G5s (iMac or Desktop) will need the rewritten sound
> >driver on which I'm working on (I _might_ get a hack for analog only on
> >some G5s on the current driver, but no promise).
> >  
> >
> That's cool. I do have one slight problem with it though: When I turn 
> down the Master mixer and up PCM it sounds badly overmodulated. I can 
> keep PCM at about 75% and turn up master, and all is fine. Would it make 
> sense to limit the PCM mixer to about 75% of its current limits, or how 
> does that actually work in the hardware?

This sounds like a problem sometimes seen in devices with a codec that
amplifies (+dB) over a certain level.  Some ac97 codecs have the same
problem, too.


Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pmac: sound support for latest laptops
  2005-04-11 15:07 ` Johannes Berg
  2005-04-11 15:21   ` Takashi Iwai
@ 2005-04-12  0:04   ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2005-04-12  0:04 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Takashi Iwai, linuxppc-dev list, debian-powerpc@lists.debian.org

On Mon, 2005-04-11 at 17:07 +0200, Johannes Berg wrote:
> Hi,
> 
> >This patch hacks the current Alsa snd-powermac driver to add support for
> >recent machine models with the tas3004 chip, that is basically new
> >laptop models. The Mac Mini is _NOT_ yet supported by this patch (soon
> >soon ...). The G5s (iMac or Desktop) will need the rewritten sound
> >driver on which I'm working on (I _might_ get a hack for analog only on
> >some G5s on the current driver, but no promise).
> >  
> >
> That's cool. I do have one slight problem with it though: When I turn 
> down the Master mixer and up PCM it sounds badly overmodulated. I can 
> keep PCM at about 75% and turn up master, and all is fine. Would it make 
> sense to limit the PCM mixer to about 75% of its current limits, or how 
> does that actually work in the hardware?

Well, the driver will let you do the setting you want, even if it's
wrong :) You should indeed keep PCM at about 75% and use the master.

There is also an issue with bad quality speakers used by Apple. OS X has
a built-in software DSP that does equalisation & filtering in the kernel
driver, and they have specific settings for it for various machine model
speakers. Obviously, we don't have such thing.

Ben.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pmac: sound support for latest laptops
  2005-04-10  6:16 [PATCH] pmac: sound support for latest laptops Benjamin Herrenschmidt
                   ` (2 preceding siblings ...)
  2005-04-11 15:07 ` Johannes Berg
@ 2005-04-14 12:55 ` Johannes Berg
  2005-04-14 13:15   ` Benjamin Herrenschmidt
  3 siblings, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2005-04-14 12:55 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Takashi Iwai, linuxppc-dev list, debian-powerpc@lists.debian.org

[-- Attachment #1: Type: text/plain, Size: 713 bytes --]

Hi,

> This patch hacks the current Alsa snd-powermac driver to add support for
> recent machine models with the tas3004 chip, that is basically new
> laptop models.

So this works, but is incompatible with gstreamer. I took it with a
rhythmbox/gstreamer developer and he said that it's a driver issue. A
gstreamer log is here:
http://johannes.sipsolutions.net/files/rhythmbox-alsa-debug
(produced by GST_DEBUG=alsa*:5 rhythmbox 2>&1 | tee logfile)

He also asked me to try
$ gst-launch-0.8 sinesrc ! alsasink device=hw:0

which yields:
RUNNING pipeline ...
ERROR: pipeline doesn't want to play.

So the conclusion was:
"set_periods_near ioctl does something weird"

Any ideas?

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pmac: sound support for latest laptops
  2005-04-14 12:55 ` Johannes Berg
@ 2005-04-14 13:15   ` Benjamin Herrenschmidt
  2005-04-14 13:20     ` Johannes Berg
  2005-04-14 16:18     ` Takashi Iwai
  0 siblings, 2 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2005-04-14 13:15 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Takashi Iwai, linuxppc-dev list, debian-powerpc@lists.debian.org

On Thu, 2005-04-14 at 14:55 +0200, Johannes Berg wrote:
> Hi,
> 
> > This patch hacks the current Alsa snd-powermac driver to add support for
> > recent machine models with the tas3004 chip, that is basically new
> > laptop models.
> 
> So this works, but is incompatible with gstreamer. I took it with a
> rhythmbox/gstreamer developer and he said that it's a driver issue. A
> gstreamer log is here:
> http://johannes.sipsolutions.net/files/rhythmbox-alsa-debug
> (produced by GST_DEBUG=alsa*:5 rhythmbox 2>&1 | tee logfile)
> 
> He also asked me to try
> $ gst-launch-0.8 sinesrc ! alsasink device=hw:0
> 
> which yields:
> RUNNING pipeline ...
> ERROR: pipeline doesn't want to play.
> 
> So the conclusion was:
> "set_periods_near ioctl does something weird"
> 
> Any ideas?

I don't know, this is definitely not a problem with the platform
specific part of the driver, which is what I've been dealin with lately.
You may find a better answer with the Alsa folks regarding the actual
PCM implementation.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pmac: sound support for latest laptops
  2005-04-14 13:15   ` Benjamin Herrenschmidt
@ 2005-04-14 13:20     ` Johannes Berg
  2005-04-14 16:18     ` Takashi Iwai
  1 sibling, 0 replies; 10+ messages in thread
From: Johannes Berg @ 2005-04-14 13:20 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Takashi Iwai, linuxppc-dev list, debian-powerpc@lists.debian.org

[-- Attachment #1: Type: text/plain, Size: 546 bytes --]

On Thu, 2005-04-14 at 23:15 +1000, Benjamin Herrenschmidt wrote:

> I don't know, this is definitely not a problem with the platform
> specific part of the driver, which is what I've been dealin with lately.
> You may find a better answer with the Alsa folks regarding the actual
> PCM implementation.

Ok. In the meantime, a workaround has been committed to the gstreamer
CVS (because, as he put it "but since there's lots of kernel modules and
every new one might have such an issue again i'd like to have a
workaround")

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pmac: sound support for latest laptops
  2005-04-14 13:15   ` Benjamin Herrenschmidt
  2005-04-14 13:20     ` Johannes Berg
@ 2005-04-14 16:18     ` Takashi Iwai
  1 sibling, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2005-04-14 16:18 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: linuxppc-dev list, Johannes Berg, debian-powerpc@lists.debian.org

At Thu, 14 Apr 2005 23:15:14 +1000,
Benjamin Herrenschmidt wrote:
> 
> On Thu, 2005-04-14 at 14:55 +0200, Johannes Berg wrote:
> > Hi,
> > 
> > > This patch hacks the current Alsa snd-powermac driver to add support for
> > > recent machine models with the tas3004 chip, that is basically new
> > > laptop models.
> > 
> > So this works, but is incompatible with gstreamer. I took it with a
> > rhythmbox/gstreamer developer and he said that it's a driver issue. A
> > gstreamer log is here:
> > http://johannes.sipsolutions.net/files/rhythmbox-alsa-debug
> > (produced by GST_DEBUG=alsa*:5 rhythmbox 2>&1 | tee logfile)
> > 
> > He also asked me to try
> > $ gst-launch-0.8 sinesrc ! alsasink device=hw:0
> > 
> > which yields:
> > RUNNING pipeline ...
> > ERROR: pipeline doesn't want to play.
> > 
> > So the conclusion was:
> > "set_periods_near ioctl does something weird"
> > 
> > Any ideas?
> 
> I don't know, this is definitely not a problem with the platform
> specific part of the driver, which is what I've been dealin with lately.
> You may find a better answer with the Alsa folks regarding the actual
> PCM implementation.

Could you try the very latest CVS alsa-lib?
(Maybe you'll need to wait until tomorrow for sync with anon tree.)

In the latest version, alsa-lib will show verbose messages to stderr
when $LIBASOUND_DEBUG is set.


Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-04-14 16:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-10  6:16 [PATCH] pmac: sound support for latest laptops Benjamin Herrenschmidt
2005-04-10  8:37 ` Antonio-M. Corbi Bellot
2005-04-11 14:46 ` Takashi Iwai
2005-04-11 15:07 ` Johannes Berg
2005-04-11 15:21   ` Takashi Iwai
2005-04-12  0:04   ` Benjamin Herrenschmidt
2005-04-14 12:55 ` Johannes Berg
2005-04-14 13:15   ` Benjamin Herrenschmidt
2005-04-14 13:20     ` Johannes Berg
2005-04-14 16:18     ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).