Skip to content

Commit

Permalink
Add 50Hz monitor test option
Browse files Browse the repository at this point in the history
  • Loading branch information
IanSB committed Oct 11, 2020
1 parent 87c3039 commit edfcd2f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/osd.c
Expand Up @@ -421,6 +421,7 @@ static void info_save_log(int line);
static void info_credits(int line);
static void info_reboot(int line);

static void info_test_50hz(int line);
static void rebuild_geometry_menu(menu_t *menu);
static void rebuild_sampling_menu(menu_t *menu);
static void rebuild_update_cpld_menu(menu_t *menu);
Expand All @@ -434,6 +435,7 @@ static info_menu_item_t save_log_ref = { I_INFO, "Save Log & EDID",
static info_menu_item_t credits_ref = { I_INFO, "Credits", info_credits};
static info_menu_item_t reboot_ref = { I_INFO, "Reboot", info_reboot};

static info_menu_item_t test_50hz_ref = { I_INFO, "Test Monitor for 50Hz Support", info_test_50hz};
static back_menu_item_t back_ref = { I_BACK, "Return"};
static action_menu_item_t save_ref = { I_SAVE, "Save Configuration"};
static action_menu_item_t restore_ref = { I_RESTORE, "Restore Default Configuration"};
Expand Down Expand Up @@ -733,6 +735,7 @@ static menu_t main_menu = {
(base_menu_item_t *) &save_ref,
(base_menu_item_t *) &restore_ref,
(base_menu_item_t *) &cal_sampling_ref,
(base_menu_item_t *) &test_50hz_ref,
(base_menu_item_t *) &resolution_ref,
(base_menu_item_t *) &scaling_ref,
(base_menu_item_t *) &frontend_ref,
Expand Down Expand Up @@ -1391,6 +1394,36 @@ static void info_save_log(int line) {
osd_set(line++, 0, "Log.txt and EDID.bin saved to SD card");
}

static void info_test_50hz(int line) {
static int old_50hz_state = 0;
int current_50hz_state = get_50hz_state();
if (old_50hz_state == 1 && current_50hz_state == 0) {
current_50hz_state = 1;
}
old_50hz_state = current_50hz_state;
switch(current_50hz_state) {
case 0:
osd_set(line++, 0, "50Hz support is already enabled");
osd_set(line++, 0, "");
osd_set(line++, 0, "If menu text is unstable, change");
osd_set(line++, 0, "Resolution to Default@60Hz");
osd_set(line++, 0, "to permanently disable 50Hz support");
break;
case 1:
set_force_genlock_range(GENLOCK_RANGE_FORCE_LOW);
set_status_message(" ");
osd_set(line++, 0, "50Hz support enabled until reset");
osd_set(line++, 0, "");
osd_set(line++, 0, "If you can see this message, change");
osd_set(line++, 0, "Resolution to Auto@50Hz-60Hz");
osd_set(line++, 0, "to permanently enable 50Hz support");
break;
default:
osd_set(line++, 0, "Unable to test: Source is not 50hz");
break;
}
}

static void info_reboot(int line) {
reboot();
}
Expand Down
7 changes: 7 additions & 0 deletions src/rgb_to_hdmi.c
Expand Up @@ -2508,6 +2508,13 @@ int get_lines_per_vsync() {

}

int get_50hz_state() {
if (source_vsync_freq_hz == 50) {
return vlock_limited;
}
return -1;
}

void set_autoswitch(int value) {
// Prevent autoswitch (to mode 7) being accidentally with the Atom CPLD,
// for example by selecting the BBC_Micro profile, as this results in
Expand Down
1 change: 1 addition & 0 deletions src/rgb_to_hdmi.h
Expand Up @@ -54,6 +54,7 @@ int get_autoswitch();
void set_debug(int on);
int get_debug();
int get_lines_per_vsync();
int get_50hz_state();
int show_detected_status(int line);
void delay_in_arm_cycles_cpu_adjust(int cycles);
void set_filtering(int filter);
Expand Down

0 comments on commit edfcd2f

Please sign in to comment.