From 7447392f8775ce7b7cbc202f407691e07947ef4d Mon Sep 17 00:00:00 2001 From: Dean Galvin Date: Tue, 29 Sep 2026 13:25:25 +1300 Subject: [PATCH] feat(videoout): accept a zeroed open param sceVideoOutOpen threw for any non-null param. PS5 titles pass a 16-byte open param whose first word is its size, so they could not open a port. A param whose size word is 16 and whose other three words are zero requests nothing beyond a null param and is accepted. Any other size, or any non-zero option word, still throws. --- .../prx/libSceVideoOut/include/VideoOutDriver.hpp | 1 + core/libs/prx/libSceVideoOut/src/Output.cpp | 12 +++++++++++- core/libs/prx/libSceVideoOut/tests/Flip.cpp | 9 ++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/libs/prx/libSceVideoOut/include/VideoOutDriver.hpp b/core/libs/prx/libSceVideoOut/include/VideoOutDriver.hpp index a24efd186..916b2db96 100644 --- a/core/libs/prx/libSceVideoOut/include/VideoOutDriver.hpp +++ b/core/libs/prx/libSceVideoOut/include/VideoOutDriver.hpp @@ -37,6 +37,7 @@ static constexpr int VIDEO_OUT_ERROR_UNAVAILABLE_OUTPUT_MODE = -2144796633; static constexpr int VIDEO_OUT_ERROR_INVALID_EVENT = -2144796624; static constexpr int VIDEO_OUT_BUS_TYPE_MAIN = 0; +static constexpr std::uint32_t VIDEO_OUT_OPEN_PARAM_SIZE = 16; static constexpr int VIDEO_OUT_BUS_TYPE_OVERLAY = 1; static constexpr int VIDEO_OUT_BUS_TYPE_SUB = 2; diff --git a/core/libs/prx/libSceVideoOut/src/Output.cpp b/core/libs/prx/libSceVideoOut/src/Output.cpp index e1038cff4..598dc08c3 100644 --- a/core/libs/prx/libSceVideoOut/src/Output.cpp +++ b/core/libs/prx/libSceVideoOut/src/Output.cpp @@ -1,3 +1,6 @@ +#include +#include +#include #include #include #include @@ -31,7 +34,14 @@ extern "C" { int APS5_VABI sceVideoOutOpen(int userId, int busType, int index, const void* param) try { if (param != nullptr) { - throw std::runtime_error(std::string(__func__) + ": param not implemented"); + std::array words{}; + std::memcpy(words.data(), param, sizeof(words)); + if (words[0] != VIDEO_OUT_OPEN_PARAM_SIZE) { + throw std::runtime_error(std::string(__func__) + ": unsupported param size"); + } + if (std::any_of(words.begin() + 1, words.end(), [](std::uint32_t word) { return word != 0; })) { + throw std::runtime_error(std::string(__func__) + ": param options not implemented"); + } } if (userId != 255 && userId != 0) { throw std::runtime_error(std::string(__func__) + ": VIDEO_OUT_ERROR_INVALID_VALUE"); diff --git a/core/libs/prx/libSceVideoOut/tests/Flip.cpp b/core/libs/prx/libSceVideoOut/tests/Flip.cpp index 99af68044..3949f3575 100644 --- a/core/libs/prx/libSceVideoOut/tests/Flip.cpp +++ b/core/libs/prx/libSceVideoOut/tests/Flip.cpp @@ -160,7 +160,14 @@ void testDecode() { } void testControls() { - const auto handle = sceVideoOutOpen(255, 0, 0, nullptr); + std::array openParam{VIDEO_OUT_OPEN_PARAM_SIZE, 0, 0, 0}; + const auto handle = sceVideoOutOpen(255, 0, 0, openParam.data()); + check(handle >= 0, "open with a zeroed param failed"); + openParam[0] = 24; + expectFailure([&] { sceVideoOutOpen(255, 0, 0, openParam.data()); }); + openParam[0] = VIDEO_OUT_OPEN_PARAM_SIZE; + openParam[2] = 1; + expectFailure([&] { sceVideoOutOpen(255, 0, 0, openParam.data()); }); const auto cfg = VideoOutDriver::Get().GetConfig(handle); for (int rate = 0; rate <= 2; ++rate) { check(sceVideoOutSetFlipRate(handle, rate) == 0 && cfg->flipRate == rate, "flip rate was not applied");