Skip to content

Commit

Permalink
Get Configuration from ACPI for SMBus devices (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
1Revenger1 authored Jan 24, 2023
1 parent 372267e commit 951d76b
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
2 changes: 2 additions & 0 deletions VoodooRMI/Transports/I2C/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<string>2.5</string>
<key>com.1Revenger1.VoodooRMI</key>
<string>1.0</string>
<key>com.apple.iokit.IOACPIFamily</key>
<string>1.0.0d1</string>
<key>com.apple.kpi.iokit</key>
<string>15</string>
<key>com.apple.kpi.libkern</key>
Expand Down
2 changes: 1 addition & 1 deletion VoodooRMI/Transports/I2C/RMII2C.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class RMII2C : public RMITransport {
int reset() APPLE_KEXT_OVERRIDE;
int readBlock(u16 rmiaddr, u8 *databuff, size_t len) APPLE_KEXT_OVERRIDE;
int blockWrite(u16 rmiaddr, u8 *buf, size_t len) APPLE_KEXT_OVERRIDE;
OSDictionary *createConfig() APPLE_KEXT_OVERRIDE;
virtual OSDictionary *createConfig() APPLE_KEXT_OVERRIDE;

private:
bool ready {false};
Expand Down
2 changes: 2 additions & 0 deletions VoodooRMI/Transports/SMBus/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
<string>3.0</string>
<key>com.1Revenger1.VoodooRMI</key>
<string>1.0</string>
<key>com.apple.iokit.IOACPIFamily</key>
<string>1.0.0d1</string>
<key>com.apple.kpi.iokit</key>
<string>15</string>
<key>com.apple.kpi.libkern</key>
Expand Down
34 changes: 34 additions & 0 deletions VoodooRMI/Transports/SMBus/RMISMBus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/

#include "RMISMBus.hpp"
#include "Configuration.hpp"
#include <IOKit/acpi/IOACPIPlatformDevice.h>

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

return kIOPMAckImplied;
}

OSDictionary *RMISMBus::createConfig() {
OSDictionary *config = nullptr;
OSArray *acpiArray = nullptr;
OSObject *acpiReturn = nullptr;

// Unlike VoodooI2C, VoodooSMBusNubs are not ACPI Devices directly. Grab the device that the controller is attached too
IORegistryEntry *controller = device_nub->getParentEntry(gIOServicePlane);
if (controller == nullptr) return nullptr;

IORegistryEntry *pciNub = controller->getParentEntry(gIOServicePlane);
if (pciNub == nullptr || pciNub->getProperty("acpi-device") == nullptr) {
IOLogError("%s Could not retrieve controller for config", getName());
return nullptr;
}

IOACPIPlatformDevice *acpi_device = OSDynamicCast(IOACPIPlatformDevice, pciNub->getProperty("acpi-device"));
if (!acpi_device) {
IOLogError("%s Could not retrieve acpi device", getName());
return nullptr;
};

if (acpi_device->evaluateObject("RCFG", &acpiReturn) != kIOReturnSuccess) {
return nullptr;
}

acpiArray = OSDynamicCast(OSArray, acpiReturn);
config = Configuration::mapArrayToDict(acpiArray);
OSSafeReleaseNULL(acpiReturn);

return config;
}
1 change: 1 addition & 0 deletions VoodooRMI/Transports/SMBus/RMISMBus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class RMISMBus : public RMITransport {
int blockWrite(u16 rmiaddr, u8 *buf, size_t len) override;

int reset() override;
virtual OSDictionary *createConfig() APPLE_KEXT_OVERRIDE;
private:
VoodooSMBusDeviceNub *device_nub;
IOLock *page_mutex;
Expand Down
21 changes: 21 additions & 0 deletions docs/Acpi_Examples/SSDT-VRMI-SBUS.dsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Example of how to configure VoodooRMI when using
* an SMBus trackpad.
*
* Configuration values can be found in the README
*/

#define SBUS_DEVICE \_SB.PCI0.SBUS

DefinitionBlock ("", "SSDT", 2, "GWYD", "Set", 0) {
External (SBUS_DEVICE, DeviceObj)
Scope (SBUS_DEVICE) {
Name (RCFG, Package() {
// Disable force touch
// 0 = Disabled
// 1 = Clickpad button + Size threshold
// 2 = Size threshold
"ForceTouchType", 0,
})
}
}

0 comments on commit 951d76b

Please sign in to comment.