Skip to content

hidi2c: fix command protocol - #955

Merged
williampMSFT merged 4 commits into
OpenDevicePartnership:mainfrom
williampMSFT:user/williamp/hidi2c-bugfix
Sep 4, 2026
Merged

hidi2c: fix command protocol#955
williampMSFT merged 4 commits into
OpenDevicePartnership:mainfrom
williampMSFT:user/williamp/hidi2c-bugfix

Conversation

@williampMSFT

Copy link
Copy Markdown
Collaborator

This change fixes two bugs in the HID-I2C command protocol:

  1. In the GET_REPORT path, we weren't listening for a read request before responding with the report payload. On some HALs, this causes the bytes you write to be dropped and never get transmitted over the bus.
  2. In the SET_REPORT path, when not using implicit report IDs, the host actually writes the report ID twice; once in the command register and again in the data register. We were not accounting for the second write as the first byte in the data register.

This change fixes two bugs in the HID-I2C command protocol:
1. In the GET_REPORT path, we weren't listening for a read request before responding with the report payload.
   On some HALs, this causes the bytes you write to be dropped and never get transmitted over the bus.
2. In the SET_REPORT path, when not using implicit report IDs, the host actually writes the report ID twice;
   once in the command register and again in the data register. We were not accounting for the second write as
   the first byte in the data register.
@williampMSFT
williampMSFT marked this pull request as ready for review September 4, 2026 20:19
@williampMSFT
williampMSFT requested a review from a team as a code owner September 4, 2026 20:19
@williampMSFT
williampMSFT requested review from RobertZ2011, felipebalbi, kurtjd and tullom and a lite review from Copilot September 4, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new GET_REPORT pre-listen does not validate that the next bus event is actually a read request, which can lead to incorrect behavior/timeouts on unexpected request types.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes HID-I2C command protocol handling in the target service to better match host/HAL transaction ordering and report payload formatting requirements.

Changes:

  • GET_REPORT: wait for a controller read request before attempting to respond with the report payload.
  • SET_REPORT: when report IDs are not implicit, skip the duplicated report ID byte present in the data-register payload.
File summaries
File Description
hidi2c-target-service/src/service.rs Adjusts GET_REPORT response sequencing and SET_REPORT payload parsing to match HID-I2C command protocol expectations.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread hidi2c-target-service/src/service.rs Outdated
kurtjd
kurtjd previously approved these changes Sep 4, 2026
@williampMSFT
williampMSFT merged commit 95f81fb into OpenDevicePartnership:main Sep 4, 2026
15 of 16 checks passed
@williampMSFT
williampMSFT deleted the user/williamp/hidi2c-bugfix branch September 4, 2026 20:35
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.

4 participants