You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
I think we might need to have to log SAM events on Windows to get a better idea on what's going on with that.
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...
The SurfaceUsbCMuxAcpiFilterDriver.sys filter driver is designed to sit in the middle of ACPI.sys IOCTL events.
In order to enable Display Port for Windows GPU driver normally the UCSI Driver from qualcomm notifies either via an interface or via an ACPI notify function the GPU device that a cable got inserted at this port number in this orientation. And it does so by getting notified from PmicGlink (missing on the Surface Pro X)
Given the Pro X doesn't make use of PmicGlink/BattMngr/PTCC in ADSP.mbn and instead uses SAM this is broken.
So the filter driver serves as getting notifications from SAM and then making qualcomm's driver react by notifying it of an pmicglink event (even though there's no pmicglink), so the GPU driver can setup display port output.
This is one of the functionality of that driver that I gathered, but I'm not sure if it does anything else.
I've experimented a bit more with various USB devices, but I don't have a powerful enough USB-C charger here, so I probably can't look at power-delivery stuff properly.
Events have 11 bytes and start off with a sequence number. Also, if events are not ACKed, the last event repeats for up to a total of 5 events being sent for one action (all with the same sequence number, which is simply incremented for new events).
So far, I've gathered the following structure. I've tested the display-port part of this with the Surface USB-C hub and its HDMI output, so this might be a bit different for more/other display connections.
structusbc_event {
u32sequence_number; // sequence number, increases with each new event (might also be smaller than 32 bit)u8port_id; // ID/index of the USB-C port, top=1, bottom=0u8cable_orientation; // 0=normal, 1=flipped, 2=disconnectu8event_type; // 0=disconnect, 1=connect, 3=dp_link_change?u8unknown1; // 2 on USB-C disconnect, 0 for everything else observed so faru8dp_link_prop; // some DP link ID?, only set on DP change, 4 or 10 for HDMI port (depending on orientation)u8dp_link_conn; // 1=connect_display, 0=disconnect_displayu8unknown2; // seems to be zero
};
I guess the event payload might be different for different (sub-)types of events.
@gus33000 You wouldn't happen to know what data specifically needs to be sent via glink (and/or could fill in the gaps of the struct above) and to which specific endpoints? I assume the display-port controller (mdss-mdp) is one?
The ACK command sent back to SAM seems to have the following properties: Target category 0x1b, target ID 0x01, instance ID 0x01, command ID 0x03. Multiple (re-)tries are attempted when the command fails.
The command payload is 12 bytes with the following structure
structusbc_ack_to_sam {
u32sequence_number; // the sequence number of the event to ACKu32unknown1; // seems to be port ID cast to u32?u32unknown2; // some bool (or byte?) returned from PdEventInfoUpdateFromSamToSoc or zero
};
Interestingly, only the LSB of unknown2 seems to be set. So could be that the rest is just padding, but that's fairly unusual for SAM communication.
@gus33000 You wouldn't happen to know what data specifically needs to be sent via glink (and/or could fill in the gaps of the struct above) and to which specific endpoints? I assume the display-port controller (mdss-mdp) is one?
Actually the filter doesn't send anything via Glink, the Surface Pro X does not provide the Pmic Glink interface at all (so no USB-C handled by ADSP, no battery management handled by ADSP). But due to how the Qualcomm GPU DirectX driver is built they needed to reuse that UCSI driver to make DisplayPort connections work.
I'm currently working on the same sort of thing for the Surface Duo.
The UCSI driver is able to make calls directly to the GPU driver to tell it, I detected a cable in DP AltMode with this pin assignment and this orientation, then the GPU driver enables the DisplayPort connection and sets up MDSS / DP PHY etc. It also tells the GPU driver which port was detected (this ultimately depends on the amount of EXTERNAL connections defined in ACPI for the GPU device)
The UCSI driver is basically a shim, listening to the QcPmicGlink8180.sys driver (not present on the Pro X), and that PmicGlink driver sends IOCTLs to the UCSI driver to notify it of changes.
The role of that filter driver is to send IOCTLs to the UCSI driver when needed so it can tell the GPU driver a DP connection needs to be setup. (essentially re-implementing missing functionality due to the Qualcomm Pmic Glink stack not being present on this device)
Unfortunately I can't help much with SAM events as my device doesn't use them so I can't really complete the structure for you, but I do actually need to not use PmicGlink (just like on the Surface Pro X) because Android platforms of the time also did not have the USB-C/charging code in ADSP instead implementing it directly in the kernel/HLOS. Previous Qualcomm Windows Platforms (SDM845/Snapdragon 850) did not use PmicGlink either.
In a way it makes sense they would not use ADSP/PmicGlink here, they already have SAM for this.
From what I can see though you also have a Surface UCSI over HID driver (SurfaceUcmUcsiHidClient.sys) that likely uses the same events the filter uses to notify the GPU driver, but for providing standard USB-C UCSI functionality (for the other ports), so I'm not saying it's only used for that purpose, just that PmicGlink is out of reach on the Surface Pro X.
Ah sorry, I misunderstood earlier then (I thought only the Glink endpoint for USB-C was not present). Thanks for clearing that up. @andersson is working on Display Ports for the Lenovo Flex 5G, which uses the same SC8180X SoC. That apparently uses Glink, so I can then hopefully see what needs to be replaced and gauge the remaining fields.
From what I can see though you also have a Surface UCSI over HID driver (SurfaceUcmUcsiHidClient.sys) that likely uses the same events the filter uses to notify the GPU driver, but for providing standard USB-C UCSI functionality (for the other ports), so I'm not saying it's only used for that purpose, just that PmicGlink is out of reach on the Surface Pro X.
As far as I know, that driver is also present on a bunch of other x86 Surface devices as well. The respective device is some SAM-provided HID device, at least according to the Windows Device Manager. Unfortunately, I haven't been able to receive any input events from that, so I'm not sure whether it provides some (e.g. when devices are connected/disconnected), whether the command to enable events is wrong, or whether it just doesn't provide any. Also, the SPX doesn't have any other USB-C ports, so if it plays a similar role as the SAM notifications, it might not be used at all...
Here's the descriptor for that device: t1i0.c.txt. However, I'm not even sure if that's the right device since that reports an id of 045e:0922 (whereas the .inf for the driver has 045e:ff00 and 045e:f900?). But that's the only other HID device I've found via SAM. So could be that it's some virtual device.
How SurfaceUcmUcsiHidClient.sys / Surface UCSI-over-HID Works
HID Matching (HID\VID_045E&UP:FF00_U:F900):
UP:FF00_U:F900 in SurfaceUcmUcsiHidClient.inf is the HID Application Collection Usage Page (0xFF00) and Usage (0xF900), not the USB/SSAM Product ID. That is why it appears under 045E:0922 on Surface Pro X and 045E:09A6 on Surface Book 3.
Note that sibling SSAM HID collections can share the same VID:PID (for example, on Surface Book 3 045E:09A6 has two separate HID interfaces: 0xFF00:0xF900 for the UCSI PPM and 0xFF0B:0x0101 for Base CFU firmware updates). Assigning a dedicated HID_GROUP_SURFACE_UCSI in hid_scan_collection() lets ucsi_surface_hid bind exclusively to 0xFF00:0xF900 across all Surface models.
HID Report Layout (109-byte descriptor):
Feature Report 0x32 (49 bytes = 1-byte Report ID + 48-byte UCSI v1.x data structure):
+0x00 (u8): Report ID (0x32)
+0x01 (__le16): VERSION(note: uninitialized in SAM RAM prior to the first UCSI_PPM_RESET after cold boot — e.g. 0x7628 on SB3 — so read_version() must sanitize pre-reset values outside {0x0100, 0x0110, 0x0120} to 0x0110)
+0x03 (__le16): RESERVED / sequence (0)
+0x05 (__le32): CCI
+0x09 (__le64): CONTROL
+0x11 (u8[16]): MESSAGE_IN
+0x21 (u8[16]): MESSAGE_OUT
Input Report 0x32: Asynchronous notification emitted by SAM whenever CCI changes — but SAM stays completely silent until initialized via SET_REPORT(Feature 0x32) with UCSI_PPM_RESET (0x01) followed by UCSI_SET_NOTIFICATION_ENABLE (0x05), which explains why raw hidraw reads showed no traffic earlier.
Feature Report 0x33 (3 bytes):[0x33, num_connectors, udc_supported] (e.g. connectors=1, udc_supported=0 on Surface Book 3).
Tested live on Surface Book 3 (7.3.0, /sys/class/typec/port0 Type-C 1.3 / USB PD 3.0 + ucsi-source-psy-*); testing on Surface Pro X (045E:0922) would be very welcome!
Finally got around to looking at this again, together with the UCSI-over-HID driver from linux-surface/kernel#184. Summary of what we now know about USB-C on the Surface Pro X:
Overview
There are two separate SAM interfaces for the two USB-C ports, mirroring what Qualcomm does with pmic_glink_altmode + ucsi_glink on other SC8180X/SC8280XP devices:
standard UCSI 1.x PPM: roles, PD contract, PDOs, partners, alt modes
Needed for
configuring the SoC side (QMP PHY orientation, USB/DP mux, HPD to the DP controller)
typec class / power-supply reporting
The two are coupled: the PPM only reflects the actual port state once the host handles (enables and ACKs) the USC events. Without that, GET_CONNECTOR_STATUS reports both connectors as disconnected, regardless of what's plugged in. This is presumably why I never got anything useful out of the HID device back then.
USC events
Enable: via the SAM event registry (TC 0x01, TID 0x01, CID 0x0b/0x0c), target category 0x1b, instance ID 0x01.
Event:TC 0x1b, TID 0x01, CID 0x02, IID 0x00, 11-byte payload:
ACK:TC 0x1b, TID 0x01, IID 0x01, CID 0x03, 12-byte payload { __le32 seq; __le32 port; __le32 flag; }. Without an ACK, SAM re-sends the last event per port every 2 s, five times in total, and only then updates the UCSI PPM (i.e. a ~10 s delay). The flag (Windows: LSB of the result of PdEventInfoUpdateFromSamToSoc) has no visible effect: both 0 and 1 stop the re-sends, and the PPM updates immediately either way.
On enable, SAM sends a burst containing the (queued) last events and current state of both ports. Events should be treated as full state (not deltas) and processed in order; the last event per port is the current state.
DP: a DP connection is reported as type=3 instead of type=1. HPD (dp_hpd) sometimes comes in the same event, sometimes as a second type=3 event ~220 ms later. The dp_mode value depends on the orientation (0x04/0x0a); its exact meaning is still unclear (0x04 would match pin assignment C, 0x0a doesn't fit that scheme). A DP+USB hub (pin assignment D) would help to figure this out.
Port mapping: bottom = port 0 = UCSI connector 1, top = port 1 = UCSI connector 2.
Side note: Currently, SuperSpeed only works in one orientation on Linux (flipped = USB 2 only), because nothing tells the QMP PHY about the orientation. A driver for these events would fix that via typec_switch_set().
UCSI over HID
Device: HID 045E:0922 at SSAM 01:15:01:00:00 (TID 1, IID 0). This is the only HID instance on TID 1 (probed IIDs 0x00–0x1f); the t1i0 dump above was correct. Windows lists it as Target_SAM&Category_HID … SID_DEVICE_01, Location 1. It's not part of the SPX registry group yet.
Events: need to be enabled via the SAM registry. The REG registry (SSAM_EVENT_REGISTRY_REG(1), what surface_hid currently uses) never responds, so hid_hw_start() times out. Without any enable, SAM sends the input reports with RQID 0 and they get dropped (rtl: dropping unexpected command message (rqid = 0x0000)). Note: enables persist across our disable (and seemingly some reboots), so test from a fresh boot.
With the USC events handled, everything works: correct connector status (power/data role, PD contract, partner type), partner PDOs (e.g. 5/9/12 V @ 3 A from a USB-C monitor), DP alt mode of the partner, and connector-change notifications, so partners appear and disappear automatically.
PPM quirks (details in the kernel PR):
unsupported commands (e.g. GET_CABLE_PROPERTY) are answered with only NOT_SUPPORTED set, without COMMAND_COMPLETE;
GET_ALTERNATE_MODES responses have an extra leading byte;
the VERSION field is garbage on every read;
RESET_COMPLETE is often still set after boot.
What's needed
Registry: SPX nodes for the UCSI HID device (01:15:01:00:00) and the USC events.
surface_hid: support selecting the SAM event registry per device.
ucsi_surface_hid (kernel#184) with the quirks above.
A new driver for the USC events (along the lines of pmic_glink_altmode), plus the DT connector graph (QMP PHYs, dwc3, mdss_dp0/1).
Also confirmed working on the SPX (kernel#184): input_power_limit from SAM Artg (60 W charger → 60000000 µW).
u8 alt_mode; // 0=nothing, 1=usb, 2=4xDP, 3=2xDP+2xSS
u8 unknown1; // 2 on USB-C disconnect, 1 on 4xDP
u8 pin_assignment; // Lanes used for DP?? 4xDP: 0011/1001, 2xDP: 0100/1010 // was: some DP link ID?, only set on DP change, 4 or 10 for HDMI port (depending on orientation)
Very early WIP does not work yet driver
// SPDX-icense-Identifier: GPL-2.0+/* * USB Type-C port driver for Microsoft Surface devices where the * Surface System Aggregator Module (SSAM) is fully managing the ports. * * Copyright (C) 2026 Val Packett <val@packett.cool> */#include<linux/fwnode.h>#include<linux/kernel.h>#include<linux/module.h>#include<linux/slab.h>#include<linux/types.h>#include<linux/surface_aggregator/device.h>#include<linux/usb/typec.h>#include<linux/usb/typec_dp.h>// #include <drm/bridge/aux-bridge.h>#defineSTCM_ORIENTATION_NORMAL 0
#defineSTCM_ORIENTATION_REVERSE 1
#defineSTCM_ORIENTATION_DISCONNECTED 2
#defineSTCM_MODE_NOTHING 1
#defineSTCM_MODE_SS_ONLY 1
#defineSTCM_MODE_DP_ONLY 2
#defineSTCM_MODE_SS_DP 3
structstcm_event {
__le32sequence_number; // sequence number, increases with each new event (might also be smaller than 32 bit)u8port_id; // ID/index of the USB-C port, top=1, bottom=0u8cable_orientation; // 0=normal, 1=flipped, 2=disconnectu8alt_mode; // 0=nothing, 1=usb, 2=4xDP, 3=2xDP+2xSSu8unknown1; // 2 on USB-C disconnect, 1 on 4xDPu8pin_assignment; // Lanes used for DP?? 4xDP: 0011/1001, 2xDP: 0100/1010 // some DP link ID?, only set on DP change, 4 or 10 for HDMI port (depending on orientation)u8dp_hpd; // 1=connect_display, 0=disconnect_displayu8unknown2; // seems to be zero. irq?
} __packed;
// [bit:reverse?] [] [] [bit:4xDP?]staticenumtypec_orientationmap_orientation(u8orientation)
{
switch (orientation) {
caseSTCM_ORIENTATION_NORMAL:
returnTYPEC_ORIENTATION_NORMAL;
caseSTCM_ORIENTATION_REVERSE:
returnTYPEC_ORIENTATION_REVERSE;
caseSTCM_ORIENTATION_DISCONNECTED:
returnTYPEC_ORIENTATION_NONE;
default:
pr_warn("unrecognized cable orientation %d", orientation);
returnTYPEC_ORIENTATION_NONE;
}
}
structstcm_ack_cmd {
__le32sequence_number; // the sequence number of the event to ACK__le32unknown1; // seems to be port ID cast to u32?__le32unknown2; // some bool (or byte?) returned from PdEventInfoUpdateFromSamToSoc or zero
} __packed;
SSAM_DEFINE_SYNC_REQUEST_W(__ssam_typec_ack, structstcm_ack_cmd, {
.target_category=SSAM_SSH_TC_USC,
.target_id=SSAM_SSH_TID_SAM,
.instance_id=0x01,
.command_id=0x03,
});
structsurface_typec_port {
structtypec_capabilitycap;
// struct device *dev;structtypec_partner*partner;
structtypec_port*port;
structtypec_altmode*dp_mode;
u8alt_mode;
};
structsurface_typec {
structssam_device*sdev;
structssam_event_notifiernotif;
structsurface_typec_portports[2];
};
staticu32surface_typec_notify(structssam_event_notifier*nf, conststructssam_event*event)
{
structsurface_typec*stcm;
structsurface_typec_port*port;
structstcm_event*evt;
structtypec_partner_descdesc= {};
enumtypec_data_roledata_role;
// int status;stcm=container_of(nf, structsurface_typec, notif);
dev_warn(&stcm->sdev->dev, "typec event (cid = %#04x, iid = %#04x, tid = %#04x) [%d]: %*ph\n",
event->command_id, event->instance_id, event->target_id, event->length, event->length, event->data);
if (event->length!=sizeof(structstcm_event)) {
dev_warn(&stcm->sdev->dev, "unexpected event length %d", event->length);
// return SSAM_NOTIF_HANDLED;
}
evt= (structstcm_event*)event->data;
if (evt->port_id >= ARRAY_SIZE(stcm->ports)) {
dev_err(&stcm->sdev->dev, "port %d out of range", evt->port_id);
returnSSAM_NOTIF_HANDLED;
}
port=&stcm->ports[evt->port_id];
if (!port->port) {
dev_warn(&stcm->sdev->dev, "received event for uninitialized port %d", evt->port_id);
returnSSAM_NOTIF_HANDLED;
}
if (port->alt_mode!=evt->alt_mode) {
if (port->partner) {
typec_unregister_partner(port->partner);
port->partner=NULL;
}
structtypec_displayport_datadp_data;
typec_set_data_role(port->port, TYPEC_HOST);
switch (evt->alt_mode) {
caseSTCM_MODE_NOTHING:
break;
caseSTCM_MODE_SS_DP:
caseSTCM_MODE_DP_ONLY:
dp_data.status=DP_STATUS_ENABLED;
if (evt->unknown2)
dp_data.status |= DP_STATUS_IRQ_HPD;
if (evt->dp_hpd)
dp_data.status |= DP_STATUS_HPD_STATE;
dp_data.conf=DP_CONF_SET_PIN_ASSIGN(BIT(evt->alt_mode==STCM_MODE_DP_ONLY ? DP_PIN_ASSIGN_C : DP_PIN_ASSIGN_D));
fallthrough;
default:
port->partner=typec_register_partner(port->port, &desc);
if (IS_ERR(port->partner)) {
dev_err(&stcm->sdev->dev, "failed to register partner: %ld\n",
PTR_ERR(port->partner));
port->partner=NULL;
}
// int ret = typec_mux_set(port->port->mux, &port->state);
}
}
typec_set_orientation(port->port, map_orientation(evt->cable_orientation));
returnSSAM_NOTIF_HANDLED;
}
staticintsurface_typec_probe(structssam_device*sdev)
{
structsurface_typec*stcm;
structdevice*ctrl_dev=ssam_controller_device(sdev->ctrl);
intret;
stcm=devm_kzalloc(&sdev->dev, sizeof(*stcm), GFP_KERNEL);
if (!stcm)
return-ENOMEM;
stcm->sdev=sdev;
stcm->notif.base.priority=1;
stcm->notif.base.fn=surface_typec_notify;
stcm->notif.event.reg=SSAM_EVENT_REGISTRY_SAM;
stcm->notif.event.id.target_category=SSAM_SSH_TC_USC;
stcm->notif.event.id.instance=0;
stcm->notif.event.mask=SSAM_EVENT_MASK_NONE;
stcm->notif.event.flags=SSAM_EVENT_SEQUENCED;
ssam_device_set_drvdata(sdev, stcm);
device_for_each_named_child_node_scoped(ctrl_dev, connector, "connector") {
structsurface_typec_port*port;
u32reg;
ret=fwnode_property_read_u32(connector, "reg", ®);
if (ret<0)
goto err_fwnode;
if (reg >= ARRAY_SIZE(stcm->ports)) {
dev_err(&sdev->dev, "connector port %d out of range\n", reg);
ret=EINVAL;
goto err_fwnode;
}
dev_err(&sdev->dev, "connector port %d..\n", reg);
port=&stcm->ports[reg];
ret=typec_get_fw_cap(&port->cap, connector);
if (ret)
goto err_fwnode;
port->cap.revision=USB_TYPEC_REV_1_2;
port->cap.orientation_aware= true;
port->cap.driver_data=stcm;
// port->cap.ops = ;port->port=typec_register_port(&sdev->dev, &port->cap);
if (IS_ERR(port->port)) {
ret=PTR_ERR(port->port);
port->port=NULL;
goto err_fwnode;
}
structtypec_altmode_descdesc= {
.svid=USB_TYPEC_DP_SID,
.mode=USB_TYPEC_DP_MODE,
.vdo=DP_CAP_DFP_D | DP_CAP_RECEPTACLE | DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D)), // E?
};
// port->dp_mode =if (IS_ERR(port->dp_mode)) {
ret=PTR_ERR(port->dp_mode);
port->dp_mode=NULL;
goto err_fwnode;
}
}
returnssam_device_notifier_register(stcm->sdev, &stcm->notif);
err_fwnode:
// TODO reuse for destruction, destroy altmodefor (inti=0; i<ARRAY_SIZE(stcm->ports); i++)
if (stcm->ports[i].port&& !IS_ERR(stcm->ports[i].port))
typec_unregister_port(stcm->ports[i].port);
kfree(stcm);
returnret;
}
staticconststructssam_device_idsurface_typec_match[] = {
{ SSAM_SDEV(USC, SAM, 0x00, 0x00) },
{ SSAM_SDEV(USC, SAM, 0x01, 0x00) },
{ },
};
MODULE_DEVICE_TABLE(ssam, surface_typec_match);
staticstructssam_device_driversurface_typec_driver= {
.probe=surface_typec_probe,
.match_table=surface_typec_match,
.driver= {
.name="surface_typec",
.probe_type=PROBE_PREFER_ASYNCHRONOUS,
},
};
module_ssam_device_driver(surface_typec_driver);
MODULE_AUTHOR("Val Packett <val@packett.cool>");
MODULE_DESCRIPTION("USB Type-C port driver for Surface System Aggregator Module");
MODULE_LICENSE("GPL");
Activity
gus33000 commentedon Jun 23, 2022
The
SurfaceUsbCMuxAcpiFilterDriver.sysfilter driver is designed to sit in the middle of ACPI.sys IOCTL events.In order to enable Display Port for Windows GPU driver normally the UCSI Driver from qualcomm notifies either via an interface or via an ACPI notify function the GPU device that a cable got inserted at this port number in this orientation. And it does so by getting notified from PmicGlink (missing on the Surface Pro X)
Given the Pro X doesn't make use of PmicGlink/BattMngr/PTCC in ADSP.mbn and instead uses SAM this is broken.
So the filter driver serves as getting notifications from SAM and then making qualcomm's driver react by notifying it of an pmicglink event (even though there's no pmicglink), so the GPU driver can setup display port output.
This is one of the functionality of that driver that I gathered, but I'm not sure if it does anything else.
qzed commentedon Jun 23, 2022
Thanks for your insights!
I've experimented a bit more with various USB devices, but I don't have a powerful enough USB-C charger here, so I probably can't look at power-delivery stuff properly.
Events have 11 bytes and start off with a sequence number. Also, if events are not ACKed, the last event repeats for up to a total of 5 events being sent for one action (all with the same sequence number, which is simply incremented for new events).
So far, I've gathered the following structure. I've tested the display-port part of this with the Surface USB-C hub and its HDMI output, so this might be a bit different for more/other display connections.
I guess the event payload might be different for different (sub-)types of events.
@gus33000 You wouldn't happen to know what data specifically needs to be sent via glink (and/or could fill in the gaps of the struct above) and to which specific endpoints? I assume the display-port controller (mdss-mdp) is one?
qzed commentedon Jun 23, 2022
The ACK command sent back to SAM seems to have the following properties: Target category 0x1b, target ID 0x01, instance ID 0x01, command ID 0x03. Multiple (re-)tries are attempted when the command fails.
The command payload is 12 bytes with the following structure
Interestingly, only the LSB of
unknown2seems to be set. So could be that the rest is just padding, but that's fairly unusual for SAM communication.[-]Support for SAM USB-C Power Delivery Events[/-][+]Support for SAM USB-C Events[/+]gus33000 commentedon Jun 27, 2022
Actually the filter doesn't send anything via Glink, the Surface Pro X does not provide the Pmic Glink interface at all (so no USB-C handled by ADSP, no battery management handled by ADSP). But due to how the Qualcomm GPU DirectX driver is built they needed to reuse that UCSI driver to make DisplayPort connections work.
I'm currently working on the same sort of thing for the Surface Duo.
The UCSI driver is able to make calls directly to the GPU driver to tell it, I detected a cable in DP AltMode with this pin assignment and this orientation, then the GPU driver enables the DisplayPort connection and sets up MDSS / DP PHY etc. It also tells the GPU driver which port was detected (this ultimately depends on the amount of EXTERNAL connections defined in ACPI for the GPU device)
The UCSI driver is basically a shim, listening to the
QcPmicGlink8180.sysdriver (not present on the Pro X), and that PmicGlink driver sends IOCTLs to the UCSI driver to notify it of changes.The role of that filter driver is to send IOCTLs to the UCSI driver when needed so it can tell the GPU driver a DP connection needs to be setup. (essentially re-implementing missing functionality due to the Qualcomm Pmic Glink stack not being present on this device)
Unfortunately I can't help much with SAM events as my device doesn't use them so I can't really complete the structure for you, but I do actually need to not use PmicGlink (just like on the Surface Pro X) because Android platforms of the time also did not have the USB-C/charging code in ADSP instead implementing it directly in the kernel/HLOS. Previous Qualcomm Windows Platforms (SDM845/Snapdragon 850) did not use PmicGlink either.
In a way it makes sense they would not use ADSP/PmicGlink here, they already have SAM for this.
From what I can see though you also have a Surface UCSI over HID driver (
SurfaceUcmUcsiHidClient.sys) that likely uses the same events the filter uses to notify the GPU driver, but for providing standard USB-C UCSI functionality (for the other ports), so I'm not saying it's only used for that purpose, just that PmicGlink is out of reach on the Surface Pro X.qzed commentedon Jun 27, 2022
Ah sorry, I misunderstood earlier then (I thought only the Glink endpoint for USB-C was not present). Thanks for clearing that up. @andersson is working on Display Ports for the Lenovo Flex 5G, which uses the same SC8180X SoC. That apparently uses Glink, so I can then hopefully see what needs to be replaced and gauge the remaining fields.
As far as I know, that driver is also present on a bunch of other x86 Surface devices as well. The respective device is some SAM-provided HID device, at least according to the Windows Device Manager. Unfortunately, I haven't been able to receive any input events from that, so I'm not sure whether it provides some (e.g. when devices are connected/disconnected), whether the command to enable events is wrong, or whether it just doesn't provide any. Also, the SPX doesn't have any other USB-C ports, so if it plays a similar role as the SAM notifications, it might not be used at all...
Here's the descriptor for that device: t1i0.c.txt. However, I'm not even sure if that's the right device since that reports an id of
045e:0922(whereas the .inf for the driver has045e:ff00and045e:f900?). But that's the only other HID device I've found via SAM. So could be that it's some virtual device.JValdivia23 commentedon Nov 2, 2026
Mystery solved — and I just opened an upstream driver PR for this in linux-surface/kernel#184 (companion config PR: linux-surface/linux-surface#2354 or see linked PR).
How
SurfaceUcmUcsiHidClient.sys/ Surface UCSI-over-HID WorksHID Matching (
HID\VID_045E&UP:FF00_U:F900):UP:FF00_U:F900inSurfaceUcmUcsiHidClient.infis the HID Application Collection Usage Page (0xFF00) and Usage (0xF900), not the USB/SSAM Product ID. That is why it appears under045E:0922on Surface Pro X and045E:09A6on Surface Book 3.VID:PID(for example, on Surface Book 3045E:09A6has two separate HID interfaces:0xFF00:0xF900for the UCSI PPM and0xFF0B:0x0101for Base CFU firmware updates). Assigning a dedicatedHID_GROUP_SURFACE_UCSIinhid_scan_collection()letsucsi_surface_hidbind exclusively to0xFF00:0xF900across all Surface models.HID Report Layout (109-byte descriptor):
0x32(49 bytes = 1-byte Report ID + 48-byte UCSI v1.x data structure):+0x00(u8): Report ID (0x32)+0x01(__le16):VERSION(note: uninitialized in SAM RAM prior to the firstUCSI_PPM_RESETafter cold boot — e.g.0x7628on SB3 — soread_version()must sanitize pre-reset values outside{0x0100, 0x0110, 0x0120}to0x0110)+0x03(__le16):RESERVED/ sequence (0)+0x05(__le32):CCI+0x09(__le64):CONTROL+0x11(u8[16]):MESSAGE_IN+0x21(u8[16]):MESSAGE_OUT0x32: Asynchronous notification emitted by SAM wheneverCCIchanges — but SAM stays completely silent until initialized viaSET_REPORT(Feature 0x32)withUCSI_PPM_RESET(0x01) followed byUCSI_SET_NOTIFICATION_ENABLE(0x05), which explains why rawhidrawreads showed no traffic earlier.0x33(3 bytes):[0x33, num_connectors, udc_supported](e.g.connectors=1, udc_supported=0on Surface Book 3).Tested live on Surface Book 3 (
7.3.0,/sys/class/typec/port0Type-C 1.3 / USB PD 3.0 +ucsi-source-psy-*); testing on Surface Pro X (045E:0922) would be very welcome!qzed commentedon Nov 2, 2026
Finally got around to looking at this again, together with the UCSI-over-HID driver from linux-surface/kernel#184. Summary of what we now know about USB-C on the Surface Pro X:
Overview
There are two separate SAM interfaces for the two USB-C ports, mirroring what Qualcomm does with
pmic_glink_altmode+ucsi_glinkon other SC8180X/SC8280XP devices:0x1b)0x15)SurfaceUsbCMuxAcpiFilterDriverSurfaceUcmUcsiHidClientThe two are coupled: the PPM only reflects the actual port state once the host handles (enables and ACKs) the USC events. Without that,
GET_CONNECTOR_STATUSreports both connectors as disconnected, regardless of what's plugged in. This is presumably why I never got anything useful out of the HID device back then.USC events
TC 0x01, TID 0x01, CID 0x0b/0x0c), target category0x1b, instance ID0x01.TC 0x1b, TID 0x01, CID 0x02, IID 0x00, 11-byte payload:TC 0x1b, TID 0x01, IID 0x01, CID 0x03, 12-byte payload{ __le32 seq; __le32 port; __le32 flag; }. Without an ACK, SAM re-sends the last event per port every 2 s, five times in total, and only then updates the UCSI PPM (i.e. a ~10 s delay). The flag (Windows: LSB of the result ofPdEventInfoUpdateFromSamToSoc) has no visible effect: both 0 and 1 stop the re-sends, and the PPM updates immediately either way.type=3instead oftype=1. HPD (dp_hpd) sometimes comes in the same event, sometimes as a secondtype=3event ~220 ms later. Thedp_modevalue depends on the orientation (0x04/0x0a); its exact meaning is still unclear (0x04would match pin assignment C,0x0adoesn't fit that scheme). A DP+USB hub (pin assignment D) would help to figure this out.Side note: Currently, SuperSpeed only works in one orientation on Linux (flipped = USB 2 only), because nothing tells the QMP PHY about the orientation. A driver for these events would fix that via
typec_switch_set().UCSI over HID
045E:0922at SSAM01:15:01:00:00(TID 1, IID 0). This is the only HID instance on TID 1 (probed IIDs 0x00–0x1f); thet1i0dump above was correct. Windows lists it asTarget_SAM&Category_HID … SID_DEVICE_01, Location 1. It's not part of the SPX registry group yet.SSAM_EVENT_REGISTRY_REG(1), whatsurface_hidcurrently uses) never responds, sohid_hw_start()times out. Without any enable, SAM sends the input reports with RQID 0 and they get dropped (rtl: dropping unexpected command message (rqid = 0x0000)). Note: enables persist across our disable (and seemingly some reboots), so test from a fresh boot.GET_CABLE_PROPERTY) are answered with onlyNOT_SUPPORTEDset, withoutCOMMAND_COMPLETE;GET_ALTERNATE_MODESresponses have an extra leading byte;VERSIONfield is garbage on every read;RESET_COMPLETEis often still set after boot.What's needed
01:15:01:00:00) and the USC events.surface_hid: support selecting the SAM event registry per device.ucsi_surface_hid(kernel#184) with the quirks above.pmic_glink_altmode), plus the DT connector graph (QMP PHYs, dwc3,mdss_dp0/1).Also confirmed working on the SPX (kernel#184):
input_power_limitfrom SAMArtg(60 W charger →60000000µW).valpackett commentedon Nov 2, 2026
Hi, I've been experimenting with this, can't believe I haven't written anything in the thread earlier.
These are actually:
Very early WIP does not work yet driver
usb: typec: ucsi: Add Microsoft Surface HID transport driver
valpackett commentedon Nov 16, 2026
Got it to a working state now!