static unsigned int vlock_log_delta_en;
static unsigned int hhi_pll_reg_m;
static unsigned int hhi_pll_reg_frac;
+u32 phase_en_after_frqlock;
+u32 vlock_ss_en = 1;
static struct stvlock_sig_sts vlock;
+
/*static unsigned int hhi_pll_reg_vlock_ctl;*/
module_param(vlock_log_size, uint, 0664);
MODULE_PARM_DESC(vlock_log_size, "\n vlock_log_size\n");
/*initial phase lock setting*/
if (vlock.phlock_en) {
- vlock_hw_reinit(vlock_pll_phase_setting, VLOCK_PHASE_REG_SIZE);
- /*disable pll lock*/
- /*WRITE_VPP_REG_BITS(VPU_VLOCK_CTRL, 0, 3, 1);*/
-
- /*enable pll mode and enc mode phase lock*/
- WRITE_VPP_REG_BITS(VPU_VLOCK_CTRL, 3, 0, 2);
-
- /*reset*/
- /*WRITE_VPP_REG_BITS(VPU_VLOCK_CTRL, 1, 2, 1);*/
- /*WRITE_VPP_REG_BITS(VPU_VLOCK_CTRL, 1, 5, 1);*/
+ if (!phase_en_after_frqlock) {
+ vlock_hw_reinit(vlock_pll_phase_setting,
+ VLOCK_PHASE_REG_SIZE);
+ /*disable pll lock*/
+ /*WRITE_VPP_REG_BITS(VPU_VLOCK_CTRL, 0, 3, 1);*/
+
+ /*enable pll mode and enc mode phase lock*/
+ WRITE_VPP_REG_BITS(VPU_VLOCK_CTRL, 3, 0, 2);
+ }
}
/* vlock module output goes to which module */
amvecm_hiu_reg_write_bits(HHI_HDMI_PLL_CNTL6,
0, 21, 2);
}
+
+ vlock_reset(1);
+ WRITE_VPP_REG_BITS(VPU_VLOCK_CTRL, 0, 0, 2);
ret = true;
if (vlock_debug & VLOCK_DEBUG_INFO)
pr_info("vlock m: pre=0x%x, rp=0x%x, wr=0x%x\n",
pre_m, new_m, m_reg_value);
}
- #if 0
- /*for test*/
- pr_info("vlock m: 0x%x (%d)\n", vlock.val_m, aaa);
- if (aaa == 0) {
- aaa = 1;
- vlock_set_panel_pll_m(vlock.val_m + 1);
- } else if (aaa == 1) {
- aaa = 2;
- vlock_set_panel_pll_m(vlock.val_m);
- } else if (aaa == 2) {
- aaa = 3;
- vlock_set_panel_pll_m(vlock.val_m - 1);
- } else if (aaa == 3) {
- aaa = 0;
- vlock_set_panel_pll_m(vlock.val_m);
- }
- #endif
}
}
else
vlock_pll_stable_cnt = 0;
} else {
+ #if 0
abs_val = abs((tmp_value & 0x1ffff) -
((m_f_reg_value & 0xfff) << 5));
(((tmp_value & 0x1ffff) +
((m_f_reg_value & 0xfff) << 5)) >> 1));
else
+ #endif
tmp_value = (tmp_value & 0xfffe0000) |
((m_f_reg_value & 0xfff) << 5);
if (((tmp_value & 0x1ffff) !=
vlock.frqlock_sts = false;
vlock.pll_mode_pause = false;
/*vlock.frqlock_stable_cnt = 0;*/
+ if (phase_en_after_frqlock)
+ vlock.phlock_en = false;
}
void vlock_set_en(bool en)
vlock.phlock_sts = false;
vlock.frqlock_sts = false;
vlock.pll_mode_pause = false;
- vlock.phlock_en = vlock.dtdata->vlk_phlock_en;
+ if (!phase_en_after_frqlock)
+ vlock.phlock_en = vlock.dtdata->vlk_phlock_en;
/* vlock.phlock_percent = phlock_percent; */
vlock_clear_frame_counter();
void vlock_set_phase_en(u32 en)
{
- if (en)
+ if (en) {
vlock.phlock_en = true;
- else
+
+ vlock_hw_reinit(vlock_pll_phase_setting, VLOCK_PHASE_REG_SIZE);
+ WRITE_VPP_REG_BITS(VPU_VLOCK_CTRL, 3, 0, 2);
+ vlock_reset(1);
+ vlock_reset(0);
+ } else
vlock.phlock_en = false;
pr_info("vlock phlock_en=%d\n", en);
}
vinfo = get_current_vinfo();
vlock_enable_step1(vf, vinfo,
pvlock->input_hz, pvlock->output_hz);
- if (IS_PLL_MODE(vlock_mode) &&
- pvlock->phlock_en) {
+ if (IS_PLL_MODE(vlock_mode)) {
vlock_set_panel_ss(false);
pvlock->ss_sts = false;
}
return ret;
}
-void vlock_fsm_check_lock_sts(struct stvlock_sig_sts *pvlock,
+u32 vlock_fsm_check_lock_sts(struct stvlock_sig_sts *pvlock,
struct vframe_s *vf)
{
u32 frqlock_sts = vlock_get_vlock_flag();
u32 phlock_sts = vlock_get_phlock_flag();
u32 pherr;
static u32 rstflag;
+ u32 ret = 1;
/*check frq lock*/
if (pvlock->frqlock_sts != frqlock_sts) {
pvlock->frqlock_sts = frqlock_sts;
}
+ /*enable phase lock after frq lock*/
+ if (phase_en_after_frqlock && !vlock.phlock_en &&
+ pvlock->frqlock_sts && (pvlock->frame_cnt_in > 50)) {
+ if (vlock.dtdata->vlk_phlock_en) {
+ vlock.phlock_en = vlock.dtdata->vlk_phlock_en;
+ pr_info("enable phase lock\n");
+ vlock_hw_reinit(vlock_pll_phase_setting,
+ VLOCK_PHASE_REG_SIZE);
+ /*WRITE_VPP_REG(VPU_VLOCK_LOOP1_CTRL0, 0x00601680);*/
+ WRITE_VPP_REG_BITS(VPU_VLOCK_CTRL, 3, 0, 2);
+ vlock_reset(1);
+ vlock_reset(0);
+ }
+ }
+
/*check phase error*/
if (IS_PLL_MODE(vlock_mode) &&
pvlock->phlock_en) {
}
/*check phase lock*/
- if (pvlock->phlock_en &&
- (pvlock->phlock_sts != phlock_sts)) {
- if (vlock_debug & VLOCK_DEBUG_INFO)
- pr_info("ph lock sts(%d,%d) cnt:%d\n",
- pvlock->phlock_sts,
- phlock_sts, pvlock->frame_cnt_in);
- pvlock->phlock_sts = phlock_sts;
- if (phlock_sts && !pvlock->ss_sts &&
- (pvlock->frame_cnt_in > 25)) {
- vlock_set_panel_ss(true);
- pvlock->ss_sts = true;
+ if (pvlock->phlock_en) {
+ if (pvlock->phlock_sts != phlock_sts) {
+ pvlock->phlock_cnt = 0;
+ if (vlock_debug & VLOCK_DEBUG_INFO)
+ pr_info("ph lock sts(%d,%d) cnt:%d\n",
+ pvlock->phlock_sts,
+ phlock_sts, pvlock->frame_cnt_in);
+ pvlock->phlock_sts = phlock_sts;
+ #if 0
+ if (pvlock->phlock_sts && !pvlock->ss_sts &&
+ (pvlock->frame_cnt_in > 25)) {
+ if (vlock_ss_en) {
+ pvlock->ss_sts = true;
+ vlock_set_panel_ss(true);
+ }
+ }
+ #endif
+ } else {
+ pvlock->phlock_cnt++;
+ if (pvlock->phlock_sts && !pvlock->ss_sts &&
+ (pvlock->phlock_cnt > 50)) {
+ if (vlock_ss_en) {
+ pvlock->ss_sts = true;
+ vlock_set_panel_ss(true);
+ }
+ }
}
}
if (IS_PLL_MODE(vlock_mode) &&
pvlock->phlock_en) {
/*error check*/
- if ((pvlock->frame_cnt_in >= 3500) && (!pvlock->ss_sts)) {
+ if ((pvlock->frame_cnt_in >= 3000) && (!pvlock->ss_sts)) {
if (vlock_debug & VLOCK_DEBUG_INFO)
pr_info("vlock warning: set back ss on(%d, %d)\n",
frqlock_sts, phlock_sts);
/*pvlock->pll_mode_pause = true;*/
- pvlock->ss_sts = true;
- vlock_set_panel_ss(true);
+ if (vlock_ss_en) {
+ pvlock->ss_sts = true;
+ vlock_set_panel_ss(true);
+ if (vlock_debug & VLOCK_DEBUG_INFO)
+ pr_info("vlock phase err, need retry\n");
+ return 0;
+ }
}
}
+
+ return ret;
}
u32 vlock_fsm_en_step2_func(struct stvlock_sig_sts *pvlock,
/*check phase*/
vlock_phaselock_check(pvlock, vf);
- vlock_fsm_check_lock_sts(pvlock, vf);
+ ret = vlock_fsm_check_lock_sts(pvlock, vf);
return ret;
}
} else {
/*normal mode*/
vlock.frame_cnt_no = 0;
- vlock_fsm_en_step2_func(&vlock, vf);
+ if (vlock_fsm_en_step2_func(&vlock, vf) <= 0) {
+ vlock.fsm_sts =
+ VLOCK_STATE_DISABLE_STEP1_DONE;
+ vlock_clear_frame_counter();
+ }
}
} else if (vlock.vmd_chg) {
vlock_clear_frame_counter();
if (vlock.dtdata->vlk_new_fsm &&
(vlock.fsm_sts >= VLOCK_STATE_ENABLE_STEP1_DONE) &&
(vlock.fsm_sts <= VLOCK_STATE_DISABLE_STEP1_DONE)) {
+ vlock_set_panel_ss(false);
/*stop vlock*/
vlock_disable_step1();
while (!vlock_disable_step2()) {
if (cnt++ > 10)
break;
}
+ vlock_set_panel_ss(true);
}
pr_info("vlock: event MODE_CHANGE_PRE %d\n", cnt);
break;