type-c-service: Migrate to per-port events#775
Open
RobertZ2011 wants to merge 2 commits intoOpenDevicePartnership:v0.2.0from
Open
type-c-service: Migrate to per-port events#775RobertZ2011 wants to merge 2 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011 wants to merge 2 commits intoOpenDevicePartnership:v0.2.0from
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors Type-C event delivery from a “pending-port bitfield + per-port polling” model to a per-port push/event-stream model, along with renaming/cleanup of port event types and removal of related legacy APIs.
Changes:
- Introduces per-port event delivery to the service via
Context::send_port_event()and per-port channels (PortRegistration). - Renames/splits port event types (
PortEventBitfield,PortStatusEventBitfield,PortNotificationEventBitfield,VdmData) and removes the old pending-bitvec mechanism (PortPending,Cached, ClearEvents/GetPdAlert commands). - Updates wrapper/service/event loops and examples to use the new push-based event path; removes
bitvecdependency.
Reviewed changes
Copilot reviewed 18 out of 27 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| type-c-service/src/wrapper/vdm.rs | Converts VDM finalization to send per-port service events (PortEventData::Vdm). |
| type-c-service/src/wrapper/power.rs | Simplifies PortState generic usage (lifetime removal). |
| type-c-service/src/wrapper/pd.rs | Removes legacy port-status/events/PD-alert pull commands from wrapper PD command processing. |
| type-c-service/src/wrapper/mod.rs | Switches wrapper event loop to produce unified LocalPortEvent and send service events directly. |
| type-c-service/src/wrapper/message.rs | Replaces separate status/notification wrapper events with a single LocalPortEvent. |
| type-c-service/src/wrapper/backing.rs | Removes pending-events + PD-alert buffering; stores PortRegistration per port. |
| type-c-service/src/task.rs | Adapts task loop to EventReceiver::wait_next() being infallible. |
| type-c-service/src/service/ucsi.rs | Updates UCSI handling to the renamed status-event bitfield type. |
| type-c-service/src/service/pd.rs | Removes PD alert pull API surface from the service layer. |
| type-c-service/src/service/mod.rs | Replaces bitfield polling with select_slice over per-port receivers and handles PortEvent. |
| type-c-service/src/lib.rs | Generalizes PortEventStreamer over an iterator and updates tests for renamed event types. |
| type-c-service/src/driver/tps6699x.rs | Updates driver event storage/clearing to use PortEventBitfield. |
| type-c-interface/src/service/event.rs | Adds service-level PortEvent / PortEventData to carry pushed per-port events. |
| type-c-interface/src/service/context.rs | Removes pending-port signaling APIs and adds send_port_event; exposes controller list. |
| type-c-interface/src/port/mod.rs | Introduces PortRegistration (per-port sender/receiver) and removes legacy commands/types. |
| type-c-interface/src/port/event.rs | Renames/refactors event bitfields and introduces VdmData + unified PortEvent enum. |
| type-c-interface/Cargo.toml | Drops bitvec dependency. |
| examples/std/src/lib/type_c/mock_controller.rs | Updates mock controller to use PortEventBitfield. |
| examples/std/src/bin/type_c/unconstrained.rs | Wires per-port channels and PortRegistration into storage initialization. |
| examples/std/src/bin/type_c/ucsi.rs | Wires per-port channels and PortRegistration into storage initialization. |
| examples/std/src/bin/type_c/service.rs | Wires per-port channels and PortRegistration into storage initialization. |
| examples/std/src/bin/type_c/basic.rs | Updates basic example to register Device with PortRegistration + per-port channels. |
| examples/std/Cargo.lock | Removes bitvec from lockfile via dependency cleanup. |
| examples/rt685s-evk/src/bin/type_c.rs | Wires per-port channels and PortRegistration into embedded example storage init. |
| examples/rt685s-evk/src/bin/type_c_cfu.rs | Wires per-port channels and PortRegistration into embedded CFU example storage init. |
| examples/rt685s-evk/Cargo.lock | Removes bitvec from lockfile via dependency cleanup. |
| Cargo.lock | Removes bitvec from workspace lockfile via dependency cleanup. |
Currently, events are signaled to the service through a bitvec representing which ports have pending events. The service then reads pending events from each port. Refactor to a design where each port pushes events to the service instead. Also do some renaming and clean-up of event types.
8065ddb to
ed2648e
Compare
kurtjd
previously approved these changes
Apr 3, 2026
kurtjd
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, events are signaled to the service through a bitvec representing which ports have pending events. The service then reads pending events from each port. Refactor to a design where each port pushes events to the service instead. Also do some renaming and clean-up of event types.