FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Audio: don't drop AppleALC on unknown codecs; pick a layout-id that has working mic by Epic34-cyberdudder · Pull Request #70 · riftaway7-code/hackmate · GitHub

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (6) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 5 additions & 0 deletions src/config_editor.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ def set_igpu_platform_id(cfg: dict, hex_str: str) -> None:
"ALC282": [(25, "most laptops"), (27, "alt")],
"ALC283": [(66, "most laptops"), (13, "alt")],
"ALC289": [(87, "most laptops"), (93, "alt")],
"ALC280": [(3, "most laptops"), (5, "alt"), (28, "alt")],
"ALC292": [(28, "most laptops"), (12, "alt"), (15, "alt")],
"ALC293": [(28, "most laptops"), (44, "alt"), (3, "alt")],
"ALC1220": [(7, "most desktops"), (11, "alt"), (16, "Gigabyte")],
"ALC1150": [(1, "most desktops"), (7, "alt"), (11, "alt")],
"ALC700": [(33, "most desktops"), (35, "alt"), (66, "alt")],
"ALC887": [(7, "most desktops"), (11, "alt"), (17, "alt")],
"ALC892": [(7, "most desktops"), (12, "alt"), (15, "alt")],
"ALC897": [(11, "most desktops"), (66, "alt")],
Expand Down
11 changes: 7 additions & 4 deletions src/hackmate.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,8 @@ def _show_results(self, profile: HardwareProfile) -> None:
if profile.dgpu_name:
lines.append(f" dGPU {profile.dgpu_name} [{profile.dgpu_vendor}]")
lines += [
f" Audio {profile.audio_name} / codec: {profile.audio_codec} → layout-id {layout}",
f" Audio {profile.audio_name} / codec: {profile.audio_codec} → layout-id {layout}"
" (mic or output wrong? try another layout-id in Edit Config)",
f" Ethernet {profile.ethernet_name or 'None'}",
f" WiFi {profile.wifi_name or 'None'}",
f" SMBIOS {profile.smbios_model}",
Expand All @@ -1452,10 +1453,12 @@ def _show_results(self, profile: HardwareProfile) -> None:
]
from hardware import hardware_warnings
warnings = hardware_warnings(profile)
if profile.audio_codec and not alc_layout_is_known(profile.audio_codec):
if not alc_layout_is_known(profile.audio_codec):
which = f"codec \"{profile.audio_codec}\"" if profile.audio_codec else "your audio codec"
warnings.append(
f"layout-id {layout} for codec \"{profile.audio_codec}\" is an unconfirmed default, "
"not a verified match — if you get no audio, try other layout IDs from "
f"couldn't identify {which} — AppleALC is included with a generic "
f"layout-id {layout}, which may not match. if you get no audio, try "
"other layout IDs for your board from "
"https://github.com/acidanthera/AppleALC/wiki/Supported-codecs"
)
for w in warnings:
Expand Down
11 changes: 7 additions & 4 deletions src/hackmate_gui.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,8 @@ def _show_results(self, profile: HardwareProfile):
if profile.dgpu_name:
lines.append(f" dGPU {profile.dgpu_name} [{profile.dgpu_vendor}]")
lines += [
f" Audio {profile.audio_name} / codec: {profile.audio_codec} → layout-id {layout}",
f" Audio {profile.audio_name} / codec: {profile.audio_codec} → layout-id {layout}"
" (mic or output wrong? try another layout-id in Edit Config)",
f" Ethernet {profile.ethernet_name or 'None'}",
f" WiFi {profile.wifi_name or 'None'}",
f" SMBIOS {profile.smbios_model}",
Expand All @@ -651,10 +652,12 @@ def _show_results(self, profile: HardwareProfile):
]
from hardware import hardware_warnings
warnings = hardware_warnings(profile)
if profile.audio_codec and not alc_layout_is_known(profile.audio_codec):
if not alc_layout_is_known(profile.audio_codec):
which = f"codec \"{profile.audio_codec}\"" if profile.audio_codec else "your audio codec"
warnings.append(
f"layout-id {layout} for codec \"{profile.audio_codec}\" is an unconfirmed default, "
"not a verified match — if you get no audio, try other layout IDs from "
f"couldn't identify {which} — AppleALC is included with a generic "
f"layout-id {layout}, which may not match. if you get no audio, try "
"other layout IDs for your board from "
"https://github.com/acidanthera/AppleALC/wiki/Supported-codecs"
)
for w in warnings:
Expand Down
28 changes: 20 additions & 8 deletions src/kexts.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ class KextEntry:
}

