Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Wolfson Audio Card by Element-14 #672

Merged
merged 0 commits into from Oct 1, 2014

Conversation

manish-wolfsonmicro
Copy link

Hi All,

Please find the patches to support Element 14 Wolfson Audio Card.

The patch bundle includes the machine driver and few other supporting patches to offer the functionality of WM5102 and WM8804 codecs drivers.
None of these patches needs to be pushed to Linux mainline as these are RPI specific.

The current patch-set does not support SPDIF functionality. We are working on a patch-set that will be pushed to the mainline Kernel and once these have been merged we will submit them for addition in to the raspberry-pi kernel.

For your reference, the following link takes you to the official product page.
http://www.element14.com/community/community/raspberry-pi/raspberry-pi-accessories/wolfson_pi?CMP=KNC-EU-RPI-ACC-Wolfson

~Manish Gupta

@popcornmix
Copy link
Collaborator

@hifiberry @koalo @hmbedded @iqaudio
Does this looks okay for existing rpi sound card users?

@koalo
Copy link
Contributor

koalo commented Aug 26, 2014

All in all it looks good.
A few comments:

ASOC: RPI : Add support for Wolfson Audio Card
rpi-wolfson-sound-pi.c:
For mainline this should be more generic since there is a lot of code duplication from bcm2708-i2s.c. For example by integrating the clock stuff into the platform driver if possible or even into an additional clock module, but for now it should be ok.

ASOC: BCM2708: Update pcm hw info flag
That is a far-reaching patch with possible side effects for the other codec boards. Especially activating MMAP was a big problem for some constellations. Please explain every additional line and why it is necessary for the Wolfson Card. Additionally, extensive testing with other codec boards is necessary.

ASOC:RPI:late initialization of dmaengine driver
Have you tested building the drivers as modules? Does it still work with this patch?

Greetings,
Florian

@iqaudio
Copy link

iqaudio commented Aug 26, 2014

Certainly the impact on other boards is a concern - would not be happy if this destabilizes other's product support.

Will look further into this.

update:

  • Florian, I agree that there is concern than the MMAP, amongst other, enabled as default base changes to bcm2708 may impact other devices. I'd like to see more testing conducted here against the other Pi audio cards and audio applications before such changes are incorporated. If I understand correctly it's not that there may be immediate impact on the other drivers but a calling ALSA / audio application will now assume that all audio cards support these features defined in the updated cpm info flag with unknown impact if acted upon. Maybe these changes can be made conditional on the Wolfson audio card being active?

On 26 Aug 2014, at 16:50, koalo notifications@github.com wrote:

All in all it looks good.
A few comments:

ASOC: RPI : Add support for Wolfson Audio Card
rpi-wolfson-sound-pi.c:
For mainline this should be more generic since there is a lot of code duplication from bcm2708-i2s.c. For example by integrating the clock stuff into the platform driver if possible or even into an additional clock module, but for now it should be ok.

ASOC: BCM2708: Update pcm hw info flag
That is a far-reaching patch with possible side effects for the other codecs. Especially activating MMAP was a big problem for some constellations. Please explain every additional line and why it is necessary for the Wolfson Card. Additionally, extensive testing with other codec boards is necessary.

ASOC:RPI:late initialization of dmaengine driver
Have you tested bullding the drivers as modules? Does it still work with this patch?

Greetings,
Florian


Reply to this email directly or view it on GitHub.

@samnazarko
Copy link
Contributor

Generally looking good.

Can you please provide a config that is based off bcmrpi_defconfig? If the current one already is, please rename it to bcmrpi_defconfig so we have a diff. I assume popcornmix is OK with this being enabled by default (which it will be if included in the defconfig) if it does not impact other hardware.

When building:

ERROR: "arizona_request_irq" [sound/soc/codecs/snd-soc-arizona.ko] undefined! make[1]: *** [__modpost] Error 1

This change seemed to fix things:

diff --git a/Kconfig.old b/Kconfig
index ed2f7b4..f6cba09 100644
--- a/Kconfig.old
+++ b/Kconfig
@@ -47,7 +47,6 @@ config SND_BCM2708_SOC_IQAUDIO_DAC
 config SND_BCM2708_SOC_RPI_CODEC_WSP
        tristate "Support for Wolfson sound pi"
        depends on SND_BCM2708_SOC_I2S
