media_modules: remove tuner and demod attach [2/4]
authornengwen.chen <nengwen.chen@amlogic.com>
Mon, 21 Dec 2020 10:27:14 +0000 (18:27 +0800)
committergerrit autosubmit <gerrit.autosubmit@scgit.amlogic.com>
Thu, 24 Dec 2020 07:01:00 +0000 (23:01 -0800)
PD#SWPL-39474

Problem:
remove tuner and demod attach.

Solution:
1.remove tuner and demod attach.
2.remove tuner and demod dts property.
3.dvb_extern_register_frontend()/dvb_extern_unregister_frontend().

Verify:
Verified by ac214, ac232, ah212.

Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
Change-Id: Ied4db82c8514a1c116aa5425058288eb7a9ec1e0

drivers/stream_input/parser/demux/aml_dvb.c
drivers/stream_input/parser/demux/aml_dvb.h
drivers/stream_input/parser/demux/hw_demux/frontend.c
drivers/stream_input/parser/dvb_common.h
drivers/stream_input/parser/hw_demux/aml_dvb.c
drivers/stream_input/parser/hw_demux/aml_dvb.h

index 8c4df62054f527285c802661983811383af07edc..57c1371f234ff7fba21e0c147e19a135b4b1293e 100644 (file)
 #define pr_error(fmt, args...) printk("DVB: " fmt, ## args)
 #define pr_inf(fmt, args...)   printk("DVB: " fmt, ## args)
 
-#define CARD_NAME "amlogic-dvb"
+#define CARD_NAME "amlogic-dvb-swdmx"
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
-extern ssize_t stb_show_tuner_setting(struct class *class,
-                                  struct class_attribute *attr, char *buf);
-extern ssize_t stb_store_tuner_setting(struct class *class,
-                                   struct class_attribute *attr,
-                                   const char *buf, size_t count);
-
 static struct aml_dvb aml_dvb_device;
 typedef struct _ChainPath
 {
@@ -350,7 +344,6 @@ static struct class_attribute aml_dvb_class_attrs[] = {
                        path0_set_buf_warning_level),
        __ATTR(path1_buf_status, 0664, path1_show_buf_warning_status,\
                        path1_set_buf_warning_level),\
-       __ATTR(tuner_setting, 0664, stb_show_tuner_setting, stb_store_tuner_setting),
        __ATTR_NULL
 };
 
