我们通过命令amixer查看声卡内容:
# amixer contents
numid=7,iface=CARD,name='Headphone Jack'
; type=BOOLEAN,access=r-------,values=1
: values=on
numid=8,iface=CARD,name='Headset Mic Jack'
; type=BOOLEAN,access=r-------,values=1
: values=off
numid=9,iface=MIXER,name='Headphone Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=2,iface=MIXER,name='Capture MIC Path'
; type=ENUMERATED,access=rw------,values=1,items=4
; Item #0 'MIC OFF'
; Item #1 'Main Mic'
; Item #2 'Hands Free Mic'
; Item #3 'BT Sco Mic'
: values=3
numid=1,iface=MIXER,name='Playback Path'
; type=ENUMERATED,access=rw------,values=1,items=11
; Item #0 'OFF'
; Item #1 'RCV'
; Item #2 'SPK'
; Item #3 'HP'
; Item #4 'HP_NO_MIC'
; Item #5 'BT'
; Item #6 'SPK_HP'
; Item #7 'RING_SPK'
; Item #8 'RING_HP'
; Item #9 'RING_HP_NO_MIC'
; Item #10 'RING_SPK_HP'
: values=3
numid=5,iface=MIXER,name='DACL Capture Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=255,step=0
: values=255
| dBscale-min=-95.00dB,step=0.37dB,mute=1
numid=3,iface=MIXER,name='DACL Playback Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=255,step=0
: values=235
| dBscale-min=-95.00dB,step=0.37dB,mute=1
numid=6,iface=MIXER,name='DACR Capture Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=255,step=0
: values=255
| dBscale-min=-95.00dB,step=0.37dB,mute=1
numid=4,iface=MIXER,name='DACR Playback Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=255,step=0
: values=235
| dBscale-min=-95.00dB,step=0.37dB,mute=1
numid=12,iface=MIXER,name='Headset Mic Switch'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=11,iface=MIXER,name='Main Mic Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=10,iface=MIXER,name='Speaker Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
使用喇叭播放时,我们需要将playback path切换到SPK上,通过amixer切换:
# amixer -c 0 cset numid=1 2
numid=2,iface=MIXER,name='Playback Path'
; type=ENUMERATED,access=rw------,values=1,items=11
; Item #0 'OFF'
; Item #1 'RCV'
; Item #2 'SPK'
; Item #3 'HP'
; Item #4 'HP_NO_MIC'
; Item #5 'BT'
; Item #6 'SPK_HP'
; Item #7 'RING_SPK'
; Item #8 'RING_HP'
; Item #9 'RING_HP_NO_MIC'
; Item #10 'RING_SPK_HP'
: values=2
播放wav文件测试,使用aplay验证:
# aplay /etc/demo.wav
Playing WAVE '/etc/demo.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
使用mic时,我们需要将mic功能打开,通过amixer打开:
# amixer -c 0 cset numid=1 1
numid=3,iface=MIXER,name='Capture MIC Path'
; type=ENUMERATED,access=rw------,values=1,items=4
; Item #0 'MIC OFF'
; Item #1 'Main Mic'
; Item #2 'Hands Free Mic'
; Item #3 'BT Sco Mic'
: values=1
执行录音功能,使用amixer验证:
# arecord -D hw:0,0 -c 2 -f S16_LE -r 44100 /data/youyeetoo.wav
Recording WAVE '/data/youyeetoo.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
^CAborted by signal Interrupt...
播放youyeetoo.wav文件测试,使用aplay验证:
# aplay /data/youyeetoo.wav
Playing WAVE '/data/youyeetoo.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
使用耳机播放时,我们需要将playback path切换到SPK上,通过amixer切换:
# amixer -c 0 cset numid=1 3
numid=2,iface=MIXER,name='Playback Path'
; type=ENUMERATED,access=rw------,values=1,items=11
; Item #0 'OFF'
; Item #1 'RCV'
; Item #2 'SPK'
; Item #3 'HP'
; Item #4 'HP_NO_MIC'
; Item #5 'BT'
; Item #6 'SPK_HP'
; Item #7 'RING_SPK'
; Item #8 'RING_HP'
; Item #9 'RING_HP_NO_MIC'
; Item #10 'RING_SPK_HP'
: values=3
播放wav文件测试,使用aplay验证:
# aplay /etc/demo.wav
Playing WAVE '/etc/demo.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo