1
0
Fork 0
mirror of https://github.com/tylernguyen/x1c6-hackintosh.git synced 2025-02-05 09:33:13 -06:00

Added modified ALCPlugFix for x1c6

Enabled automatic output switching headphone/speaker upon plug/unplug.
Fix rare audio cracking condition after waking from sleep.
See changelog 4/1/2020
This commit is contained in:
Tyler Nguyen 2020-04-01 13:27:53 -05:00
parent ad5fa48c4f
commit 119c763300
No known key found for this signature in database
GPG key ID: DB5B102B914991DA
28 changed files with 868 additions and 13 deletions

View file

@ -1503,7 +1503,7 @@
<key>7C436110-AB2A-4BBB-A880-FE41995C9F82</key> <key>7C436110-AB2A-4BBB-A880-FE41995C9F82</key>
<dict> <dict>
<key>boot-args</key> <key>boot-args</key>
<string>keepsyms=1</string> <string>keepsyms=1 -hbfx-dump-nvram</string>
<key>csr-active-config</key> <key>csr-active-config</key>
<data> <data>
AAAAAA== AAAAAA==

View file

@ -1,7 +1,5 @@
# macOS on Thinkpad X1 Carbon 6th Generation, Model 20KH* # macOS on Thinkpad X1 Carbon 6th Generation, Model 20KH*
[![macOS](https://img.shields.io/badge/macOS-Catalina-yellow.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) [![macOS](https://img.shields.io/badge/macOS-Catalina-yellow.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)
[![Clover](https://img.shields.io/badge/Clover-5100-red)](https://github.com/996icu/996.ICU/blob/master/LICENSE) *Last Clover version suppported, OpenCore is now my preferred bootloader.
[![BIOS](https://img.shields.io/badge/BIOS-1.43-blue)](https://github.com/996icu/996.ICU/blob/master/LICENSE) [![BIOS](https://img.shields.io/badge/BIOS-1.43-blue)](https://github.com/996icu/996.ICU/blob/master/LICENSE)
[![MODEL](https://img.shields.io/badge/Model-20KH*-blue)](https://github.com/996icu/996.ICU/blob/master/LICENSE) [![MODEL](https://img.shields.io/badge/Model-20KH*-blue)](https://github.com/996icu/996.ICU/blob/master/LICENSE)
[![OpenCore](https://img.shields.io/badge/OpenCore-0.5.6-green)](https://github.com/996icu/996.ICU/blob/master/LICENSE) [![OpenCore](https://img.shields.io/badge/OpenCore-0.5.6-green)](https://github.com/996icu/996.ICU/blob/master/LICENSE)
@ -20,13 +18,12 @@
> ## Update > ## Update
##### Recent | [Changelog Archive](https://github.com/tylernguyen/x1c6-hackintosh/docs/CHANGELOG.md) ##### Recent | [Changelog Archive](https://github.com/tylernguyen/x1c6-hackintosh/docs/CHANGELOG.md)
> ### 2020-3-31 > ### 2020-4-1
#### Added #### Added
* Further documentation regarding specific tweaks and recommmended macOS settings. * ALCPlugFix to automatically change output to headphones after being plugged in, and to change it back to speakers after being unplugged.
* ADB and PS2 code reference sheet. * ALCPlugFix to fix the rare condition that audio is messed up after waking from sleep.
#### Changed #### Changed
* All Fn keys now have have an assigned key, remap as needed. * More documentation about recommended macOS settings.
* Keyboard map is now in markdown.
> ## SUMMARY: > ## SUMMARY:
| Fully functional | Non-functional | Semi-functional. Additional pulls needed and welcomed. | | Fully functional | Non-functional | Semi-functional. Additional pulls needed and welcomed. |
@ -58,7 +55,7 @@ Once you are ready, follow the series of README files included `docs/`.
* While you can plug-and-play most of my hotpatches if you have an x1c6, I still suggest that you dump and disassemble your own DSDT. This is imprortant as your DSDT maybe different from mine. And furthermore, you get to learn more about what's actually going on. * While you can plug-and-play most of my hotpatches if you have an x1c6, I still suggest that you dump and disassemble your own DSDT. This is imprortant as your DSDT maybe different from mine. And furthermore, you get to learn more about what's actually going on.
> ## MY SPECIFICATIONS: > ## MY SPECIFICATIONS:
Refer to [x1c6-Platform_Specifications](https://github.com/tylernguyen/x1c6-hackintosh/blob/master/docs/x1c6-Platform_Specifications.pdf) for possible stock ThinkPad X1 6th Gen configurations. Refer to [x1c6-Platform_Specifications](https://github.com/tylernguyen/x1c6-hackintosh/blob/master/docs/references/x1c6-Platform_Specifications.pdf) for possible stock ThinkPad X1 6th Gen configurations.
| Processor Number | # of Cores | # of Threads | Base Frequency | Max Turbo Frequency | Cache | Memory Types | Graphics | | Processor Number | # of Cores | # of Threads | Base Frequency | Max Turbo Frequency | Cache | Memory Types | Graphics |
|:--|:--|:--|:--|:--|:--|:--|:--| |:--|:--|:--|:--|:--|:--|:--|:--|
@ -111,6 +108,7 @@ https://tylerspaper.com/support/
[@Colton-Ko](https://github.com/Colton-Ko/macOS-ThinkPad-X1C6) for the great features template. [@Colton-Ko](https://github.com/Colton-Ko/macOS-ThinkPad-X1C6) for the great features template.
[@stevezhengshiqi](https://github.com/stevezhengshiqi) for the one-key-cpufriend script. [@stevezhengshiqi](https://github.com/stevezhengshiqi) for the one-key-cpufriend script.
[@corpnewt](https://github.com/corpnewt) for CPUFriendFriend. [@corpnewt](https://github.com/corpnewt) for CPUFriendFriend.
[@Sniki](https://github.com/Sniki) and [@goodwin](https://github.com/goodwin) for ALCPlugFix.
[@xzhih](https://github.com/xzhih) for one-key-hidpi. [@xzhih](https://github.com/xzhih) for one-key-hidpi.
[@daliansky](https://github.com/daliansky) for all the hotpatches. [@daliansky](https://github.com/daliansky) for all the hotpatches.
[@jsassu20](https://github.com/jsassu20) for translating daliansky's documentations. [@jsassu20](https://github.com/jsassu20) for translating daliansky's documentations.

View file

@ -31,6 +31,7 @@ For the kexts you will be using, make sure to create matching entries within `Op
| PCIe Ethernet | ✅ | `IntelMausi.kext` | - | | | PCIe Ethernet | ✅ | `IntelMausi.kext` | - | |
| Audio Recording | ✅ | `AppleALC.kext` with Layout ID = 21 | - | | Audio Recording | ✅ | `AppleALC.kext` with Layout ID = 21 | - |
| Audio Playback | ✅ | `AppleALC.kext` with Layout ID = 21 | - | | Audio Playback | ✅ | `AppleALC.kext` with Layout ID = 21 | - |
| Automatic Headphone Output Switching | ✅ | `ALCPlugFix` | - |
| Full Graphics Accleration (QE/CI) | ✅ | `WhateverGreen.kext` | - | | Full Graphics Accleration (QE/CI) | ✅ | `WhateverGreen.kext` | - |
| Brightness Adjustments | ✅ | `WhateverGreen.kext` and `SSDT-PNLF-SKL_KBL.aml` | - | | Brightness Adjustments | ✅ | `WhateverGreen.kext` and `SSDT-PNLF-SKL_KBL.aml` | - |
| Micro SD Card Reader | ✅ | Custom `USBPorts.kext` See current OpenCore-EFI kext folder. You can create your own with Hackintool. | - | | Micro SD Card Reader | ✅ | Custom `USBPorts.kext` See current OpenCore-EFI kext folder. You can create your own with Hackintool. | - |

View file

@ -9,7 +9,7 @@
A good way to see if you need to edit and compile your own SSDT patches is to compare your DSDT.dsl with mine of the same BIOS version. You can find my disasemebled DSDT file in `ACPI/Disassembled ACPI/BIOS-v*`. A good way to see if you need to edit and compile your own SSDT patches is to compare your DSDT.dsl with mine of the same BIOS version. You can find my disasemebled DSDT file in `ACPI/Disassembled ACPI/BIOS-v*`.
7. Once you have the compiled ACPI patches, place them in `EFI/OC/ACPI/` and make sure to create matching entries within `OpenCore.plist`'s `ACPI/Add/` section. 7. Once you have the compiled ACPI patches, place them in `EFI/OC/ACPI/` and make sure to create matching entries within OpenCore's `config.plist`'s `ACPI/Add/` section.
# Hotpatching Notes # Hotpatching Notes
@ -83,8 +83,8 @@ For multimedia functions:
- Remap 10: PrtSc to F13 - Remap 10: PrtSc to F13
- Remap 11: Fn + K to Deadkey - Remap 11: Fn + K to Deadkey
- Remap 12: Fn + P to Deadkey - Remap 12: Fn + P to Deadkey
For Fn 1-12 functions, check the follow option within `Preferences/Keyboard`: For Fn 1-12 functions, check the following option within `Preferences/Keyboard`:
![Fn keys](https://github.com/tylernguyen/x1c6-hackintosh/blob/master/docs/assets/img/fnkeys.png) ![Fn keys](https://github.com/tylernguyen/x1c6-hackintosh/blob/master/docs/assets/img/macOS%20Settings/fnkeys.png)
> ### SSDT-PTSWAK > ### SSDT-PTSWAK
### SSDT-EXT3-LedReset-TP ### SSDT-EXT3-LedReset-TP

View file

@ -1,3 +1,20 @@
> ## Dual Booting: > ## Dual Booting:
* I recommend that you dual boot using another drive in the WAN slot. * I recommend that you dual boot using another drive in the WAN slot.
* I've found that dual booting with OpenCore can be quite troulesome. Instead, what I recommend is to use rEFInd Boot Manager should you need to dual boot Windows or Linux. * I've found that dual booting with OpenCore can be quite troulesome. Instead, what I recommend is to use rEFInd Boot Manager should you need to dual boot Windows or Linux.
## Modifier Key Patching:
By default, Windows, Left Alt, and Right Alt are mismapped. An easy fix for this is to install [Karabiner-Elements](https://karabiner-elements.pqrs.org/) and configure it as:
![karabiner_modifier](https://github.com/tylernguyen/x1c6-hackintosh/blob/master/docs/assets/img/macOS%20Settings/karabiner_modifier.png)
## Touchpad Settings in macOS:
* Force Click is enabled by default, which turns any click on the trackpad into a force touch. I suggest you turn this off.
* In addition, I prefer to have tap to click on.
See my touchpad settings:
![touchpad](https://github.com/tylernguyen/x1c6-hackintosh/blob/master/docs/assets/img/macOS%20Settings/touchpad.png)
## Headphone Patch:
* Installing ALCPlugFix addresses the following:
* Change output to headphones after being plugged in, and to change it back to speakers after being unplugged.
* Fix the rare condition that audio is messed up after waking from sleep.
See `patches/ALCPlugFix/README.md` for more details.

View file

@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
> ### 2020-4-1
#### Added
* ALCPlugFix to automatically change output to headphones after being plugged in, and to change it back to speakers after being unplugged.
* ALCPlugFix to fix the rare condition that audio is messed up after waking from sleep.
#### Changed
* More documentation about recommended macOS settings.
> ### 2020-3-31 > ### 2020-3-31
#### Added #### Added
* Further documentation regarding specific tweaks and recommmended macOS settings. * Further documentation regarding specific tweaks and recommmended macOS settings.

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View file

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View file

@ -0,0 +1,273 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
4C761DB422710250004042C9 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C761DB322710250004042C9 /* AppKit.framework */; };
4CE328391DCA9A59002A53ED /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE328381DCA9A59002A53ED /* main.m */; };
D96DD8E9562DA5C656BFF568 /* README.MD in Sources */ = {isa = PBXBuildFile; fileRef = D96BFF009CB392050D064A88 /* README.MD */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
4CE328331DCA9A59002A53ED /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
4C761DB322710250004042C9 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
4CE328351DCA9A59002A53ED /* ALCPlugFix */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ALCPlugFix; sourceTree = BUILT_PRODUCTS_DIR; };
4CE328381DCA9A59002A53ED /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
D96BFF009CB392050D064A88 /* README.MD */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.MD; sourceTree = "<group>"; };
DFD18AC8239F002300E9DD63 /* alc_fix */ = {isa = PBXFileReference; lastKnownFileType = folder; path = alc_fix; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
4CE328321DCA9A59002A53ED /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4C761DB422710250004042C9 /* AppKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
4C761DB222710250004042C9 /* Frameworks */ = {
isa = PBXGroup;
children = (
4C761DB322710250004042C9 /* AppKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
4CE3282C1DCA9A59002A53ED = {
isa = PBXGroup;
children = (
DFD18AC8239F002300E9DD63 /* alc_fix */,
4CE328371DCA9A59002A53ED /* ALCPlugFix */,
4CE328361DCA9A59002A53ED /* Products */,
4C761DB222710250004042C9 /* Frameworks */,
D96BFF009CB392050D064A88 /* README.MD */,
);
sourceTree = "<group>";
};
4CE328361DCA9A59002A53ED /* Products */ = {
isa = PBXGroup;
children = (
4CE328351DCA9A59002A53ED /* ALCPlugFix */,
);
name = Products;
sourceTree = "<group>";
};
4CE328371DCA9A59002A53ED /* ALCPlugFix */ = {
isa = PBXGroup;
children = (
4CE328381DCA9A59002A53ED /* main.m */,
);
path = ALCPlugFix;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
4CE328341DCA9A59002A53ED /* ALCPlugFix */ = {
isa = PBXNativeTarget;
buildConfigurationList = 4CE3283C1DCA9A59002A53ED /* Build configuration list for PBXNativeTarget "ALCPlugFix" */;
buildPhases = (
4CE328311DCA9A59002A53ED /* Sources */,
4CE328321DCA9A59002A53ED /* Frameworks */,
4CE328331DCA9A59002A53ED /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = ALCPlugFix;
productName = ALCPlugFix;
productReference = 4CE328351DCA9A59002A53ED /* ALCPlugFix */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
4CE3282D1DCA9A59002A53ED /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1030;
ORGANIZATIONNAME = "Oleksandr Stoyevskyy";
TargetAttributes = {
4CE328341DCA9A59002A53ED = {
CreatedOnToolsVersion = 8.1;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 4CE328301DCA9A59002A53ED /* Build configuration list for PBXProject "ALCPlugFix" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 4CE3282C1DCA9A59002A53ED;
productRefGroup = 4CE328361DCA9A59002A53ED /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
4CE328341DCA9A59002A53ED /* ALCPlugFix */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
4CE328311DCA9A59002A53ED /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4CE328391DCA9A59002A53ED /* main.m in Sources */,
D96DD8E9562DA5C656BFF568 /* README.MD in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
4CE3283A1DCA9A59002A53ED /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
4CE3283B1DCA9A59002A53ED /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
name = Release;
};
4CE3283D1DCA9A59002A53ED /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
4CE3283E1DCA9A59002A53ED /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
4CE328301DCA9A59002A53ED /* Build configuration list for PBXProject "ALCPlugFix" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4CE3283A1DCA9A59002A53ED /* Debug */,
4CE3283B1DCA9A59002A53ED /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
4CE3283C1DCA9A59002A53ED /* Build configuration list for PBXNativeTarget "ALCPlugFix" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4CE3283D1DCA9A59002A53ED /* Debug */,
4CE3283E1DCA9A59002A53ED /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 4CE3282D1DCA9A59002A53ED /* Project object */;
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:ALCPlugFix.xcodeproj">
</FileRef>
</Workspace>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View file

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4CE328341DCA9A59002A53ED"
BuildableName = "ALCPlugFix"
BlueprintName = "ALCPlugFix"
ReferencedContainer = "container:ALCPlugFix.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4CE328341DCA9A59002A53ED"
BuildableName = "ALCPlugFix"
BlueprintName = "ALCPlugFix"
ReferencedContainer = "container:ALCPlugFix.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4CE328341DCA9A59002A53ED"
BuildableName = "ALCPlugFix"
BlueprintName = "ALCPlugFix"
ReferencedContainer = "container:ALCPlugFix.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4CE328341DCA9A59002A53ED"
BuildableName = "ALCPlugFix"
BlueprintName = "ALCPlugFix"
ReferencedContainer = "container:ALCPlugFix.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ALCPlugFix.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>4CE328341DCA9A59002A53ED</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ALCPlugFix.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>good.win.ALCPlugFix</string>
<key>ProgramArguments</key>
<array>
<string>/Library/MyDaemon/Daemon/</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
/*
<key>StandardErrorPath</key>
<string>/Library/Logs/MyDaemon.log</string>
<key>StandardOutPath</key>
<string>/Library/Logs/MyDaemon.log</string>
*/
</dict>
</plist>

View file

@ -0,0 +1,224 @@
//
// main.m
// ALCPlugFix
//
// Created by Oleksandr Stoyevskyy on 11/3/16.
// Copyright © 2016 Oleksandr Stoyevskyy. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreAudio/CoreAudio.h>
#import <AppKit/AppKit.h>
void fixAudio();
NSString *binPrefix;
@protocol DaemonProtocol
- (void)performWork;
@end
@interface NSString (ShellExecution)
- (NSString*)runAsCommand;
@end
@implementation NSString (ShellExecution)
- (NSString*)runAsCommand {
NSPipe* pipe = [NSPipe pipe];
NSTask* task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/sh"];
[task setArguments:@[@"-c", [NSString stringWithFormat:@"%@", self]]];
[task setStandardOutput:pipe];
NSFileHandle* file = [pipe fileHandleForReading];
[task launch];
return [[NSString alloc] initWithData:[file readDataToEndOfFile] encoding:NSUTF8StringEncoding];
}
@end
# pragma mark ALCPlugFix Object Conforms to Protocol
@interface ALCPlugFix : NSObject <DaemonProtocol>
@end;
@implementation ALCPlugFix
- (id)init
{
self = [super init];
if (self) {
// Do here what you needs to be done to start things
// sleep wake
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver: self
selector: @selector(receiveWakeNote:)
name: NSWorkspaceDidWakeNotification object: nil];
// screen unlock
[[NSDistributedNotificationCenter defaultCenter] addObserver: self
selector: @selector(receiveWakeNote:)
name: @"com.apple.screenIsUnlocked" object: nil];
// screen saver end
[[NSDistributedNotificationCenter defaultCenter] addObserver: self
selector: @selector(receiveWakeNote:)
name: @"com.apple.screensaver.didstop" object: nil];
// Screen wake
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver: self
selector: @selector(receiveWakeNote:)
name: NSWorkspaceScreensDidWakeNotification object: nil];
// Switch to other user
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver: self
selector: @selector(receiveWakeNote:)
name: NSWorkspaceSessionDidResignActiveNotification object: nil];
// Switch back to current user
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver: self
selector: @selector(receiveWakeNote:)
name: NSWorkspaceSessionDidBecomeActiveNotification object: nil];
}
return self;
}
- (void)dealloc
{
// Do here what needs to be done to shut things down
//[super dealloc];
}
- (void)performWork
{
// This method is called periodically to perform some routine work
NSLog(@"Performing periodical work");
// fixAudio();
}
- (void) receiveWakeNote: (NSNotification*) note
{
NSLog(@"receiveSleepNote: %@", [note name]);
NSLog(@"Wake detected");
fixAudio();
}
@end
# pragma mark Setup the daemon
// Seconds runloop runs before performing work in second.
#define kRunLoopWaitTime 14400.0 // 4hour
BOOL keepRunning = TRUE;
CFRunLoopRef runLoopRef;
void sigHandler(int signo)
{
NSLog(@"sigHandler: Received signal %d", signo);
switch (signo) {
case SIGTERM:
case SIGKILL:
case SIGQUIT:
case SIGHUP:
case SIGINT:
// Now handle more signal to quit
NSLog(@"Exiting...");
keepRunning = FALSE;
CFRunLoopStop(CFRunLoopGetCurrent()); // Kill current thread so we don't need to wait until next runloop call
break;
default:
break;
}
}
void fixAudio(){
NSLog(@"Fixing...");
NSString *output1 = [[binPrefix stringByAppendingString:@"hda-verb 0x19 SET_PIN_WIDGET_CONTROL 0x25"] runAsCommand];
NSString *output2 = [[binPrefix stringByAppendingString:@"hda-verb 0x21 SET_UNSOLICITED_ENABLE 0x33"] runAsCommand];
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"ALCPlugFix v1.6");
keepRunning = false;
binPrefix = @"";
signal(SIGHUP, sigHandler);
signal(SIGTERM, sigHandler);
signal(SIGKILL, sigHandler);
signal(SIGQUIT, sigHandler);
signal(SIGINT, sigHandler);
ALCPlugFix *task = [[ALCPlugFix alloc] init];
// Check hda-verb location
NSFileManager *filemgr;
filemgr = [[NSFileManager alloc] init];
if ([filemgr fileExistsAtPath:@"./hda-verb"]){
// hda-verb at work dir
NSLog(@"Found had-verb in work dir");
binPrefix = [filemgr.currentDirectoryPath stringByAppendingString:@"/"];
}else
NSLog(@"Current Directory %@", filemgr.currentDirectoryPath);
NSLog(@"Headphones daemon running!");
// Audio Listener setup
AudioDeviceID defaultDevice = 0;
UInt32 defaultSize = sizeof(AudioDeviceID);
const AudioObjectPropertyAddress defaultAddr = {
kAudioHardwarePropertyDefaultOutputDevice,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
AudioObjectPropertyAddress sourceAddr;
sourceAddr.mSelector = kAudioDevicePropertyDataSource;
sourceAddr.mScope = kAudioDevicePropertyScopeOutput;
sourceAddr.mElement = kAudioObjectPropertyElementMaster;
AudioObjectPropertyListenerBlock audioObjectPropertyListenerBlock = ^(UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses) {
// Audio device have changed
NSLog(@"Audio device changed!");
fixAudio();
};
OSStatus osStatus;
do {
AudioObjectGetPropertyData(kAudioObjectSystemObject, &defaultAddr, 0, NULL, &defaultSize, &defaultDevice);
osStatus = AudioObjectAddPropertyListenerBlock(defaultDevice, &sourceAddr, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), audioObjectPropertyListenerBlock);
if (osStatus != 0){
// OS Status 560947818 is 'normal' as we are trying to hook audio object before login screen.
NSLog(@"ERROR: Something went wrong! Failed to add Audio Listener!");
NSLog(@"OS Status: %d",osStatus);
NSLog(@"Waiting 7 second");
sleep(7);
} else
NSLog(@"Correctly added Audio Listener!");
}while(osStatus!=0);
// Fix at boot
fixAudio();
do{
[task performWork];
CFRunLoopRunInMode(kCFRunLoopDefaultMode, kRunLoopWaitTime, false);
}while (keepRunning);
// [task release];
OSStatus removeStatus = AudioObjectRemovePropertyListenerBlock(defaultDevice, &sourceAddr, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),audioObjectPropertyListenerBlock);
NSLog(@"Listener removed with status: %d",removeStatus);
NSLog(@"Daemon exited");
}
return 0;
}

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>good.win.ALCPlugFix</string>
<key>ProgramArguments</key>
<array>
<string>/Library/MyDaemon/Daemon/</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>

View file

@ -0,0 +1,68 @@
## **Use Hackintool to determine your audio layout's pin configuration. For x1c6 owners with `ALC285`, it will most likely be the same and you can simply install my prebuilt files.**
![alc285_pin](https://github.com/tylernguyen/x1c6-hackintosh/tree/master/docs/references/alc285_pin.png)
Build
-------
By default its code command is for **Lenovo ThinkPad X1 Carbon 6th Gen** with **`ALC285`** Audio Codec with Combo Jack, you may need to change that in `fixAudio` function:
![ALCPlugFix_fixAudio](https://github.com/tylernguyen/x1c6-hackintosh/tree/master/docs/img/ALCPlugFix_fixAudio.png)
After `fixAudio` has been adjusted according to your pin layout, run:
```
xcodebuild -target ALCPlugFix
```
Now copy the built `ALCPlugFix` to `alc_fix/`.
Install
-------
Running `sh ./install.sh` will install to `/user/local/bin`.
By default it search `hda-verb` in current work directory, if not found it will search in `$PATH` _(May not work when it is running from LaunchDaemon because it is using as root)_.
Compatible Laptops
------------------
- Lenovo ThinkPad T440P
- Lenovo ThinkPad T440
- Lenovo ThinkPad T440S
- Lenovo ThinkPad L440
- Lenovo ThinkPad X240
- Lenovo ThinkPad X1 Carbon 6th Gen
Debug
-----
Add following to launchDaemon file to log to `/tmp/ALCPlugFix.log`, _(or use `log stream`)_
```
<key>StandardOutPath</key>
<string>/tmp/ALCPlugFix.log</string>
<key>StandardErrorPath</key>
<string>/tmp/ALCPlugFix.log</string>
```
ALCPlugFix
----------
This is an improved version of ALCPlugFix from [goodwin](https://github.com/goodwin/ALCPlugFix).
The original and this fork tries to fix headphone audio power state issue in non Apple sound card in macOS.
The improvement include:
- Refactor
- Add listener when sleep/wake
- Fix on sleep wake
- Let you choose `hda-verb` so it don't need be in `$PATH`
- Enable launching as LauchDaemon
- Bug fix
- Install.sh script with update support
- Uninstall.sh to uninstall ALCPlugFix
- macOS Catalina support
Credits
-----
- Goodwin for creating the Software
- Menchen for the refactoring and new features
- Joshuaseltzer for creating new install.sh and uninstall.sh
- Sniki for maintaining the software

Binary file not shown.

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>good.win.ALCPlugFix</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/ALCPlugFix</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
<!--Shuold be directory that hda-verb at-->
<key>WorkingDirectory</key>
<string>/usr/local/bin/</string>
</dict>
</plist>

Binary file not shown.

View file

@ -0,0 +1,41 @@
#!/bin/bash
DAEMON_PATH=/Library/LaunchDaemons/
BIN_PATH=/usr/local/bin/
DAEMON_FILE=good.win.ALCPlugFix.plist
VERB_FILE=hda-verb
FIX_FILE=ALCPlugFix
echo "Installing ALCPlugFix v1.6"
# check if the directory "usr/local/bin" exist, if not then create the directory
if [ ! -d "$BIN_PATH" ] ; then
mkdir "$BIN_PATH" ;
fi
# stop the daemon if it's already running
if sudo launchctl list | grep --quiet ALCPlugFix; then
echo "Stopping existing ALCPlugFix daemon."
sudo launchctl unload $DAEMON_PATH$DAEMON_FILE
fi
# copy over the files to their respective locations (overwrite automatically if files exist)
sudo cp -f ALCPlugFix $BIN_PATH
sudo cp -f hda-verb $BIN_PATH
sudo cp -f good.win.ALCPlugFix.plist $DAEMON_PATH
# set permissions and ownership
sudo chmod 755 $BIN_PATH$FIX_FILE
sudo chown $USER:admin $BIN_PATH$FIX_FILE
sudo chmod 755 $BIN_PATH$VERB_FILE
sudo chown $USER:admin $BIN_PATH$VERB_FILE
sudo chmod 644 $DAEMON_PATH$DAEMON_FILE
sudo chown root:wheel $DAEMON_PATH$DAEMON_FILE
# load and start the daemon
sudo launchctl load -w $DAEMON_PATH$DAEMON_FILE
echo "Done!"
exit 0

View file

@ -0,0 +1,21 @@
#!/bin/bash
echo "Uninstalling ALCPlugFix. Root user is required."
# check if the root filesystem is writeable (starting with macOS 10.15 Catalina, the root filesystem is read-only by default)
if sudo test ! -w "/"; then
echo "Root filesystem is not writeable. Remounting as read-write and restarting Finder."
sudo mount -uw /
sudo killall Finder
fi
sudo rm /usr/bin/ALCPlugFix
sudo rm /usr/bin/hda-verb
sudo launchctl unload -w /Library/LaunchDaemons/good.win.ALCPlugFix.plist
sudo launchctl remove good.win.ALCPlugFix
sudo rm /Library/LaunchDaemons/good.win.ALCPlugFix.plist
sudo rm /usr/local/bin/ALCPlugFix
sudo rm /usr/local/bin/hda-verb
echo "Done!"
exit 0