Getting audio jack to work on BPI-M64

Hi, I did get my BPI-M64 up and running with the 4.4 Debian image

pi@bpi-iot-ros-ai:~$ uname -a
Linux bpi-iot-ros-ai 4.4.89-BPI-M64-Kernel #8 SMP PREEMPT Thu Nov 1 15:46:06 CST 2018 aarch64 GNU/Linux
pi@bpi-iot-ros-ai:~$ cat /etc/issue
Debian GNU/Linux 9 \n \l

With the help of some forum posts I got Ethernet and WiFi up and running.

Then I tried to get the audio-jack working. Unfortunately most forum and wiki posts seem either to describe way older configurations, or newer ones. As far as I understand the new device tree configuration is however only available in newer kernels like 4.19

As a side note I saw the git repo of the 4.4 kernel at https://github.com/BPI-SINOVOIP/BPI-M64-bsp-4.4 and for the R64 board one using kernel 4.19 at https://github.com/BPI-SINOVOIP/BPI-R64-bsp-4.19 , sadly however it seems to be not compatible with the M64. Have to see if I get Armbian running instead.

Anyhow what I tried so far to try yo get the audio-jack running:

Replace asound.state and aound.state.bpi-m64 under /var/lib/alsa

Try to unmute

pi@bpi-iot-ros-ai:~$ amixer set Master unmute
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 65536 [100%] [on]
  Front Right: Playback 65536 [100%] [on]
pi@bpi-iot-ros-ai:~$ sudo amixer | grep Headphone -A 10
Simple mixer control 'Headphone',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Linein_detect',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'Phoneout Mixer Lout_Mixer_Switch',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono

Checkin devices

