Surface pro 3 黑苹果 DSDT Patch
程序员文章站
2022-03-30 13:43:46
...
首先comment掉错误的行,compiler运行没错才可以进行patch。亮度调节目前改为hotpatch方式,并不需要给DSDT打补丁。
补丁:
一. ACPI keyboard 相关的两个。为了使用平板上音量键和侧边windows键。配合ACPIKeyboard.kext使用。Windows 按键被我改成了静音键。
#Maintained by: RehabMan for: ACPIKeyboard.kext
#patch.txt
# This patch serves to provide a catalyst to load ACPIKeyboard.kext
# and it also provides a sink to send notifications to in
# order to send messages to the kext to simulate keystrokes.
into device label RMKB remove_entry;
into definitionblock code_regex . insert
begin
Device (RMKB)\n
{\n
Name(_HID, "RMKB0000")\n
}\n
end;
into method label _Q50 replace_content
begin
// Windows Home button pressed\n
Notify(\RMKB, 0x114a)\n
end;
into method label _Q51 replace_content
begin
// Windows Home button released\n
Notify(\RMKB, 0x124a)\n
end;
into method label _Q52 replace_content
begin
// Volume-up pressed\n
Notify(\RMKB, 0x1148)\n
end;
into method label _Q53 replace_content
begin
// Volume-up released\n
Notify(\RMKB, 0x1248)\n
end;
into method label _Q54 replace_content
begin
// Volume-down pressed\n
Notify(\RMKB, 0x1149)\n
end;
into method label _Q55 replace_content
begin
// Volume-down released\n
Notify(\RMKB, 0x1249)\n
end;
into method label _Q60 replace_content
begin
//Power button pressed\n
Notify(\RMKB, 0x117f)\n
end;
into method label _Q61 replace_content
begin
// Power button released\n
Notify(\RMKB, 0x127f)\n
end;
二.声音相关和AppleHDA.kext 和 AppleALC.kext配合使用。
IRQ fix
#Maintained by: RehabMan for: Laptop Patches
#system_IRQ.txt
# This can fix non-working audio and also has an affect on HPET.
#
# Use this if you have issues with patched AppleHDA (required on almost all laptops)
# or if you have issues with HPET (restart after wake).
# IRQ fix
into device name_hid PNP0000 code_regex IRQNoFlags\s\(\)\n\s+\{(\d+)\} remove_matched;
into device name_hid PNP0100 code_regex IRQNoFlags\s\(\)\n\s+\{(\d+)\} remove_matched;
into device name_hid PNP0B00 code_regex IRQNoFlags\s\(\)\n\s+\{(\d+)\} remove_matched;
into device name_hid PNP0103 code_regex IRQNoFlags\s\(\)\n\s+\{.*\} removeall_matched;
into device name_hid PNP0103 code_regex Name\s\(([^,]+),\sResourceTemplate\s\(\).*\n\s+\{((?:.|\n)*)\}\) replace_matched
begin
Name (%1, ResourceTemplate()\n
{\n
IRQNoFlags() { 0, 8, 11, 15 }\n
%2
})\n
end;
HDEF patch 为笔记本注入layout id =03;
#Automatically adjusted by AppleHDA Patcher.app
# original by RehabMan
# Inject Audio info
into method label _DSM parent_label HDEF remove_entry;
into device label HDEF insert
begin
Method (_DSM, 4, NotSerialized)\n
{\n
If (LEqual (Arg2, Zero)) { Return (Buffer() { 0x03 } ) }\n
Return (Package()\n
{\n
"AAPL,slot-name", Buffer() { "Built in" },\n
"layout-id", Buffer() { 0x03, 0x00, 0x00, 0x00 },\n
"device_type", Buffer() { "Audio Controller" },\n
"built-in", Buffer() { 0x00 },\n
"PinConfigurations", Buffer() { },\n
"hda-gfx", Buffer() { "onboard-1" }\n
})\n
}\n
end
三. 电池补丁
#Maintained by: RehabMan for: Laptop Patches
#battery_Surface-Pro-v3.txt
# created by Ravi C (wen1) 2015-02-08
# additional fixes by RehabMan, 2017-04-20 based on feedback from naterh (github) pull #46
# works for:
# Microsoft Surface Pro 3
into method label B1B2 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B2, 2, NotSerialized) { Return(Or(Arg0, ShiftLeft(Arg1, 8))) }\n
end;
into method label B1B4 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B4, 4, NotSerialized)\n
{\n
Store(Arg3, Local0)\n
Or(Arg2, ShiftLeft(Local0, 8), Local0)\n
Or(Arg1, ShiftLeft(Local0, 8), Local0)\n
Or(Arg0, ShiftLeft(Local0, 8), Local0)\n
Return(Local0)\n
}\n
end;
# utility methods to read/write buffers from/to EC
into method label RE1B parent_label EC0 remove_entry;
into method label RECB parent_label EC0 remove_entry;
into device label EC0 insert
begin
Method (RE1B, 1, NotSerialized)\n
{\n
OperationRegion(ERAM, EmbeddedControl, Arg0, 1)\n
Field(ERAM, ByteAcc, NoLock, Preserve) { BYTE, 8 }\n
Return(BYTE)\n
}\n
Method (RECB, 2, Serialized)\n
// Arg0 - offset in bytes from zero-based EC\n
// Arg1 - size of buffer in bits\n
{\n
ShiftRight(Add(Arg1,7), 3, Arg1)\n
Name(TEMP, Buffer(Arg1) { })\n
Add(Arg0, Arg1, Arg1)\n
Store(0, Local0)\n
While (LLess(Arg0, Arg1))\n
{\n
Store(RE1B(Arg0), Index(TEMP, Local0))\n
Increment(Arg0)\n
Increment(Local0)\n
}\n
Return(TEMP)\n
}\n
end;
# B0MN to BXMN //offset 0x75
# B0DN to BXDN //offset 0x81
# B0CM to BXCM //offset 0x89
# supporting math
# Offset (0x53),
# B0TP, 16, //53
# VL00,8,VL01,8, //55
# CR00,8,CR01,8, //57
# B0AC, 16, //59
# B0ME, 16, //5b
# B0RS, 16, //5d
# RC00,8,RC01,8, //5f
# FC00,8,FC01,8, //61
# B0MC, 16, //63
# B0MV, 16, //65
# B0ST, 16, //67
# CC00,8,CC01,8, //69
# DC00,8,DC01,8, //6b
# DV00,8,DV01,8, //6d
# B0SI, 16, //6f
# SN00,8,SN01,8,SN02,8,SN03,8, //71
# B0MN, 96, //75
# B0DN, 64, //81
# B0CM, 48, //89
# 16-bit registers
into device label EC0 code_regex B0VLå,\s+16, replace_matched begin VL10,8,VL11,8, end;
into device label EC0 code_regex B1CR,\s+16, replace_matched begin CR10,8,CR11,8, end;
into device label EC0 code_regex B1RC,\s+16, replace_matched begin RC10,8,RC11,8, end;
into device label EC0 code_regex B1FC,\s+16, replace_matched begin FC10,8,FC11,8, end;
into device label EC0 code_regex B1CC,\s+16, replace_matched begin CC10,8,CC11,8, end;
into device label EC0 code_regex B1DC,\s+16, replace_matched begin DC10,8,DC11,8, end;
into device label EC0 code_regex B1DV,\s+16, replace_matched begin DV10,8,DV11,8, end;
into device label EC0 code_regex B0AH,\s+16, replace_matched begin AH00,8,AH01,8, end;
into device label EC0 code_regex B1AH,\s+16, replace_matched begin AH10,8,AH11,8, end;
#into device label EC0 code_regex PLSV,\s+16, replace_matched begin LSV0,8,LSV1,8, end;
# 16-bit methods
into_all method parent_label EC0 code_regex \(B0VL, replace_matched begin (B1B2(VL00,VL01), end;
into_all method parent_label EC0 code_regex \(B0CR, replace_matched begin (B1B2(CR00,CR01), end;
into_all method parent_label EC0 code_regex \(B0RC, replace_matched begin (B1B2(RC00,RC01), end;
into_all method parent_label EC0 code_regex \(B0FC, replace_matched begin (B1B2(FC00,FC01), end;
into_all method parent_label EC0 code_regex \(B0DC, replace_matched begin (B1B2(DC00,DC01), end;
into_all method parent_label EC0 code_regex \(B0DV, replace_matched begin (B1B2(DV00,DV01), end;
into_all method parent_label EC0 code_regex \(B1DC, replace_matched begin (B1B2(DC10,DC11), end;
into_all method parent_label EC0 code_regex \(B1FC, replace_matched begin (B1B2(FC10,FC11), end;
into_all method parent_label EC0 code_regex \(B1DV, replace_matched begin (B1B2(DV10,DV11), end;
into_all method parent_label EC0 code_regex \(B1CR, replace_matched begin (B1B2(CR10,CR11), end;
into_all method parent_label EC0 code_regex \(B1RC, replace_matched begin (B1B2(RC10,RC11), end;
into_all method parent_label EC0 code_regex \(B1VL, replace_matched begin (B1B2(VL10,VL11), end;
into_all method parent_label BAT0 code_regex \(\^\^SBRG.EC0.B0CC, replace_matched begin (B1B2(^^SBRG.EC0.CC00,^^SBRG.EC0.CC01), end;
into_all method parent_label BAT0 code_regex \(\^\^SBRG.EC0.B0RC, replace_matched begin (B1B2(^^SBRG.EC0.RC00,^^SBRG.EC0.RC01), end;
into_all method parent_label BAT1 code_regex \(\^\^SBRG.EC0.B1RC, replace_matched begin (B1B2(^^SBRG.EC0.RC10,^^SBRG.EC0.RC11), end;
into_all method parent_label BAT1 code_regex \(\^\^SBRG.EC0.B1CC, replace_matched begin (B1B2(^^SBRG.EC0.CC10,^^SBRG.EC0.CC11), end;
#now the writes
into method label _BTP code_regex Store\s+\(Arg0,\s+\^\^SBRG\.EC0\.B0AH\) replace_matched begin Store(Arg0, ^^SBRG.EC0.AH00) Store(ShiftRight(Arg0, 8), ^^SBRG.EC0.AH01) end;
into method label _BTP code_regex Store\s+\(0x05,\s+\^\^SBRG\.EC0\.B0AH\) replace_matched begin Store(0x05, ^^SBRG.EC0.AH00) Store(ShiftRight(0x05, 8), ^^SBRG.EC0.AH01) end;
into method label _BTP code_regex Store\s+\(Arg0,\s+\^\^SBRG\.EC0\.B1AH\) replace_matched begin Store(Arg0, ^^SBRG.EC0.AH10) Store(ShiftRight(Arg0, 8), ^^SBRG.EC0.AH11) end;
into method label _BTP code_regex Store\s+\(0x05,\s+\^\^SBRG\.EC0\.B1AH\) replace_matched begin Store(0x05, ^^SBRG.EC0.AH10) Store(ShiftRight(0x05, 8), ^^SBRG.EC0.AH11) end;
# 32-bit EC registers to 8-bit
#. SMFV to MFV0,8,MFV1,8,MFV2,8,MFV3,8
#. B0SN to SN00,8,SN01,8,SN02,8,SN03,8
into device label EC0 code_regex SMFV,\s+32 replace_matched begin MFV0,8,MFV1,8,MFV2,8,MFV3,8 end;
into device label EC0 code_regex B0SN,\s+32 replace_matched begin SN00,8,SN01,8,SN02,8,SN03,8 end;
# fix 32-bit methods
#. SMFV to SMF0,8,SMF1,8,SMF2,8,SMF3,8
into method label _HRV code_regex \(\^\^\^SBRG\.EC0\.SMFV, replaceall_matched begin (B1B4(^^^SBRG.EC0.MFV0,^^^SBRG.EC0.MFV1,^^^SBRG.EC0.MFV2,^^^SBRG.EC0.MFV3), end;
#. B0SN to BSN0,8,BSN1,8,BSN2,8,BSN3,8
into method label FBIF code_regex \(\^\^SBRG\.EC0\.B0SN, replaceall_matched begin (B1B4(^^SBRG.EC0.SN00,^^SBRG.EC0.SN01,^^SBRG.EC0.SN02,^^SBRG.EC0.SN03), end;
# 48-bit EC registers to 8-bit
into device label EC0 code_regex (B0CM,)\s+(48) replace_matched begin BXCM,%2,//%1%2 end;
# fix 48-bit methods
into method label FBIF code_regex \^\^SBRG.EC0.B0CM replaceall_matched begin ^^SBRG.EC0.RECB(0x89,48) end;
# 64-bit EC registers to 8-bit
into device label EC0 code_regex (B0DN,)\s+(64) replace_matched begin BXDN,%2,//%1%2 end;
# fix 64-bit methods
into method label FBIF code_regex \^\^SBRG.EC0.B0DN replaceall_matched begin ^^SBRG.EC0.RECB(0x81,64) end;
# 96-bit EC registers to 8-bit
into device label EC0 code_regex (B0MN,)\s+(96) replace_matched begin BXMN,%2,//%1%2 end;
# fix 96-bit methods
into method label FBIF code_regex \^\^SBRG.EC0.B0MN replaceall_matched begin ^^SBRG.EC0.RECB(0x75,96) end;
# deal with the Mutex problem /修复电量补丁后,有获取的电池状态显示为0%的情况
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;
# SPEEDY-NUC:battery rehabman$ grep into.*method.*_STA.*Return *.txt /修复修复了“BAT0”和“BAT1”相冲突的错误(禁用了“BAT1”)
into method label _STA parent_label BAT1 replace_content begin Return(0) end;
四. HDMI 音频输出Patch
# 1. Rename GFX0 devices to IGPU
into device label GFX0 set_label begin IGPU end;
into_all all code_regex GFX0 replaceall_matched begin IGPU end;
into scope label _SB.PCI0.GFX0 set_label begin _SB.PCI0.IGPU end;ß
into scope label \_SB.PCI0.GFX0 set_label begin \_SB.PCI0.IGPU end;
#
# To patch more than once, delete from "Run this patch once …" (above) to here.
#
# 2. Add device IGPU and inject Azul framebuffer(HD5K HDMI audio - Part 1/2)
into device name_adr 0x00020000 set_label begin IGPU end;
into device label PCI0 insert
begin
Device (IGPU)\n
{\n
Name (_ADR, 0x00020000)\n
Method (_DSM, 4, NotSerialized)\n
{\n
If (LEqual (Arg2, Zero)) { Return (Buffer() { 0x03 } ) }\n
Return (Package()\n
{\n
"AAPL,ig-platform-id", Buffer() { 0x06, 0x00, 0x26, 0x0a },\n
"hda-gfx", Buffer() { "onboard-1" },\n
})\n
}\n
}\n
end;
# 3. Add device HDAU (HD5K HDMI audio - Part 2/2)
into device name_adr 0x00030000 set_label begin HDAU end;
into device label PCI0 insert
begin
Device (HDAU)\n
{\n
Name (_ADR, 0x00030000)\n
Method (_DSM, 4, NotSerialized)\n
{\n
If (LEqual (Arg2, Zero)) { Return (Buffer() { 0x03 } ) }\n
Return (Package()\n
{\n
"layout-id", Buffer() { 0x03, 0x00, 0x00, 0x00 },\n
"hda-gfx", Buffer() { "onboard-1" },\n
})\n
}\n
}\n
end;
# 4. Insert audio injection into device HDEF (HDEF audio)
into method label _DSM parent_adr 0x001B0000 remove_entry;
into device name_adr 0x001B0000 insert
begin
Method (_DSM, 4, NotSerialized)\n
{\n
If (LEqual (Arg2, Zero)) { Return (Buffer() { 0x03 } ) }\n
Return (Package()\n
{\n
"layout-id", Buffer() { 0x03, 0x00, 0x00, 0x00 },\n
"PinConfigurations", Buffer(Zero) {},\n
})\n
}\n
end;
五. VoodooI2C 触屏驱动补丁,对于window 8.1
# Windows 8.1 DSDT Patch for VoodooI2C
# Allows I2C controllers and devices to be discovered by OS X.
# Based off patches written by RehabMan
into_all method code_regex If\s+\([\\]?_OSI\s+\(\"Windows\s2013\"\)\) replace_matched begin If(LOr(_OSI("Darwin"),_OSI("Windows 2013"))) end;
没什么副作用,一般顺便打一下。