Skip to content

Commit

Permalink
Allow +-1 line when autoswitch matching frame length
Browse files Browse the repository at this point in the history
  • Loading branch information
IanSB committed Nov 10, 2020
1 parent 7a4babf commit 77d04d6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
22 changes: 9 additions & 13 deletions src/osd.c
Expand Up @@ -2167,7 +2167,7 @@ void generate_palettes() {
case 0x00:
case 0x10: //alt
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, black_ref, 2000, 2000, &r, &g, &b, &m); break; // black
case 0x02: //alt
case 0x02: //alt
case 0x12:
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, 420, 2000, 2000, &r, &g, &b, &m); break; // white (buff)
}
Expand Down Expand Up @@ -2217,7 +2217,7 @@ void generate_palettes() {
case 0x00:
case 0x10: //alt
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, 720, 2000, 2000, &r, &g, &b, &m); break; // black
case 0x02: //alt
case 0x02: //alt
case 0x12:
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, 420, 2000, 2000, &r, &g, &b, &m); break; // white (buff)
}
Expand Down Expand Up @@ -2267,7 +2267,7 @@ void generate_palettes() {
case 0x00:
case 0x10: //alt
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, 720, 2000, 2000, &r, &g, &b, &m); r = 9; g = 9; b = 9; break; // black
case 0x02: //alt
case 0x02: //alt
case 0x12:
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, 420, 2000, 2000, &r, &g, &b, &m); r = 255; g = 255; b = 255; break; // white (buff)
}
Expand Down Expand Up @@ -2317,7 +2317,7 @@ void generate_palettes() {
case 0x00:
case 0x10: //alt
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, black_ref, 2000, 2000, &r, &g, &b, &m); r=0x00; g=0x00; b=0x00; break; // black
case 0x02: //alt
case 0x02: //alt
case 0x12:
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, 420, 2000, 2000, &r, &g, &b, &m); r=0xff; g=0xff; b=0xff; break; // white (buff)
}
Expand Down Expand Up @@ -2367,7 +2367,7 @@ void generate_palettes() {
case 0x00:
case 0x10: //alt
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, black_ref, 2000, 2000, &r, &g, &b, &m); r=0x00; g=0x00; b=0x00; break; // black
case 0x02: //alt
case 0x02: //alt
case 0x12:
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, 420, 2000, 2000, &r, &g, &b, &m); r=0xff; g=0xff; b=0xff; break; // white (buff)
}
Expand Down Expand Up @@ -2417,7 +2417,7 @@ void generate_palettes() {
case 0x00:
case 0x10: //alt
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, 720, 2000, 2000, &r, &g, &b, &m); r=0x00; g=0x00; b=0x00; break; // black
case 0x02: //alt
case 0x02: //alt
case 0x12:
yuv2rgb(maxdesat, mindesat, luma_scale, black_ref, 420, 2000, 2000, &r, &g, &b, &m); r=0xff; g=0xff; b=0xff; break; // white (buff)
}
Expand Down Expand Up @@ -4108,19 +4108,15 @@ int sub_profiles_available(int profile_number) {
return has_sub_profiles[profile_number];
}

int autoswitch_detect(int one_line_time_ns, int lines_per_vsync, int interlaced, int sync_type) {
int autoswitch_detect(int one_line_time_ns, int lines_per_vsync, int sync_type) {
if (has_sub_profiles[get_feature(F_PROFILE)]) {
int rounded_up_lines_per_vsync = lines_per_vsync;
if (interlaced) {
rounded_up_lines_per_vsync = lines_per_vsync + 1;
}
log_info("Looking for autoswitch match = %d, %d, %d, %d", one_line_time_ns, lines_per_vsync, rounded_up_lines_per_vsync, sync_type);
log_info("Looking for autoswitch match = %d, %d, %d", one_line_time_ns, lines_per_vsync, sync_type);
for (int i=0; i <= features[F_SUBPROFILE].max; i++) {
//log_info("Autoswitch test: %s (%d) = %d, %d, %d, %d", sub_profile_names[i], i, autoswitch_info[i].lower_limit,
// autoswitch_info[i].upper_limit, autoswitch_info[i].lines_per_frame, autoswitch_info[i].sync_type );
if ( one_line_time_ns > autoswitch_info[i].lower_limit
&& one_line_time_ns < autoswitch_info[i].upper_limit
&& (lines_per_vsync == autoswitch_info[i].lines_per_frame || rounded_up_lines_per_vsync == autoswitch_info[i].lines_per_frame)
&& (lines_per_vsync == autoswitch_info[i].lines_per_frame || lines_per_vsync == (autoswitch_info[i].lines_per_frame - 1) || lines_per_vsync == (autoswitch_info[i].lines_per_frame + 1))
&& sync_type == autoswitch_info[i].sync_type ) {
log_info("Autoswitch match: %s (%d) = %d, %d, %d, %d", sub_profile_names[i], i, autoswitch_info[i].lower_limit,
autoswitch_info[i].upper_limit, autoswitch_info[i].lines_per_frame, autoswitch_info[i].sync_type );
Expand Down
2 changes: 1 addition & 1 deletion src/osd.h
Expand Up @@ -216,7 +216,7 @@ void process_sub_profile(int profile_number, int sub_profile_number);
void load_profiles(int profile_number, int save_selected);
void process_single_profile(char *buffer);
uint32_t osd_get_palette(int index);
int autoswitch_detect(int one_line_time_ns, int lines_per_frame, int interlaced, int sync_type);
int autoswitch_detect(int one_line_time_ns, int lines_per_frame, int sync_type);
int sub_profiles_available();
uint32_t osd_get_equivalence(uint32_t value);
int get_existing_frontend(int frontend);
Expand Down
7 changes: 4 additions & 3 deletions src/rgb_to_hdmi.c
Expand Up @@ -1530,8 +1530,9 @@ static void cpld_init() {
// have to set mux to 0 to allow analog detection to work
// so clock out 32 bits of 0 into register chain as later CPLDs have mux as a register bit

int sp = 0b0000001100000000000000000000; //sets the rate bits to 12bit capture for testing simple mode with amiga
for (int i = 0; i < 27; i++) {
// int sp = 0x1180; //15 bits sets the rate bits to 12bit capture for testing simple mode with amiga
int sp = 0x200000; //24 bits sets the rate bits to 12bit capture for testing simple mode with amiga
for (int i = 0; i < 24; i++) {
RPI_SetGpioValue(SP_DATA_PIN, sp & 1);
delay_in_arm_cycles_cpu_adjust(250);
RPI_SetGpioValue(SP_CLKEN_PIN, 1);
Expand Down Expand Up @@ -2816,7 +2817,7 @@ void rgb_to_hdmi_main() {
setup_profile(profile != last_profile || last_subprofile != subprofile);

if ((autoswitch == AUTOSWITCH_PC) && sub_profiles_available(profile) && ((result & RET_SYNC_TIMING_CHANGED) || profile != last_profile || last_subprofile != subprofile)) {
int new_sub_profile = autoswitch_detect(one_line_time_ns, lines_per_vsync, interlaced, capinfo->detected_sync_type & SYNC_BIT_MASK);
int new_sub_profile = autoswitch_detect(one_line_time_ns, lines_per_vsync, capinfo->detected_sync_type & SYNC_BIT_MASK);
if (new_sub_profile >= 0) {
set_subprofile(new_sub_profile);
process_sub_profile(get_profile(), new_sub_profile);
Expand Down

0 comments on commit 77d04d6

Please sign in to comment.