Skip to content

Add types for Discover Identity structured VDMs#64

Merged
asasine merged 26 commits into
OpenDevicePartnership:mainfrom
asasine:discover-identity
Apr 28, 2026
Merged

Add types for Discover Identity structured VDMs#64
asasine merged 26 commits into
OpenDevicePartnership:mainfrom
asasine:discover-identity

Conversation

@asasine
Copy link
Copy Markdown
Contributor

@asasine asasine commented Apr 23, 2026

The module hierarchy reflects the PD spec. Each VDO exposes a raw and parsed form, useful for callers to inspect malformed values when deserializing. The parsed types are for deserialization only.

Copilot AI review requested due to automatic review settings April 23, 2026 22:19
@asasine asasine requested a review from a team as a code owner April 23, 2026 22:19
@asasine asasine requested review from RobertZ2011 and gjpmsft April 23, 2026 22:19
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

This PR introduces a new vdm::structured module implementing USB-PD Structured VDM parsing types, with an emphasis on Discover Identity response VDOs (SOP and SOP′) that expose both raw and parsed forms.

Changes:

  • Added vdm::structured module with Svid and a Structured VDM Header parser.
  • Added structured Discover Identity response/VDO types (ID Header, Product, cable/VPD, UFP/DFP).
  • Updated UCSI GET_ALTERNATE_MODES to import Svid from the new module.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/vdm/structured/svid.rs Adds Svid newtype and common SVID constants.
src/vdm/structured/mod.rs Defines structured module layout and re-exports.
src/vdm/structured/header.rs Adds Structured VDM header parsing types and tests.
src/vdm/structured/command/mod.rs Introduces structured VDM command namespace.
src/vdm/structured/command/discover_identity/mod.rs Defines Discover Identity module and shared VDO newtypes.
src/vdm/structured/command/discover_identity/product_vdo.rs Adds ProductVdo bitfield parsing.
src/vdm/structured/command/discover_identity/dfp_vdo.rs Adds DfpVdo parsing.
src/vdm/structured/command/discover_identity/ufp_vdo.rs Adds UfpVdo parsing and enums.
src/vdm/structured/command/discover_identity/vpd_vdo.rs Adds VpdVdo parsing and enums.
src/vdm/structured/command/discover_identity/passive_cable_vdo.rs Adds Passive Cable VDO parsing and enums.
src/vdm/structured/command/discover_identity/active_cable_vdo.rs Adds Active Cable VDO1/VDO2 parsing and enums.
src/vdm/structured/command/discover_identity/sop/mod.rs Adds SOP Discover Identity ResponseVdos container.
src/vdm/structured/command/discover_identity/sop/id_header_vdo.rs Adds SOP ID Header VDO parsing and product-type enums.
src/vdm/structured/command/discover_identity/sop_prime/mod.rs Adds SOP′ Discover Identity ResponseVdos container.
src/vdm/structured/command/discover_identity/sop_prime/id_header_vdo.rs Adds SOP′ ID Header VDO parsing and product-type enum.
src/vdm/mod.rs Adds structured submodule and removes top-level Svid type.
src/ucsi/lpm/get_alternate_modes.rs Updates imports to use vdm::structured::Svid.
Comments suppressed due to low confidence (2)

src/vdm/mod.rs:3

  • Typo in module docs: PD spect should be PD spec.
    src/vdm/mod.rs:6
  • Svid was previously exported as crate::vdm::Svid, but is now only available as crate::vdm::structured::Svid. If this crate is consumed externally, this is a breaking public-API change; consider adding a pub use structured::Svid re-export (or otherwise documenting/bumping the version accordingly).

Comment thread src/vdm/structured/command/discover_identity/sop/id_header_vdo.rs
Comment thread src/vdm/structured/command/discover_identity/sop_prime/id_header_vdo.rs Outdated
Comment thread src/vdm/structured/command/discover_identity/sop/mod.rs Outdated
Comment thread src/vdm/structured/command/discover_identity/sop_prime/mod.rs Outdated
Comment thread src/vdm/structured/command/discover_identity/mod.rs Outdated
Comment thread src/vdm/structured/header.rs Outdated
Comment thread src/vdm/structured/header.rs Outdated
asasine added 2 commits April 23, 2026 16:04
Callers can now use the Product Type VDO enums to fully inspect the type without having to perform additional parsing
RobertZ2011
RobertZ2011 previously approved these changes Apr 24, 2026
Comment thread src/vdm/svid.rs Outdated
Comment thread src/vdm/structured/command/discover_identity/mod.rs Outdated
Comment thread src/vdm/structured/command/discover_identity/sop/mod.rs
Comment thread src/vdm/structured/command/discover_identity/sop_prime/mod.rs
Comment thread src/vdm/structured/header.rs Outdated
@RobertZ2011
Copy link
Copy Markdown
Contributor

Overall looks good, nothing major.

but I'm leaning to fully parsed version with the value-converting method and the two ID Header VDO types, as it makes using these types easiest in calling code, and that's what all of this is about anyways, right? :)

I think this is the best approach.

@RobertZ2011 RobertZ2011 requested review from jerrysxie and tullom April 24, 2026 18:07
@RobertZ2011 RobertZ2011 added the enhancement New feature or request label Apr 24, 2026
RobertZ2011
RobertZ2011 previously approved these changes Apr 24, 2026
Comment thread src/usb.rs Outdated
Comment thread src/vdm/structured/command/discover_identity/dfp_vdo.rs
Comment thread src/vdm/structured/header.rs
Comment thread src/vdm/structured/command/discover_identity/vpd_vdo.rs
Comment thread src/vdm/structured/header.rs
Comment thread src/usb.rs
Comment thread src/vdm/structured/command/discover_identity/product_vdo.rs
@asasine asasine enabled auto-merge (squash) April 27, 2026 18:34
@asasine asasine merged commit 21d0e22 into OpenDevicePartnership:main Apr 28, 2026
10 checks passed
@asasine asasine deleted the discover-identity branch April 28, 2026 15:48
RobertZ2011 pushed a commit to OpenDevicePartnership/tps6699x that referenced this pull request Apr 29, 2026
…ntity Data, executing Hard Reset (#104)

Builds on OpenDevicePartnership/embedded-usb-pd#64

---------

Co-authored-by: Copilot <copilot@github.com>
jerrysxie pushed a commit to jerrysxie/tps6699x that referenced this pull request May 4, 2026
…ntity Data, executing Hard Reset (OpenDevicePartnership#104)

Builds on OpenDevicePartnership/embedded-usb-pd#64

---------

Co-authored-by: Copilot <copilot@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BREAKING CHANGE enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants