1
0
mirror of https://github.com/marqs85/ossc.git synced 2026-03-13 21:16:31 +00:00

misc improvements

* add character LCD backlight timeout option
* increase h.mask range
* show accurate (fpga-calculated) timings on infoscreen
This commit is contained in:
marqs
2018-03-28 20:09:40 +03:00
parent 5422953f30
commit 37650ca22b
17 changed files with 2392 additions and 1310 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -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[AV_LAST], lt_sel, def_input, profile_link;
alt_u8 vm_sel, vm_edit, profile_sel, profile_sel_menu, input_profiles[AV_LAST], lt_sel, def_input, profile_link, lcd_bl_timeout;
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];
@@ -364,8 +364,8 @@ status_t get_status(tvp_input_t input, video_format format)
// h_info: [31:30] [29] [28] [27:20] [19:11] [10:0]
// | H_MULTMODE[1:0] | H_L5FMT | | H_SYNCLEN[7:0] | H_BACKPORCH[8:0] | H_ACTIVE[10:0] |
//
// h_info2: [31:29] [28:19] [18:16] [15:13] [12:10] [9:0]
// | | H_MASK[9:0] | H_OPT_SCALE[2:0] | H_OPT_SAMPLE_SEL[2:0] | H_OPT_SAMPLE_MULT[2:0] | H_OPT_STARTOFF[9:0] |
// h_info2: [31:30] [29:19] [18:16] [15:13] [12:10] [9:0]
// | | H_MASK[10:0] | H_OPT_SCALE[2:0] | H_OPT_SAMPLE_SEL[2:0] | H_OPT_SAMPLE_MULT[2:0] | H_OPT_STARTOFF[9:0] |
//
// v_info: [31:29] [28:27] [26] [25:20] [19:17] [16:11] [10:0]
// | V_MULTMODE[2:0] | V_SCANLINEMODE[1:0] | V_SCANLINEID | V_MASK[5:0] | V_SYNCLEN[2:0] | V_BACKPORCH[5:0] | V_ACTIVE[10:0] |
@@ -547,8 +547,10 @@ void program_mode()
int load_profile() {
int retval;
retval = read_userdata(profile_sel);
retval = read_userdata(profile_sel_menu);
if (retval == 0) {
profile_sel = profile_sel_menu;
// Change the input if the new profile demands it.
if (tc.link_av != AV_LAST)
target_input = tc.link_av;
@@ -557,16 +559,21 @@ int load_profile() {
input_profiles[profile_link ? target_input : AV_TESTPAT] = profile_sel;
write_userdata(INIT_CONFIG_SLOT);
}
return retval;
}
int save_profile() {
int retval;
input_profiles[profile_link ? cm.avinput : AV_TESTPAT] = profile_sel;
retval = write_userdata(profile_sel);
if (retval == 0)
retval = write_userdata(profile_sel_menu);
if (retval == 0) {
profile_sel = profile_sel_menu;
input_profiles[profile_link ? cm.avinput : AV_TESTPAT] = profile_sel;
write_userdata(INIT_CONFIG_SLOT);
}
return retval;
}
@@ -616,7 +623,7 @@ int init_hw()
usleep(10000);
// unreset hw
sys_ctrl = AV_RESET_N|LCD_BL|SD_SPI_SS_N|LCD_CS_N;
sys_ctrl = AV_RESET_N|LCD_BL|SD_SPI_SS_N|LCD_CS_N|REMOTE_EVENT;
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
//wait >500ms for SD card interface to be stable

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.
//
@@ -24,15 +24,17 @@
#include "sysconfig.h"
// sys_ctrl bits
#define LT_ACTIVE (1<<15)
#define LT_ARMED (1<<14)
#define LT_MODE_OFFS 12
#define SD_SPI_SS_N (1<<7)
#define LCD_CS_N (1<<6)
#define LCD_RS (1<<5)
#define LCD_BL (1<<4)
#define VIDGEN_OFF (1<<1)
#define AV_RESET_N (1<<0)
#define LT_ACTIVE (1<<15)
#define LT_ARMED (1<<14)
#define LT_MODE_OFFS 12
#define REMOTE_EVENT (1<<8)
#define SD_SPI_SS_N (1<<7)
#define LCD_CS_N (1<<6)
#define LCD_RS (1<<5)
#define LCD_BL (1<<4)
#define LCD_BL_TIMEOUT_OFFS 2
#define VIDGEN_OFF (1<<1)
#define AV_RESET_N (1<<0)
#define LT_CTRL_MASK 0xf000

View File

@@ -25,7 +25,8 @@
#define SCANLINESTR_MAX 15
#define SL_HYBRIDSTR_MAX 28
#define HV_MASK_MAX 63
#define H_MASK_MAX 255
#define V_MASK_MAX 63
#define HV_MASK_MAX_BR 15
#define VIDEO_LPF_MAX 5
#define SAMPLER_PHASE_MAX 31

View File

@@ -43,7 +43,8 @@ extern avconfig_t tc;
extern avinput_t target_input;
extern alt_u8 menu_active;
extern alt_u16 sys_ctrl;
extern alt_u8 profile_sel;
extern alt_u8 profile_sel, profile_sel_menu;
extern alt_u8 lcd_bl_timeout;
alt_u32 remote_code;
alt_u8 remote_rpt, remote_rpt_prev;
@@ -105,11 +106,15 @@ void setup_rc()
int parse_control()
{
int i;
int i, ret=0;
alt_u32 btn_vec;
alt_u8 pt_only = 0;
avinput_t man_target_input = AV_LAST;
alt_u32 fpga_status;
alt_u32 fpga_v_hz_x100;
alt_u8 fpga_ilace;
// 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 };
alt_u8 valid_pm[] = { 0x1, 0x1f, 0x3, 0xf, 0x3, 0x3, 0x3 };
@@ -139,6 +144,7 @@ int parse_control()
case RC_BTN0: man_target_input = AV3_YPBPR; break;
case RC_MENU:
menu_active = !menu_active;
profile_sel_menu = profile_sel;
if (menu_active)
display_menu(1);
@@ -147,15 +153,21 @@ int parse_control()
break;
case RC_INFO:
sniprintf(menu_row1, LCD_ROW_LEN+1, "VMod: %s", video_modes[cm.id].name);
sniprintf(menu_row2, LCD_ROW_LEN+1, "LC: %u VSM: %u", (IORD_ALTERA_AVALON_PIO_DATA(PIO_2_BASE) & 0x7ff)+1, (IORD_ALTERA_AVALON_PIO_DATA(PIO_2_BASE) >> 16) & 0x3);
fpga_status = IORD_ALTERA_AVALON_PIO_DATA(PIO_2_BASE);
fpga_ilace = !!(fpga_status & (1<<11));
sniprintf(menu_row1, LCD_ROW_LEN+1, "Prof.%u %9s", profile_sel, video_modes[cm.id].name);
if (cm.sync_active) {
fpga_v_hz_x100 = (100*TVP_EXTCLK_HZ)/IORD_ALTERA_AVALON_PIO_DATA(PIO_8_BASE);
sniprintf(menu_row2, LCD_ROW_LEN+1, "%4lu%c%c %3lu.%.2luHz", (((fpga_status & 0x7ff)+1)<<fpga_ilace)+fpga_ilace,
fpga_ilace ? 'i' : 'p',
((fpga_status >> 16) & 0x3) ? '*' : ' ',
fpga_v_hz_x100/100,
fpga_v_hz_x100%100);
}
lcd_write_menu();
printf("Mod: %s\n", video_modes[cm.id].name);
printf("Lines: %u M: %u\n", (IORD_ALTERA_AVALON_PIO_DATA(PIO_2_BASE) & 0x7ff)+1, cm.macrovis);
break;
case RC_LCDBL:
sys_ctrl ^= LCD_BL;
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
break;
case RC_SL_MODE: tc.sl_mode = (tc.sl_mode < SL_MODE_MAX) ? (tc.sl_mode + 1) : 0; break;
case RC_SL_TYPE: tc.sl_type = (tc.sl_type < SL_TYPE_MAX) ? (tc.sl_type + 1) : 0; break;
@@ -211,7 +223,7 @@ int parse_control()
}
if (i <= RC_BTN0) {
profile_sel = (i+1)%10;
profile_sel_menu = (i+1)%10;
load_profile();
break;
} else if (i == RC_BACK) {
@@ -226,6 +238,8 @@ int parse_control()
default: break;
}
sys_ctrl ^= REMOTE_EVENT;
Button_Check:
if (btn_code & PB0_BIT)
man_target_input = (cm.avinput == AV3_YPBPR) ? AV1_RGBs : (cm.avinput+1);
@@ -234,8 +248,14 @@ Button_Check:
if (man_target_input != AV_LAST) {
target_input = man_target_input;
return 1;
ret = 1;
}
return 0;
sys_ctrl &= ~(3<<LCD_BL_TIMEOUT_OFFS);
if (!menu_active)
sys_ctrl |= (lcd_bl_timeout << LCD_BL_TIMEOUT_OFFS);
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
return ret;
}

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.
//
@@ -109,6 +109,16 @@ int fw_update()
alt_u32 bytes_to_rw;
fw_hdr fw_header;
#ifdef CHECK_STACK_USE
// estimate stack usage, assuming around here is the worst case (due to 512B databuf)
alt_u32 sp;
asm volatile("mov %0, sp" : "=r"(sp));
sniprintf(menu_row1, LCD_ROW_LEN+1, "Stack size:");
sniprintf(menu_row2, LCD_ROW_LEN+1, "%lu bytes", (ONCHIP_MEMORY2_0_BASE+ONCHIP_MEMORY2_0_SIZE_VALUE)-sp);
lcd_write_menu();
usleep(1000000);
#endif
retval = check_sdcard(databuf);
SPI_CS_High();
if (retval != 0)

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.
//
@@ -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, def_input, profile_link;
extern alt_u8 vm_sel, profile_sel_menu, lt_sel, def_input, profile_link, lcd_bl_timeout;
alt_u8 menu_active;
@@ -65,6 +65,7 @@ static const char *sl_type_desc[] = { LNG("Horizontal","ヨコ"), LNG("Vertical"
static const char *sl_id_desc[] = { LNG("Top","ウエ"), LNG("Bottom","シタ") };
static const char *audio_dw_sampl_desc[] = { LNG("Off (fs = 96kHz)","オフ (fs = 96kHz)"), "2x (fs = 48kHz)" };
static const char *lt_desc[] = { "Top-left", "Center", "Bottom-right" };
static const char *lcd_bl_timeout_desc[] = { "Off", "3s", "10s", "30s" };
static void sampler_phase_disp(alt_u8 v) { sniprintf(menu_row2, LCD_ROW_LEN+1, LNG("%d deg","%d ド"), (v*1125)/100); }
static void sync_vth_disp(alt_u8 v) { sniprintf(menu_row2, LCD_ROW_LEN+1, "%d mV", (v*1127)/100); }
@@ -81,7 +82,7 @@ static void vm_display_name (alt_u8 v) { strncpy(menu_row2, video_modes[v].name,
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};
static const arg_info_t profile_arg_info = {&profile_sel_menu, MAX_PROFILE, value_disp};
static const arg_info_t lt_arg_info = {&lt_sel, (sizeof(lt_desc)/sizeof(char*))-1, lt_disp};
@@ -147,8 +148,8 @@ MENU(menu_postproc, P99_PROTECT({ \
{ LNG("Scanline method","Scanline method"), OPT_AVCONFIG_SELECTION, { .sel = { &tc.sl_method, OPT_WRAP, SETTING_ITEM(sl_method_desc) } } },
{ LNG("Scanline type","スキャンラインルイ"), OPT_AVCONFIG_SELECTION, { .sel = { &tc.sl_type, OPT_WRAP, SETTING_ITEM(sl_type_desc) } } },
{ LNG("Scanline alignm.","スキャンラインポジション"), OPT_AVCONFIG_SELECTION, { .sel = { &tc.sl_id, OPT_WRAP, SETTING_ITEM(sl_id_desc) } } },
{ LNG("Horizontal mask","スイヘイマスク"), OPT_AVCONFIG_NUMVALUE, { .num = { &tc.h_mask, OPT_NOWRAP, 0, HV_MASK_MAX, pixels_disp } } },
{ LNG("Vertical mask","スイチョクマスク"), OPT_AVCONFIG_NUMVALUE, { .num = { &tc.v_mask, OPT_NOWRAP, 0, HV_MASK_MAX, pixels_disp } } },
{ LNG("Horizontal mask","スイヘイマスク"), OPT_AVCONFIG_NUMVALUE, { .num = { &tc.h_mask, OPT_NOWRAP, 0, H_MASK_MAX, pixels_disp } } },
{ LNG("Vertical mask","スイチョクマスク"), OPT_AVCONFIG_NUMVALUE, { .num = { &tc.v_mask, OPT_NOWRAP, 0, V_MASK_MAX, pixels_disp } } },
{ LNG("Mask brightness","マスクアカルサ"), OPT_AVCONFIG_NUMVALUE, { .num = { &tc.mask_br, OPT_NOWRAP, 0, HV_MASK_MAX_BR, value_disp } } },
{ LNG("Reverse LPF","ギャクLPF"), OPT_AVCONFIG_NUMVALUE, { .num = { &tc.reverse_lpf, OPT_NOWRAP, 0, REVERSE_LPF_MAX, value_disp } } },
{ LNG("<DIY lat. test>","DIYチエンテスト"), OPT_FUNC_CALL, { .fun = { latency_test, &lt_arg_info } } },
@@ -177,6 +178,7 @@ MENU(menu_settings, P99_PROTECT({ \
{ 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) } } },
{ "LCD BL timeout", OPT_AVCONFIG_SELECTION, { .sel = { &lcd_bl_timeout, OPT_WRAP, SETTING_ITEM(lcd_bl_timeout_desc) } } },
{ LNG("<Fw. update >","<ファームウェアアップデート>"), OPT_FUNC_CALL, { .fun = { fw_update, NULL } } },
}))

View File

@@ -33,6 +33,7 @@ extern alt_u8 update_cur_vm;
extern alt_u8 input_profiles[AV_LAST];
extern alt_u8 profile_sel;
extern alt_u8 def_input, profile_link;
extern alt_u8 lcd_bl_timeout;
int write_userdata(alt_u8 entry)
{
@@ -60,6 +61,7 @@ int write_userdata(alt_u8 entry)
((ude_initcfg*)databuf)->last_input = target_input;
((ude_initcfg*)databuf)->def_input = def_input;
((ude_initcfg*)databuf)->profile_link = profile_link;
((ude_initcfg*)databuf)->lcd_bl_timeout = lcd_bl_timeout;
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)
@@ -146,6 +148,7 @@ int read_userdata(alt_u8 entry)
target_input = ((ude_initcfg*)databuf)->last_input;
profile_link = ((ude_initcfg*)databuf)->profile_link;
profile_sel = input_profiles[AV_TESTPAT]; // Global profile
lcd_bl_timeout = ((ude_initcfg*)databuf)->lcd_bl_timeout;
memcpy(rc_keymap, ((ude_initcfg*)databuf)->keys, sizeof(rc_keymap));
printf("RC data read (%u bytes)\n", sizeof(rc_keymap));
}

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.
//
@@ -50,6 +50,7 @@ typedef struct {
alt_u8 profile_link;
avinput_t last_input;
avinput_t def_input;
alt_u8 lcd_bl_timeout;
alt_u16 keys[REMOTE_MAX_KEYS];
} __attribute__((packed, __may_alias__)) ude_initcfg;