Repository navigation
Conversation
Allow everything the videocore accepts.
This is required at least for SPDIF. If the bitrate goes above, videocore will either resample the audio or corrupt it due to underruns. Supposedly the hardware isn't designed to output higher rates, but it can still resample it down to supported rates. Some code is based on ac97_pcm.c.
Add audioserv 3 extensions. The changes were taken from the paste linked here: #1166 (comment)
Report all layouts supported by the HDMI protocol to userspace. Make the videocore set the correct layout according to the userspace request. Some code taken from patch_hdmi.c. In particular, the HDMI channel layout table was copied without changes - with the idea in mind that hopefully it can be shared one day. Or at least updating it will be simpler. In my tests, everything appears to work, except when outputting FL FR RL RR. Then my receiver outputs RL on both the RL and RR speakers, while RR is never heard.
I don't think the ALSA framework provides any kind of automatic synchronization within the control callbacks. We most likely need to ensure this manually, so add locking around all access to shared mutable data. In particular, bcm2835_audio_set_ctls() should probably always be called under our own audio lock.
Pad the unused channels with NA. This means userspace needs to write additional, silent padding channels, which is not ideal, but better than noise. Works around noise at the following channel counts: 3, 5, 6, 7
Sending more than 2 channels to videocore while outputting to analogue mysteriously outputs heavy artifacts. So just paint it over with a hack: if analogue is explicitly selected as destination, do not reporting support for anything other than stereo. I'm not sure how to deal with the auto case (destination 0). There's probably way to retrieve this and even to listen to plug events, but I didn't find one yet, and it's probably not worth the trouble. Just don't use this setting, I guess. Unless you like noise. Changing the setting while an audio stream is active also doesn't work properly. We could probably interrupt running streams by returning ENODEV or using kernel hotplug stuff (maybe), but that also doesn't seem worth the trouble.
It appears the GPU only sends us a message all 10ms to update the playback progress. Other than this, the playback position (what SNDRV_PCM_IOCTL_DELAY will return) is not updated at all. Userspace will see jitter up to 10ms in the audio position. Make this a bit nicer for userspace by interpolating the position using the CPU clock. I'm not sure if setting snd_pcm_runtime.delay is the right approach for this. Or if there is maybe an already existing mechanism for position interpolation in the ALSA core. I only set SNDRV_PCM_INFO_BATCH because this appears to remove at least one situation snd_pcm_runtime.delay is used, so I have to worry less in which place I have to update this field, or how it interacts with the rest of ALSA. In the future, it might be nice to use VC_AUDIO_MSG_TYPE_LATENCY. One problem is that it requires sending a videocore message, and waiting for a reply, which could make the implementation much harder due to locking and synchronization requirements.
|
As this PR has some potential to break things, I've added the commits to 4.4 branch first. What's the best way of testing multichannel output? |
Not sure. Other than programs which use the channel map API, I don't think ALSA has a test program or anything. |
|
So what have you tested with? |
|
I tested only with mpv. I also did some tests with some ALSA tools, but since they don't use the channel mapping API, these are pretty worthless. |
|
PS: it's possible that other applications have problems with this due to the strange padding configuration, but on the other hand it shouldn't be worse than say HDMI over the nvidia binary driver. Possible that the NA channel entries cause issues to other programs, though. |
|
I'm evangelizing this change with the DIYAudio and Volumio communities, pointing them to this thread. @wm4, would it be simple to add step-by-step instructions for users wanting to validate this fix? Looks like it's a kernal update and then run mpv? |
|
Hm, that's kind of hard. I think I've tested enough with mpv; anything that can use the channel map API should be able to make is of it. My main "worry" is that the channel maps include NA channels (which is supposed to make the application insert padding), and I'm not sure how widely understood this is. |
|
PS: not sure if I made it explicit yet, but this also requires raspbian with updated alsa-lib. Not sure what's raspbian's state - my current installation is an old one, and it was indeed too old. |
|
@wm4 Can you also comment on why, with these changes having been applied to 4.4.y, it is not possible to save/restore via alsactl. eg. $ sudo alsactl store 0 |
|
It appears to access the channel map control even though no playback is active, which is not supported by the changes. |
|
Hmmm. Just about every distribution is storing and re-storing at shutdown/boot. Built-in ALSA device is typically card 0, and if "alsactl store" errors on the first device before it even gets to the cards whose mixer settings I do really want stored, then those settings for the cards I do want stored. eg. mute/volume level, do not survive a reboot...... These changes need to be backed out while things like this are thought about, IMHO!!!!!! |
|
Here's a link to some files for testing multichannel output: https://www2.iis.fraunhofer.de/AAC/multichannel.html You can either download the files or stream them via RTMP. I've done some testing streaming them to omxplayer, which supports multichannel via openMAX, and everything works fine in my 5.1 surround sound setup (channel identification/assigment, etc). Hope it help with testing. I'm following this PR with utmost interest. :) |
|
The OpenMAX codepath is completely different, and is not affected by this PR at all. So comparing ALSA results with OMX would be interesting. (I also once thought about implementing this with an ALSA plugin that uses OMX, but discarded the idea.) |
|
I'd like to test this, but I tried using sudo BRANCH=next rpi-update on my Raspbian Jessie R-Pi2, and it killed the sound card completely. No sound card with aplay -l and mixer gives the message that Gstreamer can't find any audio devices. I got it back, of course, by reverting to 4.1.y (or just using sudo rpi-update) Is there something I'm missing? |
|
What kind of sound card is it? I suppose I could try if this happens with an USB dongle. |
|
It's the built in sound on the Raspberry Pi 2, I'm connecting via HDMI. |
|
On 4.4 and above you need to add |
|
Ah! There it is, Now I'll do some testing later when I get home. Thanks! |
|
@just ran the sudo BRANCH=next rpi-update script on my rpi2, and now I don't have audio.
Nevermind, found it :) New problem: I'm still only getting 2 channels out from my hdmi :( |
|
I think i discovered an issue: No sound output to channels 7 and 8 on hdmi (tested with speaker-test and ecasound) |
|
Hmmm. That works for me. I am using 7 channels, also. You should check your
alsa configuration and make sure those channels are working and aren't
being sent somewhere you can't hear.
…On Sun, Apr 1, 2018 at 6:32 PM volkand22 ***@***.***> wrote:
I think i discovered an issue: No sound output to channels 7 and 8 on hdmi
(tested with speaker-test and ecasound)
Kernel is 4.14.31, compiled with channels_max = 8 and rate_max = 96000
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1257 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACIJuFdEOVf98miQe9OXQ8CtPcY4D5eTks5tkVV3gaJpZM4HEQv0>
.
|
|
I did a clean install of Raspbian, still no luck with 7.1 surround. My Receiver (Denon 1911) recognizes only 5.1. With Windows and Equalizer APO the 7.1 is working. I tried with and without your Alsa-config-file. |
|
Pi2. I have a Pi3 I can test with, but it takes a long time to build the
custom kernel, so I haven't bothered trying with the 3.
…On Mon, Apr 9, 2018 at 1:15 PM volkand22 ***@***.***> wrote:
I did a clean install of Raspbian, still no luck with 7.1 surround. My
Receiver (Denon 1911) recognizes only 5.1. With Windows and Equalizer APO
the 7.1 is working. I tried with and without your Alsa-config-file.
Are you using a Pi3 too or still a Pi2?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1257 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACIJuMFFB_uHXukcj7mEVzg128sXbABtks5tm5clgaJpZM4HEQv0>
.
|
|
Thank you, that would be very much appreciated. The building took one night at the Pi3. |
|
So i'm trying to test with the pi3 today and when I pulled down the kernel, there is not a /sound/arm/bcm2835-pcm.c file any more. Perhaps that is the problem. The file I'm seeing that may be relevant is /sound/atmel/ac97c.c I will try building a new kernel after changing that file. |
|
I patched the file drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c, then speaker-test with 8 channels was possible. |
|
So you are good then? I need to redo my pi install anyway, but i'm lazy so
I want to avoid rebuilding kernel if I can help it :)
…On Sat, Apr 14, 2018 at 3:22 PM volkand22 ***@***.***> wrote:
I patched the file
drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c, then
speaker-test with 8 channels was possible.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1257 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACIJuDvoUEtXU4sXfIAu7oTFINOuvqDeks5tokxigaJpZM4HEQv0>
.
|
|
No, its not working because the Receiver does not recognise 7.1 from the PI, only 5.1 is working. |
|
Did you change the alsaconf to support 8 channels? Check out my 'ible for
how to do that
http://www.instructables.com/id/Raspberry-Pi-Music-Server-With-Built-in-Crossover-/
If
you are getting 5.1, then you have multichannel support. 7.1 is just
configuration :) (assuming you told the bcm2835-pcm.c file you wanted 8
channels)
…On Sat, Apr 14, 2018 at 3:34 PM volkand22 ***@***.***> wrote:
No, its not working because the Receiver does not recognise 7.1 from the
PI, only 5.1 is working.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1257 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACIJuB0wrQVGKF3FIP64kkVHT8Pl4M6eks5tok9jgaJpZM4HEQv0>
.
|
|
Here are the Kernel-Building commands for easy cut & paste: KERNEL=kernel7 && make bcm2709_defconfig && make -j4 zImage modules dtbs && sudo make modules_install && sudo cp arch/arm/boot/dts/.dtb /boot/ && sudo cp arch/arm/boot/dts/overlays/.dtb* /boot/overlays/ && sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/ && sudo cp arch/arm/boot/zImage /boot/$KERNEL.img |
|
I tried your asoundrc, it did not work. I modified only the crossover frequency, maybe there are other changes necessary? |
|
You'll need to look at the channels. The t.table is what sends audio to
different channels.
…On Sat, Apr 14, 2018 at 3:55 PM volkand22 ***@***.***> wrote:
I tried your asoundrc, it did not work. I modified only the crossover
frequency, maybe there are other changes necessary?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1257 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACIJuE9YIFBAfRXKjgp5SpjfVCU-rjH-ks5tolQ2gaJpZM4HEQv0>
.
|
|
no, did not changed the t.table. Here is the result of the speaker-test with 8 channels, with or without the asoundrc nothing changed, 0, 1, 3, 4, 5 are working, 6 and 7 did not work, receiver screen displays 5.1 0 Front L |
|
@volkand22 can you do a pastebin of your asroundrc file? |
|
Here is the asoundrc: |
|
@volkand22 you are just using my asoundrc? That should work, you'll know it works because different speakers will produce different frequency ranges. Is that happening? If not, then you need to update asound.conf or alsa.conf (see: http://www.alsa-project.org/main/index.php/Asoundrc#The_.asoundrc_file_format) |
|
Yes, i have the kernel compiled with 8 channels and i still see only 5.1 on the receiver, that is the problem. I tried with and without the asoundrc-file. If it is working on your Pi3 now, please could you provide the 3 mentioned config files? I looked into the alsa.conf but i have no idea what to do. |
|
@wm4 -- I'm about to submit a patch to do interpolation based on your patch. Would you like to have your name associated with it? (Sorry, can't find an email for you anywhere.) |
|
@mikebrady Please do not wait too long for a feedback here. You can still reference on this pull request or single commit. |
|
It seems that the first commit would already solve multichannel in alsa: a569b82 This comment was already given on feb 26 2016:
Could someone just merge this commit in the stable branch? |
|
+1 |
1 similar comment
|
+1 |
|
@popcornmix Any thoughts on what we should do with this PR? |
|
@wm4 has stated he is no longer interested in this PR. The channel mapping interface is the main part missing but it is not something easy to control through alsa, so I haven't been able to test it (I think mvp may use this api, but not certain). I think we can close this. If we want to better support channel mapping there may be commits of interest here (but the alsa driver has been upstreamed in the meantime and these commits are touch to apply given the changes). |
|
Hi @popcornmix thanks for merging the |
The firmware driver passes only a channel count and the firmware picks the speaker layout from it (the per-stream channel map was never merged, raspberrypi/linux#1257), so only counts with one unambiguous layout are offered. The slot order is ALSA's, as measured on a Pi 3; it is not yet confirmed against a real multichannel sink. Surround is limited to 48 kHz: the Pi carries 8 HDMI channels only up to 48 kHz (raspberrypi/linux#3933). Signed-off-by: Simon Mikuda <simon.mikuda@streamunlimited.com>
…onsole The firmware driver passes only a channel count and the firmware picks the speaker layout from it (the per-stream channel map was never merged, raspberrypi/linux#1257), so only counts with one unambiguous layout are offered. The slot order is ALSA's, as measured on a Pi 3; it is not yet confirmed against a real multichannel sink. Surround is limited to 48 kHz: the Pi carries 8 HDMI channels only up to 48 kHz (raspberrypi/linux#3933). HdmiOutput becomes SocOutput so HDMI and the jack share one thread, converter and latency servo. The jack is stereo by construction: a stored layout wider than the sink reads as stereo, so nothing can make the engine write past its two-slot block. The device picker lists ALSA's playback devices, leaving out the Octo, which the engine holds open. Signed-off-by: Simon Mikuda <simon.mikuda@streamunlimited.com>
Same as #1166, but uses the audioserv 3 API for sending the channel map. It's also rebased to the current main branch.
I'm not entirely sure whether the channel map arrives correctly. Common layouts seems to work as expected with my receiver, but then my receiver might not even interpret the channel layout at all. I don't know.