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

ASoC: bcm: Use power-of-2 bclk_ratios #6110

Merged
merged 1 commit into from
Apr 18, 2024
Merged

Conversation

pelwell
Copy link
Contributor

@pelwell pelwell commented Apr 17, 2024

The soundcard drivers originally used snd_pcm_format_physical_width, but a later commit changed that to snd_pcm_format_width because the in-memory sample storage width should not be a factor in determining the bclk_ratio. However, the physical width rounds the sample bits up to the nearest power of 2, which makes it easier to find integer clock divisors.

Restore the old behaviour, but with an implementation that makes it clear what is going on.

See: #6104

The soundcard drivers originally used snd_pcm_format_physical_width,
but a later commit changed that to snd_pcm_format_width because the
in-memory sample storage width should not be a factor in determining
the bclk_ratio. However, the physical width rounds the sample bits up
to the nearest power of 2, which makes it easier to find integer clock
divisors.

Restore the old behaviour, but with an implementation that makes it
clear what is going on.

See: raspberrypi#6104

Signed-off-by: Phil Elwell <[email protected]>
@HiassofT
Copy link
Contributor

HiassofT commented Apr 17, 2024

Thanks a lot, this looks fine to me.

I don't have any of the soundcards that caused noticable issues here but I could verify that this PR works fine with my Cirrus Logic audio card (rpi-cirrus driver):

Without this PR the driver requested 2 slots of 24 bit, but the arizona driver choose to use the next higher bclk rate that was a multiple of the sample rate so it worked fine. As the interface is running in I2S mode with the RPi as a clock consumer the slight misconfiguration on the RPi side didn't matter.

dmesg with dynamic debug of snd_soc_arizona enabled showed:

wm5102-codec wm5102-codec: AIF1: Configuring for 2 24 bit TDM slots
wm5102-codec wm5102-codec: AIF1: BCLK 2822400Hz LRCLK 44100Hz

With this PR the driver now correctly requests 2 slots of 32bit which matches the actually supported bclk rate and the configuration is fine both on RPi and codec side

wm5102-codec wm5102-codec: AIF1: Configuring for 2 32 bit TDM slots
wm5102-codec wm5102-codec: AIF1: BCLK 2822400Hz LRCLK 44100Hz

@pelwell pelwell merged commit 18851c5 into raspberrypi:rpi-6.6.y Apr 18, 2024
12 checks passed
@pelwell
Copy link
Contributor Author

pelwell commented Apr 18, 2024

Thanks for reporting this.

popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Apr 18, 2024
See: raspberrypi/linux#6110

kernel: DTS: overlays: fix Pi 5 midi-over-UART
See: raspberrypi/linux#6109

kernel: DTS: rp1: fix setting xHCI TX burst fifo thresholds
See: raspberrypi/linux#6107

kernel: Fix UVC gadget support on 32-bit systems
See: raspberrypi/linux#6095

kernel: Add SunFounder Pironman 5 overlay
See: raspberrypi/linux#6087

kernel: configs: Add various Intel Ethernet drivers
See: raspberrypi/linux#5797
See: raspberrypi/linux#6102

kernel: ARM: dts: Move virtgpio under the firmware node
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Apr 18, 2024
See: raspberrypi/linux#6110

kernel: DTS: overlays: fix Pi 5 midi-over-UART
See: raspberrypi/linux#6109

kernel: DTS: rp1: fix setting xHCI TX burst fifo thresholds
See: raspberrypi/linux#6107

kernel: Fix UVC gadget support on 32-bit systems
See: raspberrypi/linux#6095

kernel: Add SunFounder Pironman 5 overlay
See: raspberrypi/linux#6087

kernel: configs: Add various Intel Ethernet drivers
See: raspberrypi/linux#5797
See: raspberrypi/linux#6102

kernel: ARM: dts: Move virtgpio under the firmware node
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.

2 participants