Skip to content
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

USB-C Power Delivery Events #63

Open
qzed opened this issue Jun 22, 2022 · 2 comments
Open

USB-C Power Delivery Events #63

qzed opened this issue Jun 22, 2022 · 2 comments

Comments

@qzed
Copy link
Member

qzed commented Jun 22, 2022

The USC subsystem is used for USB-C power delivery management on the Pro X via a SurfaceUsbCMuxAcpiFilterDriver.sys. It's possible that other (newer) devices use that as well.

Quoting myself from the issue where this was first discovered (linux-surface/surface-pro-x#33):

There is indeed some SAM stuff going on in the SurfaceUsbCMuxAcpiFilterDriver.sys using the USC subsystem. There seem to be two methods, specifically. A FilterGetPortNumbers and a FilterSendUSBCAck. In addition to that, there's a PdEventInfoUpdateFromSamToSoc function, which might be some part of a PD event handler by its name.

In fact all three functions are called in the same ProcessUsbCResponse function, first getting the port number(s?), then updating the PD event info, then sending the ACK back. I think what's happening is that SAM might send a PD event when a USB-C source is plugged in. This is then handled by that process-response function.

And from the related issue for the Pro X (the device on which this was first discovered; linux-surface/surface-pro-x#35):

Turns out we can enable and receive events on Linux (using the standard SAM event registry) when I plug in my phone for charging, but I should probably get some USB-C power meter and a powerful enough USB-C charger to see if there are any changes. Also I don't know yet what to send back to SAM via the ACK command.

Interestingly, when I enable SAM events, the port seems to do something (at very least cut power for a brief moment) as my phone screen turns on. Phone says "fast charging" regardless of events being enabled/disabled though...

Events can be enabled with

./scripts/ssam/events.py enable 0x01 0x01 0x0b 0x0c 0x1b 0x00 0x01

and listened to with

./scripts/ssam/events.py listen 0x1b

It would be interesting to know whether that's also a thing on other devices.

@NP-chaonay
Copy link

NP-chaonay commented Jun 23, 2022

SLS confirmed nothing happens when run above events.py

Both switching from AC > AC+USB Type C > USB Type C >> no events displayed
and USB Type C > AC+USB Type C > AC >> no events displayed
Noted that i mean charging to laptop

However on Windows side can able to detect USB type C and say using AC instead warning message because of slow charging (noted that it may come from charging power is lower than threshold)

On Linux dmesg gives while testing, maybe happens when remove AC while USB type C is plugged in

[125915.253494] usb usb2-port2: attempt power cycle
[125923.801628] usb usb2-port2: unable to enumerate USB device
[126047.281458] usb usb2-port2: attempt power cycle
[126055.829835] usb usb2-port2: unable to enumerate USB device

And I uses external SSD so I cannot tell much about this, since idk,

PS: in surfaceupdate folder (which contains driver downloaded from ms) is not found of that sys file

@qzed
Copy link
Member Author

qzed commented Jun 23, 2022

Thanks. It looks like this is specific to the Pro X.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants