Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C
4.5 KB
Raw Blame
From e1f8e11d8ccc80f91bd5a1f575b64aebe3b9acc3 Mon Sep 17 00:00:00 2001
From: Rafael Abud Ferreira <[email protected]>
Date: Thu, 15 Oct 2026 11:59:25 -0300
Subject: [PATCH 1/2] wsi/videoout: a VRR 119.88 Hz output counts (its idle
 vblank is the VRR floor)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/vulkan/wsi/wsi_common_videoout.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/vulkan/wsi/wsi_common_videoout.c b/src/vulkan/wsi/wsi_common_videoout.c
index 1f59ac2120e..2d6558e62e3 100644
--- a/src/vulkan/wsi/wsi_common_videoout.c
+++ b/src/vulkan/wsi/wsi_common_videoout.c
@@ -74,6 +74,12 @@
  * went on refreshing at 60 Hz, as a tester's did (PS5_Vulkan, R31). */
 #define VIDEOOUT_HIGH_REFRESH_LIMIT_NS UINT64_C(12500000)
 #define VIDEOOUT_PERIOD_INTERVALS 6
+/* With the system's VRR on, a 120 Hz request becomes VRR 119.88 Hz (AvControl:
+ * "119.88Hz request is converted to VRR 119.88Hz"): the display then waits for
+ * flips, and before the first one a vblank comes at its VRR floor (20.873 ms on
+ * an LG C1, about 48 Hz), longer than a 60 Hz period. Only a period up to this
+ * one, about 60 Hz, means the display stayed at 60 Hz (PSBox, 2026-10-15). */
+#define VIDEOOUT_FIXED_60HZ_MAX_NS UINT64_C(18500000)
 /* param.json's attribute3 bit for 120 Hz output. PS5_Vulkan R31/R92 declared it with 0x80000
  * (a 120 Hz mode that requires VRR), which turns the system's VRR off; retail titles with VRR
  * declare 0x40 with 0x40000. VideoOut itself grants mode 15 or refuses it. */
@@ -390,7 +396,10 @@ videoout_open_locked(void)
       if (out->high_frame_rate) {
          /* A period of 0 is a failed wait: never taken for 119.88 Hz */
          const uint64_t period = videoout_vblank_period_ns(out->handle);
-         if (period == 0 || period > VIDEOOUT_HIGH_REFRESH_LIMIT_NS) {
+         if (period > VIDEOOUT_FIXED_60HZ_MAX_NS) {
+            fprintf(stderr, "wsi/videoout: 119.88 Hz taken as VRR (an idle vblank every %.3f ms)\n",
+                    (double)period / 1e6);
+         } else if (period == 0 || period > VIDEOOUT_HIGH_REFRESH_LIMIT_NS) {
             sceVideoOutConfigureOutput(out->handle, PS5_VIDEO_OUT_MODE_RESTORE, NULL, NULL, NULL);
             out->high_frame_rate = false;
             if (period == 0)
-- 
2.55.0


From 993732cba5e66cf375619e74ad6105f8ba0b9d96 Mon Sep 17 00:00:00 2001
From: Rafael Abud Ferreira <[email protected]>
Date: Thu, 15 Oct 2026 12:38:29 -0300
Subject: [PATCH 2/2] wsi/videoout: wsi_videoout_set_high_refresh, 119.88 Hz on
 and off while the title runs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/vulkan/wsi/wsi_common_videoout.c | 35 ++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/src/vulkan/wsi/wsi_common_videoout.c b/src/vulkan/wsi/wsi_common_videoout.c
index 2d6558e62e3..46b83735269 100644
--- a/src/vulkan/wsi/wsi_common_videoout.c
+++ b/src/vulkan/wsi/wsi_common_videoout.c
@@ -441,6 +441,41 @@ wsi_videoout_set_flip_rate(int rate)
    return result;
 }
 
+PUBLIC int wsi_videoout_set_high_refresh(bool on);
+
+/* 119.88 Hz on the open output, or back to its default, while the title runs
+ * (a title that turns it on for some screens only). The title's param.json
+ * must declare it for the console to grant the mode. The swapchain stays as
+ * it was made; with the console's VRR on the display follows the flips.
+ * Returns VideoOut's answer: 0 done, -1 before the output is open, else the
+ * refusal (sceVideoOutIsOutputSupported's or ConfigureOutput's). */
+PUBLIC int
+wsi_videoout_set_high_refresh(bool on)
+{
+   call_once(&videoout_once, videoout_output_init_once);
+   mtx_lock(&videoout_output.lock);
+   struct wsi_videoout_output *out = &videoout_output;
+   int result = -1;
+   if (out->handle >= 0) {
+      if (on == out->high_frame_rate) {
+         result = 0;
+      } else if (on) {
+         const int supported =
+            sceVideoOutIsOutputSupported(out->handle, PS5_VIDEO_OUT_MODE_HIGH_FRAME_RATE, NULL, NULL, NULL);
+         result = supported > 0
+                     ? sceVideoOutConfigureOutput(out->handle, PS5_VIDEO_OUT_MODE_HIGH_FRAME_RATE, NULL, NULL, NULL)
+                     : (supported == 0 ? -2 : supported);
+         out->high_frame_rate = result == 0;
+      } else {
+         result = sceVideoOutConfigureOutput(out->handle, PS5_VIDEO_OUT_MODE_RESTORE, NULL, NULL, NULL);
+         if (result == 0)
+            out->high_frame_rate = false;
+      }
+   }
+   mtx_unlock(&videoout_output.lock);
+   return result;
+}
+
 static void
 videoout_settle_modes(void)
 {
-- 
2.55.0