-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[4.2] fix cyclic dma setup and i2s parameters #1193
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
Conversation
It looks OK as far as it goes. I did notice that a few lines after the period_bytes_max initialisation is |
That was in the original commit by @koalo and the value looks rather The only constraints on buffer_bytes_max are that it has to be at least Large buffer sizes can be beneficial though because they can reduce If we'd like we could bump that limit and/or use a more readable One thing that's still puzzling me is that the transfer-limit / Basically ALSA expects a buffer divided into equally-sized periods But when we re-arrange the buffer into other fragments/periods Maybe there's some sanity-checking in the ALSA code but still At least, with period_bytes_max now set up correctly we no |
05c8cab
to
dcf5a9b
Compare
c35cc1f
to
81af5ef
Compare
The calculation of the number of required frames was wrong which could lead to the last frame being longer than the requested period length and even the maximum supported transfer size. eg when requesting a 88208 bytes buffer with a period len of 22052 (the defaults when playing a 44.1kHz stereo 16bit file with aplay) the code would allocate 3 frames, two with 22052 bytes and the last one with 44104 bytes instead of the expected 4 frames with 22052 bytes each. Signed-off-by: Matthias Reichl <[email protected]>
This reverts commit 0bbc1e2. The underlying problem (cyclic DMA frame calculation) has been fixed so this workaround can be reverted. Signed-off-by: Matthias Reichl <[email protected]>
bcm2835-dma supports a maximum transfer length of 64k-4 bytes on the lite channels. period_bytes_max should reflect this limit. Also use SZ_xxx constants for buffer/prealloc size. The usage of PAGE_SIZE is misleading here, the buffer sizes are not related to the page size. Signed-off-by: Matthias Reichl <[email protected]>
superseded by #1233 |
I found out why I got clicks with I2S soundcards after the lite DMA channel transfer size limit was bumped from 32k to 64k-4 bytes:
The frame number calculation in the cyclic DMA setup code was wrong, so fewer frames than needed were allocated and the last frame was larger than it should be.
With the old limit this bug went unnoticed as the frame length was still below the maximum size the DMA controller could handle. But with the larger limit we exceeded what the DMA controller could do.
I've also adjusted the maximum period size in the i2s driver to match the capabilities of the DMA controller. This ensures that the actual DMA frames will match the requested buffer/period layout.
This fix should go in 4.3 as well, after (or with) the huge atags PR.
I'll create a separate PR for 4.1 with backported fixes for the 2708 drivers.