@@ -638,7 +631,7 @@ struct platform_driver aml_dvb_driver = {
        .suspend = NULL,
        .resume = NULL,
        .driver = {
-                  .name = "amlogic-dvb",
+                  .name = "amlogic-dvb-swdmx",
                   .owner = THIS_MODULE,
 #ifdef CONFIG_OF
           .of_match_table = aml_dvb_dt_match,
index 539025d5856f7518432f1dd74d2fc93f55994fb6..400de148e734b6134eb50f2f8c6c05685f9f3c62 100644 (file)
@@ -50,11 +50,6 @@ struct aml_dvb {
        spinlock_t slock;
 
        int ts_out_invert;
-
-       unsigned int tuner_num;
-       unsigned int tuner_cur;
-       struct aml_tuner *tuners;
-       bool tuner_attached;
 };
 
 struct aml_dvb *aml_get_dvb_device(void);
index 90a70c4a9bcbaa9c7f1f01a89be1ff7f0a8f44c2..4152ec558320bfc1c16778191280c4a1bf397e2d 100644 (file)
 #include "../../../../common/media_clock/switch/amports_gate.h"
 
 #define pr_error(fmt, args...) printk("DVB: " fmt, ## args)
-#define pr_inf(fmt, args...)   printk("DVB: " fmt, ## args)
-
-static struct dvb_frontend *frontend[FE_DEV_COUNT] = {NULL, NULL};
-static enum dtv_demod_type s_demod_type[FE_DEV_COUNT] = {AM_DTV_DEMOD_NONE, AM_DTV_DEMOD_NONE};
-static enum tuner_type s_tuner_type[FE_DEV_COUNT] = {AM_TUNER_NONE, AM_TUNER_NONE};
-
-
-ssize_t stb_show_tuner_setting(struct class *class,
-                                  struct class_attribute *attr, char *buf)
-{
-       struct aml_dvb *dvb = aml_get_dvb_device();
-
-       if (dvb->tuner_cur >= 0)
-               pr_inf("dvb current attatch tuner %d, id: %d\n",
-                               dvb->tuner_cur, dvb->tuners[dvb->tuner_cur].cfg.id);
-       else
-               pr_inf("dvb has no attatch tuner.\n");
-
-       return 0;
-}
-
-ssize_t stb_store_tuner_setting(struct class *class,
-                                   struct class_attribute *attr,
-                                   const char *buf, size_t count)
-{
-       int n = 0, i = 0, val = 0;
-       unsigned long tmp = 0;
-       char *buf_orig = NULL, *ps = NULL, *token = NULL;
-       char *parm[4] = { NULL };
-       struct aml_dvb *dvb = aml_get_dvb_device();
-       int tuner_id = 0;
-       struct aml_tuner *tuner = NULL;
-
-       buf_orig = kstrdup(buf, GFP_KERNEL);
-       ps = buf_orig;
-
-       while (1) {
-               token = strsep(&ps, "\n ");
-               if (token == NULL)
-                       break;
-               if (*token == '\0')
-                       continue;
-               parm[n++] = token;
-       }
-
-       if (parm[0] && kstrtoul(parm[0], 10, &tmp) == 0) {
-               val = tmp;
-
-               for (i = 0; i < dvb->tuner_num; ++i) {
-                       if (dvb->tuners[i].cfg.id == val) {
-                               tuner_id = dvb->tuners[i].cfg.id;
-                               break;
-                       }
-               }
-
-               if (tuner_id == 0 || dvb->tuner_cur == i) {
-                       pr_error("%s: set nonsupport or the same tuner %d.\n",
-                                       __func__, val);
-                       goto EXIT;
-               }
-
-               dvb->tuner_cur = i;
-
-               for (i = 0; i < FE_DEV_COUNT; i++) {
-                       tuner = &dvb->tuners[dvb->tuner_cur];
-
-                       if (frontend[i] == NULL)
-                               continue;
-
-                       if (aml_attach_tuner(tuner->cfg.id, frontend[i], &tuner->cfg) == NULL) {
-                               s_tuner_type[i] = AM_TUNER_NONE;
-                               pr_error("tuner[%d] [type = %d] attach error.\n", dvb->tuner_cur, tuner->cfg.id);
-                               goto EXIT;
-                       } else {
-                               s_tuner_type[i] = tuner->cfg.id;
-                               pr_error("tuner[%d] [type = %d] attach sucess.\n", dvb->tuner_cur, tuner->cfg.id);
-                       }
-               }
-
-               pr_error("%s: attach tuner %d done.\n", __func__, dvb->tuners[dvb->tuner_cur].cfg.id);
-       }
-
-EXIT:
-
-       return count;
-}
-
 
 int frontend_probe(struct platform_device *pdev)
 {
-       struct demod_config config;
-       struct tuner_config *tuner_cfg = NULL;
-       char buf[32];
-       const char *str = NULL;
-       struct device_node *node_tuner = NULL;
-       struct device_node *node_i2c = NULL;
-       u32 i2c_addr = 0xFFFFFFFF;
-       u32 value = 0;
-       int i = 0;
-       int ret =0;
-       int j = 0;
+       int ret = 0;
+#if (defined CONFIG_AMLOGIC_DVB_EXTERN)
        struct aml_dvb *advb = aml_get_dvb_device();
 
-       for (i=0; i<FE_DEV_COUNT; i++) {
-               memset(&config, 0, sizeof(struct demod_config));
-
-               memset(buf, 0, 32);
-               snprintf(buf, sizeof(buf), "fe%d_mode", i);
-               ret = of_property_read_string(pdev->dev.of_node, buf, &str);
-               if (ret) {
-                       continue;
-               }
-
-               if (!strcmp(str, "internal")) {
-                       config.mode = 0;
-                       config.id = AM_DTV_DEMOD_AMLDTV;
-                       frontend[i] = aml_attach_dtvdemod(config.id, &config);
-                       if (frontend[i] == NULL) {
-                               s_demod_type[i] = AM_DTV_DEMOD_NONE;
-                               pr_error("internal dtvdemod [type = %d] attach error.\n", config.id);
-                               goto error_fe;
-                       } else {
-                               s_demod_type[i] = config.id;
-                               pr_error("internal dtvdemod [type = %d] attach success.\n", config.id);
-                       }
+       ret = dvb_extern_register_frontend(&advb->dvb_adapter);
+       if (ret)
+               pr_error("aml register dvb frontend failed\n");
+#endif
 
-                       memset(buf, 0, 32);
-                       snprintf(buf, sizeof(buf), "fe%d_tuner",i);
-                       node_tuner = of_parse_phandle(pdev->dev.of_node, buf, 0);
-                       if (!node_tuner){
-                               pr_err("can't find tuner.\n");
-                               goto error_fe;
-                       }
-                       ret = of_property_read_u32(node_tuner, "tuner_num", &value);
-                       if (ret) {
-                               pr_err("can't find tuner_num.\n");
-                               goto error_fe;
-                       } else
-                               advb->tuner_num = value;
-
-                       advb->tuners = kzalloc(sizeof(struct aml_tuner) * advb->tuner_num, GFP_KERNEL);
-                       if (!advb->tuners) {
-                               pr_err("can't kzalloc for tuners.\n");
-                               goto error_fe;
-                       }
-
-                       ret = of_property_read_u32(node_tuner, "tuner_cur", &value);
-                       if (ret) {
-                               pr_err("can't find tuner_cur, use default 0.\n");
-                               advb->tuner_cur = -1;
-                       } else
-                               advb->tuner_cur = value;
-
-                       for (j = 0; j < advb->tuner_num; ++j) {
-                               snprintf(buf, sizeof(buf), "tuner_name_%d", j);
-                               ret = of_property_read_string(node_tuner, buf, &str);
-                               if (ret) {
-                                       //pr_error("tuner%d type error\n",i);
-                                       ret = 0;
-                                       continue;
-                               } else {
-                                       advb->tuners[j].cfg.id = aml_get_tuner_type(str);
-                                       if (advb->tuners[j].cfg.id == AM_TUNER_NONE)
-                                               pr_err("can't support tuner: %s.\n", str);
-                               }
-
-                               snprintf(buf, sizeof(buf), "tuner_i2c_adap_%d", j);
-                               node_i2c = of_parse_phandle(node_tuner, buf, 0);
-                               if (!node_i2c) {
-                                       pr_error("tuner_i2c_adap_id error\n");
-                               } else {
-                                       advb->tuners[j].cfg.i2c_adap = of_find_i2c_adapter_by_node(node_i2c);
-                                       of_node_put(node_i2c);
-                                       if (advb->tuners[j].cfg.i2c_adap == NULL) {
-                                               pr_error("i2c_get_adapter error\n");
-                                               of_node_put(node_tuner);
-                                               goto error_fe;
-                                       }
-                               }
-
-                               snprintf(buf, sizeof(buf), "tuner_i2c_addr_%d", j);
-                               ret = of_property_read_u32(node_tuner, buf, &i2c_addr);
-                               if (ret) {
-                                       pr_error("i2c_addr error\n");
-                               }
-                               else
-                                       advb->tuners[j].cfg.i2c_addr = i2c_addr;
-
-                               snprintf(buf, sizeof(buf), "tuner_xtal_%d", j);
-                               ret = of_property_read_u32(node_tuner, buf, &value);
-                               if (ret)
-                                       pr_err("tuner_xtal error.\n");
-                               else
-                                       advb->tuners[j].cfg.xtal = value;
-
-                               snprintf(buf, sizeof(buf), "tuner_xtal_mode_%d", j);
-                               ret = of_property_read_u32(node_tuner, buf, &value);
-                               if (ret)
-                                       pr_err("tuner_xtal_mode error.\n");
-                               else
-                                       advb->tuners[j].cfg.xtal_mode = value;
-
-                               snprintf(buf, sizeof(buf), "tuner_xtal_cap_%d", j);
-                               ret = of_property_read_u32(node_tuner, buf, &value);
-                               if (ret)
-                                       pr_err("tuner_xtal_cap error.\n");
-                               else
-                                       advb->tuners[j].cfg.xtal_cap = value;
-                       }
-
-                       of_node_put(node_tuner);
-
-                       /* define general-purpose callback pointer */
-                       frontend[i]->callback = NULL;
-
-                       if (advb->tuner_cur >= 0) {
-                               tuner_cfg = &advb->tuners[advb->tuner_cur].cfg;
-                               if (aml_attach_tuner(tuner_cfg->id, frontend[i], tuner_cfg) == NULL) {
-                                       s_tuner_type[i] = AM_TUNER_NONE;
-                                       pr_error("tuner [type = %d] attach error.\n", tuner_cfg->id);
-                                       goto error_fe;
-                               } else {
-                                       s_tuner_type[i] = tuner_cfg->id;
-                                       pr_error("tuner [type = %d] attach sucess.\n", tuner_cfg->id);
-                               }
-                       }
-
-                       ret = dvb_register_frontend(&advb->dvb_adapter, frontend[i]);
-                       if (ret) {
-                               pr_error("register dvb frontend failed\n");
-                               goto error_fe;
-                       }
-               } else if(!strcmp(str, "external")) {
-                       config.mode = 1;
-                       config.id = AM_DTV_DEMOD_NONE;
-                       ret = aml_get_dts_demod_config(pdev->dev.of_node, &config, i);
-                       if (ret) {
-                               pr_err("can't find demod %d.\n", i);
-                               continue;
-                       }
-
-                       memset(buf, 0, 32);
-                       snprintf(buf, sizeof(buf), "fe%d_tuner", i);
-                       node_tuner = of_parse_phandle(pdev->dev.of_node, buf, 0);
-                       if (node_tuner) {
-                               aml_get_dts_tuner_config(node_tuner, &config.tuner0, 0);
-                               aml_get_dts_tuner_config(node_tuner, &config.tuner1, 1);
-                       } else
-                               pr_err("can't find %s.\n", buf);
-
-                       of_node_put(node_tuner);
-
-                       frontend[i] = aml_attach_dtvdemod(config.id, &config);
-                       if (frontend[i] == NULL) {
-                               s_demod_type[i] = AM_DTV_DEMOD_NONE;
-                               pr_error("external dtvdemod [type = %d] attach error.\n", config.id);
-                               goto error_fe;
-                       } else {
-                               s_demod_type[i] = config.id;
-                               pr_error("external dtvdemod [type = %d] attach success.\n", config.id);
-                       }
-
-                       if (frontend[i]) {
-                               ret = dvb_register_frontend(&advb->dvb_adapter, frontend[i]);
-                               if (ret) {
-                                       pr_error("register dvb frontend failed\n");
-                                       goto error_fe;
-                               }
-                       }
-               }
-       }
-       if (advb->tuners)
-               kfree(advb->tuners);
-       return 0;
-error_fe:
-       for (i=0; i<FE_DEV_COUNT; i++) {
-               aml_detach_dtvdemod(s_demod_type[i]);
-               frontend[i] = NULL;
-               s_demod_type[i] = AM_DTV_DEMOD_NONE;
-
-               aml_detach_tuner(s_tuner_type[i]);
-               s_tuner_type[i] = AM_TUNER_NONE;
-       }
-
-       if (advb->tuners)
-               kfree(advb->tuners);
-
-       return 0;
+       return ret;
 }
 
 int frontend_remove(void)
 {
-       int i;
-
-       for (i=0; i<FE_DEV_COUNT; i++) {
-               aml_detach_dtvdemod(s_demod_type[i]);
-
-               aml_detach_tuner(s_tuner_type[i]);
-
-               if (frontend[i] &&
-                       ((s_tuner_type[i] == AM_TUNER_SI2151)
-                       || (s_tuner_type[i] == AM_TUNER_MXL661)
-                       || (s_tuner_type[i] == AM_TUNER_SI2159)
-                       || (s_tuner_type[i] == AM_TUNER_R842)
-                       || (s_tuner_type[i] == AM_TUNER_R840)
-                       || (s_tuner_type[i] == AM_TUNER_ATBM2040))) {
-                       dvb_unregister_frontend(frontend[i]);
-                       dvb_frontend_detach(frontend[i]);
-               }
-
-               frontend[i] = NULL;
-               s_demod_type[i] = AM_DTV_DEMOD_NONE;
-               s_tuner_type[i] = AM_TUNER_NONE;
+#if (defined CONFIG_AMLOGIC_DVB_EXTERN)
+       dvb_extern_unregister_frontend();
+#endif
 
-       }
        return 0;
 }
 
index 3b8a2087fc8326a2923a79036c6583c4bf72d7f4..eae2625f43c1da42732c430e0f788814d027d631 100644 (file)
@@ -18,8 +18,7 @@
 #ifndef __DVB_COMMON_H__
 #define __DVB_COMMON_H__
 
-#include <linux/amlogic/aml_dtvdemod.h>
-#include <linux/amlogic/aml_tuner.h>
+#include <linux/amlogic/aml_dvb_extern.h>
 
 #include "dvb_frontend.h"
 
index bd9d3e77e72eeb803fe95dbfc9f7fb62f26b80ca..4e1549c0f01706e70fe1736e1af5bd21d6c3c9e3 100644 (file)
@@ -70,9 +70,9 @@ MODULE_PARM_DESC(debug_dvb, "\n\t\t Enable dvb debug information");
 static int debug_dvb;
 module_param(debug_dvb, int, 0644);
 
-#define CARD_NAME "amlogic-dvb"
+#define CARD_NAME "amlogic-dvb-demux"
 
-#define DVB_VERSION "V2.00"
+#define DVB_VERSION "V2.02"
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
@@ -83,9 +83,6 @@ module_param(dsc_max, int, 0644);
 static struct aml_dvb aml_dvb_device;
 static struct class aml_stb_class;
 
-static struct dvb_frontend *frontend[FE_DEV_COUNT] = {NULL, NULL};
-static enum dtv_demod_type s_demod_type[FE_DEV_COUNT] = {AM_DTV_DEMOD_NONE, AM_DTV_DEMOD_NONE};
-static enum tuner_type s_tuner_type[FE_DEV_COUNT] = {AM_TUNER_NONE, AM_TUNER_NONE};
 static int dmx_reset_all_flag = 0;
 #if 0
 static struct reset_control *aml_dvb_demux_reset_ctl;
@@ -1974,86 +1971,6 @@ static ssize_t stb_store_hw_setting(struct class *class,
        return count;
 }
 
-static ssize_t stb_show_tuner_setting(struct class *class,
-                                  struct class_attribute *attr, char *buf)
-{
-       struct aml_dvb *dvb = &aml_dvb_device;
-
-       if (dvb->tuner_cur >= 0)
-               pr_inf("dvb current attatch tuner %d, id: %d\n",
-                               dvb->tuner_cur, dvb->tuners[dvb->tuner_cur].cfg.id);
-       else
-               pr_inf("dvb has no attatch tuner.\n");
-
-       return 0;
-}
-
-static ssize_t stb_store_tuner_setting(struct class *class,
-                                   struct class_attribute *attr,
-                                   const char *buf, size_t count)
-{
-       int n = 0, i = 0, val = 0;
-       unsigned long tmp = 0;
-       char *buf_orig = NULL, *ps = NULL, *token = NULL;
-       char *parm[4] = { NULL };
-       struct aml_dvb *dvb = &aml_dvb_device;
-       int tuner_id = 0;
-       struct aml_tuner *tuner = NULL;
-
-       buf_orig = kstrdup(buf, GFP_KERNEL);
-       ps = buf_orig;
-
-       while (1) {
-               token = strsep(&ps, "\n ");
-               if (token == NULL)
-                       break;
-               if (*token == '\0')
-                       continue;
-               parm[n++] = token;
-       }
-
-       if (parm[0] && kstrtoul(parm[0], 10, &tmp) == 0) {
-               val = tmp;
-
-               for (i = 0; i < dvb->tuner_num; ++i) {
-                       if (dvb->tuners[i].cfg.id == val) {
-                               tuner_id = dvb->tuners[i].cfg.id;
-                               break;
-                       }
-               }
-
-               if (tuner_id == 0 || dvb->tuner_cur == i) {
-                       pr_error("%s: set nonsupport or the same tuner %d.\n",
-                                       __func__, val);
-                       goto EXIT;
-               }
-
-               dvb->tuner_cur = i;
-
-               for (i = 0; i < FE_DEV_COUNT; i++) {
-                       tuner = &dvb->tuners[dvb->tuner_cur];
-
-                       if (frontend[i] == NULL)
-                               continue;
-
-                       if (aml_attach_tuner(tuner->cfg.id, frontend[i], &tuner->cfg) == NULL) {
-                               s_tuner_type[i] = AM_TUNER_NONE;
-                               pr_error("tuner[%d] [type = %d] attach error.\n", dvb->tuner_cur, tuner->cfg.id);
-                               goto EXIT;
-                       } else {
-                               s_tuner_type[i] = tuner->cfg.id;
-                               pr_error("tuner[%d] [type = %d] attach sucess.\n", dvb->tuner_cur, tuner->cfg.id);
-                       }
-               }
-
-               pr_error("%s: attach tuner %d done.\n", __func__, dvb->tuners[dvb->tuner_cur].cfg.id);
-       }
-
-EXIT:
-
-       return count;
-}
-
 static struct class_attribute aml_stb_class_attrs[] = {
        __ATTR(hw_setting, 0664, stb_show_hw_setting,
               stb_store_hw_setting),
@@ -2199,8 +2116,6 @@ static struct class_attribute aml_stb_class_attrs[] = {
        DSC_FREE_ATTR_DECL(1),
 #endif
 
-       __ATTR(tuner_setting, 0664, stb_show_tuner_setting, stb_store_tuner_setting),
-
        __ATTR_NULL
 };
 
@@ -2471,155 +2386,15 @@ static int aml_dvb_probe(struct platform_device *pdev)
        tsdemux_set_ops(NULL);
 #endif
 
-       //pengcc add for dvb using linux TV frontend api init
-       {
-               struct demod_config config;
-               struct tuner_config *tuner_cfg = NULL;
-               char buf[32];
-               const char *str = NULL;
-               struct device_node *node_tuner = NULL;
-               u32 value = 0;
-               int j = 0;
-
-               for (i=0; i<FE_DEV_COUNT; i++) {
-                       memset(&config, 0, sizeof(struct demod_config));
-
-                       memset(buf, 0, 32);
-                       snprintf(buf, sizeof(buf), "fe%d_mode", i);
-                       ret = of_property_read_string(pdev->dev.of_node, buf, &str);
-                       if (ret) {
-                               continue;
-                       }
-                       if (!strcmp(str, "internal")) {
-                               config.mode = 0;
-                               config.id = AM_DTV_DEMOD_AMLDTV;
-                               frontend[i] = aml_attach_dtvdemod(config.id, &config);
-                               if (frontend[i] == NULL) {
-                                       s_demod_type[i] = AM_DTV_DEMOD_NONE;
-                                       pr_error("internal dtvdemod [type = %d] attach error.\n", config.id);
-                                       goto error_fe;
-                               } else {
-                                       s_demod_type[i] = config.id;
-                                       pr_error("internal dtvdemod [type = %d] attach success.\n", config.id);
-                               }
-
-                               memset(buf, 0, 32);
-                               snprintf(buf, sizeof(buf), "fe%d_tuner",i);
-                               node_tuner = of_parse_phandle(pdev->dev.of_node, buf, 0);
-                               if (!node_tuner) {
-                                       pr_err("can't find tuner.\n");
-                                       goto error_fe;
-                               }
-
-                               ret = of_property_read_u32(node_tuner, "tuner_num", &value);
-                               if (ret) {
-                                       pr_err("can't find tuner_num.\n");
-                                       goto error_fe;
-                               } else
-                                       advb->tuner_num = value;
-
-                               advb->tuners = kzalloc(sizeof(struct aml_tuner) * advb->tuner_num, GFP_KERNEL);
-                               if (!advb->tuners) {
-                                       pr_err("can't kzalloc for tuners.\n");
-                                       goto error_fe;
-                               }
-
-                               ret = of_property_read_u32(node_tuner, "tuner_cur", &value);
-                               if (ret) {
-                                       pr_err("can't find tuner_cur, use default 0.\n");
-                                       advb->tuner_cur = -1;
-                               } else
-                                       advb->tuner_cur = value;
-
-                               for (j = 0; j < advb->tuner_num; ++j) {
-                                       ret = aml_get_dts_tuner_config(node_tuner, &advb->tuners[j].cfg, j);
-                                       if (ret) {
-                                               pr_err("can't find tuner.\n");
-                                               goto error_fe;
-                                       }
-                               }
-
-                               of_node_put(node_tuner);
-
-                               /* define general-purpose callback pointer */
-                               frontend[i]->callback = NULL;
-
-                               if (advb->tuner_cur >= 0) {
-                                       tuner_cfg = &advb->tuners[advb->tuner_cur].cfg;
-                                       if (aml_attach_tuner(tuner_cfg->id, frontend[i], tuner_cfg) == NULL) {
-                                               s_tuner_type[i] = AM_TUNER_NONE;
-                                               pr_error("tuner [type = %d] attach error.\n", tuner_cfg->id);
-                                               goto error_fe;
-                                       } else {
-                                               s_tuner_type[i] = tuner_cfg->id;
-                                               pr_error("tuner [type = %d] attach sucess.\n", tuner_cfg->id);
-                                       }
-                               }
-
-                               ret = dvb_register_frontend(&advb->dvb_adapter, frontend[i]);
-                               if (ret) {
-                                       pr_error("register dvb frontend failed\n");
-                                       goto error_fe;
-                               }
-                       } else if(!strcmp(str, "external")) {
-                               config.mode = 1;
-                               config.id = AM_DTV_DEMOD_NONE;
-                               ret = aml_get_dts_demod_config(pdev->dev.of_node, &config, i);
-                               if (ret) {
-                                       pr_err("can't find demod %d.\n", i);
-                                       continue;
-                               }
-
-                               memset(buf, 0, 32);
-                               snprintf(buf, sizeof(buf), "fe%d_tuner", i);
-                               node_tuner = of_parse_phandle(pdev->dev.of_node, buf, 0);
-                               if (node_tuner) {
-                                       aml_get_dts_tuner_config(node_tuner, &config.tuner0, 0);
-                                       aml_get_dts_tuner_config(node_tuner, &config.tuner1, 1);
-                               } else
-                                       pr_err("can't find %s.\n", buf);
-
-                               of_node_put(node_tuner);
-
-                               if (advb->ts[config.ts].mode == AM_TS_PARALLEL)
-                                       config.ts_out_mode = 1;
-                               else
-                                       config.ts_out_mode = 0;
-
-                               frontend[i] = aml_attach_dtvdemod(config.id, &config);
-                               if (frontend[i] == NULL) {
-                                       s_demod_type[i] = AM_DTV_DEMOD_NONE;
-                                       pr_error("external dtvdemod [type = %d] attach error.\n", config.id);
-                                       goto error_fe;
-                               } else {
-                                       s_demod_type[i] = config.id;
-                                       pr_error("external dtvdemod [type = %d] attach success.\n", config.id);
-                               }
-
-                               if (frontend[i]) {
-                                       ret = dvb_register_frontend(&advb->dvb_adapter, frontend[i]);
-                                       if (ret) {
-                                               pr_error("register dvb frontend failed\n");
-                                               goto error_fe;
-                                       }
-                               }
-                       }
-               }
-               return 0;
-error_fe:
-               for (i=0; i<FE_DEV_COUNT; i++) {
-                       aml_detach_dtvdemod(s_demod_type[i]);
-                       frontend[i] = NULL;
-                       s_demod_type[i] = AM_DTV_DEMOD_NONE;
-
-                       aml_detach_tuner(s_tuner_type[i]);
-                       s_tuner_type[i] = AM_TUNER_NONE;
-               }
-
-               if (advb->tuners)
-                       kfree(advb->tuners);
-               return 0;
+#if (defined CONFIG_AMLOGIC_DVB_EXTERN)
+       ret = dvb_extern_register_frontend(&advb->dvb_adapter);
+       if (ret) {
+               pr_error("aml register dvb frontend failed\n");
+               goto error;
        }
+#endif
+
+       return 0;
 
 error:
        for (i = 0; i < advb->async_fifo_total_count; i++) {
@@ -2648,26 +2423,9 @@ static int aml_dvb_remove(struct platform_device *pdev)
 
        pr_inf("[dmx_kpi] %s Enter.\n", __func__);
 
-       for (i=0; i<FE_DEV_COUNT; i++) {
-               aml_detach_dtvdemod(s_demod_type[i]);
-
-               aml_detach_tuner(s_tuner_type[i]);
-
-               if (frontend[i] &&
-                       ((s_tuner_type[i] == AM_TUNER_SI2151)
-                       || (s_tuner_type[i] == AM_TUNER_MXL661)
-                       || (s_tuner_type[i] == AM_TUNER_SI2159)
-                       || (s_tuner_type[i] == AM_TUNER_R842)
-                       || (s_tuner_type[i] == AM_TUNER_R840)
-                       || (s_tuner_type[i] == AM_TUNER_ATBM2040))) {
-                       dvb_unregister_frontend(frontend[i]);
-                       dvb_frontend_detach(frontend[i]);
-               }
-
-               frontend[i] = NULL;
-               s_demod_type[i] = AM_DTV_DEMOD_NONE;
-               s_tuner_type[i] = AM_TUNER_NONE;
-       }
+#if (defined CONFIG_AMLOGIC_DVB_EXTERN)
+       dvb_extern_unregister_frontend();
+#endif
 
        tsdemux_set_ops(NULL);
 
@@ -2724,9 +2482,6 @@ static int aml_dvb_remove(struct platform_device *pdev)
 #endif
 #endif
 
-       if (advb->tuners)
-               kfree(advb->tuners);
-
        pr_inf("[dmx_kpi] %s Exit.\n", __func__);
        return 0;
 }
@@ -2751,7 +2506,7 @@ static int aml_dvb_resume(struct platform_device *dev)
 #ifdef CONFIG_OF
 static const struct of_device_id aml_dvb_dt_match[] = {
        {
-        .compatible = "amlogic, dvb",
+        .compatible = "amlogic, dvb-demux",
         },
        {},
 };
@@ -2763,7 +2518,7 @@ static struct platform_driver aml_dvb_driver = {
        .suspend = aml_dvb_suspend,
        .resume = aml_dvb_resume,
        .driver = {
-                  .name = "amlogic-dvb",
+                  .name = "amlogic-dvb-demux",
                   .owner = THIS_MODULE,
 #ifdef CONFIG_OF
           .of_match_table = aml_dvb_dt_match,
index bb9e733be3efb7d1241002828ae628adb4f4a2ab..12ed65b62e7396ace116ffa4f6ae1e8361e51330 100644 (file)
@@ -333,11 +333,6 @@ struct aml_dvb {
        struct aml_swfilter  swfilter;
        int     ts_out_invert;
 
-       unsigned int tuner_num;
-       int tuner_cur;
-       struct aml_tuner *tuners;
-       bool tuner_attached;
-
        /*bufs for dmx shared*/
        unsigned long        pes_pages;
        unsigned long        pes_pages_map;
@@ -345,8 +340,6 @@ struct aml_dvb {
        unsigned long        sub_pages;
        unsigned long        sub_pages_map;
        int                  sub_buf_len;
-
-
 };