From: nengwen.chen Date: Thu, 13 Jun 2019 07:54:12 +0000 (+0800) Subject: atv_demod: fix secam-l/l' recognition and audio output [1/4] X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=161619d7b190a8a9f9e4e7f3e0f7828e8198f8d2;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git atv_demod: fix secam-l/l' recognition and audio output [1/4] PD#TV-7982 Problem: fix secam-l/l' recognition and audio output. Solution: 1.fix secam-l/l' recognition and audio output. 2.atv demod version: V2.13. Verify: Verified by x301 Change-Id: Ie09b635f132397b3c438aa3ff62f2ef915eb3462 Signed-off-by: nengwen.chen --- diff --git a/drivers/amlogic/atv_demod/atv_demod_afc.c b/drivers/amlogic/atv_demod/atv_demod_afc.c index 13518dbe109f..b4249f3ea46a 100644 --- a/drivers/amlogic/atv_demod/atv_demod_afc.c +++ b/drivers/amlogic/atv_demod/atv_demod_afc.c @@ -50,8 +50,13 @@ static void atv_demod_afc_sync_frontend(struct atv_demod_afc *afc, v4l2_fe->params.frequency = param->frequency + freq_offset; - pr_afc("%s, sync frequency: %d.\n", __func__, - v4l2_fe->params.frequency); + /* just play mode need sync */ + if (!(v4l2_fe->params.flag & ANALOG_FLAG_ENABLE_AFC)) { + v4l2_fe->params.frequency = param->frequency + freq_offset; + + pr_afc("%s, sync frequency: %d.\n", __func__, + v4l2_fe->params.frequency); + } } static void atv_demod_afc_do_work_pre(struct atv_demod_afc *afc) diff --git a/drivers/amlogic/atv_demod/atv_demod_debug.c b/drivers/amlogic/atv_demod/atv_demod_debug.c index 069d32de4cd2..7e66331b99ee 100644 --- a/drivers/amlogic/atv_demod/atv_demod_debug.c +++ b/drivers/amlogic/atv_demod/atv_demod_debug.c @@ -103,6 +103,7 @@ DEBUGFS_CREATE_NODE(audio_atv_ov_flag, 0640, dentry, u32)\ 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)\ } diff --git a/drivers/amlogic/atv_demod/atv_demod_driver.c b/drivers/amlogic/atv_demod/atv_demod_driver.c index f243aecd9af1..bb7bb8886915 100644 --- a/drivers/amlogic/atv_demod/atv_demod_driver.c +++ b/drivers/amlogic/atv_demod/atv_demod_driver.c @@ -45,7 +45,7 @@ #include "atvauddemod_func.h" -#define AMLATVDEMOD_VER "V2.12" +#define AMLATVDEMOD_VER "V2.13" struct aml_atvdemod_device *amlatvdemod_devp; @@ -140,16 +140,16 @@ static ssize_t aml_atvdemod_store(struct class *class, } else if (!strncmp(parm[0], "get", 3)) { if (!strncmp(parm[1], "avout_gain", 10)) { val = atv_dmd_rd_byte(0x0c, 0x01); - pr_dbg("avout_gain:0x%x\n", val); + pr_info("avout_gain:0x%x\n", val); } else if (!strncmp(parm[1], "avout_offset", 12)) { val = atv_dmd_rd_byte(0x0c, 0x04); - pr_dbg("avout_offset:0x%x\n", val); + pr_info("avout_offset:0x%x\n", val); } else if (!strncmp(parm[1], "atv_gain", 8)) { val = atv_dmd_rd_byte(0x19, 0x01); - pr_dbg("atv_gain:0x%x\n", val); + pr_info("atv_gain:0x%x\n", val); } else if (!strncmp(parm[1], "atv_offset", 10)) { val = atv_dmd_rd_byte(0x19, 0x04); - pr_dbg("atv_offset:0x%x\n", val); + pr_info("atv_offset:0x%x\n", val); } } else if (!strncmp(parm[0], "snr_hist", 8)) { data_snr_avg = 0; @@ -160,14 +160,14 @@ static ssize_t aml_atvdemod_store(struct class *class, data_snr_avg += data_snr[i]; } data_snr_avg = data_snr_avg / 128; - pr_dbg("**********snr_hist_128avg:0x%x(%d)*********\n", + pr_info("**********snr_hist_128avg:0x%x(%d)*********\n", data_snr_avg, data_snr_avg); } else if (!strncmp(parm[0], "afc_info", 8)) { data_afc = retrieve_vpll_carrier_afc(); - pr_dbg("afc %d Khz.\n", data_afc); + pr_info("afc %d Khz.\n", data_afc); } else if (!strncmp(parm[0], "ver_info", 8)) { - pr_dbg("aml_atvdemod_ver %s.\n", + pr_info("aml_atvdemod_ver %s.\n", AMLATVDEMOD_VER); } else if (!strncmp(parm[0], "audio_autodet", 13)) { aml_audiomode_autodet(&dev->v4l2_fe); @@ -175,10 +175,10 @@ static ssize_t aml_atvdemod_store(struct class *class, if (kstrtoul(buf + strlen("audio_gain_set") + 1, 16, &tmp) == 0) val = tmp; aml_audio_valume_gain_set(val); - pr_dbg("audio_gain_set : %d\n", val); + pr_info("audio_gain_set : %d\n", val); } else if (!strncmp(parm[0], "audio_gain_get", 14)) { val = aml_audio_valume_gain_get(); - pr_dbg("audio_gain_get : %d\n", val); + pr_info("audio_gain_get : %d\n", val); } else if (!strncmp(parm[0], "audio_gain_shift", 16)) { /* int db[] = {12, 6, 0, -6, -12, -18, -24, -30}; */ tmp = adec_rd_reg(0x16); @@ -212,7 +212,7 @@ static ssize_t aml_atvdemod_store(struct class *class, block_reg = tmp; if (block_addr < APB_BLOCK_ADDR_TOP) block_val = atv_dmd_rd_long(block_addr, block_reg); - pr_dbg("rs block_addr:0x%x,block_reg:0x%x,block_val:0x%x\n", + pr_info("rs block_addr:0x%x,block_reg:0x%x,block_val:0x%x\n", block_addr, block_reg, block_val); } else if (!strncmp(parm[0], "ws", 2)) { @@ -224,14 +224,14 @@ static ssize_t aml_atvdemod_store(struct class *class, block_val = tmp; if (block_addr < APB_BLOCK_ADDR_TOP) atv_dmd_wr_long(block_addr, block_reg, block_val); - pr_dbg("ws block_addr:0x%x,block_reg:0x%x,block_val:0x%x\n", + pr_info("ws block_addr:0x%x,block_reg:0x%x,block_val:0x%x\n", block_addr, block_reg, block_val); block_val = atv_dmd_rd_long(block_addr, block_reg); - pr_dbg("readback_val:0x%x\n", block_val); + pr_info("readback_val:0x%x\n", block_val); } else if (!strncmp(parm[0], "snr_cur", 7)) { data_snr_avg = atvdemod_get_snr_val(); - pr_dbg("**********snr_cur:%d*********\n", data_snr_avg); + pr_info("**********snr_cur:%d*********\n", data_snr_avg); } else if (!strncmp(parm[0], "pll_status", 10)) { int vpll_lock; @@ -249,9 +249,9 @@ static ssize_t aml_atvdemod_store(struct class *class, else pr_info("line lock:unlocked\n"); } else if (!strncmp(parm[0], "audio_power", 11)) { - int audio_power = 0; + unsigned int audio_power = 0; - retrieve_vpll_carrier_audio_power(&audio_power); + retrieve_vpll_carrier_audio_power(&audio_power, 1); pr_info("audio_power: %d.\n", audio_power); } else if (!strncmp(parm[0], "adc_power", 9)) { int adc_power = 0; @@ -354,8 +354,27 @@ static ssize_t aml_atvdemod_store(struct class *class, else pr_info("attach_tuner %d done.\n", tuner_id); } + } else if (!strncmp(parm[0], "dump_demod", 10)) { + int blk = 0, reg = 0; + + for (blk = 0; blk <= APB_BLOCK_ADDR_TOP; ++blk) { + for (reg = 0; reg <= 0x40; ++reg) { + val = atv_dmd_rd_long(blk, reg); + pr_err("[0x%04x] = 0x%x.\n", + (blk << 8) + (reg << 2), val); + } + } + } else if (!strncmp(parm[0], "dump_audemod", 12)) { + int reg = 0; + + if (cpu_after_eq(MESON_CPU_MAJOR_ID_TXLX)) { + for (reg = 0; reg <= 0x1ff; ++reg) { + val = adec_rd_reg(reg); + pr_err("[0x%04x] = 0x%x.\n", (reg << 2), val); + } + } } else - pr_dbg("invalid command\n"); + pr_info("invalid command\n"); EXIT: kfree(buf_orig); diff --git a/drivers/amlogic/atv_demod/atv_demod_ops.c b/drivers/amlogic/atv_demod/atv_demod_ops.c index e0ed0046b285..f1fef2108fc6 100644 --- a/drivers/amlogic/atv_demod/atv_demod_ops.c +++ b/drivers/amlogic/atv_demod/atv_demod_ops.c @@ -58,7 +58,7 @@ void aml_fe_get_atvaudio_state(int *state) static bool mute = true; #endif int av_status = 0; - int power = 0; + unsigned int power = 0; int vpll_lock = 0; int line_lock = 0; struct atv_demod_priv *priv = amlatvdemod_devp != NULL @@ -79,7 +79,7 @@ void aml_fe_get_atvaudio_state(int *state) retrieve_vpll_carrier_lock(&vpll_lock); retrieve_vpll_carrier_line_lock(&line_lock); if ((vpll_lock == 0) && (line_lock == 0)) { - /* retrieve_vpll_carrier_audio_power(&power); */ + /* retrieve_vpll_carrier_audio_power(&power, 1); */ *state = 1; } else { *state = 0; @@ -426,6 +426,9 @@ bool check_rssi = true; /* Less than -85, it means no signal */ int tuner_rssi = -80; +/* when need to support secam-l, will enable it */ +bool support_secam_l; + bool slow_mode; typedef int (*hook_func_t) (void); @@ -474,6 +477,9 @@ static v4l2_std_id atvdemod_fmt_2_v4l2_std(int fmt) case AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_L: std = V4L2_STD_SECAM_L; break; + case AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_LC: + std = V4L2_STD_SECAM_LC; + break; case AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_DK2: case AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_DK3: std = V4L2_STD_SECAM_DK; @@ -541,6 +547,14 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe, if (auto_search_std & AUTO_DETECT_COLOR) { for (i = 0; i < try_vfmt_cnt; i++) { + + /* SECAM-L/L' */ + if ((p->std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) + && (p->std & V4L2_COLOR_STD_SECAM)) { + cvbs_std = TVIN_SIG_FMT_CVBS_SECAM; + break; + } + if (aml_fe_hook_get_fmt == NULL) { pr_err("%s: aml_fe_hook_get_fmt == NULL.\n", __func__); @@ -688,7 +702,7 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe, } static void atvdemod_fe_try_signal(struct v4l2_frontend *v4l2_fe, - int auto_search_std, bool *lock) + int auto_search, bool *lock) { struct analog_parameters params; struct dvb_frontend *fe = &v4l2_fe->fe; @@ -697,9 +711,10 @@ static void atvdemod_fe_try_signal(struct v4l2_frontend *v4l2_fe, enum v4l2_status tuner_state = V4L2_TIMEDOUT; enum v4l2_status ade_state = V4L2_TIMEDOUT; int try_cnt = tuner_status_cnt; - /* v4l2_std_id std_bk = 0; */ - /* unsigned int audio = 0; */ - /* bool try_secam = false; */ + v4l2_std_id std_bk = 0; + unsigned int audio = 0; + bool try_secaml = false; + bool try_secamlc = false; unsigned int tuner_id = priv->atvdemod_param.tuner_id; s16 strength = 0; @@ -711,6 +726,10 @@ static void atvdemod_fe_try_signal(struct v4l2_frontend *v4l2_fe, fe->ops.analog_ops.set_params(fe, ¶ms); } + /* backup the std and audio mode */ + std_bk = p->std; + audio = p->audmode; + *lock = false; do { if (tuner_id == AM_TUNER_MXL661) { @@ -751,51 +770,54 @@ static void atvdemod_fe_try_signal(struct v4l2_frontend *v4l2_fe, } if (try_cnt == 0) { -#if 0 /* when need to support secam-l, will enable it */ - if (auto_search_std && - try_secam == false && - !(p->std & V4L2_COLOR_STD_SECAM) && - !(p->std & V4L2_STD_SECAM_L)) { - /* backup the std and audio mode */ - std_bk = p->std; - audio = p->audmode; - - p->std = (V4L2_COLOR_STD_SECAM + if (support_secam_l && auto_search) { + if (!(p->std & V4L2_STD_SECAM_L) && + !try_secaml) { + p->std = (V4L2_COLOR_STD_SECAM | V4L2_STD_SECAM_L); - p->audmode = V4L2_STD_SECAM_L; + p->audmode = V4L2_STD_SECAM_L; - params.frequency = p->frequency; - params.mode = p->afc_range; - params.audmode = p->audmode; - params.std = p->std; - fe->ops.analog_ops.set_params(fe, - ¶ms); + try_secaml = true; + } else if (!(p->std & V4L2_STD_SECAM_LC) && + !try_secamlc && + p->frequency <= ATV_SECAM_LC_100MHZ) { - try_secam = true; - - try_cnt = - tuner_status_cnt / 2; - - continue; - } + p->std = (V4L2_COLOR_STD_SECAM + | V4L2_STD_SECAM_LC); + p->audmode = V4L2_STD_SECAM_LC; - if (try_secam) { - p->std = std_bk; - p->audmode = audio; + try_secamlc = true; + } else + break; params.frequency = p->frequency; params.mode = p->afc_range; params.audmode = p->audmode; params.std = p->std; - fe->ops.analog_ops.set_params(fe, - ¶ms); + fe->ops.analog_ops.set_params(fe, ¶ms); + + if (tuner_status_cnt > 2) + try_cnt = tuner_status_cnt / 2; + else + try_cnt = tuner_status_cnt; - try_secam = false; + continue; } -#endif + break; } } while (1); + + if (*lock == false && (try_secaml || try_secamlc)) { + p->std = std_bk; + p->audmode = audio; + + params.frequency = p->frequency; + params.mode = p->afc_range; + params.audmode = p->audmode; + params.std = p->std; + fe->ops.analog_ops.set_params(fe, ¶ms); + } } static int atvdemod_fe_afc_closer(struct v4l2_frontend *v4l2_fe, int minafcfreq, diff --git a/drivers/amlogic/atv_demod/atv_demod_ops.h b/drivers/amlogic/atv_demod/atv_demod_ops.h index ca7c45fd7fa2..80dbe8481a5e 100644 --- a/drivers/amlogic/atv_demod/atv_demod_ops.h +++ b/drivers/amlogic/atv_demod/atv_demod_ops.h @@ -42,6 +42,8 @@ #define ATV_AFC_1_0MHZ 1000000 #define ATV_AFC_2_0MHZ 2000000 +#define ATV_SECAM_LC_100MHZ 100000000 + #define ATVDEMOD_INTERVAL (HZ / 100) /* 10ms, #define HZ 100 */ #define AUTO_DETECT_COLOR (1 << 0) @@ -59,6 +61,9 @@ struct atv_demod_parameters { struct analog_parameters param; + bool secam_l; + bool secam_lc; + unsigned int last_frequency; unsigned int lock_range; unsigned int leap_step; diff --git a/drivers/amlogic/atv_demod/atvauddemod_func.c b/drivers/amlogic/atv_demod/atvauddemod_func.c index e25fb28f7b4b..0fbf1245ade8 100644 --- a/drivers/amlogic/atv_demod/atvauddemod_func.c +++ b/drivers/amlogic/atv_demod/atvauddemod_func.c @@ -1436,6 +1436,13 @@ void set_nicam_outputmode(uint32_t outmode) set_deem_and_gain(aud_std); } + if (aud_std == AUDIO_STANDARD_NICAM_L + && outmode == AUDIO_OUTMODE_NICAM_MONO) { + audio_source_select(0); + } else { + audio_source_select(1); + } + switch (outmode) { case AUDIO_OUTMODE_NICAM_MONO:/* fm mono */ if (is_meson_tl1_cpu() || is_meson_tm2_cpu()) { @@ -1584,7 +1591,10 @@ void set_outputmode(uint32_t standard, uint32_t outmode) aud_std = AUDIO_STANDARD_NICAM_I; else if (standard == AUDIO_STANDARD_MONO_L) aud_std = AUDIO_STANDARD_NICAM_L; - } + + audio_source_select(1); + } else + audio_source_select(0); break; } diff --git a/drivers/amlogic/atv_demod/atvdemod_func.c b/drivers/amlogic/atv_demod/atvdemod_func.c index 5abd02ab0d74..6e9a3618ceae 100644 --- a/drivers/amlogic/atv_demod/atvdemod_func.c +++ b/drivers/amlogic/atv_demod/atvdemod_func.c @@ -1376,26 +1376,29 @@ void retrieve_vpll_carrier_line_lock(int *lock) *lock = (line_lock | line_lock_strong); } -void retrieve_vpll_carrier_audio_power(int *power) +void retrieve_vpll_carrier_audio_power(unsigned int *power, + unsigned int try_times) { + unsigned int i = 0; + unsigned int carrier_power = 0; + unsigned int carrier_power_total = 0; unsigned long data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02); - if (!(data & 0x80)) { - atv_dmd_wr_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02, data | 0x80); + if (!(data & 0x80)) + atv_dmd_wr_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02, data | 0x87); - usleep_range(10000, 10000 + 100); + usleep_range(20000, 20000 + 100); - data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x03); - *power = data & 0xffff; + for (i = 0; i < try_times; i++) { + carrier_power = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x03); + carrier_power_total += carrier_power & 0xffff; + } - /* keep open for carrier audio power update */ - /* - * data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02); - * atv_dmd_wr_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02,data&(~0x80)); - */ - } else { - data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x03); - *power = data & 0xffff; + if (try_times) + *power = carrier_power_total / try_times; + else { + carrier_power = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x03); + *power = carrier_power & 0xffff; } pr_audio("retrieve_vpll_carrier_audio_power: %d.\n", *power); @@ -1995,6 +1998,17 @@ int atvdemod_init(struct atv_demod_priv *priv) atv_dmd_set_std(amlatvdemod_devp->std); + if (p->param.std & (V4L2_STD_SECAM_L)) { + p->secam_l = true; + p->secam_lc = false; + } else if (p->param.std & V4L2_STD_SECAM_LC) { + p->secam_l = false; + p->secam_lc = true; + } else { + p->secam_l = false; + p->secam_lc = false; + } + if (is_meson_txlx_cpu() || is_meson_txhd_cpu() || is_meson_tl1_cpu() || is_meson_tm2_cpu()) sound_format = 1; @@ -2122,27 +2136,22 @@ void atv_dmd_set_std(unsigned long ptstd) v4l2_std_to_str((0xff000000 & ptstd)), v4l2_std_to_str((0xffffff & ptstd))); - pr_dbg("[%s] set if_freq %d, if_inv %d.\n", - __func__, amlatvdemod_devp->if_freq, - amlatvdemod_devp->if_inv); + pr_dbg("[%s] set if_freq %d, if_inv %d.\n", __func__, if_freq, if_inv); } int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe) { struct dvb_frontend *fe = &v4l2_fe->fe; - struct atv_demod_priv *priv = fe->analog_demod_priv; struct v4l2_analog_parameters *p = &v4l2_fe->params; struct analog_parameters params; - unsigned long carrier_power = 0; + unsigned int carrier_power = 0; unsigned long carrier_power_max = 0; unsigned long carrier_power_average_max = 0; unsigned long carrier_power_average[4] = {0}; - unsigned long temp_data = 0; int lock = 0, line_lock = 0; int broad_std_final = 0; int num = 0, i = 0, final_id = 0; - int delay_ms = 20, delay_ms_default = 20; int cur_std = ID_PAL_DK; bool secam_signal = false; bool ntsc_signal = false; @@ -2169,31 +2178,34 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe) case AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_DK2: case AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_DK3: if (!(p->std & V4L2_COLOR_STD_SECAM) || - !(p->std & V4L2_STD_SECAM_L)) { + !((p->std & V4L2_STD_SECAM_L) || + (p->std & V4L2_STD_SECAM_LC))) { secam_signal = true; broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M; - } else { - broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_L; - atvdemod_init(priv); - temp_data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, - 0x02); - - temp_data = temp_data & (~0x80); /* 0xbf; */ - atv_dmd_wr_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02, - temp_data); - /* pr_err("%s, SECAM ,audio set SECAM_L\n", - * __func__); - */ - return broad_std; + break; } - break; + + if ((p->std & V4L2_STD_SECAM_L) && + p->frequency <= ATV_SECAM_LC_100MHZ) { + retrieve_vpll_carrier_audio_power( + &carrier_power, 100); + if (carrier_power < AUIDO_CARRIER_POWER_MIN) { + broad_std = + AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_LC; + pr_err("%s,carrier %d too low, set L to LC.\n", + __func__, carrier_power); + } else + broad_std = + AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_L; + } else + broad_std = + AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_L; + + return broad_std; default: - pr_err("unsupport broadcast_standard!!!\n"); - temp_data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02); - temp_data = temp_data & (~0x80); /* 0xbf; */ - atv_dmd_wr_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02, temp_data); + pr_err("unsupport broadcast_standard %d !!!\n", broad_std); return broad_std; } @@ -2210,7 +2222,6 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe) p->frequency += 1; p->audmode = V4L2_STD_PAL_I; - delay_ms = delay_ms_default; break; case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_I: broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_BG; @@ -2220,7 +2231,6 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe) p->frequency += 1; p->audmode = V4L2_STD_PAL_BG; - delay_ms = delay_ms_default; break; case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_BG: broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M; @@ -2236,7 +2246,6 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe) p->audmode = V4L2_STD_NTSC_M; } - delay_ms = delay_ms_default; break; case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M: broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK; @@ -2246,7 +2255,6 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe) p->frequency += 1; p->audmode = V4L2_STD_PAL_DK; - delay_ms = delay_ms_default; break; default: pr_err("unsupport broadcast_standard!!!\n"); @@ -2260,13 +2268,6 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe) if (fe->ops.analog_ops.set_params) fe->ops.analog_ops.set_params(fe, ¶ms); - /* enable audio detect function */ - temp_data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02); - temp_data = temp_data | 0x87;/* 0x40 */ - atv_dmd_wr_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02, temp_data); - - usleep_range(delay_ms * 1000, delay_ms * 1000 + 100); - /* ----------------judgment signal state--------------------- */ i = 4; has_audio = false; @@ -2281,30 +2282,19 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe) usleep_range(6000, 9000); } /* ----------------read carrier_power--------------------- */ - if (has_audio) { - for (i = 0; i < 100; i++) { - carrier_power = atv_dmd_rd_reg( - APB_BLOCK_ADDR_SIF_STG_2, 0x03); - carrier_power_max += carrier_power; - } - carrier_power = carrier_power_max/i; - } else { - carrier_power = 0; + carrier_power = 0; + if (has_audio) + retrieve_vpll_carrier_audio_power(&carrier_power, 100); + else pr_err("[%s] pll and line unlock.\n", __func__); - } - carrier_power_max = 0; - pr_err("[%s] [num:%d] [broad_std:%d] [%s] audio carrier power: %lu. @@@@@@@@@@\n", + pr_err("[%s] [num:%d] [broad_std:%d] [%s] audio carrier power: %d. @@@@@@@@@@\n", __func__, num, broad_std, AUDIO_NAME[cur_std], carrier_power); carrier_power_average[cur_std] += carrier_power; num++; } - /* disable audio detect function */ - temp_data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02); - atv_dmd_wr_reg(APB_BLOCK_ADDR_SIF_STG_2, 0x02, temp_data & (~0x80)); - carrier_power_max = carrier_power_average[0]; for (i = 0; i < ID_MAX; i++) { if (carrier_power_max < carrier_power_average[i]) { @@ -2333,7 +2323,7 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe) pr_err("%s:broad_std:%d,carrier_power_average_max:%lu\n", __func__, broad_std, carrier_power_average_max); - if (carrier_power_average_max < 150) { + if (carrier_power_average_max < AUIDO_CARRIER_POWER_MIN) { pr_err("%s,carrier too low error\n", __func__); if (secam_signal) { broad_std = diff --git a/drivers/amlogic/atv_demod/atvdemod_func.h b/drivers/amlogic/atv_demod/atvdemod_func.h index 3454a65431b5..f7e09d36e151 100644 --- a/drivers/amlogic/atv_demod/atvdemod_func.h +++ b/drivers/amlogic/atv_demod/atvdemod_func.h @@ -21,6 +21,8 @@ struct v4l2_frontend; struct atv_demod_priv; +#define AUIDO_CARRIER_POWER_MIN 150 + #define HHI_ATV_DMD_SYS_CLK_CNTL 0x10f3 extern unsigned int reg_23cf; /* IIR filter */ @@ -80,7 +82,8 @@ extern void atv_dmd_set_std(unsigned long std); extern void retrieve_adc_power(int *adc_level); extern void retrieve_vpll_carrier_lock(int *lock); extern void retrieve_vpll_carrier_line_lock(int *lock); -extern void retrieve_vpll_carrier_audio_power(int *power); +extern void retrieve_vpll_carrier_audio_power(unsigned int *power, + unsigned int try_times); extern void retrieve_video_lock(int *lock); extern int retrieve_vpll_carrier_afc(void); @@ -160,6 +163,7 @@ extern void atvdemod_mixer_tune(void); #define AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_BG 13 #define AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_I 14 #define AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_M 15 +#define AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_LC 16 /* new add @20150813 end */ /*GDE_Curve*/