summaryrefslogtreecommitdiff
authornengwen.chen <nengwen.chen@amlogic.com>2020-04-10 06:28:38 (GMT)
committer Nengwen Chen <nengwen.chen@amlogic.com>2020-04-14 02:36:21 (GMT)
commit277c582f25d2de85d6f6e2800944654af39f2aea (patch)
tree602caed661d95e902a09bf412ac060b18a52ea3c
parent3be38e55a54cf2aa0f0a469b5acff571c4d0c3ed (diff)
downloadmedia_modules-277c582f25d2de85d6f6e2800944654af39f2aea.zip
media_modules-277c582f25d2de85d6f6e2800944654af39f2aea.tar.gz
media_modules-277c582f25d2de85d6f6e2800944654af39f2aea.tar.bz2
media_modules: modify tuner and demod attach struct [2/3]
PD#SWPL-23756 Problem: 1.modify tuner and demod attach struct. Solution: 1.modify tuner and demod attach struct. Verify: Verified by tl1, tm2, sm1. Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com> Change-Id: I25bd9859553144c6a71f11c05aaabe0d4b093d71
Diffstat
-rw-r--r--drivers/stream_input/parser/demux/hw_demux/frontend.c191
-rw-r--r--drivers/stream_input/parser/dvb_common.c218
-rw-r--r--drivers/stream_input/parser/dvb_common.h95
-rw-r--r--drivers/stream_input/parser/hw_demux/aml_dvb.c241
4 files changed, 98 insertions, 647 deletions
diff --git a/drivers/stream_input/parser/demux/hw_demux/frontend.c b/drivers/stream_input/parser/demux/hw_demux/frontend.c
index e648c4d..90a70c4 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 stb_store_tuner_setting(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 85a21d5..3b8a208 100644
--- a/drivers/stream_input/parser/dvb_common.h
+++ b/drivers/stream_input/parser/dvb_common.h
@@ -19,101 +19,8 @@
#define __DVB_COMMON_H__
#include <linux/amlogic/aml_dtvdemod.h>
+#include <linux/amlogic/aml_tuner.h>
#include "dvb_frontend.h"
-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;
-}
-/* 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 989f5da..7be153a 100644
--- a/drivers/stream_input/parser/hw_demux/aml_dvb.c
+++ b/drivers/stream_input/parser/hw_demux/aml_dvb.c
@@ -1752,9 +1752,13 @@ static ssize_t stb_store_tuner_setting(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);
}
}
@@ -2170,11 +2174,10 @@ static int aml_dvb_probe(struct platform_device *pdev)
//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;
- struct device_node *node_i2c = NULL;
- u32 i2c_addr = 0xFFFFFFFF;
u32 value = 0;
int j = 0;
@@ -2189,14 +2192,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);
@@ -2228,73 +2232,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);
@@ -2303,9 +2245,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);
}
}
@@ -2314,132 +2261,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]);
@@ -2453,11 +2308,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;
}
@@ -2494,9 +2349,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)