From 6278e1026d39082a814df99f9a178e5a03878614 Mon Sep 17 00:00:00 2001 From: borti4938 Date: Sat, 10 Mar 2018 14:54:59 +0100 Subject: [PATCH 1/5] some code space optimization --- software/sys_controller/ossc/av_controller.c | 68 ++++++-------------- 1 file changed, 19 insertions(+), 49 deletions(-) diff --git a/software/sys_controller/ossc/av_controller.c b/software/sys_controller/ossc/av_controller.c index a8a4437..12046dc 100644 --- a/software/sys_controller/ossc/av_controller.c +++ b/software/sys_controller/ossc/av_controller.c @@ -808,69 +808,39 @@ int main() if (target_input != cm.avinput) { + target_tvp = TVP_INPUT1; + target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; + + if (target_input <= AV1_YPBPR) { + target_ths = THS_INPUT_B; + target_pcm = PCM_INPUT4; + } else if (target_input <= AV2_RGsB) { + target_ths = THS_INPUT_A; + target_pcm = PCM_INPUT3; + } else { // if (target_input <= AV3_YPBPR) { + target_tvp = TVP_INPUT3; + target_ths = THS_STANDBY; + target_pcm = PCM_INPUT2; + } + switch (target_input) { case AV1_RGBs: - target_tvp = TVP_INPUT1; + case AV3_RGBs: target_format = FORMAT_RGBS; - target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; - target_ths = THS_INPUT_B; - target_pcm = PCM_INPUT4; break; case AV1_RGsB: - target_tvp = TVP_INPUT1; + case AV2_RGsB: + case AV3_RGsB: target_format = FORMAT_RGsB; - target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; - target_ths = THS_INPUT_B; - target_pcm = PCM_INPUT4; break; case AV1_YPBPR: - target_tvp = TVP_INPUT1; - target_format = FORMAT_YPbPr; - target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; - target_ths = THS_INPUT_B; - target_pcm = PCM_INPUT4; - break; case AV2_YPBPR: - target_tvp = TVP_INPUT1; + case AV3_YPBPR: target_format = FORMAT_YPbPr; - target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; - target_ths = THS_INPUT_A; - target_pcm = PCM_INPUT3; - break; - case AV2_RGsB: - target_tvp = TVP_INPUT1; - target_format = FORMAT_RGsB; - target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; - target_ths = THS_INPUT_A; - target_pcm = PCM_INPUT3; break; case AV3_RGBHV: - target_tvp = TVP_INPUT3; target_format = FORMAT_RGBHV; target_typemask = VIDEO_PC; - target_ths = THS_STANDBY; - target_pcm = PCM_INPUT2; - break; - case AV3_RGBs: - target_tvp = TVP_INPUT3; - target_format = FORMAT_RGBS; - target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; - target_ths = THS_STANDBY; - target_pcm = PCM_INPUT2; - break; - case AV3_RGsB: - target_tvp = TVP_INPUT3; - target_format = FORMAT_RGsB; - target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; - target_ths = THS_STANDBY; - target_pcm = PCM_INPUT2; - break; - case AV3_YPBPR: - target_tvp = TVP_INPUT3; - target_format = FORMAT_YPbPr; - target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; - target_ths = THS_STANDBY; - target_pcm = PCM_INPUT2; break; default: break; From f337852e19cc016c6892b7fb07cde277ceec77a2 Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Mon, 12 Mar 2018 20:37:35 +0200 Subject: [PATCH 2/5] Implement two-way profile linking in a minimalistic way --- software/sys_controller/ossc/av_controller.c | 17 ++++++++++++++--- software/sys_controller/ossc/av_controller.h | 16 ---------------- software/sys_controller/ossc/avconfig.c | 1 + software/sys_controller/ossc/avconfig.h | 17 +++++++++++++++++ software/sys_controller/ossc/menu.c | 10 ++++++---- 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/software/sys_controller/ossc/av_controller.c b/software/sys_controller/ossc/av_controller.c index 12046dc..b4052ed 100644 --- a/software/sys_controller/ossc/av_controller.c +++ b/software/sys_controller/ossc/av_controller.c @@ -549,8 +549,13 @@ int load_profile() { input_profiles[profile_link ? cm.avinput : AV_TESTPAT] = profile_sel; retval = read_userdata(profile_sel); - if (retval == 0) + if (retval == 0) { + // Change the input if the new profile demands a different one. + if (tc.link_av != AV_LAST && tc.link_av != cm.avinput) + target_input = tc.link_av; + write_userdata(INIT_CONFIG_SLOT); + } return retval; } @@ -822,7 +827,7 @@ int main() target_ths = THS_STANDBY; target_pcm = PCM_INPUT2; } - + switch (target_input) { case AV1_RGBs: case AV3_RGBs: @@ -848,12 +853,18 @@ int main() printf("### SWITCH MODE TO %s ###\n", avinput_str[target_input]); - // The input changed, so load the appropriate profile + // The input changed, so load the appropriate profile if + // input->profile link is enabled if (profile_link && (profile_sel != input_profiles[target_input])) { profile_sel = input_profiles[target_input]; read_userdata(profile_sel); } + // If profile->input link is enabled, update it to the new input to + // stay consistent, but don't automatically save the new setting. + if (tc.link_av != AV_LAST) + tc.link_av = target_input; + cm.avinput = target_input; cm.sync_active = 0; ths_source_sel(target_ths, (cm.cc.video_lpf > 1) ? (VIDEO_LPF_MAX-cm.cc.video_lpf) : THS_LPF_BYPASS); diff --git a/software/sys_controller/ossc/av_controller.h b/software/sys_controller/ossc/av_controller.h index 1bbf2cc..94c15ec 100644 --- a/software/sys_controller/ossc/av_controller.h +++ b/software/sys_controller/ossc/av_controller.h @@ -59,22 +59,6 @@ #define FPGA_SCANLINEMODE_V 2 #define FPGA_SCANLINEMODE_ALT 3 -static const char *avinput_str[] = { "Test pattern", "AV1: RGBS", "AV1: RGsB", "AV1: YPbPr", "AV2: YPbPr", "AV2: RGsB", "AV3: RGBHV", "AV3: RGBS", "AV3: RGsB", "AV3: YPbPr", "Last used" }; - -typedef enum { - AV_TESTPAT = 0, - AV1_RGBs = 1, - AV1_RGsB = 2, - AV1_YPBPR = 3, - AV2_YPBPR = 4, - AV2_RGsB = 5, - AV3_RGBHV = 6, - AV3_RGBs = 7, - AV3_RGsB = 8, - AV3_YPBPR = 9, - AV_LAST = 10 -} avinput_t; - // In reverse order of importance typedef enum { NO_CHANGE = 0, diff --git a/software/sys_controller/ossc/avconfig.c b/software/sys_controller/ossc/avconfig.c index 02a5ed9..a679f47 100644 --- a/software/sys_controller/ossc/avconfig.c +++ b/software/sys_controller/ossc/avconfig.c @@ -67,6 +67,7 @@ const avconfig_t tc_default = { .g_f_off = DEFAULT_FINE_OFFSET, .b_f_off = DEFAULT_FINE_OFFSET, }, + .link_av = AV_LAST, }; int set_default_avconfig() diff --git a/software/sys_controller/ossc/avconfig.h b/software/sys_controller/ossc/avconfig.h index 42f44a6..b4b10eb 100644 --- a/software/sys_controller/ossc/avconfig.h +++ b/software/sys_controller/ossc/avconfig.h @@ -48,6 +48,22 @@ #define L5FMT_1600x1200 1 #define L5FMT_1920x1200 2 +static const char *avinput_str[] = { "Test pattern", "AV1: RGBS", "AV1: RGsB", "AV1: YPbPr", "AV2: YPbPr", "AV2: RGsB", "AV3: RGBHV", "AV3: RGBS", "AV3: RGsB", "AV3: YPbPr", "Last used" }; + +typedef enum { + AV_TESTPAT = 0, + AV1_RGBs = 1, + AV1_RGsB = 2, + AV1_YPBPR = 3, + AV2_YPBPR = 4, + AV2_RGsB = 5, + AV3_RGBHV = 6, + AV3_RGBs = 7, + AV3_RGsB = 8, + AV3_YPBPR = 9, + AV_LAST = 10 +} avinput_t; + typedef struct { alt_u8 sl_mode; alt_u8 sl_type; @@ -93,6 +109,7 @@ typedef struct { alt_u8 audio_gain; #endif color_setup_t col; + avinput_t link_av; } __attribute__((packed)) avconfig_t; int set_default_avconfig(); diff --git a/software/sys_controller/ossc/menu.c b/software/sys_controller/ossc/menu.c index 3fe17d2..ef55396 100644 --- a/software/sys_controller/ossc/menu.c +++ b/software/sys_controller/ossc/menu.c @@ -78,6 +78,7 @@ static void value_disp(alt_u8 v) { sniprintf(menu_row2, LCD_ROW_LEN+1, " %u", static void lt_disp(alt_u8 v) { strncpy(menu_row2, lt_desc[v], LCD_ROW_LEN+1); } static void aud_db_disp(alt_u8 v) { sniprintf(menu_row2, LCD_ROW_LEN+1, "%d dB", ((alt_8)v-AUDIO_GAIN_0DB)); } static void vm_display_name (alt_u8 v) { strncpy(menu_row2, video_modes[v].name, LCD_ROW_LEN+1); } +static void link_av_desc (avinput_t v) { strncpy(menu_row2, v == AV_LAST ? "No link" : avinput_str[v], LCD_ROW_LEN+1); } static const arg_info_t vm_arg_info = {&vm_sel, VIDEO_MODES_CNT-1, vm_display_name}; static const arg_info_t profile_arg_info = {&profile_sel, MAX_PROFILE, value_disp}; @@ -170,12 +171,13 @@ MENU(menu_audio, P99_PROTECT({ \ #endif MENU(menu_settings, P99_PROTECT({ \ - { LNG("","<プロファイルロード >"), OPT_FUNC_CALL, { .fun = { load_profile, &profile_arg_info } } }, - { LNG("","<プロファイルセーブ >"), OPT_FUNC_CALL, { .fun = { save_profile, &profile_arg_info } } }, + { LNG("","<プロファイルロード >"), OPT_FUNC_CALL, { .fun = { load_profile, &profile_arg_info } } }, + { LNG("","<プロファイルセーブ >"), OPT_FUNC_CALL, { .fun = { save_profile, &profile_arg_info } } }, { LNG("","<セッテイオショキカ >"), OPT_FUNC_CALL, { .fun = { set_default_avconfig, NULL } } }, + { LNG("Link prof->input","Link prof->input"), OPT_AVCONFIG_NUMVALUE, { .num = { &tc.link_av, OPT_WRAP, AV1_RGBs, AV_LAST, link_av_desc } } }, + { LNG("Link input->prof","Link input->prof"), OPT_AVCONFIG_SELECTION, { .sel = { &profile_link, OPT_WRAP, SETTING_ITEM(off_on_desc) } } }, { LNG("Initial input","ショキニュウリョク"), OPT_AVCONFIG_SELECTION, { .sel = { &def_input, OPT_WRAP, SETTING_ITEM(avinput_str) } } }, - { "Link input/prof", OPT_AVCONFIG_SELECTION, { .sel = { &profile_link, OPT_WRAP, SETTING_ITEM(off_on_desc) } } }, - { LNG("","<ファームウェアアップデート>"), OPT_FUNC_CALL, { .fun = { fw_update, NULL } } }, + { LNG("","<ファームウェアアップデート>"), OPT_FUNC_CALL, { .fun = { fw_update, NULL } } }, })) From 5852eb3465a6401d2a4c1b2d457dbf574b4bff8b Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Wed, 14 Mar 2018 21:56:30 +0200 Subject: [PATCH 3/5] Prevent profile loads induced by profile loads --- software/sys_controller/ossc/av_controller.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/software/sys_controller/ossc/av_controller.c b/software/sys_controller/ossc/av_controller.c index b4052ed..41e4d42 100644 --- a/software/sys_controller/ossc/av_controller.c +++ b/software/sys_controller/ossc/av_controller.c @@ -67,6 +67,7 @@ alt_u8 target_typemask; alt_u8 target_type; alt_u8 stable_frames; alt_u8 update_cur_vm; +alt_u8 omit_profile_load; alt_u8 vm_sel, vm_edit, profile_sel, input_profiles[AV_LAST], lt_sel, def_input, profile_link; alt_u16 tc_h_samplerate, tc_h_synclen, tc_h_bporch, tc_h_active, tc_v_synclen, tc_v_bporch, tc_v_active; @@ -551,8 +552,11 @@ int load_profile() { retval = read_userdata(profile_sel); if (retval == 0) { // Change the input if the new profile demands a different one. - if (tc.link_av != AV_LAST && tc.link_av != cm.avinput) + // Also prevent the change of input from inducing a profile load. + if (tc.link_av != AV_LAST && tc.link_av != cm.avinput) { target_input = tc.link_av; + omit_profile_load = 1; + } write_userdata(INIT_CONFIG_SLOT); } @@ -769,6 +773,7 @@ int main() ths_input_t target_ths = 0; pcm_input_t target_pcm = 0; video_format target_format = 0; + omit_profile_load = 0; status_t status; @@ -855,10 +860,13 @@ int main() // The input changed, so load the appropriate profile if // input->profile link is enabled - if (profile_link && (profile_sel != input_profiles[target_input])) { + if (profile_link && (profile_sel != input_profiles[target_input]) && + !omit_profile_load) + { profile_sel = input_profiles[target_input]; read_userdata(profile_sel); } + omit_profile_load = 0; // If profile->input link is enabled, update it to the new input to // stay consistent, but don't automatically save the new setting. From 0bb490faa019376c88997e853dc128812da0541f Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Wed, 14 Mar 2018 21:58:02 +0200 Subject: [PATCH 4/5] Don't automagically update profile->input link --- software/sys_controller/ossc/av_controller.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/software/sys_controller/ossc/av_controller.c b/software/sys_controller/ossc/av_controller.c index 41e4d42..374ff68 100644 --- a/software/sys_controller/ossc/av_controller.c +++ b/software/sys_controller/ossc/av_controller.c @@ -868,11 +868,6 @@ int main() } omit_profile_load = 0; - // If profile->input link is enabled, update it to the new input to - // stay consistent, but don't automatically save the new setting. - if (tc.link_av != AV_LAST) - tc.link_av = target_input; - cm.avinput = target_input; cm.sync_active = 0; ths_source_sel(target_ths, (cm.cc.video_lpf > 1) ? (VIDEO_LPF_MAX-cm.cc.video_lpf) : THS_LPF_BYPASS); From b464a9224bde0c8f67ca32e927fbafdb5d65c241 Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Thu, 15 Mar 2018 01:03:54 +0200 Subject: [PATCH 5/5] Improve avoidance of profile load induced profile loads It was buggy anyway, as pointed out by borti4938. --- software/sys_controller/ossc/av_controller.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/software/sys_controller/ossc/av_controller.c b/software/sys_controller/ossc/av_controller.c index 374ff68..34f0615 100644 --- a/software/sys_controller/ossc/av_controller.c +++ b/software/sys_controller/ossc/av_controller.c @@ -67,7 +67,6 @@ alt_u8 target_typemask; alt_u8 target_type; alt_u8 stable_frames; alt_u8 update_cur_vm; -alt_u8 omit_profile_load; alt_u8 vm_sel, vm_edit, profile_sel, input_profiles[AV_LAST], lt_sel, def_input, profile_link; alt_u16 tc_h_samplerate, tc_h_synclen, tc_h_bporch, tc_h_active, tc_v_synclen, tc_v_bporch, tc_v_active; @@ -555,7 +554,8 @@ int load_profile() { // Also prevent the change of input from inducing a profile load. if (tc.link_av != AV_LAST && tc.link_av != cm.avinput) { target_input = tc.link_av; - omit_profile_load = 1; + input_profiles[profile_link ? target_input : AV_TESTPAT] + = profile_sel; } write_userdata(INIT_CONFIG_SLOT); @@ -773,7 +773,6 @@ int main() ths_input_t target_ths = 0; pcm_input_t target_pcm = 0; video_format target_format = 0; - omit_profile_load = 0; status_t status; @@ -860,13 +859,10 @@ int main() // The input changed, so load the appropriate profile if // input->profile link is enabled - if (profile_link && (profile_sel != input_profiles[target_input]) && - !omit_profile_load) - { + if (profile_link && (profile_sel != input_profiles[target_input])) { profile_sel = input_profiles[target_input]; read_userdata(profile_sel); } - omit_profile_load = 0; cm.avinput = target_input; cm.sync_active = 0;