diff --git a/drivers/amlogic/atv_demod/atv_demod_debug.c b/drivers/amlogic/atv_demod/atv_demod_debug.c index 7e66331b99ee..e00cf71dba2d 100644 --- a/drivers/amlogic/atv_demod/atv_demod_debug.c +++ b/drivers/amlogic/atv_demod/atv_demod_debug.c @@ -104,6 +104,7 @@ DEBUGFS_CREATE_NODE(atvdemod_isr_en, 0640, dentry, bool)\ DEBUGFS_CREATE_NODE(atv_audio_overmodulated_cnt, 0640, dentry, u32)\ DEBUGFS_CREATE_NODE(support_secam_l, 0640, dentry, bool)\ + DEBUGFS_CREATE_NODE(atvdemod_horiz_freq_det_en, 0640, dentry, bool)\ } diff --git a/drivers/amlogic/atv_demod/atv_demod_driver.c b/drivers/amlogic/atv_demod/atv_demod_driver.c index e56b3608ad05..b7aadef5afe1 100644 --- a/drivers/amlogic/atv_demod/atv_demod_driver.c +++ b/drivers/amlogic/atv_demod/atv_demod_driver.c @@ -44,8 +44,10 @@ #include "atvdemod_func.h" #include "atvauddemod_func.h" - -#define AMLATVDEMOD_VER "V2.14" +/********************************CODE CHANGE LIST*****************************/ +/* Date --- Version --- Note *************************************************/ +/* 2019/11/05 --- V2.15 --- Add dynamic monitoring line frequency deviation. */ +#define AMLATVDEMOD_VER "V2.15" struct aml_atvdemod_device *amlatvdemod_devp; diff --git a/drivers/amlogic/atv_demod/atv_demod_monitor.c b/drivers/amlogic/atv_demod/atv_demod_monitor.c index 4969acb20d8a..5a6e13a8818e 100644 --- a/drivers/amlogic/atv_demod/atv_demod_monitor.c +++ b/drivers/amlogic/atv_demod/atv_demod_monitor.c @@ -37,6 +37,7 @@ bool audio_thd_en; bool atvdemod_det_nonstd_en; bool atvaudio_det_outputmode_en = true; bool audio_carrier_offset_det_en; +bool atvdemod_horiz_freq_det_en = true; unsigned int atvdemod_timer_delay = 100; /* 1s */ unsigned int atvdemod_timer_delay2 = 10; /* 100ms */ @@ -87,6 +88,9 @@ static void atv_demod_monitor_do_work(struct work_struct *work) if (atvdemod_det_nonstd_en) atv_dmd_non_std_set(true); + + if (atvdemod_horiz_freq_det_en) + atvdemod_horiz_freq_detection(); } static void atv_demod_monitor_timer_handler(unsigned long arg) diff --git a/drivers/amlogic/atv_demod/atvdemod_func.c b/drivers/amlogic/atv_demod/atvdemod_func.c index 56bfd7e8c86e..78e6f8b6dc6f 100644 --- a/drivers/amlogic/atv_demod/atvdemod_func.c +++ b/drivers/amlogic/atv_demod/atvdemod_func.c @@ -2545,3 +2545,45 @@ void aml_audio_overmodulation(int enable) #endif } } + +void atvdemod_horiz_freq_detection(void) +{ + unsigned long data = 0; + int field_lock = 0; + int line_lock = 0; + int line = 0; + int std_line = 0; + unsigned long horiz_freq = 0; + + data = atv_dmd_rd_long(APB_BLOCK_ADDR_VDAGC, 0x4c); + field_lock = data & 0x4; /* bit2 */ + line_lock = data & 0x10; /* bit4 */ + line = (data >> 6) & 0x3ff; /* bit[15-6] */ + + switch (broad_std) { + case AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC: + case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M: + std_line = 525; + break; + default: + std_line = 625; + break; + } + + if (field_lock == 0 && line_lock == 0) { + /* bit[31-8] */ + data = atv_dmd_rd_long(APB_BLOCK_ADDR_VDAGC, 0x10); + + /* fh +/- (200 / 0.23841858) */ + if ((line - std_line) > 7) + horiz_freq = freq_hz_cvrt + 0x347; + else if ((line - std_line) < -7) + horiz_freq = freq_hz_cvrt - 0x347; + else + horiz_freq = freq_hz_cvrt; + + data = (horiz_freq << 8) | (data & 0xff); + + atv_dmd_wr_long(APB_BLOCK_ADDR_VDAGC, 0x10, data); + } +} diff --git a/drivers/amlogic/atv_demod/atvdemod_func.h b/drivers/amlogic/atv_demod/atvdemod_func.h index 87e73f34b9a1..c8f2f0caaf43 100644 --- a/drivers/amlogic/atv_demod/atvdemod_func.h +++ b/drivers/amlogic/atv_demod/atvdemod_func.h @@ -215,6 +215,7 @@ extern void set_atvdemod_scan_mode(int val); extern int atvauddemod_init(void); extern int amlfmt_aud_standard(int broad_std); extern void atvauddemod_set_outputmode(void); +void atvdemod_horiz_freq_detection(void); /*from amldemod/amlfrontend.c*/ extern int vdac_enable_check_dtv(void);