cs4248 / thinkpad 755 / 755c , patch suggestions [PATCH]]
Hi Takashi,
Quoted 10 lines · Takashi Iwai
At Wed, 2 Jul 2003 15:29:55 -0500,
Quoted 5 lines · Ryan Underwood
1) What is ALSA's policy on module options? For example, would it be okay to add an option like "thinkpad" to the ad1848 module, so that inserting it with "thinkpad=1" would cause the necessary ports to be prodded?
this looks like a feasible solution.
Quoted 7 lines
Quoted 4 lines
2) Since the chip's power mode can be controlled through a write to that port (bit 2 on, cs4248 power on; bit 2 off, cs4248 power off), would it be a good idea to add the
_suspend,_resume, and_set_power_statefunctions within a #ifdefCONFIG_PMblock, like in other drivers?yep. we haven't done that just becase of lack of hardware. if you can write and test it, it would be greatly appreciated.
I have attached a patch against the ALSA 0.94. ad1848.c, ad1848_lib.c, and ad1848.h have changed.
I tested the module against 2.4.21 on a Debian system, gcc 3.3 and it works fine; simply set the proper resources and thinkpad=1 and the thinkpad works.
One issue is to note, I don't know if this is a problem with the ad1848 driver in general or what; if I cat a 11025hz mono 8-bit file to/dev/dsp, the sound comes out verrrrry slllloooowwwllly. But using
aplay, it works fine.
I am not sure the best way to test the power managmeent code -- it doesn't crash the machine at least. ;)
I added a note to the ALSA wiki about this option. I tried to fix the OSS driver too but it does some other weird things like not allowing a IRQ > 7 to be used. (It thinks the CS4248 is an 8bit card or something). So this will have to be an alsa-only fix for now at least.
Let me know if the patch is ok,
Signature · 1 line
Ryan Underwood, <nemesis at icequake.net>, icq=10317253
alsa-kernel/include/ad1848.h +10 -1
@@ -121,6 +121,11 @@#define AD1848_HW_CS4248 0x0003/* CS4248 chip */ #define AD1848_HW_CMI8330 0x0004/* CMI8330 chip */ +/* IBM Thinkpad specific stuff */ +#define AD1848_THINKPAD_CTL_PORT1 0x15e8 +#define AD1848_THINKPAD_CTL_PORT2 0x15e9 +#define AD1848_THINKPAD_CS4248_ENABLE_BIT 0x02 +struct _snd_ad1848 {unsigned long port;/* i/o port */ struct resource *res_port;
@@ -140,6 +145,10 @@int mce_bit;int calibrate_mute;int dma_size; +int thinkpad_flag;/* Thinkpad CS4248 needs some extra help */ +#ifdef CONFIG_PM +struct pm_dev *thinkpad_pmstate; +#endif spinlock_t reg_lock;struct semaphore open_mutex;
@@ -157,7 +166,7 @@int snd_ad1848_create (snd_card_t * card,unsigned long port, -int irq,int dma, +int irq,int dma,int thinkpad,unsigned short hardware,ad1848_t ** chip);
alsa-kernel/isa/ad1848/ad1848.c +11 -1
@@ -46,6 +46,7 @@static long port[SNDRV_CARDS ] =SNDRV_DEFAULT_PORT ;/* PnP setup */ static int irq[SNDRV_CARDS ] =SNDRV_DEFAULT_IRQ ;/* 5,7,9,11,12,15 */ static int dma1[SNDRV_CARDS ] =SNDRV_DEFAULT_DMA ;/* 0,1,3,5,6,7 */ +static int thinkpad[SNDRV_CARDS ];/* Thinkpad special case */ MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");MODULE_PARM_DESC (index,"Index value for AD1848 soundcard." );
@@ -65,6 +66,9 @@ MODULE_PARM(dma1, "1-" __MODULE_STRING(SNDRV_CARDS) "i");MODULE_PARM_DESC (dma1,"DMA1 # for AD1848 driver." );MODULE_PARM_SYNTAX (dma1,SNDRV_DMA_DESC ); +MODULE_PARM(thinkpad, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +MODULE_PARM_DESC (thinkpad,"Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series." ); +MODULE_PARM_SYNTAX (thinkpad,SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC );static snd_card_t *snd_ad1848_cards[SNDRV_CARDS ] =SNDRV_DEFAULT_PTR ;
@@ -96,6 +100,7 @@if ((err =snd_ad1848_create (card, port[dev], irq[dev], dma1[dev], + thinkpad[dev],AD1848_HW_DETECT , &chip)) <0 ) {snd_card_free (card);
@@ -116,6 +121,10 @@sprintf (card->longname,"%s at 0x%lx, irq %d, dma %d" , pcm->name, chip->port, irq[dev], dma1[dev]); +if (thinkpad[dev]) { +strcat (card->longname," [Thinkpad]" ); + } +if ((err =snd_card_register (card)) <0 ) {snd_card_free (card);return err;
@@ -168,7 +177,8 @@get_id (&str,&id[nr_dev]) ==2 &&get_option (&str,(int *)&port[nr_dev]) ==2 &&get_option (&str,&irq[nr_dev]) ==2 && - get_option(&str,&dma1[nr_dev]) == 2); +get_option (&str,&dma1[nr_dev]) ==2 && + get_option(&str,&thinkpad[nr_dev]) == 2); nr_dev++;return 1 ; }
alsa-kernel/isa/ad1848/ad1848_lib.c +107 -1
132 lines not on this page · raw message
At Mon, 7 Jul 2003 15:53:57 -0500,
Quoted 19 lines · Ryan Underwood
Hi Takashi,
Quoted 15 lines · Takashi Iwai
At Wed, 2 Jul 2003 15:29:55 -0500,
Quoted 5 lines · Ryan Underwood
1) What is ALSA's policy on module options? For example, would it be okay to add an option like "thinkpad" to the ad1848 module, so that inserting it with "thinkpad=1" would cause the necessary ports to be prodded?
this looks like a feasible solution.
Quoted 4 lines
2) Since the chip's power mode can be controlled through a write to that port (bit 2 on, cs4248 power on; bit 2 off, cs4248 power off), would it be a good idea to add the
_suspend,_resume, and_set_power_statefunctions within a #ifdefCONFIG_PMblock, like in other drivers?
Quoted 5 lines
Quoted 2 lines
yep. we haven't done that just becase of lack of hardware. if you can write and test it, it would be greatly appreciated.
I have attached a patch against the ALSA 0.94.
ad1848.c,ad1848_lib.c, andad1848.hhave changed.
thanks!
i applied the patch to cvs with a small modification. instead of adding a new argument, i created a new hardware type AD1848_HW_THINKPAD, so that the function call is kept compatible.
Quoted 4 lines
One issue is to note, I don't know if this is a problem with the ad1848 driver in general or what; if I cat a 11025hz mono 8-bit file to
/dev/dsp, the sound comes out verrrrry slllloooowwwllly. But using
aplay, it works fine.
could you check the parameters in /proc/asound/card0/pcm0p/sub0/* during playback via oss?
Quoted 2 lines
I am not sure the best way to test the power managmeent code -- it doesn't crash the machine at least. ;)
it looks ok - but i guess we need to restore the registers (mixer status, etc) too.
Takashi
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
Hi Takashi,
Quoted 8 lines · Takashi Iwai
Quoted 5 lines
One issue is to note, I don't know if this is a problem with the ad1848 driver in general or what; if I cat a 11025hz mono 8-bit file to
/dev/dsp, the sound comes out verrrrry slllloooowwwllly. But using
aplay, it works fine.could you check the parameters in
/proc/asound/card0/pcm0p/sub0/*during playback via oss?
The results are pasted below -- what is strange is that aplay identifies the file as 11025Hz but apparently the OSS driver thinks it is 8000Hz data.
Quoted 5 lines
Quoted 2 lines
I am not sure the best way to test the power managmeent code -- it doesn't crash the machine at least. ;)
it looks ok - but i guess we need to restore the registers (mixer status, etc) too.
You are right -- I just checked the registers before and after flipping that bit, and it seems they are set to default values afterwards, which would seem to support the possibility that this is a power management feature.
The main thing I was wondering about is if some other machine with a AD1848 goes into D0 for instance, and the suspend function does nothing (since it is not a thinkpad), is the system still in an ok state as long as the card's status is not set to D0 when the card is actually not in D0? Does that make sense?
---------------------------------------------------------------------
<start of playback>
$ cat /proc/asound/card0/pcm0p/sub0/* no setup card: 0 device: 0 subdevice: 0 stream: PLAYBACK id: AD1848 name: CS4248 subname: subdevice #0 class: 0 subclass: 0 subdevices_count: 1 subdevices_avail: 0 64 state: OPEN trigger_time: -1061273892.-1072503897 tstamp : -1071322800.-1071322416 delay : -1056799360 avail : -1056014772 avail_max : 3747840 ----- hw_ptr : 0 appl_ptr : 0 no setup
<little later in playback>
$ cat /proc/asound/card0/pcm0p/sub0/* access: RW_INTERLEAVED format: U8 subformat: STD channels: 1 rate: 8000 (8000/1) period_size: 4096 buffer_size: 65536 tick_time: 10000 OSS format: U8 OSS channels: 1 OSS rate: 8000 OSS period bytes: 4096 OSS periods: 16 card: 0 device: 0 subdevice: 0 stream: PLAYBACK id: AD1848 name: CS4248 subname: subdevice #0 class: 0 subclass: 0 subdevices_count: 1 subdevices_avail: 0 64 state: DRAINING trigger_time: 1057672530.000584530 tstamp : 1057672533.000162630 delay : 8029 avail : 57507 avail_max : 61467 ----- hw_ptr : 20643 appl_ptr : 28672 tstamp_mode: NONE period_step: 1 sleep_min: 0 avail_min: 4096 xfer_align: 1 start_threshold: 1 stop_threshold: 65536 silence_threshold: 0 silence_size: 0 boundary: 1073741824
Signature · 8 lines
Ryan Underwood, <nemesis at icequake.net>, icq=10317253 ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
At Tue, 8 Jul 2003 08:58:21 -0500,
Quoted 11 lines · Ryan Underwood
Hi Takashi,
Quoted 6 lines · Takashi Iwai
Quoted 5 lines
One issue is to note, I don't know if this is a problem with the ad1848 driver in general or what; if I cat a 11025hz mono 8-bit file to
/dev/dsp, the sound comes out verrrrry slllloooowwwllly. But using
aplay, it works fine.
Quoted 6 lines
Quoted 2 lines
could you check the parameters in
/proc/asound/card0/pcm0p/sub0/*during playback via oss?The results are pasted below -- what is strange is that aplay identifies the file as 11025Hz but apparently the OSS driver thinks it is 8000Hz data.
ah, i understand. you cannot cat to /dev/dsp in general. if you do this, it's supposed to be 8kHz mono samples.
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
I am not sure the best way to test the power managmeent code -- it doesn't crash the machine at least. ;)
it looks ok - but i guess we need to restore the registers (mixer status, etc) too.
You are right -- I just checked the registers before and after flipping that bit, and it seems they are set to default values afterwards, which would seem to support the possibility that this is a power management feature.
Quoted 5 lines
The main thing I was wondering about is if some other machine with a AD1848 goes into D0 for instance, and the suspend function does nothing (since it is not a thinkpad), is the system still in an ok state as long as the card's status is not set to D0 when the card is actually not in D0? Does that make sense?
if the chip supports really something the power management, we should implement it, too. but AFAIK, ad1848 itself has no such a control. so, the suspend callback is expected just to save the last status so that it can be restored in the resume callback.
Takashi
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps
Hi Takashi,
Quoted 6 lines · Takashi Iwai
Quoted 3 lines
The results are pasted below -- what is strange is that aplay identifies the file as 11025Hz but apparently the OSS driver thinks it is 8000Hz data.
ah, i understand. you cannot cat to
/dev/dspin general. if you do this, it's supposed to be 8kHz mono samples.
Hmm, limitation of the ad1848 driver, of ALSA OSS emulation, or OSS API?
Quoted 9 lines
Quoted 4 lines
AD1848 goes into D0 for instance, and the suspend function does nothing (since it is not a thinkpad), is the system still in an ok state as long as the card's status is not set to D0 when the card is actually not in D0? Does that make sense?
if the chip supports really something the power management, we should implement it, too. but AFAIK, ad1848 itself has no such a control. so, the suspend callback is expected just to save the last status so that it can be restored in the resume callback.
Ok, will see about doing that in some time.
Signature · 8 lines
Ryan Underwood, <nemesis at icequake.net>, icq=10317253 ------------------------------------------------------- This SF.Net email sponsored by: Parasoft Error proof Web apps, automate testing & more. Download & eval WebKing and get a free book. www.parasoft.com/bulletproofapps
At Tue, 8 Jul 2003 12:32:29 -0500,
Quoted 5 lines · Ryan Underwood
Hi Takashi,
On Tue, Jul 08, 2003 at 07:27:06PM +0200, Takashi Iwai wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
The results are pasted below -- what is strange is that aplay identifies the file as 11025Hz but apparently the OSS driver thinks it is 8000Hz data.
ah, i understand. you cannot cat to
/dev/dspin general. if you do this, it's supposed to be 8kHz mono samples.Hmm, limitation of the ad1848 driver, of ALSA OSS emulation, or OSS API?
IIRC, it's the definition of this OSS device.
well, i'm not sure this is officially so.
but at least, /dev/audio is supposed to be in these formats, and we initialize /dev/dsp as well.
btw, for testing the OSS emulation, you can try play command included in sox package.
Takashi
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps
Hi Takashi,
Quoted 10 lines · Takashi Iwai
Quoted 9 lines · Takashi Iwai
Quoted 6 lines
Quoted 3 lines
The results are pasted below -- what is strange is that aplay identifies the file as 11025Hz but apparently the OSS driver thinks it is 8000Hz data.
ah, i understand. you cannot cat to
/dev/dspin general. if you do this, it's supposed to be 8kHz mono samples.Hmm, limitation of the ad1848 driver, of ALSA OSS emulation, or OSS API?
Quoted 7 lines
IIRC, it's the definition of this OSS device.
well, i'm not sure this is officially so.
but at least,/dev/audiois supposed to be in these formats, and we initialize/dev/dspas well.btw, for testing the OSS emulation, you can try play command included in sox package.
You are correct, play works correctly but catting does not. It seems, however, that many OSS drivers support cat a wav file directly to /dev/dsp, and do the detection of the format parameters internally. I guess this is not required by the OSS specification?
Signature · 8 lines
Ryan Underwood, <nemesis at icequake.net>, icq=10317253 ------------------------------------------------------- This SF.Net email sponsored by: Parasoft Error proof Web apps, automate testing & more. Download & eval WebKing and get a free book. www.parasoft.com/bulletproofapps
At Tue, 8 Jul 2003 14:54:37 -0500,
Quoted 20 lines · Ryan Underwood
Hi Takashi,
Quoted 15 lines · Takashi Iwai
Quoted 9 lines · Takashi Iwai
Quoted 6 lines
Quoted 3 lines
The results are pasted below -- what is strange is that aplay identifies the file as 11025Hz but apparently the OSS driver thinks it is 8000Hz data.
ah, i understand. you cannot cat to
/dev/dspin general. if you do this, it's supposed to be 8kHz mono samples.Hmm, limitation of the ad1848 driver, of ALSA OSS emulation, or OSS API?
IIRC, it's the definition of this OSS device.
well, i'm not sure this is officially so.
but at least,/dev/audiois supposed to be in these formats, and we initialize/dev/dspas well.
Quoted 7 lines
Quoted 2 lines
btw, for testing the OSS emulation, you can try play command included in sox package.
You are correct, play works correctly but catting does not. It seems, however, that many OSS drivers support cat a wav file directly to
/dev/dsp, and do the detection of the format parameters internally. I guess this is not required by the OSS specification?
really do _many_ oss drivers support these features? i've never thought of that...
Takashi
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft Error proof Web apps, automate testing & more. Download & eval WebKing and get a free book. www.parasoft.com/bulletproofapps
Hi,
Quoted 8 lines · Takashi Iwai
Quoted 5 lines
You are correct, play works correctly but catting does not. It seems, however, that many OSS drivers support cat a wav file directly to
/dev/dsp, and do the detection of the format parameters internally. I guess this is not required by the OSS specification?really do _many_ oss drivers support these features? i've never thought of that...
Every one I've used has done so (Aureal Vortex2, CS4614, c-media, etc). I don't know if it's the rule but it seems like fairly common behavior from my experience.
In any case it's really not a big deal, just that ALSA's OSS emulation seems to be divergent from the typical OSS driver's behavior in that regard.
Signature · 8 lines
Ryan Underwood, <nemesis at icequake.net>, icq=10317253 ------------------------------------------------------- This SF.Net email sponsored by: Parasoft Error proof Web apps, automate testing & more. Download & eval WebKing and get a free book. www.parasoft.com/bulletproofapps
Quoted 13 lines · Ryan Underwood
Hi,
Quoted 8 lines · Takashi Iwai
Quoted 5 lines
You are correct, play works correctly but catting does not. It seems, however, that many OSS drivers support cat a wav file directly to
/dev/dsp, and do the detection of the format parameters internally. I guess this is not required by the OSS specification?really do _many_ oss drivers support these features? i've never thought of that...
Quoted 7 lines
Every one I've used has done so (Aureal Vortex2, CS4614, c-media, etc). I don't know if it's the rule but it seems like fairly common behavior from my experience.
In any case it's really not a big deal, just that ALSA's OSS emulation seems to be divergent from the typical OSS driver's behavior in that regard.
Show me a wav header parser code in these drivers. I guess that you are a bit confused. The standard parameters are 8000Hz, mono, 8-bit unsigned (/dev/dsp) or 8000Hz, mono, 16-bit unsigned (/dev/dsp16) or 8000Hz, mono, muLaw (/dev/audio) as far as I work with sound drivers since 1994.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps
Hi Jaroslav,
Quoted 4 lines · Jaroslav Kysela
Show me a wav header parser code in these drivers. I guess that you are a bit confused. The standard parameters are 8000Hz, mono, 8-bit unsigned (
/dev/dsp) or 8000Hz, mono, 16-bit unsigned (/dev/dsp16) or 8000Hz, mono, muLaw (/dev/audio) as far as I work with sound drivers since 1994.
You are correct that I was either confused, or always used 8kHz sound files all the time. I unloaded ALSA and loaded up the old OSS driver to prove you wrong, and only found out that I was wrong instead. :)
Sorry for the confusion,
Signature · 8 lines
Ryan Underwood, <nemesis at icequake.net>, icq=10317253 ------------------------------------------------------- This SF.Net email sponsored by: Parasoft Error proof Web apps, automate testing & more. Download & eval WebKing and get a free book. www.parasoft.com/bulletproofapps
Takashi,
Please amend the previous patch. I forgot breaks in snd_ad1848_thinkpad_twiddle. The behavior would be to always fall through to enabling the device.
Sorry! :)
Signature · 8 lines
Ryan Underwood, <nemesis at icequake.net>, icq=10317253 ------------------------------------------------------- This SF.Net email sponsored by: Parasoft Error proof Web apps, automate testing & more. Download & eval WebKing and get a free book. www.parasoft.com/bulletproofapps
At Tue, 8 Jul 2003 12:01:21 -0500,
Quoted 7 lines · Ryan Underwood
Takashi,
Please amend the previous patch. I forgot breaks in
snd_ad1848_thinkpad_twiddle. The behavior would be to always fall through to enabling the device.
ok fixed.
Takashi
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps