Search:  
Gentoo Wiki

HOWTO_Logitech_V10_Notebook_Speakers


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Contents

Introduction

This HOWTO is from the Intel HD Audio + Logitech V10 notebook speakers thread from the Gentoo Forums. This article was prepared for those with laptops with the Intel HDA sound chip. The purpose of this article is to utilize Logitech's V10 Notebook Speakers as a hot pluggable device, available on demand when plugged in.

Although this HOWTO was developed with the Logitech V10 in mind, it is not specific to that device. These instructions should work for any device supported by the ALSA usb-audio driver. Other known-compatible devices include the Sound Blaster Live! USB (model SB0490).

Preparing Kernel 2.6

First, set up ALSA using the Gentoo Linux ALSA Guide. You must include kernel support the following ALSA drivers. I suggest building these drivers as modules:

snd-hda-intel
snd-usb-audio

If you're building the modules externally with media-sound/alsa-driver, don't forget to include this line in /etc/make.conf:

ALSA_CARDS="hda-intel usb-audio"

Load ALSA drivers

Configure your sound cards. Since in the V10 speakers are, in essence, a soundcard/speaker combo, you will be configuring for 2 soundcards. I suggest configuring your Intel HDA as card #0. Don't forget to run update-modules if you alter this file.

File: /etc/modprobe.d/alsa
##  ALSA portion
 alias char-major-116 snd
 alias snd-card-0 snd-hda-intel
 alias snd-card-1 snd-usb-audio

##
##  OSS/Free portion
 alias char-major-14 soundcore
 alias sound-slot-0 snd-hda-intel
 alias sound-slot-1 snd-usb-audio

##
## OSS/Free portion - snd-card-0 (Intel HD Audio)
 alias sound-service-0-0 snd-mixer-oss
 alias sound-service-0-1 snd-seq-oss
 alias sound-service-0-3 snd-pcm-oss
 alias sound-service-0-8 snd-seq-oss
 alias sound-service-0-12 snd-pcm-oss

##
## OSS/Free portion - snd-card-1 (Logitech V10 USB speakers)
 alias sound-service-1-0 snd-mixer-oss
 alias sound-service-1-3 snd-pcm-oss
 alias sound-service-1-12 snd-pcm-oss

 alias /dev/mixer snd-mixer-oss
 alias /dev/dsp snd-pcm-oss
 alias /dev/midi snd-seq-oss

##
## Set this to the correct number of cards.
 options snd cards_limit=2
 options snd-hda-intel index=0
 options snd-usb-audio index=1

Configure output

Since each user's .asoundrc file is overwritten as the USB device is added/removed, configuring /etc/asound.conf with the devices at the global level seems logical. This also prevents these settings from being tampered with by regular users.

Here, both devices are configured to use dmix.

File: /etc/asound.conf
pcm.hda-intel-hw {
        type hw
        card 0
}

pcm.hda-intel {
        type dmix
        ipc_key 1234
        ipc_perm 0660
        slave {
                pcm "hw:0,0"
                channels 2
                period_size 1024
                buffer_size 4096
                rate 44100
                period_time 0
        }
        bindings {
                0 0
                1 1
        }
}

ctl.hda-intel-hw {
        type hw
        card 0
}

pcm.usb-audio-hw {
        type hw
        card 1
}

pcm.usb-audio {
        type dmix
        ipc_key 4321
        ipc_perm 0660
        slave {
                pcm "hw:1,0"
                channels 2
                period_size 1024
                buffer_size 4096
                rate 44100
                period_time 0
        }
        bindings {
                0 0
                1 1
        }
}

ctl.usb-audio-hw {
        type hw
        card 1
}

Create hotplug script

You will need to create the following file (as well as the directory it will reside in). The file must end with the extension dev and can be named anything. This will script will execute on hotplug events so make sure it is executable (chmod +x /etc/dev.d/sound/alsa-device.dev).

This will create/update each user's .asoundrc file to reflect which device is in use. It will also update each user's .openalrc file with the correct device, for OpenAL library compatibility.

File: /etc/dev.d/sound/alsa-device.dev
#!/bin/sh
#
# Script to ensure USB Audio device is hotplugable.
#

#
# Default sound device
#
# $DEFAULT = the card number of your default device ('cat /proc/asound/cards')
# $DEFAULT_NAME = the name of your default device (from /etc/asound.conf)
#
DEFAULT=0
DEFAULT_NAME="hda-intel"

#
# USB sound device
#
# $USB_AUDIO = the card number of your usb device ('cat /proc/asound/cards')
# $USB_AUDIO_NAME = the name of your usb device (from /etc/asound.conf)
#
USB_AUDIO=1
USB_AUDIO_NAME="usb-audio"

#
# Where are your user home directories? This variable will allow script to write
# to /$DIR/$USER/.asoundrc
#
DIRS=`ls /home`

# If USB-Audio card does not exist, this will be an empty value
# thus defaulting to Intel HDA
CARD_EXISTS=`grep -o -e 'USB-Audio' < /proc/asound/cards`

CARD=${DEFAULT}
if [ "${CARD_EXISTS}" == "USB-Audio" ] ; then
        CARD=${USB_AUDIO}
fi

if [ "${CARD}" == "${DEFAULT}" ] ; then
        DEVICE_NAME="${DEFAULT_NAME}"
else
        DEVICE_NAME="${USB_AUDIO_NAME}"
fi

# Write to user's .asoundrc file
for userdir in ${DIRS} ; do
cat<<EOF > /home/${userdir}/.asoundrc
pcm.!default {
        type plug
        slave.pcm "${DEVICE_NAME}"
}

ctl.!default {
        type hw
        card "${CARD}"
}
EOF
done

# Write to user's .openalrc file
for userdir in ${DIRS} ; do
cat<<EOF > /home/${userdir}/.openalrc
(define devices '(alsa))
(define alsa-out-device "hw:${CARD},0")
EOF
done

exit

Summary

As mentioned above, I never build my alsa drivers into the kernel since that never works so I strongly suggest building your alsa drivers (snd-hda-intel and snd-usb-audio) as modules. If configured correctly and module is loaded, you should see the following when the V10 speakers are plugged in:

$ cat /proc/asound/cards
0 [Intel          ]: HDA-Intel - HDA Intel
                     HDA Intel at 0xd2400000 irq 21
1 [Audio          ]: USB-Audio - USB Audio
                     C-Media INC. USB Audio at usb-0000:00:1d.0-1, full speed

References

The hotplug script is based on the script from this thread.

Retrieved from "http://www.gentoo-wiki.info/HOWTO_Logitech_V10_Notebook_Speakers"

Last modified: Fri, 05 Sep 2008 06:40:00 +0000 Hits: 9,803