You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation is broken in several ways:
The number of frames was calculated wrong, which results in
one frame less than requested. eg when requesting a 96000 bytes
buffer split into 4 periods of 24000 bytes the code would allocate
3 frames: the first two with 24000 bytes size and the third one
with 48000 bytes.
This not only results in the cyclic callback being called at other
times than requested but can also lead to frames larger than what
the DMA hardware can support. eg when requesting a 192000 bytes buffer
split into 4 periods of 48000 bytes each (well within the limit
of what the DMA hardware supports) it would allocate 2 48000 byte
frames and one 96000 byte frame - the latter larger than what the
hardware supports.
Frames larger than the hardware limit are the reason for clicking
playback and the previous fix of using a smaller limit for
cyclic transfers only worked around the underlying bug.
Another issue is the way the code tried to handle period sizes larger
than what the hardware supports. It results in cyclic callbacks
not at the requested period length but in callbacks at the hardware
limit boundaries.
The simple fix for these issues is to reject requests that can't
be handled by the hardware.
The maximum period length in bcm2835-i2s has been fixed (set to
64k-4 bytes, the limit of the lite DMA channels) so the cyclic
DMA setup code should never be called with period lenght larger
than the hardware limit, thus period splitting is not neccessary
at all.
Signed-off-by: Matthias Reichl <[email protected]>
0 commit comments