Add video Pre-ADC gain setting

This commit is contained in:
paulb-nl committed 2018-04-16 12:21:31 +02:00
1 parent 70ab55c1fa
commit 5dd9f65bc6
6 files changed
+14 -7

No files matched your search

+6 -5
View File
@@ -151,6 +151,7 @@ void tvp_init()
.r_f_off = DEFAULT_FINE_OFFSET,
.g_f_off = DEFAULT_FINE_OFFSET,
.b_f_off = DEFAULT_FINE_OFFSET,
.c_gain = DEFAULT_COARSE_GAIN,
};
// disable output
@@ -201,20 +202,20 @@ void tvp_init()
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)
tvp_writereg(TVP_BG_CGAIN, 0x88);
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)
tvp_set_fine_gain_offset(&def_gain_offs);
tvp_set_gain_offset(&def_gain_offs);
}
void tvp_set_fine_gain_offset(color_setup_t *col) {
void tvp_set_gain_offset(color_setup_t *col) {
tvp_writereg(TVP_BG_CGAIN, ((col->c_gain << 4) | (col->c_gain & 0xF)));
tvp_writereg(TVP_R_CGAIN, col->c_gain);
tvp_writereg(TVP_R_FGAIN, col->r_f_gain);
tvp_writereg(TVP_G_FGAIN, col->g_f_gain);
tvp_writereg(TVP_B_FGAIN, col->b_f_gain);
tvp_writereg(TVP_R_FOFFSET_MSB, col->r_f_off);
tvp_writereg(TVP_G_FOFFSET_MSB, col->g_f_off);
tvp_writereg(TVP_B_FOFFSET_MSB, col->b_f_off);
}
// Configure H-PLL (sampling rate, VCO gain and charge pump current)
+3 -1
View File
@@ -33,6 +33,7 @@
#define DEFAULT_SYNC_VTH 0x0B
#define DEFAULT_FINE_GAIN 26
#define DEFAULT_FINE_OFFSET 0x80
#define DEFAULT_COARSE_GAIN 0x8
#define TVP_INTCLK_HZ 6500000UL
#define TVP_EXTCLK_HZ 27000000UL
@@ -68,6 +69,7 @@ typedef struct {
alt_u8 r_f_gain;
alt_u8 g_f_gain;
alt_u8 b_f_gain;
alt_u8 c_gain;
} __attribute__((packed)) color_setup_t;
@@ -89,7 +91,7 @@ inline void tvp_set_ssthold(alt_u8 vsdetect_thold);
void tvp_init();
void tvp_set_fine_gain_offset(color_setup_t *col);
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);