atv_demod: fix atv audio no output when line frequency offset over default [1/1]
authornengwen.chen <nengwen.chen@amlogic.com>
Fri, 1 Nov 2019 13:09:23 +0000 (21:09 +0800)
committerNengwen Chen <nengwen.chen@amlogic.com>
Wed, 6 Nov 2019 01:58:53 +0000 (18:58 -0700)
PD#SWPL-16188, PD#TV-11641, PD#TV-10181, PD#TV-9714

Problem:
fix atv audio no output when line frequency offset over 200Hz.

Solution:
1.fix atv audio no output when line frequency offset over 200Hz.
2.atv demod version: [V2.15].

Verify:
verified by tl1.

Change-Id: Ic43c707d3401ea93909856ff83a6842e14f0fc61
Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
drivers/amlogic/atv_demod/atv_demod_debug.c
drivers/amlogic/atv_demod/atv_demod_driver.c
drivers/amlogic/atv_demod/atv_demod_monitor.c
drivers/amlogic/atv_demod/atvdemod_func.c
drivers/amlogic/atv_demod/atvdemod_func.h

index 7e66331..e00cf71 100644 (file)
        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)\
 }
 
 
index e56b360..b7aadef 100644 (file)
 #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;
 
index 4969acb..5a6e13a 100644 (file)
@@ -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)
index 56bfd7e..78e6f8b 100644 (file)
@@ -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);
+       }
+}
index 87e73f3..c8f2f0c 100644 (file)
@@ -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);