testing_us122l_under_linux

HOW To install Tascam US-122L

Plz, feel free to mail me federico (at) briata (dot) org

Before start

Note that US-122L is not US-122, so please do not follow this howto if you don't have US-122L, both devices need specific drivers.

From Ubuntu 9.04 (Jaunty Jackalope) everything has been integrated so you don't need to recompile anything! In other words, do NOT follow step 1 and step 2, in their place just be sure that alsa-tools and libasound2-plugins are installed.

sudo apt-get install alsa-tools libasound2-plugins
Whereas, step 3 is a must and step 4 is necessary if you want to use jack in realtime and make your professional DAW (so it's highly recommended).

STEP 1 - Getting patches

Patches are based from work of Karsten (http://thread.gmane.org/gmane.linux.alsa.devel/52204 & http://mailman.alsa-project.org/pipermail/alsa-devel/2008-May/007929.html) and Philippe CARRIERE (http://www.la-page-web-of-phil.fr/index.php?page=P030101):

 cd /usr/src/

We can get all patches from http://pub.briata.org/us-122l/src/ please choose the good one for your kernel, for debian lenny I took us122l-patches_2.6.26.tar.bz2.

 wget -c http://pub.briata.org/us-122l/src/us122l-patches_2.6.26.tar.bz2

Is better to verify with md5sum what downloaded before extract, http://pub.briata.org/us-122l/src/MD5SUM

 tar xjvf us122l-patches_2.6.26.tar.bz2

STEP 2 - Your Distro

Debian Lenny

Kernel 2.6.26

Debian Lenny provide Linux 2.6.26, here the necessary patches for have US-122L working on it:

 apt-get install debhelper kernel-package libncurses5-dev linux-source-2.6.26
 cd /usr/src/
 tar xjvf linux-source-2.6.26.tar.bz2
 rm linux
 ln -s linux-source-2.6.26 linux
 cd linux

1st patch is for use the card with usb2, ( note by Karsten: .Module doesn't care for iso number of packets being a multiple of 8, so at least for vanilla kernels . 2.6.28 it only works when the device is attached to an USB1.1 port), more details about the patch for Ehci-hcd came from Phil.

 patch -p1 < ../us122l-patches_2.6.26/ehci-hcd_2.6.26.patch

2nd, for US-122L Kernel Module (snd_usb_us122l). Now as root do:

 patch -p1 < ../us122l-patches_2.6.26/snd-usb-us122l_0.5.2_2.6.26.patch
 
 make-kpkg clean
 cp /boot/config-2.6.26-1-* .config
 make oldconfig

Press 'Y' or 'm' if you recognize some of your hardwares, press 'N' where not. // If you r not sure just press enter, this will be the default option.

In case of Tascam US122L, you'll get:

     Tascam US-122L USB driver (SND_USB_US122L) [N/m/?] (NEW)

There I press 'm'. For all rest I left default options.

If you have still to make some changes in kernel config:

 make menuconfig

the way for us-122l is: Device Drivers . Sound . Advanced Linux Sound Architecture . USB devices . Tascam US-122L USB driver

Packing & Installing, in 'Debian Way', you can get more detail on this method by asking google.

 make-kpkg --append-to-version -us122l --initrd kernel_image modules_image
 cd /usr/src
 ls | grep us122l

you must get one file or even more

   linux-image-2.6.26-us122l_2.6.26-us122l-10.00.Custom_amd64.deb

install the new kernel with us122l support

 dpkg -i linux-image-2.6.26-us122l_*.deb

Newer kernel aka > 2.6.24 allow a more convient way of ordering your soundcards. It is important that driver of our soundcard doesn't load *first*, to prevent that we have to add a line to /etc/modprobe.d/alsa-base

 echo "options snd-usb-us122l index=-2" >> /etc/modprobe.d/alsa-base.conf

Now reboot and load the new kernel

alsa-plugins (libasound2-plugins) 1.0.16

This metod is based on post by Steve about: How do I patch a Debian package.

First you will need to make sure you have enabled source repositories, add this line to /etc/apt/sources.list:

 deb-src http://ftp.yourcountrytld.debian.org/debian/ lenny main non-free contrib

and as superuser run

  apt-get update

now you will need to download some package for compile libasound2-plugins

  apt-get install libasound2-plugins autoconf automake libtool checkinstall libjack-dev libpulse-dev libsamplerate0-dev libavcodec-dev
  apt-get source alsa-plugins
  apt-get build-dep alsa-plugins

Next patch will establishes pcm i/o with snd_usb_us122l module.

 cd alsa-plugins-1.0.16/
 patch -p1 < ../us122l-patches_2.6.26/usb_stream_0.1-alsa-plugins-1.0.16.patch

Compiling, Packing and Installing

 autoreconf
 debuild -us -uc
 dpkg -i ../libasound2-plugins_1.0.16-1_*.deb

Ubuntu

Deb packages

On this page are available binary packages patched for Intrepid 2.6.27 and Hardy 2.6.25, please verify md5sum before install them.

8.10 intrepid linux_2.6.27 alsa_1.0.17

 md5sum libasound2-plugins_1.0.17-0ubuntu5_i386.deb      1e3cf4b7ba62b22f82f7a36cdcf20e94
 md5sum linux-image-2.6.27.2-us122l_2.6.27.2-us122l-10.00.Custom_i386.deb 3bb22bb6b6ecd15196f9327fddd121dc

8.04 Hardy Heron

 md5sum linux-image-2.6.25.4-us122l_1.bri_i386.deb       e192cc997fb2e28efbbd46abfa5ee2dc
 md5sum linux-image-2.6.25.4-us122l_1.bri_amd64.deb      1ce0f49e145dfe88735cfb479e9761b3

In alternative, you can compile everiting from source.

  cd /usr/src
  sudo wget http://pub.briata.org/us-122l/src/us122l-patches_2.6.27.tar.bz2

Kernel 2.6.27

  sudo apt-get install build-essential debhelper kernel-package libncurses5-dev fakeroot linux-headers-2.6.27 linux-source-2.6.27
  cd /usr/src/
  sudo tar xjvf linux-source-2.6.27.tar.bz2
  sudo rm linux
  sudo ln -s linux-source-2.6.27 linux
  cd linux
  sudo patch -p1 < ../us122l-patches_2.6.27/ehci-hcd_2.6.27.patch
  sudo patch -p1 < ../us122l-patches_2.6.27/snd-usb-us122l_0.5.2_2.6.27.patch
  cp /boot/config-2.6.27 .config
  sudo make oldconfig

Make your changes in the kernel (Processor Type and other driver) and check if the soundcard is successfully included by menucommand.

  sudo make menuconfig

the way for us-122l is: Device Drivers . Sound . Advanced Linux Sound Architecture . USB devices . Tascam US-122L USB driver

Packing & Installing, in 'Debian Way'.

 sudo make-kpkg --append-to-version -us122l --initrd kernel_image modules_image
 cd /usr/src
 ls | grep us122l

you must get one file or even more

 linux-image-2.6.27.2-us122l_2.6.27.2-us122l-10.00.Custom_i386.deb

install the new kernel with us122l support

 dpkg -i linux-image-2.6.27-us122l_*.deb

Newer kernel aka > 2.6.24 allow a more convient way of ordering your soundcards. It is important that driver of our soundcard doesn't load *first*, to prevent that we have to add a line to /etc/modprobe.d/alsa-base

 echo "options snd-usb-us122l index=-2" >> /etc/modprobe.d/alsa-base.conf

Now reboot and load the new kernel

Alsa-plugins ( libasound2-plugins 1.0.17 )

First you will need to make sure you have enabled source repositories.

You will need to download some package for compile libasound2-plugins

  sudo apt-get update
  apt-get install devscripts libasound2-plugins autoconf automake libtool checkinstall libjack-dev libpulse-dev libsamplerate0-dev libavcodec-dev
  sudo apt-get source alsa-plugins
  sudo apt-get build-dep alsa-plugins
  cd alsa-plugins-1.0.17/
  sudo patch -p1 < ../us122l-patches_2.6.27/usb_stream_0.1-alsa-plugins-1.0.17.patch

Compiling, Packing and Installing

  autoreconf
  sudo debuild -us -uc
  sudo dpkg -i ../libasound2-plugins_1.0.17-0ubuntu5_*.deb

Fedora 9 and above

At the web page of Philippe http://www.la-page-web-of-phil.fr/index.php?page=P030102 you can find RPMS packages for Fedora 9 kernel and alsa-plugins.
Thanks Phil!

STEP 3 - Set ALSA

Plug in the US-122L.

My onboard sound card is recognized as 1st card (card-0), so the US-122L will be the 2nd (card-1).
If you reboot with the card plugged in it can happen that the US-122L will recognized as card-0 (now this should be fixed,is it not?) To force the order try by doing:

sudo rmmod snd_usb_us122l
sudo modprobe snd_usb_us122l enable=1 index=1 id=1
To see your order do:

$ cat /proc/asound/modules
0 snd_hda_intel
1 snd_usb_us122l
PCM access needs an ~/.asoundrc in your home directory

$ wget -c http://pub.briata.org/us-122l/.asoundrc ~/.asoundrc

Test

From Alsa online documentations

 aplay -MDusb_stream:1 -fS24_3LE -r44100 -c2 /boot/vmlinuz!

From Karsten an example loop command:

 ARGS="-MDusb_stream:1 -fS24_3LE -r44100 -c2 --period-size=640" ; arecord $ARGS | aplay $ARGS

From Philippe CARRIERE

 aplay -MDusb_stream:1 -fS24_3LE -r44100 -c2 -twav --period-size=640 some_wave_file_with_24_bit_audio.wav

For other test take a look at ML linux.usb.general

Step 4 - Jackd in Realtime

Be sure to be member of audio group:

 sudo adduser `whoami` audio

then add some lines to the file /etc/security/limits.conf:

 sudo su -c 'echo @audio - rtprio 99 >> /etc/security/limits.conf'
 sudo su -c 'echo @audio - nice -10 >> /etc/security/limits.conf'
 sudo su -c 'echo @audio - memlock 250000 >> /etc/security/limits.conf'

logout

more info about this here

Test

To start jackd from console:

 jackd -RP50 -dalsa -dusb_stream:1 -r44100 -p64 -n2

instead console initialization we can start the card from X with qjackctl, following a screen-shot with my settings:

qjackctl settings

NOTE: In the Jack config menu usbstream:1 it is not listed, you need to write this manually.

Troubleshooting

card not found

Sometimes the card is not recognize at the first try or disapper

$ cat /proc/asound/modules
0 snd_hda_intel
$

solution:
1) unplug usb, plug it again can resolve.
2) Uploading the firmware version 1.12 from https://tascam.com/int/product/us-122l/download/ to resolve definitely this issue.

random kernel error From dmesg

 usb 5-5: USB disconnect, address 4
 usb 5-5: new high speed USB device using ehci_hcd and address 5
 usb 5-5: configuration #1 chosen from 1 choice
 US122L pt_version:107 -110
 US122L pt_info:130 -110
 US122L pt_info:130 -110
 US122L pt_info:130 -71
 5: cannot set freq 44100 to ep 0x81
 us122l_set_sample_rate error
 snd-usb-us122l: probe of 5-5:1.1 failed with error -5

solution:
1) unplug usb, plug it again can resolve.
2) the problem can be the ehci_hcd module, you can try to removing it

 sudo rmmod ehci_hcd

