fix(videoout): read the open param as the service thread's priority and affinity #297

Merged
oneandonlydean merged 1 commit from upstream-pr/297 into main 2026-10-03 06:46:26 +00:00
oneandonlydean commented 2026-10-01 23:15:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-01T23:15:54Z.


What

Follow-up to #128, which guessed wrong on two points. The first word of the sceVideoOutOpen param is not its size, and PPSA21564 does not pass a zeroed param. Its main port is opened with:

Offset Value Meaning
+0 16 unknown
+4 1 set priority
+8 0x100 priority
+12 1 set affinity
+16 0x1FFF (u64) CPU affinity mask
+24..+88 0 unknown

It also calls sceVideoOutOpen(0xff, 0, 0, NULL) once. On main the open with this param throws param options not implemented, so PPSA21564 cannot open its video port and fails at startup.

The layout matches shadPS4's ServiceThreadParams (src/core/libraries/videoout/driver.h: unknown, set_priority, priority, set_affinity, affinity), i.e. the scheduling settings of libSceVideoOut's service thread. The call site in PPSA21564 agrees: it zeroes the stack block, stores the first 16 bytes from a constant (16, 1, 0x100, 1) and then movq $0x1fff at offset 16 before the call. 256..767 is the thread priority range (256 highest), and 0x1FFF covers the 13 CPUs available to a title.

Changes:

  • VideoOutOpenParam describes the five fields; VIDEO_OUT_OPEN_PARAM_SIZE becomes VIDEO_OUT_OPEN_PARAM_FIRST_WORD.
  • validateOpenParam throws for a first word other than 16, a flag other than 0 or 1, a priority outside 256..767 when its flag is set, and an affinity mask that is 0 or has bits outside 0x1FFF when its flag is set. It reads the u64 at offset 16 only when the affinity flag is set, so a 16-byte param with both flags clear is still read in bounds.
  • TechnicalDebt: the priority and affinity are validated but not applied (the port's present and vblank threads are host threads), listed under silent stubs. The first word and whether the param continues past offset 24 are listed under unknown function info.

Tested

  • Linux (CachyOS, GCC). video_out_flip_tests controls (not part of ctest) gains testOpenParam: eight invalid params throw (first word 24, a priority flag of 2, an affinity flag of 0x101, priority 255 and 768, affinity 0, 0x2000 and a bit above 32), and a 16-byte param with both flags clear, a priority of 767 and an affinity of 1 open a port. The controls themselves now run on a port opened with PPSA21564's exact 88-byte param. On main the test fails at the first valid param (param options not implemented).
  • ctest: 105/105 pass.
  • PPSA21564 on my integration branch: with this change it starts, and my visual regression check (from the intro video through the title and save menu into gameplay; checkpoint frames, flicker, video tearing and FPS) passes twice in a row.

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 in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4710737443 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/297). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-01T23:15:54Z. --- ### What Follow-up to #128, which guessed wrong on two points. The first word of the `sceVideoOutOpen` param is not its size, and PPSA21564 does not pass a zeroed param. Its main port is opened with: | Offset | Value | Meaning | |---|---|---| | +0 | 16 | unknown | | +4 | 1 | set priority | | +8 | 0x100 | priority | | +12 | 1 | set affinity | | +16 | 0x1FFF (u64) | CPU affinity mask | | +24..+88 | 0 | unknown | It also calls `sceVideoOutOpen(0xff, 0, 0, NULL)` once. On main the open with this param throws `param options not implemented`, so PPSA21564 cannot open its video port and fails at startup. The layout matches shadPS4's `ServiceThreadParams` (`src/core/libraries/videoout/driver.h`: `unknown`, `set_priority`, `priority`, `set_affinity`, `affinity`), i.e. the scheduling settings of libSceVideoOut's service thread. The call site in PPSA21564 agrees: it zeroes the stack block, stores the first 16 bytes from a constant (16, 1, 0x100, 1) and then `movq $0x1fff` at offset 16 before the call. 256..767 is the thread priority range (256 highest), and 0x1FFF covers the 13 CPUs available to a title. Changes: - `VideoOutOpenParam` describes the five fields; `VIDEO_OUT_OPEN_PARAM_SIZE` becomes `VIDEO_OUT_OPEN_PARAM_FIRST_WORD`. - `validateOpenParam` throws for a first word other than 16, a flag other than 0 or 1, a priority outside 256..767 when its flag is set, and an affinity mask that is 0 or has bits outside 0x1FFF when its flag is set. It reads the u64 at offset 16 only when the affinity flag is set, so a 16-byte param with both flags clear is still read in bounds. - TechnicalDebt: the priority and affinity are validated but not applied (the port's present and vblank threads are host threads), listed under silent stubs. The first word and whether the param continues past offset 24 are listed under unknown function info. ### Tested - Linux (CachyOS, GCC). `video_out_flip_tests controls` (not part of ctest) gains `testOpenParam`: eight invalid params throw (first word 24, a priority flag of 2, an affinity flag of 0x101, priority 255 and 768, affinity 0, 0x2000 and a bit above 32), and a 16-byte param with both flags clear, a priority of 767 and an affinity of 1 open a port. The controls themselves now run on a port opened with PPSA21564's exact 88-byte param. On main the test fails at the first valid param (`param options not implemented`). - `ctest`: 105/105 pass. - PPSA21564 on my integration branch: with this change it starts, and my visual regression check (from the intro video through the title and save menu into gameplay; checkpoint frames, flicker, video tearing and FPS) passes twice in a row. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
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!297
No description provided.