Skip to contentSkip to conversation

CS4232 SBpro

DISCUSSION Ryan Underwood 2 participants 3 messages Jul 5, 2005 – Jul 10, 2005

lore
Share & tools
lore
#0 lore raw

I'm looking at adding support for the SBPro that is part of CS4232+ as a separate pcm device. This device is mutually exclusive with the CS4231/6 component; its IRQ, DMA, and mixer settings are shared, and according to the datasheet, using the SBPro registers after the CS4231 registers should be transparent. So because of the shared resources, an open on SBPro while CS4231 is in use should return -EBUSY, and vice versa. Also, an interrupt should only be handled by the driver of the currently open device.

I created a new hwdep device for CS4232 in sb8. I have thought about a few approaches to managing user access and interrupts and wonder which one is better:

- Use a spinlock as a flag in *_open fops to prevent CS4232 or sb8 from concurrent opens. Both interrupt handlers are registered, but a check against the owner of the lock is made. Disadvantage: wasted invocation of the unused handler. Question: where do I store the lock - add on to the cs4232 card object?

- Every time the pcm is opened, call request_irq() to register the currently opened device's interrupt handler. Every time the pcm is closed, call free_irq(). Disadvantage: slower opens and closes.
Question: can anything strange happen when doing this? Maybe plugging a Cardbus card while sound is not in use takes the IRQ away?

- Instead of trying to share two independent drivers, implement a /proc/asound flag for CS4231 driver that switches between the two internally. Depending on the state of the flag, CS4231 fops and interrupts are redirected to SB8 functions. Disadvantage: Makes cs4231_lib dependent on sb8... unless it is possible to instead create proxy fops and interrupt functions in cs4232/6, and call out to cs4231_lib or sb8 appropriately.

You might ask why bother with this because the WSS component is a superset of the SBPro: occasionally the WSS component of my CS4232 stops working (I believe it is a hardware problem), but the SBPro component continues to work. I would like to be able to use the SBPro component (as hw:1,0 or /dev/adsp) instead of being forced to power cycle the machine or to manually remove snd-cs4232 modules and load snd-sb8 instead. (It would be possible to load snd-cs4231 and snd-sb8 modules concurrently if the resources were not shared.)

Signature · 8 lines
Ryan Underwood, <[email protected]>


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
#1 lore raw

At Mon, 4 Jul 2005 21:33:13 -0500,

Quoted 27 lines · Ryan Underwood

I'm looking at adding support for the SBPro that is part of CS4232+ as a separate pcm device. This device is mutually exclusive with the CS4231/6 component; its IRQ, DMA, and mixer settings are shared, and according to the datasheet, using the SBPro registers after the CS4231 registers should be transparent. So because of the shared resources, an open on SBPro while CS4231 is in use should return -EBUSY, and vice versa. Also, an interrupt should only be handled by the driver of the currently open device.

I created a new hwdep device for CS4232 in sb8. I have thought about a few approaches to managing user access and interrupts and wonder which one is better:

- Use a spinlock as a flag in *_open fops to prevent CS4232 or sb8 from concurrent opens. Both interrupt handlers are registered, but a check against the owner of the lock is made. Disadvantage: wasted invocation of the unused handler. Question: where do I store the lock - add on to the cs4232 card object?

- Every time the pcm is opened, call request_irq() to register the currently opened device's interrupt handler. Every time the pcm is closed, call free_irq(). Disadvantage: slower opens and closes.
Question: can anything strange happen when doing this? Maybe plugging a Cardbus card while sound is not in use takes the IRQ away?

Quoted 7 lines

- Instead of trying to share two independent drivers, implement a /proc/asound flag for CS4231 driver that switches between the two internally. Depending on the state of the flag, CS4231 fops and interrupts are redirected to SB8 functions. Disadvantage: Makes cs4231_lib dependent on sb8... unless it is possible to instead create proxy fops and interrupt functions in cs4232/6, and call out to cs4231_lib or sb8 appropriately.

You can create a skeleton irq handler in the top-level driver which calls either snd_cs4231_interrupt() or snd_sb8dsp_interrupt() according to the current mode.

To avoid to use snd_cs4231_interrupt(), pass CS4231_HWSHARE_IRQ to snd_cs4231_create(), and do request_irq() by yourself in the top-level.

Takashi

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click

#2 lore raw
Quoted 7 lines · Takashi Iwai

You can create a skeleton irq handler in the top-level driver which calls either snd_cs4231_interrupt() or snd_sb8dsp_interrupt() according to the current mode.

To avoid to use snd_cs4231_interrupt(), pass CS4231_HWSHARE_IRQ to snd_cs4231_create(), and do request_irq() by yourself in the top-level.

I didn't see your message, but this is exactly what I did after several other futile efforts. I'm glad that I'm on the right track.

Unfortunately, I'm having other hardware problems that hopefully someone with a CS4232 can replicate.

1) Load snd-cs4232. Play some wav file with aplay. Success.
2) rmmod snd-cs4232, load snd-sb8. Play some wav file with aplay. Success.
3) rmmod snd-sb8, load snd-cs4232. Play some wav file with aplay.

Unfortunately, the last one doesn't work; no playback IRQ is generated, and eventually pcm layer quits with EIO. If you play around with the CS4231 registers at that point, you will find that no changes can be made to the registers - they are "stuck" - but this condition *only* occurs after doing some DMA operation with the CS4232 in SB emulation mode. However, you can then load back up snd-sb8 and the SB emulation continues to work.

How *not* to run into the problem:

If the snd-cs4232 driver has just played something, and I poke the SB registers to reset the SB emulation, then no problem occurs.

Also, I can *load* snd-sb8, and then immediately unload it, and then load snd-cs4232 and play a sound, and it works fine. So nothing in the SB reset/detection seems to create the problem.

After anything is *played* with snd-sb8 (and AFAIK, sb8 doesn't have a PIO playback mode so there's no way to check if it's only the fault of DMA), the WSS/CS4231 component is stuck until reset.

One might theorize that maybe CS4232 wasn't meant to be used in this way even though the databook claims it can be, but it seems to be the same issue if it was in DOS/Windows, and a SB program was used in DOS before Windows is started where the WSS is used.

Maybe there's a reset procedure for the WSS that I'm missing? I see nothing in the CS4231/2 databook (or in AD1848K databook) about it, except for an external reset pin. I guess this pin is held by the BIOS through some proprietary port when the system reboots, to explain why the chip is "alive" again after a warm-reboot.

Anyway, can someone test this above test-case on a CS4232 and tell me what happens, so I know it's not just my broken hardware? Also if possible, test it on CS4235+ and check X30 register, which will give the current context. I hope that any register write to SB puts CWSS to 0, and any register write to WSS puts CWSS to 1. Otherwise, there is probably some reset procedure necessary which I'm missing.

Signature · 8 lines
Ryan Underwood, <[email protected]>


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP, 
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar