18c2ecf20Sopenharmony_ci========================================================
28c2ecf20Sopenharmony_ciGuide to using M-Audio Audiophile USB with ALSA and Jack
38c2ecf20Sopenharmony_ci========================================================
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_civ1.5
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciThibault Le Meur <Thibault.LeMeur@supelec.fr>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciThis document is a guide to using the M-Audio Audiophile USB (tm) device with 
108c2ecf20Sopenharmony_ciALSA and JACK.
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ciHistory
138c2ecf20Sopenharmony_ci=======
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci* v1.4 - Thibault Le Meur (2007-07-11)
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci  - Added Low Endianness nature of 16bits-modes
188c2ecf20Sopenharmony_ci    found by Hakan Lennestal <Hakan.Lennestal@brfsodrahamn.se>
198c2ecf20Sopenharmony_ci  - Modifying document structure
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci* v1.5 - Thibault Le Meur (2007-07-12)
228c2ecf20Sopenharmony_ci  - Added AC3/DTS passthru info
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ciAudiophile USB Specs and correct usage
268c2ecf20Sopenharmony_ci======================================
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciThis part is a reminder of important facts about the functions and limitations 
298c2ecf20Sopenharmony_ciof the device.
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ciThe device has 4 audio interfaces, and 2 MIDI ports:
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci * Analog Stereo Input (Ai)
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci   - This port supports 2 pairs of line-level audio inputs (1/4" TS and RCA) 
368c2ecf20Sopenharmony_ci   - When the 1/4" TS (jack) connectors are connected, the RCA connectors
378c2ecf20Sopenharmony_ci     are disabled
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci * Analog Stereo Output (Ao)
408c2ecf20Sopenharmony_ci * Digital Stereo Input (Di)
418c2ecf20Sopenharmony_ci * Digital Stereo Output (Do)
428c2ecf20Sopenharmony_ci * Midi In (Mi)
438c2ecf20Sopenharmony_ci * Midi Out (Mo)
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ciThe internal DAC/ADC has the following characteristics:
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci* sample depth of 16 or 24 bits
488c2ecf20Sopenharmony_ci* sample rate from 8kHz to 96kHz
498c2ecf20Sopenharmony_ci* Two interfaces can't use different sample depths at the same time.
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ciMoreover, the Audiophile USB documentation gives the following Warning:
528c2ecf20Sopenharmony_ci  Please exit any audio application running before switching between bit depths
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciDue to the USB 1.1 bandwidth limitation, a limited number of interfaces can be 
558c2ecf20Sopenharmony_ciactivated at the same time depending on the audio mode selected:
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci * 16-bit/48kHz ==> 4 channels in + 4 channels out
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci   - Ai+Ao+Di+Do
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci * 24-bit/48kHz ==> 4 channels in + 2 channels out, 
628c2ecf20Sopenharmony_ci   or 2 channels in + 4 channels out
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci   - Ai+Ao+Do or Ai+Di+Ao or Ai+Di+Do or Di+Ao+Do
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci * 24-bit/96kHz ==> 2 channels in _or_ 2 channels out (half duplex only)
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci   - Ai or Ao or Di or Do
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ciImportant facts about the Digital interface:
718c2ecf20Sopenharmony_ci--------------------------------------------
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci * The Do port additionally supports surround-encoded AC-3 and DTS passthrough, 
748c2ecf20Sopenharmony_ci   though I haven't tested it under Linux
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci   - Note that in this setup only the Do interface can be enabled
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci * Apart from recording an audio digital stream, enabling the Di port is a way 
798c2ecf20Sopenharmony_ci   to synchronize the device to an external sample clock
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci   - As a consequence, the Di port must be enable only if an active Digital 
828c2ecf20Sopenharmony_ci     source is connected
838c2ecf20Sopenharmony_ci   - Enabling Di when no digital source is connected can result in a 
848c2ecf20Sopenharmony_ci     synchronization error (for instance sound played at an odd sample rate)
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ciAudiophile USB MIDI support in ALSA
888c2ecf20Sopenharmony_ci===================================
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ciThe Audiophile USB MIDI ports will be automatically supported once the
918c2ecf20Sopenharmony_cifollowing modules have been loaded:
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci * snd-usb-audio
948c2ecf20Sopenharmony_ci * snd-seq-midi
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ciNo additional setting is required.
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ciAudiophile USB Audio support in ALSA
1008c2ecf20Sopenharmony_ci====================================
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ciAudio functions of the Audiophile USB device are handled by the snd-usb-audio 
1038c2ecf20Sopenharmony_cimodule. This module can work in a default mode (without any device-specific 
1048c2ecf20Sopenharmony_ciparameter), or in an "advanced" mode with the device-specific parameter called 
1058c2ecf20Sopenharmony_ci``device_setup``.
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ciDefault Alsa driver mode
1088c2ecf20Sopenharmony_ci------------------------
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ciThe default behavior of the snd-usb-audio driver is to list the device 
1118c2ecf20Sopenharmony_cicapabilities at startup and activate the required mode when required 
1128c2ecf20Sopenharmony_ciby the applications: for instance if the user is recording in a 
1138c2ecf20Sopenharmony_ci24bit-depth-mode and immediately after wants to switch to a 16bit-depth mode,
1148c2ecf20Sopenharmony_cithe snd-usb-audio module will reconfigure the device on the fly.
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ciThis approach has the advantage to let the driver automatically switch from sample 
1178c2ecf20Sopenharmony_cirates/depths automatically according to the user's needs. However, those who 
1188c2ecf20Sopenharmony_ciare using the device under windows know that this is not how the device is meant to
1198c2ecf20Sopenharmony_ciwork: under windows applications must be closed before using the m-audio control
1208c2ecf20Sopenharmony_cipanel to switch the device working mode. Thus as we'll see in next section, this 
1218c2ecf20Sopenharmony_ciDefault Alsa driver mode can lead to device misconfigurations.
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ciLet's get back to the Default Alsa driver mode for now.  In this case the 
1248c2ecf20Sopenharmony_ciAudiophile interfaces are mapped to alsa pcm devices in the following 
1258c2ecf20Sopenharmony_ciway (I suppose the device's index is 1):
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci * hw:1,0 is Ao in playback and Di in capture
1288c2ecf20Sopenharmony_ci * hw:1,1 is Do in playback and Ai in capture
1298c2ecf20Sopenharmony_ci * hw:1,2 is Do in AC3/DTS passthrough mode
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ciIn this mode, the device uses Big Endian byte-encoding so that 
1328c2ecf20Sopenharmony_cisupported audio format are S16_BE for 16-bit depth modes and S24_3BE for 
1338c2ecf20Sopenharmony_ci24-bits depth mode.
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ciOne exception is the hw:1,2 port which was reported to be Little Endian 
1368c2ecf20Sopenharmony_cicompliant (supposedly supporting S16_LE) but processes in fact only S16_BE streams.
1378c2ecf20Sopenharmony_ciThis has been fixed in kernel 2.6.23 and above and now the hw:1,2 interface 
1388c2ecf20Sopenharmony_ciis reported to be big endian in this default driver mode.
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ciExamples:
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci * playing a S24_3BE encoded raw file to the Ao port::
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci   % aplay -D hw:1,0 -c2 -t raw -r48000 -fS24_3BE test.raw
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci * recording a  S24_3BE encoded raw file from the Ai port::
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci   % arecord -D hw:1,1 -c2  -t raw -r48000 -fS24_3BE test.raw
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci * playing a S16_BE encoded raw file to the Do port::
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci   % aplay -D hw:1,1 -c2 -t raw -r48000 -fS16_BE test.raw
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci * playing an ac3 sample file to the Do port::
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci   % aplay -D hw:1,2 --channels=6 ac3_S16_BE_encoded_file.raw
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ciIf you're happy with the default Alsa driver mode and don't experience any 
1598c2ecf20Sopenharmony_ciissue with this mode, then you can skip the following chapter.
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ciAdvanced module setup
1628c2ecf20Sopenharmony_ci---------------------
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ciDue to the hardware constraints described above, the device initialization made 
1658c2ecf20Sopenharmony_ciby the Alsa driver in default mode may result in a corrupted state of the 
1668c2ecf20Sopenharmony_cidevice. For instance, a particularly annoying issue is that the sound captured 
1678c2ecf20Sopenharmony_cifrom the Ai interface sounds distorted (as if boosted with an excessive high
1688c2ecf20Sopenharmony_civolume gain).
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ciFor people having this problem, the snd-usb-audio module has a new module 
1718c2ecf20Sopenharmony_ciparameter called ``device_setup`` (this parameter was introduced in kernel
1728c2ecf20Sopenharmony_cirelease 2.6.17)
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ciInitializing the working mode of the Audiophile USB
1758c2ecf20Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ciAs far as the Audiophile USB device is concerned, this value let the user 
1788c2ecf20Sopenharmony_cispecify:
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci * the sample depth
1818c2ecf20Sopenharmony_ci * the sample rate
1828c2ecf20Sopenharmony_ci * whether the Di port is used or not 
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ciWhen initialized with ``device_setup=0x00``, the snd-usb-audio module has
1858c2ecf20Sopenharmony_cithe same behaviour as when the parameter is omitted (see paragraph "Default 
1868c2ecf20Sopenharmony_ciAlsa driver mode" above)
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ciOthers modes are described in the following subsections.
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci16-bit modes
1918c2ecf20Sopenharmony_ci~~~~~~~~~~~~
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ciThe two supported modes are:
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci * ``device_setup=0x01``
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci   - 16bits 48kHz mode with Di disabled
1988c2ecf20Sopenharmony_ci   - Ai,Ao,Do can be used at the same time
1998c2ecf20Sopenharmony_ci   - hw:1,0 is not available in capture mode
2008c2ecf20Sopenharmony_ci   - hw:1,2 is not available
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci * ``device_setup=0x11``
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci   - 16bits 48kHz mode with Di enabled
2058c2ecf20Sopenharmony_ci   - Ai,Ao,Di,Do can be used at the same time
2068c2ecf20Sopenharmony_ci   - hw:1,0 is available in capture mode
2078c2ecf20Sopenharmony_ci   - hw:1,2 is not available
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ciIn this modes the device operates only at 16bits-modes. Before kernel 2.6.23,
2108c2ecf20Sopenharmony_cithe devices where reported to be Big-Endian when in fact they were Little-Endian
2118c2ecf20Sopenharmony_ciso that playing a file was a matter of using:
2128c2ecf20Sopenharmony_ci::
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci   % aplay -D hw:1,1 -c2 -t raw -r48000 -fS16_BE test_S16_LE.raw
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ciwhere "test_S16_LE.raw" was in fact a little-endian sample file.
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ciThanks to Hakan Lennestal (who discovered the Little-Endiannes of the device in
2198c2ecf20Sopenharmony_cithese modes) a fix has been committed (expected in kernel 2.6.23) and
2208c2ecf20Sopenharmony_ciAlsa now reports Little-Endian interfaces. Thus playing a file now is as simple as
2218c2ecf20Sopenharmony_ciusing:
2228c2ecf20Sopenharmony_ci::
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci   % aplay -D hw:1,1 -c2 -t raw -r48000 -fS16_LE test_S16_LE.raw
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci24-bit modes
2288c2ecf20Sopenharmony_ci~~~~~~~~~~~~
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ciThe three supported modes are:
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci * ``device_setup=0x09``
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci   - 24bits 48kHz mode with Di disabled
2358c2ecf20Sopenharmony_ci   - Ai,Ao,Do can be used at the same time
2368c2ecf20Sopenharmony_ci   - hw:1,0 is not available in capture mode
2378c2ecf20Sopenharmony_ci   - hw:1,2 is not available
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci * ``device_setup=0x19``
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci   - 24bits 48kHz mode with Di enabled
2428c2ecf20Sopenharmony_ci   - 3 ports from {Ai,Ao,Di,Do} can be used at the same time
2438c2ecf20Sopenharmony_ci   - hw:1,0 is available in capture mode and an active digital source must be 
2448c2ecf20Sopenharmony_ci     connected to Di
2458c2ecf20Sopenharmony_ci   - hw:1,2 is not available
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci * ``device_setup=0x0D`` or ``0x10``
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci   - 24bits 96kHz mode
2508c2ecf20Sopenharmony_ci   - Di is enabled by default for this mode but does not need to be connected 
2518c2ecf20Sopenharmony_ci     to an active source
2528c2ecf20Sopenharmony_ci   - Only 1 port from {Ai,Ao,Di,Do} can be used at the same time
2538c2ecf20Sopenharmony_ci   - hw:1,0 is available in captured mode
2548c2ecf20Sopenharmony_ci   - hw:1,2 is not available
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ciIn these modes the device is only Big-Endian compliant (see "Default Alsa driver 
2578c2ecf20Sopenharmony_cimode" above for an aplay command example)
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ciAC3 w/ DTS passthru mode
2608c2ecf20Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ciThanks to Hakan Lennestal, I now have a report saying that this mode works.
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci * ``device_setup=0x03``
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci   - 16bits 48kHz mode with only the Do port enabled 
2678c2ecf20Sopenharmony_ci   - AC3 with DTS passthru
2688c2ecf20Sopenharmony_ci   - Caution with this setup the Do port is mapped to the pcm device hw:1,0
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ciThe command line used to playback the AC3/DTS encoded .wav-files in this mode:
2718c2ecf20Sopenharmony_ci::
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci   % aplay -D hw:1,0 --channels=6 ac3_S16_LE_encoded_file.raw
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ciHow to use the ``device_setup`` parameter
2768c2ecf20Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ciThe parameter can be given:
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci * By manually probing the device (as root):::
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci   # modprobe -r snd-usb-audio
2838c2ecf20Sopenharmony_ci   # modprobe snd-usb-audio index=1 device_setup=0x09
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci * Or while configuring the modules options in your modules configuration file
2868c2ecf20Sopenharmony_ci   (typically a .conf file in /etc/modprobe.d/ directory:::
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci       alias snd-card-1 snd-usb-audio
2898c2ecf20Sopenharmony_ci       options snd-usb-audio index=1 device_setup=0x09
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ciCAUTION when initializing the device
2928c2ecf20Sopenharmony_ci-------------------------------------
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci * Correct initialization on the device requires that device_setup is given to
2958c2ecf20Sopenharmony_ci   the module BEFORE the device is turned on. So, if you use the "manual probing"
2968c2ecf20Sopenharmony_ci   method described above, take care to power-on the device AFTER this initialization.
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci * Failing to respect this will lead to a misconfiguration of the device. In this case
2998c2ecf20Sopenharmony_ci   turn off the device, unprobe the snd-usb-audio module, then probe it again with
3008c2ecf20Sopenharmony_ci   correct device_setup parameter and then (and only then) turn on the device again.
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci * If you've correctly initialized the device in a valid mode and then want to switch
3038c2ecf20Sopenharmony_ci   to  another mode (possibly with another sample-depth), please use also the following 
3048c2ecf20Sopenharmony_ci   procedure:
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci   - first turn off the device
3078c2ecf20Sopenharmony_ci   - de-register the snd-usb-audio module (modprobe -r)
3088c2ecf20Sopenharmony_ci   - change the device_setup parameter by changing the device_setup
3098c2ecf20Sopenharmony_ci     option in ``/etc/modprobe.d/*.conf``
3108c2ecf20Sopenharmony_ci   - turn on the device
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci * A workaround for this last issue has been applied to kernel 2.6.23, but it may not
3138c2ecf20Sopenharmony_ci   be enough to ensure the 'stability' of the device initialization.
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ciTechnical details for hackers
3168c2ecf20Sopenharmony_ci-----------------------------
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ciThis section is for hackers, wanting to understand details about the device
3198c2ecf20Sopenharmony_ciinternals and how Alsa supports it.
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ciAudiophile USB's ``device_setup`` structure
3228c2ecf20Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ciIf you want to understand the device_setup magic numbers for the Audiophile 
3258c2ecf20Sopenharmony_ciUSB, you need some very basic understanding of binary computation. However, 
3268c2ecf20Sopenharmony_cithis is not required to use the parameter and you may skip this section.
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ciThe device_setup is one byte long and its structure is the following:
3298c2ecf20Sopenharmony_ci::
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_ci       +---+---+---+---+---+---+---+---+
3328c2ecf20Sopenharmony_ci       | b7| b6| b5| b4| b3| b2| b1| b0|
3338c2ecf20Sopenharmony_ci       +---+---+---+---+---+---+---+---+
3348c2ecf20Sopenharmony_ci       | 0 | 0 | 0 | Di|24B|96K|DTS|SET|
3358c2ecf20Sopenharmony_ci       +---+---+---+---+---+---+---+---+
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ciWhere:
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci * b0 is the ``SET`` bit
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci   - it MUST be set if device_setup is initialized 
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci * b1 is the ``DTS`` bit
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci   - it is set only for Digital output with DTS/AC3
3468c2ecf20Sopenharmony_ci   - this setup is not tested
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci * b2 is the Rate selection flag
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci   - When set to ``1`` the rate range is 48.1-96kHz
3518c2ecf20Sopenharmony_ci   - Otherwise the sample rate range is 8-48kHz
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci * b3 is the bit depth selection flag
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_ci   - When set to ``1`` samples are 24bits long
3568c2ecf20Sopenharmony_ci   - Otherwise they are 16bits long
3578c2ecf20Sopenharmony_ci   - Note that b2 implies b3 as the 96kHz mode is only supported for 24 bits 
3588c2ecf20Sopenharmony_ci     samples
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci * b4 is the Digital input flag
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_ci   - When set to ``1`` the device assumes that an active digital source is 
3638c2ecf20Sopenharmony_ci     connected 
3648c2ecf20Sopenharmony_ci   - You shouldn't enable Di if no source is seen on the port (this leads to 
3658c2ecf20Sopenharmony_ci     synchronization issues)
3668c2ecf20Sopenharmony_ci   - b4 is implied by b2 (since only one port is enabled at a time no synch 
3678c2ecf20Sopenharmony_ci     error can occur) 
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ci * b5 to b7 are reserved for future uses, and must be set to ``0``
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci   - might become Ao, Do, Ai, for b7, b6, b4 respectively
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ciCaution:
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci * there is no check on the value you will give to device_setup
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_ci   - for instance choosing 0x05 (16bits 96kHz) will fail back to 0x09 since 
3788c2ecf20Sopenharmony_ci     b2 implies b3. But _there_will_be_no_warning_ in /var/log/messages
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_ci * Hardware constraints due to the USB bus limitation aren't checked
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci   - choosing b2 will prepare all interfaces for 24bits/96kHz but you'll
3838c2ecf20Sopenharmony_ci     only be able to use one at the same time
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ciUSB implementation details for this device
3868c2ecf20Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ciYou may safely skip this section if you're not interested in driver 
3898c2ecf20Sopenharmony_cihacking.
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ciThis section describes some internal aspects of the device and summarizes the 
3928c2ecf20Sopenharmony_cidata I got by usb-snooping the windows and Linux drivers.
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ciThe M-Audio Audiophile USB has 7 USB Interfaces:
3958c2ecf20Sopenharmony_cia "USB interface":
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci * USB Interface nb.0
3988c2ecf20Sopenharmony_ci * USB Interface nb.1
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_ci   - Audio Control function
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ci * USB Interface nb.2
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ci   - Analog Output
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci * USB Interface nb.3
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_ci   - Digital Output
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci * USB Interface nb.4
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci   - Analog Input
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci * USB Interface nb.5
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci   - Digital Input
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_ci * USB Interface nb.6
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci   - MIDI interface compliant with the MIDIMAN quirk 
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ciEach interface has 5 altsettings (AltSet 1,2,3,4,5) except:
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci * Interface 3 (Digital Out) has an extra Alset nb.6 
4258c2ecf20Sopenharmony_ci * Interface 5 (Digital In) does not have Alset nb.3 and 5 
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ciHere is a short description of the AltSettings capabilities:
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_ci* AltSettings 1 corresponds to
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci  - 24-bit depth, 48.1-96kHz sample mode
4328c2ecf20Sopenharmony_ci  - Adaptive playback (Ao and Do), Synch capture (Ai), or Asynch capture (Di)
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ci* AltSettings 2 corresponds to
4358c2ecf20Sopenharmony_ci
4368c2ecf20Sopenharmony_ci  - 24-bit depth, 8-48kHz sample mode
4378c2ecf20Sopenharmony_ci  - Asynch capture and playback  (Ao,Ai,Do,Di)
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_ci* AltSettings 3 corresponds to
4408c2ecf20Sopenharmony_ci
4418c2ecf20Sopenharmony_ci  - 24-bit depth, 8-48kHz sample mode
4428c2ecf20Sopenharmony_ci  - Synch capture (Ai) and Adaptive playback (Ao,Do)
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_ci* AltSettings 4 corresponds to
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci  - 16-bit depth, 8-48kHz sample mode
4478c2ecf20Sopenharmony_ci  - Asynch capture and playback  (Ao,Ai,Do,Di)
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci* AltSettings 5 corresponds to
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci  - 16-bit depth, 8-48kHz sample mode
4528c2ecf20Sopenharmony_ci  - Synch capture (Ai) and Adaptive playback (Ao,Do)
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci* AltSettings 6 corresponds to
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_ci  - 16-bit depth, 8-48kHz sample mode
4578c2ecf20Sopenharmony_ci  - Synch playback (Do), audio format type III IEC1937_AC-3
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_ciIn order to ensure a correct initialization of the device, the driver 
4608c2ecf20Sopenharmony_ci*must* *know* how the device will be used:
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ci * if DTS is chosen, only Interface 2 with AltSet nb.6 must be
4638c2ecf20Sopenharmony_ci   registered
4648c2ecf20Sopenharmony_ci * if 96KHz only AltSets nb.1 of each interface must be selected
4658c2ecf20Sopenharmony_ci * if samples are using 24bits/48KHz then AltSet 2 must me used if
4668c2ecf20Sopenharmony_ci   Digital input is connected, and only AltSet nb.3 if Digital input
4678c2ecf20Sopenharmony_ci   is not connected
4688c2ecf20Sopenharmony_ci * if samples are using 16bits/48KHz then AltSet 4 must me used if
4698c2ecf20Sopenharmony_ci   Digital input is connected, and only AltSet nb.5 if Digital input
4708c2ecf20Sopenharmony_ci   is not connected
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ciWhen device_setup is given as a parameter to the snd-usb-audio module, the 
4738c2ecf20Sopenharmony_ciparse_audio_endpoints function uses a quirk called 
4748c2ecf20Sopenharmony_ci``audiophile_skip_setting_quirk`` in order to prevent AltSettings not 
4758c2ecf20Sopenharmony_cicorresponding to device_setup from being registered in the driver.
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ciAudiophile USB and Jack support
4788c2ecf20Sopenharmony_ci===============================
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_ciThis section deals with support of the Audiophile USB device in Jack.
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_ciThere are 2 main potential issues when using Jackd with the device:
4838c2ecf20Sopenharmony_ci
4848c2ecf20Sopenharmony_ci* support for Big-Endian devices in 24-bit modes
4858c2ecf20Sopenharmony_ci* support for 4-in / 4-out channels
4868c2ecf20Sopenharmony_ci
4878c2ecf20Sopenharmony_ciDirect support in Jackd
4888c2ecf20Sopenharmony_ci-----------------------
4898c2ecf20Sopenharmony_ci
4908c2ecf20Sopenharmony_ciJack supports big endian devices only in recent versions (thanks to
4918c2ecf20Sopenharmony_ciAndreas Steinmetz for his first big-endian patch). I can't remember 
4928c2ecf20Sopenharmony_ciexactly when this support was released into jackd, let's just say that
4938c2ecf20Sopenharmony_ciwith jackd version 0.103.0 it's almost ok (just a small bug is affecting 
4948c2ecf20Sopenharmony_ci16bits Big-Endian devices, but since you've read carefully the above
4958c2ecf20Sopenharmony_ciparagraphs, you're now using kernel >= 2.6.23 and your 16bits devices 
4968c2ecf20Sopenharmony_ciare now Little Endians ;-) ).
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_ciYou can run jackd with the following command for playback with Ao and
4998c2ecf20Sopenharmony_cirecord with Ai:
5008c2ecf20Sopenharmony_ci::
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_ci  % jackd -R -dalsa -Phw:1,0 -r48000 -p128 -n2 -D -Chw:1,1
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_ciUsing Alsa plughw
5058c2ecf20Sopenharmony_ci-----------------
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ciIf you don't have a recent Jackd installed, you can downgrade to using
5088c2ecf20Sopenharmony_cithe Alsa ``plug`` converter.
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ciFor instance here is one way to run Jack with 2 playback channels on Ao and 2 
5118c2ecf20Sopenharmony_cicapture channels from Ai:
5128c2ecf20Sopenharmony_ci::
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_ci  % jackd -R -dalsa -dplughw:1 -r48000 -p256 -n2 -D -Cplughw:1,1
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_ciHowever you may see the following warning message:
5178c2ecf20Sopenharmony_ci  You appear to be using the ALSA software "plug" layer, probably a result of 
5188c2ecf20Sopenharmony_ci  using the "default" ALSA device. This is less efficient than it could be. 
5198c2ecf20Sopenharmony_ci  Consider using a hardware device instead rather than using the plug layer.
5208c2ecf20Sopenharmony_ci
5218c2ecf20Sopenharmony_ciGetting 2 input and/or output interfaces in Jack
5228c2ecf20Sopenharmony_ci------------------------------------------------
5238c2ecf20Sopenharmony_ci
5248c2ecf20Sopenharmony_ciAs you can see, starting the Jack server this way will only enable 1 stereo
5258c2ecf20Sopenharmony_ciinput (Di or Ai) and 1 stereo output (Ao or Do).
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_ciThis is due to the following restrictions:
5288c2ecf20Sopenharmony_ci
5298c2ecf20Sopenharmony_ci* Jack can only open one capture device and one playback device at a time
5308c2ecf20Sopenharmony_ci* The Audiophile USB is seen as 2 (or three) Alsa devices: hw:1,0, hw:1,1
5318c2ecf20Sopenharmony_ci  (and optionally hw:1,2)
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_ciIf you want to get Ai+Di and/or Ao+Do support with Jack, you would need to
5348c2ecf20Sopenharmony_cicombine the Alsa devices into one logical "complex" device.
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ciIf you want to give it a try, I recommend reading the information from
5378c2ecf20Sopenharmony_cithis page: http://www.sound-man.co.uk/linuxaudio/ice1712multi.html
5388c2ecf20Sopenharmony_ciIt is related to another device (ice1712) but can be adapted to suit
5398c2ecf20Sopenharmony_cithe Audiophile USB.
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ciEnabling multiple Audiophile USB interfaces for Jackd will certainly require:
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_ci* Making sure your Jackd version has the MMAP_COMPLEX patch (see the ice1712 page)
5448c2ecf20Sopenharmony_ci* (maybe) patching the alsa-lib/src/pcm/pcm_multi.c file (see the ice1712 page)
5458c2ecf20Sopenharmony_ci* define a multi device (combination of hw:1,0 and hw:1,1) in your .asoundrc
5468c2ecf20Sopenharmony_ci  file 
5478c2ecf20Sopenharmony_ci* start jackd with this device
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_ciI had no success in testing this for now, if you have any success with this kind 
5508c2ecf20Sopenharmony_ciof setup, please drop me an email.
551