From 1979bdb333f7fff69836e7e6ef145cadb5c56d3b Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Mon, 23 Oct 2017 15:48:42 +0300 Subject: [PATCH 1/5] Save the last profile used for each physical input --- software/sys_controller/ossc/av_controller.c | 21 +++++++++++++++++++- software/sys_controller/ossc/av_controller.h | 6 ++++++ software/sys_controller/ossc/userdata.c | 11 +++++++--- software/sys_controller/ossc/userdata.h | 3 ++- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/software/sys_controller/ossc/av_controller.c b/software/sys_controller/ossc/av_controller.c index 069eb02..50ac1e9 100644 --- a/software/sys_controller/ossc/av_controller.c +++ b/software/sys_controller/ossc/av_controller.c @@ -68,13 +68,14 @@ alt_u8 target_type; alt_u8 stable_frames; alt_u8 update_cur_vm; -alt_u8 vm_sel, vm_edit, profile_sel, lt_sel; +alt_u8 vm_sel, vm_edit, profile_sel, input_profiles[3], lt_sel; alt_u16 tc_h_samplerate, tc_h_synclen, tc_h_bporch, tc_h_active, tc_v_synclen, tc_v_bporch, tc_v_active; char row1[LCD_ROW_LEN+1], row2[LCD_ROW_LEN+1], menu_row1[LCD_ROW_LEN+1], menu_row2[LCD_ROW_LEN+1]; extern alt_u8 menu_active; avinput_t target_mode; +phyinput_t phy_input_sel; alt_u8 pcm1862_active; @@ -540,6 +541,7 @@ void program_mode() int load_profile() { int retval; + input_profiles[phy_input_sel] = profile_sel; retval = read_userdata(profile_sel); if (retval == 0) write_userdata(INIT_CONFIG_SLOT); @@ -549,6 +551,7 @@ int load_profile() { int save_profile() { int retval; + input_profiles[phy_input_sel] = profile_sel; retval = write_userdata(profile_sel); if (retval == 0) write_userdata(INIT_CONFIG_SLOT); @@ -806,6 +809,7 @@ int main() switch (target_mode) { case AV1_RGBs: + phy_input_sel = PHY_AV1; target_input = TVP_INPUT1; target_format = FORMAT_RGBS; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -813,6 +817,7 @@ int main() target_pcm = PCM_INPUT4; break; case AV1_RGsB: + phy_input_sel = PHY_AV1; target_input = TVP_INPUT1; target_format = FORMAT_RGsB; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -820,6 +825,7 @@ int main() target_pcm = PCM_INPUT4; break; case AV1_YPBPR: + phy_input_sel = PHY_AV1; target_input = TVP_INPUT1; target_format = FORMAT_YPbPr; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -827,6 +833,7 @@ int main() target_pcm = PCM_INPUT4; break; case AV2_YPBPR: + phy_input_sel = PHY_AV2; target_input = TVP_INPUT1; target_format = FORMAT_YPbPr; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -834,6 +841,7 @@ int main() target_pcm = PCM_INPUT3; break; case AV2_RGsB: + phy_input_sel = PHY_AV2; target_input = TVP_INPUT1; target_format = FORMAT_RGsB; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -841,6 +849,7 @@ int main() target_pcm = PCM_INPUT3; break; case AV3_RGBHV: + phy_input_sel = PHY_AV3; target_input = TVP_INPUT3; target_format = FORMAT_RGBHV; target_typemask = VIDEO_PC; @@ -848,6 +857,7 @@ int main() target_pcm = PCM_INPUT2; break; case AV3_RGBs: + phy_input_sel = PHY_AV3; target_input = TVP_INPUT3; target_format = FORMAT_RGBS; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -855,6 +865,7 @@ int main() target_pcm = PCM_INPUT2; break; case AV3_RGsB: + phy_input_sel = PHY_AV3; target_input = TVP_INPUT3; target_format = FORMAT_RGsB; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -862,6 +873,7 @@ int main() target_pcm = PCM_INPUT2; break; case AV3_YPBPR: + phy_input_sel = PHY_AV3; target_input = TVP_INPUT3; target_format = FORMAT_YPbPr; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -874,6 +886,13 @@ int main() if (target_mode != AV_KEEP) { printf("### SWITCH MODE TO %s ###\n", avinput_str[target_mode]); + + // The input changed, so load the appropriate profile + if (profile_sel != input_profiles[phy_input_sel]) { + profile_sel = input_profiles[phy_input_sel]; + load_profile(); + } + cm.avinput = target_mode; 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 511b3a6..99cd6fc 100644 --- a/software/sys_controller/ossc/av_controller.h +++ b/software/sys_controller/ossc/av_controller.h @@ -75,6 +75,12 @@ typedef enum { AV_LAST = 10 } avinput_t; +typedef enum { + PHY_AV1 = 0, + PHY_AV2 = 1, + PHY_AV3 = 2 +} phyinput_t; + // In reverse order of importance typedef enum { NO_CHANGE = 0, diff --git a/software/sys_controller/ossc/userdata.c b/software/sys_controller/ossc/userdata.c index 0ea1807..a534d2a 100644 --- a/software/sys_controller/ossc/userdata.c +++ b/software/sys_controller/ossc/userdata.c @@ -29,7 +29,9 @@ extern avmode_t cm; extern avconfig_t tc; extern mode_data_t video_modes[]; extern avinput_t target_mode; +extern phyinput_t phy_input_sel; extern alt_u8 update_cur_vm; +extern alt_u8 input_profiles[3]; extern alt_u8 profile_sel; int write_userdata(alt_u8 entry) @@ -53,8 +55,9 @@ int write_userdata(alt_u8 entry) switch (((ude_hdr*)databuf)->type) { case UDE_INITCFG: ((ude_initcfg*)databuf)->data_len = sizeof(ude_initcfg) - offsetof(ude_initcfg, last_profile); - ((ude_initcfg*)databuf)->last_profile = profile_sel; + memcpy(((ude_initcfg*)databuf)->last_profile, input_profiles, sizeof(input_profiles)); ((ude_initcfg*)databuf)->last_input = cm.avinput; + ((ude_initcfg*)databuf)->last_phy_input = phy_input_sel; memcpy(((ude_initcfg*)databuf)->keys, rc_keymap, sizeof(rc_keymap)); retval = write_flash_page(databuf, sizeof(ude_initcfg), (USERDATA_OFFSET+entry*SECTORSIZE)/PAGESIZE); if (retval != 0) @@ -133,10 +136,12 @@ int read_userdata(alt_u8 entry) switch (((ude_hdr*)databuf)->type) { case UDE_INITCFG: if (((ude_initcfg*)databuf)->data_len == sizeof(ude_initcfg) - offsetof(ude_initcfg, last_profile)) { - if (((ude_initcfg*)databuf)->last_profile <= MAX_PROFILE) - profile_sel = ((ude_initcfg*)databuf)->last_profile; + for (alt_u8 i = 0; i < sizeof(input_profiles)/sizeof(*input_profiles); ++i) + if (((ude_initcfg*)databuf)->last_profile[i] <= MAX_PROFILE) + input_profiles[i] = ((ude_initcfg*)databuf)->last_profile[i]; if (((ude_initcfg*)databuf)->last_input < AV_LAST) target_mode = ((ude_initcfg*)databuf)->last_input; + profile_sel = input_profiles[((ude_initcfg*)databuf)->last_phy_input]; memcpy(rc_keymap, ((ude_initcfg*)databuf)->keys, sizeof(rc_keymap)); printf("RC data read (%u bytes)\n", sizeof(rc_keymap)); } diff --git a/software/sys_controller/ossc/userdata.h b/software/sys_controller/ossc/userdata.h index 114718a..4698102 100644 --- a/software/sys_controller/ossc/userdata.h +++ b/software/sys_controller/ossc/userdata.h @@ -46,8 +46,9 @@ typedef struct { typedef struct { ude_hdr hdr; alt_u16 data_len; - alt_u8 last_profile; + alt_u8 last_profile[3]; avinput_t last_input; + phyinput_t last_phy_input; alt_u16 keys[REMOTE_MAX_KEYS]; } __attribute__((packed, __may_alias__)) ude_initcfg; From ab61fd0c6705687e0110b8f7a9319065ad666689 Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Thu, 2 Nov 2017 23:42:47 +0200 Subject: [PATCH 2/5] Don't save initconfig every time the physical input and profile change This spares the Flash from some unnecessary writes. If the profile tied to a physical input changes, this change will be reflected in the initconfig when the new profile is loaded. --- software/sys_controller/ossc/av_controller.c | 2 +- software/sys_controller/ossc/userdata.c | 3 +-- software/sys_controller/ossc/userdata.h | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/software/sys_controller/ossc/av_controller.c b/software/sys_controller/ossc/av_controller.c index 50ac1e9..e8e9d70 100644 --- a/software/sys_controller/ossc/av_controller.c +++ b/software/sys_controller/ossc/av_controller.c @@ -890,7 +890,7 @@ int main() // The input changed, so load the appropriate profile if (profile_sel != input_profiles[phy_input_sel]) { profile_sel = input_profiles[phy_input_sel]; - load_profile(); + read_userdata(profile_sel); } cm.avinput = target_mode; diff --git a/software/sys_controller/ossc/userdata.c b/software/sys_controller/ossc/userdata.c index a534d2a..bb23b6f 100644 --- a/software/sys_controller/ossc/userdata.c +++ b/software/sys_controller/ossc/userdata.c @@ -57,7 +57,6 @@ int write_userdata(alt_u8 entry) ((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_phy_input = phy_input_sel; memcpy(((ude_initcfg*)databuf)->keys, rc_keymap, sizeof(rc_keymap)); retval = write_flash_page(databuf, sizeof(ude_initcfg), (USERDATA_OFFSET+entry*SECTORSIZE)/PAGESIZE); if (retval != 0) @@ -141,7 +140,7 @@ int read_userdata(alt_u8 entry) input_profiles[i] = ((ude_initcfg*)databuf)->last_profile[i]; if (((ude_initcfg*)databuf)->last_input < AV_LAST) target_mode = ((ude_initcfg*)databuf)->last_input; - profile_sel = input_profiles[((ude_initcfg*)databuf)->last_phy_input]; + profile_sel = input_profiles[0]; // Arbitrary default memcpy(rc_keymap, ((ude_initcfg*)databuf)->keys, sizeof(rc_keymap)); printf("RC data read (%u bytes)\n", sizeof(rc_keymap)); } diff --git a/software/sys_controller/ossc/userdata.h b/software/sys_controller/ossc/userdata.h index 4698102..507c57e 100644 --- a/software/sys_controller/ossc/userdata.h +++ b/software/sys_controller/ossc/userdata.h @@ -48,7 +48,6 @@ typedef struct { alt_u16 data_len; alt_u8 last_profile[3]; avinput_t last_input; - phyinput_t last_phy_input; alt_u16 keys[REMOTE_MAX_KEYS]; } __attribute__((packed, __may_alias__)) ude_initcfg; From 571b588da74db35ff455c8f0739d94db38ddacd5 Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Thu, 2 Nov 2017 22:37:27 +0200 Subject: [PATCH 3/5] Shrink the code by 16 bytes by using an array to map values --- software/sys_controller/ossc/av_controller.c | 11 ++--------- software/sys_controller/ossc/av_controller.h | 17 ++++++++++++++++- software/sys_controller/ossc/userdata.c | 1 - 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/software/sys_controller/ossc/av_controller.c b/software/sys_controller/ossc/av_controller.c index e8e9d70..af5c469 100644 --- a/software/sys_controller/ossc/av_controller.c +++ b/software/sys_controller/ossc/av_controller.c @@ -809,7 +809,6 @@ int main() switch (target_mode) { case AV1_RGBs: - phy_input_sel = PHY_AV1; target_input = TVP_INPUT1; target_format = FORMAT_RGBS; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -817,7 +816,6 @@ int main() target_pcm = PCM_INPUT4; break; case AV1_RGsB: - phy_input_sel = PHY_AV1; target_input = TVP_INPUT1; target_format = FORMAT_RGsB; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -825,7 +823,6 @@ int main() target_pcm = PCM_INPUT4; break; case AV1_YPBPR: - phy_input_sel = PHY_AV1; target_input = TVP_INPUT1; target_format = FORMAT_YPbPr; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -833,7 +830,6 @@ int main() target_pcm = PCM_INPUT4; break; case AV2_YPBPR: - phy_input_sel = PHY_AV2; target_input = TVP_INPUT1; target_format = FORMAT_YPbPr; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -841,7 +837,6 @@ int main() target_pcm = PCM_INPUT3; break; case AV2_RGsB: - phy_input_sel = PHY_AV2; target_input = TVP_INPUT1; target_format = FORMAT_RGsB; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -849,7 +844,6 @@ int main() target_pcm = PCM_INPUT3; break; case AV3_RGBHV: - phy_input_sel = PHY_AV3; target_input = TVP_INPUT3; target_format = FORMAT_RGBHV; target_typemask = VIDEO_PC; @@ -857,7 +851,6 @@ int main() target_pcm = PCM_INPUT2; break; case AV3_RGBs: - phy_input_sel = PHY_AV3; target_input = TVP_INPUT3; target_format = FORMAT_RGBS; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -865,7 +858,6 @@ int main() target_pcm = PCM_INPUT2; break; case AV3_RGsB: - phy_input_sel = PHY_AV3; target_input = TVP_INPUT3; target_format = FORMAT_RGsB; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -873,7 +865,6 @@ int main() target_pcm = PCM_INPUT2; break; case AV3_YPBPR: - phy_input_sel = PHY_AV3; target_input = TVP_INPUT3; target_format = FORMAT_YPbPr; target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV; @@ -887,6 +878,8 @@ int main() if (target_mode != AV_KEEP) { printf("### SWITCH MODE TO %s ###\n", avinput_str[target_mode]); + phy_input_sel = avinput_to_phyinput[target_mode]; + // The input changed, so load the appropriate profile if (profile_sel != input_profiles[phy_input_sel]) { profile_sel = input_profiles[phy_input_sel]; diff --git a/software/sys_controller/ossc/av_controller.h b/software/sys_controller/ossc/av_controller.h index 99cd6fc..0ea1147 100644 --- a/software/sys_controller/ossc/av_controller.h +++ b/software/sys_controller/ossc/av_controller.h @@ -78,9 +78,24 @@ typedef enum { typedef enum { PHY_AV1 = 0, PHY_AV2 = 1, - PHY_AV3 = 2 + PHY_AV3 = 2, + PHY_INVALID = 3 } phyinput_t; +static phyinput_t avinput_to_phyinput[] = { + [AV_KEEP] = PHY_INVALID, + [AV1_RGBs] = PHY_AV1, + [AV1_RGsB] = PHY_AV1, + [AV1_YPBPR] = PHY_AV1, + [AV2_YPBPR] = PHY_AV2, + [AV2_RGsB] = PHY_AV2, + [AV3_RGBHV] = PHY_AV3, + [AV3_RGBs] = PHY_AV3, + [AV3_RGsB] = PHY_AV3, + [AV3_YPBPR] = PHY_AV3, + [AV_LAST] = PHY_INVALID +}; + // In reverse order of importance typedef enum { NO_CHANGE = 0, diff --git a/software/sys_controller/ossc/userdata.c b/software/sys_controller/ossc/userdata.c index bb23b6f..4f38e77 100644 --- a/software/sys_controller/ossc/userdata.c +++ b/software/sys_controller/ossc/userdata.c @@ -29,7 +29,6 @@ extern avmode_t cm; extern avconfig_t tc; extern mode_data_t video_modes[]; extern avinput_t target_mode; -extern phyinput_t phy_input_sel; extern alt_u8 update_cur_vm; extern alt_u8 input_profiles[3]; extern alt_u8 profile_sel; From d638b6a6508ddffea6e3c6fa9be4600932ebf505 Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Thu, 2 Nov 2017 23:24:32 +0200 Subject: [PATCH 4/5] Shrink write_userdata() by 20 bytes --- software/sys_controller/ossc/userdata.c | 33 ++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/software/sys_controller/ossc/userdata.c b/software/sys_controller/ossc/userdata.c index 4f38e77..3c2bf28 100644 --- a/software/sys_controller/ossc/userdata.c +++ b/software/sys_controller/ossc/userdata.c @@ -39,6 +39,7 @@ int write_userdata(alt_u8 entry) alt_u16 vm_to_write; alt_u16 pageoffset, srcoffset; alt_u8 pageno; + alt_u32 bytes_to_w; int retval; if (entry > MAX_USERDATA_ENTRY) { @@ -68,31 +69,29 @@ int write_userdata(alt_u8 entry) ((ude_profile*)databuf)->avc_data_len = sizeof(avconfig_t); ((ude_profile*)databuf)->vm_data_len = vm_to_write; - pageno = 0; pageoffset = offsetof(ude_profile, avc); // assume that sizeof(avconfig_t) << PAGESIZE memcpy(databuf+pageoffset, &tc, sizeof(avconfig_t)); pageoffset += sizeof(avconfig_t); - srcoffset = 0; + // write a full page first + memcpy(databuf+pageoffset, (char*)video_modes, PAGESIZE-pageoffset); + srcoffset = PAGESIZE-pageoffset; + vm_to_write -= PAGESIZE-pageoffset; + write_flash_page(databuf, PAGESIZE, ((USERDATA_OFFSET+entry*SECTORSIZE)/PAGESIZE)); + + // then write the rest + pageno = 1; while (vm_to_write > 0) { - if (vm_to_write >= PAGESIZE-pageoffset) { - memcpy(databuf+pageoffset, (char*)video_modes+srcoffset, PAGESIZE-pageoffset); - srcoffset += PAGESIZE-pageoffset; - pageoffset = 0; - vm_to_write -= PAGESIZE-pageoffset; - // check - write_flash_page(databuf, PAGESIZE, ((USERDATA_OFFSET+entry*SECTORSIZE)/PAGESIZE) + pageno); - pageno++; - } else { - memcpy(databuf+pageoffset, (char*)video_modes+srcoffset, vm_to_write); - pageoffset += vm_to_write; - vm_to_write = 0; - // check - write_flash_page(databuf, PAGESIZE, ((USERDATA_OFFSET+entry*SECTORSIZE)/PAGESIZE) + pageno); - } + bytes_to_w = (vm_to_write > PAGESIZE) ? PAGESIZE : vm_to_write; + memcpy(databuf, (char*)video_modes+srcoffset, bytes_to_w); + write_flash_page(databuf, bytes_to_w, ((USERDATA_OFFSET+entry*SECTORSIZE)/PAGESIZE) + pageno); + srcoffset += bytes_to_w; + vm_to_write -= bytes_to_w; + ++pageno; } + printf("Profile %u data written (%u bytes)\n", entry, sizeof(avconfig_t)+VIDEO_MODES_SIZE); break; default: From 04c9137e29a36a210225756d9c2721649ae4c374 Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Sat, 11 Nov 2017 00:23:51 +0200 Subject: [PATCH 5/5] Move default input field from profiles to initconfig This makes things consistent. Without this change, the default input would be dictated by the profile associated with AV1. --- software/sys_controller/ossc/av_controller.c | 8 ++++---- software/sys_controller/ossc/avconfig.h | 1 - software/sys_controller/ossc/menu.c | 4 ++-- software/sys_controller/ossc/userdata.c | 3 +++ software/sys_controller/ossc/userdata.h | 1 + 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/software/sys_controller/ossc/av_controller.c b/software/sys_controller/ossc/av_controller.c index af5c469..07fdbf9 100644 --- a/software/sys_controller/ossc/av_controller.c +++ b/software/sys_controller/ossc/av_controller.c @@ -68,7 +68,7 @@ alt_u8 target_type; alt_u8 stable_frames; alt_u8 update_cur_vm; -alt_u8 vm_sel, vm_edit, profile_sel, input_profiles[3], lt_sel; +alt_u8 vm_sel, vm_edit, profile_sel, input_profiles[3], lt_sel, def_input; alt_u16 tc_h_samplerate, tc_h_synclen, tc_h_bporch, tc_h_active, tc_v_synclen, tc_v_bporch, tc_v_active; char row1[LCD_ROW_LEN+1], row2[LCD_ROW_LEN+1], menu_row1[LCD_ROW_LEN+1], menu_row2[LCD_ROW_LEN+1]; @@ -785,8 +785,8 @@ int main() while (1) {} } - if (tc.def_input < AV_LAST) - target_mode = tc.def_input; + if (def_input < AV_LAST) + target_mode = def_input; // Mainloop while(1) { @@ -901,7 +901,7 @@ int main() strncpy(row2, " NO SYNC", LCD_ROW_LEN+1); if (!menu_active) lcd_write_status(); - if (av_init && (tc.def_input == AV_LAST)) + if (av_init && (def_input == AV_LAST)) write_userdata(INIT_CONFIG_SLOT); av_init = 1; } diff --git a/software/sys_controller/ossc/avconfig.h b/software/sys_controller/ossc/avconfig.h index a032793..1b68504 100644 --- a/software/sys_controller/ossc/avconfig.h +++ b/software/sys_controller/ossc/avconfig.h @@ -83,7 +83,6 @@ typedef struct { alt_u8 audio_dw_sampl; alt_u8 audio_swap_lr; #endif - alt_u8 def_input; color_setup_t col; } __attribute__((packed)) avconfig_t; diff --git a/software/sys_controller/ossc/menu.c b/software/sys_controller/ossc/menu.c index cc0b86c..e8904b7 100644 --- a/software/sys_controller/ossc/menu.c +++ b/software/sys_controller/ossc/menu.c @@ -41,7 +41,7 @@ extern mode_data_t video_modes[]; extern alt_u16 tc_h_samplerate, tc_h_synclen, tc_h_bporch, tc_h_active, tc_v_synclen, tc_v_bporch, tc_v_active; extern alt_u32 remote_code; extern alt_u16 rc_keymap[REMOTE_MAX_KEYS]; -extern alt_u8 vm_sel, profile_sel, lt_sel; +extern alt_u8 vm_sel, profile_sel, lt_sel, def_input; alt_u8 menu_active; @@ -134,7 +134,7 @@ MENU(menu_output, P99_PROTECT({ \ { LNG("256x240 aspect","256x240アスペクト"), OPT_AVCONFIG_SELECTION, { .sel = { &tc.ar_256col, OPT_WRAP, SETTING_ITEM(ar_256col_desc) } } }, { LNG("TX mode","TXモード"), OPT_AVCONFIG_SELECTION, { .sel = { &tc.tx_mode, OPT_WRAP, SETTING_ITEM(tx_mode_desc) } } }, { "HDMI ITC", OPT_AVCONFIG_SELECTION, { .sel = { &tc.hdmi_itc, OPT_WRAP, SETTING_ITEM(off_on_desc) } } }, - { LNG("Initial input","ショキニュウリョク"), OPT_AVCONFIG_SELECTION, { .sel = { &tc.def_input, OPT_WRAP, SETTING_ITEM(avinput_str) } } }, + { LNG("Initial input","ショキニュウリョク"), OPT_AVCONFIG_SELECTION, { .sel = { &def_input, OPT_WRAP, SETTING_ITEM(avinput_str) } } }, })) MENU(menu_postproc, P99_PROTECT({ \ diff --git a/software/sys_controller/ossc/userdata.c b/software/sys_controller/ossc/userdata.c index 3c2bf28..1a11901 100644 --- a/software/sys_controller/ossc/userdata.c +++ b/software/sys_controller/ossc/userdata.c @@ -32,6 +32,7 @@ extern avinput_t target_mode; extern alt_u8 update_cur_vm; extern alt_u8 input_profiles[3]; extern alt_u8 profile_sel; +extern alt_u8 def_input; int write_userdata(alt_u8 entry) { @@ -57,6 +58,7 @@ int write_userdata(alt_u8 entry) ((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)->def_input = def_input; memcpy(((ude_initcfg*)databuf)->keys, rc_keymap, sizeof(rc_keymap)); retval = write_flash_page(databuf, sizeof(ude_initcfg), (USERDATA_OFFSET+entry*SECTORSIZE)/PAGESIZE); if (retval != 0) @@ -138,6 +140,7 @@ int read_userdata(alt_u8 entry) input_profiles[i] = ((ude_initcfg*)databuf)->last_profile[i]; if (((ude_initcfg*)databuf)->last_input < AV_LAST) target_mode = ((ude_initcfg*)databuf)->last_input; + def_input = ((ude_initcfg*)databuf)->def_input; profile_sel = input_profiles[0]; // Arbitrary default memcpy(rc_keymap, ((ude_initcfg*)databuf)->keys, sizeof(rc_keymap)); printf("RC data read (%u bytes)\n", sizeof(rc_keymap)); diff --git a/software/sys_controller/ossc/userdata.h b/software/sys_controller/ossc/userdata.h index 507c57e..d86d2a2 100644 --- a/software/sys_controller/ossc/userdata.h +++ b/software/sys_controller/ossc/userdata.h @@ -48,6 +48,7 @@ typedef struct { alt_u16 data_len; alt_u8 last_profile[3]; avinput_t last_input; + avinput_t def_input; alt_u16 keys[REMOTE_MAX_KEYS]; } __attribute__((packed, __may_alias__)) ude_initcfg;