Skip to content

Commit 951d76b

Browse files
authored
Get Configuration from ACPI for SMBus devices (#157)
1 parent 372267e commit 951d76b

File tree

6 files changed

+61
-1
lines changed

6 files changed

+61
-1
lines changed

VoodooRMI/Transports/I2C/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
<string>2.5</string>
5050
<key>com.1Revenger1.VoodooRMI</key>
5151
<string>1.0</string>
52+
<key>com.apple.iokit.IOACPIFamily</key>
53+
<string>1.0.0d1</string>
5254
<key>com.apple.kpi.iokit</key>
5355
<string>15</string>
5456
<key>com.apple.kpi.libkern</key>

VoodooRMI/Transports/I2C/RMII2C.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class RMII2C : public RMITransport {
8686
int reset() APPLE_KEXT_OVERRIDE;
8787
int readBlock(u16 rmiaddr, u8 *databuff, size_t len) APPLE_KEXT_OVERRIDE;
8888
int blockWrite(u16 rmiaddr, u8 *buf, size_t len) APPLE_KEXT_OVERRIDE;
89-
OSDictionary *createConfig() APPLE_KEXT_OVERRIDE;
89+
virtual OSDictionary *createConfig() APPLE_KEXT_OVERRIDE;
9090

9191
private:
9292
bool ready {false};

VoodooRMI/Transports/SMBus/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
<string>3.0</string>
4646
<key>com.1Revenger1.VoodooRMI</key>
4747
<string>1.0</string>
48+
<key>com.apple.iokit.IOACPIFamily</key>
49+
<string>1.0.0d1</string>
4850
<key>com.apple.kpi.iokit</key>
4951
<string>15</string>
5052
<key>com.apple.kpi.libkern</key>

VoodooRMI/Transports/SMBus/RMISMBus.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
*/
99

1010
#include "RMISMBus.hpp"
11+
#include "Configuration.hpp"
12+
#include <IOKit/acpi/IOACPIPlatformDevice.h>
1113

1214
OSDefineMetaClassAndStructors(RMISMBus, RMITransport)
1315
#define super IOService
@@ -341,3 +343,35 @@ IOReturn RMISMBus::setPowerState(unsigned long whichState, IOService* whatDevice
341343

342344
return kIOPMAckImplied;
343345
}
346+
347+
OSDictionary *RMISMBus::createConfig() {
348+
OSDictionary *config = nullptr;
349+
OSArray *acpiArray = nullptr;
350+
OSObject *acpiReturn = nullptr;
351+
352+
// Unlike VoodooI2C, VoodooSMBusNubs are not ACPI Devices directly. Grab the device that the controller is attached too
353+
IORegistryEntry *controller = device_nub->getParentEntry(gIOServicePlane);
354+
if (controller == nullptr) return nullptr;
355+
356+
IORegistryEntry *pciNub = controller->getParentEntry(gIOServicePlane);
357+
if (pciNub == nullptr || pciNub->getProperty("acpi-device") == nullptr) {
358+
IOLogError("%s Could not retrieve controller for config", getName());
359+
return nullptr;
360+
}
361+
362+
IOACPIPlatformDevice *acpi_device = OSDynamicCast(IOACPIPlatformDevice, pciNub->getProperty("acpi-device"));
363+
if (!acpi_device) {
364+
IOLogError("%s Could not retrieve acpi device", getName());
365+
return nullptr;
366+
};
367+
368+
if (acpi_device->evaluateObject("RCFG", &acpiReturn) != kIOReturnSuccess) {
369+
return nullptr;
370+
}
371+
372+
acpiArray = OSDynamicCast(OSArray, acpiReturn);
373+
config = Configuration::mapArrayToDict(acpiArray);
374+
OSSafeReleaseNULL(acpiReturn);
375+
376+
return config;
377+
}

VoodooRMI/Transports/SMBus/RMISMBus.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class RMISMBus : public RMITransport {
4141
int blockWrite(u16 rmiaddr, u8 *buf, size_t len) override;
4242

4343
int reset() override;
44+
virtual OSDictionary *createConfig() APPLE_KEXT_OVERRIDE;
4445
private:
4546
VoodooSMBusDeviceNub *device_nub;
4647
IOLock *page_mutex;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Example of how to configure VoodooRMI when using
3+
* an SMBus trackpad.
4+
*
5+
* Configuration values can be found in the README
6+
*/
7+
8+
#define SBUS_DEVICE \_SB.PCI0.SBUS
9+
10+
DefinitionBlock ("", "SSDT", 2, "GWYD", "Set", 0) {
11+
External (SBUS_DEVICE, DeviceObj)
12+
Scope (SBUS_DEVICE) {
13+
Name (RCFG, Package() {
14+
// Disable force touch
15+
// 0 = Disabled
16+
// 1 = Clickpad button + Size threshold
17+
// 2 = Size threshold
18+
"ForceTouchType", 0,
19+
})
20+
}
21+
}

0 commit comments

Comments
 (0)