Creative USB X-Fi Surround 5.1

Creative USB X-Fi Surround 5.1

Updated 20th Feb 2011
lsusb -v output
creative.log


Notes
The card works fine with the snd-usb-audio module. I've only tested the stereo output though.
The X-Fi USB doesn't have a hardware mixer. So you have to use the softvol plugin along with dmix.
The asoundrc file, mplayer config file and amarok config info can be found here http://mndar.phpnet.us/usbxfi/files.
One important thing to note about softvol is that the Master control won't appear until the device is used for playback.



All this has been to be added to the ALSA Wiki. http://alsa.opensrc.org/Usb-audio#Creative_USB_X-Fi_Surround_5.1
The device has a volume knob, the behavior of which is identical to that of IR remotes bundled with some Creative USB Audio devices. It also has a LED which can be set to On or can be set to Blink continuously. There doesn't seem to be a way to switch it off.

The latest stable kernel release (2.6.37) has support for this.
alsa-driver-1.0.24 too has these changes but I haven't tested it yet.
Support for this is now in the git repo. Ref: [1] [2] Here is the patch for alsa-driver-1.0.23

Once the snd-usb-audio module is loaded, you'll see the 'Power LED' control in alsamixer. Muting it will set the LED to Blink and unmuting it will set it to On. The patch allows lirc to receive events from the volume knob. You need to use the alsa_usb driver with lirc.

There is a remote bundled with this device sometimes. Its possible the remote will work with the same patch but unfortunately I don't have one with me.

The default alsa_usb config can be used as the codes are 0x0d for Mute, 0x0f for Vol- and 0x10 for Vol+. These are identical to the remote identified by name RM-1500 (Not Creative_RM-1500)
cp /usr/share/lirc/remotes/creative/lircd.conf.alsa_usb /etc/lircd.conf
Lirc needs to be started with these options. You can set your distro's config file accordingly
lircd --driver=alsa_usb --device=hw:S51
Run irw and you'll be able to see the received code when you turn or press the volume knob.
If you need to execute commands for Vol-,Vol+ and Mute, setup ~/.lircrc . You need to have irexec -d running in the background for these commands to be executed. Everytime you change ~/.lircrc you need to restart irexec

# $HOME/.lircrc
#S51 Volume Knob
begin
 prog = irexec
 remote = RM-1500
 button = vol-
 repeat = 1
 config = amixer sset Master 1- 
end

begin
 prog = irexec
 remote = RM-1500
 button = mute
 repeat = 1
 config = if [ `amixer sget Master|grep "Front Left:"|awk '{print $3}'` -gt 0 ]; then alsactl store -f ~/.asound.state; amixer sset Master 0; amixer sset 'Power LED' off; else alsactl restore -f ~/.asound.state; amixer sset 'Power LED' on;  fi 
end

begin
 prog = irexec
 remote = RM-1500
 button = vol+
 repeat = 1
 config = amixer sset Master 1+ 
end
The Mute part is messy because softvol plugin doesn't have the Mute feature. This lircrc allows you to mimic the behaviour under Windows i.e. LED blinking on Mute.

Anyway, you should change the commands based on your configuration. Eg. If you are using Pulseaudio you probably don't even need to use dmix & softvol. You could just use dbus-send or qdbus to change volume in Pulseaudio or use Pulseaudio's Lirc config in which case you don't need irexec running at all . I don't use Pulseaudio. Someone who is using it can probably explain it.