dtv_demod: txl: add dtv demod support for txl
authorJihong Sui <jihong.sui@amlogic.com>
Tue, 17 Jul 2018 12:30:02 +0000 (20:30 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Wed, 18 Jul 2018 09:51:38 +0000 (02:51 -0700)
PD#168480 :dtv_demod: txl: add dtv demod support for txl

Change-Id: Ib2503aa5f626a5fff115104d0b246cc080fb1123
Signed-off-by: Jihong Sui <jihong.sui@amlogic.com>
drivers/amlogic/media/dtv_demod/amlfrontend.c
drivers/amlogic/media/dtv_demod/dtmb_func.c

index 803bc337e1defccb0902ae6136be7f25d755d6b7..106e2450f98b4a674d14c50fb9c147980b664451 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/err.h> /*IS_ERR*/
 #include <linux/clk.h> /*clk tree*/
 #include <linux/of_device.h>
+#include <linux/of_reserved_mem.h>
 
 
 #ifdef ARC_700
@@ -2393,7 +2394,7 @@ static int gxtv_demod_dtmb_tune(struct dvb_frontend *fe, bool re_tune,
 {
        /*struct dtv_frontend_properties *c = &fe->dtv_property_cache;*/
        int ret = 0;
-       unsigned int up_delay;
+//     unsigned int up_delay;
        unsigned int firstdetet;
 
 
@@ -2435,7 +2436,7 @@ static int gxtv_demod_dtmb_tune(struct dvb_frontend *fe, bool re_tune,
                return ret;
        }
 
-#if 0  /**/
+#if 1  /**/
        *delay = HZ / 4;
        gxtv_demod_dtmb_read_status_old(fe, status);
 #else  /*try polling*/
@@ -2743,6 +2744,10 @@ int dtvdemod_set_iccfg_by_dts(struct platform_device *pdev)
 
        PR_DBG("%s:\n", __func__);
 
+       ret = of_reserved_mem_device_init(&pdev->dev);
+       if (ret != 0)
+               PR_INFO("no reserved mem.\n");
+
 
        /*agc pinmux: option*/
        ret = of_property_read_string(pdev->dev.of_node, "pinctrl-names",
@@ -3247,7 +3252,7 @@ static void __exit aml_dtvdemod_exit(void)
        PR_INFO("[amldtvdemod..]%s: driver removed ok.\n", __func__);
 }
 
-
+#if 0
 static int delsys_confirm(struct dvb_frontend *fe)
 {
        enum fe_delivery_system ldelsys = dtvdd_devp->last_delsys;
@@ -3369,7 +3374,7 @@ static int delsys_confirm(struct dvb_frontend *fe)
 
        return 0;
 }
-
+#endif
 static int delsys_set(struct dvb_frontend *fe, unsigned int delsys)
 {
        enum fe_delivery_system ldelsys = dtvdd_devp->last_delsys;
@@ -3510,7 +3515,10 @@ static int delsys_set(struct dvb_frontend *fe, unsigned int delsys)
                fe->ops.info.type = FE_ATSC;
        else if (mode == AM_FE_OFDM_N || mode == AM_FE_ISDBT_N)
                fe->ops.info.type = FE_OFDM;
-
+       else if (mode == AM_FE_DTMB_N)
+               fe->ops.info.type = FE_DTMB;
+       else if (mode == AM_FE_QAM_N)
+               fe->ops.info.type = FE_QAM;
        fe->ops.tuner_ops.set_config(fe, NULL);
 
 #endif
@@ -3541,6 +3549,16 @@ static int aml_dtvdm_init(struct dvb_frontend *fe)
 }
 static int aml_dtvdm_sleep(struct dvb_frontend *fe)
 {
+       enum aml_fe_n_mode_t nmode = dtvdd_devp->n_mode;
+
+       if (get_dtvpll_init_flag()) {
+               PR_INFO("%s\n", __func__);
+               leave_mode(nmode);
+               if (fe->ops.tuner_ops.release)
+                       fe->ops.tuner_ops.release(fe);
+               dtvdd_devp->last_delsys = SYS_UNDEFINED;
+               dtvdd_devp->n_mode = AM_FE_UNKNOWN_N;
+       }
        return 0;
 }
 static int aml_dtvdm_set_parameters(struct dvb_frontend *fe)
@@ -3550,7 +3568,7 @@ static int aml_dtvdm_set_parameters(struct dvb_frontend *fe)
 
        PR_INFO("%s", __func__);
 
-       delsys_confirm(fe);
+       /*delsys_confirm(fe);*/
        if (is_not_active(fe)) {
                PR_DBG("set parm:not active\n");
                return 0;
@@ -3912,6 +3930,15 @@ static void aml_dtvdm_release(struct dvb_frontend *fe)
 
                break;
        }
+
+       if (get_dtvpll_init_flag()) {
+               PR_INFO("%s\n", __func__);
+               leave_mode(nmode);
+               if (fe->ops.tuner_ops.release)
+                       fe->ops.tuner_ops.release(fe);
+               dtvdd_devp->last_delsys = SYS_UNDEFINED;
+               dtvdd_devp->n_mode = AM_FE_UNKNOWN_N;
+       }
 }
 
 
@@ -3923,7 +3950,7 @@ static int aml_dtvdm_tune(struct dvb_frontend *fe, bool re_tune,
        static int flg; /*debug only*/
 
        if (re_tune)
-               delsys_confirm(fe);
+               ;//delsys_confirm(fe);
 
        if (nmode == AM_FE_UNKNOWN_N) {
                *delay = HZ * 5;
@@ -4037,10 +4064,10 @@ static struct dvb_frontend_ops aml_dtvdm_gxtvbb_ops = {
 };
 
 static struct dvb_frontend_ops aml_dtvdm_txl_ops = {
-       .delsys = { SYS_DVBC_ANNEX_A, SYS_DTMB},
+       .delsys = { /*SYS_DVBC_ANNEX_A,*/ SYS_DTMB, SYS_ANALOG},
        .info = {
                /*in aml_fe, it is 'amlogic dvb frontend' */
-               .name = "amlogic dtv demod txlx",
+               .name = "amlogic dtv demod txl",
                .frequency_min      = 51000000,
                .frequency_max      = 900000000,
                .frequency_stepsize = 0,
index 5e1d96cf487383b5b698ff52ecbd68c3ecc31ba6..1a1513d28508fea6f4257510ba6628c569b2edb1 100644 (file)
@@ -506,12 +506,12 @@ int dtmb_check_status_txl(struct dvb_frontend *fe)
        int time_cnt;
 
        time_cnt = 0;
-       /*ary temp dtmb_information();*/
+       dtmb_information();
        if (check_dtmb_fec_lock() != 1) {
                while ((time_cnt < 10) && (check_dtmb_fec_lock() != 1)) {
                        msleep(demod_timeout);
                        time_cnt++;
-                       /*ary temp dtmb_information();*/
+                       dtmb_information();
                        if (((dtmb_read_reg(DTMB_TOP_CTRL_CHE_WORKCNT)
                                >> 21) & 0x1) == 0x1) {
                                PR_DTMB("4qam-nr,need set spectrum\n");
@@ -527,8 +527,7 @@ int dtmb_check_status_txl(struct dvb_frontend *fe)
                                }
                        }
                        if (time_cnt > 8)
-                               PR_DTMB
-                                       ("* time_cnt = %d\n", time_cnt);
+                               PR_DTMB("* time_cnt = %d\n", time_cnt);
                }
                if (time_cnt >= 10 && (check_dtmb_fec_lock() != 1)) {
                        time_cnt = 0;
@@ -538,8 +537,7 @@ int dtmb_check_status_txl(struct dvb_frontend *fe)
                                dtmb_spectrum = 1;
                        else
                                dtmb_spectrum = 0;
-                       PR_DTMB
-                               ("*all reset,timeout is %d\n", demod_timeout);
+                       PR_DTMB("*all reset,timeout is %d\n", demod_timeout);
                }
        } else {
                dtmb_bch_check();
@@ -723,6 +721,7 @@ unsigned int dtmb_detect_first(void)
 
        /*fsm status is 4,maybe analog signal*/
        dtmb_status = dtmb_read_reg(DTMB_TOP_CTRL_FSM_STATE0);
+       PR_DTMB("fsm_status is %x\n", dtmb_status);
 
        for (i = 0 ; i < 8 ; i++) {
                if (((dtmb_status >> (i*4)) & 0xf) > 4) {
@@ -738,6 +737,7 @@ unsigned int dtmb_detect_first(void)
                /*(7->8) 8ms,(8->9) 55ms, (9->a) 350ms*/
                msleep(500);
                dtmb_status = dtmb_read_reg(DTMB_TOP_CTRL_FSM_STATE0);
+               PR_DTMB("fsm_status2 is %x\n", dtmb_status);
                for (i = 0 ; i < 8 ; i++) {
                        if (((dtmb_status >> (i*4))
                                & 0xf) > 6) {
@@ -750,7 +750,8 @@ unsigned int dtmb_detect_first(void)
 
        PR_DTMB("[DTV]has_signal is %d\n", has_signal);
        if ((has_signal == 0) || (has_signal == 0x1)) {
-               timeout = 1;    /*FE_TIMEDOUT;*/
+               //timeout = 1;  /*FE_TIMEDOUT;*/
+               timeout = 0;    /*FE_TIMEDOUT;*/
                PR_DTMB("\t timeout\n");
 
        } else {