feat(libSceVideoOut): implement sceVideoOutAllowOutputResolutionWqhdDetection

Lets an open port report 2560x1440 output (resolution 4). The output
status here is 1080p or 2160p, so the call changes nothing it reports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
raghav314
2026-10-06 10:06:13 +05:30
parent 109a3281f8
commit 958b856832
4 changed files with 75 additions and 0 deletions
@@ -38,6 +38,19 @@ if(BUILD_TESTING)
add_test(NAME pad_sdl COMMAND pad_sdl_tests)
endif()
if(BUILD_TESTING)
add_test_executable(guest_video_out_wqhd_detection_tests ${LIBS_INCLUDE_DIR}/tests/GuestVideoOutWqhdDetection.cpp)
target_include_directories(guest_video_out_wqhd_detection_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_video_out_wqhd_detection_tests PRIVATE libSceVideoOut libSceAgcDriver libkernel libc)
configure_windows_unwind(guest_video_out_wqhd_detection_tests)
add_test(NAME guest_video_out_wqhd_detection COMMAND guest_video_out_wqhd_detection_tests)
set_tests_properties(guest_video_out_wqhd_detection PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_video_out_wqhd_detection PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
endif()
if(BUILD_TESTING)
add_test_executable(guest_buffer_reuse_tests ${LIBS_INCLUDE_DIR}/tests/GuestBufferReuse.cpp)
target_include_directories(guest_buffer_reuse_tests PRIVATE ${LIBS_INCLUDE_DIR})
@@ -12,6 +12,7 @@ int APS5_VABI sceVideoOutClose(int handle);
int APS5_VABI sceVideoOutConfigureOutput(int handle, uint64_t mode, const VideoOutOutputOptions* options, void* reserved_ptr, uint64_t reserved);
int APS5_VABI sceVideoOutIsOutputSupported(int handle, uint64_t mode, const VideoOutOutputOptions* options, void* reserved_ptr, uint64_t reserved);
int APS5_VABI sceVideoOutInitializeOutputOptions(VideoOutOutputOptions* options);
int APS5_VABI sceVideoOutAllowOutputResolutionWqhdDetection(int handle);
int APS5_VABI sceVideoOutSetFlipRate(int handle, int rate);
int APS5_VABI sceVideoOutSetWindowModeMargins(int handle, int top, int bottom);
int APS5_VABI sceVideoOutGetFlipStatus(int handle, VideoOutFlipStatus* status);
@@ -80,6 +80,15 @@ int APS5_VABI sceVideoOutClose(int handle) try {
LibcAwaitExit_nid_postfix();
}
int APS5_VABI sceVideoOutAllowOutputResolutionWqhdDetection(int handle) try {
if (!VideoOutDriver::Get().IsOpen(handle)) {
throw std::runtime_error(std::string(__func__) + ": VIDEO_OUT_ERROR_INVALID_HANDLE");
}
return 0;
} catch (const ProcessShutdown&) {
LibcAwaitExit_nid_postfix();
}
int APS5_VABI sceVideoOutSetFlipRate(int handle, int rate) try {
auto cfg = VideoOutDriver::Get().GetConfig(handle);
if (cfg == nullptr) {
@@ -0,0 +1,52 @@
#include "SceTypes.hpp"
#include "prx/libc/include/Shutdown.hpp"
#include <cstdlib>
#include <cstring>
#include <stdexcept>
extern "C" {
int APS5_VABI sceVideoOutOpen(int userId, int busType, int index, const void* param);
int APS5_VABI sceVideoOutClose(int handle);
int APS5_VABI sceVideoOutGetOutputStatus(int handle, VideoOutOutputStatus* status);
int APS5_VABI sceVideoOutAllowOutputResolutionWqhdDetection(int handle);
}
static constexpr int SYSTEM_USER = 255;
static constexpr int MAIN_BUS = 0;
static constexpr int NEVER_OPENED_HANDLE = 2;
static void Require(bool value) { if (!value) std::abort(); }
static bool RejectsHandle(int handle) {
try {
sceVideoOutAllowOutputResolutionWqhdDetection(handle);
} catch (const std::runtime_error&) {
return true;
}
return false;
}
static bool SameStatus(const VideoOutOutputStatus& a, const VideoOutOutputStatus& b) {
return std::memcmp(&a, &b, sizeof(a)) == 0;
}
int main() {
const int handle = sceVideoOutOpen(SYSTEM_USER, MAIN_BUS, 0, nullptr);
Require(handle > 0);
VideoOutOutputStatus before{};
Require(sceVideoOutGetOutputStatus(handle, &before) == 0);
Require(sceVideoOutAllowOutputResolutionWqhdDetection(handle) == 0);
Require(sceVideoOutAllowOutputResolutionWqhdDetection(handle) == 0);
VideoOutOutputStatus after{};
Require(sceVideoOutGetOutputStatus(handle, &after) == 0);
Require(SameStatus(before, after));
Require(RejectsHandle(0));
Require(RejectsHandle(-1));
Require(RejectsHandle(NEVER_OPENED_HANDLE));
Require(sceVideoOutClose(handle) == 0);
Require(RejectsHandle(handle));
LibcRunShutdown_nid_postfix();
}