Jetson nano USB声卡调试

这段时间一直在做USB声卡调试,之前做了x86上的调试,这次分享在英伟达Jetson nano平台上接USB声卡。 nano上运行Ubuntu 18.04的系统。当然USB声卡调试也是跟x86大致相同。下面我们就来分享下调试过程:

  1. 检查是否有USB声卡设备:
    在终端中输入命令: lsusb
$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 032: ID 0d8c:0012 C-Media Electronics, Inc. 
Bus 001 Device 031: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 002: ID 0bda:5411 Realtek Semiconductor Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

其中 Bus 001 Device 032: ID 0d8c:0012 C-Media Electronics, Inc. 就是USB声卡。

  1. 查看声卡设备信息 :
    在终端中输入命令:aplay -l
$ aplay -l 
**** List of PLAYBACK Hardware Devices ****
card 0: tegrahda [tegra-hda], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-rt565x], device 0: ADMAIF1 CIF ADMAIF1-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-rt565x], device 1: ADMAIF2 CIF ADMAIF2-1 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-rt565x], device 2: ADMAIF3 CIF ADMAIF3-2 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-rt565x], device 3: ADMAIF4 CIF ADMAIF4-3 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-rt565x], device 4: ADMAIF5 CIF ADMAIF5-4 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-rt565x], device 5: ADMAIF6 CIF ADMAIF6-5 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-rt565x], device 6: ADMAIF7 CIF ADMAIF7-6 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-rt565x], device 7: ADMAIF8 CIF ADMAIF8-7 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-rt565x], device 8: ADMAIF9 CIF ADMAIF9-8 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-rt565x], device 9: ADMAIF10 CIF ADMAIF10-9 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Device [USB Audio Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

其中 card 2: Device [USB Audio Device], device 0: USB Audio [USB Audio] 为usb声卡设备信息。

  1. 查看usb声卡控制参数
    在终端中输入 amixer -c 2
$ amixer -c 2
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 37
  Mono:
  Front Left: Playback 4 [11%] [-33.00dB] [on]
  Front Right: Playback 4 [11%] [-33.00dB] [on]
Simple mixer control 'Mic',0
  Capabilities: pvolume pvolume-joined cvolume cvolume-joined pswitch pswitch-joined cswitch cswitch-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: Playback 0 - 31 Capture 0 - 35
  Mono: Playback 16 [52%] [-7.00dB] [off] Capture 20 [57%] [8.00dB] [on]
Simple mixer control 'Auto Gain Control',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]

命令中 2 就是指 card 2 即USB声卡设备。
可以看出声音控制就是 Speaker

  1. 调节声音大小 amixer -c 2 set Speaker 50%
$ amixer -c 2 set Speaker 50%
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 37
  Mono:
  Front Left: Playback 19 [51%] [-18.00dB] [on]
  Front Right: Playback 19 [51%] [-18.00dB] [on]
  1. 播放音频文件 aplay xxx.wav
    在终端中播放音频 :
$ aplay /home/nano/audio/leisheng.wav
Playing WAVE '/home/nano/audio/leisheng.wav' : Unsigned 8 bit, Rate 11025 Hz, Mono

最后也通过 'pactl' 命令来获取USB声卡的信息

$ pactl list sinks 
Sink #1
        State: SUSPENDED
        Name: alsa_output.platform-sound.analog-stereo
        Description: Built-in Audio Analog Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 9
        Mute: no
        Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: alsa_output.platform-sound.analog-stereo.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY 
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "ADMAIF1 CIF ADMAIF1-0"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "1"
                alsa.card_name = "tegra-snd-t210ref-mobile-rt565x"
                alsa.long_card_name = "tegra-snd-t210ref-mobile-rt565x"
                device.bus_path = "platform-sound"
                sysfs.path = "/devices/sound/sound/card1"
                device.form_factor = "internal"
                device.string = "front:1"
                device.buffering.buffer_size = "32768"
                device.buffering.fragment_size = "16384"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "Built-in Audio Analog Stereo"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card"
        Ports:
                analog-output: Analog Output (priority: 9900)
        Active Port: analog-output
        Formats:
                pcm

Sink #2
        State: SUSPENDED
        Name: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo
        Description: USB Audio Device Analog Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 25
        Mute: no
        Volume: front-left: 18471 /  28% / -33.00 dB,   front-right: 18471 /  28% / -33.00 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "USB Audio"
                alsa.id = "USB Audio"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "2"
                alsa.card_name = "USB Audio Device"
                alsa.long_card_name = "C-Media Electronics Inc. USB Audio Device at usb-70090000.xusb-2.3.1, full spee"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "platform-70090000.xusb-usb-0:2.3.1:1.0"
                sysfs.path = "/devices/70090000.xusb/usb1/1-2/1-2.3/1-2.3.1/1-2.3.1:1.0/sound/card2"
                udev.id = "usb-C-Media_Electronics_Inc._USB_Audio_Device-00"
                device.bus = "usb"
                device.vendor.id = "0d8c"
                device.vendor.name = "C-Media Electronics, Inc."
                device.product.id = "0012"
                device.product.name = "USB Audio Device"
                device.serial = "C-Media_Electronics_Inc._USB_Audio_Device"
                device.string = "front:2"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "USB Audio Device Analog Stereo"
                alsa.mixer_name = "USB Mixer"
                alsa.components = "USB0d8c:0012"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        Ports:
                analog-output-speaker: Speakers (priority: 10000)
        Active Port: analog-output-speaker
        Formats:
                pcm

可以看到alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo详细的信息。

你可能感兴趣的:(Jetson nano USB声卡调试)