Difference between revisions of "Matrix:Module-asihpi"

From AlsaProject
Jump to: navigation, search
(mention merge with mainline kernel)
(add example volume control names)
 
(3 intermediate revisions by one user not shown)
Line 8: Line 8:
 
=== Additional Installation notes===
 
=== Additional Installation notes===
  
The asihpi driver was merged with mainline kernel at version 2.6.34.  However, to keep up with latest developments you may need to build from source.
+
The asihpi driver was merged with mainline kernel at version 2.6.35.  However, to keep up with latest developments you may need to build from source.
  
 
In addition to the alsa-driver source package, the matching alsa-firmware package must be downloaded, and run "make install" in the asihpi subdirectory.
 
In addition to the alsa-driver source package, the matching alsa-firmware package must be downloaded, and run "make install" in the asihpi subdirectory.
Line 33: Line 33:
 
=== Mixer ===
 
=== Mixer ===
 
==== control names ====
 
==== control names ====
By default the controls have names that follow AudioScience naming conventions. These reflect ASI documentation and will be familiar to users of the card via HPI or windows drivers.
+
Controls use ALSA naming conventions that differ from AudioScience HPI names.
  
Main differences: OutStream == PCM Playback, InStream == PCM Capture, AesIn == Digital in 
+
{| border="1"
 +
!ALSA
 +
! HPI
 +
|-
 +
| PCM   
 +
| Stream
 +
|-
 +
| Capture
 +
| In
 +
|-
 +
| Playback
 +
| Out
 +
|-
 +
| Clock
 +
| SampleClock
 +
|-
 +
| Digital
 +
| AES/EBU
 +
|-
 +
| Mode
 +
| ChannelMode
 +
|-
 +
| Route
 +
| Multiplexer
 +
|-
 +
| Switch
 +
| Mute
 +
|-
 +
| Volume, Level, Meter
 +
| same
 +
|}
  
It is possible to build the driver with more ALSA-style names by editing asihpi.c and removing the definition ASI_STYLE_NAMES
+
For example HPI "LineOut 0 Level" becomes ALSA "Line 0 Playback Level"
  
As of about 20071101 the controls no longer use indices (all have index=0).  The node indices have been assimilated into the control names. E.g. "Outstream to Lineout3", 4 has become Outstream3 to Lineout3.
+
The general format for an ALSA control name is "SOURCE SINK DIRECTION TYPE". Some examples<br>
All indices are now zero-based, corresponding to PCM substream numbering.
+
"PCM 0 Playback Volume" = master volume of player 0<br>
 +
"PCM 0 Line 0 Playback Volume" = matrix volume between player 0 and output 0<br>
 +
"Line 0 Line 0 Monitor Playback Volume" = feedthrough volume from input 0 to output 0<br>
 +
"PCM 0 Capture Route" = select one source for recorder 0 (more common)<br>
 +
"Line 0 PCM 0 Capture Volume" = matrix volume between input 0 and recorder 0 (less common alternative to capture route)
  
 
==== setting card master samplerate ====
 
==== setting card master samplerate ====
Line 197: Line 231:
 
|id:ID string for AudioScience soundcard. (charp)
 
|id:ID string for AudioScience soundcard. (charp)
 
|enable:Enable card(bool)
 
|enable:Enable card(bool)
|hpiDebugLevel:Debug level for Audioscience HPI 0:none..5:verbose (int)
+
|enable_hpi_hwdep:ALSA enable HPI hwdep for AudioScience soundcard  (bool)
|major:Device major number for HPI device(int)
+
|hpi_debug_level:Debug level for Audioscience HPI 0:none..5:verbose (int)
|bufsize:Buffer size to allocate for data transfer from HPI ioctl  (int)}}
+
|prealloc_stream_buf:Preallocate size for per-adapter stream buffer (int)}}
  
 
{{Matrix:Soundcard|name=AudioScience ASIxxxx|module=asihpi}}
 
{{Matrix:Soundcard|name=AudioScience ASIxxxx|module=asihpi}}

Latest revision as of 01:36, 1 May 2012


Driver for cards from Matrix:Vendor-AudioScience

Contents

[edit] Card Specific Information

[edit] Additional Installation notes

The asihpi driver was merged with mainline kernel at version 2.6.35. However, to keep up with latest developments you may need to build from source.

In addition to the alsa-driver source package, the matching alsa-firmware package must be downloaded, and run "make install" in the asihpi subdirectory.

If you have installed the hpklinux driver available from AudioScience website, you will end up with two different drivers that can claim the cards. To avoid unexpected behaviour, either remove one of the drivers or blacklist one or both E.g add "blacklist asihpi" to /etc/modprobe.d/blacklist. If both drivers are blacklisted, it is still possible to load either of them manually using modprobe.

Also you need to take care that incompatible firmware is not installed. In this case, it is recommended to rebuild the alsa driver using source from the hpklinux package (see that package for instructions).

[edit] Card indices

AudioScience cards have a hardware jumper to specify the card index. This ensures that cards keep the same index even if they are moved between slots, or other cards are added.

The driver will try to make ALSA card indices match the card jumper settings. This may fail if another card (onboard sound) is present and has already claimed a desired index. The cards will still work, but have unexpected indices.

By default the card name shown by ALSA will be the card model eg "ASI6644"

[edit] PCM streams

AudioScience cards support multiple streams (PCMs). These are exposed as ALSA substreams of device 0. I.e. hw:0,0,0 hw:0,0,1 etc.

The reason the driver doesn't map streams to ALSA devices is that there is a limit of four devices per card, and some cards have up to 16 streams.

Streams do not correspond to physical inputs and outputs, see Mixer section for more on this.

[edit] Mixer

[edit] control names

Controls use ALSA naming conventions that differ from AudioScience HPI names.

ALSA HPI
PCM Stream
Capture In
Playback Out
Clock SampleClock
Digital AES/EBU
Mode ChannelMode
Route Multiplexer
Switch Mute
Volume, Level, Meter same

For example HPI "LineOut 0 Level" becomes ALSA "Line 0 Playback Level"

The general format for an ALSA control name is "SOURCE SINK DIRECTION TYPE". Some examples
"PCM 0 Playback Volume" = master volume of player 0
"PCM 0 Line 0 Playback Volume" = matrix volume between player 0 and output 0
"Line 0 Line 0 Monitor Playback Volume" = feedthrough volume from input 0 to output 0
"PCM 0 Capture Route" = select one source for recorder 0 (more common)
"Line 0 PCM 0 Capture Volume" = matrix volume between input 0 and recorder 0 (less common alternative to capture route)

[edit] setting card master samplerate

Most cards will have a Sample Rate control. This sets the master samplerate for the card. The default rate will be 44100 or 48000. Setting this to the same rate as your source material means that the card will not have to do sample rate conversion.

Read the control amixer -c1 cget name='Clock0 LocalRate'

Set a new rate amixer -c1 cset name='Clock0 LocalRate' 48000

[edit] Level controls

Note that input level controls do not set input gain directly. The setting of an input level control is the full scale input signal level in dBu. So increasing input level control DECREASES the input gain.

Likewise, the setting of output level controls is the fullscale output level in dBu

[edit] Linked streams

Most AudioScience cards support multiple independent stereo play and record streams with different formats and samplerates (not ASI5xxx)

ALSA allows streams to be grouped together into a virtual stream with more channels using the multi plugin, maybe also requiring ttable plugin to allow memory mapped operation of the virtual stream.

To support stream grouping with the multi plugin, the card must support mmap. This will be reported in "dmesg" when the driver loads as Supports mmap:1

Cards which support hardware linking of streams for sample-accurate start and stop report grouping:1

Example definitions for .asoundrc

# create a virtual four-channel device with two sound devices:
# This is in fact two interleaved stereo streams in
# This creates a 4 channel interleaved pcm stream based on
# the multi device. JACK will work with this one.
# Usage: aplay -Dttable4:1  fourchannel.wav
#  jackd -d alsa -dttable4 -n4 -p2048

pcm.ttable4 {
	@args [ CARD DEV SUBDEV ]
	@args.CARD {
		type string
		default {
			@func getenv
			vars [
				ALSA_PCM_CARD
				ALSA_CARD
			]
			default {
				@func refer
				name defaults.pcm.card
			}
		}
	}
	@args.DEV {
		type integer
		default {
			@func igetenv
			vars [
				ALSA_PCM_DEVICE
			]
			default {
				@func refer
				name defaults.pcm.device
			}
		}
	}
	@args.SUBDEV {
		type integer
		default 0
	}
	type route;
	hint {
		show {
			@func refer
			name defaults.namehint.basic
		}
		description "4 channel multi route"
	}
	slave.pcm {
		type multi;
		slaves.a.pcm {
			type hw
			card $CARD
			device $DEV
			subdevice 0 # $SUBDEV
			#mmap_emulation true
		}
		slaves.a.channels 2;
		slaves.b.pcm {
			type hw
			card $CARD
			device $DEV
			subdevice 1 # { @func iadd integers [ $SUBDEV 1 ] }
			#mmap_emulation true
		}
		slaves.b.channels 2;
		bindings.0.slave a;
		bindings.0.channel 0;
		bindings.1.slave a;
		bindings.1.channel 1;
		bindings.2.slave b;
		bindings.2.channel 0;
		bindings.3.slave b;
		bindings.3.channel 1;
	}
	ttable.0.0 1;
	ttable.1.1 1;
	ttable.2.2 1;
	ttable.3.3 1;
}
# see above.
ctl.ttable4 {
	@args [ CARD DEV SUBDEV ]
	@args.CARD {
		type string
		default {
			@func getenv
			vars [
				ALSA_PCM_CARD
				ALSA_CARD
			]
			default {
				@func refer
				name defaults.pcm.card
			}
		}
	}
	@args.DEV {
		type integer
		default {
			@func igetenv
			vars [
				ALSA_PCM_DEVICE
			]
			default {
				@func refer
				name defaults.pcm.device
			}
		}
	}
	@args.SUBDEV {
		type integer
		default 0
	}
	type hw;
	card $CARD;
}

