enable sound

Enabling the sound and microphone for Sony Vaio on Ubuntu

After upgrading to Ubuntu 10.04 Lucid Lynx some things started to work out of the box, but the sound and the microphone weren't between them.

Fixing the sound is easy, just install the alsa backport module:

sudo apt-get install linux-backports-modules-alsa

Fixing the microphone is a little bit more complicated. My solution is to patch the alsa-driver which comes with the backports package.

First you'll have to install the packages needed for compiling and then get the sources for the backports package:

sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)
apt-get source linux-backports-modules-alsa-$(uname -r)

Now download the patch file and apply it to the sources:

cd linux-backports-modules-2.6.32-2.6.32/updates/alsa-driver/
wget http://kenjiru.ro/files/enable-internal-microphone.patch
patch -p1 < enable-internal-microphone.patch

If everything goes fine, you can start compiling the sources. The following line will make sure only the driver for your card will be compiled:

./configure --with-cards=hda-intel --enable-dynamic-minors --with-moddir=extra
make

We don't need all the modules, only the one we patched:

sudo mkdir /lib/modules/`uname -r`/extra
sudo cp ./pci/hda/snd-hda-codec-realtek.ko /lib/modules/`uname -r`/extra/

Next you'll have to tell depmod to use the new module instead of the old one:

echo "override snd-hda-codec-realtek * extra" | sudo tee -a /etc/depmod.d/ubuntu.conf > /dev/null
sudo depmod -a

That's it! You'll have to restart to load the new module. You can verify the new module is used by issuing the following command:

$ modinfo snd-hda-codec-realtek
filename:       /lib/modules/2.6.32-22-generic/extra/snd-hda-codec-realtek.ko
description:    Realtek HD-audio codec
license:        GPL
alias:          snd-hda-codec-id:10ec*
srcversion:     4513A8ACA8A682A191E5AE5
depends:        snd-hda-codec,snd
vermagic:       2.6.32-22-generic SMP mod_unload modversions

The filename field should point to the new module.