1
0
mirror of https://github.com/marqs85/ossc.git synced 2024-06-01 17:41:37 +00:00

minor optimizations

This commit is contained in:
marqs 2018-03-25 00:32:06 +02:00
parent e6e970227a
commit 5422953f30
4 changed files with 43 additions and 33 deletions

View File

@ -547,17 +547,14 @@ void program_mode()
int load_profile() {
int retval;
input_profiles[profile_link ? cm.avinput : AV_TESTPAT] = profile_sel;
retval = read_userdata(profile_sel);
if (retval == 0) {
// Change the input if the new profile demands a different one.
// Also prevent the change of input from inducing a profile load.
if (tc.link_av != AV_LAST && tc.link_av != cm.avinput) {
// Change the input if the new profile demands it.
if (tc.link_av != AV_LAST)
target_input = tc.link_av;
input_profiles[profile_link ? target_input : AV_TESTPAT]
= profile_sel;
}
// Update profile link (also prevents the change of input from inducing a profile load).
input_profiles[profile_link ? target_input : AV_TESTPAT] = profile_sel;
write_userdata(INIT_CONFIG_SLOT);
}
return retval;
@ -778,7 +775,7 @@ int main()
alt_u32 input_vec;
int init_stat;
int init_stat, man_input_change;
init_stat = init_hw();
@ -810,7 +807,16 @@ int main()
if ((remote_rpt == 0) || ((remote_rpt > 1) && (remote_rpt < 6)) || (remote_rpt == remote_rpt_prev))
remote_code = 0;
parse_control();
remote_rpt_prev = remote_rpt;
if (btn_code_prev == 0) {
btn_code_prev = btn_code;
} else {
btn_code_prev = btn_code;
btn_code = 0;
}
man_input_change = parse_control();
if (menu_active)
display_menu(0);
@ -880,7 +886,7 @@ int main()
if (!menu_active)
lcd_write_status();
// record last input if it was selected manually
if ((def_input == AV_LAST) && (remote_code || (btn_code & PB0_BIT)))
if ((def_input == AV_LAST) && man_input_change)
write_userdata(INIT_CONFIG_SLOT);
}
@ -936,8 +942,6 @@ int main()
}
}
btn_code_prev = btn_code;
remote_rpt_prev = remote_rpt;
usleep(300); // Avoid executing mainloop multiple times per vsync
}

View File

@ -1,5 +1,5 @@
//
// Copyright (C) 2015-2017 Markus Hiienkari <mhiienka@niksula.hut.fi>
// Copyright (C) 2015-2018 Markus Hiienkari <mhiienka@niksula.hut.fi>
//
// This file is part of Open Source Scan Converter project.
//
@ -103,11 +103,12 @@ void setup_rc()
write_userdata(INIT_CONFIG_SLOT);
}
void parse_control()
int parse_control()
{
int i;
alt_u32 btn_vec;
alt_u8 pt_only = 0;
avinput_t man_target_input = AV_LAST;
// one for each video_group
alt_u8* pmcfg_ptr[] = { &pt_only, &tc.pm_240p, &tc.pm_384p, &tc.pm_480i, &tc.pm_480p, &tc.pm_480p, &tc.pm_1080i };
@ -116,7 +117,7 @@ void parse_control()
if (remote_code)
printf("RCODE: 0x%.4lx, %d\n", remote_code, remote_rpt);
if (btn_code_prev == 0 && btn_code != 0)
if (btn_code)
printf("BCODE: 0x%.2lx\n", btn_code>>16);
for (i = RC_BTN1; i < REMOTE_MAX_KEYS; i++) {
@ -127,15 +128,15 @@ void parse_control()
}
switch (i) {
case RC_BTN1: target_input = AV1_RGBs; break;
case RC_BTN4: target_input = AV1_RGsB; break;
case RC_BTN7: target_input = AV1_YPBPR; break;
case RC_BTN2: target_input = AV2_YPBPR; break;
case RC_BTN5: target_input = AV2_RGsB; break;
case RC_BTN3: target_input = AV3_RGBHV; break;
case RC_BTN6: target_input = AV3_RGBs; break;
case RC_BTN9: target_input = AV3_RGsB; break;
case RC_BTN0: target_input = AV3_YPBPR; break;
case RC_BTN1: man_target_input = AV1_RGBs; break;
case RC_BTN4: man_target_input = AV1_RGsB; break;
case RC_BTN7: man_target_input = AV1_YPBPR; break;
case RC_BTN2: man_target_input = AV2_YPBPR; break;
case RC_BTN5: man_target_input = AV2_RGsB; break;
case RC_BTN3: man_target_input = AV3_RGBHV; break;
case RC_BTN6: man_target_input = AV3_RGBs; break;
case RC_BTN9: man_target_input = AV3_RGsB; break;
case RC_BTN0: man_target_input = AV3_YPBPR; break;
case RC_MENU:
menu_active = !menu_active;
@ -226,10 +227,15 @@ void parse_control()
}
Button_Check:
if (btn_code_prev == 0) {
if (btn_code & PB0_BIT)
target_input = (cm.avinput == AV3_YPBPR) ? AV1_RGBs : (cm.avinput+1);
if (btn_code & PB1_BIT)
tc.sl_mode = tc.sl_mode < SL_MODE_MAX ? tc.sl_mode + 1 : 0;
if (btn_code & PB0_BIT)
man_target_input = (cm.avinput == AV3_YPBPR) ? AV1_RGBs : (cm.avinput+1);
if (btn_code & PB1_BIT)
tc.sl_mode = tc.sl_mode < SL_MODE_MAX ? tc.sl_mode + 1 : 0;
if (man_target_input != AV_LAST) {
target_input = man_target_input;
return 1;
}
return 0;
}

View File

@ -1,5 +1,5 @@
//
// Copyright (C) 2015-2016 Markus Hiienkari <mhiienka@niksula.hut.fi>
// Copyright (C) 2015-2018 Markus Hiienkari <mhiienka@niksula.hut.fi>
//
// This file is part of Open Source Scan Converter project.
//
@ -60,6 +60,6 @@ typedef enum {
#define REMOTE_MAX_KEYS (RC_PROF_HOTKEY-RC_BTN1+1)
void setup_rc();
void parse_control();
int parse_control();
#endif

View File

@ -1,5 +1,5 @@
//
// Copyright (C) 2015-2017 Markus Hiienkari <mhiienka@niksula.hut.fi>
// Copyright (C) 2015-2018 Markus Hiienkari <mhiienka@niksula.hut.fi>
//
// This file is part of Open Source Scan Converter project.
//
@ -57,7 +57,7 @@ int write_userdata(alt_u8 entry)
case UDE_INITCFG:
((ude_initcfg*)databuf)->data_len = sizeof(ude_initcfg) - offsetof(ude_initcfg, last_profile);
memcpy(((ude_initcfg*)databuf)->last_profile, input_profiles, sizeof(input_profiles));
((ude_initcfg*)databuf)->last_input = cm.avinput;
((ude_initcfg*)databuf)->last_input = target_input;
((ude_initcfg*)databuf)->def_input = def_input;
((ude_initcfg*)databuf)->profile_link = profile_link;
memcpy(((ude_initcfg*)databuf)->keys, rc_keymap, sizeof(rc_keymap));