Fix HDMI audio detection on Pi4 with dual HDMI ports#2667
Open
Alex1981-tech wants to merge 2 commits intoScreenly:masterfrom
Open
Fix HDMI audio detection on Pi4 with dual HDMI ports#2667Alex1981-tech wants to merge 2 commits intoScreenly:masterfrom
Alex1981-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.
Contributor
|
@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>
Author
|
CI update: Fixed |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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