Skip to content

fw: wire USB HID power commands to power_suspend and add PTN3460 safeguards - #16

Open
genneth wants to merge 1 commit into
Modos-Labs:mainfrom
genneth:feat/hid-power-control
Open

fw: wire USB HID power commands to power_suspend and add PTN3460 safeguards#16
genneth wants to merge 1 commit into
Modos-Labs:mainfrom
genneth:feat/hid-power-control

Conversation

@genneth

@genneth genneth commented Jul 21, 2026

Copy link
Copy Markdown

This PR completes the stubbed USB HID power control commands (USBCMD_POWERDOWN and USBCMD_POWERUP) in fw/User/usbapp.c by wiring them to the new power_suspend(POWER_SUSPEND_USER) and power_request_resume(POWER_WAKE_USB) APIs.

It also adds two DisplayPort bridge (PTN3460) safeguards:

  1. Bootloader delay: Adds 50ms delay in ptn3460_early_init() to allow the chip's internal bootloader to finish powering up before receiving I2C writes.
  2. Loop timeout break: Adds break; inside the HPD boot timeout condition in ptn3460_init() to prevent an infinite loop if HPD fails to assert.

Replaces #15.

UavL added a commit to UavL/Glider that referenced this pull request Aug 2, 2026
Cherry-picked from the ptn3460.c portion of upstream PR Modos-Labs#16
(Modos-Labs#16, genneth:feat/hid-power-control, commit ced3fa1
"fw: hook USB HID power commands to power_suspend and add PTN3460
safeguards").

Two independent fixes:
- ptn3460_init() logged "PTN3460 boot timeout" after 500 ticks but kept
  looping forever, so a PTN3460 that never raises DP_HPD hangs ui_task
  before the display pipeline ever starts. Break out instead.
- ptn3460_early_init() drove DP_PDN high and immediately returned; give
  the part 50 ms to come out of power-down before the first I2C access.

The usbapp.c portion of PR Modos-Labs#16 is deliberately NOT taken: this tree
already wires USBCMD_POWERDOWN/USBCMD_POWERUP through
power_post_request(), which defers the work to ui_task. PR Modos-Labs#16 instead
calls power_suspend() directly from the TinyUSB HID set_report callback,
which would race ui_task's FPGA CSR polling.

Not compile-verified: no arm-none-eabi toolchain in this environment.
UavL added a commit to UavL/Glider that referenced this pull request Aug 2, 2026
…riage

Static analysis of the video-loss path, power/suspend state machine, and
upstream PRs Modos-Labs#16 and Modos-Labs#17, plus an ordered hardware test plan.

No hardware was observed; every claim is labelled code-derived, inferred,
estimated, or needing a test.
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.

1 participant