driverosx-yosemitekernel-extensionhackintosh

How to write a driver for Elan smartpad for it to work on Yosemite?


I recently installed hackintosh Yosemite on my Lenovo Y50 system and used the provided kexts to make most of the things work. The elan smartpad (touchpad) is not working though. I would like to develop kexts or any other software required to make it work on my own. I am not able to find the hardware specifications for the elan smartpad on web. Can anyone help me find it. Also, what should be my next step after reading the specifications. Any suggestions from people experienced from writing kexts or device drivers is welcome.

Thankyou.

Elan Smartpad webpage


Solution

  • There are quite a few pieces to this. Depends on what you already know/have experience with, and how much time and persistence you'd like to invest in it, and of course, the awkwardness of the hardware itself, as to whether it'll be worth it...

    1. Determine type of hardware interface. It's most likely a USB HID device, although if not, it's going to be more work, as you'll need to turn the messages the device sends into HID reports one way or another. Easiest way to find out is to download the Hardware IO Tools from Apple's developer website, or the open source IOJones, and look for the device in the service tree. You'll likely find it attached to a USB bus, but a key question is what drivers are already matched on it. IOHID* is a good sign. IOHIDPointing is an even better sign. Note that its default configuration may not be the only one, and if there are multiple device configurations, the default one likely isn't the most fully featured one. (Read up on USB device configurations if this doesn't ring a bell.)

    2. If it doesn't report as a HID device, you'll need to figure out its hardware interface in detail. If there's an open source Linux or BSD driver, you can probably work it out from that source and translate it into an IOKit kext for OSX. Not straightforward, expect this to take you quite some time if it's your first driver. I'd recommend trying to write a user space USB driver first, and porting it to the kernel when you're happy with the messages you're getting. If there's no OSS driver, reverse engineer the Windows one. Easiest way is to install Windows in a VM, pass the USB device through to the VM, load the driver there, and log all of the USB traffic on your host machine. Then painstakingly work out what it all means. Once you have worked out the messages, you may need to translate them into HID reports, together with a report descriptor that tells the OS how they're formatted. You need to publish it to the OS as a HID device. Check the IOHIDFamily source for details, and use a mouse or so as a working reference.

    3. Once you have HID descriptors, the question is whether OSX can interpret them as is. If your device already shows up as HID, then either OSX isn't interpreting the report descriptor as a pointing defice correctly, or it can't make sense of the resulting reports. You'll need to either modify the report descriptor, or both the descriptor and every report to something that makes sense to OSX. The best way is probably to look at the report descriptor for a similar device (e.g. Apple's own trackpad) and try to turn your device's into a similar form. The other useful technique is to trace through the IOHIDFamily soirce to find out where it's going wrong. An example of a driver that modifies HID report descriptors (but not reports) for OSX to make sense of them is here: https://github.com/pmj/QemuUSBTablet-OSX/blob/master/QemuUSBTablet/PJQemuUSBTabletDriver.cpp

    Depending on your level of experience with this kind of thing, there's probably quite a bit in there that doesn't make a whole lot of sense initially. Expect to read up on USB, HID, the xnu kernel, kext development, etc. if you aren't already intimately familiar with those topics. On the plus side, this is probably not the hardest possible driver project to get started on. Good luck!