Skip to content

SL3 Ambient light sensor driver #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
archseer opened this issue Mar 14, 2020 · 11 comments
Closed

SL3 Ambient light sensor driver #121

archseer opened this issue Mar 14, 2020 · 11 comments
Labels
C: missing feature Category: Missing Feature D: Surface Book 3 Device: Surface Book 3 D: Surface Laptop 3 Device: Surface Laptop 3 D: Surface Pro 7 Device: Surface Pro 7

Comments

@archseer
Copy link
Member

SL3 uses a custom ambient light sensor (MSHW0184) under i2c-12. By dumping some logs on windows I was able to find the correct sequence to turn the sensor on:

https://gist.github.com/archseer/3f58a74d4dd02dd0c9284b571fdbc1df

Intel(R) Serial IO I2C Host Controller 34C5 -> Surface Light Sensor (MSHW0184) -> VHF (HID, the hid-iio framework should take care of that). _SB.PCI0.I2C4.ACSD on the ACPI.

All the registers seem to line up with APDS9960 which is already upstream so we can probably just reuse the same driver. I wasn't able to get the driver to bind after boot via sysfs (I think it said something like "resource busy").

We should be able to get the driver to bind by modifying this to include MSHW0184 but I haven't had the time to do a full kernel recompile yet.

Lastly, this might also affect SP7, I'm not sure.

@qzed qzed added D: Surface Book 3 Device: Surface Book 3 D: Surface Pro 7 Device: Surface Pro 7 labels Jun 8, 2020
@archseer
Copy link
Member Author

archseer commented Jun 8, 2020

Sensors supposedly work on SP7, they were checked off on the feature matrix at least. Maybe we just didn't get an accurate report from end users.

@archseer
Copy link
Member Author

archseer commented Jun 8, 2020

I must have missed that, it looks like the same device as SL3 actually (also on I2C4).

@archseer
Copy link
Member Author

archseer commented Jun 8, 2020

All the registers seem to line up with apds9960, and I was able to turn on the sensor and read data from the same sequence as in that driver if I remember correctly. Should be as simple as adding the device to https://github.com/torvalds/linux/blob/fffb08b37df928475fef9c7f2aafddc2f6ebfaf4/drivers/iio/light/apds9960.c#L1111-L1121

@qzed
Copy link
Member

qzed commented Jun 8, 2020

Sensors supposedly work on SP7, they were checked off on the feature matrix at least. Maybe we just didn't get an accurate report from end users.

I think they saw the other IIO sensors and didn't notice that the ALS was missing. Those seem to also work on the SB3.

@qzed qzed mentioned this issue Jun 11, 2020
@MaxLeiter
Copy link

@archseer any update here? Is adding the device all that's required?

@archseer
Copy link
Member Author

archseer commented Dec 9, 2020

We should be able to get the driver to bind by modifying this to include MSHW0184 but I haven't had the time to do a full kernel recompile yet.

That's still the case, I dumped all the info here hoping someone else will pick up the issue. I haven't had the motivation to do so since my setup doesn't use the ambient sensors. I can probably give it another look this week though, now using a custom kernel config so it doesn't take forever to recompile anymore.

@MaxLeiter
Copy link

@archseer I'm in the ##linuxsurface channel working on this if you'd like to talk

@MaxLeiter
Copy link

MaxLeiter commented Dec 10, 2020

Patch for detecting the device by adding an acpi match table: https://gist.github.com/MaxLeiter/800146e7fbb5abee792d1b50f6e3dcbc

also for anyone investigating, on the surface pro 7 the device is under i2c-3

@qzed
Copy link
Member

qzed commented Aug 26, 2021

I believe we can close this as the patch has been merged and is upstream. If not let me know.

@qzed qzed closed this as completed Aug 26, 2021
@MaxLeiter
Copy link

Yep sorry, the patch was merged. https://lkml.org/lkml/2020/12/21/271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: missing feature Category: Missing Feature D: Surface Book 3 Device: Surface Book 3 D: Surface Laptop 3 Device: Surface Laptop 3 D: Surface Pro 7 Device: Surface Pro 7
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants