- Joined
- Aug 15, 2011
- Messages
- 961
- Motherboard
- HP-4540S
- CPU
- i5-3210M
- Graphics
- HD4000
- Mac
- Classic Mac
- Mobile Phone
I've received 4540S I3-3110M this morning. Quickly patched my DSDT to get this going. Existing patches are for 4530S chipset and could use some refreshing. Please comment and recommend any changes.
01_Basic_Compilation
02_DSDT_Patch
03_AR9285 Atheros WiFi card. Use instead of patching AirPortAtheros40.kext with pci168c,2b
04a_HDMI. Provides HDMI and QE/CI graphics info for HD3000/HD4000 (HD3000 in addition needs MEI patch)
04b_HDMI_Dual-Link. Use instead of patch 4a (1600x900 and 4740S laptops)
05a_FanExperimental No change at this moment.
05b Fan_Speed. No fan control, displays speed and heatsink temperature only. Use instead of patch 5a
01_Basic_Compilation
Code:
# Fix _T_x compiler reserved errors
into_all all code_regex _T_0 replaceall_matched begin T_0 end;
into_all all code_regex _T_1 replaceall_matched begin T_1 end;
# Fix 201 parse errors (remove FPED)
into device label GFX0 code_regex If\s\(CondRefOf\s\(FPED\)\)\s*\n\s*\{\s*\n\s*FPED\s\(\)\s*\n\s*\} remove_matched;
# 4x40S BB2S 3 dots error
into all code_regex Name\s+\(BB2S,[^\)].*\) replace_matched
begin
Name (BB2S, " ")
end;
02_DSDT_Patch
Code:
# Power fix
into device label AC insert
begin
Name (_PRW, Package (0x02)\n
{\n
0x18, \n
0x03\n
})
end;
# Replace all instances of AC with ADP1 (Apple label naming)
into_all all code_regex \.AC, replaceall_matched begin .ADP1, end;
into all label AC set_label begin ADP1 end;
# Insert standard DTGP entry
into method label DTGP remove_entry;
into definitionblock code_regex . insert
begin
Method (DTGP, 5, NotSerialized)\n
{\n
If (LEqual (Arg0, Buffer (0x10)\n
{\n
/* 0000 */ 0xC6, 0xB7, 0xB5, 0xA0, 0x18, 0x13, 0x1C, 0x44, \n
/* 0008 */ 0xB0, 0xC9, 0xFE, 0x69, 0x5E, 0xAF, 0x94, 0x9B\n
}))\n
{\n
If (LEqual (Arg1, One))\n
{\n
If (LEqual (Arg2, Zero))\n
{\n
Store (Buffer (One)\n
{\n
0x03\n
}, Arg4)\n
Return (One)\n
}\n
If (LEqual (Arg2, One))\n
{\n
Return (One)\n
}\n
}\n
}\n
Store (Buffer (One)\n
{\n
0x00\n
}, Arg4)\n
Return (Zero)\n
}
end;
# Insert Apple USB properties into EHC1
into method label _DSM parent_adr 0x001D0000 remove_entry;
into device name_adr 0x001D0000 insert
begin
Method (_DSM, 4, NotSerialized)\n
{\n
Store (Package ()\n
{\n
"subsystem-id",\n
Buffer (0x04)\n
{\n
0x70, 0x72, 0x00, 0x00\n
},\n
"subsystem-vendor-id",\n
Buffer (0x04)\n
{\n
0x86, 0x80, 0x00, 0x00\n
},\n
"AAPL,current-available", \n
0x0834, \n
"AAPL,current-extra", \n
0x0898, \n
"AAPL,current-extra-in-sleep", \n
0x0640, \n
"AAPL,device-internal",\n
0x02,\n
"AAPL,max-port-current-in-sleep",\n
0x0834, \n
Buffer (One)\n
{\n
0x00\n
}\n
}, Local0)\n
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))\n
Return (Local0)\n
}
end;
# Insert Apple USB properties into EHC2
into method label _DSM parent_adr 0x001A0000 remove_entry;
into device name_adr 0x001A0000 insert
begin
Method (_DSM, 4, NotSerialized)\n
{\n
Store (Package ()\n
{\n
"subsystem-id",\n
Buffer (0x04)\n
{\n
0x70, 0x72, 0x00, 0x00\n
},\n
"subsystem-vendor-id",\n
Buffer (0x04)\n
{\n
0x86, 0x80, 0x00, 0x00\n
},\n
"AAPL,current-available", \n
0x0834, \n
"AAPL,current-extra", \n
0x0898, \n
"AAPL,current-extra-in-sleep", \n
0x0640, \n
"AAPL,device-internal",\n
0x02,\n
"AAPL,max-port-current-in-sleep",\n
0x0834, \n
Buffer (One)\n
{\n
0x00\n
}\n
}, Local0)\n
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))\n
Return (Local0)\n
}
end;
# Insert Apple USB properties into USB 3.0 XHC
into method label _DSM parent_adr 0x00140000 remove_entry;
into device name_adr 0x00140000 insert
begin
Method (_DSM, 4, NotSerialized)\n
{\n
Store (Package ()\n
{\n
"subsystem-id",\n
Buffer (0x04)\n
{\n
0x70, 0x72, 0x00, 0x00\n
},\n
"subsystem-vendor-id",\n
Buffer (0x04)\n
{\n
0x86, 0x80, 0x00, 0x00\n
},\n
"AAPL,current-available", \n
0x0834, \n
"AAPL,current-extra", \n
0x0898, \n
"AAPL,current-extra-in-sleep", \n
0x0640, \n
"AAPL,device-internal",\n
0x02,\n
"AAPL,max-port-current-in-sleep",\n
0x0834, \n
Buffer (One)\n
{\n
0x00\n
}\n
}, Local0)\n
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))\n
Return (Local0)\n
}
end;
# Enable functions keys
into device label PS2K insert
begin
Method (_DSM, 4, NotSerialized)\n
{\n
Store (Package (0x02)\n
{\n
"AAPL,has-embedded-fn-keys", \n
Buffer (0x04)\n
{\n
0x01, 0x00, 0x00, 0x00\n
}\n
}, Local0)\n
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))\n
Return (Local0)\n
}\n
end;
# Inject Audio properties
into device label HDEF insert
begin
Method (_DSM, 4, NotSerialized)\n
{\n
Store (Package (0x06)\n
{\n
"hda-gfx", \n
Buffer (0x0A)\n
{\n
"onboard-1"\n
}, \n
"layout-id", \n
Buffer (0x04)\n
{\n
0x0C, 0x00, 0x00, 0x00\n
}, \n
"PinConfigurations", \n
Buffer (Zero) {}\n
}, Local0)\n
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))\n
Return (Local0)\n
}
end;
# 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+\{(\d+)\} 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 ()\n
{0}\n
IRQNoFlags ()\n
{8}\n
IRQNoFlags ()\n
{11}\n
IRQNoFlags ()\n
{15}\n
%2
})
end;
# Rename all instances of GFX0 to IGPU
into_all all code_regex GFX0 replaceall_matched begin IGPU end;
into_all all label GFX0 set_label begin IGPU end;
# Brightness control fix
into scope label \_SB insert
begin
Device (PNLF)\n
{\n
Name (_HID, EisaId ("APP0002"))\n
Name (_CID, "backlight")\n
Name (_UID, 0x0A)\n
Name (_STA, 0x0B)\n
}
end;
# RTC fix
into device name_hid PNP0B00 code_regex (IO\s\((?:\s*[^,]+,\s*(?:\/\/\s.*)?\s*\n)+\s*)(\dx\d+)(,\s*(?:\/\/\s.*)?\s*\n\s*\)) replace_matched begin %10x02%3 end;
# Shutdown fix
into method label _PTS code_regex_not If\s\(LEqual\s\(Arg0,\s0x05\)\) code_regex ^((?:.|\n)*)$ replace_matched
begin
If (LEqual (Arg0, 0x05)) {}\n
Else\n
{\n
%1
}
end;
# SMBUS fix
into method label _DSM parent_adr 0x001F0003 remove_entry;
into device name_adr 0x001F0003 insert
begin
Device (BUS0)\n
{\n
Name (_CID, "smbus")\n
Name (_ADR, Zero)\n
Device (DVL0)\n
{\n
Name (_ADR, 0x57)\n
Name (_CID, "diagsvault")\n
Method (_DSM, 4, NotSerialized)\n
{\n
Store (Package (0x02)\n
{\n
"address", \n
0x57\n
}, Local0)\n
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))\n
Return (Local0)\n
}\n
}\n
}
end;
# HPET fix
into method label _STA parent_hid PNP0103 remove_entry;
into device name_hid PNP0103 insert
begin
Method (_STA, 0, NotSerialized)\n
{\n
Return (0x0F)\n
}
end;
into method label _CRS parent_hid PNP0103 remove_entry;
into device name_hid PNP0103 insert
begin
Method (_CRS, 0, NotSerialized)\n
{\n
Return (BUF0)\n
}
end;
# Remove icons for SD card
into method label _RMV parent_label SMHC replace_content begin Return (Zero) end;
into method label _RMV parent_label MSHC replace_content begin Return (Zero) end;
into method label _RMV parent_label XDCC replace_content begin Return (Zero) end;
into method label _RMV parent_label I1C replace_content begin Return (Zero) end;
03_AR9285 Atheros WiFi card. Use instead of patching AirPortAtheros40.kext with pci168c,2b
Code:
# Atheros AR9285 fix works with vanilla IO80211 kext
into device label WNIC parent_label RP04 replace_content
begin
Name (_ADR, Zero) // _ADR: Address\n
Method (_PRW, 0, Serialized) // _PRW: Power Resources for Wake\n
{\n
Return (^^_PRW)\n
}\n
Method (_DSM, 4, NotSerialized)\n
{\n
Store (Package (0x0C)\n
{\n
"AAPL,slot-name", \n
Buffer (0x08)\n
{\n
"AirPort"\n
}, \n
"device-id", \n
Unicode ("*"), \n
"device_type", \n
Buffer (0x08)\n
{\n
"AirPort"\n
}, \n
"model", \n
Buffer (0x33)\n
{\n
"Atheros 9285 802.11 b/g/n Wireless Network Adapter"\n
},\n
"subsystem-id", \n
Buffer (0x04)\n
{\n
0x8F, 0x00, 0x00, 0x00\n
}, \n
"subsystem-vendor-id", \n
Buffer (0x04)\n
{\n
0x6B, 0x10, 0x00, 0x00\n
}\n
}, Local0)\n
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))\n
Return (Local0)\n
}
end;
# Rename wireless label WNIC to ARPT
into all label WNIC set_label begin ARPT end;
04a_HDMI. Provides HDMI and QE/CI graphics info for HD3000/HD4000 (HD3000 in addition needs MEI patch)
Code:
# Inject HDMI info into GFX0/IGPU */
into method label _DSM parent_adr 0x00020000 remove_entry;
into device name_adr 0x00020000 insert
begin
Method (_DSM, 4, NotSerialized)\n
{\n
Store (Package ()\n
{\n
"hda-gfx",\n
Buffer (0x0A)\n
{\n
"onboard-1"\n
},\n
"AAPL,snb-platform-id",\n
Buffer (0x04)\n
{\n
0x00, 0x00, 0x01, 0x00\n
},\n
"AAPL,ig-platform-id",\n
Buffer (0x04)\n
{\n
0x03, 0x00, 0x66, 0x01\n
}\n
}, Local0)\n
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))\n
Return (Local0)\n
}\n
end;
04b_HDMI_Dual-Link. Use instead of patch 4a (1600x900 and 4740S laptops)
Code:
# Inject HDMI info and dual-link into GFX0/IGPU */
# Do not use GraphicsEnabler or device-properties
into method label _DSM parent_adr 0x00020000 remove_entry;
into device name_adr 0x00020000 insert
begin
Method (_DSM, 4, NotSerialized)\n
{\n
Store (Package ()\n
{\n
"AAPL00,DualLink",\n
Buffer (0x04)\n
{\n
0x01, 0x00, 0x00, 0x00\n
},\n
"hda-gfx",\n
Buffer (0x0A)\n
{\n
"onboard-1"\n
},\n
"AAPL,snb-platform-id",\n
Buffer (0x04)\n
{\n
0x00, 0x00, 0x01, 0x00\n
},\n
"AAPL,ig-platform-id",\n
Buffer (0x04)\n
{\n
0x04, 0x00, 0x66, 0x01\n
}\n
}, Local0)\n
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))\n
Return (Local0)\n
}\n
end;
Code:
# add fan readings and fan control
into device label SMCD remove_entry;
into definitionblock code_regex . insert
begin
Device (SMCD)\n
{\n
Name (_HID, "FAN00000") // _HID: Hardware ID\n
Method (FAN0, 0, Serialized)\n
{\n
Store (\_TZ.GFRM (), Local0)\n
If (LEqual (0x03C4, Local0))\n
{\n
Store (Zero, Local0)\n
Return (Local0)\n
}\n
Return (Local0)\n
}\n
\n
// commented out: just for debugging and experimenting
//
// monitoring additional temperatures\n
// Method (TDIM, 0, Serialized) // GFXZ temp\n
// {\n
// Divide (Subtract (\_TZ.GFXZ._TMP, 2732), 10,, Local0)\n
// return (Local0)\n
// }\n
// Method (TSYS, 0, Serialized) // LOCZ temp\n
// {\n
// Divide (Subtract (\_TZ.LOCZ._TMP, 2732), 10,, Local0)\n
// return (Local0)\n
// }\n
//\n
// for debugging fan control\n
// Method (TCPP, 0, Serialized) // Average temp\n
// {\n
// Store (FNUM, Local0)\n
// if (LNotEqual (Local0, 0))\n
// {\n
// Store (FSUM, Local1)\n
// Divide (Local1, Local0,, Local0)\n
// }\n
// return (Local0)\n
// }\n
// Method (TAMB, 0, Serialized) // fan counter\n
// {\n
// return (FCNT)\n
// }\n
//\n
Method (TCPU, 0, Serialized)\n
{\n
Acquire (\_SB.PCI0.LPCB.EC0.ECMX, 0xFFFF)\n
Store (1, \_SB.PCI0.LPCB.EC0.CRZN)\n
Store (\_SB.PCI0.LPCB.EC0.DTMP, Local0)\n
Release (\_SB.PCI0.LPCB.EC0.ECMX)\n
return (Local0)\n
}\n
\n
// Fan Control Table (pairs of temp, fan control byte)\n
Name (FTAB, Buffer ()\n
{\n
50, 255, // 255 is off (really auto, but at low temp it is off)\n
57, 128, // 128 is slowest speed\n
63, 82,\n
68, 74,\n
72, 59,\n
75, 49,\n
0xFF, 0 // last entry must be 0xFF, 0 is max fan speed\n
})\n
// Table to keep track of past temperatures (to build average)\n
Name (FHST, Buffer (16) { 0x0, 0, 0, 0, 0x0, 0, 0, 0, 0x0, 0, 0, 0, 0x0, 0, 0, 0 })\n
Name (FIDX, Zero) // current index in buffer above\n
Name (FNUM, Zero) // number of entries in above buffer to count in avg\n
Name (FSUM, Zero) // current sum of entries in buffer\n
// Keeps track of last fan speed set, and counter to set new one\n
Name (FLST, 0xFF) // last index for fan control\n
Name (FCNT, 0) // count of times it has been "wrong", 0 means no counter\n
Name (FCTU, 20) // timeout for changes (fan rpm going up)\n
Name (FCTD, 40) // timeout for changes (fan rpm going down)\n
\n
// Fan control for CPU -- expects to be evaluated 1-per second\n
Method (FCPU, 0, Serialized)\n
{\n
Acquire (\_SB.PCI0.LPCB.EC0.ECMX, 0xFFFF)\n
\n
// setup fake temperature (this is the key to controlling the fan!)\n
Store (1, \_SB.PCI0.LPCB.EC0.CRZN) // select CPU temp\n
Store (31, \_SB.PCI0.LPCB.EC0.TEMP) // write fake value there (31C)\n
\n
// get current temp into Local0 for eventual return\n
// Note: reading from DTMP here instead of TEMP because we wrote\n
// a fake temp to TEMP to trick the system into running the fan\n
// at a lower speed than it otherwise would.\n
Store (1, \_SB.PCI0.LPCB.EC0.CRZN) // select CPU temp\n
Store (\_SB.PCI0.LPCB.EC0.DTMP, Local0) // Local0 is current temp\n
\n
// calculate average temperature\n
Add (Local0, FSUM, Local1)\n
Store (FIDX, Local2)\n
Subtract (Local1, DerefOf (Index (FHST, Local2)), Local1)\n
Store (Local0, Index (FHST, Local2))\n
Store (Local1, FSUM) // Local1 is new sum\n
\n
// adjust current index into temp table\n
Increment (Local2)\n
if (LGreaterEqual (Local2, SizeOf(FHST)))\n
{ Store (0, Local2) }\n
Store (Local2, FIDX)\n
// adjust total items collected in temp table\n
Store (FNUM, Local2)\n
if (LNotEqual (Local2, SizeOf (FHST)))\n
{\n
Increment (Local2)\n
Store (Local2, FNUM)\n
}\n
\n
// Local1 is new sum, Local2 is number of entries in sum\n
Divide (Local1, Local2,, Local0) // Local0 is now average temp\n
\n
// table based search (use avg temperature to search)\n
if (LGreater (Local0, 255)) { Store (255, Local0) }\n
Store (Zero, Local2)\n
while (LGreater (Local0, DerefOf (Index (FTAB, Local2))))\n
{ Add (Local2, 2, Local2) }\n
\n
// calculate difference between current and found index\n
if (LGreater (Local2, FLST))\n
{\n
Subtract(Local2, FLST, Local1)\n
Store(FCTU, Local4)\n
}\n
else\n
{\n
Subtract(FLST, Local2, Local1)\n
Store(FCTD, Local4)\n
}\n
\n
// set new fan speed, if necessary\n
if (LEqual (Local1, 0))\n
{\n
// no difference, so leave current fan speed and reset count\n
Store (0, FCNT)\n
}\n
else\n
{\n
// there is a difference, start/continue process of changing fan\n
Store (FCNT, Local3)\n
Increment (Local3)\n
Store (Local3, FCNT)\n
\n
// how long to wait depends on how big the difference\n
// 20 secs if diff is 2, 5 secs if diff is 4, etc.\n
Divide (ShiftLeft (Local4, 1), Local1,, Local1)\n
if (LGreaterEqual (Local3, Local1))\n
{\n
// timeout expired, so set new fan speed\n
Store (Local2, FLST)\n
Increment (Local2)\n
Store (DerefOf (Index (FTAB, Local2)), \_SB.PCI0.LPCB.EC0.FTGC)\n
Store (0, FCNT)\n
}\n
}\n
\n
Release (\_SB.PCI0.LPCB.EC0.ECMX)\n
return (Local0) // returns average temp\n
}\n
}\n
end;
05b Fan_Speed. No fan control, displays speed and heatsink temperature only. Use instead of patch 5a
Code:
into device label SMCD remove_entry;
into definitionblock code_regex . insert
begin
Device (SMCD)\n
{\n
Name (_HID, "FAN00000") // _HID: Hardware ID\n
Method (FAN0, 0, Serialized)\n
{\n
Store (\_TZ.GFRM (), Local0)\n
If (LEqual (0x03C4, Local0))\n
{\n
Store (Zero, Local0)\n
Return (Local0)\n
}\n
Return (Local0)\n
}\n
Method (TCPU, 0, Serialized)\n
{\n
Acquire (\_SB.PCI0.LPCB.EC0.ECMX, 0xFFFF)\n
Store (1, \_SB.PCI0.LPCB.EC0.CRZN)\n
Store (\_SB.PCI0.LPCB.EC0.DTMP, Local0)\n
Release (\_SB.PCI0.LPCB.EC0.ECMX)\n
return (Local0)\n
}\n
}\n
end;