PDA

View Full Version : 5.0.1 CD sound config sometimes confused after boot



zsd
07-03-2006, 11:44 PM
Hi,

I have a Dell D600 with an Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 01). Normally when I boot the 5.0.1 CD the soundcard is correctly detected and configured.

However, if I boot while I have a USB webcam (046d:08b1 Logitech, Inc. QuickCam Notebook Pro, this webcam has a built in MIC) plugged in, and also an Edirol USB-MIDI converter plugged in, on occasion the sound does not get configured correctly and no startup sound is played, and "wavp" is unable to play a sound.

When this happens, rather than the Intel sound card being registered as card0, the USB audio driver gets registered as card0. Whether this is cause or effect of the sound output problems I dunno, but I'm guessing cause.

I am creating a CD for non-technies to use, and I don't want to confuse them by telling them not to plug in their USB devices until after booting is complete.

Does anyone have a suggestion as to how I can coax the boot process into always picking the built-in sound card to be card0? (I can't really tie this to the Intel sound card specifically, since the CD will be used on other computers as well.)

Thanks.

Jim

zsd
07-07-2006, 05:47 PM
Well, I've come across enough of the answer to kludge a solution, so I'll write this up in case anyone else cares about it in the future.

knoppix-autoconfig calls /etc/init.d/udev start (unless you told it not to).

udev calls /sbin/udevsynthesize to generate events for files matching /sys/bus/*/devices/*/uevent
/sys/class/*/*/uevent
/sys/block/*/uevent
/sys/block/*/*/uevent

Among those are a device in /sys/bus/pci/devices/ corresponding to my PCI sound card
and devices in /sys/bus/usb/devices/ corresponding to the USB audio devices I have
plugged in.

Each device is registered in quick succession by writing "add" to that file, which
(presumably) makes udev take notice of the device and load drivers. A "queue" is formed in a (temporary) directory /dev/.udev/queue and as events are processed the files
are removed from this directory.

Unfortunately, "queue" is a mis-nomer, and events are not always handled in the order
in which they are generated. Consequently, on occasion, the PCI sound card is not
dealt with first, and one of the USB devices gets to be sound card 0, which is a Bad Thing
in this case.

I have a workaround which I think is horrible and ugly, but it seems to work, and thus it
has some virtue. Here it is for anyone wanting to use it. The first change was my first
attempt and did not work by itself, possibly I could remove it.

The queue size of 3 below was chosen after a few tests, there is no scientific basis to it.

Cheers.

Jim




# Jim Diamond mod #1... list the USB devices last, so that PCI sound card events
# come as much before USB audio devices as possible
for file in /sys/bus/[A-Za-tv-z]*/devices/uevent /sys/class/*/*/uevent \
/sys/block/*/uevent /sys/block/*/*/uevent \
/sys/bus/u*/devices/*/uevent ; do
case "$file" in
*/device/uevent) ;; # skip followed device symlinks
*/\*/*) ;;

*/class/mem/*) # for /dev/null
first="$first${IFS}$file" ;;

*/block/md[0-9]*)
last="$last${IFS}$file" ;;

*)
default="$default${IFS}$file" ;;
esac
done

# Jim Diamond mod #2: also don't let the queue get too full, else the USB devices
# may still get registered as sound card 0.
# 3 is a number seen to work in a number of tests; if too big, the USB device might
# get card0, if too small there will be too many sleeps, slowing down the whole process.
for file in $first${IFS}$default${IFS}$last; do
[ "$file" ] || continue
# echo "sending 'add' to $file"
# lsmod | /usr/bin/head -8
# echo =========================================
echo 'add' > "$file" || true
if [ `ls -1 /dev/.udev/queue | /usr/bin/wc -l` -gt 3 ]
then
# echo "sleeping for a second because queue has more than 3 items"
sleep 1
else
# echo "not sleeping for a second"
:
fi
done