Add a maximum limit for vi.

In rare cases, the LT6911 I2C may return incorrect resolution information, which is passed to vi and causes the system to freeze.
This commit is contained in:
BuGu
2025-02-25 18:21:02 +08:00
parent ba620db901
commit 7bd7b77fa9

View File

@@ -19,6 +19,8 @@
#define KVMV_MAX_TRY_NUM 2
#define vi_min_width 32
#define vi_min_height 3
#define vi_max_width 1920
#define vi_max_height 1080
#define default_vi_width 1920
#define default_vi_height 1080
@@ -297,6 +299,19 @@ int get_manual_resolution(void)
sprintf(Cmd, "echo %d > %s", vi_min_height, vi_height_path);
system(Cmd);
}
// res max limit
if(tmp_width > vi_max_width){
tmp_width = vi_max_width;
char Cmd[100]={0};
sprintf(Cmd, "echo %d > %s", vi_max_width, vi_width_path);
system(Cmd);
}
if(tmp_height > vi_max_height){
tmp_height = vi_max_height;
char Cmd[100]={0};
sprintf(Cmd, "echo %d > %s", vi_max_height, vi_height_path);
system(Cmd);
}
// res change ?
if(kvmv_cfg.vi_width != tmp_width){