dtv_demod: optimize isdbt stability of locking signal (V3.2.104) [1/1]

PD#SWPL-123990
PD#TV-80871
PD#TV-79342

Problem:
The lock frequency state cannot be quickly reset after signal reset

Solution:
1.reduce sensitivity of demod state
2.reset demod every interval after signal loss
3.reset demod every interval after lock status loss

Verify:
AR331, Latam, AT30a3

Change-Id: I75c73cdf82014454610d37e2479a7f8b536076d0
Signed-off-by: caiyi.xu <caiyi.xu@amlogic.com>
This commit is contained in:
caiyi.xu
2023-05-17 07:31:01 +00:00
committed by gerrit autosubmit
parent 2d1b3f30de
commit fb92a67b52
2 changed files with 60 additions and 23 deletions
+55 -19
View File
@@ -58,15 +58,13 @@
#include <linux/amlogic/media/vout/vdac_dev.h>
#include <linux/amlogic/aml_dtvdemod.h>
//It is a timeout which is used for check atsc signal
#define ATSC_TIME_CHECK_SIGNAL 600
#define ATSC_TIME_START_CCI 1500
#define ISDBT_TIME_CHECK_SIGNAL 400
#define ISDBT_FSM_CHECK_SIGNAL 7
#define ATSC_AGC_TARGET_VALUE 0x28
#define ISDBT_TIME_CHECK_SIGNAL 400
#define ISDBT_RESET_IN_UNLOCK_TIMES 40
//atsc-c
MODULE_PARM_DESC(auto_search_std, "\n\t\t atsc-c std&hrc search");
static unsigned int auto_search_std;
module_param(auto_search_std, int, 0644);
@@ -75,6 +73,15 @@ MODULE_PARM_DESC(std_lock_timeout, "\n\t\t atsc-c std lock timeout");
static unsigned int std_lock_timeout = 1000;
module_param(std_lock_timeout, int, 0644);
//atsc-t
MODULE_PARM_DESC(atsc_agc_target, "\n\t\t atsc agc target");
static unsigned char atsc_agc_target;
module_param(atsc_agc_target, byte, 0644);
MODULE_PARM_DESC(atsc_check_signal_time, "\n\t\t atsc check signal time");
static unsigned int atsc_check_signal_time;
module_param(atsc_check_signal_time, int, 0644);
MODULE_PARM_DESC(atsc_t_lock_continuous_cnt, "\n\t\t atsc-t lock signal continuous counting");
static unsigned int atsc_t_lock_continuous_cnt = 1;
module_param(atsc_t_lock_continuous_cnt, int, 0644);
@@ -83,20 +90,21 @@ MODULE_PARM_DESC(atsc_t_lost_continuous_cnt, "\n\t\t atsc-t lost signal continuo
static unsigned int atsc_t_lost_continuous_cnt = 15;
module_param(atsc_t_lost_continuous_cnt, int, 0644);
MODULE_PARM_DESC(atsc_check_signal_time, "\n\t\t atsc check signal time");
static unsigned int atsc_check_signal_time;
module_param(atsc_check_signal_time, int, 0644);
//isdb-t
MODULE_PARM_DESC(isdbt_check_signal_time, "\n\t\t isdbt check signal time");
static unsigned int isdbt_check_signal_time = ISDBT_TIME_CHECK_SIGNAL;
module_param(isdbt_check_signal_time, int, 0644);
MODULE_PARM_DESC(atsc_agc_target, "\n\t\t atsc agc target");
static unsigned char atsc_agc_target;
module_param(atsc_agc_target, byte, 0644);
MODULE_PARM_DESC(isdbt_reset_in_unlock_times, "\n\t\t isdbt check signal time");
static unsigned int isdbt_reset_in_unlock_times = ISDBT_RESET_IN_UNLOCK_TIMES;
module_param(isdbt_reset_in_unlock_times, int, 0644);
MODULE_PARM_DESC(isdbt_lock_continuous_cnt, "\n\t\t isdbt lock signal continuous counting");
static unsigned int isdbt_lock_continuous_cnt = 1;
module_param(isdbt_lock_continuous_cnt, int, 0644);
MODULE_PARM_DESC(isdbt_lost_continuous_cnt, "\n\t\t isdbt lost signal continuous counting");
static unsigned int isdbt_lost_continuous_cnt = 1;
static unsigned int isdbt_lost_continuous_cnt = 10;
module_param(isdbt_lost_continuous_cnt, int, 0644);
/*use this flag to mark the new method for dvbc channel fast search
@@ -908,22 +916,30 @@ static void gxtv_demod_dvbt_release(struct dvb_frontend *fe)
}
static int dvbt_isdbt_read_status(struct dvb_frontend *fe, enum fe_status *status,
bool re_tune)
static int dvbt_isdbt_set_frontend(struct dvb_frontend *fe);
#define ISDBT_FSM_CHECK_SIGNAL 7
static int dvbt_isdbt_read_status(struct dvb_frontend *fe, enum fe_status *status, bool re_tune)
{
struct aml_dtvdemod *demod = (struct aml_dtvdemod *)fe->demodulator_priv;
unsigned char s = 0;
unsigned int fsm;
int lock, strength, snr10;
static int has_signal;
static int no_signal_cnt, unlock_cnt;
int lock_continuous_cnt = isdbt_lock_continuous_cnt > 1 ? isdbt_lock_continuous_cnt : 1;
int lost_continuous_cnt = isdbt_lost_continuous_cnt > 1 ? isdbt_lost_continuous_cnt : 1;
int check_signal_time = isdbt_check_signal_time > 1 ? isdbt_check_signal_time :
ISDBT_TIME_CHECK_SIGNAL;
int reset_in_unlock_times = isdbt_reset_in_unlock_times > 1 ? isdbt_reset_in_unlock_times :
ISDBT_RESET_IN_UNLOCK_TIMES;
if (re_tune) {
demod->time_start = jiffies_to_msecs(jiffies);
*status = 0;
demod->last_status = 0;
has_signal = 0;
no_signal_cnt = 0;
unlock_cnt = 0;
demod->last_lock = 0;
return 0;
@@ -936,9 +952,13 @@ static int dvbt_isdbt_read_status(struct dvb_frontend *fe, enum fe_status *statu
if (strength < THRD_TUNER_STRENGTH_ISDBT) {
*status = FE_TIMEDOUT;
PR_ISDBT("no signal, strength=%d, need<%d\n", strength, THRD_TUNER_STRENGTH_ISDBT);
if (!(no_signal_cnt++ % 20))
dvbt_isdbt_set_frontend(fe);
unlock_cnt = 0;
goto finish;
}
no_signal_cnt = 0;
demod->time_passed = jiffies_to_msecs(jiffies) - demod->time_start;
fsm = dvbt_isdbt_rd_reg(0x2a << 2);
@@ -949,14 +969,21 @@ static int dvbt_isdbt_read_status(struct dvb_frontend *fe, enum fe_status *statu
fsm, strength, snr10 / 10, snr10 % 10, demod->time_passed);
s = dvbt_isdbt_rd_reg(0x0) >> 12 & 1;
if (s == 1)
if (s == 1) {
lock = 1;
else if (demod->time_passed < ISDBT_TIME_CHECK_SIGNAL ||
(demod->time_passed < TIMEOUT_ISDBT && has_signal && demod->last_lock == 0))
} else if (demod->time_passed < check_signal_time ||
(demod->time_passed < TIMEOUT_ISDBT && has_signal && demod->last_lock == 0)) {
lock = 0;
else
} else {
lock = -1;
if (!has_signal && demod->last_lock == 0) {
demod->last_lock = -lost_continuous_cnt;
*status = FE_TIMEDOUT;
PR_ISDBT("not isdb-t signal\n");
goto finish;
}
}
//The status is updated only when the status continuously reaches the threshold of times
if (lock < 0) {
@@ -997,6 +1024,15 @@ static int dvbt_isdbt_read_status(struct dvb_frontend *fe, enum fe_status *statu
PR_ISDBT("==> wait\n");
}
if (*status == FE_TIMEDOUT)
unlock_cnt++;
else
unlock_cnt = 0;
if (unlock_cnt >= reset_in_unlock_times) {
unlock_cnt = 0;
dvbt_isdbt_set_frontend(fe);
}
finish:
if (demod->last_status != *status && *status != 0) {
PR_INFO("!! >> %s << !!, freq=%d\n", *status == FE_TIMEDOUT ? "UNLOCK" : "LOCK",
@@ -93,8 +93,9 @@
/* V1.1.99 fix init flow */
/* V1.1.100 bring up dump ADC data feature */
/* V3.1.101 fix dvb-s unicable blind scan miss TP */
/* V1.2.0 bring up dump ADC data feature */
/* V1.2.00 t3x bringup */
/* V3.1.102 bring up dump ADC data feature */
/* V3.2.103 t3x bringup */
/* V3.2.104 optimize isdbt stability of locking signal */
/****************************************************/
/****************************************************************/
/* AMLDTVDEMOD_VER Description: */
@@ -111,8 +112,8 @@
/*->The last four digits indicate the release time */
/****************************************************************/
#define KERNEL_4_9_EN 1
#define AMLDTVDEMOD_VER "V3.1.101"
#define DTVDEMOD_VER "2023/5/16: fix dvb-s unicable blind scan miss TP"
#define AMLDTVDEMOD_VER "V3.1.102"
#define DTVDEMOD_VER "2023/5/17: optimize isdbt stability of locking signal"
#define AMLDTVDEMOD_T2_FW_VER "V1551.20220524"
#define DEMOD_DEVICE_NAME "dtvdemod"