-       select SND_SOC_PCM512x
-       select SND_SOC_WM8804
+       depends on SND_SOC_ARIZONA
        help
          Say Y if you want to add support for Wolfson sound pi

When I boot Pi without a Wolfson card attached, I see the following:

Aug 26 17:15:12 raspbmc kernel: snd-rpi-wsp snd-rpi-wsp.0: ASoC: CODEC wm5102-codec not registered
Aug 26 17:15:12 raspbmc kernel: snd-rpi-wsp snd-rpi-wsp.0: Failed to register card: -517
Aug 26 17:15:12 raspbmc kernel: platform snd-rpi-wsp.0: Driver snd-rpi-wsp requests probe deferral

Here is my lsmod, post modprobe snd-soc-rpi-wsp

Module                  Size  Used by
snd_soc_rpi_wsp         6584  0 
bcm2708_wdog            2340  1 
ipv6                  251268  27 
xt_state                 664  1 
iptable_mangle           760  0 
iptable_nat             1736  0 
nf_conntrack_ipv4       8860  2 
nf_defrag_ipv4           760  1 nf_conntrack_ipv4
nf_nat_ipv4             2358  1 iptable_nat
nf_nat                  8820  2 nf_nat_ipv4,iptable_nat
nf_conntrack           54280  5 nf_nat,xt_state,nf_nat_ipv4,iptable_nat,nf_conntrack_ipv4
iptable_filter           624  1 
ip_tables              10592  3 iptable_filter,iptable_mangle,iptable_nat
x_tables               10532  4 ip_tables,xt_state,iptable_filter,iptable_mangle
snd_soc_pcm512x         6592  0 
snd_soc_wm8804          6064  0 
snd_soc_bcm2708_i2s     4668  0 
regmap_mmio             1796  1 snd_soc_bcm2708_i2s
snd_soc_core           98992  4 snd_soc_pcm512x,snd_soc_wm8804,snd_soc_rpi_wsp,snd_soc_bcm2708_i2s
snd_compress            6124  1 snd_soc_core
regmap_i2c               824  3 snd_soc_pcm512x,snd_soc_wm8804,snd_soc_core
snd_pcm_dmaengine       2428  1 snd_soc_core
regmap_spi               968  3 snd_soc_pcm512x,snd_soc_wm8804,snd_soc_core
snd_pcm                62036  3 snd_soc_core,snd_soc_rpi_wsp,snd_pcm_dmaengine
snd_page_alloc          2984  1 snd_pcm
snd_timer              17252  1 snd_pcm
snd                    41760  4 snd_soc_core,snd_timer,snd_pcm,snd_compress
i2c_bcm2708             3596  0 

thus I would suggest reducing noise in d7ea787. Otherwise this confuses users. Maybe pr_err should be pr_warn?

Others with sound card modules in the kernel should also take note here. Booting a vanilla kernel with no blacklisted modules, I will see probe failures for hardware I do not have attached! If you want to autoload your modules, you should not print failed probes as errors.

@cirrus-frankb
Copy link

Hi,
Just a quick update from the Wolfson side. Thanks for all the useful review feedback. We are currently working through this but as Manish is now out on holiday there will be a bit of a delay before we get back to everyone.
Best Regards
Francis

@pumphaus
Copy link

pumphaus commented Sep 2, 2014

I've tested these changes and there still seems to be a problem with recording 32 bit audio at 192 kHz. This has worked fine with the 3.10 kernel. 16 bit @ 192 kHz works fine, 32 bit @ 44.1 kHz works also fine. But with 32 bit @ 192 kHz I get loads of buffer overruns from arecord until it runs out of memory (or at least it says so - 'free -h' still shows plenty of free memory).

@liamw9534
Copy link

Using these patches against rpi-3.12.y, with the rpi_wolfson_sound_pi kernel config script, I have not yet been able to get anything out of my wolfson sound card (play or record). Historically, I have used rpi-3.10.y without any problems, so my hardware is known good.

