Using alsa-utils debug ALSA driver

Source: Internet
Author: User
Tags stdin

2011-06-24 17:35:58

The Alsa Utils below Android offers three tools, respectively:
Alsa_amixer: Configuring
Alsa_aplay: Play Recording
Alsa_ctl:: Store/restore configuration file, related to asound.conf

Detailed parameters can be viewed through alsa_xxx--help

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"Alsa_amixer"
/$ alsa_amixer--help usage:amixer <options> [command] Available options:-H,--Help the Help-c,--card N Select t He card-d,--device N Select the device, default ' default '-D,--debug Debug mode-n,--Nocheck do not perform range checkin G-v,--Version Print version of this program-q,--quiet is quiet-i,--inactive show also inactive controls-a,--abstract L Select Abstraction level (None or Basic)-s,--stdin Read and execute commands from stdin sequentially Available commands: We mainly use the back four Scontrols show all mixer simple controls scontents show contents The all mixer simple controls (default comma nd) sset SID P set contents for one mixer simple control Sget SID get contents to one mixer simple control controls All controls for given card contents show contents to all controls for given card Cset CID P set control contents for one Control Cget CID Contents

"Use Method"

Alsa_amixer controls: Lists all the control interfaces registered in the ALSA driver.
These controls are defined in the drive through the struct snd_kcontrol_new twl4030_snd_controls[] function static int twl4030_add_controls (struct SND_SOC _codec *codec) to add an interface.
The format is as follows:
Numid=19,iface=mixer,name= ' Analog Capture Volume '

Alsa_amixer Contents: Lists the details of the above interface in the following format:
Numid=19,iface=mixer,name= ' Analog Capture Volume '
; TYPE=INTEGER,ACCESS=RW---R--, values=2,min=0,max=5,step=0
: values=5,5
| Dbscale-min=0.00db,step=6.00db,mute=0

Above, the Numid is in the order of the registration of the distribution, other information to look at the data structure to understand the driver.

We can read and set the relevant parameters through two commands:
Cset CID P Set control contents for one control
Cget CID Get control contents for one control
For example:
Alsa_amixer cget numid=19,iface=mixer,name= ' analog Capture Volume '
Alsa_amixer cset numid=19,iface=mixer,name= ' analog Capture Volume ' 5
In fact, if you get the numid of these controls through Alsa_amixer controls, you can use Numid to do the same:
/$ alsa_amixer Cget numid=19
Numid=19,iface=mixer,name= ' Analog Capture Volume '
; TYPE=INTEGER,ACCESS=RW---R--, values=2,min=0,max=5,step=0
: values=5,5
| Dbscale-min=0.00db,step=6.00db,mute=0

/$ alsa_amixer Cset numid=19 4
# # #reg_0x48 ==twl4030_reg_anamic_gain:0x24
Numid=19,iface=mixer,name= ' Analog Capture Volume '
; TYPE=INTEGER,ACCESS=RW---R--, values=2,min=0,max=5,step=0
: values=4,4
| Dbscale-min=0.00db,step=6.00db,mute=0

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"Alsa_aplay"
/$ alsa_aplay--help usage:aplay [OPTION] ... [FILE] ...-h,--help help--version print version-l,--list-devices list all soundcards and digital audio -L,--list-pcms list device names-d,--device=name select PCM by Name-q,--quiet quiet mode-t,--file-type type file t YPE (VOC, WAV, raw or AU)-C,--channels=# channels-f,--format=format sample format (case insensitive)-R,--rate=# Samp Le rate-d,--duration=# interrupt after # seconds-m,--mmap mmap stream-n,--nonblock nonblocking, Mode-f,--period-tim e=# distance between interrupts is # Microseconds-b,--buffer-time=# buffer duration is # microseconds--period-size=# di Stance between interrupts is # frames--buffer-size=# buffer duration are # frames-a,--avail-min=# min available space fo R Wakeup is # Microseconds-r,--start-delay=# delay for automatic PCM start are # microseconds (relative to buffer size if <= 0)-T,--stop-delay=# delay for automatic PCM stop are # microseconds from Xrun-v,--verbose Show PCM structure and Setup (accumulative)-V,--vumeter=type enable VU meter (Type:mono or stereo)-I,--separate-chan Nels one file for each channel--disable-resample disable automatic rate resample--disable-channels disable-automatic cha Nnel conversions--disable-format Disable automatic format conversions--disable-softvol disable software volume control ( Softvol)--test-position test Ring buffer position recognized sample formats Are:s8 U8 s16_le s16_be u16_le u16_be S24_be u24_le u24_be s32_le s32_be u32_le u32_be float_le float_be float64_le float64_be IEC958_SUBFRAME_LE IEC958_SUBFRA ME_BE MU_LAW A_LAW IMA_ADPCM MPEG GSM SPECIAL S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_ 3BE U18_3le Some of May is available on selected hardware The availabled format shortcuts are:-F CD (bit lit Tle endian, 44100, stereo)-F CDR (bit big endian, 44100, stereo)-F dat (bit little endian, 48000, stereo)  

Detailed explanation of recording parameters S8 U8 s16_le s16_be u16_le u16_b:
S is signed U is unsigned
Be a big-endian
Le is a small end
This is a range of PCM method, so the representation method of the minimum equivalent, the maximum equivalent, the middle of the data level is the corresponding progress, can be mapped to the -1~1 range.
S8:signed 8 bits, signed characters = char, representing range -128~127
U8:unsigned 8 bits, unsigned characters = unsigned char, representing range 0~255
S16_le:little endian signed Bits, small end signed = short, representing range -32768~32767
S16_be:big endian signed bits, big-endian signed = short reverse (PPC), representing range -32768~32767
U16_le:little endian unsigned bits, small-end unsigned words = unsigned short, representation range 0~65535
U16_be:big endian unsigned signed bits, big-name unsigned = unsigned short reverse (PPC), range 0~65535

There are s24_le,s32_le and so on, can represent a number of methods, PCM can use these representations.
Of these values, all the minimum values-128, 0,-32768,-32768, 0, 0-correspond to the PCM description as a value that represents the minimum value that can be quantified to floating-point-1. All the maximum values are also a value, which can be quantified to float 1, and other values can be equal proportional conversions.

Example
Alsa_aplay-c-T wav-c 2-r 44100-f s16_le-d 10-v
Alsa_aplay Record.wav
-c:record
-T,--file-type type file type (VOC, WAV, raw or AU)
-C,--channels=# channels
-F,--format=format sample format (case insensitive)
-R,--rate=# sample rate
-D,--duration=# interrupt after # seconds
-V,--verbose show PCM structure and setup (accumulative)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"Alsa_ctl"
/$ alsa_ctl--help usage:alsactl <options> Command Available Global options:-H,--help this help-d,--debug debug Mode-v,--Version Print version of this program Available State options:-F,--File # configuration file (Default/etc/asou Nd.state-F,--Force try to restore the matching controls as much as possible (default mode)-G,--ignore ignore ' No SOUNDC Ards found ' error-p,--pedantic don't restore mismatching controls (old default)-I,--no-init-fallback don ' t initialize E ven if restore Fails-r,--runstate # Save restore and init state to this file [only errors] default settings is ' no file s ET ' r,--Remove Runstate file at a, otherwise append errors Available init options:-e,--env #=# set Environmen T variable for init phase (Name=value)-I,--initfile # main configuation file for init phase (default/system/usr/share/al Sa/init/00main) Available commands:store <card #> Save current Driver The setup for one or all soundcards to Configura tion file Restore <caRD #> Load Current driver setup for one or each soundcards from configuration file init <card #> Initialize Drive R to a default state names <card #> dump information about all known present (sub-) devices into configuration fi Le (deprecated)  

The main use of two commands:
ALSA_CTL Store: Export the current audio configuration parameter settings to a file/system/etc/asound.conf

We can directly modify this file for system initialization configuration, of course, do not forget to add a command in the init.rc:

# # # #add to Init.rc
Service Asound_conf/system/bin/alsa_ctl Restore
OneShot

Alsa_ctl Restore: Reload the configuration in the file/system/etc/asound.conf

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.