Skip to content

type-c-service: Migrate to per-port events#775

Open
RobertZ2011 wants to merge 2 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011:type-c-per-port-events
Open

type-c-service: Migrate to per-port events#775
RobertZ2011 wants to merge 2 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011:type-c-per-port-events

Conversation

@RobertZ2011
Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings April 2, 2026 23:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 bitvec dependency.

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.
@RobertZ2011 RobertZ2011 force-pushed the type-c-per-port-events branch from 8065ddb to ed2648e Compare April 2, 2026 23:41
@RobertZ2011 RobertZ2011 self-assigned this Apr 2, 2026
@RobertZ2011 RobertZ2011 marked this pull request as ready for review April 2, 2026 23:46
@RobertZ2011 RobertZ2011 requested review from a team as code owners April 2, 2026 23:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 27 changed files in this pull request and generated 2 comments.

kurtjd
kurtjd previously approved these changes Apr 3, 2026
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

Successfully merging this pull request may close these issues.

3 participants