[edit] Capabilities and limitations

  1. HPI ioctl provided in addition to ALSA interface
  2. No support for compressed formats, though card supports them
  3. Limited use of large on card buffers

[edit] The module options for snd-asihpi

description:  AudioScience sound or tuner card
author:  AudioScience <support@audioscience.com>
license: GPL
parm: index:Index value for AudioScience soundcard. (int)
parm: id:ID string for AudioScience soundcard. (charp)
parm: enable:Enable card(bool)
parm: enable_hpi_hwdep:ALSA enable HPI hwdep for AudioScience soundcard (bool)
parm: hpi_debug_level:Debug level for Audioscience HPI 0:none..5:verbose (int)
parm: prealloc_stream_buf:Preallocate size for per-adapter stream buffer (int)

Introduction for AudioScience ASIxxxx soundcard

There are two ways of getting Linux drivers to work, you can either compile them into the kernel or build them separately as modules. Read the Kernel-HOWTO for details of how to compile a kernel.

You must turn on the sound support soundcore module. This is in the kernel. Look in the sound drivers directory and it should be the first option. Most people enable the module setting. That way you can load and unload the module manually if you have multiple soundcards/​devices or if you intend to debug or use cutting edge software which may cause your drivers to halt sometimes. Of course it also means you have more control of your system.

Most modern distros come with soundcore compiled as a module. You can check this in numerous ways. The easiest way is to type:

       modinfo soundcore

If this command returns that you have this module, then you don't need to recompile your kernel.

[edit] Quick installation

This explains how to build from source tarballs. See GIT_Server for instructions on getting and using the latest source from git repositories.

Type the following commands in the shell of your choice.

Make a directory to store the alsa source code in:

       cd /usr/src
       mkdir alsa
       cd alsa
       cp /downloads/alsa-* .

Now unzip and install the alsa-driver package:

       bunzip2 alsa-driver-xxx
       tar -xf alsa-driver-xxx
       cd alsa-driver-xxx
       ./configure --with-cards=asihpi --with-sequencer=yes ; make ; make install

Now unzip and install the alsa-lib package:

       cd ..
       bunzip2 alsa-lib-xxx
       tar -xf alsa-lib-xxx
       cd alsa-lib-xxx
       ./configure ; make ; make install

Now unzip and install the alsa-firmware package:

       cd ..
       bunzip2 alsa-firmware-xxx
       tar -xf alsa-firmware-xxx
       cd alsa-firmware-xxx
       ./configure ; make ; make install

Now unzip and install the alsa-utils package:

       cd ..
       bunzip2 alsa-utils-xxx
       tar -xf alsa-utils-xxx
       cd alsa-utils-xxx
       ./configure ; make ; make install

Now insert the modules into the kernel:

       modprobe snd-asihpi ; modprobe snd-pcm-oss ; modprobe snd-mixer-oss ; modprobe snd-seq-oss

Now adjust your soundcard's volume levels. All mixer channels are muted by default. You must use a native mixer program to unmute appropriate channels, for example alsamixer from the alsa-utils package. Note that some usb-audio devices do not have internal mixer controls. Run:

       alsamixer

You can also look at the utils/​alsasound file. This script is designed for the RedHat Linux distribution, but it can also be used with other distributions which use System V style rc init scripts. This will allow you to load your modules at boot time. If you don't want to do this you can of course compile them into the kernel instead and save yourself the hassle of coming to terms with the rc init scripts.

[edit] Setting up modprobe and kmod support

