atv_demod: Add audio carrier offset detect [1/1]
authornengwen.chen <nengwen.chen@amlogic.com>
Mon, 25 Feb 2019 02:10:27 +0000 (10:10 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Tue, 26 Feb 2019 05:31:11 +0000 (21:31 -0800)
PD#TV-2564

Problem:
Torture room teset report SND0810 sound carrier deviation

Solution:
Add audio carrier offset detect

Verify:
verified by x301

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

index 551ef3b..6535e09 100644 (file)
@@ -57,6 +57,7 @@
        DEBUGFS_CREATE_NODE(over_threshold, 0640, dentry, u64)\
        DEBUGFS_CREATE_NODE(input_amplitude, 0640, dentry, u64)\
        DEBUGFS_CREATE_NODE(atvaudio_det_outputmode_en, 0640, dentry, bool)\
+       DEBUGFS_CREATE_NODE(audio_carrier_offset_det_en, 0640, dentry, bool)\
        DEBUGFS_CREATE_NODE(audio_det_en, 0640, dentry, bool)\
        DEBUGFS_CREATE_NODE(non_std_en, 0640, dentry, u32)\
        DEBUGFS_CREATE_NODE(atvdemod_det_nonstd_en, 0640, dentry, bool)\
index 240a043..0ebc929 100644 (file)
@@ -34,6 +34,7 @@ bool atvdemod_det_snr_en = true;
 bool audio_thd_en = true;
 bool atvdemod_det_nonstd_en;
 bool atvaudio_det_outputmode_en = true;
+bool audio_carrier_offset_det_en;
 
 unsigned int atvdemod_timer_delay = 100; /* 1s */
 unsigned int atvdemod_timer_delay2 = 10; /* 100ms */
@@ -70,6 +71,9 @@ static void atv_demod_monitor_do_work(struct work_struct *work)
        if (atvaudio_det_outputmode_en)
                atvauddemod_set_outputmode();
 
+       if (audio_carrier_offset_det_en)
+               audio_carrier_offset_det();
+
        if (atvdemod_det_nonstd_en)
                atv_dmd_non_std_set(true);
 }
index 76fea6a..93a3f25 100644 (file)
@@ -60,7 +60,12 @@ static int last_mode = -1;
 #undef pr_info
 #define pr_info(args...)\
        do {\
-               if (ademod_debug_en)\
+               if (ademod_debug_en & 0x1)\
+                       printk(args);\
+       } while (0)
+#define pr_carr(args...)\
+       do {\
+               if (ademod_debug_en & 0x2)\
                        printk(args);\
        } while (0)
 #undef pr_dbg
@@ -1469,6 +1474,37 @@ void audio_thd_det(void)
        }
 }
 
+void audio_carrier_offset_det(void)
+{
+       unsigned int carrier_freq = 0, report = 0;
+       int threshold = 0;
+
+       report = adec_rd_reg(DC_REPORT);
+       carrier_freq = adec_rd_reg(ADDR_DDC_FREQ0);
+
+       pr_carr("\n\nreport: 0x%x.\n", report);
+       pr_carr("read carrier_freq: 0x%x.\n", carrier_freq);
+       report = report & 0xFFFF;
+
+       if (report > (1 << 15))
+               threshold = report - (1 << 16);
+       else
+               threshold = report;
+
+       threshold = threshold >> 8;
+       pr_carr("threshold: %d.\n", threshold);
+
+       if (threshold > 30) {
+               carrier_freq = carrier_freq - 0x100;
+               adec_wr_reg(ADDR_DDC_FREQ0, carrier_freq);
+       } else if (threshold < -30) {
+               carrier_freq = carrier_freq + 0x100;
+               adec_wr_reg(ADDR_DDC_FREQ0, carrier_freq);
+       }
+
+       pr_carr("write carrier_freq: 0x%x.\n", carrier_freq);
+}
+
 void set_outputmode_status_init(void)
 {
        last_nicam_lock = -1;
index 361b556..c71037f 100644 (file)
@@ -32,6 +32,7 @@ void configure_adec(int Audio_mode);
 void adec_soft_reset(void);
 void audio_thd_init(void);
 void audio_thd_det(void);
+void audio_carrier_offset_det(void);
 void set_nicam_outputmode(uint32_t outmode);
 void set_a2_eiaj_outputmode(uint32_t outmode);
 void set_btsc_outputmode(uint32_t outmode);