From a33df4c92b523ae7d3a52b8f9ddb7ef79dd91b3e Mon Sep 17 00:00:00 2001 From: Sorgelig Date: Tue, 5 May 2026 04:20:05 +0800 Subject: [PATCH] video: add spd_quirk. --- MiSTer.ini | 13 ++++++++++++- cfg.cpp | 1 + cfg.h | 1 + video.cpp | 15 ++++++--------- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/MiSTer.ini b/MiSTer.ini index 4cf9419..a05a7b8 100644 --- a/MiSTer.ini +++ b/MiSTer.ini @@ -37,7 +37,7 @@ video_off_hdmi=0 ; 1 - power down HDMI on video_off timeout (TV can sleep) video_off_logo=0 ; 1 - show moving MiSTer logo when video_off is enabled (to distinguish from TV off mode) osd_rotate=0 ; Display OSD menu rotated, 0 - no rotation, 1 - rotate right (+90°), 2 - rotate left (-90°) vga_sog=0 ; 1 - enable sync on green (needs analog I/O board v6.0 or newer). -lookahead=1 ; 1 - keep cursor centered while scrolling, 0 - only scroll at list edges +lookahead=1 ; 1 - keep cursor centered while scrolling, 0 - only scroll at list edges ; 1 - enables the recent file loaded/mounted. @@ -379,3 +379,14 @@ osd_lock_time=5 ; XBE2 controller with chatpad accessory and this option can replace full(almost) keyboard and mouse. ; Note: chatpad works only when XBE2 is connected through cable or USB dongle. Not through Bluetooth. ;xbe2_shift=0x224 ;Paddle P3 + +; Some board have i2c communication problem between FPGA and HDMI chip making OSD (and even core itself) laggy. +; This option reduces amount of i2c communication by removing SPD packet change from specific events. +; Note: SPD packets are most important if you use Direct Video mode together with external scaler which +; supports MiSTer specifically. If you don't use such scaler or don't use Direct Video mode then it's safe to set +; this option to 3 +; 0 - normal SPD work (default). +; 1 - Don't send SPD in normal mode (non-Direct-Video). +; 2 - Additionally don't send new SPD upon OSD open/close +; 3 - Don't send SPD at all. +spd_quirk=0 diff --git a/cfg.cpp b/cfg.cpp index ff588fe..98f75d5 100644 --- a/cfg.cpp +++ b/cfg.cpp @@ -137,6 +137,7 @@ static const ini_var_t ini_vars[] = { "AUTOFIRE_ON_DIRECTIONS", (void *)(&(cfg.autofire_on_directions)), UINT8, 0, 1 }, { "SCREENSHOT_IMAGE_FORMAT", (void *)(&(cfg.screenshot_image_format)), STRING, 0, sizeof(cfg.screenshot_image_format) - 1 }, { "XBE2_SHIFT", (void*)(&(cfg.xbe2_shift)), UINT16, 0, 0x22F }, + { "SPD_QUIRK", (void*)(&(cfg.spd_quirk)), UINT8, 0, 3 }, }; static const int nvars = (int)(sizeof(ini_vars) / sizeof(ini_var_t)); diff --git a/cfg.h b/cfg.h index 960d38e..9a14fe3 100644 --- a/cfg.h +++ b/cfg.h @@ -105,6 +105,7 @@ typedef struct { uint8_t autofire_on_directions; char screenshot_image_format[16]; uint16_t xbe2_shift; + uint8_t spd_quirk; } cfg_t; extern cfg_t cfg; diff --git a/video.cpp b/video.cpp index 01775f5..65b0f9a 100644 --- a/video.cpp +++ b/video.cpp @@ -1151,11 +1151,8 @@ static void hdmi_packet_set_data(uint8_t mask, uint8_t offset, uint8_t *data, in } else { - for (int i = 0; i < size; i++) - { - res = i2c_smbus_write_byte_data(fd, offset + i, data[i]); - if (res < 0) printf("i2c: SPD register write error (%02X %02x): %d\n", offset + i, data[i], res); - } + res = i2c_smbus_write_block_data(fd, offset, size, data); + if (res < 0) printf("i2c: SPD data write error: %d\n", res); res = i2c_smbus_write_byte_data(fd, offset + 0x1F, 0x00); if (res < 0) printf("i2c: Couldn't update packet change register (0x%02X, 0x00) %d\n", offset + 0x1F, res); @@ -3009,7 +3006,7 @@ static void spd_config_update() { if (use_freesync_spd) return; - if (cfg.direct_video) + if (cfg.direct_video && (cfg.spd_quirk < 3)) { // Custom SPD IF for additional DV1 metadata VideoInfo *vi = ¤t_video_info; @@ -3020,7 +3017,7 @@ static void spd_config_update() 'D', 'V', '1', // version - (uint8_t)((vi->interlaced ? 1 : 0) | (menu_present() ? 4 : 0) | (vi->rotated ? 8 : 0) | (arcade_get_direction() << 4)), + (uint8_t)((vi->interlaced ? 1 : 0) | ((menu_present() && (cfg.spd_quirk < 2)) ? 4 : 0) | (vi->rotated ? 8 : 0) | (arcade_get_direction() << 4)), (uint8_t)(vi->pixrep ? vi->pixrep : (vi->ctime / vi->width)), (uint8_t)vi->de_h, (uint8_t)(vi->de_h >> 8), @@ -3042,7 +3039,7 @@ static void spd_config_update() hdmi_spd_config(data); } - else + else if(!cfg.spd_quirk) { // Standard SPD IF uint8_t data[31] = { @@ -3089,7 +3086,7 @@ void video_mode_adjust(bool force) static int menu = 0; int menu_now = menu_present(); - if(menu != menu_now) spd_config_update(); + if(menu != menu_now && cfg.spd_quirk < 2) spd_config_update(); menu = menu_now; if (vid_changed && !is_menu())