mirror of
https://github.com/marqs85/ossc
synced 2026-11-11 09:23:12 +03:00
tweak activity detection to fix auto input
This commit is contained in:
1 parent
e49106b635
commit
10f1afd79c
8 files changed
+8075
-8069
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -294,8 +294,8 @@ inline int check_linecnt(alt_u8 progressive, alt_u32 totlines) {
|
||||
// Check if input video status / target configuration has changed
|
||||
status_t get_status(tvp_sync_input_t syncinput)
|
||||
{
|
||||
alt_u32 totlines, clkcnt, pcnt_frame;
|
||||
alt_u8 progressive, sync_active, valid_linecnt, hsync_width;
|
||||
alt_u32 totlines, clkcnt, pcnt_field;
|
||||
alt_u8 progressive, sync_active, valid_mode, hsync_width;
|
||||
status_t status = NO_CHANGE;
|
||||
alt_timestamp_type start_ts = alt_timestamp();
|
||||
|
||||
@@ -305,34 +305,32 @@ status_t get_status(tvp_sync_input_t syncinput)
|
||||
break;
|
||||
}
|
||||
|
||||
//sync_active = tvp_check_sync(syncinput);
|
||||
sync_active = sc->fe_status.sync_active;
|
||||
|
||||
// Read sync information from TVP7002 frontend
|
||||
sync_active = sc->fe_status.sync_active;
|
||||
totlines = sc->fe_status.vtotal;
|
||||
progressive = !sc->fe_status.interlace_flag;
|
||||
pcnt_frame = (unsigned long)sc->fe_status2.pcnt_frame;
|
||||
pcnt_field = (unsigned long)sc->fe_status2.pcnt_field;
|
||||
hsync_width = (unsigned long)sc->fe_status2.hsync_width;
|
||||
clkcnt = pcnt_frame/(totlines>>!progressive);
|
||||
|
||||
valid_linecnt = check_linecnt(progressive, totlines);
|
||||
clkcnt = pcnt_field/(totlines>>!progressive);
|
||||
valid_mode = (pcnt_field > 0) && check_linecnt(progressive, totlines);
|
||||
|
||||
// Check sync activity
|
||||
if (!cm.sync_active && sync_active && valid_linecnt) {
|
||||
if (!cm.sync_active && sync_active && valid_mode) {
|
||||
cm.sync_active = 1;
|
||||
status = ACTIVITY_CHANGE;
|
||||
} else if (cm.sync_active && (!sync_active || !valid_linecnt)) {
|
||||
} else if (cm.sync_active && (!sync_active || !valid_mode)) {
|
||||
cm.sync_active = 0;
|
||||
status = ACTIVITY_CHANGE;
|
||||
}
|
||||
|
||||
if (valid_linecnt) {
|
||||
if (sync_active && valid_mode) {
|
||||
if ((totlines != cm.totlines) ||
|
||||
(progressive != cm.progressive) ||
|
||||
(pcnt_frame < (cm.pcnt_frame - PCNT_TOLERANCE)) ||
|
||||
(pcnt_frame > (cm.pcnt_frame + PCNT_TOLERANCE)) ||
|
||||
(pcnt_field < (cm.pcnt_field - PCNT_TOLERANCE)) ||
|
||||
(pcnt_field > (cm.pcnt_field + PCNT_TOLERANCE)) ||
|
||||
(abs(((int)hsync_width - (int)cm.hsync_width)) > HSYNC_WIDTH_TOLERANCE)) {
|
||||
printf("totlines: %lu (cur) / %lu (prev), pcnt_frame: %lu (cur) / %lu (prev), hsync_width: %lu (cur) / %lu (prev)\n", totlines, cm.totlines, pcnt_frame, cm.pcnt_frame, hsync_width, cm.hsync_width);
|
||||
printf("totlines: %lu (cur) / %lu (prev), pcnt_field: %lu (cur) / %lu (prev), hsync_width: %lu (cur) / %lu (prev)\n", totlines, cm.totlines, pcnt_field, cm.pcnt_field, hsync_width, cm.hsync_width);
|
||||
|
||||
status = (status < MODE_CHANGE) ? MODE_CHANGE : status;
|
||||
}
|
||||
@@ -345,7 +343,7 @@ status_t get_status(tvp_sync_input_t syncinput)
|
||||
|
||||
cm.totlines = totlines;
|
||||
cm.clkcnt = clkcnt;
|
||||
cm.pcnt_frame = pcnt_frame;
|
||||
cm.pcnt_field = pcnt_field;
|
||||
cm.hsync_width = hsync_width;
|
||||
cm.progressive = progressive;
|
||||
}
|
||||
@@ -541,8 +539,8 @@ void program_mode()
|
||||
|
||||
memset(&vmode_in, 0, sizeof(mode_data_t));
|
||||
|
||||
vmode_in.timings.v_hz_x100 = (100*27000000UL)/cm.pcnt_frame;
|
||||
h_hz = (100*27000000UL)/((100*cm.pcnt_frame*(1+!cm.progressive))/cm.totlines);
|
||||
vmode_in.timings.v_hz_x100 = (100*27000000UL)/cm.pcnt_field;
|
||||
h_hz = (100*27000000UL)/((100*cm.pcnt_field*(1+!cm.progressive))/cm.totlines);
|
||||
|
||||
printf("\nLines: %u %c\n", (unsigned)cm.totlines, cm.progressive ? 'p' : 'i');
|
||||
printf("Clocks per line: %u\n", (unsigned)cm.clkcnt);
|
||||
@@ -941,7 +939,7 @@ int main()
|
||||
printf("### DIY VIDEO DIGITIZER / SCANCONVERTER INIT OK ###\n\n");
|
||||
sniprintf(row1, LCD_ROW_LEN+1, "OSSC fw. %u.%.2u" FW_SUFFIX1 FW_SUFFIX2, FW_VER_MAJOR, FW_VER_MINOR);
|
||||
#ifndef DEBUG
|
||||
strncpy(row2, "2014-2023 marqs", LCD_ROW_LEN+1);
|
||||
strncpy(row2, "2014-2024 marqs", LCD_ROW_LEN+1);
|
||||
#else
|
||||
strncpy(row2, "** DEBUG BUILD *", LCD_ROW_LEN+1);
|
||||
#endif
|
||||
@@ -1123,6 +1121,9 @@ int main()
|
||||
auto_input_ctr = 0;
|
||||
auto_input_timestamp = alt_timestamp();
|
||||
}
|
||||
// Avoid detection of initial vsync pulses after auto mode switch
|
||||
if (auto_input_changed)
|
||||
usleep(120000);
|
||||
}
|
||||
|
||||
// Check here to enable regardless of input
|
||||
|
||||
@@ -76,7 +76,7 @@ typedef struct {
|
||||
//TODO: transform binary values into flags
|
||||
typedef struct {
|
||||
alt_u32 totlines;
|
||||
alt_u32 pcnt_frame;
|
||||
alt_u32 pcnt_field;
|
||||
alt_u32 hsync_width;
|
||||
alt_u32 clkcnt;
|
||||
alt_u8 progressive;
|
||||
|
||||
@@ -185,8 +185,8 @@ int parse_control()
|
||||
case RC_SL_TYPE:
|
||||
tc.sl_type = (tc.sl_type < SL_TYPE_MAX) ? (tc.sl_type + 1) : 0;
|
||||
if (!menu_active) {
|
||||
strncpy((char*)osd->osd_array.data[0][0], menu_scanlines.items[5].name, OSD_CHAR_COLS);
|
||||
strncpy((char*)osd->osd_array.data[1][0], menu_scanlines.items[5].sel.setting_str[tc.sl_type], OSD_CHAR_COLS);
|
||||
strncpy((char*)osd->osd_array.data[0][0], menu_scanlines.items[6].name, OSD_CHAR_COLS);
|
||||
strncpy((char*)osd->osd_array.data[1][0], menu_scanlines.items[6].sel.setting_str[tc.sl_type], OSD_CHAR_COLS);
|
||||
osd->osd_config.status_refresh = 1;
|
||||
osd->osd_row_color.mask = 0;
|
||||
osd->osd_sec_enable[0].mask = 3;
|
||||
@@ -265,7 +265,7 @@ int parse_control()
|
||||
set_sampler_phase(video_modes_plm[cm.id].sampler_phase, 1);
|
||||
|
||||
if (!menu_active) {
|
||||
strncpy((char*)osd->osd_array.data[0][0], menu_advtiming.items[8].name, OSD_CHAR_COLS);
|
||||
strncpy((char*)osd->osd_array.data[0][0], menu_advtiming.items[10].name, OSD_CHAR_COLS);
|
||||
sampler_phase_disp(video_modes_plm[cm.id].sampler_phase);
|
||||
strncpy((char*)osd->osd_array.data[1][0], menu_row2, OSD_CHAR_COLS);
|
||||
osd->osd_config.status_refresh = 1;
|
||||
|
||||
@@ -304,8 +304,8 @@ void tvp_setup_hpll(alt_u16 h_samplerate, alt_u16 pixs_per_line, alt_u16 refclks
|
||||
}
|
||||
|
||||
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;
|
||||
if (cp_current > 6)
|
||||
cp_current = 6;
|
||||
|
||||
printf("VCO range: %s\nCPC: %u\n", Kvco_str[vco_range], cp_current);
|
||||
tvp_writereg(TVP_HPLLCTRL, ((vco_range << 6) | (cp_current << 3)));
|
||||
|
||||
Reference in new issue
Block a user