After spending far too much time trying to figure out how to get this configured correctly, I actually managed to get it running flawlessly. The end result is running LMS/squeezebox through max2play while also streaming from the S/PDIF In and Line In ports on the Wolfson card. The reason I wanted to do this is so that I could listen to Google Play Music (Max2Play being the only real option), vinyl records from turntable (Line In), or Xbox (games/plex streaming) on their own or in any combination without having to run any commands.
Max2Play
Simple to set up, make sure you download the base "Max2Play Raspberry Pi Image" as it runs Jessie-Lite without any extras. The squeezeplug version runs wheezy which makes installing googleplaymusicapi unreasonable. After you flash your SD card and let M2P install, ensure you have the Raspberry Setting Plugin enabled. Go ahead and install Squeezelite from the "Audioplayer" tab and if you want, grab shareport and the DLNA client (Also available as Squeezebox plugins). Install Logitech Media Server under "Squeezebox Server", make sure you install the 7.9 nightly release if you want to use Google Play Music. This installation will take 5-10 minutes so just be patient, Max2Play conveniently shows the installation log as it goes so you don't have to guess at its success. After it is complete, install the Google Play Music plugin and the ShareTunes2 plugin for airplaying files from iOS devices.
Cirrus Logic Setup
Reboot the pi once more and navigate to the "Raspberry Settings" tab. Select the Wolfson Card from the drop down list and reboot when prompted. Return to the same tab and check the "Enable I2S-MMAP (Mixerdevice for Soundcards)" check box. Now we get to where I started struggling. After reading every post from Ragnar (GOAT for this forum by the way!!!) numerous times I finally figured it out. First off, even though M2P knows you have a sound card in use at this point, it never changes the card number in the ALSA device structure. This was an oversight on their part so I chose instead to use Ragnar's .asoundrc file instead.
sudo cp /etc/asound.conf ~/asound.conf.backup # Make a copy of Ragnar's .asoundrc sudo mv ~/.asoundrc /etc/asound.conf
Note: M2P implements a different order for sound cards than Ragnar's kernel does. So you will have to replace every "card 0" with "card 1"
Next, edit /opt/max2play/audioplayer.conf and change the squeezelite command to:
"SQUEEZELITE_PARAMETER=-o default -a 16"
This sets the audio device to the default device as configured in /etc/asound.conf which we set up to allow multiple input streams/recordings at once.
Routing Setup
M2P implements a slightly varied set of use case scripts that you will find whenever this sound card comes up and will be found in /opt/max2play/wolfson/
Since I am using the LineOut port, I edited the "Playback_to_Lineout.sh" file found in this directory. This script is run by Max2Play whenever squeezelite is started so it is kind of the only relevant script in this example. It is pretty straight forward to adapt to other outputs though. But here is my edited script:
#!/bin/bash # $1 added to support 1st line argument. i.e. "./Playback_to_Lineout.sh -q" will stop all the control information #being displayed on screen #Playback from AP to Line Output, default gain 0dB amixer $1 -Dhw:sndrpiwsp cset name='SPDIF In Switch' on # Clear the HPOUT2 Input 1 and 2 mixers. This will ensure no previous paths are connected to the HPOUT2. This doesn't # include Inputs 3 and 4. amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 1' None amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 1' None amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 2' None amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 2' None amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 3' None amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 3' None # Setup HPOUT2 input path and volume for streaming amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 1' AIF1RX1 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 1 Volume' 20 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 1' AIF1RX2 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 1 Volume' 20 # Setup HPOUT2 input path and volume for S/PDIF in # Pass through Low/High Pass Filter Fers amixer $1 -Dhw:sndrpiwsp cset name='LHPF3 Input 1' AIF2RX1 amixer $1 -Dhw:sndrpiwsp cset name='LHPF4 Input 1' AIF2RX2 amixer $1 -Dhw:sndrpiwsp cset name='LHPF3 Mode' High-pass amixer $1 -Dhw:sndrpiwsp cset name='LHPF4 Mode' High-pass amixer $1 -Dhw:sndrpiwsp cset name='LHPF3 Coefficients' 240,3 amixer $1 -Dhw:sndrpiwsp cset name='LHPF42 Coefficients' 240,3 # Now add as input to HPOUT2 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 2' LHPF3 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 2' LHPF4 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 2 Volume' 15 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 2 Volume' 15 # Setup HPOUT2 input path and volume for Line-in better THD in normal mode vs lower noise floor in high performance amixer $1 -Dhw:sndrpiwsp cset name='IN3 High Performance Switch' on # Configure the input path for 0dB Gain, HPF with a low cut off for DC removal amixer $1 -Dhw:sndrpiwsp cset name='LHPF1 Input 1' IN3L amixer $1 -Dhw:sndrpiwsp cset name='LHPF2 Input 1' IN3R amixer $1 -Dhw:sndrpiwsp cset name='LHPF1 Mode' High-pass amixer $1 -Dhw:sndrpiwsp cset name='LHPF2 Mode' High-pass amixer $1 -Dhw:sndrpiwsp cset name='LHPF1 Coefficients' 240,3 amixer $1 -Dhw:sndrpiwsp cset name='LHPF2 Coefficients' 240,3 # Now mix to HPOUT2 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 3' LHPF1 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 3' LHPF2 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 3 Volume' 32 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 3 Volume' 32 #Finally unmute HPOUT2 amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2 Digital Switch' on
That should do it! Now you can play from those three sources independently and simultaneously. All that is left is to open the LMS webui and configure squeezebox plugins to your needs!
Shoutout to ragnar.jensen for knowing the inner workings better than I ever will!