[SOLVED] Creative X-FI Titanium (ctxfi) on Ubuntu 11.10

The Creative line of cards can be a handful at times, so that's why we (by we I mean other Linux developers) developed Alsa and open source drivers. Contrary to popular belief, you do not need the official drivers from Creative. All you need is a little bit of time and command-line work. For this, you'll need access to a terminal and root privileges (because you'll be installing some stuff). Best of all, I got digital out working as well with AC3 Digital surround sound! With these exact instructions, I got my Creative X-FI Titanium working on Ubuntu 11.10 with the 3.0.0-14-generic kernel (x64/AMD64). It outputs via the digital optical cable, so I'm running in “Digital Surround 5.1 (IEC958/AC3) Output”, pretty awesome aye? You can have this working too, all you need is a little elbow grease. So let's get started.

UPDATE: the apt-get line right below had a mistake in it where I accidently left in ‘build-dep'. Build-dep is NOT a package you install … it's something APT does to help build things. Sorry for those of you who were led astray by that! The proper code is below. 🙂 Enjoy! There are several prerequisites before doing anything. We need to download some packages which will help build everything. sudo apt-get install linux-source libasound2-plugins libavcodec-dev libavformat-dev After that installs, we need to handle building a patched (fixed) Linux Kernel module for the Creative card (the driver is called ctxfi though inside your linux installation it's called snd_ctxfi). Don't worry though, you won't be compiling a whole new kernel, just the ctxfi module. Let's start by making a folder we can work in and then getting the source code into it so we can edit it.
mkdir ctxfi-module
cd ctxfi-module
cp /usr/src/linux-source-3.0.0.tar.bz2 .
tar xfj linux-source-3.0.0.tar.bz2

Now the important stuff: patching the module so that it'll work just right! You can download (ie: copy and paste) the patch directly from the official Kernel GIT repository (that's the place cool hackers put up all the great code and fixes!) right here: GIT Kernel Patch OR just download the patch file I made for you (my file is exactly the same as the link above except it's in a file all ready and waiting to be used by you) by clicking: right here to download the file (.patch file). Right click and choose “Save As” to download it Time to apply the patch. First though, we need to change something that the CURRENT kernel files are missing. So let's edit and fix that first:

gksu gedit /usr/src/linux-headers-uname -r/include/linux/pci_ids.h Side note: You can also use vim or whatever. Also, if you want to stick to the command line always, just use ‘sudo' instead of gksu. Inside the file that we just opened (pci_ids.h), scroll down to line 1308 There you'll find something that looks like:

define PCI_SUBDEVICE_ID_CREATIVE_SB08801 0x0041

define PCI_SUBDEVICE_ID_CREATIVE_SB08802 0x0042

define PCI_SUBDEVICE_ID_CREATIVE_SB08803 0x0043

define PCI_SUBDEVICE_ID_CREATIVE_HENDRIX 0x6000

Under the like that has "0x0043" in the right column place this line which will tell Linux about our sound-card:

define PCI_SUBDEVICE_ID_CREATIVE_SB1270 0x0062

Save and close this file. Now onto some meaty patching and compiling! Let's get into the correct directory so that we build the modules properly. Assuming you're in the directory were we copies and extracted the linux-source code to:
cd linux-source-3.0.0/
Now for the all important patch and compile. First we copy the patch into the current directory (my default download directory is Downloads, so change it to wherever you downloaded the patch), apply it and only then do we compile:
cp ~/Downloads/ctxfi_kernel_3.0.0-14.patch ./
patch -p1 < ctxfi_kernel_3.0.0-14.patch
cd sound/pci/ctxfi/
make -C /usr/src/linux-headers-
uname -rM=pwdmodules
sudo make -C /usr/src/linux-headers-
uname -rM=pwdmodules_install
After compiling and doing the initial install, it's time to finalize, cleanup and install the new driver module permanently.
sudo depmod -a
sudo rmmod snd_ctxfi
sudo insmod /lib/modules/
uname -r/extra/snd-ctxfi.ko
sudo update-initramfs -u
A quick explanation of the code. First we reload the modules in general. Then remove the old useless snd_ctxfi module. Load in our newly built module and then by using update-initramfs -u we install it permanently into the (current) kernel. But wait! The fight isn't over yet! We need full surround sound AND digital goodness! Let's tackle surround first, open asound.conf:
gksu gedit /etc/asound.conf
You most likely don't have that file, that's ok. By opening it that way and then saving it, it'll be created. Now add the following code into asound.conf:
pcm.a52 {
@args [CARD]
@args.CARD {
type string
}
type rate
slave {
pcm {
type a52
bitrate 448
channels 6
card $CARD
}
rate 48000 #required somehow, otherwise nothing happens in PulseAudio
}
}
Alright, now it's time to get the digital and proper surround goodness. For this we'll use the A52 Alsa module which isn't build by default, we have we to do that ourselves:
cd ~/Downloads
apt-get source libasound2-plugins
cd alsa-plugins-*
./configure
make
cd a52/.libs
Some things changed since the previous versions of Ubuntu Linux, especially for ALSA and the CTXFI module so we have to first create the proper directory to put the plugin into. Only then can we copy it to the right place.
sudo mkdir /usr/lib/alsa-lib
sudo cp libasound_module_pcm_a52.la libasound_module_pcm_a52.so /usr/lib/alsa-lib/
sudo cp libasound_module_pcm_a52.so /usr/lib/
uname -i-linux-gnu/alsa-lib/
Time for the big finale! Let's reload alsa and pulseaudio!
sudo alsa reload
killall pulseaudio
After everything reloads (it takes a little while so be patient), try this and see if you the creative card:
aplay -l
If everything went correct you'll see things like this:
card 0: XFi [Creative X-Fi], device 1: ctxfi [Surround]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
What does that all mean? Well, it means we got sound! Open up your sound control panel thingy (select Sound Settings from the menu), click on the hardware tab and you should see: “X-Fi Titanium series [EMU20k2]” listed in there. Under ‘Profile' (on the same tab) select the type of sound output you want. If you're not using the digital cable (optical or coax) then select Analog sound options. You'll have many choices, so pick the one that's right for your setup. For me, the right choice is: “Digital Surround 5.1 (IEC958/AC3) Output + Analog Stereo Input”. Now open up Pandora, Amarok or whatever's your fancy and enjoy your awesome Creative X-Fi Titanium card!

If this worked for you, let me know in the comments! If it didn't let me know as well and I'll see what I can do to help Sources:

http://piotrkrzyzek.com/creative-x-fi-titanium-5-1-digital-surround-on-ubuntu/ http://www.intervigil.net/sound-blaster-x-fi-titanium-hd-on-ubuntu-1110 https://wiki.ubuntu.com/KernelCustomBuild https://help.ubuntu.com/community/DigitalAC-3Pulseaudio

  • I used to Use XP Pro, But i refuse to install a 25 gigabyte spy-ware virus on my system in place of an OS, so, I’ve been using Kubuntu Linux for about 3 months now. I recently updated to 11.10. I’m probably wrong, but I couldn’t get the first command line at the top of the page,
    “sudo apt-get install linux-source build-dep libasound2-plugins libavcodec-dev libavformat-dev”
    , to complete. I think you meant to put,
    “sudo apt-get build-dep linux-source libasound2-plugins libavcodec-dev libavformat-dev”
    , or at least that’s the only way i could get it to work.

    So far, I’ve made it as far as running “sudo rmmod snd_ctxfi”, and i got this message, “ERROR: Module snd_ctxfi is in use”. I’m stuck at this point.

  • Just between you and I, did you mean for both these commands to be there?

    make -C /usr/src/linux-headers-uname -r M=pwd modules
    sudo make -C /usr/src/linux-headers-uname -r M=pwd modules_install

    I could only get it to work correctly by skipping the first one.

  • It looks like the files are being changed or moved. I think i might have gotten it it installed in not for that. I couldn’t get a finished product. May have to wait for it to be updated. File names are replaced by different ons now. I think I’ll just play Rift for a couple days & see what happens then. Oh, I did have to use both lines when i tried it today.

    Thanks for the response. o/

  • Thanks for the excellent walkthrough, worked perfect!
    The only ‘extra’ step I had to do, was go into Synaptic first and get the linux-source-3.0.0 package, as it was not on my system by default. Once it downloaded, all the steps worked great, and like your setup, 5.1 Surround Digital is going to my Harmon Kardon now.

  • Piotr you rock, I now have sound coming out of my Creative Titanium sound card.

    The only problem is under the available profiles, only Stereo appears available for digital. For analogue I have all the available surround options. Any idea why my digital options might be limited?

    • Hey Robert,

      Sorry about taking so long to get back to you.

      Without taking a look on your system, I can’t really say what the issue is off the top of my head. Though my guess would be the A52 plugin isn’t installed/configured correctly or maybe you need a .asoundrc file?

      I sent you an e-mail a little while ago and didn’t hear back, hope you got it working alright. If not let me know.

      Cheers,
      — Peter

  • Awesome write up!!! And I’m just so close

    Here is what I did
    With the xfi sound card plugged into the pci bus I got stuck at the following step (as noted by another user):
    sudo rmmod snd_ctxfi”, and i got this message, “ERROR: Module snd_ctxfi is in use”
    I tried then to sudo /sbin/alsa force-unload, however even then it wouldn’t unload the snd-ctxfi (likely due to a dependency). Killing the pulse audio server didnt’ work either

    I then unplugged the card from the pci bus, and then with the following statement I received this error:
    sudo insmod /lib/modules/uname -r/extra/snd-ctxfi.ko
    insmod: error inserting ‘/lib/modules/3.0.0-14-generic/extra/snd-ctxfi.ko’: -1 Invalid parameters

    Help?? Please?

  • **Followup
    I was able to bypass the “ERROR: Module snd_ctxfi is in use” by going into the Sound Dialog and choosing Hardware (Xifi) -> Device off. By doing this is was able to run the following commands without errors:
    sudo depmod -a
    sudo rmmod snd_ctxfi

    However when trying to insmod or modprobe the patched kernel driver into the kernel I get the following error:
    sudo insmod /lib/modules/uname -r/extra/snd-ctxfi.ko
    insmod: error inserting ‘/lib/modules/3.0.0-14-generic/extra/snd-ctxfi.ko’: -1 Invalid parameters

    I’ve tried patching the source using both github and your patch and get the same result. I’ve ensured about 5 times the pci_ids.h was appropriately edited.

    Thanks for any input.

    • Hey Kev,

      Sorry you’re having these issues. Off the top of my head I don’t know the issue, though I’ll see what I can find. I vaguely remember having a similar issue, I just don’t remember the solution.

      One thing might be you compiled the module against a different kernel version? Maybe … though I think you did everything right. Hmm, sorry, just thinking out loud.

      Found this idea online:

      Instead of ‘insmod’ try using ‘modprobe’ to load the new module (after compiling). Try that and see how it works. Let me know if it worked or not. Hope it does.

  • modprobe produces same output — tried that!!

    What kernel did you compile against? 3.0.12? I tried against 3.0.14 and saw just this morning 3.0.15 was released. You know an easy way to downgrade the kernel?

    • You can’t ‘downgrade’ per-say but you can install an older kernel and then just boot into it. More than likely you have older kernel versions installed (assuming you’ve had ubuntu installed for a little while). The older kernel versions are found under ‘other’ (or something like that) from the GRUB (2) screen when you boot.

      To answer your first question:

      $ uname -a
      > Linux 3.0.0-14-generic #23-Ubuntu SMP Mon Nov 21 20:28:43 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

      I wrote this article with 3.0.0-14 in mind.

      Wouldn’t hurt trying to redo’ing the steps from beginning to end using the latest kernel. On a side note: I’m not updating to the latest kernel because I’m just too lazy to redo all the sound steps. Eh, maybe soon I’ll create a script/program to automate it all …

      Well, if modprobe produces the same error I don’t know the solution. Though I’ll look into it and see what I can come up with for you. Might take some time though, fair warning.

  • Just wanted to give feedback that I finally did get this up and running on the 3.0.14 kernel. I haven’t tried with 3.0.15. Thanks for the guide. At the current time you have the only credible guide on the entire internet.

  • Hello. Thank you for your tutorial. I have the same problem as @Kevdog:

    error inserting ‘/lib/modules/3.0.0-14-generic/extra/snd-ctxfi.ko’: -1 Invalid parameters

    I think it is because of some missing dependencies.
    I had error installing some packages from the first line:
    sudo apt-get install linux-source build-dep libasound2-plugins libavcodec-dev libavformat-dev

    The error: E: Unable to locate package build-dep
    Can it be this the problem? If it is, how can I install it?
    Fortunately Kevdog made it throug, but sadly he never posted how he bypassed his issue.

    Thank you

    • Hey Mano,

      You’re right, the current issue you’re having is a dependency issue. But … I think I got the code wrong: try doing the ‘apt-get install’ line WITHOUT ‘build-dep’ … I think it’s something that accidently snuck in there. So here’s the complete line to try: sudo apt-get install linux-source libasound2-plugins libavcodec-dev libavformat-dev

      Let me know how that goes.

  • I did that way, because I couldn’t get further if build-dep was included.
    Than I got “error inserting ‘/lib/modules/3.0.0-14-generic/extra/snd-ctxfi.ko’: -1 Invalid parameters”, and I thought it is some missing dependencies from build-dep perhaps.
    Right now I’m stuck here. I was thinking to install 11.04, I saw your other article and I think it is much easier to make it work with the previous ubuntu.

  • all has been going well until i hit this brick wall. thanks for the guide and any help anyone can give me.

    ohiogrown@Server:~/Downloads$ cd ~/Downloads
    ohiogrown@Server:~/Downloads$ sudo apt-get source libasound2-plugins
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Picking ‘alsa-plugins’ as source package instead of ‘libasound2-plugins’
    NOTICE: ‘alsa-plugins’ packaging is maintained in the ‘Bzr’ version control system at:
    http://bazaar.launchpad.net/~ubuntu-audio-dev/alsa-plugins/ubuntu.oneiric
    Please use:
    bzr branch http://bazaar.launchpad.net/~ubuntu-audio-dev/alsa-plugins/ubuntu.oneiric
    to retrieve the latest (possibly unreleased) updates to the package.
    Skipping already downloaded file ‘alsa-plugins_1.0.24-0ubuntu6.1.dsc’
    Skipping already downloaded file ‘alsa-plugins_1.0.24.orig.tar.bz2’
    Skipping already downloaded file ‘alsa-plugins_1.0.24-0ubuntu6.1.debian.tar.bz2’
    Need to get 0 B of source archives.
    sh: dpkg-source: not found
    Unpack command ‘dpkg-source -x alsa-plugins_1.0.24-0ubuntu6.1.dsc’ failed.
    Check if the ‘dpkg-dev’ package is installed.
    E: Child process failed
    ohiogrown@Server:~/Downloads$

    • fixed this problem by installing dpkg-dev, now i’m suck at the alsa plugin part

      checking for ALSA… configure: error: Package requirements (alsa >= 1.0.11) were not met:

      No package ‘alsa’ found

      Consider adjusting the PKG_CONFIG_PATH environment variable if you
      installed software in a non-standard prefix.

      Alternatively, you may set the environment variables ALSA_CFLAGS
      and ALSA_LIBS to avoid the need to call pkg-config.
      See the pkg-config man page for more details.

      ohiogrown@Server:~/Downloads/alsa-plugins-1.0.24$ make
      make: *** No targets specified and no makefile found. Stop.
      ohiogrown@Server:~/Downloads/alsa-plugins-1.0.24$ cd a52/.libs
      bash: cd: a52/.libs: No such file or directory

    • I also tried to install plugins from website and it shows i installed ALSA library additional plugins. libasound2-plugins 1.0.24-0ubuntu6.1 Installed 2012-02-03. When i try to run the “make” command i think is the issue now. I have a Makefile.am and Makefile.in in the a52 folder as well as the pcm_a52.c file. I’m not sure if the problem is with these make files or the ./configure in the previous command.

    • Hey Fabio,

      Genius idea! Thanks for finding that. I’ll update the article soon to reflect this info! Currently on Ubuntu 11.10 (without doing some of the latest updates) my current version of alsa is 1.0.24. The version listed on your article is 1.0.25! Exciting! Hopefully there are a lot of goodies and fixes in this latest version.

  • Hi i keep having problem at one of the steps, hope you can help me. Thank you.

    jease@ubuntu:~/Downloads$ apt-get source libasound2-plugins
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Picking ‘alsa-plugins’ as source package instead of ‘libasound2-plugins’
    E: Unable to find a source package for alsa-plugins

  • Btw, I forgot to mention that I already followed the steps posted by the user above Fabio, but this command does not work still.

  • Same problem as dan,

    Trying several different ways to get it working (downloading other sources etc), but no success so far.

  • Is there any Updates on:

    insmod: error inserting ‘/lib/modules/3.0.0-12-generic/extra/snd-ctxfi.ko’: -1 Invalid parameters

    Could you figure out how to solve this Problem? Thanks for your Help 🙂

    • Hey Robert,

      Sorry, there isn’t yet. I’ve been overly busy being in a development push on an international clients major site. Once that’s done, I’ll take a look. Hope it ‘somehow’ resolves itself … I hope to find something for you (and others) soon.

  • so long and the same problem, I have a soundblaster titanium, 5.1 speaker sistem but it only works as a 4 speaker system, frontcntr and buffer doesnt woork and the creative driver seems like an archive is missing. seems like it would be solved. but now I am restarting to use something else, and bookmark this page to troubleshoot later, and may be to be succesful in bussines too. grats

  • >