Before you send a mail complaining that "I don't have /etc/​modules.conf, where do I find it ……" ‒ the /etc/​conf.modules has been deprecated with a few distro's, but in your case it may still be /etc/​conf.modules. Basically they are both the same, but recent version of modutils use /etc/​modules.conf instead. Nothing to worry about as such, optionally please update to the latest version of modutils. This should solve your problem.

Here's the example for this card. Copy and paste this to the bottom of your /etc/​modules.conf file.

Note: 

Debian GNU/Linux users need to save this information into a file in the /etc/​modutils/ directory (eg. /etc/​modutils/​alsa) and run update-modules.

Note also that the kernel module soundcore has been renamed in Debian kernels >2.6.23 into snd. A workaround is to put a symlink at /lib/modules/x.x.xx/kernel/sound/soundcore.ko pointing to snd.ko


       # ALSA portion
       alias char-major-116 snd
       alias snd-card-0 snd-asihpi
       # module options should go here
       
       # OSS/Free portion
       alias char-major-14 soundcore
       alias sound-slot-0 snd-card-0
       
       # card #1
       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

To copy and paste the above to your /etc/​modules.conf file follow these instructions.

[edit] modules.conf

This is a short explanation of what happens in the /etc/​modules.conf file.

[edit] Native devices

After the main multiplexer is loaded, its code automatically requests the top level sound card module. String snd-card-%i is requested for native devices where %i is the sound card number, counted from zero (the first sound card) to seven (the eighth sound card). String sound-slot-%i is requested for native devices where %i is slot number for the corresponding ALSA owner (which is basically the sound card number). The options line allows you to set various configuration options before the module is loaded. String id (or snd_id) lets you set the name of the card which is then returned in the /proc/​asound/​cards file, i.e. to user space applications. Other options may be available depending on the specific card. Options for these cards are found in the INSTALL file or above.

       username@hostname# pico /etc/modules.conf
       
       # ALSA portion
       alias snd-card-0 snd-hda-intel
       alias snd-card-1 snd-cmipci
       options snd-cmipci id="first" mpu_port=0x330
       
       # OSS/Free portion
       alias sound-slot-0 snd-card-0
       alias sound-slot-1 snd-card-1
NB: 

For drivers older than 0.9.0rc5 use:

       options snd-cmipci snd_id="first" snd_mpu_port=0x330


NB: 

The "snd_" prefix has been removed from the module options to fit with the kernel standard.


[edit] Autoloading OSS/free emulation

At this point we are finished with the configuration for ALSA native devices, but you may also need autoloading for the OSS/Free emulation modules, an ALSA add-on. At this time only one module does not depend on any others, thus must be loaded separately: snd-pcm1-oss. String sound-service-%i-%i is required for OSS/Free service where the first %i is the slot number/​sound card number and the second %i is the service number.

       username@hostname# pico /etc/modules.conf
       
       # OSS/Free portion - card #1
       alias sound-slot-0 snd-card-0
       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 - card #2 (cmipci)
       alias sound-slot-1 snd-card-1
       alias sound-service-1-0 snd-mixer-oss
       alias sound-service-1-3 snd-pcm-oss
       alias sound-service-1-12 snd-pcm-oss

The alias for snd-seq-oss is not necessary on the second device, because there is only one /dev/​sequencer regardless how many devices you have.

[edit] The .asoundrc file

This file allows you to have more advanced control over your card/​device. For most setups the default, system-wide configuration is sufficient. You may change this file only for special setup. The .asoundrc file consists of definitions for the various sound devices available in your system. It also provides access to the pcm plugins in alsa-lib. These allow you to do tricky things like combine your cards into one or access multiple I/O streams on your multi-channel card.

Below is the most basic definition (only example - not required to define at all).

Make a file called .asoundrc in your home and/​or root directory:

       vi ~/.asoundrc

Copy and paste the following into the file, then save it:

       pcm.asihpi {
          type hw
          card 0
       }
       
       ctl.asihpi {
          type hw
          card 0
       }

[edit] Software volume control

If your card doesn't have hardware volume control (e. g. Asus Xonar XD/XDG), you might want to create software Master control. Edit .asoundrc as follows.

       pcm.softvol {
          type softvol
          slave {
             pcm "dmix"
          }
          control {
             name "Master"
             card 0
          }
       }
       
       pcm.!default {
         type plug
         slave.pcm "softvol"
       }

Restart alsa, then open a music player, play a file and close the player. Then check alsamixer, as you should have a Master volume control. Note that this control doesn't have a mute option.

[edit] Links

Generic

Specific

Custom Search
Personal tools
Namespaces

Variants
Actions
Navigation
wiki
Toolbox