1 2 3 Previous Next 278 Replies Latest reply on Oct 10, 2017 2:43 PM by psyj

    New reworked driver for Wolfson/Cirrus Logic audio card

    hiassoft

      I've been working on a driver rework, mainly to get rid of the requirement to carry around a bunch of patches to upstream driver code, and also to fix some outstanding issues and introduce some new features.

       

      Most issues have been ironed out so here's the first public release.

       

      Edit: the driver has been included in official RPi kernels. Just run sudo rpi-update to install it.

      You still have to install the mixer scripts and add the /etc/modprobe.d file. See my website for details

      RPi Linux driver for Wolfson / Cirrus Logic Audio Card

       

      Source: https://github.com/HiassofT/rpi-linux/tree/cirrus-ng-4.9.0

      Precompiled kernel: http://www.horus.com/~hias/tmp/cirrus/cirrus-ng-linux-4.9.0.tgz

      New mixer scripts: http://www.horus.com/~hias/tmp/cirrus/cirrus-ng-scripts.tgz

       

      Important notes:

      • The new driver bases on the rather fresh kernel 4.9.0 which means there's some risk of (yet unknown) issues. Use it at your own risk and please run "rpi-update" to get the latest firmware before installing the new driver.
      • The soundcard name has been changed from "snd_rpi_wsp" to "RPi-Cirrus", also several ALSA controls have been removed and new ones were added. This means the old usecase scripts and any custom-made scripts will no longer work. Use the new mixer scripts instead of the old usecase/listen scripts.
      • The new driver supports setting (and receiving) of the S/PDIF channel status bits (aka AES bits). If you add an ALSA card configuration file this means applications like Kodi can do proper AC3/DTS passthrough. A sample card configuration file (plus the mixer scripts) can be found here: https://github.com/HiassofT/rpi-cirrus-config
      • I haven't fully updated the documentation on my website RPi Linux driver for Wolfson / Cirrus Logic Audio Card  yet, will do that during the next weeks/months. But except for the things noted above most stuff should still work as in previous driver versions.

       

      Please report back if you tested the driver (either successfully or unsuccessfully), any feedback will help me!

       

      so long,

       

      Hias

        • 1. Re: New reworked driver for Wolfson/Cirrus Logic audio card
          mskyaxl

          Thanks for updating this! I'll try it today and come back with a feedback.

           

          [edit]

          I just saw  that this is for kernel 4.9.  rpi-update will just update to 4.4.38. Should I try installing it on this version?

           

          [edit2]

          I'm back with some feedback.

           

          At first I've tried to compile from source but for some reasons the sound card was not shown although the compilation was successful. I did not try the second time as it takes a loooot of time. What I did instead was to use your binaries directly and it worked meaning that I had audio on output.

           

           

          I've notices that in  dmesg I get some errors:

           

           

           

          [    2.450796] systemd[1]: Starting Encrypted Volumes.
          [    2.491344] usb 1-1.4: New USB device found, idVendor=046d, idProduct=c52e
          [    2.491355] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
          [    2.491362] usb 1-1.4: Product: USB Receiver
          [    2.491369] usb 1-1.4: Manufacturer: Logitech
          [    2.513696] input: Logitech USB Receiver as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C52E.0001/input/input0
          [    2.576217] hid-generic 0003:046D:C52E.0001: input,hidraw0: USB HID v1.11 Keyboard [Logitech USB Receiver] on usb-3f980000.usb-1.4/input0
          [    2.583759] input: Logitech USB Receiver as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C52E.0002/input/input1
          [    2.646054] hid-generic 0003:046D:C52E.0002: input,hiddev0,hidraw1: USB HID v1.11 Mouse [Logitech USB Receiver] on usb-3f980000.usb-1.4/input1
          [    3.319367] systemd-udevd[143]: starting version 215
          [    3.702546] gpiomem-bcm2835 3f200000.gpiomem: Initialised: Registers at 0x3f200000
          [    3.854333] arizona spi0.1: Failed to get mclk1: -2
          [    3.854351] arizona spi0.1: Failed to get mclk2: -2
          [    3.854826] LDO1: supplied by RPi-Cirrus 1v8
          [    3.864272] arizona spi0.1: WM5102 revision C
          [    3.890200] Adding alias for supply MICVDD,(null) -> MICVDD,spi0.1
          [    3.890723] Adding alias for supply MICVDD,(null) -> MICVDD,spi0.1
          [    3.890730] Adding alias for supply DBVDD2,(null) -> DBVDD2,spi0.1
          [    3.890736] Adding alias for supply DBVDD3,(null) -> DBVDD3,spi0.1
          [    3.890743] Adding alias for supply CPVDD,(null) -> CPVDD,spi0.1
          [    3.890749] Adding alias for supply SPKVDDL,(null) -> SPKVDDL,spi0.1
          [    3.890755] Adding alias for supply SPKVDDR,(null) -> SPKVDDR,spi0.1
          [    3.908398] MICVDD: supplied by RPi-Cirrus 1v8
          [    3.913997] snd-rpi-cirrus soc:sound: ASoC: CODEC DAI wm5102-aif1 not registered
          [    3.924215] snd-rpi-cirrus soc:sound: ASoC: CODEC DAI wm5102-aif1 not registered
          [    3.929051] wm8804 1-003b: revision E
          [    3.930445] snd-rpi-cirrus soc:sound: ASoC: CODEC DAI wm5102-aif1 not registered
          [    4.090662] snd-rpi-cirrus soc:sound: wm5102-aif1 <-> 3f203000.i2s mapping ok
          [    4.124437] usbcore: registered new interface driver brcmfmac
          [    4.250137] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
          [    4.280279] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: May 27 2016 00:13:38 version 7.45.41.26 (r640327) FWID 01-df77e4a7
          [    4.321667] brcmfmac: brcmf_cfg80211_reg_notifier: not a ISO3166 code (0x30 0x30)
          [    4.498695] brcmfmac: brcmf_cfg80211_reg_notifier: not a ISO3166 code (0x30 0x30)
          [    4.765902] systemd-journald[141]: Received request to flush runtime journal from PID 1
          [    5.403864] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
          [    5.403874] brcmfmac: power management disabled
          [    6.048178] uart-pl011 3f201000.serial: no DMA platform data
          [    6.311183] Adding 102396k swap on /var/swap.  Priority:-1 extents:2 across:217084k SSFS
          [    6.636395] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
          [    8.120974] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
          [   10.458792] Bluetooth: Core ver 2.22
          [   10.458918] NET: Registered protocol family 31
          [   10.458924] Bluetooth: HCI device and connection manager initialized
          [   10.460116] Bluetooth: HCI socket layer initialized
          [   10.460140] Bluetooth: L2CAP socket layer initialized
          [   10.460185] Bluetooth: SCO socket layer initialized
          [   10.468484] Bluetooth: HCI UART driver ver 2.3
          [   10.468498] Bluetooth: HCI UART protocol H4 registered
          [   10.468503] Bluetooth: HCI UART protocol Three-wire (H5) registered
          [   10.468707] Bluetooth: HCI UART protocol Broadcom registered
          [   10.666681] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
          [   10.666690] Bluetooth: BNEP filters: protocol multicast
          [   10.666708] Bluetooth: BNEP socket layer initialized
          [   39.934339] random: crng init done
          [ 2744.08356/5] bcm2835-i2s 3f203000.i2s: I2S SYNC error!

          do you know why?

           

          Another thing I would like to "route" from line in to line out is this possible using the "usecase" scripts?

           

          If you want I can try again the compilation if you want to be sure that this works on a different machine.

           

          Thanks!

           

          [edit3]

          I've just found how to route.

           

          sudo ./Cirrus_listen.sh line line

          1 of 1 people found this helpful
          • 2. Re: New reworked driver for Wolfson/Cirrus Logic audio card
            hiassoft

            Hi Alex, thanks a lot for your feedback!

             

            I just saw that this is for kernel 4.9. rpi-update will just update to 4.4.38. Should I try installing it on this version?

            Yes, this is fine. The reason for running rpi-update is to get a recent gpu firmware version.

            At first I've tried to compile from source but for some reasons the sound card was not shown although the compilation was successful. I did not try the second time as it takes a loooot of time. What I did instead was to use your binaries directly and it worked meaning that I had audio on output.

            It's hard to tell what went wrong but my guess would be missing to install the dtb and dtbo files and/or modules. If you still have the compiled tree you could try reinstalling it, it should work just fine.

            I've notices that in dmesg I get some errors:

            [ 3.913997] snd-rpi-cirrus soc:sound: ASoC: CODEC DAI wm5102-aif1 not registered
            [ 3.924215] snd-rpi-cirrus soc:sound: ASoC: CODEC DAI wm5102-aif1 not registered

            You can ignore these, they come from the kernel deferred probing mechanism. It just means that bcm2835-i2s hadn't been loaded/initialized by the time the kernel tried to load/init the sound card driver.

            sudo ./Cirrus_listen.sh line line

            BTW: you can omit "sudo", running the alsa mixer scripts should work fine as a normal user.

             

            so long,

             

            Hias

            1 of 1 people found this helpful
            • 3. Re: New reworked driver for Wolfson/Cirrus Logic audio card
              mskyaxl

              Thanks Hias for the reply,

               

              I have another questions as I am quite new to alsa.

              I get sound only when I test it via command line using for example

               

              mplayer -volume 100 file.flac

               

              I've tried some things like running rpi3 with pixel, emulationstation(retropie) and kodi but have some issues as I do not have sound.

              I've disabled the default sound card.

               

              I think it has something to do with the mixer and I think I have to update

              /etc/asound.conf

               

              but I don't know whith what. amixer is returning a lot of entries.

               

              Do you know how to "fix" this?

               

              Thanks!

              1 of 1 people found this helpful
              • 4. Re: New reworked driver for Wolfson/Cirrus Logic audio card
                hiassoft

                Usually you shouldn't have to change /etc/asound.conf or ~/.asoundrc.

                 

                Could you post the output of

                aplay -l
                

                 

                BTW: in case of kodi make sure you select the RPi-Cirrus card in audio settings, default usually is to play back via HDMI only. Also make sure you have MMAL video acceleration enabled - OMX can't output to ALSA.

                 

                so long,

                 

                Hias

                1 of 1 people found this helpful
                • 5. Re: New reworked driver for Wolfson/Cirrus Logic audio card
                  mskyaxl

                  aplay -l returns

                   

                  **** List of PLAYBACK Hardware Devices ****
                  card 0: RPiCirrus [RPi-Cirrus], device 0: WM5102 AiFi wm5102-aif1-0 []
                    Subdevices: 1/1
                    Subdevice #0: subdevice #0
                  

                   

                   

                  BTW: in case of kodi make sure you select the RPi-Cirrus card in audio settings, default usually is to play back via HDMI only. Also make sure you have MMAL video acceleration enabled - OMX can't output to ALSA.

                  You are right about kodi, I remember I did this last time with the previous driver and it worked I do not have it yet installed yet.

                   

                  I had raspbian lite installed with retropie and I got issues like

                   

                  VolumeControl::init() - Failed to find mixer elements!
                  

                   

                  and as far as I understood emulation station assumes that the default alsa mixer is PCM, that's why I was thinking that /etc/asound.conf has to be updated. Somehow I have to point out which is the right mixer.

                   

                  Having this I said that I should first get the normal raspbian working so I've flashed raspbian lite again and it worked from command line as shown below and afterwards I tried it also on full raspbian with the new pixel desktop and again the volume control is not working and trying to play anything from GUI fails, for example Chronium crashes. I tried to figure out which is the correct mixer but I get a long list.

                   

                  In general I would like to be able to route from line in to line out as I want have a vinyl player connected to it. I want to use it as my main media player(most probably kodi) and optional I would like to play around with retropie.

                  1 of 1 people found this helpful
                  • 6. Re: New reworked driver for Wolfson/Cirrus Logic audio card
                    kevin1313

                    Hias,

                     

                    Thanks for the comment about ALSA not working with OMX! My card was working 2 days ago but I didn't know it while using OMX to test. But now my RPi2 is updated to Jessie and the audio card is working!!!

                     

                    Also thanks for ALL the work you have done on the updates!

                     

                    Thanks,

                    Kevin

                    1 of 1 people found this helpful
                    • 7. Re: New reworked driver for Wolfson/Cirrus Logic audio card
                      hiassoft

                      Chromium crashing with kernel 4.9 is a known issue and should be fixed in a future chromium update. Read more about it (and a workaround for the issue) here in the official 4.9 kernel thread:

                      https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=167934

                       

                      I did a quick test on the current Jessie release (with pixel desktop) and VLC played fine, chromium started with --no-sandbox was also able to play a youtube video.

                       

                      The main control for the lineout volume would be "HPOUT2 Digital". Make sure you don't set it to more than 50% or you'll get clipping (that control can also be used to boost very low volume signals). As an alternative you can change your ~/.asoundrc and use the softvol plugin to create a sofware "PCM" mixer control - but note that this'll affect only the PCM output from the RPi, not any other signals (like linein) that you mixed into the lineout signal:

                      pcm.!default {
                          type            softvol
                          slave.pcm       "plughw:RPiCirrus"
                          control.name    "PCM"
                          control.card    RPiCirrus
                      }
                      

                       

                      I'm not sure about the issues you've seen with retropie/emulationstation. I'm using emulationstation on LibreELEC (from the gamestarter addon) and it worked fine out of the box (only had to disable onboard sound which was automatically enabled by the addon), didn't see any issues about non-existent mixers.

                       

                      so long,

                       

                      Hias

                      2 of 2 people found this helpful
                      • 8. Re: New reworked driver for Wolfson/Cirrus Logic audio card
                        hiassoft

                        The problem with retropie is that it cannot detect the platform, this is a general retropie issue with kernel 4.9: https://github.com/RetroPie/RetroPie-Setup/issues/1809

                         

                        As a workaround you could trying to add

                        __platform="rpi3"
                        

                        (or whatever plaform you are running it on) to /home/pi/RetroPie-Setup/retropie_packages.sh or wait for retropie to resolve the issue.

                         

                        so long,

                         

                        Hias

                        1 of 1 people found this helpful
                        • 9. Re: New reworked driver for Wolfson/Cirrus Logic audio card
                          mskyaxl

                          Yes, I know and fixed that some days ago. Thanks for the reply!

                           

                          I've been reading these days all kinds of wikies and forums about the audio layer of linux(alsa, sdl, omx, etc etc - and it seems that the things are not standardized at all). I think that now my issue lies in the way the application uses the sound card.

                           

                          Currently:

                          -Kodi seems to be working fine

                          -Pixel desktop...I don't know yet(maybe it is using OMX?), anyway currently I'm not really interested in using it.

                          -Retropie(emulationstation to be more precise) seems to output sound while "browsing" the settings but it stops when I enter in a "rom" but it seems not to be a problem of this driver but some configuration I have to do [see later edit]

                           

                          Thanks for the big contribution and I'll get back if I manage to solve some of these problems!

                           

                          [later edit]

                          I saw afterwards the first post. The error in emulationstation is gone now after doing what you suggested. although I think I will switch to your setup as I think I want more to have kodi as main and to launch emulationstation from kodi than the other way around.

                           

                          Thanks again!

                          1 of 1 people found this helpful
                          • 10. Re: New reworked driver for Wolfson/Cirrus Logic audio card
                            hiassoft

                            FYI: Yesterday I released a new LibreELEC build which also uses this new driver:

                            https://forum.libreelec.tv/thread-3387.html

                             

                            As for Linux audio layers, actually it's quite simple:

                             

                            OMX is RPi specific and IIRC only used by Kodi and the standalone omxplayer application. I interfaces directly with the RPi GPU and can do video decoding and audio output.

                             

                            All other Linux applications either use ALSA directly or indirectly via some libraries (like SDL) or audio servers (like PulseAudio or Jack).

                             

                            Personally I'm not a big fan of these audio servers (Pulse has been a real PITA to configure and caused more problems than it solved for me) so unless you really need to use Pulse Audio (eg to connect a bluetooth headset or to be able to quickly switch between HDMI audio and integrated speakers on a laptop) better not install it and stick to pure ALSA. Raspbian ships with ALSA only and fortunately doesn't have Pulse enabled

                             

                            so long,

                             

                            Hias

                            2 of 2 people found this helpful
                            • 11. Re: New reworked driver for Wolfson/Cirrus Logic audio card
                              mskyaxl

                              Thanks, its working fine but what I find really annoying is that I cannot use apt-get to install packages.

                               

                              Happy new year!

                               

                              Alex

                              1 of 1 people found this helpful
                              • 12. Re: New reworked driver for Wolfson/Cirrus Logic audio card
                                phxang

                                Thank you Hias for detailed instructions. I did all exactly and sound appeared.

                                But I have problem. Sound goes only from single source.

                                Raspberry Pi 3, Raspbian Jessie, compiled 4.9.0 kernel without any config changes.

                                1 of 1 people found this helpful
                                • 13. Re: New reworked driver for Wolfson/Cirrus Logic audio card
                                  phxang

                                  PulseAudio helped me to solve some problems. But I still can't listen from mpd and other applications together. I think something in mpd config, but I can't discover it.

                                  1 of 1 people found this helpful
                                  1 2 3 Previous Next