1
0
mirror of https://github.com/marqs85/ossc.git synced 2024-06-08 18:29:30 +00:00

fix applying of power-on default settings

This commit is contained in:
marqs 2018-04-13 01:24:34 +03:00
parent 37650ca22b
commit dcd3d14a53
5 changed files with 50 additions and 39 deletions

View File

@ -61,7 +61,7 @@ extern alt_u16 rc_keymap_default[REMOTE_MAX_KEYS];
extern alt_u32 remote_code; extern alt_u32 remote_code;
extern alt_u32 btn_code, btn_code_prev; extern alt_u32 btn_code, btn_code_prev;
extern alt_u8 remote_rpt, remote_rpt_prev; extern alt_u8 remote_rpt, remote_rpt_prev;
extern avconfig_t tc; extern avconfig_t tc, tc_default;
alt_u8 target_typemask; alt_u8 target_typemask;
alt_u8 target_type; alt_u8 target_type;
@ -338,7 +338,7 @@ status_t get_status(tvp_input_t input, video_format format)
if (tc.sync_lpf != cm.cc.sync_lpf) if (tc.sync_lpf != cm.cc.sync_lpf)
tvp_set_sync_lpf(tc.sync_lpf); tvp_set_sync_lpf(tc.sync_lpf);
if (!memcmp(&tc.col, &cm.cc.col, sizeof(color_setup_t))) if (memcmp(&tc.col, &cm.cc.col, sizeof(color_setup_t)))
tvp_set_fine_gain_offset(&cm.cc.col); tvp_set_fine_gain_offset(&cm.cc.col);
#ifdef ENABLE_AUDIO #ifdef ENABLE_AUDIO
@ -520,10 +520,7 @@ void program_mode()
cm.sample_mult*video_modes[cm.id].h_total, cm.sample_mult*video_modes[cm.id].h_total,
cm.clkcnt, cm.clkcnt,
cm.cc.tvp_hpll2x && (video_modes[cm.id].flags & MODE_PLLDIVBY2), cm.cc.tvp_hpll2x && (video_modes[cm.id].flags & MODE_PLLDIVBY2),
(alt_u8)h_synclen_px, (alt_u8)h_synclen_px);
cm.cc.pre_coast,
cm.cc.post_coast,
cm.cc.vsync_thold);
set_lpf(cm.cc.video_lpf); set_lpf(cm.cc.video_lpf);
cm.sample_sel = tvp_set_hpll_phase(cm.cc.sampler_phase, cm.sample_mult); cm.sample_sel = tvp_set_hpll_phase(cm.cc.sampler_phase, cm.sample_mult);
@ -676,6 +673,7 @@ int init_hw()
// Set defaults // Set defaults
set_default_avconfig(); set_default_avconfig();
memcpy(&cm.cc, &tc_default, sizeof(avconfig_t));
memcpy(rc_keymap, rc_keymap_default, sizeof(rc_keymap)); memcpy(rc_keymap, rc_keymap_default, sizeof(rc_keymap));
// Load initconfig and profile // Load initconfig and profile

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. // This file is part of Open Source Scan Converter project.
// //
@ -25,13 +25,6 @@
#include "tvp7002.h" #include "tvp7002.h"
#define DEFAULT_ON 1 #define DEFAULT_ON 1
#define DEFAULT_PRE_COAST 1
#define DEFAULT_POST_COAST 0
#define DEFAULT_SAMPLER_PHASE 16
#define DEFAULT_SYNC_LPF 3
#define DEFAULT_SYNC_VTH 11
#define DEFAULT_FINE_GAIN 26
#define DEFAULT_FINE_OFFSET 0x80
extern mode_data_t video_modes[], video_modes_default[]; extern mode_data_t video_modes[], video_modes_default[];
extern alt_u8 update_cur_vm; extern alt_u8 update_cur_vm;
@ -46,7 +39,7 @@ const avconfig_t tc_default = {
.pm_384p = 1, .pm_384p = 1,
.pm_480i = 1, .pm_480i = 1,
.pm_1080i = 1, .pm_1080i = 1,
.tvp_hpll2x = 1, .tvp_hpll2x = DEFAULT_ON,
.sampler_phase = DEFAULT_SAMPLER_PHASE, .sampler_phase = DEFAULT_SAMPLER_PHASE,
.sync_vth = DEFAULT_SYNC_VTH, .sync_vth = DEFAULT_SYNC_VTH,
.linelen_tol = DEFAULT_LINELEN_TOL, .linelen_tol = DEFAULT_LINELEN_TOL,

View File

@ -49,7 +49,7 @@ static const char *off_on_desc[] = { LNG("Off","オフ"), LNG("On","オン") };
static const char *video_lpf_desc[] = { LNG("Auto","オート"), LNG("Off","オフ"), "95MHz (HDTV II)", "35MHz (HDTV I)", "16MHz (EDTV)", "9MHz (SDTV)" }; static const char *video_lpf_desc[] = { LNG("Auto","オート"), LNG("Off","オフ"), "95MHz (HDTV II)", "35MHz (HDTV I)", "16MHz (EDTV)", "9MHz (SDTV)" };
static const char *ypbpr_cs_desc[] = { "Rec. 601", "Rec. 709" }; static const char *ypbpr_cs_desc[] = { "Rec. 601", "Rec. 709" };
static const char *s480p_mode_desc[] = { LNG("Auto","オート"), "DTV 480p", "VESA 640x480@60" }; static const char *s480p_mode_desc[] = { LNG("Auto","オート"), "DTV 480p", "VESA 640x480@60" };
static const char *sync_lpf_desc[] = { LNG("Off","オフ"), LNG("33MHz (min)","33MHz (サイショウ)"), LNG("10MHz (med)","10MHz (チュウイ)"), LNG("2.5MHz (max)","2.5MHz (サイダイ)") }; static const char *sync_lpf_desc[] = { LNG("2.5MHz (max)","2.5MHz (サイダイ)"), LNG("10MHz (med)","10MHz (チュウイ)"), LNG("33MHz (min)","33MHz (サイショウ)"), LNG("Off","オフ") };
static const char *l3_mode_desc[] = { LNG("Generic 16:9","ジェネリック 16:9"), LNG("Generic 4:3","ジェネリック 4:3"), LNG("320x240 optim.","320x240 サイテキカ."), LNG("256x240 optim.","256x240 サイテキカ.") }; static const char *l3_mode_desc[] = { LNG("Generic 16:9","ジェネリック 16:9"), LNG("Generic 4:3","ジェネリック 4:3"), LNG("320x240 optim.","320x240 サイテキカ."), LNG("256x240 optim.","256x240 サイテキカ.") };
static const char *l2l4l5_mode_desc[] = { LNG("Generic 4:3","ジェネリック 4:3"), LNG("320x240 optim.","320x240 サイテキカ."), LNG("256x240 optim.","256x240 サイテキカ.") }; static const char *l2l4l5_mode_desc[] = { LNG("Generic 4:3","ジェネリック 4:3"), LNG("320x240 optim.","320x240 サイテキカ."), LNG("256x240 optim.","256x240 サイテキカ.") };
static const char *l5_fmt_desc[] = { "1920x1080", "1600x1200", "1920x1200" }; static const char *l5_fmt_desc[] = { "1920x1080", "1600x1200", "1920x1200" };

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. // This file is part of Open Source Scan Converter project.
// //
@ -43,19 +43,21 @@ static const char *Kvco_str[] = { "Ultra low", "Low", "Medium", "High" };
static void tvp_set_clamp(video_format fmt) static void tvp_set_clamp(video_format fmt)
{ {
alt_u8 status = tvp_readreg(TVP_SOGTHOLD) & 0xF8;
switch (fmt) { switch (fmt) {
case FORMAT_YPbPr: case FORMAT_YPbPr:
//select mid clamp for Pb & Pr //select mid clamp for Pb & Pr
tvp_writereg(TVP_SOGTHOLD, 0x5D); status |= 0x5;
break; break;
case FORMAT_RGBS: case FORMAT_RGBS:
case FORMAT_RGBHV: case FORMAT_RGBHV:
case FORMAT_RGsB: case FORMAT_RGsB:
default: default:
//select bottom clamp (RGB) //select bottom clamp (RGB)
tvp_writereg(TVP_SOGTHOLD, 0x58);
break; break;
} }
tvp_writereg(TVP_SOGTHOLD, status);
} }
static void tvp_set_clamp_position(video_type type, alt_u8 h_syncinlen) static void tvp_set_clamp_position(video_type type, alt_u8 h_syncinlen)
@ -142,10 +144,19 @@ inline void tvp_set_ssthold(alt_u8 vsdetect_thold)
void tvp_init() void tvp_init()
{ {
color_setup_t def_gain_offs = {
.r_f_gain = DEFAULT_FINE_GAIN,
.g_f_gain = DEFAULT_FINE_GAIN,
.b_f_gain = DEFAULT_FINE_GAIN,
.r_f_off = DEFAULT_FINE_OFFSET,
.g_f_off = DEFAULT_FINE_OFFSET,
.b_f_off = DEFAULT_FINE_OFFSET,
};
// disable output // disable output
tvp_disable_output(); tvp_disable_output();
//Set global defaults // Set default configuration (skip those which match register reset values)
// Configure external refclk // Configure external refclk
tvp_sel_clk(REFCLK_EXT27); tvp_sel_clk(REFCLK_EXT27);
@ -162,11 +173,11 @@ void tvp_init()
tvp_sel_csc(&csc_coeffs[0]); tvp_sel_csc(&csc_coeffs[0]);
// Set default phase // Set default phase
tvp_set_hpll_phase(0x10, 1); //tvp_set_hpll_phase(DEFAULT_SAMPLER_PHASE, 1);
// Set min LPF // Set min video LPF, max sync LPF
tvp_set_lpf(0); //tvp_set_lpf(0);
tvp_set_sync_lpf(0); tvp_set_sync_lpf(DEFAULT_SYNC_LPF);
// Increase line length tolerance // Increase line length tolerance
tvp_set_linelen_tol(DEFAULT_LINELEN_TOL); tvp_set_linelen_tol(DEFAULT_LINELEN_TOL);
@ -177,17 +188,24 @@ void tvp_init()
//tvp_writereg(TVP_OUTFORMAT, 0x0C); //tvp_writereg(TVP_OUTFORMAT, 0x0C);
// Minimize HSYNC window for best sync stability // Minimize HSYNC window for best sync stability
tvp_writereg(TVP_MVSWIDTH, 0x03); //tvp_writereg(TVP_MVSWIDTH, 0x03);
// Common sync separator threshold // Common sync separator threshold
// Some arcade games need more that the default 0x40 // Some arcade games need more that the default 0x40
tvp_set_ssthold(DEFAULT_VSYNC_THOLD); tvp_set_ssthold(DEFAULT_VSYNC_THOLD);
// Analog sync/SoG thresholf
//tvp_set_sog_thold(DEFAULT_SYNC_VTH);
// Default (3,3) coast may lead to PLL jitter and sync loss (e.g. SNES)
tvp_set_hpllcoast(DEFAULT_PRE_COAST, DEFAULT_POST_COAST);
//set analog (coarse) gain to max recommended value (-> 91% of the ADC range with 0.7Vpp input) //set analog (coarse) gain to max recommended value (-> 91% of the ADC range with 0.7Vpp input)
tvp_writereg(TVP_BG_CGAIN, 0x88); tvp_writereg(TVP_BG_CGAIN, 0x88);
tvp_writereg(TVP_R_CGAIN, 0x08); tvp_writereg(TVP_R_CGAIN, 0x08);
//set rest of the gain digitally (fine) to utilize 100% of the range at the output (0.91*(1+(26/256)) = 1) //set rest of the gain digitally (fine) to utilize 100% of the range at the output (0.91*(1+(26/256)) = 1)
tvp_set_fine_gain_offset(&def_gain_offs);
} }
void tvp_set_fine_gain_offset(color_setup_t *col) { void tvp_set_fine_gain_offset(color_setup_t *col) {
@ -293,8 +311,8 @@ void tvp_set_lpf(alt_u8 val)
void tvp_set_sync_lpf(alt_u8 val) void tvp_set_sync_lpf(alt_u8 val)
{ {
alt_u8 status = tvp_readreg(TVP_INPMUX2) & 0x3F; alt_u8 status = tvp_readreg(TVP_INPMUX2) & 0x3F;
tvp_writereg(TVP_INPMUX2, status|((3-val)<<6)); tvp_writereg(TVP_INPMUX2, status|(val<<6));
printf("Sync LPF value set to 0x%x\n", (3-val)); printf("Sync LPF value set to 0x%x\n", val);
} }
alt_u8 tvp_set_hpll_phase(alt_u8 val, alt_u8 sample_mult) alt_u8 tvp_set_hpll_phase(alt_u8 val, alt_u8 sample_mult)
@ -342,14 +360,12 @@ void tvp_set_alc(alt_u8 en_alc, video_type type, alt_u8 h_syncinlen)
} }
} }
void tvp_source_setup(video_type type, alt_u16 h_samplerate, alt_u16 refclks_per_line, alt_u8 plldivby2, alt_u8 h_syncinlen, alt_u8 pre_coast, alt_u8 post_coast, alt_u8 vsync_thold) void tvp_source_setup(video_type type, alt_u16 h_samplerate, alt_u16 refclks_per_line, alt_u8 plldivby2, alt_u8 h_syncinlen)
{ {
// Clamp position and ALC // Clamp position and ALC
tvp_set_clamp_position(type, h_syncinlen); tvp_set_clamp_position(type, h_syncinlen);
tvp_set_alc(1, type, h_syncinlen); tvp_set_alc(1, type, h_syncinlen);
tvp_set_ssthold(vsync_thold);
// Setup Macrovision stripper and H-PLL coast signal. // Setup Macrovision stripper and H-PLL coast signal.
// Coast needs to be enabled when HSYNC is missing during VSYNC. RGBHV mode cannot use it, so turn off the internal signal for this mode. // Coast needs to be enabled when HSYNC is missing during VSYNC. RGBHV mode cannot use it, so turn off the internal signal for this mode.
// Macrovision stripper filters out glitches and serration pulses that may occur outside of sync window (HSYNC_lead +- TVP_MVSWIDTH*37ns). Enabled for all inputs. // Macrovision stripper filters out glitches and serration pulses that may occur outside of sync window (HSYNC_lead +- TVP_MVSWIDTH*37ns). Enabled for all inputs.
@ -367,9 +383,6 @@ void tvp_source_setup(video_type type, alt_u16 h_samplerate, alt_u16 refclks_per
} }
tvp_setup_hpll(h_samplerate, refclks_per_line, plldivby2); tvp_setup_hpll(h_samplerate, refclks_per_line, plldivby2);
// Default (3,3) coast may lead to PLL jitter and sync loss (e.g. SNES)
tvp_set_hpllcoast(pre_coast, post_coast);
} }
void tvp_source_sel(tvp_input_t input, video_format fmt) void tvp_source_sel(tvp_input_t input, video_format fmt)

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. // This file is part of Open Source Scan Converter project.
// //
@ -24,11 +24,18 @@
#include "video_modes.h" #include "video_modes.h"
#include "sysconfig.h" #include "sysconfig.h"
#define DEFAULT_VSYNC_THOLD 0x44 #define DEFAULT_VSYNC_THOLD 0x44
#define DEFAULT_LINELEN_TOL 0x06 #define DEFAULT_LINELEN_TOL 0x06
#define DEFAULT_SAMPLER_PHASE 0x10
#define DEFAULT_PRE_COAST 1
#define DEFAULT_POST_COAST 0
#define DEFAULT_SYNC_LPF 0
#define DEFAULT_SYNC_VTH 0x0B
#define DEFAULT_FINE_GAIN 26
#define DEFAULT_FINE_OFFSET 0x80
#define TVP_INTCLK_HZ 6500000UL #define TVP_INTCLK_HZ 6500000UL
#define TVP_EXTCLK_HZ 27000000UL #define TVP_EXTCLK_HZ 27000000UL
typedef enum { typedef enum {
TVP_INPUT1 = 0, TVP_INPUT1 = 0,
@ -100,7 +107,7 @@ void tvp_set_sog_thold(alt_u8 val);
void tvp_set_alc(alt_u8 en_alc, video_type type, alt_u8 h_syncinlen); void tvp_set_alc(alt_u8 en_alc, video_type type, alt_u8 h_syncinlen);
void tvp_source_setup(video_type type, alt_u16 h_samplerate, alt_u16 refclks_per_line, alt_u8 plldivby2, alt_u8 h_syncinlen, alt_u8 pre_coast, alt_u8 post_coast, alt_u8 vsync_thold); void tvp_source_setup(video_type type, alt_u16 h_samplerate, alt_u16 refclks_per_line, alt_u8 plldivby2, alt_u8 h_syncinlen);
void tvp_source_sel(tvp_input_t input, video_format fmt); void tvp_source_sel(tvp_input_t input, video_format fmt);