fix(libSceVideoOut): check the output mode calls' arguments as firmware 13.42 does #19293

Merged
zaryabzip merged 2 commits from upstream-pr/19293 into main 2026-11-13 20:55:49 +00:00
zaryabzip commented 2026-11-13 02:03:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-11-13T02:03:43Z.


What

sceVideoOutGetDeviceInfoEx_ and sceVideoOutConfigureOutputMode_ now take their firmware arguments and make the checks firmware 13.42 makes before it hands off. They throw NotImplemented only where the part nobody has read begins. Before this, both threw for any call.

Source. @BunnyFl's reading of libSceVideoOut.sprx on #15134 (comment). It came from disassembly; nothing was run on a console. The issue asked for exactly this: local checks and argument lists in place of the placeholders, even where the rest stays unsupported.

sceVideoOutGetDeviceInfoEx_(handle, reserved, info, size) (entry 0x161d0), in order:

  1. size other than 0x18: 0x80290001, before the handle.
  2. Handle lookup: no port gives 0x8029000b (HasConfig then IsOpen, as in Output.cpp).
  3. reserved not null: 0x80290001.
  4. info null: 0x80290002.
  5. The firmware then fills the record from an import with no known name (0BKuKlQG8zE). Here it throws.

sceVideoOutConfigureOutputMode_(handle, reserved, mode, forwarded, unused, size) (entry 0x156c0, routine 0x15760), in order:

  1. A null mode, a non-zero reserved or a size other than 0x10 gives 0x80290001, before the handle.
  2. Handle lookup: no port gives 0x8029000b.
  3. The device's bus must be 0 or 0x200, else 0x8029001b. A main-bus port goes on; any other port throws, because how the open's bus type maps to the device's is unknown.
  4. If a module global is set and the mode's +0x10 is 0xffffffff21ffffff with +8 13, 16 or 18, the firmware returns 0x80290019. That global isn't known, so this combination throws.
  5. The validator's first check: the mode's first word must be 0x20, else 0x80290016 (UNSUPPORTED_OUTPUT_MODE). The rest of the validator wasn't read, so a valid record throws.

Not modelled: the handle lookup's 0x8029001b for a port record whose +0x10 is non-zero. Nothing here sets that state, so it is never returned.

Change (InventoryExports.cpp and its header). The two placeholders get these signatures and checks. The forwarded argument is handed to the unread validator in firmware, and unused is never read there either.

Debt (libSceVideoOut.md). The two names leave the inventory table. One Unknown-function-info entry records what still throws and why, and the unmodelled 0x8029001b.

Test (GuestVideoOutOutputModeChecks.cpp, ctest guest_video_out_output_mode_checks).

  • Without a display: the five checks that fail before the handle lookup (wrong size, short size with other bad arguments, null mode, non-zero reserved, wrong size for ConfigureOutputMode_). If the port can't open, the test then skips with 77, like guest_video_out_hdr.
  • With an open main-bus port:
    • a port that isn't open gives 0x8029000b, before the other arguments;
    • a non-null reserved gives 0x80290001, before a null info;
    • a null info gives 0x80290002;
    • mode records whose first word is 0x1f or 0 give 0x80290016;
    • after sceVideoOutClose, the port gives 0x8029000b.

