RV1109 音频的调试与使用

RV1106 音频的调试与使用

开发环境

主芯片:瑞芯微:rv1109,PMIC 为RK809 ,809带有一个IIS
查看声卡数量

[root@RV1126_RV1109:/]# cat /proc/asound/cards 
 0 [rockchippdmmica]: rockchip_pdm-mi - rockchip,pdm-mic-array
                      rockchip,pdm-mic-array
 1 [rockchiprk809co]: rockchip_rk809- - rockchip,rk809-codec
                      rockchip,rk809-codec
 7 [Loopback       ]: Loopback - Loopback
                      Loopback 1
[root@RV1126_RV1109:/]# 

板子上有两个声卡,一个是硅麦的声卡,一个是 rk809 集成的声卡,rockchippdmmica 是硅麦的声卡,为默认声卡,只能录音不能播放,rockchiprk809co 为 rk809 集成的声卡,可以录音和播放,录音仅限 LANE IN,Loopback 为本地回环声卡。

修改配置

使用amixer 指令进行配置声卡

[root@RV1126_RV1109:/]# cat /etc/asound.conf 
pcm.!default{
     type hw
     card 1
     device 0
     }
ctl.!default{
     type hw
     card 1    # 这里默认控制改为声卡1 ,即rk809集成的声卡
    }
[root@RV1126_RV1109:/]# 

终端输入 amixer contents ,如果不修改asound.conf 则需要amixer -c 1 contents,否则终端上打印为空内容

[root@RV1126_RV1109:/]# amixer contents
numid=1,iface=CARD,name='Headphones Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=on
numid=9,iface=MIXER,name='Master Playback Volume'
  ; type=INTEGER,access=rw---RW-,values=2,min=0,max=255,step=0
  : values=10,10
  | dBscale-min=-20.00dB,step=0.03dB,mute=0
numid=6,iface=MIXER,name='ADCL Capture Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=126,step=0
  : values=126
  | dBscale-min=-95.00dB,step=0.75dB,mute=0
numid=7,iface=MIXER,name='ADCR Capture Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=126,step=0
  : values=126
  | dBscale-min=-95.00dB,step=0.75dB,mute=0
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
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=6
numid=4,iface=MIXER,name='DACL Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=126,step=0
  : values=10
  | dBscale-min=-95.00dB,step=0.75dB,mute=0
numid=5,iface=MIXER,name='DACR Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=126,step=0
  : values=100
  | dBscale-min=-95.00dB,step=0.75dB,mute=0
numid=8,iface=MIXER,name='Digital Capture Volume'
  ; type=INTEGER,access=rw---RW-,values=2,min=0,max=120,step=0
  : values=120,120
  | dBscale-min=-30.00dB,step=0.41dB,mute=0

播放声音

使能硬件功放

echo 77 >  /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio77/direction
echo 1 > /sys/class/gpio/gpio77/value

播放音乐
aplay /userdata/rjyanhuo.wav & ; 或者 aplay -Dhw:1,0 /userdata/rjyanhuo.wav &

设置音量

在这里插入图片描述最开发的硬件SPKR_OUT,SPKL_OUT 接功放输入
在这里插入图片描述调试时发现把SPK_EN使能后喇叭有很大的噪声输出,用示波器观察功放的输入端,有500HZ的方波输出。
当播放音乐时功放输入端的的波形会随音乐变化(占空比会发生变化)。
最后硬件上做调整,把SPKP改为模拟的输入(HPR_OUT,HPL_OUT),接到功放中,解决了噪音的问题。

所以这里音量的设置方法如下
命令行输入 amixer contents

numid=4,iface=MIXER,name='DACL Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=126,step=0
  : values=10
  | dBscale-min=-95.00dB,step=0.75dB,mute=0
numid=5,iface=MIXER,name='DACR Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=126,step=0
  : values=100
  | dBscale-min=-95.00dB,step=0.75dB,mute=0

重点看DACL,DACR, 耳机的左声道和右声道设置
设置音量的脚本如下

#!/bin/sh
if [ $# -lt 1 ] ;then
        echo "Too few input parameters ..\n"
        exit 1;
fi
amixer cset numid=4,iface=MIXER,name='DACL Playback Volume' $1
amixer cset numid=5,iface=MIXER,name='DACR Playback Volume' $1

音量设置在0 - 126 之间

录音

硬件麦克风接在RK809上,录音的测试指令如下

arecord -c 2 -r 44100 -f S16_LE -d 10 /tmp/record.wav

或者

arecord -Dhw:1,0 -c 2 -r 44100 -f S16_LE -d 10 /tmp/record.wav
[root@RV1126_RV1109:/userdata]# arecord -h
Usage: arecord [OPTION]... [FILE]...

-h, --help              help
    --version           print current version
-l, --list-devices      list all soundcards and digital audio devices
-L, --list-pcms         list device names
-D, --device=NAME       select PCM by name
-q, --quiet             quiet mode
-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
-s, --samples=#         interrupt after # samples per channel
-M, --mmap              mmap stream
-N, --nonblock          nonblocking mode
-F, --period-time=#     distance between interrupts is # microseconds
-B, --buffer-time=#     buffer duration is # microseconds
    --period-size=#     distance between interrupts is # frames
    --buffer-size=#     buffer duration is # frames
-A, --avail-min=#       min available space for wakeup is # microseconds
-R, --start-delay=#     delay for automatic PCM start is # microseconds 
                        (relative to buffer size if <= 0)
-T, --stop-delay=#      delay for automatic PCM stop is # microseconds from xrun
-v, --verbose           show PCM structure and setup (accumulative)
-V, --vumeter=TYPE      enable VU meter (TYPE: mono or stereo)
-I, --separate-channels one file for each channel
-i, --interactive       allow interactive operation from stdin
-m, --chmap=ch1,ch2,..  Give the channel map to override or follow
    --disable-resample  disable automatic rate resample
    --disable-channels  disable automatic channel conversions
    --disable-format    disable automatic format conversions
    --disable-softvol   disable software volume control (softvol)
    --test-position     test ring buffer position
    --test-coef=#       test coefficient for ring buffer position (default 8)
                        expression for validation is: coef * (buffer_size / 2)
    --test-nowait       do not wait for ring buffer - eats whole CPU
    --max-file-time=#   start another output file when the old file has recorded
                        for this many seconds
    --process-id-file   write the process ID here
    --use-strftime      apply the strftime facility to the output file name
    --dump-hw-params    dump hw_params of the device
    --fatal-errors      treat all errors as fatal
Recognized sample formats are: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE E
Some of these may not be available on selected hardware
The available format shortcuts are:
-f cd (16 bit little endian, 44100, stereo)
-f cdr (16 bit big endian, 44100, stereo)
-f dat (16 bit little endian, 48000, stereo)
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值