Merge pull request #16745 from GiannisG1/feat/videoout-current-output-mode-handle

feat(libSceVideoOut): answer sceVideoOutGetCurrentOutputMode_ for a VideoOut handle as a PS5 does
This commit is contained in:
Adrià authored and GitHub committed 2026-11-11 09:26:21 +01:00
commit 276f436fc1
5 files changed
+97 -4

No files matched your search

@@ -119,6 +119,16 @@ if(BUILD_TESTING)
set_tests_properties(guest_video_out_device_capability PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_test_executable(guest_video_out_current_output_mode_tests ${LIBS_INCLUDE_DIR}/tests/GuestVideoOutCurrentOutputMode.cpp)
target_include_directories(guest_video_out_current_output_mode_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_video_out_current_output_mode_tests PRIVATE libSceVideoOut libSceAgcDriver libkernel libc)
configure_windows_unwind(guest_video_out_current_output_mode_tests)
add_test(NAME guest_video_out_current_output_mode COMMAND guest_video_out_current_output_mode_tests)
set_tests_properties(guest_video_out_current_output_mode PROPERTIES TIMEOUT 20 SKIP_RETURN_CODE 77 RESOURCE_LOCK videoout_app0)
if(WIN32)
set_tests_properties(guest_video_out_current_output_mode PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
if(WIN32)
set(videoOutTestDriver "windows")
else()
@@ -2,13 +2,16 @@
#include "prx/libSceVideoOut/include/LegacyExports.hpp"
#include "prx/libc/include/general/ExportMacros.hpp"
#include "prx/libSceVideoOut/include/InventoryExports.hpp"
#include "prx/libSceVideoOut/include/VideoOutDriver.hpp"
#include "prx/libc/include/General.hpp"
#include <cstdint>
#include <cstring>
#include <limits>
namespace {
constexpr int VideoOutErrorCurveSamplePoints = static_cast<int>(0x8029001Cu);
constexpr int VideoOutErrorLatestEopHandle = static_cast<int>(0x802900FFu);
constexpr int VideoOutErrorNoDevice = static_cast<int>(0x80290018u);
std::uint32_t ModeFlags(const void* mode) {
std::uint32_t flags;
@@ -191,7 +194,11 @@ int APS5_VABI sceVideoOutGetCoredumpOutputMode() {
NotImplemented_nid_no_patch(__func__);
}
int APS5_VABI sceVideoOutGetCurrentOutputMode_() {
int APS5_VABI sceVideoOutGetCurrentOutputMode_(std::uint64_t bus, void* mode) {
if (mode == nullptr) return VIDEO_OUT_ERROR_INVALID_ADDRESS;
if (bus <= static_cast<std::uint64_t>(std::numeric_limits<int>::max()) && VideoOutDriver::Get().IsOpen(static_cast<int>(bus))) {
return VideoOutErrorNoDevice;
}
NotImplemented_nid_no_patch(__func__);
}
@@ -47,7 +47,7 @@ int APS5_VABI sceVideoOutDriverResetBufferLabel();
int APS5_VABI sceVideoOutDriverTriggerEvent();
int APS5_VABI sceVideoOutGetBufferInformation();
int APS5_VABI sceVideoOutGetCoredumpOutputMode();
int APS5_VABI sceVideoOutGetCurrentOutputMode_();
int APS5_VABI sceVideoOutGetCurrentOutputMode_(std::uint64_t bus, void* mode);
int APS5_VABI sceVideoOutGetDeviceInfoExOts_();
int APS5_VABI sceVideoOutGetDeviceInfoEx_();
int APS5_VABI sceVideoOutGetHdmiKsvList_();
@@ -0,0 +1,76 @@
#include "SceTypes.hpp"
#include "prx/libSceVideoOut/include/InventoryExports.hpp"
#include "prx/libSceVideoOut/include/Output.hpp"
#include "tests/VideoOutTestEnvironment.hpp"
#include <array>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <stdexcept>
static constexpr int SYSTEM_USER = 255;
static constexpr int MAIN_BUS = 0;
static constexpr int NO_DEVICE = static_cast<int>(0x80290018u);
static constexpr int INVALID_ADDRESS = static_cast<int>(0x80290002u);
static constexpr std::uint64_t MAIN_OUTPUT = 0x7000;
static void Require(bool value, const char* message) {
if (!value) throw std::logic_error(message);
}
static bool Throws(std::uint64_t target, void* mode) {
try {
sceVideoOutGetCurrentOutputMode_(target, mode);
} catch (const std::runtime_error&) {
return true;
}
return false;
}
static bool Untouched(const std::array<std::uint8_t, 64>& mode) {
for (const auto value : mode) {
if (value != 0xAA) return false;
}
return true;
}
static int Run() {
VideoOutTestEnvironment environment;
std::array<std::uint8_t, 64> mode{};
mode.fill(0xAA);
Require(Throws(MAIN_OUTPUT, mode.data()), "the main output bus did not throw");
Require(Throws(0x7FFFFFFF, mode.data()), "a value that is no VideoOut handle did not throw");
Require(Throws(0x100000001ull, mode.data()), "a value above 32 bits did not throw");
Require(Untouched(mode), "a call that threw wrote the mode");
Require(sceVideoOutGetCurrentOutputMode_(MAIN_OUTPUT, nullptr) == INVALID_ADDRESS, "the main output bus with a null mode did not answer INVALID_ADDRESS");
Require(sceVideoOutGetCurrentOutputMode_(0x7FFFFFFF, nullptr) == INVALID_ADDRESS, "a value that is no VideoOut handle with a null mode did not answer INVALID_ADDRESS");
Require(sceVideoOutGetCurrentOutputMode_(0x100000001ull, nullptr) == INVALID_ADDRESS, "a value above 32 bits with a null mode did not answer INVALID_ADDRESS");
int handle = 0;
try {
handle = sceVideoOutOpen(SYSTEM_USER, MAIN_BUS, 0, nullptr);
} catch (const std::runtime_error& error) {
if (std::getenv("ANYPS5_REQUIRE_DISPLAY") != nullptr) throw;
std::printf("skipped, no display or Vulkan device: %s\n", error.what());
return 77;
}
Require(handle > 0, "sceVideoOutOpen failed");
Require(sceVideoOutGetCurrentOutputMode_(static_cast<std::uint64_t>(handle), mode.data()) == NO_DEVICE, "an open VideoOut handle did not answer NO_DEVICE");
Require(Untouched(mode), "the NO_DEVICE answer wrote the mode");
Require(sceVideoOutGetCurrentOutputMode_(static_cast<std::uint64_t>(handle), nullptr) == INVALID_ADDRESS, "an open VideoOut handle with a null mode did not answer INVALID_ADDRESS");
Require(sceVideoOutClose(handle) == 0, "sceVideoOutClose failed");
Require(Throws(static_cast<std::uint64_t>(handle), mode.data()), "a closed VideoOut handle did not throw");
Require(Untouched(mode), "a closed handle wrote the mode");
Require(sceVideoOutGetCurrentOutputMode_(static_cast<std::uint64_t>(handle), nullptr) == INVALID_ADDRESS, "a closed VideoOut handle with a null mode did not answer INVALID_ADDRESS");
std::puts("sceVideoOutGetCurrentOutputMode_ tests passed");
return 0;
}
int main() {
try {
return Run();
} catch (const std::exception& error) {
std::fprintf(stderr, "%s\n", error.what());
return 1;
}
}
+2 -2
View File
@@ -38,6 +38,7 @@
- [PS4 tiled display buffers](../../../core/libs/prx/libSceVideoOut/src/Buffer.cpp) (libSceVideoOut, PS4) - a tiled PS4 buffer group keeps its pitch in pixels apart from the buffer attribute, which has no pitch for tiled buffers on the PS5, and is presented as GCN Display2DThin.
- [sceVideoOutGetFlipStatus, sceVideoOutIsFlipPending](../../../core/libs/prx/libSceVideoOut/src/Output.cpp) (libSceVideoOut) - a null output together with an invalid handle throws, as only each alone was measured; a closed handle is unmeasured and answered like an invalid one. Measured in a payload process on a PS5 (firmware 12.70) on a handle from `sceVideoOutOpen(0xff, 0, 0, NULL)` with no buffer registered: `sceVideoOutGetFlipStatus` returned 0 and wrote 128 bytes, all zero except `flipArg` and `currentBuffer`, which were -1; a null output returned 0x80290002 and handle -1 returned 0x8029000b without writing the output; `sceVideoOutIsFlipPending` returned 0, and 0x8029000b for handle -1
- [DialogInput](../../../core/libs/prx/libSceVideoOut/src/DialogInput.cpp) (libSceVideoOut) - the inputs that drive the overlay dialog are not measured: Enter, Space, a left click and Cross confirm; Escape, a right click and Circle cancel, whatever the confirm-button setting of the console; the arrow keys, Tab, the mouse wheel, the D-pad and the left stick move the focus. A click confirms the focused button wherever it lands, as the overlay has no hit test. Closes when: measured on a PS5
- [sceVideoOutGetCurrentOutputMode_](../../../core/libs/prx/libSceVideoOut/InventoryExports.cpp) (libSceVideoOut) - throws for any first argument but an open VideoOut handle, which gets 0x80290018 (`NO_DEVICE`, [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/2bd672ea5c188b99d1080029a57ba0926273381c/src/core/libraries/videoout/videoout_error.h#L30)) and nothing written, as PPSA90212 gets on a PS5 with HDR off and on ([findings](https://github.com/bizkut/SavageWindRecomp/blob/6fd1a72d4ec6fdbde8b36485ca128a112a1f3ac7/ps5/FINDINGS.md#L987-L989)). A null record returns 0x80290002 first. Firmware 13.42's module (`0x149a0`, [reading](https://github.com/boykopovar/AnyPS5/issues/15134#issuecomment-6755215803), disassembly only) looks up no handle: it hands the argument to `sceAvControlGetCurrentOutputMode` and maps 0x802a0003 and 0x802a0004 to 0x80290018. That call's answer for a closed handle, or for a bus such as the main output 0x7000, is not read or measured
- [VideoOutDriver](../../../core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp) (libSceVideoOut) - the overlay dialog is drawn only while a window exists and the title keeps flipping: a dialog that no flip drew within three seconds of its open is dropped, its caller finishes with the automatic answer and the input is released, while one that was drawn waits for the player even if the title stops flipping. The three seconds are a host choice. An IME keyboard or pad capture takes the overlay and the input from the dialog until it ends. While the dialog is shown the title gets no pad, keyboard or mouse input, and a key or mouse button the title saw pressed is released once. Closes when: measured on a PS5
- [sceVideoOutRegisterBuffers2 past the last buffer](../../../core/libs/prx/libSceVideoOut/src/Buffer.cpp) (libSceVideoOut) - a call whose buffers run past index 15 returns `INVALID_VALUE` (0x80290001) and registers nothing. [PS5_Vulkan measured](https://github.com/mihawk-99/PS5_Vulkan/blob/f410e67a0241b3e8edcdbcd2a9b285dfc4a412ed/docs/HARDWARE_FINDINGS.md#L3773-L3791) that answer on a PS5 (firmware 13.40) for a fourth set at buffers 15 to 19, after three sets took buffers 0 to 14. Whether the console refused it for the sixteen buffer indices or for the number of sets is not measured: here four sets are accepted, and the other out-of-range arguments still throw.
@@ -68,7 +69,7 @@
- The [revision-pinned identity inventory](https://gist.github.com/kyon-eth/ea0a096e6231dbe7b98b5a308e2ac91e/00f8422a1ae71e32816d72ae579c2f2d097f63a0) records module, logical library, symbol type and NIDs for [InventoryExports.cpp](../../../core/libs/prx/libSceVideoOut/InventoryExports.cpp); it is a metadata summary rather than independent verification. Some NIDs belong to multiple logical libraries within the module.
- [Additional callable exports](../../../core/libs/prx/libSceVideoOut/InventoryExports.cpp) - 169 entries observed in a 3.20-labelled image and a later 13.60-labelled image; of the original 182, 107 match the public 3.20 catalogue and 75 do not. These are import-resolution declarations only. Neither image label authenticates a retail firmware version. Parameter lists, return types and behavior are unverified; parameterless `int` declarations are placeholders, not verified ABI contracts. Every entry throws through `NotImplemented_nid_no_patch`. Unidentified names use literal NID aliases. No runtime functionality is implemented; data exports need separate analysis. Identified candidate names match their NIDs in the [public symbol database](https://github.com/zecoxao/sce_symbols/blob/2883963a0a514ba6e77407a08ef4730a65e88254/aerolib.csv) or [supplemental catalog](https://github.com/claimore22/ps5rs/blob/2304be5131221bae0dac24b9767cabffda33f747/data/nids.csv).
- [Additional callable exports](../../../core/libs/prx/libSceVideoOut/InventoryExports.cpp) - 168 entries observed in a 3.20-labelled image and a later 13.60-labelled image; of the original 182, 107 match the public 3.20 catalogue and 75 do not. These are import-resolution declarations only. Neither image label authenticates a retail firmware version. Parameter lists, return types and behavior are unverified; parameterless `int` declarations are placeholders, not verified ABI contracts. Every entry throws through `NotImplemented_nid_no_patch`. Unidentified names use literal NID aliases. No runtime functionality is implemented; data exports need separate analysis. Identified candidate names match their NIDs in the [public symbol database](https://github.com/zecoxao/sce_symbols/blob/2883963a0a514ba6e77407a08ef4730a65e88254/aerolib.csv) or [supplemental catalog](https://github.com/claimore22/ps5rs/blob/2304be5131221bae0dac24b9767cabffda33f747/data/nids.csv).
| Name | NID |
| --- | --- |
@@ -112,7 +113,6 @@
| `sceVideoOutDriverTriggerEvent` | `OHnnkrUcShM` |
| `sceVideoOutGetBufferInformation` | `5V8YGx9g0UA` |
| `sceVideoOutGetCoredumpOutputMode` | `IZw2TINic+0` |
| `sceVideoOutGetCurrentOutputMode_` | `W0iQAbGaTBg` |
| `sceVideoOutGetDeviceInfoExOts_` | `p7FV-mU6EM0` |
| `sceVideoOutGetDeviceInfoEx_` | `k6JLQGuPEYA` |
| `sceVideoOutGetHdmiKsvList_` | `hZvzQy2VLKY` |