atv_demod: add nicam detection when current signal fm-mono change to nicam [1/1]
authornengwen.chen <nengwen.chen@amlogic.com>
Wed, 3 Jul 2019 04:13:19 +0000 (12:13 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Tue, 9 Jul 2019 11:08:02 +0000 (04:08 -0700)
PD#TV-7335

Problem:
add nicam detection when current signal fm-mono change to nicam.

Solution:
1.add nicam detection when current signal fm-mono change to nicam.

Verify:
Verified by x301

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

index eaec1c1ad506d49a1e5b50b64df0c8dd29757405..e25fb28f7b4b8eb88639f06877a129fb3e7ec495 100644 (file)
@@ -1100,6 +1100,17 @@ void update_btsc_mode(int auto_en, int *stereo_flag, int *sap_flag)
 
 }
 
+int get_nicam_lock_status(void)
+{
+       uint32_t reg_value = 0;
+
+       reg_value = adec_rd_reg(NICAM_LEVEL_REPORT);
+
+       pr_info("%s nicam_lock:%d\n", __func__, ((reg_value >> 28) & 1));
+
+       return ((reg_value >> 28) & 1);
+}
+
 void update_nicam_mode(int *nicam_flag, int *nicam_mono_flag,
                int *nicam_stereo_flag, int *nicam_dual_flag)
 {
@@ -1545,6 +1556,18 @@ void set_outputmode(uint32_t standard, uint32_t outmode)
                        adec_wr_reg(DUAL_DET_THD, 0x4000);
                }
 
+               /* for FM MONO system to detection nicam status */
+               if (!aud_reinit && get_nicam_lock_status()) {
+                       if (standard == AUDIO_STANDARD_A2_DK1
+                               || standard == AUDIO_STANDARD_A2_DK1
+                               || standard == AUDIO_STANDARD_A2_DK3)
+                               aud_std = AUDIO_STANDARD_NICAM_DK;
+                       else if (standard == AUDIO_STANDARD_A2_BG)
+                               aud_std = AUDIO_STANDARD_NICAM_BG;
+
+                       break;
+               }
+
                set_a2_eiaj_outputmode(outmode);
                break;
        case AUDIO_STANDARD_NICAM_DK:
@@ -1552,6 +1575,17 @@ void set_outputmode(uint32_t standard, uint32_t outmode)
        case AUDIO_STANDARD_NICAM_BG:
        case AUDIO_STANDARD_NICAM_L:
                set_nicam_outputmode(outmode);
+               break;
+       case AUDIO_STANDARD_MONO_I:
+       case AUDIO_STANDARD_MONO_L:
+               /* for FM MONO system to detection nicam status */
+               if (!aud_reinit && get_nicam_lock_status()) {
+                       if (standard == AUDIO_STANDARD_MONO_I)
+                               aud_std = AUDIO_STANDARD_NICAM_I;
+                       else if (standard == AUDIO_STANDARD_MONO_L)
+                               aud_std = AUDIO_STANDARD_NICAM_L;
+               }
+
                break;
        }
 #endif
index 9ecc978f904bbc2ad0ee7faaec9a4f95215541fc..ae6af49f919cad8737c354f77931c3ecb788f407 100644 (file)
@@ -37,6 +37,7 @@ 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);
+int get_nicam_lock_status(void);
 void update_nicam_mode(int *nicam_flag, int *nicam_mono_flag,
                int *nicam_stereo_flag, int *nicam_dual_flag);
 void update_btsc_mode(int auto_en, int *stereo_flag, int *sap_flag);
index 5daa986e7fcf5a9a7d0a2f0f353d588bef3747a7..26c2c77524fb0f06e3a1cbfb74f68ef8a9d23c67 100644 (file)
@@ -1321,7 +1321,7 @@ void configure_receiver(int Broadcast_Standard, unsigned int Tuner_IF_Frequency,
 
        /*PWM*/
        pr_dbg("ATV-DMD configure pwm\n");
-       atv_dmd_wr_long(APB_BLOCK_ADDR_AGC_PWM, 0x00, 0x1f40);  /*4KHz*/
+       atv_dmd_wr_long(APB_BLOCK_ADDR_AGC_PWM, 0x00, 0x1f40); /*4KHz*/
        atv_dmd_wr_long(APB_BLOCK_ADDR_AGC_PWM, 0x04, 0xc8);
        /*26 dB dynamic range*/
        atv_dmd_wr_byte(APB_BLOCK_ADDR_AGC_PWM, 0x09, 0xa);
@@ -1330,7 +1330,7 @@ void configure_receiver(int Broadcast_Standard, unsigned int Tuner_IF_Frequency,
                amlatvdemod_devp->tuners[amlatvdemod_devp->tuner_cur].cfg.id
                        == AM_TUNER_R842) {
                /*config pwm for tuner r840*/
-               atv_dmd_wr_long(APB_BLOCK_ADDR_AGC_PWM, 0, 0xc80);
+               atv_dmd_wr_long(APB_BLOCK_ADDR_AGC_PWM, 0, 0xc80); /*10KHz*/
                /* guanzhong for Tuner AGC shock */
                atv_dmd_wr_long(APB_BLOCK_ADDR_AGC_PWM, 0x08, 0x46180200);
                /* atv_dmd_wr_byte(APB_BLOCK_ADDR_ADC_SE,1,0xf);//Kd = 0xf */