Wednesday 25 August 2010

ALSA drivers not working for Cirrus Logic CS46xx soundcard

If you are using OSS emulation for ALSA on a laptop with a CS46xx card, and are getting no sound, then read on.

I use a really old laptop (Ascentia M-Series dating from 1998) that I carry about in places where I think anything nicer would get stolen/drowned in spilled tea/rolled over by a forklift. One thing that has long annoyed me about this laptop though, is that the sound doesn't work. Things would appear to be working, mplayer would claim it was playing .mp3 files, but no sound would come out.

The sound card is a cirrus logic CS4624B, and everyone says that these are a pig to get working, requiring lots of meddling with old-style Plug-and-Pray settings because, in these old laptops, the soundcard is on an isa bus.

Funny thing is though, that back in the day when I used OSS for sound, rather than ALSA, the soundcard worked fine. Why would ALSA suddenly have irq or resource issues that require me to mess with isapnp, when OSS didn't?

In the end, the problem turned out to have nothing to do with irq's, io-ports or plug-and-play. Basically there is a bug in ALSA. For these cards, ALSA sets everything to 'Mute' by default. This doesn't mean it sets the sound level to zero, it seems to be more than that, it actually does some magic 'mute' thing to the card that you have to unlock. Unfortunately, the OSS compatibility module that makes the sound-card visible to programs that use the old OSS interface, doesn't know how to mute/unmute, so the card stays muted no matter what you do.
Or it might not be the mute, it might be the fact that one of the volume controls 'Master' doesn't appear to be exported to the OSS emulation, under ALSA volume control programs you see the 'Master' setting, but under OSS volume controls, you don't.

The only solution I've found is to install the alsa libraries, and use 'alsamixer' to initially set up the card and volume levels. Suddenly BINGO! It works! No need to meddle with irq's and isapnp.conf.

However, I didn't really want to install the ALSA libraries, that's why I'm using OSS emulation. But, more and more these days Linux is becoming another O.S. of you-will-do-as-we-say. IF you want to use software X, you will install lots of libraries and now you're going to have to upgrade your computer. If I have to upgrade my computer, then why not just put windows on it or get a mac and be done with it, hmmm??

Wednesday 2 June 2010

M. T. Urself

So, I had a server that was misbehaving in a truely weird way. I was accessing this server via and ADSL line, connecting into it using Secure Shell. Any large amount of data pulled from it caused the network connection to drop. But I could push as much data to it as I liked. Huge uploads worked fine, but downloads would get me disconnected instantly. Logging in and typing 'ps ax' would normally only get me half the page of output before the connection froze up. Also, anything that posted information to websites, like logging into googlemail for instance, seemed to freeze as well.

I tried altering the firewall, the router, the routing table on the server, recompiling the kernel, etc, etc, all to no avail. After each new attempt the problem would seem to go away, cruely making me think I'd fixed it, before returning again.

Now, often in the past when there's been network problems, some old unix-hacker with open-toed sandals and a grateful-dead t-shirt has been around to say; "You know man, could it be, like, the MTU?"

The MTU. That thing they had on modems, remember? No, I don't suppose you would.

Friday 16 April 2010

Quick and Dirty Webcam monitoring

Just thought I'd mention a very quick and dirty way to get 'webcam monitoring' going. I've done this with axis webcams, but it should work with any webcam that allows you to fetch a jpeg image from a url.

This will, of course, be working under linux. It's only using the standard 'Borne' shell and a program called 'links' so it should work under FreeBSD and Mac OSX too.

The command-line webbrowser, 'links' has an option called -'-source'. This has the effect that a webpage or item fetched using http with links is written in raw format to stdout. So

links -source http://media.libsyn.com/media/djsteveboy/the_swing_set.mp3 > TheSwingSet.mp3

Will download the example .mp3 file.

Most axis webcams allow you to download an image from http://<webcamip>/axis-cgi/jpg/image.cgi, so we can use links to Grab an image thusly:

links -source http://192.168.5.4:1000/axis-cgi/jpg/image.cgi > snapshot.jpg

Of course, what's best is to get images every couple of seconds and put them into a date/timestamped file. Here's the script I've been using, it creates directories for each hour of a day, and puts timestamped .jpg files in them.


#! /bin/sh

cd /home/Public/AxisWebcam

while [ 1 = 1 ]
do

DIR=`date "+%d_%m_%Y_Hour-%H"`
FILE=`date "+%H_%M_%S.jpg"`

mkdir $DIR
links -source http://192.168.5.4:1000/axis-cgi/jpg/image.cgi > $DIR/$FILE

sleep 2

done


One issue is that links doesn't have any way (that I know of) of expressing a username/password to access a website. Fortunately, Axis cameras have a setup option under 'Setup->Users' called 'Enable anonymous viewer login'. This allows access to the image without having to supply a username and password.


If you're going to leave this script running, you may want to periodically run a command like:

find -mtime +7 -exec rm -f {} \;

This command will delete any files older than a week.

And that's it!

Tuesday 9 March 2010

Slow boot due to libata problems with mwdma2

I use a lot of old kit. Recent linux kernels are starting to have problems with old kit. An old laptop harddrive suddenly started to 'freeze' during bootup. The kernel was trying to access it with various DMA modes, none of which seemed to work. Finally it would fall back to PIO, and work, but this was annoying, because it meant the laptop took ages to boot.

I'm attaching a dump of what the kernel spewed out while it was trying to talk to the hard-drive. The main thing to look for if you have the same problem is:

[ 23.107017] ata2: soft resetting link
[ 23.259250] ata2.00: configured for MWDMA1