commit a070462dc2669d6cf64a4b3ed4ddce3659ad3109
Author: mrfox <jens.se@icloud.com>
AuthorDate: Wed Nov 25 16:14:01 2026 +0100
Commit: mrfox <jens.se@icloud.com>
CommitDate: Wed Nov 25 16:14:01 2026 +0100
xex video test: colour matrix/LUT dumps and phased display fixes
The display registers on hardware already point at the title's buffer
(graphics enabled, scaler 640x480 -> 1280x1024, detiler set), yet the
picture stays black. The test now dumps the colour matrix and LUT and
tries, 6 s apart: opaque alpha, libxenon's RGB colour matrix, and a LUT
autofill.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---
platform/xex/runtime/video.c | 21 ++++++++++++++++++++
platform/xex/runtime/xex_video.h | 4 ++++
platform/xex/tests/video/main.cpp | 41 +++++++++++++++++++++++++++++++++++----
3 files changed, 62 insertions(+), 4 deletions(-)
diff --git a/platform/xex/runtime/video.c b/platform/xex/runtime/video.c
index 414ed3c..3f68500 100644
--- a/platform/xex/runtime/video.c
+++ b/platform/xex/runtime/video.c
@@ -493,6 +493,15 @@ static const struct { uint16_t offset; const char *name; } display_registers[] =
{0x6594, "SCL_TAP"}, {0x65a0, "SCL_65a0"}, {0x65b0, "SCL_65b0"}, {0x65b4, "SCL_65b4"},
{0x65b8, "SCL_65b8"}, {0x65c0, "SCL_65c0"}, {0x65c4, "SCL_65c4"}, {0x65c8, "SCL_65c8"},
{0x65cc, "SCL_UPDATE"}, {0x65d0, "SCL_65d0"}, {0x65dc, "SCL_65dc"}, {0x65e8, "SCL_65e8"},
+ {0x6108, "GRPH_LUT_SEL"}, {0x6058, "MVP_BLACK_KEYER"},
+ {0x6380, "CMATRIX_CNTL"}, {0x6384, "CM_1_1"}, {0x6388, "CM_1_2"}, {0x638c, "CM_1_3"},
+ {0x6390, "CM_1_4"}, {0x6394, "CM_2_1"}, {0x6398, "CM_2_2"}, {0x639c, "CM_2_3"},
+ {0x63a0, "CM_2_4"}, {0x63a4, "CM_3_1"}, {0x63a8, "CM_3_2"}, {0x63ac, "CM_3_3"},
+ {0x63b0, "CM_3_4"}, {0x63b4, "CM_63b4"},
+ {0x6484, "LUT_RW_MODE"}, {0x6488, "LUT_RW_INDEX"}, {0x649c, "LUT_WRITE_EN"},
+ {0x64a0, "LUT_AUTOFILL"}, {0x64c0, "LUTA_CONTROL"}, {0x64c4, "LUTA_64c4"},
+ {0x64c8, "LUTA_64c8"}, {0x64cc, "LUTA_64cc"}, {0x64d0, "LUTA_64d0"},
+ {0x64d4, "LUTA_64d4"}, {0x64d8, "LUTA_64d8"},
{0x2840, "DETILE_BASE"}, {0x2844, "DETILE_PITCH"}, {0x2848, "DETILE_2848"},
{0x7900, "OUT_7900"}, {0x7938, "OUT_7938"}, {0x793c, "OUT_793c"},
};
@@ -512,6 +521,18 @@ void xex_video_dump_registers(const char *label)
}
}
+uint32_t xex_video_read_register(uint32_t offset) { return gpu_read(offset / 4); }
+void xex_video_write_register(uint32_t offset, uint32_t value) { gpu_write(offset / 4, value); }
+
+void xex_video_dump_lut(void)
+{
+ static const int entries[] = {0, 1, 64, 128, 192, 255};
+ for (unsigned i = 0; i < sizeof(entries) / sizeof(entries[0]); i++) {
+ gpu_write(0x6488 / 4, entries[i]);
+ TRACE(" LUT[%d] = %08x", entries[i], (unsigned)gpu_read(0x6494 / 4));
+ }
+}
+
int xex_video_scaler_via_kernel = 0;
const char *xex_video_error(void)
diff --git a/platform/xex/runtime/xex_video.h b/platform/xex/runtime/xex_video.h
index 1616594..2340138 100644
--- a/platform/xex/runtime/xex_video.h
+++ b/platform/xex/runtime/xex_video.h
@@ -40,6 +40,10 @@ extern void (*xex_video_trace)(const char *fmt, ...);
/* Diagnostics: traces the display controller registers. */
void xex_video_dump_registers(const char *label);
+/* Diagnostics: raw display register access (byte offsets) and a few LUT entries. */
+uint32_t xex_video_read_register(uint32_t offset);
+void xex_video_write_register(uint32_t offset, uint32_t value);
+void xex_video_dump_lut(void);
/* Nonzero: program the scaler with VdInitializeScalerCommandBuffer at init
* (hangs on hardware so far). */
extern int xex_video_scaler_via_kernel;
diff --git a/platform/xex/tests/video/main.cpp b/platform/xex/tests/video/main.cpp
index 3f7a060..fe09522 100644
--- a/platform/xex/tests/video/main.cpp
+++ b/platform/xex/tests/video/main.cpp
@@ -48,12 +48,13 @@ int main(int, char **) {
xex_video_dump_registers("after init");
uint64_t startTime = xex_timebase();
int seconds = 0;
+ uint32_t alpha = 0;
for (;;) {
xex_pad pad;
int connected = xex_input_get(0, &pad);
// stop by itself after 20 s, so a black screen still tells whether the loop runs
- if (xex_timebase() - startTime > 20 * freq) {
- logLine("20 s elapsed, exiting");
+ if (xex_timebase() - startTime > 24 * freq) {
+ logLine("24 s elapsed, exiting");
break;
}
if ((pad.buttons & XEX_PAD_BACK) && (pad.buttons & XEX_PAD_START)) break;
@@ -85,7 +86,7 @@ int main(int, char **) {
} else {
c = xex_video_rgb((uint8_t)(x + t), (uint8_t)(y + t / 2), 96);
}
- f.pixels[xex_video_tiled_index(f.window_x + x, py, f.pitch)] = c;
+ f.pixels[xex_video_tiled_index(f.window_x + x, py, f.pitch)] = c | alpha;
}
}
xex_video_present();
@@ -98,7 +99,39 @@ int main(int, char **) {
logLine("second %d: %d fps, %dx%d window at %d,%d, pad %s buttons %04x",
++seconds, fps, f.window_width, f.window_height, f.window_x, f.window_y,
connected == 0 ? "ok" : "none", pad.buttons);
- if (seconds == 2 || seconds == 10) xex_video_dump_registers("running");
+ if (seconds == 2) {
+ xex_video_dump_registers("running");
+ xex_video_dump_lut();
+ }
+ // Phases to find what keeps the picture black (the display
+ // registers already point at our buffer):
+ if (seconds == 6) {
+ logLine("PHASE 2 (6 s): pixels with alpha 0xff");
+ alpha = 0xff;
+ }
+ if (seconds == 12) {
+ logLine("PHASE 3 (12 s): RGB colour matrix as libxenon");
+ static const uint32_t cm[] = {0x00db4000, 0, 0, 0x00408000, 0, 0x00db4000, 0, 0x00408000,
+ 0, 0, 0x00db4000, 0x00408000};
+ xex_video_write_register(0x6380, 1);
+ for (int i = 0; i < 12; i++) xex_video_write_register(0x6384 + i * 4, cm[i]);
+ xex_video_write_register(0x63b4, 0);
+ xex_video_dump_registers("phase 3");
+ }
+ if (seconds == 18) {
+ logLine("PHASE 4 (18 s): LUT autofill (identity ramp) as libxenon");
+ xex_video_write_register(0x6108, 0);
+ xex_video_write_register(0x64c0, 0);
+ xex_video_write_register(0x6488, 0);
+ xex_video_write_register(0x6484, 0);
+ xex_video_write_register(0x649c, 7);
+ xex_video_write_register(0x64a0, 1);
+ uint64_t w = xex_timebase();
+ while (!(xex_video_read_register(0x64a0) & 2) && xex_timebase() - w < freq / 10) {}
+ logLine("autofill %s", (xex_video_read_register(0x64a0) & 2) ? "done" : "timed out");
+ xex_video_dump_registers("phase 4");
+ xex_video_dump_lut();
+ }
frames = 0;
second = now;
}