atv_demod: after afc adjusts freq and stable, sync to settings to get freq [1/1]
authornengwen.chen <nengwen.chen@amlogic.com>
Wed, 3 Jul 2019 11:48:52 +0000 (19:48 +0800)
committerNengwen Chen <nengwen.chen@amlogic.com>
Tue, 16 Jul 2019 03:05:27 +0000 (20:05 -0700)
PD#TV-7462

Problem:
after afc adjusts freq and stable, sync to settings to get freq.

Solution:
1.after afc adjusts freq and stable, sync to settings to get freq.

Verify:
Verified by x301

Change-Id: Id78a7f974345fd428f9bb185c36fcbe7b93f4ac2
Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
drivers/amlogic/atv_demod/atv_demod_afc.c

index f5571e5..13518db 100644 (file)
@@ -38,6 +38,22 @@ static int afc_range[11] = {0, -500, 500, -1000, 1000,
 bool afc_timer_en = true;
 
 
+static void atv_demod_afc_sync_frontend(struct atv_demod_afc *afc,
+               int freq_offset)
+{
+       struct atv_demod_priv *priv =
+                       container_of(afc, struct atv_demod_priv, afc);
+       struct dvb_frontend *fe = afc->fe;
+       struct v4l2_frontend *v4l2_fe =
+                               container_of(fe, struct v4l2_frontend, fe);
+       struct analog_parameters *param = &priv->atvdemod_param.param;
+
+       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)
 {
        struct atv_demod_priv *priv =
@@ -146,6 +162,9 @@ void atv_demod_afc_do_work(struct work_struct *work)
                abs(afc->offset) <= afc_limit) && field_lock) {
                afc->status = AFC_LOCK_STATUS_POST_LOCK;
                afc->wave_cnt = 0;
+
+               atv_demod_afc_sync_frontend(afc, freq_offset * 1000);
+
                pr_afc("%s,afc lock, set wave_cnt 0\n", __func__);
                return;
        }