Tested

  • macOS host (arm64): the two functions were extracted verbatim into a harness whose driver throws if touched. The five display-free rows pass, so they return before the handle lookup, as in firmware.
  • Windows, by JJenkx at 919f7e6624 merged onto main a6606d5bab (comment). Windows 11 Enterprise 22621, AMD RX 6700 XT (driver 26.10.1), MinGW-w64 GCC 15.2 UCRT, Release.
    • Without a display, the test skips after the five display-free rows, 3 of 3.
    • With a display it aborted 3 of 3 at the first not-open row, on VideoOut: invalid output handle: IsOpen throws for a handle that isn't open.
    • 84e5aa6fb4 checks HasConfig first in both calls, as Output.cpp does (review).
  • Windows with a display, by my test session at 84e5aa6fb4 (tree 2856af864d) on main 8ab1200bc2. The 261 later main commits up to 96b9b4cd64 don't touch InventoryExports.*, and the head merges cleanly with that main.
    • Windows 11 Home 25H2 (26200.9974), RTX 3060 Laptop, WinLibs GCC 15.2.0 r7 UCRT, CMake 4.3.1, Ninja 1.13.2, Release, BUILD_TESTING=ON.
    • With ANYPS5_REQUIRE_DISPLAY=1, guest_video_out_output_mode_checks passes 3 of 3, not skipped. The open-port rows ran, including the handle + 1 rows.
    • guest_video_out_firmware_answers and guest_video_out_hdr pass.
    • Control: with main's InventoryExports.cpp (its two stubs given this PR's parameter lists so it compiles), the test aborts 2 of 2 at its first row (GuestVideoOutOutputModeChecks.cpp:41), sceVideoOutGetDeviceInfoEx_ not implemented.
    • No warnings in the changed files.
  • Hosted CI: has no display, so it skips after the display-free rows and can't show the open-port rows.