Anyway, here's my input so far for what it's worth:

  • The rpi_wolfson_sound_pi_defconfig file is not at all obviously derived from the latest bcmrpi_defconfig so it is difficult to identify precisely which incremental config options are needed to support the sound card. I therefore second the request made to have the incremental configuration deltas versus bcmrpi_defconfig as opposed to a separately maintained file.
  • The wolfson sound card is detected as hw:1 rather than hw:0 (as it was on my old setup, with the NOOBS image supplied by Wolfson based on rpi-3.10.y). This difference breaks compatibility with the existing ALSA mixer setup shell scripts which have hw:0 hard coded throughout. Ideally, the actual ALSA card address should be determined by looking in /proc/asound/cards rather than assuming it will always be hw:0 in these shell scripts.
  • Overcoming the aforementioned ALSA addressing problem in the shell scripts, the scripts now appear to run without reporting any errors. However, sound playback fails, resulting in a aplay: pcm_write:1737: write error: Input/output error error when I run aplay and arecord produces files that are only ever 44 bytes long along with the error arecord: pcm_read:1828: read error: Input/output error

My root filesystem is admittedly now different (using a Buildroot FS rather than a Raspbian FS) but I see no reason why this should be a problem since alsa_lib and alsa_utils are installed and aplay works perfectly with bcm_2835 (mapped to hw:0) using the on-board headphone jack.

It is unclear to me what the issue is but I will keep digging since it could unearth a bug that could potentially affect other users.

@liamw9534
Copy link

Struggling to find the root cause of this problem, however it looks like some kind of SPI issue:

arizona spi0.1: FLL1: Timed out waiting for lock
bcm2708-i2s bcm2708-i2s.0: I2S SYNC error!
aplay: pcm_write:1737: write error: Input/output error
bcm2708-dmaengine bcm2708-dmaengine: DMA transfer could not be terminated

I had a look at the dmesg logs and see a number of errors during start-up (including FLL1: Timed out waiting for lock) but this was also the case when running the build from the earlier rpi-3.10 with Wolfson patches (which works). One difference I've spotted in the code, which is worth noting, is that the following code in bcm2708.c:

#ifdef CONFIG_BCM2708_SPIDEV
static struct spi_board_info bcm2708_spi_devices[] = {
#ifdef CONFIG_SPI_SPIDEV
        {
                .modalias = "spidev",
                .max_speed_hz = 500000,
                .bus_num = 0,
                .chip_select = 0,
                .mode = SPI_MODE_0,
        }, {
                .modalias = "spidev",
                .max_speed_hz = 500000,
                .bus_num = 0,
                .chip_select = 1,
                .mode = SPI_MODE_0,
        }
#endif
};
#endif

This will cause two attempts to initialize SPI bus 0 / cs 1. The second attempt fails, because it has already been allocated to snd_rpi_wsp_spi_devices. This seems to be an unnecessary run-time error. Probably need to put some conditional compilation around this.

@liamw9534
Copy link

@manish-wolfsonmicro I notice you're back online....would be interested to get your thoughts on the issues I've encountered. I haven't been able to root cause them yet myself.

@popcornmix popcornmix merged commit c256eb9 into raspberrypi:rpi-3.12.y Oct 1, 2014
@iqaudio
Copy link

iqaudio commented Oct 1, 2014

Dom, is it just the i2s GPIO settings that have been merged or is the full Wolfson set of changes being merged?

@popcornmix
Copy link
Collaborator

I've no idea what's happened. I updated kernel tree to 3.12.29. I didn't hit the merge button and github is showing that c256eb9 was merged from this PR.

However that commit is unrelated to this PR (it's a commit of mine), so I'm not actually sure if anything from this PR has been merged.

@manish-wolfsonmicro
Copy link
Author

I don't think anything form this PR has been merged .I was in the process of uploading new patch set on the same pull request , so I reverted the previous patches .There was nothing in there to merge.

~Manish

@popcornmix
Copy link
Collaborator

Seems like a github glitch.
@manish-wolfsonmicro I'm not sure if you can push new commits to this branch and reopen this PR, or if a new PR is required.

@manish-wolfsonmicro
Copy link
Author

Hi Dom,

I think you are right. It is not showing me any option of pushing new commits or reopen the PR.
I need to open another PR I believe.

~Manish

pfpacket pushed a commit to pfpacket/linux-rpi-rust that referenced this pull request Apr 7, 2023
treewide: update/normalize comment style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants