zynthian / zynthian-issue-tracking

Centralized Issue Tracking for Zynthian Project
https://github.com/orgs/zynthian/projects/1
11 stars 3 forks source link

Support the Waveshare WM8960 Audio HAT #588

Open probonopd opened 2 years ago

probonopd commented 2 years ago

Is your feature request related to a problem? Please describe.

Please support the Waveshare WM8960 Audio HAT as an audio output device. It is inexpensive, has a built-in amplifier and comes with stereo speakers.

image

Describe the solution you'd like

It shoud be possible to select this device from the menu.

Describe alternatives you've considered

Running the following as instructed on https://github.com/waveshare/WM8960-Audio-HAT manually via ssh.

git clone https://github.com/waveshare/WM8960-Audio-HAT
cd WM8960-Audio-HAT
sudo ./install.sh 
sudo reboot

I don't know whether this would work. I don't want to ruin my installation. Also I would like to be able to select this from the menu.

Additional context

https://github.com/waveshare/WM8960-Audio-HAT

jofemodo commented 2 years ago

The wm8960 is already supported by the mainstream kernel and a DTBO is already included in the "/boot/overlays" directory. Please, could you try to load this DTBO? It would simplify things with zynthian ...

probonopd commented 2 years ago

Hi @jofemodo thanks for considering this. I am happy to test things out but need a little guidance.

Please, could you try to load this DTBO? It would simplify things with zynthian ...

Is the below approximately what I should do?

grep -q "dtoverlay=wm8960-soundcard" /boot/config.txt || \
  echo "dtoverlay=wm8960-soundcard" >> /boot/config.txt

Do I need to also do more, like the following?

#set kernel moduels
grep -q "i2c-dev" /etc/modules || \
  echo "i2c-dev" >> /etc/modules  
grep -q "snd-soc-wm8960" /etc/modules || \
  echo "snd-soc-wm8960" >> /etc/modules  
grep -q "snd-soc-wm8960-soundcard" /etc/modules || \
  echo "snd-soc-wm8960-soundcard" >> /etc/modules  

#set dtoverlays
sed -i -e 's:#dtparam=i2c_arm=on:dtparam=i2c_arm=on:g'  /boot/config.txt || true
grep -q "dtoverlay=i2s-mmap" /boot/config.txt || \
  echo "dtoverlay=i2s-mmap" >> /boot/config.txt

grep -q "dtparam=i2s=on" /boot/config.txt || \
  echo "dtparam=i2s=on" >> /boot/config.txt

#grep -q "dtoverlay=wm8960-soundcard" /boot/config.txt || \
#  echo "dtoverlay=wm8960-soundcard" >> /boot/config.txt

Would I also need https://github.com/waveshare/WM8960-Audio-HAT/blob/master/wm8960-soundcard, https://github.com/waveshare/WM8960-Audio-HAT/blob/master/asound.conf, and possibly more?

What is unclear to me is how what I am doing on the command line interacts with the Zynthian GUI, and whether there might be conflicts.

jofemodo commented 2 years ago

The first modification to /boot/config.txt should be enough. At less it's enough with most soundcards. You should try it and see if it works ;-)

Thanks!

probonopd commented 2 years ago

If I add dtoverlay=wm8960-soundcard to /boot/config.txt and reboot (still with the C-Media USB Headphone Set attached because without it will not boot up all the way into the GUI, showing instead the frightening Zythian logo shows up - disappears - Zythian logo shows up - disappears - Zythian logo shows up - disappears loop), then I do see the new device via ssh:

root@zynthian:~# cat /proc/asound/cards 
 0 [fmidi          ]: MIDI Gadget - f_midi
                      MIDI Gadget
 1 [b1             ]: bcm2835_hdmi - bcm2835 HDMI 1
                      bcm2835 HDMI 1
 2 [Headphones     ]: bcm2835_headpho - bcm2835 Headphones
                      bcm2835 Headphones
 3 [Set            ]: USB-Audio - C-Media USB Headphone Set
                      C-Media USB Headphone Set at usb-0000:01:00.0-1.4.3, full speed
 4 [wm8960soundcard]: wm8960-soundcar - wm8960-soundcard
                      wm8960-soundcard

How do I use it now? Trying

image

Rebooting.

Now I get the frightening Zythian logo shows up - disappears - Zythian logo shows up - disappears - Zythian logo shows up - disappears loop.

What do I have to enter into the "Jackd options" input field? It would be nice if this field would be automatically populated correctly based on the hardware autodetected in the device.

Also, after the reboot it seems like the device as disappeared?!

root@zynthian:~# cat /proc/asound/cards 
 0 [fmidi          ]: MIDI Gadget - f_midi
                      MIDI Gadget
 1 [b1             ]: bcm2835_hdmi - bcm2835 HDMI 1
                      bcm2835 HDMI 1
 2 [Headphones     ]: bcm2835_headpho - bcm2835 Headphones
                      bcm2835 Headphones
 3 [Set            ]: USB-Audio - C-Media USB Headphone Set
                      C-Media USB Headphone Set at usb-0000:01:00.0-1.4.3, full speed

and indeed, /boot/config.txt no longer contains my change...

probonopd commented 2 years ago

Retrying with:

image

and rebooting.

Geting the frightening Zythian logo shows up - disappears - Zythian logo shows up - disappears - Zythian logo shows up - disappears loop again.

probonopd commented 2 years ago

Now I cannot uncheck "Disable RBPi Audio" anymore. As soon as I uncheck it, it gets checked again immediately. /boot/config.txt now contains:

# Enable RBPi Onboard Audio (Headphones)
#RBPI_AUDIO_CONFIG#

# Soundcard Config
dtoverlay=wm8960-soundcard

And for whatever reason, wm8960soundcard is no longer in /proc/asound/cards:

root@zynthian:~# cat /proc/asound/cards 
 0 [fmidi          ]: MIDI Gadget - f_midi
                      MIDI Gadget
 1 [MK3            ]: USB-Audio - Keystation Mini 32 MK3
                      M-Audio Keystation Mini 32 MK3 at usb-0000:01:00.0-1.4.2, full speed
root@zynthian:~# aplay -l
**** List of PLAYBACK Hardware Devices ****

Did I break my system beyond repair?