tvp7002: optimize CP current adjustment

Adjust charge pump current based on the number of pixels
ultimately extracted from a line which can be less than
sample rate. This seems to result in reduced jitter
on optimized modes.
This commit is contained in:
marqs 2024-06-01 12:39:08 +03:00
parent 1ba1779632
commit b45e0fb517
2 changed files with 6 additions and 6 deletions

View File

@ -268,7 +268,7 @@ void tvp_set_gain_offset(color_setup_t *col) {
}
// Configure H-PLL (sampling rate, VCO gain and charge pump current)
void tvp_setup_hpll(alt_u16 h_samplerate, alt_u16 refclks_per_line, alt_u8 plldivby2)
void tvp_setup_hpll(alt_u16 h_samplerate, alt_u16 pixs_per_line, alt_u16 refclks_per_line, alt_u8 plldivby2)
{
alt_u32 pclk_est;
alt_u8 vco_range;
@ -303,7 +303,7 @@ void tvp_setup_hpll(alt_u16 h_samplerate, alt_u16 refclks_per_line, alt_u8 plldi
vco_range = 3;
}
cp_current = (40*Kvco[vco_range]+h_samplerate/2) / h_samplerate; //"+h_samplerate/2" for fast rounding
cp_current = (40*Kvco[vco_range]+pixs_per_line/2) / pixs_per_line; //"+pixs_per_line/2" for fast rounding
if (cp_current > 7)
cp_current = 7;
@ -375,7 +375,7 @@ void tvp_set_alcfilt(alt_u8 nsv, alt_u8 nsh) {
tvp_writereg(TVP_ALCFILT, (nsv<<3)|nsh);
}
void tvp_source_setup(video_type type, alt_u16 h_samplerate, alt_u16 refclks_per_line, alt_u8 plldivby2, alt_u8 h_synclen_px, alt_8 clamp_user_offset)
void tvp_source_setup(video_type type, alt_u16 h_samplerate, alt_u16 pixs_per_line, alt_u16 refclks_per_line, alt_u8 plldivby2, alt_u8 h_synclen_px, alt_8 clamp_user_offset)
{
// Due to short MVS width, clamp reference starts prematurely (at the end of MVS window). Adjust offset so that reference moves back to hsync trailing edge.
alt_u8 clamp_ref_offset = h_synclen_px - (((30*h_samplerate)/refclks_per_line)+5)/10;
@ -399,7 +399,7 @@ void tvp_source_setup(video_type type, alt_u16 h_samplerate, alt_u16 refclks_per
break;
}
tvp_setup_hpll(h_samplerate, refclks_per_line, plldivby2);
tvp_setup_hpll(h_samplerate, pixs_per_line, refclks_per_line, plldivby2);
}
void tvp_source_sel(tvp_input_t input, tvp_sync_input_t syncinput, video_format fmt)

View File

@ -98,7 +98,7 @@ void tvp_init();
void tvp_set_gain_offset(color_setup_t *col);
void tvp_setup_hpll(alt_u16 h_samplerate, alt_u16 refclks_per_line, alt_u8 plldivby2);
void tvp_setup_hpll(alt_u16 h_samplerate, alt_u16 pixs_per_line, alt_u16 refclks_per_line, alt_u8 plldivby2);
void tvp_sel_csc(const ypbpr_to_rgb_csc_t *csc);
@ -114,7 +114,7 @@ void tvp_set_sog_thold(alt_u8 val);
void tvp_set_alcfilt(alt_u8 nsv, alt_u8 nsh);
void tvp_source_setup(video_type type, alt_u16 h_samplerate, alt_u16 refclks_per_line, alt_u8 plldivby2, alt_u8 h_synclen_px, alt_8 clamp_user_offset);
void tvp_source_setup(video_type type, alt_u16 h_samplerate, alt_u16 pixs_per_line, alt_u16 refclks_per_line, alt_u8 plldivby2, alt_u8 h_synclen_px, alt_8 clamp_user_offset);
void tvp_source_sel(tvp_input_t input, tvp_sync_input_t syncinput, video_format fmt);