tools/check_conventions.py --base main passes. git merge-tree finds no conflict with main 8e7cb8f17c or with any open PR that merges with main. The test's CMake block sits before guest_video_out_firmware_answers, clear of #18919's block after it.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none (the checks of two of the exports in #15134)
  • Unblocks: none
  • GPUs tested: NVIDIA RTX 3060 Laptop, Windows 11 25H2 (my run); AMD RX 6700 XT, driver 26.10.1, Windows 11 22621 (JJenkx, before the fix). Only the new test and two neighbours ran, not the GPU suite
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5288646882 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19293). Originally posted by [zaryabzip](https://github.com/zaryabzip) on 2026-11-13T02:03:43Z. --- ### What `sceVideoOutGetDeviceInfoEx_` and `sceVideoOutConfigureOutputMode_` now take their firmware arguments and make the checks firmware 13.42 makes before it hands off. They throw `NotImplemented` only where the part nobody has read begins. Before this, both threw for any call. **Source.** @BunnyFl's reading of `libSceVideoOut.sprx` on #15134 ([comment](https://github.com/boykopovar/AnyPS5/issues/15134#issuecomment-6755215803)). It came from disassembly; nothing was run on a console. The issue asked for exactly this: local checks and argument lists in place of the placeholders, even where the rest stays unsupported. **`sceVideoOutGetDeviceInfoEx_(handle, reserved, info, size)`** (entry `0x161d0`), in order: 1. `size` other than 0x18: `0x80290001`, before the handle. 2. Handle lookup: no port gives `0x8029000b` (`HasConfig` then `IsOpen`, as in `Output.cpp`). 3. `reserved` not null: `0x80290001`. 4. `info` null: `0x80290002`. 5. The firmware then fills the record from an import with no known name (`0BKuKlQG8zE`). Here it throws. **`sceVideoOutConfigureOutputMode_(handle, reserved, mode, forwarded, unused, size)`** (entry `0x156c0`, routine `0x15760`), in order: 1. A null `mode`, a non-zero `reserved` or a `size` other than 0x10 gives `0x80290001`, before the handle. 2. Handle lookup: no port gives `0x8029000b`. 3. The device's bus must be 0 or 0x200, else `0x8029001b`. A main-bus port goes on; any other port throws, because how the open's bus type maps to the device's is unknown. 4. If a module global is set and the mode's `+0x10` is `0xffffffff21ffffff` with `+8` 13, 16 or 18, the firmware returns `0x80290019`. That global isn't known, so this combination throws. 5. The validator's first check: the mode's first word must be 0x20, else `0x80290016` (`UNSUPPORTED_OUTPUT_MODE`). The rest of the validator wasn't read, so a valid record throws. Not modelled: the handle lookup's `0x8029001b` for a port record whose `+0x10` is non-zero. Nothing here sets that state, so it is never returned. **Change** (`InventoryExports.cpp` and its header). The two placeholders get these signatures and checks. The `forwarded` argument is handed to the unread validator in firmware, and `unused` is never read there either. **Debt** (`libSceVideoOut.md`). The two names leave the inventory table. One Unknown-function-info entry records what still throws and why, and the unmodelled `0x8029001b`. **Test** (`GuestVideoOutOutputModeChecks.cpp`, ctest `guest_video_out_output_mode_checks`). - Without a display: the five checks that fail before the handle lookup (wrong size, short size with other bad arguments, null mode, non-zero `reserved`, wrong size for `ConfigureOutputMode_`). If the port can't open, the test then skips with 77, like `guest_video_out_hdr`. - With an open main-bus port: - a port that isn't open gives `0x8029000b`, before the other arguments; - a non-null `reserved` gives `0x80290001`, before a null `info`; - a null `info` gives `0x80290002`; - mode records whose first word is 0x1f or 0 give `0x80290016`; - after `sceVideoOutClose`, the port gives `0x8029000b`. ### Tested - **macOS host (arm64)**: the two functions were extracted verbatim into a harness whose driver throws if touched. The five display-free rows pass, so they return before the handle lookup, as in firmware. - **Windows, by JJenkx** at `919f7e6624` merged onto `main` `a6606d5bab` ([comment](https://github.com/boykopovar/AnyPS5/pull/19293#issuecomment-6842707813)). Windows 11 Enterprise 22621, AMD RX 6700 XT (driver 26.10.1), MinGW-w64 GCC 15.2 UCRT, Release. - Without a display, the test skips after the five display-free rows, 3 of 3. - With a display it aborted 3 of 3 at the first not-open row, on `VideoOut: invalid output handle`: `IsOpen` throws for a handle that isn't open. - `84e5aa6fb4` checks `HasConfig` first in both calls, as `Output.cpp` does ([review](https://github.com/boykopovar/AnyPS5/pull/19293#issuecomment-6841904374)). - **Windows with a display, by my test session** at `84e5aa6fb4` (tree `2856af864d`) on `main` `8ab1200bc2`. The 261 later `main` commits up to `96b9b4cd64` don't touch `InventoryExports.*`, and the head merges cleanly with that `main`. - Windows 11 Home 25H2 (26200.9974), RTX 3060 Laptop, WinLibs GCC 15.2.0 r7 UCRT, CMake 4.3.1, Ninja 1.13.2, Release, `BUILD_TESTING=ON`. - With `ANYPS5_REQUIRE_DISPLAY=1`, `guest_video_out_output_mode_checks` passes 3 of 3, not skipped. The open-port rows ran, including the `handle + 1` rows. - `guest_video_out_firmware_answers` and `guest_video_out_hdr` pass. - Control: with `main`'s `InventoryExports.cpp` (its two stubs given this PR's parameter lists so it compiles), the test aborts 2 of 2 at its first row (`GuestVideoOutOutputModeChecks.cpp:41`), `sceVideoOutGetDeviceInfoEx_ not implemented`. - No warnings in the changed files. - **Hosted CI**: has no display, so it skips after the display-free rows and can't show the open-port rows. `tools/check_conventions.py --base main` passes. `git merge-tree` finds no conflict with `main` `8e7cb8f17c` or with any open PR that merges with `main`. The test's CMake block sits before `guest_video_out_firmware_answers`, clear of #18919's block after it. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none (the checks of two of the exports in #15134) - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> NVIDIA RTX 3060 Laptop, Windows 11 25H2 (my run); AMD RX 6700 XT, driver 26.10.1, Windows 11 22621 (JJenkx, before the fix). Only the new test and two neighbours ran, not the GPU suite - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!19293
No description provided.