author | nengwen.chen <nengwen.chen@amlogic.com> | 2020-05-20 12:05:22 (GMT) |
---|---|---|
committer | nengwen.chen <nengwen.chen@amlogic.com> | 2020-05-20 12:05:22 (GMT) |
commit | 81b659430ef6142d26910a27f06b40cc5207bc58 (patch) | |
tree | f6e40995f37580083013f0baba07d92db39aca57 | |
parent | db449239d4e20ce701ca19e696e79072ae3b6253 (diff) | |
download | media_modules-81b659430ef6142d26910a27f06b40cc5207bc58.zip media_modules-81b659430ef6142d26910a27f06b40cc5207bc58.tar.gz media_modules-81b659430ef6142d26910a27f06b40cc5207bc58.tar.bz2 |
media_modules: merge code from amlogic-4.9-dev [1/1]
PD#SWPL-26362
Problem:
1.merge code from amlogic-4.9-dev.
Solution:
1.merge code from amlogic-4.9-dev.
Verify:
Verified by ac214.
Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
Change-Id: I2c6dc8a8b75b97e1210e2285d450b099c5691df1
-rw-r--r-- | drivers/stream_input/parser/demux/hw_demux/frontend.c | 191 | ||||
-rw-r--r-- | drivers/stream_input/parser/dvb_common.c | 218 | ||||
-rw-r--r-- | drivers/stream_input/parser/dvb_common.h | 102 | ||||
-rw-r--r-- | drivers/stream_input/parser/hw_demux/aml_dvb.c | 241 | ||||
-rw-r--r-- | drivers/stream_input/parser/hw_demux/aml_dvb.h | 1 |
5 files changed, 98 insertions, 655 deletions
diff --git a/drivers/stream_input/parser/demux/hw_demux/frontend.c b/drivers/stream_input/parser/demux/hw_demux/frontend.c index 0e0e978..304786e 100644 --- a/drivers/stream_input/parser/demux/hw_demux/frontend.c +++ b/drivers/stream_input/parser/demux/hw_demux/frontend.c @@ -119,9 +119,13 @@ ssize_t tuner_setting_store(struct class *class, if (frontend[i] == NULL) continue; - if (dvb_attach_tuner(frontend[i], tuner, &s_tuner_type[i]) < 0) { - pr_error("attach tuner %d failed\n", dvb->tuner_cur); + 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); } } @@ -137,6 +141,7 @@ EXIT: 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; @@ -157,16 +162,18 @@ int frontend_probe(struct platform_device *pdev) if (ret) { continue; } - if (!strcmp(str,"internal")) { - config.mode = 0; - frontend[i] = dvb_attach_demod(&config, &s_demod_type[i], "internal"); + 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) { - pr_error("dvb attach demod error\n"); + s_demod_type[i] = AM_DTV_DEMOD_NONE; + pr_error("internal dtvdemod [type = %d] attach error.\n", config.id); goto error_fe; } else { - pr_inf("dtvdemod attatch sucess\n"); - s_demod_type[i] = AM_DTV_DEMOD_AML; + s_demod_type[i] = config.id; + pr_error("internal dtvdemod [type = %d] attach success.\n", config.id); } memset(buf, 0, 32); @@ -204,22 +211,9 @@ int frontend_probe(struct platform_device *pdev) ret = 0; continue; } else { - if (!strncmp(str, "mxl661_tuner", 12)) - advb->tuners[j].cfg.id = AM_TUNER_MXL661; - else if (!strncmp(str, "si2151_tuner", 12)) - advb->tuners[j].cfg.id = AM_TUNER_SI2151; - else if (!strncmp(str, "si2159_tuner", 12)) - advb->tuners[j].cfg.id = AM_TUNER_SI2159; - else if (!strncmp(str, "r840_tuner", 10)) - advb->tuners[j].cfg.id = AM_TUNER_R840; - else if (!strncmp(str, "r842_tuner", 10)) - advb->tuners[j].cfg.id = AM_TUNER_R842; - else if (!strncmp(str, "atbm2040_tuner", 14)) - advb->tuners[i].cfg.id = AM_TUNER_ATBM2040; - else { - pr_err("nonsupport tuner: %s.\n", str); - advb->tuners[j].cfg.id = AM_TUNER_NONE; - } + 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); @@ -227,9 +221,9 @@ int frontend_probe(struct platform_device *pdev) if (!node_i2c) { pr_error("tuner_i2c_adap_id error\n"); } else { - advb->tuners[j].i2c_adp = of_find_i2c_adapter_by_node(node_i2c); + advb->tuners[j].cfg.i2c_adap = of_find_i2c_adapter_by_node(node_i2c); of_node_put(node_i2c); - if (advb->tuners[j].i2c_adp == NULL) { + if (advb->tuners[j].cfg.i2c_adap == NULL) { pr_error("i2c_get_adapter error\n"); of_node_put(node_tuner); goto error_fe; @@ -272,9 +266,14 @@ int frontend_probe(struct platform_device *pdev) frontend[i]->callback = NULL; if (advb->tuner_cur >= 0) { - if (dvb_attach_tuner(frontend[i], &advb->tuners[advb->tuner_cur], &s_tuner_type[i]) < 0) { - pr_error("attach tuner failed\n"); + 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); } } @@ -283,128 +282,36 @@ int frontend_probe(struct platform_device *pdev) pr_error("register dvb frontend failed\n"); goto error_fe; } - } else if(!strcmp(str,"external")) { - const char *name = NULL; - + } else if(!strcmp(str, "external")) { config.mode = 1; - config.dev_id = i; - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_demod",i); - ret = of_property_read_string(pdev->dev.of_node, buf, &name); + config.id = AM_DTV_DEMOD_NONE; + ret = aml_get_dts_demod_config(pdev->dev.of_node, &config, i); if (ret) { - ret = 0; + pr_err("can't find demod %d.\n", i); continue; } memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_i2c_adap_id",i); - node_i2c = of_parse_phandle(pdev->dev.of_node,buf,0); - if (!node_i2c) { - pr_error("demod%d_i2c_adap_id error\n", i); - } else { - config.i2c_adap = of_find_i2c_adapter_by_node(node_i2c); - of_node_put(node_i2c); - if (config.i2c_adap == NULL) { - pr_error("i2c_get_adapter error\n"); - goto error_fe; - } - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_demod_i2c_addr",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.i2c_addr); - if (ret) { - pr_error("i2c_addr error\n"); - goto error_fe; - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_ts",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.ts); - if (ret) { - pr_error("ts error\n"); - goto error_fe; - } + 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); - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_reset_gpio",i); - ret = of_property_read_string(pdev->dev.of_node, buf, &str); - if (!ret) { - config.reset_gpio = - of_get_named_gpio_flags(pdev->dev.of_node, - buf, 0, NULL); - pr_inf("%s: %d\n", buf, config.reset_gpio); - } else { - config.reset_gpio = -1; - pr_error("cannot find resource \"%s\"\n", buf); - goto error_fe; - } + of_node_put(node_tuner); - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_reset_value",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.reset_value); - if (ret) { - pr_error("reset_value error\n"); - config.reset_value = 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; - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_ant_power_gpio", i); - ret = of_property_read_string(pdev->dev.of_node, buf, &str); - if (!ret) { - config.ant_power_gpio = - of_get_named_gpio_flags(pdev->dev.of_node, - buf, 0, NULL); - pr_inf("%s: %d\n", buf, config.ant_power_gpio); } else { - config.ant_power_gpio = -1; - pr_error("cannot find resource \"%s\"\n", buf); + s_demod_type[i] = config.id; + pr_error("external dtvdemod [type = %d] attach success.\n", config.id); } - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_ant_poweron_value", i); - ret = of_property_read_u32(pdev->dev.of_node, buf, &config.ant_power_value); - if (ret) { - pr_error("ant_power_value error\n"); - config.ant_power_value = 0; - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_tuner0_i2c_addr",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.tuner0_i2c_addr); - if (ret) { - pr_error("no tuner0 i2c_addr define\n"); - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_tuner1_i2c_addr",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.tuner1_i2c_addr); - if (ret) { - pr_error("no tuner1 addr define\n"); - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_tuner0_code",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.tuner0_code); - if (ret) { - pr_error("no tuner0_code define\n"); - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_tuner1_code",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.tuner1_code); - if (ret) { - pr_error("no tuner1_code define\n"); - } - - frontend[i] = dvb_attach_demod(&config, &s_demod_type[i], name); - if (frontend[i] == NULL) { - pr_error("dvb attach demod error\n"); - goto error_fe; - } else - pr_inf("dtvdemod attatch sucess\n"); - if (frontend[i]) { ret = dvb_register_frontend(&advb->dvb_adapter, frontend[i]); if (ret) { @@ -419,11 +326,11 @@ int frontend_probe(struct platform_device *pdev) return 0; error_fe: for (i=0; i<FE_DEV_COUNT; i++) { - dvb_detach_demod(&s_demod_type[i]); + aml_detach_dtvdemod(s_demod_type[i]); frontend[i] = NULL; s_demod_type[i] = AM_DTV_DEMOD_NONE; - dvb_detach_tuner(&s_tuner_type[i]); + aml_detach_tuner(s_tuner_type[i]); s_tuner_type[i] = AM_TUNER_NONE; } @@ -438,9 +345,9 @@ int frontend_remove(void) int i; for (i=0; i<FE_DEV_COUNT; i++) { - dvb_detach_demod(&s_demod_type[i]); + aml_detach_dtvdemod(s_demod_type[i]); - dvb_detach_tuner(&s_tuner_type[i]); + aml_detach_tuner(s_tuner_type[i]); if (frontend[i] && ((s_tuner_type[i] == AM_TUNER_SI2151) diff --git a/drivers/stream_input/parser/dvb_common.c b/drivers/stream_input/parser/dvb_common.c index 64564c4..ecea691 100644 --- a/drivers/stream_input/parser/dvb_common.c +++ b/drivers/stream_input/parser/dvb_common.c @@ -15,221 +15,3 @@ * */ -#include <linux/printk.h> -#include "dvb_common.h" - -#define pr_error(fmt, args...) printk("DVB: " fmt, ## args) - -int dvb_attach_tuner(struct dvb_frontend *fe, struct aml_tuner *tuner, - enum tuner_type *type) -{ - struct tuner_config *cfg = NULL; - struct i2c_adapter *i2c_adap = NULL; - - if (fe == NULL || tuner == NULL || type == NULL) { - pr_error("%s: NULL pointer.\n", __func__); - return -1; - } - - cfg = &tuner->cfg; - i2c_adap = tuner->i2c_adp; - - switch (cfg->id) { - case AM_TUNER_R840: - if (!dvb_attach(r840_attach, fe, i2c_adap, cfg)) { - pr_error("dvb attach r840_attach tuner error\n"); - return -1; - } else { - pr_error("r840_attach attach sucess\n"); - *type = AM_TUNER_R840; - } - break; - case AM_TUNER_R842: - if (!dvb_attach(r842_attach, fe, i2c_adap, cfg)) { - pr_error("dvb attach r842_attach tuner error\n"); - return -1; - } else { - pr_error("r842_attach attach sucess\n"); - *type = AM_TUNER_R842; - } - break; - case AM_TUNER_SI2151: - if (!dvb_attach(si2151_attach, fe, i2c_adap, cfg)) { - pr_error("dvb attach tuner error\n"); - return -1; - } else { - pr_error("si2151 attach sucess\n"); - *type = AM_TUNER_SI2151; - } - break; - case AM_TUNER_SI2159: - if (!dvb_attach(si2159_attach, fe, i2c_adap, cfg)) { - pr_error("dvb attach si2159_attach tuner error\n"); - return -1; - } else { - pr_error("si2159_attach attach sucess\n"); - *type = AM_TUNER_SI2159; - } - break; - case AM_TUNER_MXL661: - if (!dvb_attach(mxl661_attach, fe, i2c_adap, cfg)) { - pr_error("dvb attach mxl661_attach tuner error\n"); - return -1; - } else { - pr_error("mxl661_attach attach sucess\n"); - *type = AM_TUNER_MXL661; - } - break; - case AM_TUNER_ATBM2040: - if (!dvb_attach(atbm2040_attach, fe, i2c_adap, cfg)) { - pr_error("dvb attach atbm2040_attach tuner error\n"); - return -1; - } else { - pr_error("atbm2040_attach attach sucess\n"); - *type = AM_TUNER_ATBM2040; - } - break; - default: - pr_error("can't support tuner type: %d\n", cfg->id); - break; - } - - return 0; -} -EXPORT_SYMBOL(dvb_attach_tuner); - -int dvb_detach_tuner(enum tuner_type *type) -{ - if (type == NULL) { - pr_error("%s: type == NULL\n", __func__); - return -1; - } - - switch (*type) { - case AM_TUNER_R840: - dvb_detach(r840_attach); - *type = AM_TUNER_NONE; - break; - case AM_TUNER_R842: - dvb_detach(r842_attach); - *type = AM_TUNER_NONE; - break; - case AM_TUNER_SI2151: - dvb_detach(si2151_attach); - *type = AM_TUNER_NONE; - break; - case AM_TUNER_SI2159: - dvb_detach(si2159_attach); - *type = AM_TUNER_NONE; - break; - case AM_TUNER_MXL661: - dvb_detach(mxl661_attach); - *type = AM_TUNER_NONE; - break; - case AM_TUNER_ATBM2040: - dvb_detach(atbm2040_attach); - *type = AM_TUNER_NONE; - break; - default: - pr_error("can't support tuner type: %d\n", *type); - break; - } - - return 0; -} -EXPORT_SYMBOL(dvb_detach_tuner); - -struct dvb_frontend *dvb_attach_demod(struct demod_config *cfg, - enum dtv_demod_type *type, const char *name) -{ - struct dvb_frontend *fe = NULL; - - if (cfg == NULL || type == NULL || name == NULL) { - pr_error("%s: NULL pointer.\n", __func__); - return NULL; - } - - if (!strncmp(name, "internal", strlen("internal"))) { - fe = dvb_attach(aml_dtvdm_attach, cfg); - if (fe) - *type = AM_DTV_DEMOD_AML; - } else if (!strncmp(name, "Si2168", strlen("Si2168"))) { - fe = dvb_attach(si2168_attach, cfg); - if (fe) - *type = AM_DTV_DEMOD_SI2168; - } else if (!strncmp(name, "Si2168-1", strlen("Si2168-1"))) { - fe = dvb_attach(si2168_attach_1, cfg); - if (fe) - *type = AM_DTV_DEMOD_SI2168_1; - } else if (!strncmp(name, "Avl6762", strlen("Avl6762"))) { - fe = dvb_attach(avl6762_attach, cfg); - if (fe) - *type = AM_DTV_DEMOD_AVL6762; - } else if (!strncmp(name, "cxd2856", strlen("cxd2856"))) { - fe = dvb_attach(cxd2856_attach, cfg); - if (fe) - *type = AM_DTV_DEMOD_CXD2856; - } else if (!strncmp(name, "atbm7821", strlen("atbm7821"))) { - fe = dvb_attach(atbm7821_attach, cfg); - if (fe) - *type = AM_DTV_DEMOD_ATBM7821; - } else if (!strncmp(name, "mxl248", strlen("mxl248"))) { - fe = dvb_attach(mxl248_attach, cfg); - if (fe) - *type = AM_DTV_DEMOD_MXL248; - } else { - pr_error("can't support demod type: %s\n", name); - } - - return fe; -} -EXPORT_SYMBOL(dvb_attach_demod); - -int dvb_detach_demod(enum dtv_demod_type *type) -{ - if (type == NULL) { - pr_error("%s: type == NULL\n", __func__); - return -1; - } - - switch (*type) { - case AM_DTV_DEMOD_AML: - dvb_detach(aml_dtvdm_attach); - *type = AM_DTV_DEMOD_NONE; - break; - case AM_DTV_DEMOD_ATBM8881: - dvb_detach(atbm8881_attach); - *type = AM_DTV_DEMOD_NONE; - break; - case AM_DTV_DEMOD_SI2168: - dvb_detach(si2168_attach); - *type = AM_DTV_DEMOD_NONE; - break; - case AM_DTV_DEMOD_SI2168_1: - dvb_detach(si2168_attach_1); - *type = AM_DTV_DEMOD_NONE; - break; - case AM_DTV_DEMOD_AVL6762: - dvb_detach(avl6762_attach); - *type = AM_DTV_DEMOD_NONE; - break; - case AM_DTV_DEMOD_CXD2856: - dvb_detach(cxd2856_attach); - *type = AM_DTV_DEMOD_NONE; - break; - case AM_DTV_DEMOD_ATBM7821: - dvb_detach(atbm7821_attach); - *type = AM_DTV_DEMOD_NONE; - break; - case AM_DTV_DEMOD_MXL248: - dvb_detach(mxl248_attach); - *type = AM_DTV_DEMOD_NONE; - break; - default: - pr_error("can't support demod type: %d\n", *type); - break; - } - - return 0; -} -EXPORT_SYMBOL(dvb_detach_demod); diff --git a/drivers/stream_input/parser/dvb_common.h b/drivers/stream_input/parser/dvb_common.h index f36097c..11850ce 100644 --- a/drivers/stream_input/parser/dvb_common.h +++ b/drivers/stream_input/parser/dvb_common.h @@ -19,6 +19,7 @@ #define __DVB_COMMON_H__ #include <linux/amlogic/aml_dtvdemod.h> +#include <linux/amlogic/aml_tuner.h> #include "dvb_frontend.h" @@ -64,105 +65,4 @@ enum aml_ts_source_t { AM_TS_SRC_DMX2 }; - -extern int dvb_attach_tuner(struct dvb_frontend *fe, struct aml_tuner *tuner, - enum tuner_type *type); -extern int dvb_detach_tuner(enum tuner_type *type); -extern struct dvb_frontend *dvb_attach_demod(struct demod_config *cfg, - enum dtv_demod_type *type, const char *name); -extern int dvb_detach_demod(enum dtv_demod_type *type); - -/* For compile and load warnings */ -static inline struct dvb_frontend *mxl661_attach(struct dvb_frontend *fe, - struct i2c_adapter *i2c_adap, struct tuner_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *si2151_attach(struct dvb_frontend *fe, - struct i2c_adapter *i2c_adap, struct tuner_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *si2159_attach(struct dvb_frontend *fe, - struct i2c_adapter *i2c_adap, struct tuner_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *r840_attach(struct dvb_frontend *fe, - struct i2c_adapter *i2c_adap, struct tuner_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *r842_attach(struct dvb_frontend *fe, - struct i2c_adapter *i2c_adap, struct tuner_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *atbm2040_attach(struct dvb_frontend *fe, - struct i2c_adapter *i2c_adap, struct tuner_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *atbm253_attach(struct dvb_frontend *fe, - struct i2c_adapter *i2c_adap, struct tuner_config *cfg) -{ - return NULL; -} -/* For attach tuner driver end */ - -static inline struct dvb_frontend *atbm8881_attach( - const struct demod_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *si2168_attach( - const struct demod_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *si2168_attach_1( - const struct demod_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *avl6762_attach( - const struct demod_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *atbm7821_attach( - const struct demod_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *mxl248_attach( - const struct demod_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *cxd2856_attach( - const struct demod_config *cfg) -{ - return NULL; -} - -static inline struct dvb_frontend *aml_dtvdm_attach( - const struct demod_config *cfg) -{ - return NULL; -} -/* For attach demod driver end */ - #endif /* __DVB_COMMON_H__ */ diff --git a/drivers/stream_input/parser/hw_demux/aml_dvb.c b/drivers/stream_input/parser/hw_demux/aml_dvb.c index 157bdf4..d7ae3c7 100644 --- a/drivers/stream_input/parser/hw_demux/aml_dvb.c +++ b/drivers/stream_input/parser/hw_demux/aml_dvb.c @@ -1767,9 +1767,13 @@ static ssize_t tuner_setting_store(struct class *class, if (frontend[i] == NULL) continue; - if (dvb_attach_tuner(frontend[i], tuner, &s_tuner_type[i]) < 0) { - pr_error("attach tuner %d failed\n", dvb->tuner_cur); + 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); } } @@ -2305,11 +2309,10 @@ static int aml_dvb_probe(struct platform_device *pdev) //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; - struct device_node *node_i2c = NULL; - u32 i2c_addr = 0xFFFFFFFF; u32 value = 0; int j = 0; @@ -2324,14 +2327,15 @@ static int aml_dvb_probe(struct platform_device *pdev) } if (!strcmp(str, "internal")) { config.mode = 0; - - frontend[i] = dvb_attach_demod(&config, &s_demod_type[i], "internal"); + config.id = AM_DTV_DEMOD_AMLDTV; + frontend[i] = aml_attach_dtvdemod(config.id, &config); if (frontend[i] == NULL) { - pr_error("dvb attach demod error\n"); + s_demod_type[i] = AM_DTV_DEMOD_NONE; + pr_error("internal dtvdemod [type = %d] attach error.\n", config.id); goto error_fe; } else { - pr_inf("dtvdemod attatch sucess\n"); - s_demod_type[i] = AM_DTV_DEMOD_AML; + s_demod_type[i] = config.id; + pr_error("internal dtvdemod [type = %d] attach success.\n", config.id); } memset(buf, 0, 32); @@ -2363,73 +2367,11 @@ static int aml_dvb_probe(struct platform_device *pdev) 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 { - if (!strncmp(str, "mxl661_tuner", 12)) - advb->tuners[j].cfg.id = AM_TUNER_MXL661; - else if (!strncmp(str, "si2151_tuner", 12)) - advb->tuners[j].cfg.id = AM_TUNER_SI2151; - else if (!strncmp(str, "si2159_tuner", 12)) - advb->tuners[j].cfg.id = AM_TUNER_SI2159; - else if (!strncmp(str, "r840_tuner", 10)) - advb->tuners[j].cfg.id = AM_TUNER_R840; - else if (!strncmp(str, "r842_tuner", 10)) - advb->tuners[j].cfg.id = AM_TUNER_R842; - else if (!strncmp(str, "atbm2040_tuner", 14)) - advb->tuners[i].cfg.id = AM_TUNER_ATBM2040; - else { - pr_err("nonsupport tuner: %s.\n", str); - advb->tuners[j].cfg.id = AM_TUNER_NONE; - } - } - - 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].i2c_adp = of_find_i2c_adapter_by_node(node_i2c); - of_node_put(node_i2c); - if (advb->tuners[j].i2c_adp == 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); + ret = aml_get_dts_tuner_config(node_tuner, &advb->tuners[j].cfg, j); if (ret) { - pr_error("i2c_addr error\n"); + pr_err("can't find tuner.\n"); + goto error_fe; } - 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); @@ -2438,9 +2380,14 @@ static int aml_dvb_probe(struct platform_device *pdev) frontend[i]->callback = NULL; if (advb->tuner_cur >= 0) { - if (dvb_attach_tuner(frontend[i], &advb->tuners[advb->tuner_cur], &s_tuner_type[i]) < 0) { - pr_error("attach tuner failed\n"); + 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); } } @@ -2449,132 +2396,40 @@ static int aml_dvb_probe(struct platform_device *pdev) pr_error("register dvb frontend failed\n"); goto error_fe; } - } else if(!strcmp(str,"external")) { - const char *name = NULL; - + } else if(!strcmp(str, "external")) { config.mode = 1; - config.dev_id = i; - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_demod",i); - ret = of_property_read_string(pdev->dev.of_node, buf, &name); + config.id = AM_DTV_DEMOD_NONE; + ret = aml_get_dts_demod_config(pdev->dev.of_node, &config, i); if (ret) { - ret = 0; + pr_err("can't find demod %d.\n", i); continue; } memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_i2c_adap_id",i); - node_i2c = of_parse_phandle(pdev->dev.of_node,buf,0); - if (!node_i2c) { - pr_error("demod%d_i2c_adap_id error\n", i); - } else { - config.i2c_adap = of_find_i2c_adapter_by_node(node_i2c); - of_node_put(node_i2c); - if (config.i2c_adap == NULL) { - pr_error("i2c_get_adapter error\n"); - goto error_fe; - } - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_demod_i2c_addr",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.i2c_addr); - if (ret) { - pr_error("i2c_addr error\n"); - goto error_fe; - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_ts",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.ts); - if (ret) { - pr_error("ts error\n"); - goto error_fe; - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_reset_gpio",i); - ret = of_property_read_string(pdev->dev.of_node, buf, &str); - if (!ret) { - config.reset_gpio = - of_get_named_gpio_flags(pdev->dev.of_node, - buf, 0, NULL); - pr_inf("%s: %d\n", buf, config.reset_gpio); - } else { - config.reset_gpio = -1; - pr_error("cannot find resource \"%s\"\n", buf); - goto error_fe; - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_reset_value",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.reset_value); - if (ret) { - pr_error("reset_value error\n"); - config.reset_value = 0; - goto error_fe; - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_ant_power_gpio", i); - ret = of_property_read_string(pdev->dev.of_node, buf, &str); - if (!ret) { - config.ant_power_gpio = - of_get_named_gpio_flags(pdev->dev.of_node, - buf, 0, NULL); - pr_inf("%s: %d\n", buf, config.ant_power_gpio); - } else { - config.ant_power_gpio = -1; - pr_error("cannot find resource \"%s\"\n", buf); - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_ant_poweron_value", i); - ret = of_property_read_u32(pdev->dev.of_node, buf, &config.ant_power_value); - if (ret) { - pr_error("ant_power_value error\n"); - config.ant_power_value = 0; - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_tuner0_i2c_addr",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.tuner0_i2c_addr); - if (ret) { - pr_error("no tuner0 i2c_addr define\n"); - } - - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_tuner1_i2c_addr",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.tuner1_i2c_addr); - if (ret) { - pr_error("no tuner1 addr define\n"); - } + 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); - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_tuner0_code",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.tuner0_code); - if (ret) { - pr_error("no tuner0_code define\n"); - } + of_node_put(node_tuner); - memset(buf, 0, 32); - snprintf(buf, sizeof(buf), "fe%d_tuner1_code",i); - ret = of_property_read_u32(pdev->dev.of_node, buf,&config.tuner1_code); - if (ret) { - pr_error("no tuner1_code define\n"); - } - if (advb->ts[config.ts].mode == AM_TS_PARALLEL) { + if (advb->ts[config.ts].mode == AM_TS_PARALLEL) config.ts_out_mode = 1; - } else { + else config.ts_out_mode = 0; - } - frontend[i] = dvb_attach_demod(&config, &s_demod_type[i], name); + frontend[i] = aml_attach_dtvdemod(config.id, &config); if (frontend[i] == NULL) { - pr_error("dvb attach demod error\n"); + s_demod_type[i] = AM_DTV_DEMOD_NONE; + pr_error("external dtvdemod [type = %d] attach error.\n", config.id); goto error_fe; - } else - pr_inf("dtvdemod attatch sucess\n"); + } 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]); @@ -2588,11 +2443,11 @@ static int aml_dvb_probe(struct platform_device *pdev) return 0; error_fe: for (i=0; i<FE_DEV_COUNT; i++) { - dvb_detach_demod(&s_demod_type[i]); + aml_detach_dtvdemod(s_demod_type[i]); frontend[i] = NULL; s_demod_type[i] = AM_DTV_DEMOD_NONE; - dvb_detach_tuner(&s_tuner_type[i]); + aml_detach_tuner(s_tuner_type[i]); s_tuner_type[i] = AM_TUNER_NONE; } @@ -2629,9 +2484,9 @@ static int aml_dvb_remove(struct platform_device *pdev) int i; for (i=0; i<FE_DEV_COUNT; i++) { - dvb_detach_demod(&s_demod_type[i]); + aml_detach_dtvdemod(s_demod_type[i]); - dvb_detach_tuner(&s_tuner_type[i]); + aml_detach_tuner(s_tuner_type[i]); if (frontend[i] && ((s_tuner_type[i] == AM_TUNER_SI2151) diff --git a/drivers/stream_input/parser/hw_demux/aml_dvb.h b/drivers/stream_input/parser/hw_demux/aml_dvb.h index 340dc5b..8088a43 100644 --- a/drivers/stream_input/parser/hw_demux/aml_dvb.h +++ b/drivers/stream_input/parser/hw_demux/aml_dvb.h @@ -48,7 +48,6 @@ #include <dvb_filter.h> #include <dvb_net.h> #include <dvb_ringbuffer.h> -#include <dvb_frontend.h> #include <linux/of.h> #include <linux/pinctrl/consumer.h> |