pi@bpi-iot-ros-ai:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC codec-aif1-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: audiocodec [audiocodec], device 1: bb Voice codec-aif2-1 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: audiocodec [audiocodec], device 2: bb-bt-clk codec-aif2-2 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: audiocodec [audiocodec], device 3: bt Voice codec-aif3-3 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sndhdmi [sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
pi@bpi-iot-ros-ai:~$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default
    Playback/recording through the PulseAudio sound server
sysdefault:CARD=audiocodec
    audiocodec,
    Default Audio Device
dmix:CARD=audiocodec,DEV=0
    audiocodec,
    Direct sample mixing device
dmix:CARD=audiocodec,DEV=1
    audiocodec,
    Direct sample mixing device
dmix:CARD=audiocodec,DEV=2
    audiocodec,
    Direct sample mixing device
dmix:CARD=audiocodec,DEV=3
    audiocodec,
    Direct sample mixing device
dsnoop:CARD=audiocodec,DEV=0
    audiocodec,
    Direct sample snooping device
dsnoop:CARD=audiocodec,DEV=1
    audiocodec,
    Direct sample snooping device
dsnoop:CARD=audiocodec,DEV=2
    audiocodec,
    Direct sample snooping device
dsnoop:CARD=audiocodec,DEV=3
    audiocodec,
    Direct sample snooping device
hw:CARD=audiocodec,DEV=0
    audiocodec,
    Direct hardware device without any conversions
hw:CARD=audiocodec,DEV=1
    audiocodec,
    Direct hardware device without any conversions
hw:CARD=audiocodec,DEV=2
    audiocodec,
    Direct hardware device without any conversions
hw:CARD=audiocodec,DEV=3
    audiocodec,
    Direct hardware device without any conversions
plughw:CARD=audiocodec,DEV=0
    audiocodec,
    Hardware device with all software conversions
plughw:CARD=audiocodec,DEV=1
    audiocodec,
    Hardware device with all software conversions
plughw:CARD=audiocodec,DEV=2
    audiocodec,
    Hardware device with all software conversions
plughw:CARD=audiocodec,DEV=3
    audiocodec,
    Hardware device with all software conversions
sysdefault:CARD=sndhdmi
    sndhdmi,
    Default Audio Device
dmix:CARD=sndhdmi,DEV=0
    sndhdmi,
    Direct sample mixing device
dsnoop:CARD=sndhdmi,DEV=0
    sndhdmi,
    Direct sample snooping device
hw:CARD=sndhdmi,DEV=0
    sndhdmi,
    Direct hardware device without any conversions
plughw:CARD=sndhdmi,DEV=0
    sndhdmi,
    Hardware device with all software conversions

tried to change asound.conf

pi@bpi-iot-ros-ai:~$ cat /etc/asound.conf
#pcm.!default {
#    type hw
#    card 1    #If you want to set HDMI as output ,turn 0 to 1.
#    device 0
#}
#ctl.!default {
#    type hw
#    card 1   #If you want to set HDMI as output ,turn 0 to 1.
#}

pcm.!default {
    type hw card 0 device 0
}
ctl.!default {
    type hw card 0
}

try to play a sound

pi@bpi-iot-ros-ai:~$ aplay -vD hw:0,0 /usr/share/sounds/alsa/Front_Center.wav
Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
Hardware PCM card 0 'audiocodec' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 1
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 16
  buffer_size  : 24000
  period_size  : 6000
  period_time  : 125000
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 6000
  period_event : 0
  start_threshold  : 24000
  stop_threshold   : 24000
  silence_threshold: 0
  silence_size : 0
  boundary     : 6755399441055744000
  appl_ptr     : 0
  hw_ptr       : 0
pi@bpi-iot-ros-ai:~$ sudo speaker-test -c2 -D plughw:0,0

speaker-test 1.1.3

Playback device is plughw:0,0
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 32 to 16384
Period size range from 31 to 16385
Using max buffer size 16384
Periods = 4
was set period_size = 4096
was set buffer_size = 16384
 0 - Front Left
 1 - Front Right
Time per period = 5.673465
 0 - Front Left
 1 - Front Right
...

to no avail…

Running on the Ubuntu build version 4.4.89-a64 I got the audo jack working. So it is not a hardware defect.

Interestingly it seems to be a configuration thing in the alsamixer of different values for

  • AIF1 DAC timeslot 0 volume : 69% °
  • AIF1 DAC timeslot 1 volume : 32% °
  • AIF1IN0L Mux [AIF1_DA0L]
  • AIF1IN0R Mux [AIF1_DA0R] °
  • AIF1IN1L Mux [AVE_AIF1DA1L_AIF1DA1R]
  • AIF1IN1R Mux [AVE_AIF1DA1L_AIF1DA1R] °
  • AIF1OUT0L Mux [AVE_AIF1AD0L_AIF1AD0R]
  • AIF1OUT0R Mux [AVE_AIF1AD0L_AIF1AD0R]
  • AIF1OUT1L Mux [AVE_AIF1AD1L_AIF1AD1R]
  • AIF1OUT1R Mux [AVE_AIF1AD1L_AIF1AD1R]
  • AIF2 ADC mixer gain : 20%
  • AIF2 ADC volume : 0%
  • AIF2 DAC volume : 0%
  • AIF2INL Mux [AVE_AIF2DACL_AIF2DACR]
  • AIF2INR Mux [AVE_AIF2DACL_AIF2DACR]
  • AIF2OUTL Mux [AVE_AIF2_ADCL_AIF2_ADCR]
  • AIF2OUTR Mux [AVE_AIF2_ADCL_AIF2_ADCR]
  • AIF3OUT Mux [NULL]
  • DAC mixer gain : 20%
  • DAC volume : 60%
  • HP_L Mux [Left Analog Mixer HPL Switch] °
  • HP_R Mux [Right Analog Mixer HPL Switch] °
  • digital volume : 25% °
  • earpiece volume : 0%
  • headphone volume : 75% °
  • speaker volume : 0%

Especially the values with ° had the most impact. For example increasing digital volume actually reduced the overall volume. But going below 20 increased noise. Same for headphone volume, going over volume 80 increased noise. Increasing DAC mixer gain also reduced overall volume. Likewise the combination of the both AIF1 DAC values lead either to more noise or lowered the volume. Changing AIF1IN0L and AIF1IN0R to either AVE… or SUM… actually disabled output.

I do have an additionl entry for pulse in the aplay output:

...
pulse
    PulseAudio Sound Server
...