def get_alc_layout(codec: str) -> int:
"""Best-guess AppleALC layout-id for a codec.

Prefers the curated "most laptops / most desktops" pick from
config_editor.AUDIO_LAYOUTS — those are vetted for working *input* as well
as output. ALC_LAYOUTS below is just every numerically-valid layout for the
codec, and its first element is often a partial one (output works, mic
doesn't), which is exactly the "speaker fine, mic dead" class of bug.
"""
from config_editor import AUDIO_LAYOUTS
up = codec.upper()
for key, layouts in AUDIO_LAYOUTS.items():
if key in up and layouts:
return layouts[0][0]
for key, layouts in ALC_LAYOUTS.items():
if key.lower() in codec.lower():
return layouts[0]
Expand Down Expand Up @@ -404,15 +417,14 @@ def add(*names: str):
if profile.cpu_vendor == "amd":
add("SMCAMDProcessor")

codec = profile.audio_codec.lower()
alc_supported = any(k.lower() in codec for k in ALC_LAYOUTS)
if alc_supported or not codec:
# AppleALC ships on every non-legacy build. Unlike VoodooHDA it is inert
# when it can't match the codec (it never causes a boot failure), so there
# is no downside to always injecting it — and detection frequently yields
# only a generic string ("Realtek", "High Definition Audio") with no
# ALCxxxx, which previously left the EFI with no audio kext at all.
# CodecCommander (EAPD sleep fix) is handled by AppleALC on modern systems.
if not legacy:
add("AppleALC")
# VoodooHDA is not safe to prelink from an installer EFI on modern macOS.
# Upstream's Big Sur+ workflow installs it into /Library/Extensions after
# macOS is running, so leave explicitly unsupported codecs unconfigured
# here instead of turning a missing-audio issue into a boot failure.
# CodecCommander (EAPD sleep fix) is handled by AppleALC on modern systems

if profile.platform == "laptop":
if tp == "rmi":
Expand Down
12 changes: 10 additions & 2 deletions tests/test_config_safety.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,20 @@ def test_supported_codec_uses_applealc(self):
self.assertIn("AppleALC", names)
self.assertNotIn("VoodooHDA", names)

def test_unknown_codec_does_not_inject_voodoohda(self):
def test_unknown_codec_still_ships_applealc_but_never_voodoohda(self):
# AppleALC is inert when it can't match the codec, so injecting it is
# strictly better than an EFI with no audio kext at all. VoodooHDA must
# never be prelinked from an installer EFI.
names = self._selected_names("Conexant CX20751")

self.assertNotIn("AppleALC", names)
self.assertIn("AppleALC", names)
self.assertNotIn("VoodooHDA", names)

def test_generic_realtek_string_still_ships_applealc(self):
# Windows detection falls back to the literal "Realtek" when it can't
# read the exact codec — that must not drop AppleALC.
self.assertIn("AppleALC", self._selected_names("Realtek"))

def test_missing_codec_keeps_safe_applealc_default(self):
names = self._selected_names("")

Expand Down
9 changes: 9 additions & 0 deletions tests/test_kexts.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ def test_generic_realtek_string_is_not_confirmed(self):
def test_unrecognized_alc_model_is_not_confirmed(self):
self.assertFalse(alc_layout_is_known("ALC1200"))

def test_layout_uses_the_curated_pick_not_the_first_valid_id(self):
# config_editor.AUDIO_LAYOUTS is vetted for working input too; the raw
# ALC_LAYOUTS lists are just every valid id and their first element is
# often output-only ("speaker fine, mic dead").
self.assertEqual(get_alc_layout("ALC295"), 28) # not 11
self.assertEqual(get_alc_layout("ALC255"), 71) # not 3
self.assertEqual(get_alc_layout("ALC1220"), 7) # not 1
self.assertEqual(get_alc_layout("Realtek ALC257"), 21) # not 11


class OpenCoreDebugBuildTests(unittest.TestCase):
def test_fallback_url_points_at_debug_not_release(self):
Expand Down

Back | FazBrowse Home | New Git URL