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 } } }, }))