Surface pro 3 黑苹果 DSDT Patch

首先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;

没什么副作用,一般顺便打一下。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 215,133评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,682评论 3 390
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,784评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,508评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,603评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,607评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,604评论 3 415
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,359评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,805评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,121评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,280评论 1 344
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,959评论 5 339
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,588评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,206评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,442评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,193评论 2 367
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,144评论 2 352

推荐阅读更多精彩内容