snd-aoa: g5 tas codec problems
Ok, so now I have it working on the G5 :)
(Patch below)
There are several issues (I would say in addition to what I listed earlier):
- Maybe it's me or maybe it's just too complicated, but I haven't quite
grasped the whole interaction between the soundbus,i2sbus,fabric and codecs... especially initialisation ordering. It would be nice if we could spend some time going through that and simplifying :) It leads to at least one of the problems
- The patch fixes a couple of nits related to having the modules
built-in: soundbus must really be a subsys_initcall() so it's initialized before anybody else, and I've put the soundbus/ dir before the codecs in the link order because the TAS is unhappy if loaded before i2s (see below)
- The TAS is a nasty beast. It needs the i2s clocks enabled or it goes
bunk... That's the problem with the G5. I've added a clock notifier and reset it completely when the clocks come back, that's what fixes the G5 sound (looks like it loses state somewhat when not clocked). It would be nice to streamline/cleanup some of the TAS handling, maybe with register shadows like darwin or just with proper state variables to re-consitute the whole thing and have a "fast mode" load since we need to do it so often
- Because of the above, starting to play a sound 1- takes some time to
init things and 2- clacks (setting the mutes on TAS before losing clocks isn't enough, I think the fact that it goes bonk makes it parasite the analog outputs). We need to also mute the amps around that. I haven't quite figured how to do that from i2sbus though :) Also, we should try (if not already the case) to cache our clock/i2s state so that subsequent prepare() don't try to change things that are already ok. That way we avoid having to blast the codec each time. But right now, the important thing is to add mutes. People with external amplifiers will really not like those clacs...
Note that the patch applies on top of Andreas latest one fixing the irq on latest git.
sound/aoa/soundbus/core.c +1 -1
@@ -246,5 +246,5 @@ }EXPORT_SYMBOL_GPL (soundbus_unregister_driver); -module_init (soundbus_init); +subsys_initcall (soundbus_init);module_exit (soundbus_exit);
arch/powerpc/platforms/powermac/feature.c +1 -0
@@ -2394,6 +2394,7 @@return func (node, param, value); } +EXPORT_SYMBOL_GPL (pmac_do_feature_call);static int __init probe_motherboard (void ) {
sound/aoa/Makefile +2 -2
@@ -1,4 +1,4 @@ obj-$(CONFIG_SND_AOA) += core/ -obj-$(CONFIG_SND_AOA) += codecs/ -obj-$(CONFIG_SND_AOA) += fabrics/ obj-$(CONFIG_SND_AOA_SOUNDBUS) += soundbus/ +obj-$(CONFIG_SND_AOA) += fabrics/ +obj-$(CONFIG_SND_AOA) += codecs/
sound/aoa/codecs/snd-aoa-codec-tas.c +106 -34
269 lines not on this page · raw message
sound/aoa/codecs/snd-aoa-codec-tas.h +8 -0
@@ -44,4 +44,12 @@#define TAS_REG_LEFT_BIQUAD6 0x10#define TAS_REG_RIGHT_BIQUAD6 0x19 +#define TAS_REG_LEFT_LOUDNESS 0x21 +#define TAS_REG_RIGHT_LOUDNESS 0x22 +#define TAS_REG_LEFT_LOUDNESS_GAIN 0x23 +#define TAS_REG_RIGHT_LOUDNESS_GAIN 0x24 + +#define TAS3001_DRC_MAX 0x5f +#define TAS3004_DRC_MAX 0xef +#endif /* __SND_AOA_CODECTASH */
sound/aoa/core/snd-aoa-gpio-pmf.c +11 -3
@@ -14,9 +14,13 @@ static void pmf_gpio_set_##name(struct gpio_runtime *rt, int on)\ { \ struct pmf_args args = { .count = 1, .u[0].v = !on }; \ - \ + int rc; \ + \ if (unlikely(!rt)) return; \ - pmf_call_function(rt->node, #name "-mute", &args); \ + rc = pmf_call_function(rt->node, #name "-mute", &args); \ + if (rc) \ + printk(KERN_WARNING "pmf_gpio_set_" #name \ + " failed, rc: %d\n", rc); \ rt->implementation_private &= ~(1<<bit); \ rt->implementation_private |= (!!on << bit); \ } \
@@ -33,9 +37,13 @@static void pmf_gpio_set_hw_reset (struct gpio_runtime *rt,int on) {struct pmf_args args = { .count =1 , .u[0 ].v = !!on }; +int rc;if (unlikely (!rt))return ; -pmf_call_function (rt->node,"hw-reset" , &args); + rc =pmf_call_function (rt->node,"hw-reset" , &args); +if (rc) +printk (KERN_WARNING "pmf_gpio_set_hw_reset" +" failed, rc: %d\n" , rc); }static void pmf_gpio_all_amps_off (struct gpio_runtime *rt)
sound/aoa/fabrics/snd-aoa-fabric-layout.c +7 -4
@@ -950,11 +950,12 @@ layout_id = (unsigned int *)get_property (sound,"layout-id" ,NULL );if (!layout_id) goto outnodev; -printk (KERN_INFO "snd-aoa-fabric-layout: found bus with layout %d " , *layout_id); +printk (KERN_INFO "snd-aoa-fabric-layout: found bus with layout %d\n" , + *layout_id); layout =find_layout_by_id (*layout_id);if (!layout) { -printk ("(no idea how to handle)\n" ); +printk (KERN_ERR "snd-aoa-fabric-layout: unknown layout\n" ); goto outnodev; }
@@ -972,15 +973,17 @@case 51 :/* PowerBook5,4 */ case 58 :/* Mac Mini */ ldev->gpio.methods = ftr_gpio_methods; +printk (KERN_DEBUG +"snd-aoa-fabric-layout: Using PMF GPIOs\n" );break ;default : ldev->gpio.methods = pmf_gpio_methods; +printk (KERN_DEBUG +"snd-aoa-fabric-layout: Using direct GPIOs\n" ); } ldev->selfptr_headphone.ptr = ldev; ldev->selfptr_lineout.ptr = ldev; sdev->ofdev.dev.driver_data = ldev; - -printk ("(using)\n" );list_add (&ldev->list, &layouts_list); layouts_list_items++;
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Quoted 2 lines · Benjamin Herrenschmidt
Note that the patch applies on top of Andreas latest one fixing the irq on latest git.
Actually, it applies on top of Andres patch, plus my patch fixing the resources on g5, updated to apply on top of latest git:
I'll do a combo patch later (or you can do one if you want)
Ben.
sound/aoa/soundbus/i2sbus/i2sbus-core.c +80 -23
@@ -7,13 +7,16 @@*/ #include <linux/module.h> -#include <asm/macio.h> -#include <asm/dbdma.h> #include <linux/pci.h> #include <linux/interrupt.h> +#include <linux/dma-mapping.h> +#include <sound/driver.h> #include <sound/core.h> -#include <linux/dma-mapping.h> + +#include <asm/macio.h> +#include <asm/dbdma.h> +#include "../soundbus.h" #include "i2sbus.h"
@@ -24,6 +27,12 @@* string that macio puts into the relevant device */ MODULE_ALIAS ("of:Ni2sTi2sC" ); +static int force; +module_param (force, int,0444 ); +MODULE_PARM_DESC (force,"Force loading i2sbus even when" +" no layout-id property is present" ); + +static struct of_device_id i2sbus_match[] = { { .name ="i2s" }, { }
@@ -73,7 +82,7 @@if (i2sdev->intfregs)iounmap (i2sdev->intfregs);if (i2sdev->out.dbdma)iounmap (i2sdev->out.dbdma);if (i2sdev->in.dbdma)iounmap (i2sdev->in.dbdma); -for (i=0 ;i<3 ;i++) +for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++)if (i2sdev->allocated_resource[i])release_and_free_resource (i2sdev->allocated_resource[i]);free_dbdma_descriptor_ring (i2sdev, &i2sdev->out.dbdma_ring);
@@ -101,10 +110,47 @@return IRQ_HANDLED ; } -static int force; -module_param (force, int,0444 ); -MODULE_PARM_DESC (force,"Force loading i2sbus even when" -" no layout-id property is present" ); +/* +* XXX FIXME: We have to test the layout_id's here to get the proper way +* of mapping in various registers, thanks to bugs in Apple device-trees. +* Ideally, that should be handled by the layout fabric but doing so would +* require a little bit of shuffling around +*/ +static int i2sbus_get_and_fixup_rsrc (struct device_node *np,int index, +int layout,struct resource *res) +{ +struct device_node *parent; +int pindex, rc = -ENXIO ; +u32 *reg; + +/* Machines with layout 76 and 36 (K2 based) have a weird device +* tree what we need to special case. +* Normal machines just fetch the resource from the i2s-X node. +* Darwin further divides normal machines into old and new layouts +* with a subtely different code path but that doesn't seem necessary +* in practice, they just bloated it. In addition, even on our K2 +* case the i2s-modem node, if we ever want to handle it, uses the +* normal layout +*/ +if (layout !=76 && layout !=36 ) +return of_address_to_resource (np, index, res); + + parent =of_get_parent (np); + pindex = (index == aoa_resource_i2smmio) ?0 :1 ; + rc =of_address_to_resource (parent, pindex, res); +if (rc) + goto bail; + reg = (u32 *)get_property (np,"reg" ,NULL ); +if (reg ==NULL ) { + rc = -ENXIO ; + goto bail; + } + res->start += reg[index *2 ]; + res->end = res->start + reg[index *2 +1 ] -1 ; + bail: +of_node_put (parent); +return rc; +}/* FIXME: look at device node refcounting */ static int i2sbus_add_dev(struct macio_dev *macio,
@@ -113,7 +159,8 @@ {struct i2sbus_dev *dev;struct device_node *child =NULL , *sound =NULL ; -int i; +struct resource *r; +int i, layout =0 ;static const char *rnames[] = {"i2sbus: %s (control)" ,"i2sbus: %s (tx)" ,"i2sbus: %s (rx)" };
@@ -144,8 +191,9 @@u32 *layout_id; layout_id = (u32 *)get_property (sound,"layout-id" ,NULL );if (layout_id) { + layout = *layout_id;snprintf (dev->sound.modalias,32 , -"sound-layout-%d" , *layout_id); +"sound-layout-%d" , layout); force =1 ; } }
@@ -175,23 +223,32 @@ dev->bus_number = np->name[4 ] -'a' ;INIT_LIST_HEAD (&dev->sound.codec_list); -for (i=0 ;i<3 ;i++) { +for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++) { dev->interrupts[i] =-1 ; -snprintf (dev->rnames[i],sizeof (dev->rnames[i]), rnames[i], np->name); +snprintf (dev->rnames[i],sizeof (dev->rnames[i]), rnames[i], + np->name); } -for (i=0 ;i<3 ;i++) { +for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++) {int irq =irq_of_parse_and_map (np, i);if (request_irq (irq, ints[i],0 , dev->rnames[i], dev)) goto err; dev->interrupts[i] = irq; } -for (i=0 ;i<3 ;i++) { -if (of_address_to_resource (np, i, &dev->resources[i])) +/* Resource handling is problematic as some device-trees contain +* useless crap (ugh ugh ugh). We work around that here by calling +* specific functions for calculating the appropriate resources. +* +* This will all be moved to macio_asic.c at one point +*/ +for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++) { +if (i2sbus_get_and_fixup_rsrc (np,i,layout,&dev->resources[i])) goto err; -/* if only we could use our resource dev->resources[i]... + +/* If only we could use our resource dev->resources[i]... * but request_resource doesn't know about parents and -* contained resources... */ +* contained resources... +*/ dev->allocated_resource[i] = request_mem_region(dev->resources[i].start, dev->resources[i].end -
@@ -203,12 +260,12 @@ } }/* should do sanity checking here about length of them */ - dev->intfregs =ioremap (dev->resources[0 ].start, - dev->resources[0 ].end-dev->resources[0 ].start+1 ); - dev->out.dbdma =ioremap (dev->resources[1 ].start, - dev->resources[1 ].end-dev->resources[1 ].start+1 ); - dev->in.dbdma =ioremap (dev->resources[2 ].start, - dev->resources[2 ].end-dev->resources[2 ].start+1 ); + r = &dev->resources[aoa_resource_i2smmio]; + dev->intfregs =ioremap (r->start, r->end - r->start +1 ); + r = &dev->resources[aoa_resource_txdbdma]; + dev->out.dbdma =ioremap (r->start, r->end - r->start +1 ); + r = &dev->resources[aoa_resource_rxdbdma]; + dev->in.dbdma =ioremap (r->start, r->end - r->start +1 );if (!dev->intfregs || !dev->out.dbdma || !dev->in.dbdma) goto err;
sound/aoa/soundbus/i2sbus/i2sbus.h +13 -5
@@ -7,20 +7,22 @@*/ #ifndef __I2SBUS_H#define __I2SBUS_H -#include <asm/dbdma.h> #include <linux/interrupt.h> -#include <sound/pcm.h> #include <linux/spinlock.h> #include <linux/mutex.h> + +#include <sound/pcm.h> +#include <asm/prom.h> +#include <asm/pmac_feature.h> +#include <asm/dbdma.h> +#include "i2sbus-interface.h" -#include "i2sbus-control.h" #include "../soundbus.h" struct i2sbus_control { -volatile struct i2s_control_regs __iomem *controlregs; -struct resource rsrc;struct list_head list; +struct macio_chip *macio; };#define MAX_DBDMA_COMMANDS 32
@@ -45,6 +47,12 @@volatile struct dbdma_regs __iomem *dbdma; }; +enum { + aoa_resource_i2smmio =0 , + aoa_resource_txdbdma, + aoa_resource_rxdbdma, +}; +struct i2sbus_dev {struct soundbus_dev sound;struct macio_dev *macio;
sound/aoa/soundbus/i2sbus/i2sbus-control.c +34 -39
141 lines not on this page · raw message
sound/aoa/soundbus/i2sbus/i2sbus-control.h deleted +0 -37
@@ -1,37 +0,0 @@ -/* -* i2sbus driver -- bus register definitions -* -* Copyright 2006 Johannes Berg <[email protected]> -* -* GPL v2, can be found in COPYING. -*/ -#ifndef __I2SBUS_CONTROLREGS_H -#define __I2SBUS_CONTROLREGS_H - -/* i2s control registers, at least what we know about them */ - -#define __PAD (m,n) u8 __pad##m[n] -#define _PAD (line, n) __PAD(line, n) -#define PAD (n) _PAD(__LINE__, (n)) -struct i2s_control_regs { - PAD(0x38); -__le32 fcr0;/* 0x38 (unknown) */ -__le32 cell_control;/* 0x3c (fcr1) */ -__le32 fcr2;/* 0x40 (unknown) */ -__le32 fcr3;/* 0x44 (fcr3) */ -__le32 clock_control;/* 0x48 (unknown) */ - PAD(4); -/* total size: 0x50 bytes */ -} __attribute__((__packed__ )); - -#define CTRL_CLOCK_CELL_0_ENABLE (1<<10) -#define CTRL_CLOCK_CLOCK_0_ENABLE (1<<12) -#define CTRL_CLOCK_SWRESET_0 (1<<11) -#define CTRL_CLOCK_INTF_0_ENABLE (1<<13) - -#define CTRL_CLOCK_CELL_1_ENABLE (1<<17) -#define CTRL_CLOCK_CLOCK_1_ENABLE (1<<18) -#define CTRL_CLOCK_SWRESET_1 (1<<19) -#define CTRL_CLOCK_INTF_1_ENABLE (1<<20) - -#endif /* __I2SBUS_CONTROLREGS_H */
sound/aoa/codecs/snd-aoa-codec-tas.c +5 -0
@@ -310,6 +310,7 @@ }MIXER_CONTROL (pcm1,"PCM1" ,0 ); +MIXER_CONTROL (pcm2,"PCM2" ,1 );MIXER_CONTROL (monitor,"Monitor" ,2 ); static int tas_snd_capture_source_info(struct snd_kcontrol *kcontrol,
@@ -507,6 +508,10 @@if (err) goto error; + err =aoa_snd_ctl_add (snd_ctl_new1 (&pcm2_control, tas)); +if (err) + goto error; + err =aoa_snd_ctl_add (snd_ctl_new1 (&monitor_control, tas));if (err) goto error;
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Johannes Berg
maintainerQuoted 1 line · Benjamin Herrenschmidt
I'll do a combo patch later (or you can do one if you want)
Don't, I just made the whole thing a 9 patch series.
johannes
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
Johannes Berg
maintainerQuoted 1 line · Benjamin Herrenschmidt
Ok, so now I have it working on the G5 :)
Great :)
Powerbook woke itself an hour ago, no idea why, sorry for confusing you on irc.
Quoted 5 lines
- Maybe it's me or maybe it's just too complicated, but I haven't quite
grasped the whole interaction between the soundbus,i2sbus,fabric and codecs... especially initialisation ordering. It would be nice if we could spend some time going through that and simplifying :) It leads to at least one of the problems
Yeah, well... I sorta know.
Quoted 5 lines
- The patch fixes a couple of nits related to having the modules
built-in: soundbus must really be asubsys_initcall()so it's initialized before anybody else, and I've put the soundbus/ dir before the codecs in the link order because the TAS is unhappy if loaded before i2s (see below)
Right.
Quoted 8 lines
- The TAS is a nasty beast. It needs the i2s clocks enabled or it goes
bunk... That's the problem with the G5. I've added a clock notifier and reset it completely when the clocks come back, that's what fixes the G5 sound (looks like it loses state somewhat when not clocked). It would be nice to streamline/cleanup some of the TAS handling, maybe with register shadows like darwin or just with proper state variables to re-consitute the whole thing and have a "fast mode" load since we need to do it so often
Ahrg
Quoted 10 lines
- Because of the above, starting to play a sound 1- takes some time to
init things and 2- clacks (setting the mutes on TAS before losing clocks isn't enough, I think the fact that it goes bonk makes it parasite the analog outputs). We need to also mute the amps around that. I haven't quite figured how to do that from i2sbus though :) Also, we should try (if not already the case) to cache our clock/i2s state so that subsequentprepare()don't try to change things that are already ok. That way we avoid having to blast the codec each time. But right now, the important thing is to add mutes. People with external amplifiers will really not like those clacs...
Right. The way I did that with the onyx is that I told the GPIOs to mute all amps from the clock switch callback.
I see you added DRC too, thanks :) I'll take a closer look after breakfast ;)
johannes
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
Quoted 3 lines
I see you added DRC too, thanks :) I'll take a closer look after breakfast ;)
Hehe :) Oh I just added a routine to program it in hardware, not any control to actually change it.
Ben.
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Quoted 3 lines
I see you added DRC too, thanks :) I'll take a closer look after breakfast ;)
Hehe :) Oh I just added a routine to program it in hardware, not any control to actually change it.
Ben.
Johannes Berg
maintainerQuoted 3 lines · Benjamin Herrenschmidt
Also, we should try
(if not already the case) to cache our clock/i2s state so that subsequentprepare()don't try to change things that are already ok.
I do that, the function reads the dws and sfr registers and exits early if they match.
johannes
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
Quoted 7 lines · Johannes Berg
Quoted 3 lines · Benjamin Herrenschmidt
Also, we should try
(if not already the case) to cache our clock/i2s state so that subsequentprepare()don't try to change things that are already ok.I do that, the function reads the dws and sfr registers and exits early if they match.
Ok. Be careful that I've removed the initial init of TAS thinking we always get to clock restart to do it in prepare()... might need to be put back.
Ben.
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Johannes Berg
maintainerQuoted 6 lines · Benjamin Herrenschmidt
Quoted 5 lines · Johannes Berg
Quoted 3 lines · Benjamin Herrenschmidt
Also, we should try
(if not already the case) to cache our clock/i2s state so that subsequentprepare()don't try to change things that are already ok.
Quoted 6 lines
Quoted 2 lines
I do that, the function reads the dws and sfr registers and exits early if they match.
Ok. Be careful that I've removed the initial init of TAS thinking we always get to clock restart to do it in
prepare()... might need to be put back.
Oh yes, we do, wonder why it even worked then since most of the time we'll be using whatever the firmware does (44.1KHz,16bit).
johannes
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel