Fix HDMI audio detection on Pi4 with dual HDMI ports#2667
Fix HDMI audio detection on Pi4 with dual HDMI ports#2667Alex1981-tech wants to merge 2 commits intoScreenly:masterfrom
Conversation
Pi4 has two HDMI ports (HDMI-A-1 and HDMI-A-2), but the existing code always hardcodes `default:CARD=vc4hdmi0` regardless of which port has a display connected. This causes no audio when using HDMI-A-2. Changes: - Add `_detect_hdmi_audio_device()` that reads `/sys/class/drm/cardN-HDMI-A-N/status` to find which HDMI port is connected and returns the correct ALSA device - Use `sysdefault:CARD=` instead of `default:CARD=` for more reliable audio output (avoids PulseAudio/dmix interference) - Apply detection for Pi4 and Pi5 HDMI output - Keep headphones and Pi1-3 paths unchanged Tested on Pi4 Model B with single HDMI connected to HDMI-A-1.
|
@Alex1981-tech, thank you for opening a pull request! I will test the changes when I get the chance. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
CI update: Fixed |
|
|
Hi @Alex1981-tech — thanks again for this fix! Closing this PR in favor of #2811, which supersedes it. Master moved on since you opened #2667 (the Closing this PR — please follow along on #2811. |



Summary
default:CARD=vc4hdmi0regardless of which port has a display connected. This causes no audio when using HDMI-A-2.default:CARD=ALSA device name can be unreliable when PulseAudio or dmix is involved.Changes
_detect_hdmi_audio_device()function that reads/sys/class/drm/cardN-HDMI-A-N/statusto detect which HDMI port is connecteddefault:CARD=tosysdefault:CARD=for direct hardware accessTest plan