than plug it again, it will work in usb1.1 mode.
3) if still error appear try to reboot without audio plugged.

XRUNS too often:

 alsa_pcm: xrun of at least 2719.619 msecs
 10:56:12.399 XRUN callback (1).
 alsa_pcm: xrun of at least 1998.113 msecs
 10:56:14.395 XRUN callback (2).
 alsa_pcm: xrun of at least 1999.455 msecs
 10:56:16.396 XRUN callback (3).
 alsa_pcm: xrun of at least 2000.552 msecs
 10:56:18.396 XRUN callback (4).
 subgraph starting at qjackctl timed out (subgraph_wait_fd=10, status = 0, state = Triggered)
 10:56:20.392 XRUN callback (5).
 alsa_pcm: xrun of at least 1995.392 msecs
 alsa_pcm: xrun of at least 2002.769 msecs
 10:56:22.394 XRUN callback (6).
 alsa_pcm: xrun of at least 1999.113 msecs
 10:56:24.396 XRUN callback (7).
 alsa_pcm: xrun of at least 1998.984 msecs
 10:56:26.396 XRUN callback (8).
 subgraph starting at qjackctl timed out (subgraph_wait_fd=10, status = 0, state = Triggered)
 alsa_pcm: xrun of at least 1999.673 msecs
 10:56:28.397 XRUN callback (9).
 alsa_pcm: xrun of at least 2000.981 msecs
 10:56:30.396 XRUN callback (10).
 alsa_pcm: xrun of at least 2000.495 msecs
 10:56:32.397 XRUN callback (11).
 10:56:32.402 ALSA connection graph change.
 10:56:32.518 ALSA connection change.
 10:56:34.347 JACK connection graph change.
 alsa_pcm: xrun of at least 1951.228 msecs
 10:56:34.352 JACK connection change.
 10:56:34.355 XRUN callback (12).
 10:56:34.356 JACK connection graph change.
 alsa_pcm: xrun of at least 3.679 msecs
 alsa_pcm: xrun of at least 42.795 msecs
 10:56:34.559 JACK connection change.
 10:56:34.770 ALSA connection graph change.
 10:56:34.970 ALSA connection change.
 alsa_pcm: xrun of at least 960.412 msecs
 alsa_pcm: xrun of at least 20.726 msecs
 10:56:35.392 JACK connection graph change.
 10:56:36.414 XRUN callback (4 skipped).
 subgraph starting at bristol timed out (subgraph_wait_fd=19, status = 0, state = Running)
 10:56:42.395 JACK connection graph change.
 10:56:42.397 XRUN callback (17).
 alsa_pcm: xrun of at least 7004.332 msecs
 10:56:42.436 ALSA connection graph change.
 10:56:42.539 JACK connection change.
 10:56:42.542 ALSA connection change.
 subgraph starting at qjackctl timed out (subgraph_wait_fd=10, status = 0, state = Triggered)
 alsa_pcm: xrun of at least 1997.459 msecs
 10:56:44.396 XRUN callback (18).
 subgraph starting at qjackctl timed out (subgraph_wait_fd=10, status = 0, state = Triggered)
 alsa_pcm: xrun of at least 1999.071 msecs
 10:56:46.398 XRUN callback (19).
 alsa_pcm: xrun of at least 1999.996 msecs
 10:56:48.397 XRUN callback (20).
 alsa_pcm: xrun of at least 1999.188 msecs
 10:56:50.397 XRUN callback (21).
 10:56:52.272 ALSA connection graph change.
 10:56:52.306 ALSA connection change.
 alsa_pcm: xrun of at least 1987.084 msecs
 10:56:52.384 XRUN callback (22).
 alsa_pcm: xrun of at least 1997.046 msecs
 10:56:54.383 XRUN callback (23).
 alsa_pcm: xrun of at least 2013.621 msecs

all those xruns, make the sound card impossible to use with jackd for record and play
solution: Have longer periods help. Thanks Karsten for the tip and troubleshooting!!
with -p256 I got better result but still some xrun with -p512 , got the expected result and only some few (but tollerable) xrun

 jackd -RP50 -dalsa -dusb_stream:1 -r44100 -p512 -n2